From c9a99a29ab15d993bdd9e095ed4793b5776f8ff6 Mon Sep 17 00:00:00 2001 From: Flavio B Date: Sun, 27 Jul 2025 16:55:56 -0400 Subject: [PATCH 01/13] define CanInvoke --- programs/system/src/lib.rs | 41 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/programs/system/src/lib.rs b/programs/system/src/lib.rs index 35268bc1..45ca8b67 100644 --- a/programs/system/src/lib.rs +++ b/programs/system/src/lib.rs @@ -1,5 +1,46 @@ #![no_std] +use pinocchio::{ + account_info::AccountInfo, + instruction::{AccountMeta, Instruction, Signer}, + pubkey::Pubkey, + ProgramResult, +}; + pub mod instructions; pinocchio_pubkey::declare_id!("11111111111111111111111111111111"); + +pub trait CanInvoke { + fn invoke_via( + &self, + invoke: impl FnOnce( + /* program_id: */ &Pubkey, + /* accounts: */ &[&AccountInfo; ACCOUNTS_LEN], + /* account_metas: */ &[AccountMeta], + /* data: */ &[u8], + ) -> ProgramResult, + ) -> ProgramResult; + + fn invoke(&self) -> ProgramResult { + self.invoke_via(|program_id, accounts, account_metas, data| { + let instruction = Instruction { + program_id: program_id, + accounts: &account_metas, + data: data, + }; + pinocchio::cpi::invoke(&instruction, accounts) + }) + } + + fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult { + self.invoke_via(|program_id, accounts, account_metas, data| { + let instruction = Instruction { + program_id: program_id, + accounts: &account_metas, + data: data, + }; + pinocchio::cpi::invoke_signed(&instruction, accounts, signers) + }) + } +} From 6361ff7c3026058c146108e9ed46b7599570df83 Mon Sep 17 00:00:00 2001 From: Flavio B Date: Sun, 27 Jul 2025 16:56:15 -0400 Subject: [PATCH 02/13] impl CanInvoke for ix --- .../src/instructions/advance_nonce_account.rs | 28 +++++++++++++ programs/system/src/instructions/allocate.rs | 28 +++++++++++++ .../src/instructions/allocate_with_seed.rs | 36 +++++++++++++++++ programs/system/src/instructions/assign.rs | 27 +++++++++++++ .../src/instructions/assign_with_seed.rs | 35 ++++++++++++++++ .../instructions/authorize_nonce_account.rs | 30 ++++++++++++++ .../system/src/instructions/create_account.rs | 31 ++++++++++++++ .../instructions/create_account_with_seed.rs | 38 ++++++++++++++++++ .../instructions/initialize_nonce_account.rs | 35 ++++++++++++++++ programs/system/src/instructions/transfer.rs | 31 ++++++++++++++ .../src/instructions/transfer_with_seed.rs | 36 +++++++++++++++++ .../src/instructions/update_nonce_account.rs | 25 ++++++++++++ .../instructions/withdraw_nonce_account.rs | 40 +++++++++++++++++++ 13 files changed, 420 insertions(+) diff --git a/programs/system/src/instructions/advance_nonce_account.rs b/programs/system/src/instructions/advance_nonce_account.rs index 9b26b1c9..dcd0ea5c 100644 --- a/programs/system/src/instructions/advance_nonce_account.rs +++ b/programs/system/src/instructions/advance_nonce_account.rs @@ -2,9 +2,12 @@ use pinocchio::{ account_info::AccountInfo, instruction::{AccountMeta, Instruction, Signer}, program::invoke_signed, + pubkey::Pubkey, ProgramResult, }; +use crate::CanInvoke; + /// Consumes a stored nonce, replacing it with a successor. /// /// ### Accounts: @@ -51,3 +54,28 @@ impl AdvanceNonceAccount<'_> { ) } } + +const ACCOUNTS_LEN: usize = 3; + +impl CanInvoke for AdvanceNonceAccount<'_> { + fn invoke_via( + &self, + invoke: impl FnOnce( + /* program_id: */ &Pubkey, + /* accounts: */ &[&AccountInfo; ACCOUNTS_LEN], + /* account_metas: */ &[AccountMeta], + /* data: */ &[u8], + ) -> ProgramResult, + ) -> ProgramResult { + invoke( + &crate::ID, + &[self.account, self.recent_blockhashes_sysvar, self.authority], + &[ + AccountMeta::writable(self.account.key()), + AccountMeta::readonly(self.recent_blockhashes_sysvar.key()), + AccountMeta::readonly_signer(self.authority.key()), + ], + &[4], + ) + } +} diff --git a/programs/system/src/instructions/allocate.rs b/programs/system/src/instructions/allocate.rs index 9ebc57f1..c0b281a6 100644 --- a/programs/system/src/instructions/allocate.rs +++ b/programs/system/src/instructions/allocate.rs @@ -2,9 +2,12 @@ use pinocchio::{ account_info::AccountInfo, instruction::{AccountMeta, Instruction, Signer}, program::invoke_signed, + pubkey::Pubkey, ProgramResult, }; +use crate::CanInvoke; + /// Allocate space in a (possibly new) account without funding. /// /// ### Accounts: @@ -44,3 +47,28 @@ impl Allocate<'_> { invoke_signed(&instruction, &[self.account], signers) } } + +const ACCOUNTS_LEN: usize = 1; + +impl CanInvoke for Allocate<'_> { + fn invoke_via( + &self, + invoke: impl FnOnce( + /* program_id: */ &Pubkey, + /* accounts: */ &[&AccountInfo; ACCOUNTS_LEN], + /* account_metas: */ &[AccountMeta], + /* data: */ &[u8], + ) -> ProgramResult, + ) -> ProgramResult { + let mut instruction_data = [0; 12]; + instruction_data[0] = 8; + instruction_data[4..12].copy_from_slice(&self.space.to_le_bytes()); + + invoke( + &crate::ID, + &[self.account], + &[AccountMeta::writable_signer(self.account.key())], + &instruction_data, + ) + } +} diff --git a/programs/system/src/instructions/allocate_with_seed.rs b/programs/system/src/instructions/allocate_with_seed.rs index 423f85b4..3a01bc74 100644 --- a/programs/system/src/instructions/allocate_with_seed.rs +++ b/programs/system/src/instructions/allocate_with_seed.rs @@ -6,6 +6,8 @@ use pinocchio::{ ProgramResult, }; +use crate::CanInvoke; + /// Allocate space for and assign an account at an address derived /// from a base public key and a seed. /// @@ -73,3 +75,37 @@ impl AllocateWithSeed<'_, '_, '_> { invoke_signed(&instruction, &[self.account, self.base], signers) } } + +const ACCOUNTS_LEN: usize = 2; + +impl CanInvoke for AllocateWithSeed<'_, '_, '_> { + fn invoke_via( + &self, + invoke: impl FnOnce( + /* program_id: */ &Pubkey, + /* accounts: */ &[&AccountInfo; ACCOUNTS_LEN], + /* account_metas: */ &[AccountMeta], + /* data: */ &[u8], + ) -> ProgramResult, + ) -> ProgramResult { + let mut instruction_data = [0; 112]; + instruction_data[0] = 9; + instruction_data[4..36].copy_from_slice(self.base.key()); + instruction_data[36..44].copy_from_slice(&u64::to_le_bytes(self.seed.len() as u64)); + + let offset = 44 + self.seed.len(); + instruction_data[44..offset].copy_from_slice(self.seed.as_bytes()); + instruction_data[offset..offset + 8].copy_from_slice(&self.space.to_le_bytes()); + instruction_data[offset + 8..offset + 40].copy_from_slice(self.owner.as_ref()); + + invoke( + &crate::ID, + &[&self.account, &self.base], + &[ + AccountMeta::writable(self.account.key()), + AccountMeta::readonly_signer(self.base.key()), + ], + &instruction_data[..offset + 40], + ) + } +} diff --git a/programs/system/src/instructions/assign.rs b/programs/system/src/instructions/assign.rs index 327a5d3b..c4049766 100644 --- a/programs/system/src/instructions/assign.rs +++ b/programs/system/src/instructions/assign.rs @@ -6,6 +6,8 @@ use pinocchio::{ ProgramResult, }; +use crate::CanInvoke; + /// Assign account to a program /// /// ### Accounts: @@ -45,3 +47,28 @@ impl Assign<'_, '_> { invoke_signed(&instruction, &[self.account], signers) } } + +const ACCOUNTS_LEN: usize = 1; + +impl CanInvoke for Assign<'_, '_> { + fn invoke_via( + &self, + invoke: impl FnOnce( + /* program_id: */ &Pubkey, + /* accounts: */ &[&AccountInfo; ACCOUNTS_LEN], + /* account_metas: */ &[AccountMeta], + /* data: */ &[u8], + ) -> ProgramResult, + ) -> ProgramResult { + let mut instruction_data = [0; 36]; + instruction_data[0] = 1; + instruction_data[4..36].copy_from_slice(self.owner.as_ref()); + + invoke( + &crate::ID, + &[self.account], + &[AccountMeta::writable_signer(self.account.key())], + &instruction_data, + ) + } +} diff --git a/programs/system/src/instructions/assign_with_seed.rs b/programs/system/src/instructions/assign_with_seed.rs index 97d27e03..4be4c197 100644 --- a/programs/system/src/instructions/assign_with_seed.rs +++ b/programs/system/src/instructions/assign_with_seed.rs @@ -6,6 +6,8 @@ use pinocchio::{ ProgramResult, }; +use crate::CanInvoke; + /// Assign account to a program based on a seed. /// /// ### Accounts: @@ -67,3 +69,36 @@ impl AssignWithSeed<'_, '_, '_> { invoke_signed(&instruction, &[self.account, self.base], signers) } } + +const ACCOUNTS_LEN: usize = 2; + +impl CanInvoke for AssignWithSeed<'_, '_, '_> { + fn invoke_via( + &self, + invoke: impl FnOnce( + /* program_id: */ &Pubkey, + /* accounts: */ &[&AccountInfo; ACCOUNTS_LEN], + /* account_metas: */ &[AccountMeta], + /* data: */ &[u8], + ) -> ProgramResult, + ) -> ProgramResult { + let mut instruction_data = [0; 104]; + instruction_data[0] = 10; + instruction_data[4..36].copy_from_slice(self.base.key()); + instruction_data[36..44].copy_from_slice(&u64::to_le_bytes(self.seed.len() as u64)); + + let offset = 44 + self.seed.len(); + instruction_data[44..offset].copy_from_slice(self.seed.as_bytes()); + instruction_data[offset..offset + 32].copy_from_slice(self.owner.as_ref()); + + invoke( + &crate::ID, + &[self.account, self.base], + &[ + AccountMeta::writable(self.account.key()), + AccountMeta::readonly_signer(self.base.key()), + ], + &instruction_data[..offset + 32], + ) + } +} diff --git a/programs/system/src/instructions/authorize_nonce_account.rs b/programs/system/src/instructions/authorize_nonce_account.rs index 3402b1d9..d6679fb6 100644 --- a/programs/system/src/instructions/authorize_nonce_account.rs +++ b/programs/system/src/instructions/authorize_nonce_account.rs @@ -6,6 +6,8 @@ use pinocchio::{ ProgramResult, }; +use crate::CanInvoke; + /// Change the entity authorized to execute nonce instructions on the account. /// /// The `Pubkey` parameter identifies the entity to authorize. @@ -54,3 +56,31 @@ impl AuthorizeNonceAccount<'_, '_> { invoke_signed(&instruction, &[self.account, self.authority], signers) } } + +const ACCOUNTS_LEN: usize = 2; + +impl CanInvoke for AuthorizeNonceAccount<'_, '_> { + fn invoke_via( + &self, + invoke: impl FnOnce( + /* program_id: */ &Pubkey, + /* accounts: */ &[&AccountInfo; ACCOUNTS_LEN], + /* account_metas: */ &[AccountMeta], + /* data: */ &[u8], + ) -> ProgramResult, + ) -> ProgramResult { + let mut instruction_data = [0; 36]; + instruction_data[0] = 7; + instruction_data[4..36].copy_from_slice(self.new_authority); + + invoke( + &crate::ID, + &[self.account, self.authority], + &[ + AccountMeta::writable(self.account.key()), + AccountMeta::readonly_signer(self.authority.key()), + ], + &instruction_data, + ) + } +} diff --git a/programs/system/src/instructions/create_account.rs b/programs/system/src/instructions/create_account.rs index fc804fe8..9ffb66a6 100644 --- a/programs/system/src/instructions/create_account.rs +++ b/programs/system/src/instructions/create_account.rs @@ -6,6 +6,8 @@ use pinocchio::{ ProgramResult, }; +use crate::CanInvoke; + /// Create a new account. /// /// ### Accounts: @@ -62,3 +64,32 @@ impl CreateAccount<'_> { invoke_signed(&instruction, &[self.from, self.to], signers) } } + +const ACCOUNTS_LEN: usize = 2; + +impl CanInvoke for CreateAccount<'_> { + fn invoke_via( + &self, + invoke: impl FnOnce( + /* program_id: */ &Pubkey, + /* accounts: */ &[&AccountInfo; ACCOUNTS_LEN], + /* account_metas: */ &[AccountMeta], + /* data: */ &[u8], + ) -> ProgramResult, + ) -> ProgramResult { + let mut instruction_data = [0; 52]; + instruction_data[4..12].copy_from_slice(&self.lamports.to_le_bytes()); + instruction_data[12..20].copy_from_slice(&self.space.to_le_bytes()); + instruction_data[20..52].copy_from_slice(self.owner.as_ref()); + + invoke( + &crate::ID, + &[self.from, self.to], + &[ + AccountMeta::writable_signer(self.from.key()), + AccountMeta::writable_signer(self.to.key()), + ], + &instruction_data, + ) + } +} diff --git a/programs/system/src/instructions/create_account_with_seed.rs b/programs/system/src/instructions/create_account_with_seed.rs index dd5ad2c7..ec4ed545 100644 --- a/programs/system/src/instructions/create_account_with_seed.rs +++ b/programs/system/src/instructions/create_account_with_seed.rs @@ -6,6 +6,8 @@ use pinocchio::{ ProgramResult, }; +use crate::CanInvoke; + /// Create a new account at an address derived from a base pubkey and a seed. /// /// ### Accounts: @@ -87,3 +89,39 @@ impl CreateAccountWithSeed<'_, '_, '_> { ) } } + +const ACCOUNTS_LEN: usize = 3; + +impl CanInvoke for CreateAccountWithSeed<'_, '_, '_> { + fn invoke_via( + &self, + invoke: impl FnOnce( + /* program_id: */ &Pubkey, + /* accounts: */ &[&AccountInfo; ACCOUNTS_LEN], + /* account_metas: */ &[AccountMeta], + /* data: */ &[u8], + ) -> ProgramResult, + ) -> ProgramResult { + let mut instruction_data = [0; 120]; + instruction_data[0] = 3; + instruction_data[4..36].copy_from_slice(self.base.unwrap_or(self.from).key()); + instruction_data[36..44].copy_from_slice(&u64::to_le_bytes(self.seed.len() as u64)); + + let offset = 44 + self.seed.len(); + instruction_data[44..offset].copy_from_slice(self.seed.as_bytes()); + instruction_data[offset..offset + 8].copy_from_slice(&self.lamports.to_le_bytes()); + instruction_data[offset + 8..offset + 16].copy_from_slice(&self.space.to_le_bytes()); + instruction_data[offset + 16..offset + 48].copy_from_slice(self.owner.as_ref()); + + invoke( + &crate::ID, + &[self.from, self.to, self.base.unwrap_or(self.from)], + &[ + AccountMeta::writable_signer(self.from.key()), + AccountMeta::writable(self.to.key()), + AccountMeta::readonly_signer(self.base.unwrap_or(self.from).key()), + ], + &instruction_data[..offset + 48], + ) + } +} diff --git a/programs/system/src/instructions/initialize_nonce_account.rs b/programs/system/src/instructions/initialize_nonce_account.rs index 9ff050da..1fde46fa 100644 --- a/programs/system/src/instructions/initialize_nonce_account.rs +++ b/programs/system/src/instructions/initialize_nonce_account.rs @@ -6,6 +6,8 @@ use pinocchio::{ ProgramResult, }; +use crate::CanInvoke; + /// Drive state of Uninitialized nonce account to Initialized, setting the nonce value. /// /// The `Pubkey` parameter specifies the entity authorized to execute nonce @@ -74,3 +76,36 @@ impl InitializeNonceAccount<'_, '_> { ) } } + +const ACCOUNTS_LEN: usize = 3; + +impl CanInvoke for InitializeNonceAccount<'_, '_> { + fn invoke_via( + &self, + invoke: impl FnOnce( + /* program_id: */ &Pubkey, + /* accounts: */ &[&AccountInfo; ACCOUNTS_LEN], + /* account_metas: */ &[AccountMeta], + /* data: */ &[u8], + ) -> ProgramResult, + ) -> ProgramResult { + let mut instruction_data = [0; 36]; + instruction_data[0] = 6; + instruction_data[4..36].copy_from_slice(self.authority); + + invoke( + &crate::ID, + &[ + self.account, + self.recent_blockhashes_sysvar, + self.rent_sysvar, + ], + &[ + AccountMeta::writable(self.account.key()), + AccountMeta::readonly(self.recent_blockhashes_sysvar.key()), + AccountMeta::readonly(self.rent_sysvar.key()), + ], + &instruction_data, + ) + } +} diff --git a/programs/system/src/instructions/transfer.rs b/programs/system/src/instructions/transfer.rs index 0444714b..85ba35df 100644 --- a/programs/system/src/instructions/transfer.rs +++ b/programs/system/src/instructions/transfer.rs @@ -2,9 +2,12 @@ use pinocchio::{ account_info::AccountInfo, instruction::{AccountMeta, Instruction, Signer}, program::invoke_signed, + pubkey::Pubkey, ProgramResult, }; +use crate::CanInvoke; + /// Transfer lamports. /// /// ### Accounts: @@ -51,3 +54,31 @@ impl Transfer<'_> { invoke_signed(&instruction, &[self.from, self.to], signers) } } + +const ACCOUNTS_LEN: usize = 2; + +impl CanInvoke for Transfer<'_> { + fn invoke_via( + &self, + invoke: impl FnOnce( + /* program_id: */ &Pubkey, + /* accounts: */ &[&AccountInfo; ACCOUNTS_LEN], + /* account_metas: */ &[AccountMeta], + /* data: */ &[u8], + ) -> ProgramResult, + ) -> ProgramResult { + let mut instruction_data = [0; 12]; + instruction_data[0] = 2; + instruction_data[4..12].copy_from_slice(&self.lamports.to_le_bytes()); + + invoke( + &crate::ID, + &[self.from, self.to], + &[ + AccountMeta::writable_signer(self.from.key()), + AccountMeta::writable(self.to.key()), + ], + &instruction_data, + ) + } +} diff --git a/programs/system/src/instructions/transfer_with_seed.rs b/programs/system/src/instructions/transfer_with_seed.rs index 38581078..4795b616 100644 --- a/programs/system/src/instructions/transfer_with_seed.rs +++ b/programs/system/src/instructions/transfer_with_seed.rs @@ -6,6 +6,8 @@ use pinocchio::{ ProgramResult, }; +use crate::CanInvoke; + /// Transfer lamports from a derived address. /// /// ### Accounts: @@ -75,3 +77,37 @@ impl TransferWithSeed<'_, '_, '_> { invoke_signed(&instruction, &[self.from, self.base, self.to], signers) } } + +const ACCOUNTS_LEN: usize = 3; + +impl CanInvoke for TransferWithSeed<'_, '_, '_> { + fn invoke_via( + &self, + invoke: impl FnOnce( + /* program_id: */ &Pubkey, + /* accounts: */ &[&AccountInfo; ACCOUNTS_LEN], + /* account_metas: */ &[AccountMeta], + /* data: */ &[u8], + ) -> ProgramResult, + ) -> ProgramResult { + let mut instruction_data = [0; 80]; + instruction_data[0] = 11; + instruction_data[4..12].copy_from_slice(&self.lamports.to_le_bytes()); + instruction_data[12..20].copy_from_slice(&u64::to_le_bytes(self.seed.len() as u64)); + + let offset = 20 + self.seed.len(); + instruction_data[20..offset].copy_from_slice(self.seed.as_bytes()); + instruction_data[offset..offset + 32].copy_from_slice(self.owner.as_ref()); + + invoke( + &crate::ID, + &[self.from, self.base, self.to], + &[ + AccountMeta::writable(self.from.key()), + AccountMeta::readonly_signer(self.base.key()), + AccountMeta::writable(self.to.key()), + ], + &instruction_data[..offset + 32], + ) + } +} diff --git a/programs/system/src/instructions/update_nonce_account.rs b/programs/system/src/instructions/update_nonce_account.rs index 92b69aa1..771a6e44 100644 --- a/programs/system/src/instructions/update_nonce_account.rs +++ b/programs/system/src/instructions/update_nonce_account.rs @@ -2,9 +2,12 @@ use pinocchio::{ account_info::AccountInfo, instruction::{AccountMeta, Instruction, Signer}, program::invoke_signed, + pubkey::Pubkey, ProgramResult, }; +use crate::CanInvoke; + /// One-time idempotent upgrade of legacy nonce versions in order to bump /// them out of chain blockhash domain. /// @@ -36,3 +39,25 @@ impl UpdateNonceAccount<'_> { invoke_signed(&instruction, &[self.account], signers) } } + +const ACCOUNTS_LEN: usize = 1; + +impl CanInvoke for UpdateNonceAccount<'_> { + fn invoke_via( + &self, + invoke: impl FnOnce( + /* program_id: */ &Pubkey, + /* accounts: */ &[&AccountInfo; 1], + /* account_metas: */ &[AccountMeta], + /* data: */ &[u8], + ) -> ProgramResult, + ) -> ProgramResult { + let instruction_data = [12]; + invoke( + &crate::ID, + &[self.account], + &[AccountMeta::writable(self.account.key())], + &instruction_data, + ) + } +} diff --git a/programs/system/src/instructions/withdraw_nonce_account.rs b/programs/system/src/instructions/withdraw_nonce_account.rs index 2f21593c..ddb86489 100644 --- a/programs/system/src/instructions/withdraw_nonce_account.rs +++ b/programs/system/src/instructions/withdraw_nonce_account.rs @@ -2,9 +2,12 @@ use pinocchio::{ account_info::AccountInfo, instruction::{AccountMeta, Instruction, Signer}, program::invoke_signed, + pubkey::Pubkey, ProgramResult, }; +use crate::CanInvoke; + /// Withdraw funds from a nonce account. /// /// The `u64` parameter is the lamports to withdraw, which must leave the @@ -82,3 +85,40 @@ impl WithdrawNonceAccount<'_> { ) } } + +const ACCOUNTS_LEN: usize = 5; + +impl CanInvoke for WithdrawNonceAccount<'_> { + fn invoke_via( + &self, + invoke: impl FnOnce( + /* program_id: */ &Pubkey, + /* accounts: */ &[&AccountInfo; ACCOUNTS_LEN], + /* account_metas: */ &[AccountMeta], + /* data: */ &[u8], + ) -> ProgramResult, + ) -> ProgramResult { + let mut instruction_data = [0; 12]; + instruction_data[0] = 5; + instruction_data[4..12].copy_from_slice(&self.lamports.to_le_bytes()); + + invoke( + &crate::ID, + &[ + self.account, + self.recipient, + self.recent_blockhashes_sysvar, + self.rent_sysvar, + self.authority, + ], + &[ + AccountMeta::writable(self.account.key()), + AccountMeta::writable(self.recipient.key()), + AccountMeta::readonly(self.recent_blockhashes_sysvar.key()), + AccountMeta::readonly(self.rent_sysvar.key()), + AccountMeta::readonly_signer(self.authority.key()), + ], + &instruction_data, + ) + } +} From b8e5969978ccdfb35ca027dbced5358b8fba76db Mon Sep 17 00:00:00 2001 From: Flavio B Date: Sun, 27 Jul 2025 17:02:20 -0400 Subject: [PATCH 03/13] remove struct impls --- .../src/instructions/advance_nonce_account.rs | 36 +---------- programs/system/src/instructions/allocate.rs | 37 ++--------- .../src/instructions/allocate_with_seed.rs | 54 +++------------- programs/system/src/instructions/assign.rs | 37 ++--------- .../src/instructions/assign_with_seed.rs | 51 +++------------ .../instructions/authorize_nonce_account.rs | 40 ++---------- .../system/src/instructions/create_account.rs | 46 ++------------ .../instructions/create_account_with_seed.rs | 62 +++---------------- .../instructions/initialize_nonce_account.rs | 49 ++------------- programs/system/src/instructions/transfer.rs | 40 ++---------- .../src/instructions/transfer_with_seed.rs | 52 +++------------- .../src/instructions/update_nonce_account.rs | 31 +--------- .../instructions/withdraw_nonce_account.rs | 53 ++-------------- 13 files changed, 64 insertions(+), 524 deletions(-) diff --git a/programs/system/src/instructions/advance_nonce_account.rs b/programs/system/src/instructions/advance_nonce_account.rs index dcd0ea5c..1113a1ca 100644 --- a/programs/system/src/instructions/advance_nonce_account.rs +++ b/programs/system/src/instructions/advance_nonce_account.rs @@ -1,9 +1,5 @@ use pinocchio::{ - account_info::AccountInfo, - instruction::{AccountMeta, Instruction, Signer}, - program::invoke_signed, - pubkey::Pubkey, - ProgramResult, + account_info::AccountInfo, instruction::AccountMeta, pubkey::Pubkey, ProgramResult, }; use crate::CanInvoke; @@ -25,36 +21,6 @@ pub struct AdvanceNonceAccount<'a> { pub authority: &'a AccountInfo, } -impl AdvanceNonceAccount<'_> { - #[inline(always)] - pub fn invoke(&self) -> ProgramResult { - self.invoke_signed(&[]) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult { - // account metadata - let account_metas: [AccountMeta; 3] = [ - AccountMeta::writable(self.account.key()), - AccountMeta::readonly(self.recent_blockhashes_sysvar.key()), - AccountMeta::readonly_signer(self.authority.key()), - ]; - - // instruction - let instruction = Instruction { - program_id: &crate::ID, - accounts: &account_metas, - data: &[4], - }; - - invoke_signed( - &instruction, - &[self.account, self.recent_blockhashes_sysvar, self.authority], - signers, - ) - } -} - const ACCOUNTS_LEN: usize = 3; impl CanInvoke for AdvanceNonceAccount<'_> { diff --git a/programs/system/src/instructions/allocate.rs b/programs/system/src/instructions/allocate.rs index c0b281a6..c89f7183 100644 --- a/programs/system/src/instructions/allocate.rs +++ b/programs/system/src/instructions/allocate.rs @@ -1,9 +1,5 @@ use pinocchio::{ - account_info::AccountInfo, - instruction::{AccountMeta, Instruction, Signer}, - program::invoke_signed, - pubkey::Pubkey, - ProgramResult, + account_info::AccountInfo, instruction::AccountMeta, pubkey::Pubkey, ProgramResult, }; use crate::CanInvoke; @@ -20,34 +16,6 @@ pub struct Allocate<'a> { pub space: u64, } -impl Allocate<'_> { - #[inline(always)] - pub fn invoke(&self) -> ProgramResult { - self.invoke_signed(&[]) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult { - // account metadata - let account_metas: [AccountMeta; 1] = [AccountMeta::writable_signer(self.account.key())]; - - // instruction data - // - [0..4 ]: instruction discriminator - // - [4..12]: space - let mut instruction_data = [0; 12]; - instruction_data[0] = 8; - instruction_data[4..12].copy_from_slice(&self.space.to_le_bytes()); - - let instruction = Instruction { - program_id: &crate::ID, - accounts: &account_metas, - data: &instruction_data, - }; - - invoke_signed(&instruction, &[self.account], signers) - } -} - const ACCOUNTS_LEN: usize = 1; impl CanInvoke for Allocate<'_> { @@ -60,6 +28,9 @@ impl CanInvoke for Allocate<'_> { /* data: */ &[u8], ) -> ProgramResult, ) -> ProgramResult { + // instruction data + // - [0..4 ]: instruction discriminator + // - [4..12]: space let mut instruction_data = [0; 12]; instruction_data[0] = 8; instruction_data[4..12].copy_from_slice(&self.space.to_le_bytes()); diff --git a/programs/system/src/instructions/allocate_with_seed.rs b/programs/system/src/instructions/allocate_with_seed.rs index 3a01bc74..e11706c0 100644 --- a/programs/system/src/instructions/allocate_with_seed.rs +++ b/programs/system/src/instructions/allocate_with_seed.rs @@ -1,9 +1,5 @@ use pinocchio::{ - account_info::AccountInfo, - instruction::{AccountMeta, Instruction, Signer}, - program::invoke_signed, - pubkey::Pubkey, - ProgramResult, + account_info::AccountInfo, instruction::AccountMeta, pubkey::Pubkey, ProgramResult, }; use crate::CanInvoke; @@ -35,47 +31,6 @@ pub struct AllocateWithSeed<'a, 'b, 'c> { pub owner: &'c Pubkey, } -impl AllocateWithSeed<'_, '_, '_> { - #[inline(always)] - pub fn invoke(&self) -> ProgramResult { - self.invoke_signed(&[]) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult { - // account metadata - let account_metas: [AccountMeta; 2] = [ - AccountMeta::writable(self.account.key()), - AccountMeta::readonly_signer(self.base.key()), - ]; - - // instruction data - // - [0..4 ]: instruction discriminator - // - [4..36 ]: base pubkey - // - [36..44]: seed length - // - [44.. ]: seed (max 32) - // - [.. +8]: account space - // - [.. +32]: owner pubkey - let mut instruction_data = [0; 112]; - instruction_data[0] = 9; - instruction_data[4..36].copy_from_slice(self.base.key()); - instruction_data[36..44].copy_from_slice(&u64::to_le_bytes(self.seed.len() as u64)); - - let offset = 44 + self.seed.len(); - instruction_data[44..offset].copy_from_slice(self.seed.as_bytes()); - instruction_data[offset..offset + 8].copy_from_slice(&self.space.to_le_bytes()); - instruction_data[offset + 8..offset + 40].copy_from_slice(self.owner.as_ref()); - - let instruction = Instruction { - program_id: &crate::ID, - accounts: &account_metas, - data: &instruction_data[..offset + 40], - }; - - invoke_signed(&instruction, &[self.account, self.base], signers) - } -} - const ACCOUNTS_LEN: usize = 2; impl CanInvoke for AllocateWithSeed<'_, '_, '_> { @@ -88,6 +43,13 @@ impl CanInvoke for AllocateWithSeed<'_, '_, '_> { /* data: */ &[u8], ) -> ProgramResult, ) -> ProgramResult { + // instruction data + // - [0..4 ]: instruction discriminator + // - [4..36 ]: base pubkey + // - [36..44]: seed length + // - [44.. ]: seed (max 32) + // - [.. +8]: account space + // - [.. +32]: owner pubkey let mut instruction_data = [0; 112]; instruction_data[0] = 9; instruction_data[4..36].copy_from_slice(self.base.key()); diff --git a/programs/system/src/instructions/assign.rs b/programs/system/src/instructions/assign.rs index c4049766..7c4998f7 100644 --- a/programs/system/src/instructions/assign.rs +++ b/programs/system/src/instructions/assign.rs @@ -1,9 +1,5 @@ use pinocchio::{ - account_info::AccountInfo, - instruction::{AccountMeta, Instruction, Signer}, - program::invoke_signed, - pubkey::Pubkey, - ProgramResult, + account_info::AccountInfo, instruction::AccountMeta, pubkey::Pubkey, ProgramResult, }; use crate::CanInvoke; @@ -20,34 +16,6 @@ pub struct Assign<'a, 'b> { pub owner: &'b Pubkey, } -impl Assign<'_, '_> { - #[inline(always)] - pub fn invoke(&self) -> ProgramResult { - self.invoke_signed(&[]) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult { - // account metadata - let account_metas: [AccountMeta; 1] = [AccountMeta::writable_signer(self.account.key())]; - - // instruction data - // - [0..4 ]: instruction discriminator - // - [4..36]: owner pubkey - let mut instruction_data = [0; 36]; - instruction_data[0] = 1; - instruction_data[4..36].copy_from_slice(self.owner.as_ref()); - - let instruction = Instruction { - program_id: &crate::ID, - accounts: &account_metas, - data: &instruction_data, - }; - - invoke_signed(&instruction, &[self.account], signers) - } -} - const ACCOUNTS_LEN: usize = 1; impl CanInvoke for Assign<'_, '_> { @@ -60,6 +28,9 @@ impl CanInvoke for Assign<'_, '_> { /* data: */ &[u8], ) -> ProgramResult, ) -> ProgramResult { + // instruction data + // - [0..4 ]: instruction discriminator + // - [4..36]: owner pubkey let mut instruction_data = [0; 36]; instruction_data[0] = 1; instruction_data[4..36].copy_from_slice(self.owner.as_ref()); diff --git a/programs/system/src/instructions/assign_with_seed.rs b/programs/system/src/instructions/assign_with_seed.rs index 4be4c197..d3e4c165 100644 --- a/programs/system/src/instructions/assign_with_seed.rs +++ b/programs/system/src/instructions/assign_with_seed.rs @@ -1,9 +1,5 @@ use pinocchio::{ - account_info::AccountInfo, - instruction::{AccountMeta, Instruction, Signer}, - program::invoke_signed, - pubkey::Pubkey, - ProgramResult, + account_info::AccountInfo, instruction::AccountMeta, pubkey::Pubkey, ProgramResult, }; use crate::CanInvoke; @@ -31,45 +27,6 @@ pub struct AssignWithSeed<'a, 'b, 'c> { pub owner: &'c Pubkey, } -impl AssignWithSeed<'_, '_, '_> { - #[inline(always)] - pub fn invoke(&self) -> ProgramResult { - self.invoke_signed(&[]) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult { - // account metadata - let account_metas: [AccountMeta; 2] = [ - AccountMeta::writable(self.account.key()), - AccountMeta::readonly_signer(self.base.key()), - ]; - - // instruction data - // - [0..4 ]: instruction discriminator - // - [4..36 ]: base pubkey - // - [36..44]: seed length - // - [44.. ]: seed (max 32) - // - [.. +32]: owner pubkey - let mut instruction_data = [0; 104]; - instruction_data[0] = 10; - instruction_data[4..36].copy_from_slice(self.base.key()); - instruction_data[36..44].copy_from_slice(&u64::to_le_bytes(self.seed.len() as u64)); - - let offset = 44 + self.seed.len(); - instruction_data[44..offset].copy_from_slice(self.seed.as_bytes()); - instruction_data[offset..offset + 32].copy_from_slice(self.owner.as_ref()); - - let instruction = Instruction { - program_id: &crate::ID, - accounts: &account_metas, - data: &instruction_data[..offset + 32], - }; - - invoke_signed(&instruction, &[self.account, self.base], signers) - } -} - const ACCOUNTS_LEN: usize = 2; impl CanInvoke for AssignWithSeed<'_, '_, '_> { @@ -82,6 +39,12 @@ impl CanInvoke for AssignWithSeed<'_, '_, '_> { /* data: */ &[u8], ) -> ProgramResult, ) -> ProgramResult { + // instruction data + // - [0..4 ]: instruction discriminator + // - [4..36 ]: base pubkey + // - [36..44]: seed length + // - [44.. ]: seed (max 32) + // - [.. +32]: owner pubkey let mut instruction_data = [0; 104]; instruction_data[0] = 10; instruction_data[4..36].copy_from_slice(self.base.key()); diff --git a/programs/system/src/instructions/authorize_nonce_account.rs b/programs/system/src/instructions/authorize_nonce_account.rs index d6679fb6..00dabe9d 100644 --- a/programs/system/src/instructions/authorize_nonce_account.rs +++ b/programs/system/src/instructions/authorize_nonce_account.rs @@ -1,9 +1,5 @@ use pinocchio::{ - account_info::AccountInfo, - instruction::{AccountMeta, Instruction, Signer}, - program::invoke_signed, - pubkey::Pubkey, - ProgramResult, + account_info::AccountInfo, instruction::AccountMeta, pubkey::Pubkey, ProgramResult, }; use crate::CanInvoke; @@ -26,37 +22,6 @@ pub struct AuthorizeNonceAccount<'a, 'b> { pub new_authority: &'b Pubkey, } -impl AuthorizeNonceAccount<'_, '_> { - #[inline(always)] - pub fn invoke(&self) -> ProgramResult { - self.invoke_signed(&[]) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult { - // account metadata - let account_metas: [AccountMeta; 2] = [ - AccountMeta::writable(self.account.key()), - AccountMeta::readonly_signer(self.authority.key()), - ]; - - // instruction data - // - [0..4 ]: instruction discriminator - // - [4..12]: lamports - let mut instruction_data = [0; 36]; - instruction_data[0] = 7; - instruction_data[4..36].copy_from_slice(self.new_authority); - - let instruction = Instruction { - program_id: &crate::ID, - accounts: &account_metas, - data: &instruction_data, - }; - - invoke_signed(&instruction, &[self.account, self.authority], signers) - } -} - const ACCOUNTS_LEN: usize = 2; impl CanInvoke for AuthorizeNonceAccount<'_, '_> { @@ -69,6 +34,9 @@ impl CanInvoke for AuthorizeNonceAccount<'_, '_> { /* data: */ &[u8], ) -> ProgramResult, ) -> ProgramResult { + // instruction data + // - [0..4 ]: instruction discriminator + // - [4..12]: lamports let mut instruction_data = [0; 36]; instruction_data[0] = 7; instruction_data[4..36].copy_from_slice(self.new_authority); diff --git a/programs/system/src/instructions/create_account.rs b/programs/system/src/instructions/create_account.rs index 9ffb66a6..02f6cc3a 100644 --- a/programs/system/src/instructions/create_account.rs +++ b/programs/system/src/instructions/create_account.rs @@ -1,9 +1,5 @@ use pinocchio::{ - account_info::AccountInfo, - instruction::{AccountMeta, Instruction, Signer}, - program::invoke_signed, - pubkey::Pubkey, - ProgramResult, + account_info::AccountInfo, instruction::AccountMeta, pubkey::Pubkey, ProgramResult, }; use crate::CanInvoke; @@ -30,41 +26,6 @@ pub struct CreateAccount<'a> { pub owner: &'a Pubkey, } -impl CreateAccount<'_> { - #[inline(always)] - pub fn invoke(&self) -> ProgramResult { - self.invoke_signed(&[]) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult { - // account metadata - let account_metas: [AccountMeta; 2] = [ - AccountMeta::writable_signer(self.from.key()), - AccountMeta::writable_signer(self.to.key()), - ]; - - // instruction data - // - [0..4 ]: instruction discriminator - // - [4..12 ]: lamports - // - [12..20]: account space - // - [20..52]: owner pubkey - let mut instruction_data = [0; 52]; - // create account instruction has a '0' discriminator - instruction_data[4..12].copy_from_slice(&self.lamports.to_le_bytes()); - instruction_data[12..20].copy_from_slice(&self.space.to_le_bytes()); - instruction_data[20..52].copy_from_slice(self.owner.as_ref()); - - let instruction = Instruction { - program_id: &crate::ID, - accounts: &account_metas, - data: &instruction_data, - }; - - invoke_signed(&instruction, &[self.from, self.to], signers) - } -} - const ACCOUNTS_LEN: usize = 2; impl CanInvoke for CreateAccount<'_> { @@ -77,6 +38,11 @@ impl CanInvoke for CreateAccount<'_> { /* data: */ &[u8], ) -> ProgramResult, ) -> ProgramResult { + // instruction data + // - [0..4 ]: instruction discriminator + // - [4..12 ]: lamports + // - [12..20]: account space + // - [20..52]: owner pubkey let mut instruction_data = [0; 52]; instruction_data[4..12].copy_from_slice(&self.lamports.to_le_bytes()); instruction_data[12..20].copy_from_slice(&self.space.to_le_bytes()); diff --git a/programs/system/src/instructions/create_account_with_seed.rs b/programs/system/src/instructions/create_account_with_seed.rs index ec4ed545..71fb7b7c 100644 --- a/programs/system/src/instructions/create_account_with_seed.rs +++ b/programs/system/src/instructions/create_account_with_seed.rs @@ -1,9 +1,5 @@ use pinocchio::{ - account_info::AccountInfo, - instruction::{AccountMeta, Instruction, Signer}, - program::invoke_signed, - pubkey::Pubkey, - ProgramResult, + account_info::AccountInfo, instruction::AccountMeta, pubkey::Pubkey, ProgramResult, }; use crate::CanInvoke; @@ -42,54 +38,6 @@ pub struct CreateAccountWithSeed<'a, 'b, 'c> { pub owner: &'c Pubkey, } -impl CreateAccountWithSeed<'_, '_, '_> { - #[inline(always)] - pub fn invoke(&self) -> ProgramResult { - self.invoke_signed(&[]) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult { - // account metadata - let account_metas: [AccountMeta; 3] = [ - AccountMeta::writable_signer(self.from.key()), - AccountMeta::writable(self.to.key()), - AccountMeta::readonly_signer(self.base.unwrap_or(self.from).key()), - ]; - - // instruction data - // - [0..4 ]: instruction discriminator - // - [4..36 ]: base pubkey - // - [36..44]: seed length - // - [44.. ]: seed (max 32) - // - [.. +8]: lamports - // - [.. +8]: account space - // - [.. +32]: owner pubkey - let mut instruction_data = [0; 120]; - instruction_data[0] = 3; - instruction_data[4..36].copy_from_slice(self.base.unwrap_or(self.from).key()); - instruction_data[36..44].copy_from_slice(&u64::to_le_bytes(self.seed.len() as u64)); - - let offset = 44 + self.seed.len(); - instruction_data[44..offset].copy_from_slice(self.seed.as_bytes()); - instruction_data[offset..offset + 8].copy_from_slice(&self.lamports.to_le_bytes()); - instruction_data[offset + 8..offset + 16].copy_from_slice(&self.space.to_le_bytes()); - instruction_data[offset + 16..offset + 48].copy_from_slice(self.owner.as_ref()); - - let instruction = Instruction { - program_id: &crate::ID, - accounts: &account_metas, - data: &instruction_data[..offset + 48], - }; - - invoke_signed( - &instruction, - &[self.from, self.to, self.base.unwrap_or(self.from)], - signers, - ) - } -} - const ACCOUNTS_LEN: usize = 3; impl CanInvoke for CreateAccountWithSeed<'_, '_, '_> { @@ -102,6 +50,14 @@ impl CanInvoke for CreateAccountWithSeed<'_, '_, '_> { /* data: */ &[u8], ) -> ProgramResult, ) -> ProgramResult { + // instruction data + // - [0..4 ]: instruction discriminator + // - [4..36 ]: base pubkey + // - [36..44]: seed length + // - [44.. ]: seed (max 32) + // - [.. +8]: lamports + // - [.. +8]: account space + // - [.. +32]: owner pubkey let mut instruction_data = [0; 120]; instruction_data[0] = 3; instruction_data[4..36].copy_from_slice(self.base.unwrap_or(self.from).key()); diff --git a/programs/system/src/instructions/initialize_nonce_account.rs b/programs/system/src/instructions/initialize_nonce_account.rs index 1fde46fa..1fbf6cd4 100644 --- a/programs/system/src/instructions/initialize_nonce_account.rs +++ b/programs/system/src/instructions/initialize_nonce_account.rs @@ -1,9 +1,5 @@ use pinocchio::{ - account_info::AccountInfo, - instruction::{AccountMeta, Instruction, Signer}, - program::invoke_signed, - pubkey::Pubkey, - ProgramResult, + account_info::AccountInfo, instruction::AccountMeta, pubkey::Pubkey, ProgramResult, }; use crate::CanInvoke; @@ -37,46 +33,6 @@ pub struct InitializeNonceAccount<'a, 'b> { pub authority: &'b Pubkey, } -impl InitializeNonceAccount<'_, '_> { - #[inline(always)] - pub fn invoke(&self) -> ProgramResult { - self.invoke_signed(&[]) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult { - // account metadata - let account_metas: [AccountMeta; 3] = [ - AccountMeta::writable(self.account.key()), - AccountMeta::readonly(self.recent_blockhashes_sysvar.key()), - AccountMeta::readonly(self.rent_sysvar.key()), - ]; - - // instruction data - // - [0..4 ]: instruction discriminator - // - [4..36]: authority pubkey - let mut instruction_data = [0; 36]; - instruction_data[0] = 6; - instruction_data[4..36].copy_from_slice(self.authority); - - let instruction = Instruction { - program_id: &crate::ID, - accounts: &account_metas, - data: &instruction_data, - }; - - invoke_signed( - &instruction, - &[ - self.account, - self.recent_blockhashes_sysvar, - self.rent_sysvar, - ], - signers, - ) - } -} - const ACCOUNTS_LEN: usize = 3; impl CanInvoke for InitializeNonceAccount<'_, '_> { @@ -89,6 +45,9 @@ impl CanInvoke for InitializeNonceAccount<'_, '_> { /* data: */ &[u8], ) -> ProgramResult, ) -> ProgramResult { + // instruction data + // - [0..4 ]: instruction discriminator + // - [4..36]: authority pubkey let mut instruction_data = [0; 36]; instruction_data[0] = 6; instruction_data[4..36].copy_from_slice(self.authority); diff --git a/programs/system/src/instructions/transfer.rs b/programs/system/src/instructions/transfer.rs index 85ba35df..8f8a3034 100644 --- a/programs/system/src/instructions/transfer.rs +++ b/programs/system/src/instructions/transfer.rs @@ -1,9 +1,5 @@ use pinocchio::{ - account_info::AccountInfo, - instruction::{AccountMeta, Instruction, Signer}, - program::invoke_signed, - pubkey::Pubkey, - ProgramResult, + account_info::AccountInfo, instruction::AccountMeta, pubkey::Pubkey, ProgramResult, }; use crate::CanInvoke; @@ -24,37 +20,6 @@ pub struct Transfer<'a> { pub lamports: u64, } -impl Transfer<'_> { - #[inline(always)] - pub fn invoke(&self) -> ProgramResult { - self.invoke_signed(&[]) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult { - // account metadata - let account_metas: [AccountMeta; 2] = [ - AccountMeta::writable_signer(self.from.key()), - AccountMeta::writable(self.to.key()), - ]; - - // instruction data - // - [0..4 ]: instruction discriminator - // - [4..12]: lamports amount - let mut instruction_data = [0; 12]; - instruction_data[0] = 2; - instruction_data[4..12].copy_from_slice(&self.lamports.to_le_bytes()); - - let instruction = Instruction { - program_id: &crate::ID, - accounts: &account_metas, - data: &instruction_data, - }; - - invoke_signed(&instruction, &[self.from, self.to], signers) - } -} - const ACCOUNTS_LEN: usize = 2; impl CanInvoke for Transfer<'_> { @@ -67,6 +32,9 @@ impl CanInvoke for Transfer<'_> { /* data: */ &[u8], ) -> ProgramResult, ) -> ProgramResult { + // instruction data + // - [0..4 ]: instruction discriminator + // - [4..12]: lamports amount let mut instruction_data = [0; 12]; instruction_data[0] = 2; instruction_data[4..12].copy_from_slice(&self.lamports.to_le_bytes()); diff --git a/programs/system/src/instructions/transfer_with_seed.rs b/programs/system/src/instructions/transfer_with_seed.rs index 4795b616..f174f0ab 100644 --- a/programs/system/src/instructions/transfer_with_seed.rs +++ b/programs/system/src/instructions/transfer_with_seed.rs @@ -1,9 +1,5 @@ use pinocchio::{ - account_info::AccountInfo, - instruction::{AccountMeta, Instruction, Signer}, - program::invoke_signed, - pubkey::Pubkey, - ProgramResult, + account_info::AccountInfo, instruction::AccountMeta, pubkey::Pubkey, ProgramResult, }; use crate::CanInvoke; @@ -38,46 +34,6 @@ pub struct TransferWithSeed<'a, 'b, 'c> { pub owner: &'c Pubkey, } -impl TransferWithSeed<'_, '_, '_> { - #[inline(always)] - pub fn invoke(&self) -> ProgramResult { - self.invoke_signed(&[]) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult { - // account metadata - let account_metas: [AccountMeta; 3] = [ - AccountMeta::writable(self.from.key()), - AccountMeta::readonly_signer(self.base.key()), - AccountMeta::writable(self.to.key()), - ]; - - // instruction data - // - [0..4 ]: instruction discriminator - // - [4..12 ]: lamports amount - // - [12..20]: seed length - // - [20.. ]: seed (max 32) - // - [.. +32]: owner pubkey - let mut instruction_data = [0; 80]; - instruction_data[0] = 11; - instruction_data[4..12].copy_from_slice(&self.lamports.to_le_bytes()); - instruction_data[12..20].copy_from_slice(&u64::to_le_bytes(self.seed.len() as u64)); - - let offset = 20 + self.seed.len(); - instruction_data[20..offset].copy_from_slice(self.seed.as_bytes()); - instruction_data[offset..offset + 32].copy_from_slice(self.owner.as_ref()); - - let instruction = Instruction { - program_id: &crate::ID, - accounts: &account_metas, - data: &instruction_data[..offset + 32], - }; - - invoke_signed(&instruction, &[self.from, self.base, self.to], signers) - } -} - const ACCOUNTS_LEN: usize = 3; impl CanInvoke for TransferWithSeed<'_, '_, '_> { @@ -90,6 +46,12 @@ impl CanInvoke for TransferWithSeed<'_, '_, '_> { /* data: */ &[u8], ) -> ProgramResult, ) -> ProgramResult { + // instruction data + // - [0..4 ]: instruction discriminator + // - [4..12 ]: lamports amount + // - [12..20]: seed length + // - [20.. ]: seed (max 32) + // - [.. +32]: owner pubkey let mut instruction_data = [0; 80]; instruction_data[0] = 11; instruction_data[4..12].copy_from_slice(&self.lamports.to_le_bytes()); diff --git a/programs/system/src/instructions/update_nonce_account.rs b/programs/system/src/instructions/update_nonce_account.rs index 771a6e44..6b65be27 100644 --- a/programs/system/src/instructions/update_nonce_account.rs +++ b/programs/system/src/instructions/update_nonce_account.rs @@ -1,9 +1,5 @@ use pinocchio::{ - account_info::AccountInfo, - instruction::{AccountMeta, Instruction, Signer}, - program::invoke_signed, - pubkey::Pubkey, - ProgramResult, + account_info::AccountInfo, instruction::AccountMeta, pubkey::Pubkey, ProgramResult, }; use crate::CanInvoke; @@ -18,28 +14,6 @@ pub struct UpdateNonceAccount<'a> { pub account: &'a AccountInfo, } -impl UpdateNonceAccount<'_> { - #[inline(always)] - pub fn invoke(&self) -> ProgramResult { - self.invoke_signed(&[]) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult { - // account metadata - let account_metas: [AccountMeta; 1] = [AccountMeta::writable(self.account.key())]; - - // instruction - let instruction = Instruction { - program_id: &crate::ID, - accounts: &account_metas, - data: &[12], - }; - - invoke_signed(&instruction, &[self.account], signers) - } -} - const ACCOUNTS_LEN: usize = 1; impl CanInvoke for UpdateNonceAccount<'_> { @@ -52,12 +26,11 @@ impl CanInvoke for UpdateNonceAccount<'_> { /* data: */ &[u8], ) -> ProgramResult, ) -> ProgramResult { - let instruction_data = [12]; invoke( &crate::ID, &[self.account], &[AccountMeta::writable(self.account.key())], - &instruction_data, + &[12], ) } } diff --git a/programs/system/src/instructions/withdraw_nonce_account.rs b/programs/system/src/instructions/withdraw_nonce_account.rs index ddb86489..45f8e65c 100644 --- a/programs/system/src/instructions/withdraw_nonce_account.rs +++ b/programs/system/src/instructions/withdraw_nonce_account.rs @@ -1,9 +1,5 @@ use pinocchio::{ - account_info::AccountInfo, - instruction::{AccountMeta, Instruction, Signer}, - program::invoke_signed, - pubkey::Pubkey, - ProgramResult, + account_info::AccountInfo, instruction::AccountMeta, pubkey::Pubkey, ProgramResult, }; use crate::CanInvoke; @@ -42,50 +38,6 @@ pub struct WithdrawNonceAccount<'a> { pub lamports: u64, } -impl WithdrawNonceAccount<'_> { - #[inline(always)] - pub fn invoke(&self) -> ProgramResult { - self.invoke_signed(&[]) - } - - #[inline(always)] - pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult { - // account metadata - let account_metas: [AccountMeta; 5] = [ - AccountMeta::writable(self.account.key()), - AccountMeta::writable(self.recipient.key()), - AccountMeta::readonly(self.recent_blockhashes_sysvar.key()), - AccountMeta::readonly(self.rent_sysvar.key()), - AccountMeta::readonly_signer(self.authority.key()), - ]; - - // instruction data - // - [0..4 ]: instruction discriminator - // - [4..12]: lamports - let mut instruction_data = [0; 12]; - instruction_data[0] = 5; - instruction_data[4..12].copy_from_slice(&self.lamports.to_le_bytes()); - - let instruction = Instruction { - program_id: &crate::ID, - accounts: &account_metas, - data: &instruction_data, - }; - - invoke_signed( - &instruction, - &[ - self.account, - self.recipient, - self.recent_blockhashes_sysvar, - self.rent_sysvar, - self.authority, - ], - signers, - ) - } -} - const ACCOUNTS_LEN: usize = 5; impl CanInvoke for WithdrawNonceAccount<'_> { @@ -98,6 +50,9 @@ impl CanInvoke for WithdrawNonceAccount<'_> { /* data: */ &[u8], ) -> ProgramResult, ) -> ProgramResult { + // instruction data + // - [0..4 ]: instruction discriminator + // - [4..12]: lamports let mut instruction_data = [0; 12]; instruction_data[0] = 5; instruction_data[4..12].copy_from_slice(&self.lamports.to_le_bytes()); From 2002c6b755415dc7872ac95882036b0dab8c548b Mon Sep 17 00:00:00 2001 From: Flavio B Date: Sun, 27 Jul 2025 17:16:01 -0400 Subject: [PATCH 04/13] consume self --- programs/system/src/instructions/advance_nonce_account.rs | 2 +- programs/system/src/instructions/allocate.rs | 2 +- programs/system/src/instructions/allocate_with_seed.rs | 2 +- programs/system/src/instructions/assign.rs | 2 +- programs/system/src/instructions/assign_with_seed.rs | 2 +- .../system/src/instructions/authorize_nonce_account.rs | 2 +- programs/system/src/instructions/create_account.rs | 2 +- .../system/src/instructions/create_account_with_seed.rs | 2 +- .../system/src/instructions/initialize_nonce_account.rs | 2 +- programs/system/src/instructions/transfer.rs | 2 +- programs/system/src/instructions/transfer_with_seed.rs | 2 +- programs/system/src/instructions/update_nonce_account.rs | 2 +- .../system/src/instructions/withdraw_nonce_account.rs | 2 +- programs/system/src/lib.rs | 8 ++++---- 14 files changed, 17 insertions(+), 17 deletions(-) diff --git a/programs/system/src/instructions/advance_nonce_account.rs b/programs/system/src/instructions/advance_nonce_account.rs index 1113a1ca..f09a1ded 100644 --- a/programs/system/src/instructions/advance_nonce_account.rs +++ b/programs/system/src/instructions/advance_nonce_account.rs @@ -25,7 +25,7 @@ const ACCOUNTS_LEN: usize = 3; impl CanInvoke for AdvanceNonceAccount<'_> { fn invoke_via( - &self, + self, invoke: impl FnOnce( /* program_id: */ &Pubkey, /* accounts: */ &[&AccountInfo; ACCOUNTS_LEN], diff --git a/programs/system/src/instructions/allocate.rs b/programs/system/src/instructions/allocate.rs index c89f7183..5e9c54dc 100644 --- a/programs/system/src/instructions/allocate.rs +++ b/programs/system/src/instructions/allocate.rs @@ -20,7 +20,7 @@ const ACCOUNTS_LEN: usize = 1; impl CanInvoke for Allocate<'_> { fn invoke_via( - &self, + self, invoke: impl FnOnce( /* program_id: */ &Pubkey, /* accounts: */ &[&AccountInfo; ACCOUNTS_LEN], diff --git a/programs/system/src/instructions/allocate_with_seed.rs b/programs/system/src/instructions/allocate_with_seed.rs index e11706c0..0291351c 100644 --- a/programs/system/src/instructions/allocate_with_seed.rs +++ b/programs/system/src/instructions/allocate_with_seed.rs @@ -35,7 +35,7 @@ const ACCOUNTS_LEN: usize = 2; impl CanInvoke for AllocateWithSeed<'_, '_, '_> { fn invoke_via( - &self, + self, invoke: impl FnOnce( /* program_id: */ &Pubkey, /* accounts: */ &[&AccountInfo; ACCOUNTS_LEN], diff --git a/programs/system/src/instructions/assign.rs b/programs/system/src/instructions/assign.rs index 7c4998f7..3a2be245 100644 --- a/programs/system/src/instructions/assign.rs +++ b/programs/system/src/instructions/assign.rs @@ -20,7 +20,7 @@ const ACCOUNTS_LEN: usize = 1; impl CanInvoke for Assign<'_, '_> { fn invoke_via( - &self, + self, invoke: impl FnOnce( /* program_id: */ &Pubkey, /* accounts: */ &[&AccountInfo; ACCOUNTS_LEN], diff --git a/programs/system/src/instructions/assign_with_seed.rs b/programs/system/src/instructions/assign_with_seed.rs index d3e4c165..ec490829 100644 --- a/programs/system/src/instructions/assign_with_seed.rs +++ b/programs/system/src/instructions/assign_with_seed.rs @@ -31,7 +31,7 @@ const ACCOUNTS_LEN: usize = 2; impl CanInvoke for AssignWithSeed<'_, '_, '_> { fn invoke_via( - &self, + self, invoke: impl FnOnce( /* program_id: */ &Pubkey, /* accounts: */ &[&AccountInfo; ACCOUNTS_LEN], diff --git a/programs/system/src/instructions/authorize_nonce_account.rs b/programs/system/src/instructions/authorize_nonce_account.rs index 00dabe9d..8341d42c 100644 --- a/programs/system/src/instructions/authorize_nonce_account.rs +++ b/programs/system/src/instructions/authorize_nonce_account.rs @@ -26,7 +26,7 @@ const ACCOUNTS_LEN: usize = 2; impl CanInvoke for AuthorizeNonceAccount<'_, '_> { fn invoke_via( - &self, + self, invoke: impl FnOnce( /* program_id: */ &Pubkey, /* accounts: */ &[&AccountInfo; ACCOUNTS_LEN], diff --git a/programs/system/src/instructions/create_account.rs b/programs/system/src/instructions/create_account.rs index 02f6cc3a..60a49ac1 100644 --- a/programs/system/src/instructions/create_account.rs +++ b/programs/system/src/instructions/create_account.rs @@ -30,7 +30,7 @@ const ACCOUNTS_LEN: usize = 2; impl CanInvoke for CreateAccount<'_> { fn invoke_via( - &self, + self, invoke: impl FnOnce( /* program_id: */ &Pubkey, /* accounts: */ &[&AccountInfo; ACCOUNTS_LEN], diff --git a/programs/system/src/instructions/create_account_with_seed.rs b/programs/system/src/instructions/create_account_with_seed.rs index 71fb7b7c..26aff58c 100644 --- a/programs/system/src/instructions/create_account_with_seed.rs +++ b/programs/system/src/instructions/create_account_with_seed.rs @@ -42,7 +42,7 @@ const ACCOUNTS_LEN: usize = 3; impl CanInvoke for CreateAccountWithSeed<'_, '_, '_> { fn invoke_via( - &self, + self, invoke: impl FnOnce( /* program_id: */ &Pubkey, /* accounts: */ &[&AccountInfo; ACCOUNTS_LEN], diff --git a/programs/system/src/instructions/initialize_nonce_account.rs b/programs/system/src/instructions/initialize_nonce_account.rs index 1fbf6cd4..57333483 100644 --- a/programs/system/src/instructions/initialize_nonce_account.rs +++ b/programs/system/src/instructions/initialize_nonce_account.rs @@ -37,7 +37,7 @@ const ACCOUNTS_LEN: usize = 3; impl CanInvoke for InitializeNonceAccount<'_, '_> { fn invoke_via( - &self, + self, invoke: impl FnOnce( /* program_id: */ &Pubkey, /* accounts: */ &[&AccountInfo; ACCOUNTS_LEN], diff --git a/programs/system/src/instructions/transfer.rs b/programs/system/src/instructions/transfer.rs index 8f8a3034..dfdced76 100644 --- a/programs/system/src/instructions/transfer.rs +++ b/programs/system/src/instructions/transfer.rs @@ -24,7 +24,7 @@ const ACCOUNTS_LEN: usize = 2; impl CanInvoke for Transfer<'_> { fn invoke_via( - &self, + self, invoke: impl FnOnce( /* program_id: */ &Pubkey, /* accounts: */ &[&AccountInfo; ACCOUNTS_LEN], diff --git a/programs/system/src/instructions/transfer_with_seed.rs b/programs/system/src/instructions/transfer_with_seed.rs index f174f0ab..d8df0544 100644 --- a/programs/system/src/instructions/transfer_with_seed.rs +++ b/programs/system/src/instructions/transfer_with_seed.rs @@ -38,7 +38,7 @@ const ACCOUNTS_LEN: usize = 3; impl CanInvoke for TransferWithSeed<'_, '_, '_> { fn invoke_via( - &self, + self, invoke: impl FnOnce( /* program_id: */ &Pubkey, /* accounts: */ &[&AccountInfo; ACCOUNTS_LEN], diff --git a/programs/system/src/instructions/update_nonce_account.rs b/programs/system/src/instructions/update_nonce_account.rs index 6b65be27..bd31a596 100644 --- a/programs/system/src/instructions/update_nonce_account.rs +++ b/programs/system/src/instructions/update_nonce_account.rs @@ -18,7 +18,7 @@ const ACCOUNTS_LEN: usize = 1; impl CanInvoke for UpdateNonceAccount<'_> { fn invoke_via( - &self, + self, invoke: impl FnOnce( /* program_id: */ &Pubkey, /* accounts: */ &[&AccountInfo; 1], diff --git a/programs/system/src/instructions/withdraw_nonce_account.rs b/programs/system/src/instructions/withdraw_nonce_account.rs index 45f8e65c..ca93a03f 100644 --- a/programs/system/src/instructions/withdraw_nonce_account.rs +++ b/programs/system/src/instructions/withdraw_nonce_account.rs @@ -42,7 +42,7 @@ const ACCOUNTS_LEN: usize = 5; impl CanInvoke for WithdrawNonceAccount<'_> { fn invoke_via( - &self, + self, invoke: impl FnOnce( /* program_id: */ &Pubkey, /* accounts: */ &[&AccountInfo; ACCOUNTS_LEN], diff --git a/programs/system/src/lib.rs b/programs/system/src/lib.rs index 45ca8b67..69a43a48 100644 --- a/programs/system/src/lib.rs +++ b/programs/system/src/lib.rs @@ -11,9 +11,9 @@ pub mod instructions; pinocchio_pubkey::declare_id!("11111111111111111111111111111111"); -pub trait CanInvoke { +pub trait CanInvoke: Sized { fn invoke_via( - &self, + self, invoke: impl FnOnce( /* program_id: */ &Pubkey, /* accounts: */ &[&AccountInfo; ACCOUNTS_LEN], @@ -22,7 +22,7 @@ pub trait CanInvoke { ) -> ProgramResult, ) -> ProgramResult; - fn invoke(&self) -> ProgramResult { + fn invoke(self) -> ProgramResult { self.invoke_via(|program_id, accounts, account_metas, data| { let instruction = Instruction { program_id: program_id, @@ -33,7 +33,7 @@ pub trait CanInvoke { }) } - fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult { + fn invoke_signed(self, signers: &[Signer]) -> ProgramResult { self.invoke_via(|program_id, accounts, account_metas, data| { let instruction = Instruction { program_id: program_id, From a375b7db93a1e466f2d7d448b64893451e524976 Mon Sep 17 00:00:00 2001 From: Flavio B Date: Sat, 2 Aug 2025 11:40:52 -0400 Subject: [PATCH 05/13] as invoker --- .../src/instructions/advance_nonce_account.rs | 8 +- programs/system/src/instructions/allocate.rs | 8 +- .../src/instructions/allocate_with_seed.rs | 8 +- programs/system/src/instructions/assign.rs | 8 +- .../src/instructions/assign_with_seed.rs | 8 +- .../instructions/authorize_nonce_account.rs | 8 +- .../system/src/instructions/create_account.rs | 8 +- .../instructions/create_account_with_seed.rs | 8 +- .../instructions/initialize_nonce_account.rs | 8 +- programs/system/src/instructions/transfer.rs | 8 +- .../src/instructions/transfer_with_seed.rs | 8 +- .../src/instructions/update_nonce_account.rs | 8 +- .../instructions/withdraw_nonce_account.rs | 8 +- programs/system/src/lib.rs | 124 +++++++++++++++--- 14 files changed, 168 insertions(+), 60 deletions(-) diff --git a/programs/system/src/instructions/advance_nonce_account.rs b/programs/system/src/instructions/advance_nonce_account.rs index f09a1ded..58702a8e 100644 --- a/programs/system/src/instructions/advance_nonce_account.rs +++ b/programs/system/src/instructions/advance_nonce_account.rs @@ -23,12 +23,14 @@ pub struct AdvanceNonceAccount<'a> { const ACCOUNTS_LEN: usize = 3; -impl CanInvoke for AdvanceNonceAccount<'_> { +impl<'a> CanInvoke for AdvanceNonceAccount<'a> { + type Accounts = [&'a AccountInfo; ACCOUNTS_LEN]; + fn invoke_via( - self, + &self, invoke: impl FnOnce( /* program_id: */ &Pubkey, - /* accounts: */ &[&AccountInfo; ACCOUNTS_LEN], + /* accounts: */ &Self::Accounts, /* account_metas: */ &[AccountMeta], /* data: */ &[u8], ) -> ProgramResult, diff --git a/programs/system/src/instructions/allocate.rs b/programs/system/src/instructions/allocate.rs index 5e9c54dc..efa44791 100644 --- a/programs/system/src/instructions/allocate.rs +++ b/programs/system/src/instructions/allocate.rs @@ -18,12 +18,14 @@ pub struct Allocate<'a> { const ACCOUNTS_LEN: usize = 1; -impl CanInvoke for Allocate<'_> { +impl<'a> CanInvoke for Allocate<'a> { + type Accounts = [&'a AccountInfo; ACCOUNTS_LEN]; + fn invoke_via( - self, + &self, invoke: impl FnOnce( /* program_id: */ &Pubkey, - /* accounts: */ &[&AccountInfo; ACCOUNTS_LEN], + /* accounts: */ &Self::Accounts, /* account_metas: */ &[AccountMeta], /* data: */ &[u8], ) -> ProgramResult, diff --git a/programs/system/src/instructions/allocate_with_seed.rs b/programs/system/src/instructions/allocate_with_seed.rs index 0291351c..3829306a 100644 --- a/programs/system/src/instructions/allocate_with_seed.rs +++ b/programs/system/src/instructions/allocate_with_seed.rs @@ -33,12 +33,14 @@ pub struct AllocateWithSeed<'a, 'b, 'c> { const ACCOUNTS_LEN: usize = 2; -impl CanInvoke for AllocateWithSeed<'_, '_, '_> { +impl<'a, 'b, 'c> CanInvoke for AllocateWithSeed<'a, 'b, 'c> { + type Accounts = [&'a AccountInfo; ACCOUNTS_LEN]; + fn invoke_via( - self, + &self, invoke: impl FnOnce( /* program_id: */ &Pubkey, - /* accounts: */ &[&AccountInfo; ACCOUNTS_LEN], + /* accounts: */ &Self::Accounts, /* account_metas: */ &[AccountMeta], /* data: */ &[u8], ) -> ProgramResult, diff --git a/programs/system/src/instructions/assign.rs b/programs/system/src/instructions/assign.rs index 3a2be245..f82ce4e6 100644 --- a/programs/system/src/instructions/assign.rs +++ b/programs/system/src/instructions/assign.rs @@ -18,12 +18,14 @@ pub struct Assign<'a, 'b> { const ACCOUNTS_LEN: usize = 1; -impl CanInvoke for Assign<'_, '_> { +impl<'a, 'b> CanInvoke for Assign<'a, 'b> { + type Accounts = [&'a AccountInfo; ACCOUNTS_LEN]; + fn invoke_via( - self, + &self, invoke: impl FnOnce( /* program_id: */ &Pubkey, - /* accounts: */ &[&AccountInfo; ACCOUNTS_LEN], + /* accounts: */ &Self::Accounts, /* account_metas: */ &[AccountMeta], /* data: */ &[u8], ) -> ProgramResult, diff --git a/programs/system/src/instructions/assign_with_seed.rs b/programs/system/src/instructions/assign_with_seed.rs index ec490829..03d824b6 100644 --- a/programs/system/src/instructions/assign_with_seed.rs +++ b/programs/system/src/instructions/assign_with_seed.rs @@ -29,12 +29,14 @@ pub struct AssignWithSeed<'a, 'b, 'c> { const ACCOUNTS_LEN: usize = 2; -impl CanInvoke for AssignWithSeed<'_, '_, '_> { +impl<'a, 'b, 'c> CanInvoke for AssignWithSeed<'a, 'b, 'c> { + type Accounts = [&'a AccountInfo; ACCOUNTS_LEN]; + fn invoke_via( - self, + &self, invoke: impl FnOnce( /* program_id: */ &Pubkey, - /* accounts: */ &[&AccountInfo; ACCOUNTS_LEN], + /* accounts: */ &Self::Accounts, /* account_metas: */ &[AccountMeta], /* data: */ &[u8], ) -> ProgramResult, diff --git a/programs/system/src/instructions/authorize_nonce_account.rs b/programs/system/src/instructions/authorize_nonce_account.rs index 8341d42c..1a6568d6 100644 --- a/programs/system/src/instructions/authorize_nonce_account.rs +++ b/programs/system/src/instructions/authorize_nonce_account.rs @@ -24,12 +24,14 @@ pub struct AuthorizeNonceAccount<'a, 'b> { const ACCOUNTS_LEN: usize = 2; -impl CanInvoke for AuthorizeNonceAccount<'_, '_> { +impl<'a, 'b> CanInvoke for AuthorizeNonceAccount<'a, 'b> { + type Accounts = [&'a AccountInfo; ACCOUNTS_LEN]; + fn invoke_via( - self, + &self, invoke: impl FnOnce( /* program_id: */ &Pubkey, - /* accounts: */ &[&AccountInfo; ACCOUNTS_LEN], + /* accounts: */ &Self::Accounts, /* account_metas: */ &[AccountMeta], /* data: */ &[u8], ) -> ProgramResult, diff --git a/programs/system/src/instructions/create_account.rs b/programs/system/src/instructions/create_account.rs index 60a49ac1..1279096d 100644 --- a/programs/system/src/instructions/create_account.rs +++ b/programs/system/src/instructions/create_account.rs @@ -28,12 +28,14 @@ pub struct CreateAccount<'a> { const ACCOUNTS_LEN: usize = 2; -impl CanInvoke for CreateAccount<'_> { +impl<'a> CanInvoke for CreateAccount<'a> { + type Accounts = [&'a AccountInfo; ACCOUNTS_LEN]; + fn invoke_via( - self, + &self, invoke: impl FnOnce( /* program_id: */ &Pubkey, - /* accounts: */ &[&AccountInfo; ACCOUNTS_LEN], + /* accounts: */ &Self::Accounts, /* account_metas: */ &[AccountMeta], /* data: */ &[u8], ) -> ProgramResult, diff --git a/programs/system/src/instructions/create_account_with_seed.rs b/programs/system/src/instructions/create_account_with_seed.rs index 26aff58c..07f515ac 100644 --- a/programs/system/src/instructions/create_account_with_seed.rs +++ b/programs/system/src/instructions/create_account_with_seed.rs @@ -40,12 +40,14 @@ pub struct CreateAccountWithSeed<'a, 'b, 'c> { const ACCOUNTS_LEN: usize = 3; -impl CanInvoke for CreateAccountWithSeed<'_, '_, '_> { +impl<'a, 'b, 'c> CanInvoke for CreateAccountWithSeed<'a, 'b, 'c> { + type Accounts = [&'a AccountInfo; ACCOUNTS_LEN]; + fn invoke_via( - self, + &self, invoke: impl FnOnce( /* program_id: */ &Pubkey, - /* accounts: */ &[&AccountInfo; ACCOUNTS_LEN], + /* accounts: */ &Self::Accounts, /* account_metas: */ &[AccountMeta], /* data: */ &[u8], ) -> ProgramResult, diff --git a/programs/system/src/instructions/initialize_nonce_account.rs b/programs/system/src/instructions/initialize_nonce_account.rs index 57333483..dacbe0cc 100644 --- a/programs/system/src/instructions/initialize_nonce_account.rs +++ b/programs/system/src/instructions/initialize_nonce_account.rs @@ -35,12 +35,14 @@ pub struct InitializeNonceAccount<'a, 'b> { const ACCOUNTS_LEN: usize = 3; -impl CanInvoke for InitializeNonceAccount<'_, '_> { +impl<'a, 'b> CanInvoke for InitializeNonceAccount<'a, 'b> { + type Accounts = [&'a AccountInfo; ACCOUNTS_LEN]; + fn invoke_via( - self, + &self, invoke: impl FnOnce( /* program_id: */ &Pubkey, - /* accounts: */ &[&AccountInfo; ACCOUNTS_LEN], + /* accounts: */ &Self::Accounts, /* account_metas: */ &[AccountMeta], /* data: */ &[u8], ) -> ProgramResult, diff --git a/programs/system/src/instructions/transfer.rs b/programs/system/src/instructions/transfer.rs index dfdced76..68f25cea 100644 --- a/programs/system/src/instructions/transfer.rs +++ b/programs/system/src/instructions/transfer.rs @@ -22,12 +22,14 @@ pub struct Transfer<'a> { const ACCOUNTS_LEN: usize = 2; -impl CanInvoke for Transfer<'_> { +impl<'a> CanInvoke for Transfer<'a> { + type Accounts = [&'a AccountInfo; ACCOUNTS_LEN]; + fn invoke_via( - self, + &self, invoke: impl FnOnce( /* program_id: */ &Pubkey, - /* accounts: */ &[&AccountInfo; ACCOUNTS_LEN], + /* accounts: */ &Self::Accounts, /* account_metas: */ &[AccountMeta], /* data: */ &[u8], ) -> ProgramResult, diff --git a/programs/system/src/instructions/transfer_with_seed.rs b/programs/system/src/instructions/transfer_with_seed.rs index d8df0544..cd55e8ff 100644 --- a/programs/system/src/instructions/transfer_with_seed.rs +++ b/programs/system/src/instructions/transfer_with_seed.rs @@ -36,12 +36,14 @@ pub struct TransferWithSeed<'a, 'b, 'c> { const ACCOUNTS_LEN: usize = 3; -impl CanInvoke for TransferWithSeed<'_, '_, '_> { +impl<'a, 'b, 'c> CanInvoke for TransferWithSeed<'a, 'b, 'c> { + type Accounts = [&'a AccountInfo; ACCOUNTS_LEN]; + fn invoke_via( - self, + &self, invoke: impl FnOnce( /* program_id: */ &Pubkey, - /* accounts: */ &[&AccountInfo; ACCOUNTS_LEN], + /* accounts: */ &Self::Accounts, /* account_metas: */ &[AccountMeta], /* data: */ &[u8], ) -> ProgramResult, diff --git a/programs/system/src/instructions/update_nonce_account.rs b/programs/system/src/instructions/update_nonce_account.rs index bd31a596..fea0bc26 100644 --- a/programs/system/src/instructions/update_nonce_account.rs +++ b/programs/system/src/instructions/update_nonce_account.rs @@ -16,12 +16,14 @@ pub struct UpdateNonceAccount<'a> { const ACCOUNTS_LEN: usize = 1; -impl CanInvoke for UpdateNonceAccount<'_> { +impl<'a> CanInvoke for UpdateNonceAccount<'a> { + type Accounts = [&'a AccountInfo; ACCOUNTS_LEN]; + fn invoke_via( - self, + &self, invoke: impl FnOnce( /* program_id: */ &Pubkey, - /* accounts: */ &[&AccountInfo; 1], + /* accounts: */ &Self::Accounts, /* account_metas: */ &[AccountMeta], /* data: */ &[u8], ) -> ProgramResult, diff --git a/programs/system/src/instructions/withdraw_nonce_account.rs b/programs/system/src/instructions/withdraw_nonce_account.rs index ca93a03f..8c4a0d99 100644 --- a/programs/system/src/instructions/withdraw_nonce_account.rs +++ b/programs/system/src/instructions/withdraw_nonce_account.rs @@ -40,12 +40,14 @@ pub struct WithdrawNonceAccount<'a> { const ACCOUNTS_LEN: usize = 5; -impl CanInvoke for WithdrawNonceAccount<'_> { +impl<'a> CanInvoke for WithdrawNonceAccount<'a> { + type Accounts = [&'a AccountInfo; ACCOUNTS_LEN]; + fn invoke_via( - self, + &self, invoke: impl FnOnce( /* program_id: */ &Pubkey, - /* accounts: */ &[&AccountInfo; ACCOUNTS_LEN], + /* accounts: */ &Self::Accounts, /* account_metas: */ &[AccountMeta], /* data: */ &[u8], ) -> ProgramResult, diff --git a/programs/system/src/lib.rs b/programs/system/src/lib.rs index 69a43a48..c2aa2c81 100644 --- a/programs/system/src/lib.rs +++ b/programs/system/src/lib.rs @@ -1,5 +1,7 @@ #![no_std] +use core::marker::PhantomData; + use pinocchio::{ account_info::AccountInfo, instruction::{AccountMeta, Instruction, Signer}, @@ -11,36 +13,116 @@ pub mod instructions; pinocchio_pubkey::declare_id!("11111111111111111111111111111111"); -pub trait CanInvoke: Sized { +pub type ConstAccounts<'a, const ACCOUNTS_LEN: usize> = [&'a AccountInfo; ACCOUNTS_LEN]; +pub type SliceAccounts<'a> = [&'a AccountInfo]; + +mod sealed { + pub trait Sealed {} + + impl<'a, const ACCOUNTS_LEN: usize> Sealed for crate::ConstAccounts<'a, ACCOUNTS_LEN> {} + impl<'a> Sealed for crate::SliceAccounts<'a> {} + impl<'a, T, Account> Sealed for crate::Invoker<'a, T, Account> {} + impl Sealed for T where T: crate::CanInvoke {} +} + +pub trait AccountType: sealed::Sealed {} + +impl<'a, const ACCOUNTS_LEN: usize> AccountType for ConstAccounts<'a, ACCOUNTS_LEN> {} +impl<'a> AccountType for SliceAccounts<'a> {} + +pub trait CanInvoke { + type Accounts: AccountType; + fn invoke_via( - self, + &self, invoke: impl FnOnce( /* program_id: */ &Pubkey, - /* accounts: */ &[&AccountInfo; ACCOUNTS_LEN], + /* accounts: */ &Self::Accounts, /* account_metas: */ &[AccountMeta], /* data: */ &[u8], ) -> ProgramResult, ) -> ProgramResult; - fn invoke(self) -> ProgramResult { - self.invoke_via(|program_id, accounts, account_metas, data| { - let instruction = Instruction { - program_id: program_id, - accounts: &account_metas, - data: data, - }; - pinocchio::cpi::invoke(&instruction, accounts) - }) + #[inline] + fn as_invoker<'a>(&'a self) -> Invoker<'a, Self, &'a Self::Accounts> + where + Self: Sized, + { + Invoker { + inner: self, + account_ty: PhantomData, + } + } +} + +pub trait Invoke: sealed::Sealed { + fn invoke(&self) -> ProgramResult; + fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult; +} + +pub struct Invoker<'a, T, Account> { + inner: &'a T, + account_ty: PhantomData, +} + +impl<'a, const ACCOUNTS_LEN: usize, T> Invoke for Invoker<'a, T, &ConstAccounts<'a, ACCOUNTS_LEN>> +where + T: CanInvoke>, +{ + #[inline] + fn invoke(&self) -> ProgramResult { + self.inner + .invoke_via(|program_id, accounts, account_metas, data| { + let instruction = Instruction { + program_id: program_id, + accounts: &account_metas, + data: data, + }; + pinocchio::cpi::invoke(&instruction, accounts) + }) + } + + #[inline] + fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult { + self.inner + .invoke_via(|program_id, accounts, account_metas, data| { + let instruction = Instruction { + program_id: program_id, + accounts: &account_metas, + data: data, + }; + pinocchio::cpi::invoke_signed(&instruction, accounts, signers) + }) + } +} + +impl<'a, T> Invoke for Invoker<'a, T, &SliceAccounts<'a>> +where + T: CanInvoke>, +{ + #[inline] + fn invoke(&self) -> ProgramResult { + self.inner + .invoke_via(|program_id, accounts, account_metas, data| { + let instruction = Instruction { + program_id: program_id, + accounts: &account_metas, + data: data, + }; + pinocchio::cpi::slice_invoke(&instruction, accounts) + }) } - fn invoke_signed(self, signers: &[Signer]) -> ProgramResult { - self.invoke_via(|program_id, accounts, account_metas, data| { - let instruction = Instruction { - program_id: program_id, - accounts: &account_metas, - data: data, - }; - pinocchio::cpi::invoke_signed(&instruction, accounts, signers) - }) + #[inline] + fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult { + self.inner + .invoke_via(|program_id, accounts, account_metas, data| { + let instruction = Instruction { + program_id: program_id, + accounts: &account_metas, + data: data, + }; + pinocchio::cpi::slice_invoke_signed(&instruction, accounts, signers) + }) } } From 566d41a1b556db3e44d7c904839a173a1fd5548f Mon Sep 17 00:00:00 2001 From: Flavio B Date: Sat, 2 Aug 2025 12:20:00 -0400 Subject: [PATCH 06/13] remove lifetime bound from Invoker --- programs/system/src/lib.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/programs/system/src/lib.rs b/programs/system/src/lib.rs index c2aa2c81..793f4e03 100644 --- a/programs/system/src/lib.rs +++ b/programs/system/src/lib.rs @@ -21,7 +21,7 @@ mod sealed { impl<'a, const ACCOUNTS_LEN: usize> Sealed for crate::ConstAccounts<'a, ACCOUNTS_LEN> {} impl<'a> Sealed for crate::SliceAccounts<'a> {} - impl<'a, T, Account> Sealed for crate::Invoker<'a, T, Account> {} + impl<'a, T, Account> Sealed for crate::Invoker<&'a T, Account> {} impl Sealed for T where T: crate::CanInvoke {} } @@ -44,7 +44,7 @@ pub trait CanInvoke { ) -> ProgramResult; #[inline] - fn as_invoker<'a>(&'a self) -> Invoker<'a, Self, &'a Self::Accounts> + fn as_invoker<'a>(&'a self) -> Invoker<&'a Self, &'a Self::Accounts> where Self: Sized, { @@ -60,12 +60,12 @@ pub trait Invoke: sealed::Sealed { fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult; } -pub struct Invoker<'a, T, Account> { - inner: &'a T, +pub struct Invoker { + inner: T, account_ty: PhantomData, } -impl<'a, const ACCOUNTS_LEN: usize, T> Invoke for Invoker<'a, T, &ConstAccounts<'a, ACCOUNTS_LEN>> +impl<'a, const ACCOUNTS_LEN: usize, T> Invoke for Invoker<&'a T, &ConstAccounts<'a, ACCOUNTS_LEN>> where T: CanInvoke>, { @@ -96,7 +96,7 @@ where } } -impl<'a, T> Invoke for Invoker<'a, T, &SliceAccounts<'a>> +impl<'a, T> Invoke for Invoker<&'a T, &SliceAccounts<'a>> where T: CanInvoke>, { From 23d48a37101ec4702e66e19b7443b1a1348f9306 Mon Sep 17 00:00:00 2001 From: Flavio B Date: Sat, 2 Aug 2025 13:37:54 -0400 Subject: [PATCH 07/13] all three impls --- programs/system/src/callback.rs | 84 +++++++++++++++++++ programs/system/src/invoke_parts.rs | 91 ++++++++++++++++++++ programs/system/src/invoker.rs | 122 +++++++++++++++++++++++++++ programs/system/src/lib.rs | 126 +--------------------------- 4 files changed, 301 insertions(+), 122 deletions(-) create mode 100644 programs/system/src/callback.rs create mode 100644 programs/system/src/invoke_parts.rs create mode 100644 programs/system/src/invoker.rs diff --git a/programs/system/src/callback.rs b/programs/system/src/callback.rs new file mode 100644 index 00000000..dc26935d --- /dev/null +++ b/programs/system/src/callback.rs @@ -0,0 +1,84 @@ +use pinocchio::{ + account_info::AccountInfo, + cpi, + instruction::{AccountMeta, Instruction, Signer}, + pubkey::Pubkey, + ProgramResult, +}; + +mod sealed { + pub trait Sealed {} + impl Sealed for T where T: super::CanInvoke {} +} + +pub trait CanInvoke { + type Accounts; + + fn invoke_via( + &self, + invoke: impl for<'a> FnOnce( + /* program_id: */ &'a Pubkey, + /* accounts: */ &'a Self::Accounts, + /* account_metas: */ &'a [AccountMeta], + /* data: */ &'a [u8], + ) -> ProgramResult, + slice_invoke: impl for<'a> FnOnce( + /* program_id: */ &'a Pubkey, + /* accounts: */ &'a [&'a AccountInfo], + /* account_metas: */ &'a [AccountMeta], + /* data: */ &'a [u8], + ) -> ProgramResult, + ) -> ProgramResult; +} + +pub trait Invoke: sealed::Sealed { + fn invoke(&self) -> ProgramResult; + fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult; +} + +impl<'a, const ACCOUNTS_LEN: usize, T> Invoke for T +where + T: CanInvoke, +{ + fn invoke(&self) -> ProgramResult { + self.invoke_via( + |program_id, accounts, account_metas, data| { + let instruction = Instruction { + program_id, + accounts: &account_metas, + data, + }; + cpi::invoke(&instruction, accounts) + }, + |program_id, accounts, account_metas, data| { + let instruction = Instruction { + program_id, + accounts: &account_metas, + data, + }; + cpi::slice_invoke(&instruction, accounts) + }, + ) + } + + fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult { + self.invoke_via( + |program_id, accounts, account_metas, data| { + let instruction = Instruction { + program_id, + accounts: &account_metas, + data, + }; + cpi::invoke_signed(&instruction, accounts, signers) + }, + |program_id, accounts, account_metas, data| { + let instruction = Instruction { + program_id, + accounts: &account_metas, + data, + }; + cpi::slice_invoke_signed(&instruction, accounts, signers) + }, + ) + } +} diff --git a/programs/system/src/invoke_parts.rs b/programs/system/src/invoke_parts.rs new file mode 100644 index 00000000..107faf60 --- /dev/null +++ b/programs/system/src/invoke_parts.rs @@ -0,0 +1,91 @@ +use pinocchio::{ + account_info::AccountInfo, + cpi, + instruction::{AccountMeta, Instruction, Signer}, + pubkey::Pubkey, + ProgramResult, +}; + +type SliceInvokeParts<'a> = InvokeParts<&'a [&'a AccountInfo], &'a [AccountMeta<'a>], &'a [u8]>; +type FixedInvokeParts<'a, const N: usize> = + InvokeParts<&'a [&'a AccountInfo; N], &'a [AccountMeta<'a>], &'a [u8]>; + +pub trait InvokePartsType: sealed::Sealed {} +impl InvokePartsType for SliceInvokeParts<'_> {} +impl InvokePartsType for FixedInvokeParts<'_, N> {} + +pub struct InvokeParts { + pub program_id: Pubkey, + pub accounts: Accounts, + pub account_metas: Metas, + pub instruction_data: Data, +} + +pub trait IntoInvokeParts { + type Output: InvokePartsType; + fn into_invoke_parts(self) -> Self::Output; +} + +pub trait Invoke: sealed::Sealed { + fn invoke(self) -> ProgramResult; + fn invoke_signed(self, signers: &[Signer]) -> ProgramResult; +} + +impl Invoke for SliceInvokeParts<'_> { + fn invoke(self) -> ProgramResult { + self.invoke_signed(&[]) + } + + fn invoke_signed(self, signers: &[Signer]) -> ProgramResult { + cpi::slice_invoke_signed( + &Instruction { + program_id: &self.program_id, + data: &self.instruction_data, + accounts: &self.account_metas, + }, + self.accounts, + signers, + ) + } +} + +impl Invoke for FixedInvokeParts<'_, N> { + fn invoke(self) -> ProgramResult { + self.invoke_signed(&[]) + } + + fn invoke_signed(self, signers: &[Signer]) -> ProgramResult { + cpi::invoke_signed( + &Instruction { + program_id: &self.program_id, + data: &self.instruction_data, + accounts: &self.account_metas, + }, + self.accounts, + signers, + ) + } +} + +impl Invoke for T +where + T: IntoInvokeParts, + T::Output: Invoke, +{ + fn invoke(self) -> ProgramResult { + self.into_invoke_parts().invoke() + } + + fn invoke_signed(self, signers: &[Signer]) -> ProgramResult { + self.into_invoke_parts().invoke_signed(signers) + } +} + +mod sealed { + use crate::invoke_parts::{FixedInvokeParts, IntoInvokeParts, SliceInvokeParts}; + + pub trait Sealed {} + impl<'a, const N: usize> Sealed for FixedInvokeParts<'a, N> {} + impl<'a> Sealed for SliceInvokeParts<'a> {} + impl Sealed for T where T: IntoInvokeParts {} +} diff --git a/programs/system/src/invoker.rs b/programs/system/src/invoker.rs new file mode 100644 index 00000000..e2bfa7a7 --- /dev/null +++ b/programs/system/src/invoker.rs @@ -0,0 +1,122 @@ +use core::marker::PhantomData; + +use pinocchio::{ + account_info::AccountInfo, + instruction::{AccountMeta, Instruction, Signer}, + pubkey::Pubkey, + ProgramResult, +}; + +pub type ConstAccounts<'a, const ACCOUNTS_LEN: usize> = [&'a AccountInfo; ACCOUNTS_LEN]; +pub type SliceAccounts<'a> = [&'a AccountInfo]; + +mod sealed { + pub trait Sealed {} + + impl<'a, const ACCOUNTS_LEN: usize> Sealed for super::ConstAccounts<'a, ACCOUNTS_LEN> {} + impl<'a> Sealed for super::SliceAccounts<'a> {} + impl<'a, T, Account> Sealed for super::Invoker<&'a T, Account> {} + impl Sealed for T where T: super::CanInvoke {} +} + +pub trait AccountType: sealed::Sealed {} + +impl<'a, const ACCOUNTS_LEN: usize> AccountType for ConstAccounts<'a, ACCOUNTS_LEN> {} +impl<'a> AccountType for SliceAccounts<'a> {} + +pub trait CanInvoke { + type Accounts: AccountType; + + fn invoke_via( + &self, + invoke: impl FnOnce( + /* program_id: */ &Pubkey, + /* accounts: */ &Self::Accounts, + /* account_metas: */ &[AccountMeta], + /* data: */ &[u8], + ) -> ProgramResult, + ) -> ProgramResult; + + #[inline] + fn as_invoker<'a>(&'a self) -> Invoker<&'a Self, &'a Self::Accounts> + where + Self: Sized, + { + Invoker { + inner: self, + account_ty: PhantomData, + } + } +} + +pub trait Invoke: sealed::Sealed { + fn invoke(&self) -> ProgramResult; + fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult; +} + +pub struct Invoker { + inner: T, + account_ty: PhantomData, +} + +impl<'a, const ACCOUNTS_LEN: usize, T> Invoke for Invoker<&'a T, &ConstAccounts<'a, ACCOUNTS_LEN>> +where + T: CanInvoke>, +{ + #[inline] + fn invoke(&self) -> ProgramResult { + self.inner + .invoke_via(|program_id, accounts, account_metas, data| { + let instruction = Instruction { + program_id: program_id, + accounts: &account_metas, + data: data, + }; + pinocchio::cpi::invoke(&instruction, accounts) + }) + } + + #[inline] + fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult { + self.inner + .invoke_via(|program_id, accounts, account_metas, data| { + let instruction = Instruction { + program_id: program_id, + accounts: &account_metas, + data: data, + }; + pinocchio::cpi::invoke_signed(&instruction, accounts, signers) + }) + } +} + +impl<'a, T> Invoke for Invoker<&'a T, &SliceAccounts<'a>> +where + T: CanInvoke>, +{ + #[inline] + fn invoke(&self) -> ProgramResult { + self.inner + .invoke_via(|program_id, accounts, account_metas, data| { + let instruction = Instruction { + program_id: program_id, + accounts: &account_metas, + data: data, + }; + pinocchio::cpi::slice_invoke(&instruction, accounts) + }) + } + + #[inline] + fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult { + self.inner + .invoke_via(|program_id, accounts, account_metas, data| { + let instruction = Instruction { + program_id: program_id, + accounts: &account_metas, + data: data, + }; + pinocchio::cpi::slice_invoke_signed(&instruction, accounts, signers) + }) + } +} diff --git a/programs/system/src/lib.rs b/programs/system/src/lib.rs index 793f4e03..a43da36d 100644 --- a/programs/system/src/lib.rs +++ b/programs/system/src/lib.rs @@ -1,128 +1,10 @@ #![no_std] -use core::marker::PhantomData; - -use pinocchio::{ - account_info::AccountInfo, - instruction::{AccountMeta, Instruction, Signer}, - pubkey::Pubkey, - ProgramResult, -}; +pub use invoker::*; +pub mod callback; pub mod instructions; +pub mod invoke_parts; +pub mod invoker; pinocchio_pubkey::declare_id!("11111111111111111111111111111111"); - -pub type ConstAccounts<'a, const ACCOUNTS_LEN: usize> = [&'a AccountInfo; ACCOUNTS_LEN]; -pub type SliceAccounts<'a> = [&'a AccountInfo]; - -mod sealed { - pub trait Sealed {} - - impl<'a, const ACCOUNTS_LEN: usize> Sealed for crate::ConstAccounts<'a, ACCOUNTS_LEN> {} - impl<'a> Sealed for crate::SliceAccounts<'a> {} - impl<'a, T, Account> Sealed for crate::Invoker<&'a T, Account> {} - impl Sealed for T where T: crate::CanInvoke {} -} - -pub trait AccountType: sealed::Sealed {} - -impl<'a, const ACCOUNTS_LEN: usize> AccountType for ConstAccounts<'a, ACCOUNTS_LEN> {} -impl<'a> AccountType for SliceAccounts<'a> {} - -pub trait CanInvoke { - type Accounts: AccountType; - - fn invoke_via( - &self, - invoke: impl FnOnce( - /* program_id: */ &Pubkey, - /* accounts: */ &Self::Accounts, - /* account_metas: */ &[AccountMeta], - /* data: */ &[u8], - ) -> ProgramResult, - ) -> ProgramResult; - - #[inline] - fn as_invoker<'a>(&'a self) -> Invoker<&'a Self, &'a Self::Accounts> - where - Self: Sized, - { - Invoker { - inner: self, - account_ty: PhantomData, - } - } -} - -pub trait Invoke: sealed::Sealed { - fn invoke(&self) -> ProgramResult; - fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult; -} - -pub struct Invoker { - inner: T, - account_ty: PhantomData, -} - -impl<'a, const ACCOUNTS_LEN: usize, T> Invoke for Invoker<&'a T, &ConstAccounts<'a, ACCOUNTS_LEN>> -where - T: CanInvoke>, -{ - #[inline] - fn invoke(&self) -> ProgramResult { - self.inner - .invoke_via(|program_id, accounts, account_metas, data| { - let instruction = Instruction { - program_id: program_id, - accounts: &account_metas, - data: data, - }; - pinocchio::cpi::invoke(&instruction, accounts) - }) - } - - #[inline] - fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult { - self.inner - .invoke_via(|program_id, accounts, account_metas, data| { - let instruction = Instruction { - program_id: program_id, - accounts: &account_metas, - data: data, - }; - pinocchio::cpi::invoke_signed(&instruction, accounts, signers) - }) - } -} - -impl<'a, T> Invoke for Invoker<&'a T, &SliceAccounts<'a>> -where - T: CanInvoke>, -{ - #[inline] - fn invoke(&self) -> ProgramResult { - self.inner - .invoke_via(|program_id, accounts, account_metas, data| { - let instruction = Instruction { - program_id: program_id, - accounts: &account_metas, - data: data, - }; - pinocchio::cpi::slice_invoke(&instruction, accounts) - }) - } - - #[inline] - fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult { - self.inner - .invoke_via(|program_id, accounts, account_metas, data| { - let instruction = Instruction { - program_id: program_id, - accounts: &account_metas, - data: data, - }; - pinocchio::cpi::slice_invoke_signed(&instruction, accounts, signers) - }) - } -} From 0980f931c83d0160e72e260393480695bf4574fc Mon Sep 17 00:00:00 2001 From: Flavio B Date: Sat, 2 Aug 2025 14:20:09 -0400 Subject: [PATCH 08/13] impl tansfer --- programs/system/src/callback.rs | 78 +++++++++++++------- programs/system/src/instructions/transfer.rs | 40 +--------- programs/system/src/invoke_parts.rs | 36 +++++++-- programs/system/src/invoker.rs | 53 ++++++++----- 4 files changed, 118 insertions(+), 89 deletions(-) diff --git a/programs/system/src/callback.rs b/programs/system/src/callback.rs index dc26935d..78b22130 100644 --- a/programs/system/src/callback.rs +++ b/programs/system/src/callback.rs @@ -6,6 +6,8 @@ use pinocchio::{ ProgramResult, }; +use crate::instructions::{Transfer, TRANSFER_ACCOUNTS_LEN}; + mod sealed { pub trait Sealed {} impl Sealed for T where T: super::CanInvoke {} @@ -16,17 +18,17 @@ pub trait CanInvoke { fn invoke_via( &self, - invoke: impl for<'a> FnOnce( - /* program_id: */ &'a Pubkey, - /* accounts: */ &'a Self::Accounts, - /* account_metas: */ &'a [AccountMeta], - /* data: */ &'a [u8], + invoke: impl FnOnce( + /* program_id: */ &Pubkey, + /* accounts: */ &Self::Accounts, + /* account_metas: */ &[AccountMeta], + /* data: */ &[u8], ) -> ProgramResult, - slice_invoke: impl for<'a> FnOnce( - /* program_id: */ &'a Pubkey, - /* accounts: */ &'a [&'a AccountInfo], - /* account_metas: */ &'a [AccountMeta], - /* data: */ &'a [u8], + slice_invoke: impl FnOnce( + /* program_id: */ &Pubkey, + /* accounts: */ &[&AccountInfo], + /* account_metas: */ &[AccountMeta], + /* data: */ &[u8], ) -> ProgramResult, ) -> ProgramResult; } @@ -41,24 +43,7 @@ where T: CanInvoke, { fn invoke(&self) -> ProgramResult { - self.invoke_via( - |program_id, accounts, account_metas, data| { - let instruction = Instruction { - program_id, - accounts: &account_metas, - data, - }; - cpi::invoke(&instruction, accounts) - }, - |program_id, accounts, account_metas, data| { - let instruction = Instruction { - program_id, - accounts: &account_metas, - data, - }; - cpi::slice_invoke(&instruction, accounts) - }, - ) + self.invoke_signed(&[]) } fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult { @@ -82,3 +67,40 @@ where ) } } + +impl<'a> CanInvoke for Transfer<'a> { + type Accounts = [&'a AccountInfo; TRANSFER_ACCOUNTS_LEN]; + + fn invoke_via( + &self, + invoke: impl FnOnce( + /* program_id: */ &Pubkey, + /* accounts: */ &Self::Accounts, + /* account_metas: */ &[AccountMeta], + /* data: */ &[u8], + ) -> ProgramResult, + _slice_invoke: impl FnOnce( + /* program_id: */ &Pubkey, + /* accounts: */ &[&'a AccountInfo], + /* account_metas: */ &[AccountMeta], + /* data: */ &[u8], + ) -> ProgramResult, + ) -> ProgramResult { + // instruction data + // - [0..4 ]: instruction discriminator + // - [4..12]: lamports amount + let mut instruction_data = [0; 12]; + instruction_data[0] = 2; + instruction_data[4..12].copy_from_slice(&self.lamports.to_le_bytes()); + + invoke( + &crate::ID, + &[self.from, self.to], + &[ + AccountMeta::writable_signer(self.from.key()), + AccountMeta::writable(self.to.key()), + ], + &instruction_data, + ) + } +} diff --git a/programs/system/src/instructions/transfer.rs b/programs/system/src/instructions/transfer.rs index 68f25cea..8b9566e4 100644 --- a/programs/system/src/instructions/transfer.rs +++ b/programs/system/src/instructions/transfer.rs @@ -1,8 +1,4 @@ -use pinocchio::{ - account_info::AccountInfo, instruction::AccountMeta, pubkey::Pubkey, ProgramResult, -}; - -use crate::CanInvoke; +use pinocchio::account_info::AccountInfo; /// Transfer lamports. /// @@ -20,35 +16,5 @@ pub struct Transfer<'a> { pub lamports: u64, } -const ACCOUNTS_LEN: usize = 2; - -impl<'a> CanInvoke for Transfer<'a> { - type Accounts = [&'a AccountInfo; ACCOUNTS_LEN]; - - fn invoke_via( - &self, - invoke: impl FnOnce( - /* program_id: */ &Pubkey, - /* accounts: */ &Self::Accounts, - /* account_metas: */ &[AccountMeta], - /* data: */ &[u8], - ) -> ProgramResult, - ) -> ProgramResult { - // instruction data - // - [0..4 ]: instruction discriminator - // - [4..12]: lamports amount - let mut instruction_data = [0; 12]; - instruction_data[0] = 2; - instruction_data[4..12].copy_from_slice(&self.lamports.to_le_bytes()); - - invoke( - &crate::ID, - &[self.from, self.to], - &[ - AccountMeta::writable_signer(self.from.key()), - AccountMeta::writable(self.to.key()), - ], - &instruction_data, - ) - } -} +pub const TRANSFER_ACCOUNTS_LEN: usize = 2; +pub const TRANSFER_DATA_SIZE: usize = 12; diff --git a/programs/system/src/invoke_parts.rs b/programs/system/src/invoke_parts.rs index 107faf60..ad040838 100644 --- a/programs/system/src/invoke_parts.rs +++ b/programs/system/src/invoke_parts.rs @@ -6,13 +6,15 @@ use pinocchio::{ ProgramResult, }; +use crate::instructions::{Transfer, TRANSFER_ACCOUNTS_LEN, TRANSFER_DATA_SIZE}; + type SliceInvokeParts<'a> = InvokeParts<&'a [&'a AccountInfo], &'a [AccountMeta<'a>], &'a [u8]>; -type FixedInvokeParts<'a, const N: usize> = - InvokeParts<&'a [&'a AccountInfo; N], &'a [AccountMeta<'a>], &'a [u8]>; +type FixedInvokeParts<'a, const N: usize, const M: usize> = + InvokeParts<[&'a AccountInfo; N], [AccountMeta<'a>; N], [u8; M]>; pub trait InvokePartsType: sealed::Sealed {} impl InvokePartsType for SliceInvokeParts<'_> {} -impl InvokePartsType for FixedInvokeParts<'_, N> {} +impl InvokePartsType for FixedInvokeParts<'_, N, M> {} pub struct InvokeParts { pub program_id: Pubkey, @@ -49,7 +51,7 @@ impl Invoke for SliceInvokeParts<'_> { } } -impl Invoke for FixedInvokeParts<'_, N> { +impl Invoke for FixedInvokeParts<'_, N, M> { fn invoke(self) -> ProgramResult { self.invoke_signed(&[]) } @@ -61,7 +63,7 @@ impl Invoke for FixedInvokeParts<'_, N> { data: &self.instruction_data, accounts: &self.account_metas, }, - self.accounts, + &self.accounts, signers, ) } @@ -85,7 +87,29 @@ mod sealed { use crate::invoke_parts::{FixedInvokeParts, IntoInvokeParts, SliceInvokeParts}; pub trait Sealed {} - impl<'a, const N: usize> Sealed for FixedInvokeParts<'a, N> {} + impl<'a, const N: usize, const M: usize> Sealed for FixedInvokeParts<'a, N, M> {} impl<'a> Sealed for SliceInvokeParts<'a> {} impl Sealed for T where T: IntoInvokeParts {} } + +impl<'a> IntoInvokeParts for Transfer<'a> { + type Output = FixedInvokeParts<'a, TRANSFER_ACCOUNTS_LEN, TRANSFER_DATA_SIZE>; + + fn into_invoke_parts(self) -> Self::Output { + // instruction data + // - [0..4 ]: instruction discriminator + // - [4..12]: lamports amount + let mut instruction_data = [0; 12]; + instruction_data[0] = 2; + instruction_data[4..12].copy_from_slice(&self.lamports.to_le_bytes()); + FixedInvokeParts { + program_id: crate::ID, + accounts: [&self.from, &self.to], + account_metas: [ + AccountMeta::writable_signer(self.from.key()), + AccountMeta::writable(self.to.key()), + ], + instruction_data: instruction_data, + } + } +} diff --git a/programs/system/src/invoker.rs b/programs/system/src/invoker.rs index e2bfa7a7..85f28c1d 100644 --- a/programs/system/src/invoker.rs +++ b/programs/system/src/invoker.rs @@ -7,6 +7,8 @@ use pinocchio::{ ProgramResult, }; +use crate::instructions::{Transfer, TRANSFER_ACCOUNTS_LEN}; + pub type ConstAccounts<'a, const ACCOUNTS_LEN: usize> = [&'a AccountInfo; ACCOUNTS_LEN]; pub type SliceAccounts<'a> = [&'a AccountInfo]; @@ -65,15 +67,7 @@ where { #[inline] fn invoke(&self) -> ProgramResult { - self.inner - .invoke_via(|program_id, accounts, account_metas, data| { - let instruction = Instruction { - program_id: program_id, - accounts: &account_metas, - data: data, - }; - pinocchio::cpi::invoke(&instruction, accounts) - }) + self.invoke_signed(&[]) } #[inline] @@ -96,15 +90,7 @@ where { #[inline] fn invoke(&self) -> ProgramResult { - self.inner - .invoke_via(|program_id, accounts, account_metas, data| { - let instruction = Instruction { - program_id: program_id, - accounts: &account_metas, - data: data, - }; - pinocchio::cpi::slice_invoke(&instruction, accounts) - }) + self.invoke_signed(&[]) } #[inline] @@ -120,3 +106,34 @@ where }) } } + +impl<'a> CanInvoke for Transfer<'a> { + type Accounts = [&'a AccountInfo; TRANSFER_ACCOUNTS_LEN]; + + fn invoke_via( + &self, + invoke: impl FnOnce( + /* program_id: */ &Pubkey, + /* accounts: */ &Self::Accounts, + /* account_metas: */ &[AccountMeta], + /* data: */ &[u8], + ) -> ProgramResult, + ) -> ProgramResult { + // instruction data + // - [0..4 ]: instruction discriminator + // - [4..12]: lamports amount + let mut instruction_data = [0; 12]; + instruction_data[0] = 2; + instruction_data[4..12].copy_from_slice(&self.lamports.to_le_bytes()); + + invoke( + &crate::ID, + &[self.from, self.to], + &[ + AccountMeta::writable_signer(self.from.key()), + AccountMeta::writable(self.to.key()), + ], + &instruction_data, + ) + } +} From 47e322df59668f088b67468f9a88363906ade7bf Mon Sep 17 00:00:00 2001 From: Flavio B Date: Sat, 2 Aug 2025 15:55:24 -0400 Subject: [PATCH 09/13] adds unsafe call to into_parts --- programs/system/src/invoke_parts.rs | 53 +++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/programs/system/src/invoke_parts.rs b/programs/system/src/invoke_parts.rs index ad040838..33c4b400 100644 --- a/programs/system/src/invoke_parts.rs +++ b/programs/system/src/invoke_parts.rs @@ -28,16 +28,21 @@ pub trait IntoInvokeParts { fn into_invoke_parts(self) -> Self::Output; } -pub trait Invoke: sealed::Sealed { - fn invoke(self) -> ProgramResult; - fn invoke_signed(self, signers: &[Signer]) -> ProgramResult; -} - -impl Invoke for SliceInvokeParts<'_> { +pub trait Invoke: sealed::Sealed + Sized { fn invoke(self) -> ProgramResult { self.invoke_signed(&[]) } + fn invoke_signed(self, signers: &[Signer]) -> ProgramResult; + + unsafe fn invoke_unchecked(self) { + self.invoke_signed_unchecked(&[]) + } + + unsafe fn invoke_signed_unchecked(self, signers: &[Signer]); +} + +impl Invoke for SliceInvokeParts<'_> { fn invoke_signed(self, signers: &[Signer]) -> ProgramResult { cpi::slice_invoke_signed( &Instruction { @@ -49,13 +54,21 @@ impl Invoke for SliceInvokeParts<'_> { signers, ) } -} -impl Invoke for FixedInvokeParts<'_, N, M> { - fn invoke(self) -> ProgramResult { - self.invoke_signed(&[]) + unsafe fn invoke_signed_unchecked(self, signers: &[Signer]) { + cpi::invoke_signed_unchecked( + &Instruction { + program_id: &self.program_id, + data: &self.instruction_data, + accounts: &self.account_metas, + }, + todo!(), + signers, + ) } +} +impl Invoke for FixedInvokeParts<'_, N, M> { fn invoke_signed(self, signers: &[Signer]) -> ProgramResult { cpi::invoke_signed( &Instruction { @@ -67,6 +80,18 @@ impl Invoke for FixedInvokeParts<'_, N, M> { signers, ) } + + unsafe fn invoke_signed_unchecked(self, signers: &[Signer]) { + cpi::invoke_signed_unchecked( + &Instruction { + program_id: &self.program_id, + data: &self.instruction_data, + accounts: &self.account_metas, + }, + todo!(), + signers, + ) + } } impl Invoke for T @@ -74,13 +99,13 @@ where T: IntoInvokeParts, T::Output: Invoke, { - fn invoke(self) -> ProgramResult { - self.into_invoke_parts().invoke() - } - fn invoke_signed(self, signers: &[Signer]) -> ProgramResult { self.into_invoke_parts().invoke_signed(signers) } + + unsafe fn invoke_signed_unchecked(self, signers: &[Signer]) { + self.into_invoke_parts().invoke_signed_unchecked(signers) + } } mod sealed { From 407eaf348bff8f378facdbae89e76d58097734a2 Mon Sep 17 00:00:00 2001 From: Flavio B Date: Sat, 2 Aug 2025 18:34:58 -0400 Subject: [PATCH 10/13] complete unsafe call for slice --- programs/system/src/invoke_parts.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/programs/system/src/invoke_parts.rs b/programs/system/src/invoke_parts.rs index 33c4b400..97088fa1 100644 --- a/programs/system/src/invoke_parts.rs +++ b/programs/system/src/invoke_parts.rs @@ -1,7 +1,9 @@ +use core::{mem::MaybeUninit, slice}; + use pinocchio::{ account_info::AccountInfo, - cpi, - instruction::{AccountMeta, Instruction, Signer}, + cpi::{self, MAX_CPI_ACCOUNTS}, + instruction::{Account, AccountMeta, Instruction, Signer}, pubkey::Pubkey, ProgramResult, }; @@ -56,13 +58,21 @@ impl Invoke for SliceInvokeParts<'_> { } unsafe fn invoke_signed_unchecked(self, signers: &[Signer]) { + const UNINIT: MaybeUninit = MaybeUninit::::uninit(); + let mut accounts = [UNINIT; MAX_CPI_ACCOUNTS]; + + self.accounts + .iter() + .enumerate() + .for_each(|(i, account)| accounts[i] = MaybeUninit::new(Account::from(*account))); + cpi::invoke_signed_unchecked( &Instruction { program_id: &self.program_id, data: &self.instruction_data, accounts: &self.account_metas, }, - todo!(), + slice::from_raw_parts(accounts.as_ptr() as _, self.accounts.len()), signers, ) } @@ -82,13 +92,14 @@ impl Invoke for FixedInvokeParts<'_, N, M> { } unsafe fn invoke_signed_unchecked(self, signers: &[Signer]) { + let accounts = self.accounts.map(Account::from); cpi::invoke_signed_unchecked( &Instruction { program_id: &self.program_id, data: &self.instruction_data, accounts: &self.account_metas, }, - todo!(), + &accounts, signers, ) } From 21fa578c8a7bdb535385b62bfc90c40395c8e4ee Mon Sep 17 00:00:00 2001 From: Flavio B Date: Sat, 2 Aug 2025 22:45:39 -0400 Subject: [PATCH 11/13] adds unsafe call to callback + exsample --- Cargo.lock | 13 ++++++-- Cargo.toml | 1 + examples/cpi-call/Cargo.toml | 15 +++++++++ examples/cpi-call/src/lib.rs | 23 ++++++++++++++ programs/system/src/callback.rs | 55 ++++++++++++++++++++++++++++----- 5 files changed, 98 insertions(+), 9 deletions(-) create mode 100644 examples/cpi-call/Cargo.toml create mode 100644 examples/cpi-call/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 5388b80b..510b3f8a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11,6 +11,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "cpi-call" +version = "0.1.0" +dependencies = [ + "pinocchio", + "pinocchio-pubkey", + "pinocchio-system", +] + [[package]] name = "five8_const" version = "0.1.4" @@ -95,9 +104,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.89" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" dependencies = [ "unicode-ident", ] diff --git a/Cargo.toml b/Cargo.toml index 85159322..2f5fa51d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,7 @@ [workspace] resolver = "2" members = [ + "examples/cpi-call", "programs/associated-token-account", "programs/memo", "programs/system", diff --git a/examples/cpi-call/Cargo.toml b/examples/cpi-call/Cargo.toml new file mode 100644 index 00000000..70b08349 --- /dev/null +++ b/examples/cpi-call/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "cpi-call" +version = "0.1.0" +edition.workspace = true +license.workspace = true +repository.workspace = true +rust-version.workspace = true + +[lib] +crate-type = ["cdylib", "lib"] + +[dependencies] +pinocchio = { workspace = true } +pinocchio-pubkey = { workspace = true } +pinocchio-system = { path = "../../programs/system" } diff --git a/examples/cpi-call/src/lib.rs b/examples/cpi-call/src/lib.rs new file mode 100644 index 00000000..008f8c23 --- /dev/null +++ b/examples/cpi-call/src/lib.rs @@ -0,0 +1,23 @@ +#![no_std] + +use pinocchio::{program_error::ProgramError, pubkey::Pubkey}; +use pinocchio_system::{callback::Invoke, instructions::Transfer}; + +use pinocchio::{no_allocator, nostd_panic_handler, program_entrypoint}; + +program_entrypoint!(crate::dispatch); +nostd_panic_handler!(); +no_allocator!(); + +pub fn dispatch<'info>( + _program_id: &Pubkey, + accounts: &'info [pinocchio::account_info::AccountInfo], + _payload: &[u8], +) -> Result<(), ProgramError> { + Transfer { + from: &accounts[0], + to: &accounts[1], + lamports: 1_000_000_000, + } + .invoke() +} diff --git a/programs/system/src/callback.rs b/programs/system/src/callback.rs index 78b22130..f5f53871 100644 --- a/programs/system/src/callback.rs +++ b/programs/system/src/callback.rs @@ -1,7 +1,9 @@ +use core::{mem::MaybeUninit, slice}; + use pinocchio::{ account_info::AccountInfo, - cpi, - instruction::{AccountMeta, Instruction, Signer}, + cpi::{self, MAX_CPI_ACCOUNTS}, + instruction::{Account, AccountMeta, Instruction, Signer}, pubkey::Pubkey, ProgramResult, }; @@ -34,18 +36,23 @@ pub trait CanInvoke { } pub trait Invoke: sealed::Sealed { - fn invoke(&self) -> ProgramResult; + fn invoke(&self) -> ProgramResult { + self.invoke_signed(&[]) + } + fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult; + + unsafe fn invoke_unchecked(&self) { + self.invoke_signed_unchecked(&[]) + } + + unsafe fn invoke_signed_unchecked(&self, signers: &[Signer]); } impl<'a, const ACCOUNTS_LEN: usize, T> Invoke for T where T: CanInvoke, { - fn invoke(&self) -> ProgramResult { - self.invoke_signed(&[]) - } - fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult { self.invoke_via( |program_id, accounts, account_metas, data| { @@ -66,6 +73,40 @@ where }, ) } + unsafe fn invoke_signed_unchecked(&self, signers: &[Signer]) { + self.invoke_via( + |program_id, accounts, account_metas, data| unsafe { + let instruction = Instruction { + program_id, + accounts: &account_metas, + data, + }; + cpi::invoke_signed_unchecked(&instruction, &accounts.map(Account::from), signers); + Ok(()) + }, + |program_id, accounts, account_metas, data| unsafe { + const UNINIT: MaybeUninit = MaybeUninit::::uninit(); + let mut ix_accounts = [UNINIT; MAX_CPI_ACCOUNTS]; + + accounts.iter().enumerate().for_each(|(i, account)| { + ix_accounts[i] = MaybeUninit::new(Account::from(*account)) + }); + + let instruction = Instruction { + program_id, + accounts: &account_metas, + data, + }; + cpi::invoke_signed_unchecked( + &instruction, + slice::from_raw_parts(ix_accounts.as_ptr() as _, accounts.len()), + signers, + ); + Ok(()) + }, + ) + .unwrap(); + } } impl<'a> CanInvoke for Transfer<'a> { From 0ec5673a267a2d5a60476ce90194767a8aa14be0 Mon Sep 17 00:00:00 2001 From: Flavio B Date: Sun, 3 Aug 2025 00:17:11 -0400 Subject: [PATCH 12/13] testing --- call_dump_asm.txt | 848 ++++++++++++++++++++++++++++ parts_dump_asm.txt | 848 ++++++++++++++++++++++++++++ programs/system/src/invoke_parts.rs | 9 + 3 files changed, 1705 insertions(+) create mode 100644 call_dump_asm.txt create mode 100644 parts_dump_asm.txt diff --git a/call_dump_asm.txt b/call_dump_asm.txt new file mode 100644 index 00000000..7132a214 --- /dev/null +++ b/call_dump_asm.txt @@ -0,0 +1,848 @@ +0000000000000490 +ldxdw r4, [r1 + 0x0] +jeq r4, 0x0, +0x6b +mov64 r2, r1 +add64 r2, 0x8 +stxdw [r10 - 0x7f0], r2 +jeq r4, 0x1, +0x67 +ldxdw r2, [r1 + 0x58] +add64 r1, r2 +add64 r1, 0x286f +and64 r1, -0x8 +jeq r4, 0x2, +0x5f +mov64 r2, r10 +add64 r2, -0x7f0 +mov64 r3, r4 +jlt r4, 0x6, +0x54 +mov64 r2, r10 +add64 r2, -0x7f0 +mov64 r3, r4 +ldxb r5, [r1 + 0x0] +jeq r5, 0xff, +0x1 +ja +0x25 +stxdw [r2 + 0x8], r1 +ldxdw r5, [r1 + 0x50] +add64 r1, r5 +add64 r1, 0x2867 +and64 r1, -0x8 +ldxb r5, [r1 + 0x0] +jne r5, 0xff, +0x26 +stxdw [r2 + 0x10], r1 +ldxdw r5, [r1 + 0x50] +add64 r1, r5 +add64 r1, 0x2867 +and64 r1, -0x8 +ldxb r5, [r1 + 0x0] +jne r5, 0xff, +0x27 +stxdw [r2 + 0x18], r1 +ldxdw r5, [r1 + 0x50] +add64 r1, r5 +add64 r1, 0x2867 +and64 r1, -0x8 +ldxb r5, [r1 + 0x0] +jne r5, 0xff, +0x28 +stxdw [r2 + 0x20], r1 +ldxdw r5, [r1 + 0x50] +add64 r1, r5 +add64 r1, 0x2867 +and64 r1, -0x8 +add64 r2, 0x28 +ldxb r5, [r1 + 0x0] +jne r5, 0xff, +0x28 +stxdw [r2 + 0x0], r1 +ldxdw r5, [r1 + 0x50] +add64 r1, r5 +add64 r1, 0x2867 +and64 r1, -0x8 +add64 r3, -0x5 +jgt r3, 0x5, -0x27 +ja +0x29 +lsh64 r5, 0x3 +mov64 r0, r10 +add64 r0, -0x7f0 +add64 r0, r5 +ldxdw r5, [r0 + 0x0] +stxdw [r2 + 0x8], r5 +add64 r1, 0x8 +ja -0x28 +lsh64 r5, 0x3 +mov64 r0, r10 +add64 r0, -0x7f0 +add64 r0, r5 +ldxdw r5, [r0 + 0x0] +stxdw [r2 + 0x10], r5 +add64 r1, 0x8 +ja -0x29 +lsh64 r5, 0x3 +mov64 r0, r10 +add64 r0, -0x7f0 +add64 r0, r5 +ldxdw r5, [r0 + 0x0] +stxdw [r2 + 0x18], r5 +add64 r1, 0x8 +ja -0x2a +lsh64 r5, 0x3 +mov64 r0, r10 +add64 r0, -0x7f0 +add64 r0, r5 +ldxdw r5, [r0 + 0x0] +stxdw [r2 + 0x20], r5 +add64 r1, 0x8 +ja -0x2b +lsh64 r5, 0x3 +mov64 r0, r10 +add64 r0, -0x7f0 +add64 r0, r5 +ldxdw r5, [r0 + 0x0] +stxdw [r2 + 0x0], r5 +add64 r1, 0x8 +add64 r3, -0x5 +jgt r3, 0x5, -0x51 +jsgt r3, 0x2, +0x35 +jeq r3, 0x1, +0x8 +ldxb r3, [r1 + 0x0] +jeq r3, 0xff, +0x1 +ja +0xf8 +stxdw [r2 + 0x8], r1 +ja +0x3 +ldxb r2, [r1 + 0x0] +jne r2, 0xff, +0xa9 +stxdw [r10 - 0x7e8], r1 +mov64 r1, r10 +add64 r1, -0x7f8 +mov64 r3, r10 +add64 r3, -0x7f0 +mov64 r5, r10 +call -0xe1 +ldxw r1, [r10 - 0x7f8] +jsgt r1, 0xd, +0x7 +jsgt r1, 0x6, +0xd +jsgt r1, 0x3, +0x3e +jlt r1, 0x2, +0x47 +jeq r1, 0x2, +0x7e +lddw r0, 0x400000000 +ja +0x98 +jsgt r1, 0x13, +0xc +jsgt r1, 0x10, +0x3c +jeq r1, 0xe, +0x81 +jeq r1, 0xf, +0x8f +lddw r0, 0x1100000000 +ja +0x91 +jsgt r1, 0x9, +0xb +jeq r1, 0x7, +0x63 +jeq r1, 0x8, +0x6b +lddw r0, 0xa00000000 +ja +0x8b +jsgt r1, 0x16, +0xa +jeq r1, 0x14, +0x63 +jeq r1, 0x15, +0x7a +lddw r0, 0x1700000000 +ja +0x85 +jsgt r1, 0xb, +0x32 +jeq r1, 0xa, +0x69 +lddw r0, 0xc00000000 +ja +0x80 +jsgt r1, 0x18, +0x31 +jeq r1, 0x17, +0x73 +lddw r0, 0x1900000000 +ja +0x7b +jeq r3, 0x3, +0x2f +jeq r3, 0x4, +0x3a +ldxb r3, [r1 + 0x0] +jeq r3, 0xff, +0x1 +ja +0x8c +stxdw [r2 + 0x8], r1 +ldxdw r3, [r1 + 0x50] +add64 r1, r3 +add64 r1, 0x2867 +and64 r1, -0x8 +ldxb r3, [r1 + 0x0] +jne r3, 0xff, +0x8d +stxdw [r2 + 0x10], r1 +ldxdw r3, [r1 + 0x50] +add64 r1, r3 +add64 r1, 0x2867 +and64 r1, -0x8 +ldxb r3, [r1 + 0x0] +jne r3, 0xff, +0x8e +stxdw [r2 + 0x18], r1 +ldxdw r3, [r1 + 0x50] +add64 r1, r3 +add64 r1, 0x2867 +and64 r1, -0x8 +ldxb r3, [r1 + 0x0] +jne r3, 0xff, +0x8f +stxdw [r2 + 0x20], r1 +ja -0x48 +jeq r1, 0x4, +0x35 +jeq r1, 0x5, +0x3d +lddw r0, 0x700000000 +ja +0x5a +jeq r1, 0x11, +0x48 +jeq r1, 0x12, +0x56 +lddw r0, 0x1400000000 +ja +0x55 +lddw r0, 0x200000000 +ja +0x52 +jeq r1, 0xc, +0x3a +lddw r0, 0xe00000000 +ja +0x4e +jeq r1, 0x19, +0x45 +mov64 r0, 0x0 +ja +0x4b +ldxb r3, [r1 + 0x0] +jeq r3, 0xff, +0x1 +ja +0x4f +stxdw [r2 + 0x8], r1 +ldxdw r3, [r1 + 0x50] +add64 r1, r3 +add64 r1, 0x2867 +and64 r1, -0x8 +ldxb r3, [r1 + 0x0] +jne r3, 0xff, +0x50 +stxdw [r2 + 0x10], r1 +ja -0x68 +ldxb r3, [r1 + 0x0] +jeq r3, 0xff, +0x1 +ja +0x71 +stxdw [r2 + 0x8], r1 +ldxdw r3, [r1 + 0x50] +add64 r1, r3 +add64 r1, 0x2867 +and64 r1, -0x8 +ldxb r3, [r1 + 0x0] +jne r3, 0xff, +0x72 +stxdw [r2 + 0x10], r1 +ldxdw r3, [r1 + 0x50] +add64 r1, r3 +add64 r1, 0x2867 +and64 r1, -0x8 +ldxb r3, [r1 + 0x0] +jne r3, 0xff, +0x73 +stxdw [r2 + 0x18], r1 +ja -0x7b +lddw r0, 0x800000000 +ja +0x29 +lddw r0, 0x500000000 +ja +0x26 +lddw r0, 0x1500000000 +ja +0x23 +lddw r0, 0x900000000 +ja +0x20 +lddw r0, 0x600000000 +ja +0x1d +lddw r0, 0x300000000 +ja +0x1a +lddw r0, 0xb00000000 +ja +0x17 +lddw r0, 0xd00000000 +ja +0x14 +lddw r0, 0xf00000000 +ja +0x11 +lddw r0, 0x1200000000 +ja +0xe +lddw r0, 0x1600000000 +ja +0xb +lddw r0, 0x1800000000 +ja +0x8 +lddw r0, 0x1a00000000 +ja +0x5 +lddw r0, 0x1000000000 +ja +0x2 +lddw r0, 0x1300000000 +exit +lsh64 r2, 0x3 +mov64 r1, r10 +add64 r1, -0x7f0 +add64 r1, r2 +ldxdw r1, [r1 + 0x0] +ja -0xaf +lsh64 r3, 0x3 +mov64 r5, r10 +add64 r5, -0x7f0 +add64 r5, r3 +ldxdw r3, [r5 + 0x0] +stxdw [r2 + 0x8], r3 +add64 r1, 0x8 +ja -0x52 +lsh64 r3, 0x3 +mov64 r1, r10 +add64 r1, -0x7f0 +add64 r1, r3 +ldxdw r1, [r1 + 0x0] +stxdw [r2 + 0x10], r1 +ja -0xbd +lsh64 r3, 0x3 +mov64 r5, r10 +add64 r5, -0x7f0 +add64 r5, r3 +ldxdw r3, [r5 + 0x0] +stxdw [r2 + 0x8], r3 +add64 r1, 0x8 +ja -0x8f +lsh64 r3, 0x3 +mov64 r5, r10 +add64 r5, -0x7f0 +add64 r5, r3 +ldxdw r3, [r5 + 0x0] +stxdw [r2 + 0x10], r3 +add64 r1, 0x8 +ja -0x90 +lsh64 r3, 0x3 +mov64 r5, r10 +add64 r5, -0x7f0 +add64 r5, r3 +ldxdw r3, [r5 + 0x0] +stxdw [r2 + 0x18], r3 +add64 r1, 0x8 +ja -0x91 +lsh64 r3, 0x3 +mov64 r1, r10 +add64 r1, -0x7f0 +add64 r1, r3 +ldxdw r1, [r1 + 0x0] +stxdw [r2 + 0x20], r1 +ja -0xdc +lsh64 r3, 0x3 +mov64 r5, r10 +add64 r5, -0x7f0 +add64 r5, r3 +ldxdw r3, [r5 + 0x0] +stxdw [r2 + 0x8], r3 +add64 r1, 0x8 +ja -0x74 +lsh64 r3, 0x3 +mov64 r5, r10 +add64 r5, -0x7f0 +add64 r5, r3 +ldxdw r3, [r5 + 0x0] +stxdw [r2 + 0x10], r3 +add64 r1, 0x8 +ja -0x75 +lsh64 r3, 0x3 +mov64 r1, r10 +add64 r1, -0x7f0 +add64 r1, r3 +ldxdw r1, [r1 + 0x0] +stxdw [r2 + 0x18], r1 +ja -0xf3 +lsh64 r3, 0x3 +mov64 r1, r10 +add64 r1, -0x7f0 +add64 r1, r3 +ldxdw r1, [r1 + 0x0] +stxdw [r2 + 0x8], r1 +ja -0xfa +ldxdw r1, [r1 + 0x8] +ldxw r4, [r1 + 0x14] +ldxw r3, [r1 + 0x10] +ldxdw r2, [r1 + 0x8] +ldxdw r1, [r1 + 0x0] +call -0x1 +stxdw [r10 - 0x10], r2 +stxdw [r10 - 0x18], r1 +sth [r10 - 0x8], 0x1 +mov64 r1, r10 +add64 r1, -0x18 +call -0xc +stxdw [r10 - 0x58], r2 +stxdw [r10 - 0x60], r1 +lddw r1, 0x2198 +stxdw [r10 - 0x50], r1 +mov64 r1, r10 +add64 r1, -0x20 +stxdw [r10 - 0x40], r1 +mov64 r1, r10 +add64 r1, -0x60 +stxdw [r10 - 0x10], r1 +lddw r1, 0x1d60 +stxdw [r10 - 0x8], r1 +stxdw [r10 - 0x18], r1 +mov64 r1, r10 +add64 r1, -0x58 +stxdw [r10 - 0x20], r1 +stdw [r10 - 0x30], 0x0 +stdw [r10 - 0x48], 0x2 +stdw [r10 - 0x38], 0x2 +mov64 r1, r10 +add64 r1, -0x50 +mov64 r2, r3 +call -0x1f +mov64 r6, r1 +ldxdw r0, [r5 - 0xff8] +jne r2, 0x0, +0x3 +mov64 r2, 0x2d +ldxw r7, [r6 + 0x34] +ja +0x17 +mov64 r2, 0x110000 +ldxw r7, [r6 + 0x34] +mov64 r1, r7 +and64 r1, 0x1 +mov64 r9, r0 +jne r1, 0x0, +0x10 +stxdw [r10 - 0x28], r0 +ldxdw r1, [r5 - 0x1000] +stxdw [r10 - 0x30], r1 +mov64 r8, 0x0 +mov64 r1, r7 +and64 r1, 0x4 +jeq r1, 0x0, +0x21 +stxdw [r10 - 0x40], r2 +stxdw [r10 - 0x48], r6 +stxdw [r10 - 0x38], r4 +jlt r4, 0x20, +0x9 +mov64 r8, r3 +mov64 r1, r3 +mov64 r2, r4 +call 0xd0 +ja +0x13 +mov64 r2, 0x2b +mov64 r9, r0 +add64 r9, 0x1 +ja -0x14 +mov64 r8, r3 +mov64 r0, 0x0 +jeq r4, 0x0, +0xc +mov64 r1, r8 +ldxdw r2, [r10 - 0x38] +ldxb r4, [r1 + 0x0] +lsh64 r4, 0x38 +arsh64 r4, 0x38 +mov64 r3, 0x1 +jsgt r4, -0x41, +0x1 +mov64 r3, 0x0 +add64 r0, r3 +add64 r1, 0x1 +add64 r2, -0x1 +jne r2, 0x0, -0xa +add64 r0, r9 +mov64 r9, r0 +ldxdw r6, [r10 - 0x48] +ldxdw r4, [r10 - 0x38] +ldxdw r2, [r10 - 0x40] +ldxdw r1, [r6 + 0x0] +jne r1, 0x0, +0x6 +mov64 r1, r6 +mov64 r3, r8 +call 0x77 +mov64 r7, 0x1 +jne r0, 0x0, +0x3e +ja +0x36 +ldxdw r3, [r6 + 0x8] +jgt r3, r9, +0x1 +ja +0x2e +and64 r7, 0x8 +jeq r7, 0x0, +0x1 +ja +0x3a +stxdw [r10 - 0x40], r2 +stxdw [r10 - 0x38], r4 +sub64 r3, r9 +mov64 r1, r10 +add64 r1, -0x20 +mov64 r7, 0x1 +mov64 r2, r6 +mov64 r9, r6 +mov64 r4, 0x1 +call 0x7c +ldxw r1, [r10 - 0x18] +stxdw [r10 - 0x48], r1 +jeq r1, 0x110000, +0x2a +ldxdw r6, [r10 - 0x20] +mov64 r1, r9 +ldxdw r2, [r10 - 0x40] +mov64 r3, r8 +ldxdw r4, [r10 - 0x38] +call 0x5b +jne r0, 0x0, +0x23 +ldxdw r8, [r9 + 0x20] +ldxdw r9, [r9 + 0x28] +ldxdw r4, [r9 + 0x18] +mov64 r1, r8 +ldxdw r2, [r10 - 0x30] +ldxdw r3, [r10 - 0x28] +callx r4 +jne r0, 0x0, +0x1b +mov64 r7, 0x0 +mov64 r1, r6 +jeq r6, r7, +0x8 +ldxdw r3, [r9 + 0x20] +mov64 r1, r8 +ldxdw r2, [r10 - 0x48] +callx r3 +add64 r7, 0x1 +jeq r0, 0x0, -0x8 +add64 r7, -0x1 +mov64 r1, r7 +mov64 r7, 0x1 +jlt r1, r6, +0xe +mov64 r7, 0x0 +ja +0xc +mov64 r1, r6 +mov64 r3, r8 +call 0x40 +mov64 r7, 0x1 +jne r0, 0x0, +0x7 +ldxdw r1, [r6 + 0x20] +ldxdw r2, [r6 + 0x28] +ldxdw r4, [r2 + 0x18] +ldxdw r2, [r10 - 0x30] +ldxdw r3, [r10 - 0x28] +callx r4 +mov64 r7, r0 +and64 r7, 0x1 +mov64 r0, r7 +exit +stxdw [r10 - 0x40], r3 +ldxw r1, [r6 + 0x30] +stxdw [r10 - 0x50], r1 +stw [r6 + 0x30], 0x30 +ldxb r1, [r6 + 0x38] +stxdw [r10 - 0x58], r1 +stb [r6 + 0x38], 0x1 +mov64 r1, r6 +mov64 r3, r8 +call 0x2a +mov64 r7, 0x1 +jne r0, 0x0, -0xf +ldxdw r3, [r10 - 0x40] +sub64 r3, r9 +mov64 r1, r10 +add64 r1, -0x10 +mov64 r2, r6 +mov64 r4, 0x1 +call 0x39 +ldxw r8, [r10 - 0x8] +jeq r8, 0x110000, -0x18 +ldxdw r1, [r10 - 0x10] +stxdw [r10 - 0x38], r1 +ldxdw r1, [r6 + 0x20] +ldxdw r2, [r6 + 0x28] +stxdw [r10 - 0x48], r2 +ldxdw r4, [r2 + 0x18] +stxdw [r10 - 0x40], r1 +ldxdw r2, [r10 - 0x30] +ldxdw r3, [r10 - 0x28] +callx r4 +jne r0, 0x0, -0x23 +mov64 r9, 0x0 +mov64 r1, r6 +ldxdw r2, [r10 - 0x38] +jeq r2, r9, +0xb +ldxdw r1, [r10 - 0x48] +ldxdw r3, [r1 + 0x20] +ldxdw r1, [r10 - 0x40] +mov64 r2, r8 +callx r3 +add64 r9, 0x1 +jeq r0, 0x0, -0xa +add64 r9, -0x1 +mov64 r1, r6 +ldxdw r2, [r10 - 0x38] +jlt r9, r2, -0x32 +ldxdw r2, [r10 - 0x58] +stxb [r1 + 0x38], r2 +ldxdw r2, [r10 - 0x50] +stxw [r1 + 0x30], r2 +ja -0x45 +mov64 r6, r4 +mov64 r7, r3 +mov64 r8, r1 +mov64 r1, r2 +lsh64 r1, 0x20 +rsh64 r1, 0x20 +jeq r1, 0x110000, +0x7 +ldxdw r1, [r8 + 0x20] +ldxdw r3, [r8 + 0x28] +ldxdw r3, [r3 + 0x20] +callx r3 +mov64 r1, r0 +mov64 r0, 0x1 +jne r1, 0x0, +0x2 +mov64 r0, 0x0 +jne r7, 0x0, +0x1 +exit +ldxdw r1, [r8 + 0x20] +ldxdw r2, [r8 + 0x28] +ldxdw r4, [r2 + 0x18] +mov64 r2, r7 +mov64 r3, r6 +callx r4 +ja -0x8 +stxdw [r10 - 0x10], r1 +ldxb r6, [r2 + 0x38] +jsgt r6, 0x1, +0x2 +jeq r6, 0x0, +0xc +ja +0x4 +jeq r6, 0x2, +0x6 +mov64 r6, 0x0 +and64 r4, 0xff +jeq r4, 0x0, +0x7 +mov64 r6, r3 +mov64 r3, 0x0 +ja +0x4 +mov64 r6, r3 +rsh64 r6, 0x1 +add64 r3, 0x1 +rsh64 r3, 0x1 +stxdw [r10 - 0x8], r3 +add64 r6, 0x1 +ldxw r8, [r2 + 0x30] +ldxdw r7, [r2 + 0x28] +ldxdw r9, [r2 + 0x20] +add64 r6, -0x1 +mov64 r1, r8 +jeq r6, 0x0, +0x6 +ldxdw r3, [r7 + 0x20] +mov64 r1, r9 +mov64 r2, r8 +callx r3 +mov64 r1, 0x110000 +jeq r0, 0x0, -0x9 +ldxdw r2, [r10 - 0x10] +stxw [r2 + 0x8], r1 +ldxdw r1, [r10 - 0x8] +stxdw [r2 + 0x0], r1 +exit +mov64 r7, r1 +add64 r7, 0x7 +and64 r7, -0x8 +mov64 r3, r7 +sub64 r3, r1 +jlt r2, r3, +0x8f +mov64 r5, r2 +sub64 r5, r3 +jlt r5, 0x8, +0x8c +stxdw [r10 - 0x8], r3 +mov64 r2, r5 +and64 r2, 0x7 +mov64 r0, 0x0 +mov64 r3, 0x0 +jeq r7, r1, +0x10 +mov64 r6, r1 +sub64 r6, r7 +mov64 r7, r1 +ldxb r4, [r7 + 0x0] +lsh64 r4, 0x38 +arsh64 r4, 0x38 +mov64 r8, 0x1 +mov64 r9, 0x1 +jsgt r4, -0x41, +0x1 +mov64 r9, 0x0 +add64 r6, 0x1 +jeq r6, 0x0, +0x1 +mov64 r8, 0x0 +add64 r3, r9 +add64 r7, 0x1 +jne r8, 0x1, -0xd +ldxdw r4, [r10 - 0x8] +add64 r1, r4 +jeq r2, 0x0, +0xf +mov64 r0, r5 +and64 r0, -0x8 +mov64 r4, r1 +add64 r4, r0 +mov64 r0, 0x0 +ldxb r7, [r4 + 0x0] +lsh64 r7, 0x38 +arsh64 r7, 0x38 +mov64 r6, 0x1 +jsgt r7, -0x41, +0x1 +mov64 r6, 0x0 +add64 r0, r6 +add64 r4, 0x1 +add64 r2, -0x1 +jne r2, 0x0, -0xa +rsh64 r5, 0x3 +add64 r0, r3 +lddw r9, 0x101010101010101 +mov64 r3, r5 +jeq r3, 0x0, +0x6b +stxdw [r10 - 0x8], r1 +mov64 r5, r3 +jlt r3, 0xc0, +0x1 +mov64 r5, 0xc0 +stxdw [r10 - 0x10], r5 +lsh64 r5, 0x3 +mov64 r4, 0x0 +jlt r3, 0x4, +0x19 +mov64 r2, r5 +and64 r2, 0x7e0 +ldxdw r6, [r10 - 0x8] +mov64 r1, r6 +add64 r1, r2 +mov64 r2, r6 +ja +0x2 +add64 r2, 0x20 +jeq r2, r1, +0x10 +mov64 r6, r4 +mov64 r7, 0x0 +mov64 r4, r2 +add64 r4, r7 +ldxdw r4, [r4 + 0x0] +mov64 r8, r4 +rsh64 r8, 0x6 +xor64 r4, -0x1 +rsh64 r4, 0x7 +or64 r4, r8 +and64 r4, r9 +add64 r4, r6 +add64 r7, 0x8 +mov64 r6, r4 +jeq r7, 0x20, -0x11 +ja -0xe +ldxdw r1, [r10 - 0x8] +add64 r1, r5 +ldxdw r7, [r10 - 0x10] +mov64 r2, r7 +and64 r2, 0x3 +mov64 r8, r3 +sub64 r3, r7 +mov64 r6, r4 +lddw r5, 0xff00ff00ff00ff +and64 r6, r5 +rsh64 r4, 0x8 +and64 r4, r5 +mov64 r5, r3 +add64 r4, r6 +lddw r6, 0x1000100010001 +mul64 r4, r6 +rsh64 r4, 0x30 +add64 r4, r0 +mov64 r0, r4 +jeq r2, 0x0, -0x39 +mov64 r0, 0x0 +ldxdw r6, [r10 - 0x8] +jeq r2, 0x0, +0x17 +and64 r7, 0xfc +lsh64 r7, 0x3 +jlt r8, 0xc0, +0x1 +mov64 r8, 0xc0 +add64 r6, r7 +mov64 r2, 0x0 +and64 r8, 0x3 +lsh64 r8, 0x3 +lddw r1, 0x101010101010101 +ldxdw r0, [r6 + 0x0] +mov64 r5, r0 +rsh64 r5, 0x6 +xor64 r0, -0x1 +rsh64 r0, 0x7 +or64 r0, r5 +and64 r0, r1 +add64 r0, r2 +add64 r6, 0x8 +add64 r8, -0x8 +mov64 r2, r0 +jeq r8, 0x0, +0x1 +ja -0xd +lddw r1, 0xff00ff00ff00ff +mov64 r2, r0 +and64 r2, r1 +rsh64 r0, 0x8 +and64 r0, r1 +add64 r0, r2 +lddw r1, 0x1000100010001 +mul64 r0, r1 +rsh64 r0, 0x30 +add64 r0, r4 +ja +0xd +mov64 r0, 0x0 +jeq r2, 0x0, +0xb +ldxb r4, [r1 + 0x0] +lsh64 r4, 0x38 +arsh64 r4, 0x38 +mov64 r3, 0x1 +jsgt r4, -0x41, +0x1 +mov64 r3, 0x0 +add64 r0, r3 +add64 r1, 0x1 +add64 r2, -0x1 +jeq r2, 0x0, +0x1 +ja -0xb +exit +mov64 r3, r2 +ldxdw r1, [r1 + 0x0] +mov64 r2, 0x1 +call 0x1 +exit +mov64 r4, 0x14 +jlt r1, 0x2710, +0x20 +mov64 r4, 0x0 +mov64 r5, r1 +div64 r1, 0x2710 +mov64 r6, r1 +mul64 r6, 0x2710 +mov64 r0, r5 +sub64 r0, r6 +mov64 r6, r0 +and64 r6, 0xffff +div64 r6, 0x64 +mov64 r7, r6 +mul64 r7, 0x64 +sub64 r0, r7 +mov64 r7, r10 +add64 r7, -0x14 +add64 r7, r4 +lsh64 r6, 0x1 +lddw r8, 0x209e +add64 r8, r6 +ldxh r6, [r8 + 0x0] +stxh [r7 + 0x10], r6 +lsh64 r0, 0x1 +and64 r0, 0xfffe +lddw r6, 0x209e +add64 r6, r0 +ldxh r0, [r6 + 0x0] +stxh [r7 + 0x12], r0 +add64 r4, -0x4 +jgt r5, 0x5f5e0ff, -0x1e +add64 r4, 0x14 +jgt r1, 0x63, +0x1 +ja +0x12 +mov64 r5, r1 +and64 r5, 0xffff +div64 r5, 0x64 +mov64 r0, r5 +mul64 r0, 0x64 +sub64 r1, r0 +lsh64 r1, 0x1 +and64 r1, 0xfffe +lddw r0, 0x209e +add64 r0, r1 +add64 r4, -0x2 +mov64 r1, r10 +add64 r1, -0x14 +add64 r1, r4 +ldxh r0, [r0 + 0x0] +stxh [r1 + 0x0], r0 +mov64 r1, r5 +jlt r1, 0xa, +0xb +lsh64 r1, 0x1 +lddw r5, 0x209e +add64 r5, r1 +add64 r4, -0x2 +mov64 r1, r10 +add64 r1, -0x14 +add64 r1, r4 +ldxh r5, [r5 + 0x0] +stxh [r1 + 0x0], r5 +ja +0x6 +add64 r4, -0x1 +mov64 r5, r10 +add64 r5, -0x14 +add64 r5, r4 +or64 r1, 0x30 +stxb [r5 + 0x0], r1 +mov64 r1, 0x14 +sub64 r1, r4 +stxdw [r10 - 0xff8], r1 +mov64 r1, r10 +add64 r1, -0x14 +add64 r1, r4 +stxdw [r10 - 0x1000], r1 +mov64 r5, r10 +mov64 r1, r3 +mov64 r3, 0x1 +mov64 r4, 0x0 +call -0x1e7 +exit diff --git a/parts_dump_asm.txt b/parts_dump_asm.txt new file mode 100644 index 00000000..7132a214 --- /dev/null +++ b/parts_dump_asm.txt @@ -0,0 +1,848 @@ +0000000000000490 +ldxdw r4, [r1 + 0x0] +jeq r4, 0x0, +0x6b +mov64 r2, r1 +add64 r2, 0x8 +stxdw [r10 - 0x7f0], r2 +jeq r4, 0x1, +0x67 +ldxdw r2, [r1 + 0x58] +add64 r1, r2 +add64 r1, 0x286f +and64 r1, -0x8 +jeq r4, 0x2, +0x5f +mov64 r2, r10 +add64 r2, -0x7f0 +mov64 r3, r4 +jlt r4, 0x6, +0x54 +mov64 r2, r10 +add64 r2, -0x7f0 +mov64 r3, r4 +ldxb r5, [r1 + 0x0] +jeq r5, 0xff, +0x1 +ja +0x25 +stxdw [r2 + 0x8], r1 +ldxdw r5, [r1 + 0x50] +add64 r1, r5 +add64 r1, 0x2867 +and64 r1, -0x8 +ldxb r5, [r1 + 0x0] +jne r5, 0xff, +0x26 +stxdw [r2 + 0x10], r1 +ldxdw r5, [r1 + 0x50] +add64 r1, r5 +add64 r1, 0x2867 +and64 r1, -0x8 +ldxb r5, [r1 + 0x0] +jne r5, 0xff, +0x27 +stxdw [r2 + 0x18], r1 +ldxdw r5, [r1 + 0x50] +add64 r1, r5 +add64 r1, 0x2867 +and64 r1, -0x8 +ldxb r5, [r1 + 0x0] +jne r5, 0xff, +0x28 +stxdw [r2 + 0x20], r1 +ldxdw r5, [r1 + 0x50] +add64 r1, r5 +add64 r1, 0x2867 +and64 r1, -0x8 +add64 r2, 0x28 +ldxb r5, [r1 + 0x0] +jne r5, 0xff, +0x28 +stxdw [r2 + 0x0], r1 +ldxdw r5, [r1 + 0x50] +add64 r1, r5 +add64 r1, 0x2867 +and64 r1, -0x8 +add64 r3, -0x5 +jgt r3, 0x5, -0x27 +ja +0x29 +lsh64 r5, 0x3 +mov64 r0, r10 +add64 r0, -0x7f0 +add64 r0, r5 +ldxdw r5, [r0 + 0x0] +stxdw [r2 + 0x8], r5 +add64 r1, 0x8 +ja -0x28 +lsh64 r5, 0x3 +mov64 r0, r10 +add64 r0, -0x7f0 +add64 r0, r5 +ldxdw r5, [r0 + 0x0] +stxdw [r2 + 0x10], r5 +add64 r1, 0x8 +ja -0x29 +lsh64 r5, 0x3 +mov64 r0, r10 +add64 r0, -0x7f0 +add64 r0, r5 +ldxdw r5, [r0 + 0x0] +stxdw [r2 + 0x18], r5 +add64 r1, 0x8 +ja -0x2a +lsh64 r5, 0x3 +mov64 r0, r10 +add64 r0, -0x7f0 +add64 r0, r5 +ldxdw r5, [r0 + 0x0] +stxdw [r2 + 0x20], r5 +add64 r1, 0x8 +ja -0x2b +lsh64 r5, 0x3 +mov64 r0, r10 +add64 r0, -0x7f0 +add64 r0, r5 +ldxdw r5, [r0 + 0x0] +stxdw [r2 + 0x0], r5 +add64 r1, 0x8 +add64 r3, -0x5 +jgt r3, 0x5, -0x51 +jsgt r3, 0x2, +0x35 +jeq r3, 0x1, +0x8 +ldxb r3, [r1 + 0x0] +jeq r3, 0xff, +0x1 +ja +0xf8 +stxdw [r2 + 0x8], r1 +ja +0x3 +ldxb r2, [r1 + 0x0] +jne r2, 0xff, +0xa9 +stxdw [r10 - 0x7e8], r1 +mov64 r1, r10 +add64 r1, -0x7f8 +mov64 r3, r10 +add64 r3, -0x7f0 +mov64 r5, r10 +call -0xe1 +ldxw r1, [r10 - 0x7f8] +jsgt r1, 0xd, +0x7 +jsgt r1, 0x6, +0xd +jsgt r1, 0x3, +0x3e +jlt r1, 0x2, +0x47 +jeq r1, 0x2, +0x7e +lddw r0, 0x400000000 +ja +0x98 +jsgt r1, 0x13, +0xc +jsgt r1, 0x10, +0x3c +jeq r1, 0xe, +0x81 +jeq r1, 0xf, +0x8f +lddw r0, 0x1100000000 +ja +0x91 +jsgt r1, 0x9, +0xb +jeq r1, 0x7, +0x63 +jeq r1, 0x8, +0x6b +lddw r0, 0xa00000000 +ja +0x8b +jsgt r1, 0x16, +0xa +jeq r1, 0x14, +0x63 +jeq r1, 0x15, +0x7a +lddw r0, 0x1700000000 +ja +0x85 +jsgt r1, 0xb, +0x32 +jeq r1, 0xa, +0x69 +lddw r0, 0xc00000000 +ja +0x80 +jsgt r1, 0x18, +0x31 +jeq r1, 0x17, +0x73 +lddw r0, 0x1900000000 +ja +0x7b +jeq r3, 0x3, +0x2f +jeq r3, 0x4, +0x3a +ldxb r3, [r1 + 0x0] +jeq r3, 0xff, +0x1 +ja +0x8c +stxdw [r2 + 0x8], r1 +ldxdw r3, [r1 + 0x50] +add64 r1, r3 +add64 r1, 0x2867 +and64 r1, -0x8 +ldxb r3, [r1 + 0x0] +jne r3, 0xff, +0x8d +stxdw [r2 + 0x10], r1 +ldxdw r3, [r1 + 0x50] +add64 r1, r3 +add64 r1, 0x2867 +and64 r1, -0x8 +ldxb r3, [r1 + 0x0] +jne r3, 0xff, +0x8e +stxdw [r2 + 0x18], r1 +ldxdw r3, [r1 + 0x50] +add64 r1, r3 +add64 r1, 0x2867 +and64 r1, -0x8 +ldxb r3, [r1 + 0x0] +jne r3, 0xff, +0x8f +stxdw [r2 + 0x20], r1 +ja -0x48 +jeq r1, 0x4, +0x35 +jeq r1, 0x5, +0x3d +lddw r0, 0x700000000 +ja +0x5a +jeq r1, 0x11, +0x48 +jeq r1, 0x12, +0x56 +lddw r0, 0x1400000000 +ja +0x55 +lddw r0, 0x200000000 +ja +0x52 +jeq r1, 0xc, +0x3a +lddw r0, 0xe00000000 +ja +0x4e +jeq r1, 0x19, +0x45 +mov64 r0, 0x0 +ja +0x4b +ldxb r3, [r1 + 0x0] +jeq r3, 0xff, +0x1 +ja +0x4f +stxdw [r2 + 0x8], r1 +ldxdw r3, [r1 + 0x50] +add64 r1, r3 +add64 r1, 0x2867 +and64 r1, -0x8 +ldxb r3, [r1 + 0x0] +jne r3, 0xff, +0x50 +stxdw [r2 + 0x10], r1 +ja -0x68 +ldxb r3, [r1 + 0x0] +jeq r3, 0xff, +0x1 +ja +0x71 +stxdw [r2 + 0x8], r1 +ldxdw r3, [r1 + 0x50] +add64 r1, r3 +add64 r1, 0x2867 +and64 r1, -0x8 +ldxb r3, [r1 + 0x0] +jne r3, 0xff, +0x72 +stxdw [r2 + 0x10], r1 +ldxdw r3, [r1 + 0x50] +add64 r1, r3 +add64 r1, 0x2867 +and64 r1, -0x8 +ldxb r3, [r1 + 0x0] +jne r3, 0xff, +0x73 +stxdw [r2 + 0x18], r1 +ja -0x7b +lddw r0, 0x800000000 +ja +0x29 +lddw r0, 0x500000000 +ja +0x26 +lddw r0, 0x1500000000 +ja +0x23 +lddw r0, 0x900000000 +ja +0x20 +lddw r0, 0x600000000 +ja +0x1d +lddw r0, 0x300000000 +ja +0x1a +lddw r0, 0xb00000000 +ja +0x17 +lddw r0, 0xd00000000 +ja +0x14 +lddw r0, 0xf00000000 +ja +0x11 +lddw r0, 0x1200000000 +ja +0xe +lddw r0, 0x1600000000 +ja +0xb +lddw r0, 0x1800000000 +ja +0x8 +lddw r0, 0x1a00000000 +ja +0x5 +lddw r0, 0x1000000000 +ja +0x2 +lddw r0, 0x1300000000 +exit +lsh64 r2, 0x3 +mov64 r1, r10 +add64 r1, -0x7f0 +add64 r1, r2 +ldxdw r1, [r1 + 0x0] +ja -0xaf +lsh64 r3, 0x3 +mov64 r5, r10 +add64 r5, -0x7f0 +add64 r5, r3 +ldxdw r3, [r5 + 0x0] +stxdw [r2 + 0x8], r3 +add64 r1, 0x8 +ja -0x52 +lsh64 r3, 0x3 +mov64 r1, r10 +add64 r1, -0x7f0 +add64 r1, r3 +ldxdw r1, [r1 + 0x0] +stxdw [r2 + 0x10], r1 +ja -0xbd +lsh64 r3, 0x3 +mov64 r5, r10 +add64 r5, -0x7f0 +add64 r5, r3 +ldxdw r3, [r5 + 0x0] +stxdw [r2 + 0x8], r3 +add64 r1, 0x8 +ja -0x8f +lsh64 r3, 0x3 +mov64 r5, r10 +add64 r5, -0x7f0 +add64 r5, r3 +ldxdw r3, [r5 + 0x0] +stxdw [r2 + 0x10], r3 +add64 r1, 0x8 +ja -0x90 +lsh64 r3, 0x3 +mov64 r5, r10 +add64 r5, -0x7f0 +add64 r5, r3 +ldxdw r3, [r5 + 0x0] +stxdw [r2 + 0x18], r3 +add64 r1, 0x8 +ja -0x91 +lsh64 r3, 0x3 +mov64 r1, r10 +add64 r1, -0x7f0 +add64 r1, r3 +ldxdw r1, [r1 + 0x0] +stxdw [r2 + 0x20], r1 +ja -0xdc +lsh64 r3, 0x3 +mov64 r5, r10 +add64 r5, -0x7f0 +add64 r5, r3 +ldxdw r3, [r5 + 0x0] +stxdw [r2 + 0x8], r3 +add64 r1, 0x8 +ja -0x74 +lsh64 r3, 0x3 +mov64 r5, r10 +add64 r5, -0x7f0 +add64 r5, r3 +ldxdw r3, [r5 + 0x0] +stxdw [r2 + 0x10], r3 +add64 r1, 0x8 +ja -0x75 +lsh64 r3, 0x3 +mov64 r1, r10 +add64 r1, -0x7f0 +add64 r1, r3 +ldxdw r1, [r1 + 0x0] +stxdw [r2 + 0x18], r1 +ja -0xf3 +lsh64 r3, 0x3 +mov64 r1, r10 +add64 r1, -0x7f0 +add64 r1, r3 +ldxdw r1, [r1 + 0x0] +stxdw [r2 + 0x8], r1 +ja -0xfa +ldxdw r1, [r1 + 0x8] +ldxw r4, [r1 + 0x14] +ldxw r3, [r1 + 0x10] +ldxdw r2, [r1 + 0x8] +ldxdw r1, [r1 + 0x0] +call -0x1 +stxdw [r10 - 0x10], r2 +stxdw [r10 - 0x18], r1 +sth [r10 - 0x8], 0x1 +mov64 r1, r10 +add64 r1, -0x18 +call -0xc +stxdw [r10 - 0x58], r2 +stxdw [r10 - 0x60], r1 +lddw r1, 0x2198 +stxdw [r10 - 0x50], r1 +mov64 r1, r10 +add64 r1, -0x20 +stxdw [r10 - 0x40], r1 +mov64 r1, r10 +add64 r1, -0x60 +stxdw [r10 - 0x10], r1 +lddw r1, 0x1d60 +stxdw [r10 - 0x8], r1 +stxdw [r10 - 0x18], r1 +mov64 r1, r10 +add64 r1, -0x58 +stxdw [r10 - 0x20], r1 +stdw [r10 - 0x30], 0x0 +stdw [r10 - 0x48], 0x2 +stdw [r10 - 0x38], 0x2 +mov64 r1, r10 +add64 r1, -0x50 +mov64 r2, r3 +call -0x1f +mov64 r6, r1 +ldxdw r0, [r5 - 0xff8] +jne r2, 0x0, +0x3 +mov64 r2, 0x2d +ldxw r7, [r6 + 0x34] +ja +0x17 +mov64 r2, 0x110000 +ldxw r7, [r6 + 0x34] +mov64 r1, r7 +and64 r1, 0x1 +mov64 r9, r0 +jne r1, 0x0, +0x10 +stxdw [r10 - 0x28], r0 +ldxdw r1, [r5 - 0x1000] +stxdw [r10 - 0x30], r1 +mov64 r8, 0x0 +mov64 r1, r7 +and64 r1, 0x4 +jeq r1, 0x0, +0x21 +stxdw [r10 - 0x40], r2 +stxdw [r10 - 0x48], r6 +stxdw [r10 - 0x38], r4 +jlt r4, 0x20, +0x9 +mov64 r8, r3 +mov64 r1, r3 +mov64 r2, r4 +call 0xd0 +ja +0x13 +mov64 r2, 0x2b +mov64 r9, r0 +add64 r9, 0x1 +ja -0x14 +mov64 r8, r3 +mov64 r0, 0x0 +jeq r4, 0x0, +0xc +mov64 r1, r8 +ldxdw r2, [r10 - 0x38] +ldxb r4, [r1 + 0x0] +lsh64 r4, 0x38 +arsh64 r4, 0x38 +mov64 r3, 0x1 +jsgt r4, -0x41, +0x1 +mov64 r3, 0x0 +add64 r0, r3 +add64 r1, 0x1 +add64 r2, -0x1 +jne r2, 0x0, -0xa +add64 r0, r9 +mov64 r9, r0 +ldxdw r6, [r10 - 0x48] +ldxdw r4, [r10 - 0x38] +ldxdw r2, [r10 - 0x40] +ldxdw r1, [r6 + 0x0] +jne r1, 0x0, +0x6 +mov64 r1, r6 +mov64 r3, r8 +call 0x77 +mov64 r7, 0x1 +jne r0, 0x0, +0x3e +ja +0x36 +ldxdw r3, [r6 + 0x8] +jgt r3, r9, +0x1 +ja +0x2e +and64 r7, 0x8 +jeq r7, 0x0, +0x1 +ja +0x3a +stxdw [r10 - 0x40], r2 +stxdw [r10 - 0x38], r4 +sub64 r3, r9 +mov64 r1, r10 +add64 r1, -0x20 +mov64 r7, 0x1 +mov64 r2, r6 +mov64 r9, r6 +mov64 r4, 0x1 +call 0x7c +ldxw r1, [r10 - 0x18] +stxdw [r10 - 0x48], r1 +jeq r1, 0x110000, +0x2a +ldxdw r6, [r10 - 0x20] +mov64 r1, r9 +ldxdw r2, [r10 - 0x40] +mov64 r3, r8 +ldxdw r4, [r10 - 0x38] +call 0x5b +jne r0, 0x0, +0x23 +ldxdw r8, [r9 + 0x20] +ldxdw r9, [r9 + 0x28] +ldxdw r4, [r9 + 0x18] +mov64 r1, r8 +ldxdw r2, [r10 - 0x30] +ldxdw r3, [r10 - 0x28] +callx r4 +jne r0, 0x0, +0x1b +mov64 r7, 0x0 +mov64 r1, r6 +jeq r6, r7, +0x8 +ldxdw r3, [r9 + 0x20] +mov64 r1, r8 +ldxdw r2, [r10 - 0x48] +callx r3 +add64 r7, 0x1 +jeq r0, 0x0, -0x8 +add64 r7, -0x1 +mov64 r1, r7 +mov64 r7, 0x1 +jlt r1, r6, +0xe +mov64 r7, 0x0 +ja +0xc +mov64 r1, r6 +mov64 r3, r8 +call 0x40 +mov64 r7, 0x1 +jne r0, 0x0, +0x7 +ldxdw r1, [r6 + 0x20] +ldxdw r2, [r6 + 0x28] +ldxdw r4, [r2 + 0x18] +ldxdw r2, [r10 - 0x30] +ldxdw r3, [r10 - 0x28] +callx r4 +mov64 r7, r0 +and64 r7, 0x1 +mov64 r0, r7 +exit +stxdw [r10 - 0x40], r3 +ldxw r1, [r6 + 0x30] +stxdw [r10 - 0x50], r1 +stw [r6 + 0x30], 0x30 +ldxb r1, [r6 + 0x38] +stxdw [r10 - 0x58], r1 +stb [r6 + 0x38], 0x1 +mov64 r1, r6 +mov64 r3, r8 +call 0x2a +mov64 r7, 0x1 +jne r0, 0x0, -0xf +ldxdw r3, [r10 - 0x40] +sub64 r3, r9 +mov64 r1, r10 +add64 r1, -0x10 +mov64 r2, r6 +mov64 r4, 0x1 +call 0x39 +ldxw r8, [r10 - 0x8] +jeq r8, 0x110000, -0x18 +ldxdw r1, [r10 - 0x10] +stxdw [r10 - 0x38], r1 +ldxdw r1, [r6 + 0x20] +ldxdw r2, [r6 + 0x28] +stxdw [r10 - 0x48], r2 +ldxdw r4, [r2 + 0x18] +stxdw [r10 - 0x40], r1 +ldxdw r2, [r10 - 0x30] +ldxdw r3, [r10 - 0x28] +callx r4 +jne r0, 0x0, -0x23 +mov64 r9, 0x0 +mov64 r1, r6 +ldxdw r2, [r10 - 0x38] +jeq r2, r9, +0xb +ldxdw r1, [r10 - 0x48] +ldxdw r3, [r1 + 0x20] +ldxdw r1, [r10 - 0x40] +mov64 r2, r8 +callx r3 +add64 r9, 0x1 +jeq r0, 0x0, -0xa +add64 r9, -0x1 +mov64 r1, r6 +ldxdw r2, [r10 - 0x38] +jlt r9, r2, -0x32 +ldxdw r2, [r10 - 0x58] +stxb [r1 + 0x38], r2 +ldxdw r2, [r10 - 0x50] +stxw [r1 + 0x30], r2 +ja -0x45 +mov64 r6, r4 +mov64 r7, r3 +mov64 r8, r1 +mov64 r1, r2 +lsh64 r1, 0x20 +rsh64 r1, 0x20 +jeq r1, 0x110000, +0x7 +ldxdw r1, [r8 + 0x20] +ldxdw r3, [r8 + 0x28] +ldxdw r3, [r3 + 0x20] +callx r3 +mov64 r1, r0 +mov64 r0, 0x1 +jne r1, 0x0, +0x2 +mov64 r0, 0x0 +jne r7, 0x0, +0x1 +exit +ldxdw r1, [r8 + 0x20] +ldxdw r2, [r8 + 0x28] +ldxdw r4, [r2 + 0x18] +mov64 r2, r7 +mov64 r3, r6 +callx r4 +ja -0x8 +stxdw [r10 - 0x10], r1 +ldxb r6, [r2 + 0x38] +jsgt r6, 0x1, +0x2 +jeq r6, 0x0, +0xc +ja +0x4 +jeq r6, 0x2, +0x6 +mov64 r6, 0x0 +and64 r4, 0xff +jeq r4, 0x0, +0x7 +mov64 r6, r3 +mov64 r3, 0x0 +ja +0x4 +mov64 r6, r3 +rsh64 r6, 0x1 +add64 r3, 0x1 +rsh64 r3, 0x1 +stxdw [r10 - 0x8], r3 +add64 r6, 0x1 +ldxw r8, [r2 + 0x30] +ldxdw r7, [r2 + 0x28] +ldxdw r9, [r2 + 0x20] +add64 r6, -0x1 +mov64 r1, r8 +jeq r6, 0x0, +0x6 +ldxdw r3, [r7 + 0x20] +mov64 r1, r9 +mov64 r2, r8 +callx r3 +mov64 r1, 0x110000 +jeq r0, 0x0, -0x9 +ldxdw r2, [r10 - 0x10] +stxw [r2 + 0x8], r1 +ldxdw r1, [r10 - 0x8] +stxdw [r2 + 0x0], r1 +exit +mov64 r7, r1 +add64 r7, 0x7 +and64 r7, -0x8 +mov64 r3, r7 +sub64 r3, r1 +jlt r2, r3, +0x8f +mov64 r5, r2 +sub64 r5, r3 +jlt r5, 0x8, +0x8c +stxdw [r10 - 0x8], r3 +mov64 r2, r5 +and64 r2, 0x7 +mov64 r0, 0x0 +mov64 r3, 0x0 +jeq r7, r1, +0x10 +mov64 r6, r1 +sub64 r6, r7 +mov64 r7, r1 +ldxb r4, [r7 + 0x0] +lsh64 r4, 0x38 +arsh64 r4, 0x38 +mov64 r8, 0x1 +mov64 r9, 0x1 +jsgt r4, -0x41, +0x1 +mov64 r9, 0x0 +add64 r6, 0x1 +jeq r6, 0x0, +0x1 +mov64 r8, 0x0 +add64 r3, r9 +add64 r7, 0x1 +jne r8, 0x1, -0xd +ldxdw r4, [r10 - 0x8] +add64 r1, r4 +jeq r2, 0x0, +0xf +mov64 r0, r5 +and64 r0, -0x8 +mov64 r4, r1 +add64 r4, r0 +mov64 r0, 0x0 +ldxb r7, [r4 + 0x0] +lsh64 r7, 0x38 +arsh64 r7, 0x38 +mov64 r6, 0x1 +jsgt r7, -0x41, +0x1 +mov64 r6, 0x0 +add64 r0, r6 +add64 r4, 0x1 +add64 r2, -0x1 +jne r2, 0x0, -0xa +rsh64 r5, 0x3 +add64 r0, r3 +lddw r9, 0x101010101010101 +mov64 r3, r5 +jeq r3, 0x0, +0x6b +stxdw [r10 - 0x8], r1 +mov64 r5, r3 +jlt r3, 0xc0, +0x1 +mov64 r5, 0xc0 +stxdw [r10 - 0x10], r5 +lsh64 r5, 0x3 +mov64 r4, 0x0 +jlt r3, 0x4, +0x19 +mov64 r2, r5 +and64 r2, 0x7e0 +ldxdw r6, [r10 - 0x8] +mov64 r1, r6 +add64 r1, r2 +mov64 r2, r6 +ja +0x2 +add64 r2, 0x20 +jeq r2, r1, +0x10 +mov64 r6, r4 +mov64 r7, 0x0 +mov64 r4, r2 +add64 r4, r7 +ldxdw r4, [r4 + 0x0] +mov64 r8, r4 +rsh64 r8, 0x6 +xor64 r4, -0x1 +rsh64 r4, 0x7 +or64 r4, r8 +and64 r4, r9 +add64 r4, r6 +add64 r7, 0x8 +mov64 r6, r4 +jeq r7, 0x20, -0x11 +ja -0xe +ldxdw r1, [r10 - 0x8] +add64 r1, r5 +ldxdw r7, [r10 - 0x10] +mov64 r2, r7 +and64 r2, 0x3 +mov64 r8, r3 +sub64 r3, r7 +mov64 r6, r4 +lddw r5, 0xff00ff00ff00ff +and64 r6, r5 +rsh64 r4, 0x8 +and64 r4, r5 +mov64 r5, r3 +add64 r4, r6 +lddw r6, 0x1000100010001 +mul64 r4, r6 +rsh64 r4, 0x30 +add64 r4, r0 +mov64 r0, r4 +jeq r2, 0x0, -0x39 +mov64 r0, 0x0 +ldxdw r6, [r10 - 0x8] +jeq r2, 0x0, +0x17 +and64 r7, 0xfc +lsh64 r7, 0x3 +jlt r8, 0xc0, +0x1 +mov64 r8, 0xc0 +add64 r6, r7 +mov64 r2, 0x0 +and64 r8, 0x3 +lsh64 r8, 0x3 +lddw r1, 0x101010101010101 +ldxdw r0, [r6 + 0x0] +mov64 r5, r0 +rsh64 r5, 0x6 +xor64 r0, -0x1 +rsh64 r0, 0x7 +or64 r0, r5 +and64 r0, r1 +add64 r0, r2 +add64 r6, 0x8 +add64 r8, -0x8 +mov64 r2, r0 +jeq r8, 0x0, +0x1 +ja -0xd +lddw r1, 0xff00ff00ff00ff +mov64 r2, r0 +and64 r2, r1 +rsh64 r0, 0x8 +and64 r0, r1 +add64 r0, r2 +lddw r1, 0x1000100010001 +mul64 r0, r1 +rsh64 r0, 0x30 +add64 r0, r4 +ja +0xd +mov64 r0, 0x0 +jeq r2, 0x0, +0xb +ldxb r4, [r1 + 0x0] +lsh64 r4, 0x38 +arsh64 r4, 0x38 +mov64 r3, 0x1 +jsgt r4, -0x41, +0x1 +mov64 r3, 0x0 +add64 r0, r3 +add64 r1, 0x1 +add64 r2, -0x1 +jeq r2, 0x0, +0x1 +ja -0xb +exit +mov64 r3, r2 +ldxdw r1, [r1 + 0x0] +mov64 r2, 0x1 +call 0x1 +exit +mov64 r4, 0x14 +jlt r1, 0x2710, +0x20 +mov64 r4, 0x0 +mov64 r5, r1 +div64 r1, 0x2710 +mov64 r6, r1 +mul64 r6, 0x2710 +mov64 r0, r5 +sub64 r0, r6 +mov64 r6, r0 +and64 r6, 0xffff +div64 r6, 0x64 +mov64 r7, r6 +mul64 r7, 0x64 +sub64 r0, r7 +mov64 r7, r10 +add64 r7, -0x14 +add64 r7, r4 +lsh64 r6, 0x1 +lddw r8, 0x209e +add64 r8, r6 +ldxh r6, [r8 + 0x0] +stxh [r7 + 0x10], r6 +lsh64 r0, 0x1 +and64 r0, 0xfffe +lddw r6, 0x209e +add64 r6, r0 +ldxh r0, [r6 + 0x0] +stxh [r7 + 0x12], r0 +add64 r4, -0x4 +jgt r5, 0x5f5e0ff, -0x1e +add64 r4, 0x14 +jgt r1, 0x63, +0x1 +ja +0x12 +mov64 r5, r1 +and64 r5, 0xffff +div64 r5, 0x64 +mov64 r0, r5 +mul64 r0, 0x64 +sub64 r1, r0 +lsh64 r1, 0x1 +and64 r1, 0xfffe +lddw r0, 0x209e +add64 r0, r1 +add64 r4, -0x2 +mov64 r1, r10 +add64 r1, -0x14 +add64 r1, r4 +ldxh r0, [r0 + 0x0] +stxh [r1 + 0x0], r0 +mov64 r1, r5 +jlt r1, 0xa, +0xb +lsh64 r1, 0x1 +lddw r5, 0x209e +add64 r5, r1 +add64 r4, -0x2 +mov64 r1, r10 +add64 r1, -0x14 +add64 r1, r4 +ldxh r5, [r5 + 0x0] +stxh [r1 + 0x0], r5 +ja +0x6 +add64 r4, -0x1 +mov64 r5, r10 +add64 r5, -0x14 +add64 r5, r4 +or64 r1, 0x30 +stxb [r5 + 0x0], r1 +mov64 r1, 0x14 +sub64 r1, r4 +stxdw [r10 - 0xff8], r1 +mov64 r1, r10 +add64 r1, -0x14 +add64 r1, r4 +stxdw [r10 - 0x1000], r1 +mov64 r5, r10 +mov64 r1, r3 +mov64 r3, 0x1 +mov64 r4, 0x0 +call -0x1e7 +exit diff --git a/programs/system/src/invoke_parts.rs b/programs/system/src/invoke_parts.rs index 97088fa1..ecdcdf84 100644 --- a/programs/system/src/invoke_parts.rs +++ b/programs/system/src/invoke_parts.rs @@ -31,12 +31,14 @@ pub trait IntoInvokeParts { } pub trait Invoke: sealed::Sealed + Sized { + #[inline] fn invoke(self) -> ProgramResult { self.invoke_signed(&[]) } fn invoke_signed(self, signers: &[Signer]) -> ProgramResult; + #[inline] unsafe fn invoke_unchecked(self) { self.invoke_signed_unchecked(&[]) } @@ -45,6 +47,7 @@ pub trait Invoke: sealed::Sealed + Sized { } impl Invoke for SliceInvokeParts<'_> { + #[inline] fn invoke_signed(self, signers: &[Signer]) -> ProgramResult { cpi::slice_invoke_signed( &Instruction { @@ -57,6 +60,7 @@ impl Invoke for SliceInvokeParts<'_> { ) } + #[inline] unsafe fn invoke_signed_unchecked(self, signers: &[Signer]) { const UNINIT: MaybeUninit = MaybeUninit::::uninit(); let mut accounts = [UNINIT; MAX_CPI_ACCOUNTS]; @@ -79,6 +83,7 @@ impl Invoke for SliceInvokeParts<'_> { } impl Invoke for FixedInvokeParts<'_, N, M> { + #[inline] fn invoke_signed(self, signers: &[Signer]) -> ProgramResult { cpi::invoke_signed( &Instruction { @@ -91,6 +96,7 @@ impl Invoke for FixedInvokeParts<'_, N, M> { ) } + #[inline] unsafe fn invoke_signed_unchecked(self, signers: &[Signer]) { let accounts = self.accounts.map(Account::from); cpi::invoke_signed_unchecked( @@ -110,10 +116,12 @@ where T: IntoInvokeParts, T::Output: Invoke, { + #[inline] fn invoke_signed(self, signers: &[Signer]) -> ProgramResult { self.into_invoke_parts().invoke_signed(signers) } + #[inline] unsafe fn invoke_signed_unchecked(self, signers: &[Signer]) { self.into_invoke_parts().invoke_signed_unchecked(signers) } @@ -131,6 +139,7 @@ mod sealed { impl<'a> IntoInvokeParts for Transfer<'a> { type Output = FixedInvokeParts<'a, TRANSFER_ACCOUNTS_LEN, TRANSFER_DATA_SIZE>; + #[inline] fn into_invoke_parts(self) -> Self::Output { // instruction data // - [0..4 ]: instruction discriminator From 288aa7ee069cee409f7e9c4fa092e2571cb6ca06 Mon Sep 17 00:00:00 2001 From: Flavio B Date: Sun, 3 Aug 2025 00:23:59 -0400 Subject: [PATCH 13/13] remove dump --- call_dump_asm.txt | 848 --------------------------------------------- parts_dump_asm.txt | 848 --------------------------------------------- 2 files changed, 1696 deletions(-) delete mode 100644 call_dump_asm.txt delete mode 100644 parts_dump_asm.txt diff --git a/call_dump_asm.txt b/call_dump_asm.txt deleted file mode 100644 index 7132a214..00000000 --- a/call_dump_asm.txt +++ /dev/null @@ -1,848 +0,0 @@ -0000000000000490 -ldxdw r4, [r1 + 0x0] -jeq r4, 0x0, +0x6b -mov64 r2, r1 -add64 r2, 0x8 -stxdw [r10 - 0x7f0], r2 -jeq r4, 0x1, +0x67 -ldxdw r2, [r1 + 0x58] -add64 r1, r2 -add64 r1, 0x286f -and64 r1, -0x8 -jeq r4, 0x2, +0x5f -mov64 r2, r10 -add64 r2, -0x7f0 -mov64 r3, r4 -jlt r4, 0x6, +0x54 -mov64 r2, r10 -add64 r2, -0x7f0 -mov64 r3, r4 -ldxb r5, [r1 + 0x0] -jeq r5, 0xff, +0x1 -ja +0x25 -stxdw [r2 + 0x8], r1 -ldxdw r5, [r1 + 0x50] -add64 r1, r5 -add64 r1, 0x2867 -and64 r1, -0x8 -ldxb r5, [r1 + 0x0] -jne r5, 0xff, +0x26 -stxdw [r2 + 0x10], r1 -ldxdw r5, [r1 + 0x50] -add64 r1, r5 -add64 r1, 0x2867 -and64 r1, -0x8 -ldxb r5, [r1 + 0x0] -jne r5, 0xff, +0x27 -stxdw [r2 + 0x18], r1 -ldxdw r5, [r1 + 0x50] -add64 r1, r5 -add64 r1, 0x2867 -and64 r1, -0x8 -ldxb r5, [r1 + 0x0] -jne r5, 0xff, +0x28 -stxdw [r2 + 0x20], r1 -ldxdw r5, [r1 + 0x50] -add64 r1, r5 -add64 r1, 0x2867 -and64 r1, -0x8 -add64 r2, 0x28 -ldxb r5, [r1 + 0x0] -jne r5, 0xff, +0x28 -stxdw [r2 + 0x0], r1 -ldxdw r5, [r1 + 0x50] -add64 r1, r5 -add64 r1, 0x2867 -and64 r1, -0x8 -add64 r3, -0x5 -jgt r3, 0x5, -0x27 -ja +0x29 -lsh64 r5, 0x3 -mov64 r0, r10 -add64 r0, -0x7f0 -add64 r0, r5 -ldxdw r5, [r0 + 0x0] -stxdw [r2 + 0x8], r5 -add64 r1, 0x8 -ja -0x28 -lsh64 r5, 0x3 -mov64 r0, r10 -add64 r0, -0x7f0 -add64 r0, r5 -ldxdw r5, [r0 + 0x0] -stxdw [r2 + 0x10], r5 -add64 r1, 0x8 -ja -0x29 -lsh64 r5, 0x3 -mov64 r0, r10 -add64 r0, -0x7f0 -add64 r0, r5 -ldxdw r5, [r0 + 0x0] -stxdw [r2 + 0x18], r5 -add64 r1, 0x8 -ja -0x2a -lsh64 r5, 0x3 -mov64 r0, r10 -add64 r0, -0x7f0 -add64 r0, r5 -ldxdw r5, [r0 + 0x0] -stxdw [r2 + 0x20], r5 -add64 r1, 0x8 -ja -0x2b -lsh64 r5, 0x3 -mov64 r0, r10 -add64 r0, -0x7f0 -add64 r0, r5 -ldxdw r5, [r0 + 0x0] -stxdw [r2 + 0x0], r5 -add64 r1, 0x8 -add64 r3, -0x5 -jgt r3, 0x5, -0x51 -jsgt r3, 0x2, +0x35 -jeq r3, 0x1, +0x8 -ldxb r3, [r1 + 0x0] -jeq r3, 0xff, +0x1 -ja +0xf8 -stxdw [r2 + 0x8], r1 -ja +0x3 -ldxb r2, [r1 + 0x0] -jne r2, 0xff, +0xa9 -stxdw [r10 - 0x7e8], r1 -mov64 r1, r10 -add64 r1, -0x7f8 -mov64 r3, r10 -add64 r3, -0x7f0 -mov64 r5, r10 -call -0xe1 -ldxw r1, [r10 - 0x7f8] -jsgt r1, 0xd, +0x7 -jsgt r1, 0x6, +0xd -jsgt r1, 0x3, +0x3e -jlt r1, 0x2, +0x47 -jeq r1, 0x2, +0x7e -lddw r0, 0x400000000 -ja +0x98 -jsgt r1, 0x13, +0xc -jsgt r1, 0x10, +0x3c -jeq r1, 0xe, +0x81 -jeq r1, 0xf, +0x8f -lddw r0, 0x1100000000 -ja +0x91 -jsgt r1, 0x9, +0xb -jeq r1, 0x7, +0x63 -jeq r1, 0x8, +0x6b -lddw r0, 0xa00000000 -ja +0x8b -jsgt r1, 0x16, +0xa -jeq r1, 0x14, +0x63 -jeq r1, 0x15, +0x7a -lddw r0, 0x1700000000 -ja +0x85 -jsgt r1, 0xb, +0x32 -jeq r1, 0xa, +0x69 -lddw r0, 0xc00000000 -ja +0x80 -jsgt r1, 0x18, +0x31 -jeq r1, 0x17, +0x73 -lddw r0, 0x1900000000 -ja +0x7b -jeq r3, 0x3, +0x2f -jeq r3, 0x4, +0x3a -ldxb r3, [r1 + 0x0] -jeq r3, 0xff, +0x1 -ja +0x8c -stxdw [r2 + 0x8], r1 -ldxdw r3, [r1 + 0x50] -add64 r1, r3 -add64 r1, 0x2867 -and64 r1, -0x8 -ldxb r3, [r1 + 0x0] -jne r3, 0xff, +0x8d -stxdw [r2 + 0x10], r1 -ldxdw r3, [r1 + 0x50] -add64 r1, r3 -add64 r1, 0x2867 -and64 r1, -0x8 -ldxb r3, [r1 + 0x0] -jne r3, 0xff, +0x8e -stxdw [r2 + 0x18], r1 -ldxdw r3, [r1 + 0x50] -add64 r1, r3 -add64 r1, 0x2867 -and64 r1, -0x8 -ldxb r3, [r1 + 0x0] -jne r3, 0xff, +0x8f -stxdw [r2 + 0x20], r1 -ja -0x48 -jeq r1, 0x4, +0x35 -jeq r1, 0x5, +0x3d -lddw r0, 0x700000000 -ja +0x5a -jeq r1, 0x11, +0x48 -jeq r1, 0x12, +0x56 -lddw r0, 0x1400000000 -ja +0x55 -lddw r0, 0x200000000 -ja +0x52 -jeq r1, 0xc, +0x3a -lddw r0, 0xe00000000 -ja +0x4e -jeq r1, 0x19, +0x45 -mov64 r0, 0x0 -ja +0x4b -ldxb r3, [r1 + 0x0] -jeq r3, 0xff, +0x1 -ja +0x4f -stxdw [r2 + 0x8], r1 -ldxdw r3, [r1 + 0x50] -add64 r1, r3 -add64 r1, 0x2867 -and64 r1, -0x8 -ldxb r3, [r1 + 0x0] -jne r3, 0xff, +0x50 -stxdw [r2 + 0x10], r1 -ja -0x68 -ldxb r3, [r1 + 0x0] -jeq r3, 0xff, +0x1 -ja +0x71 -stxdw [r2 + 0x8], r1 -ldxdw r3, [r1 + 0x50] -add64 r1, r3 -add64 r1, 0x2867 -and64 r1, -0x8 -ldxb r3, [r1 + 0x0] -jne r3, 0xff, +0x72 -stxdw [r2 + 0x10], r1 -ldxdw r3, [r1 + 0x50] -add64 r1, r3 -add64 r1, 0x2867 -and64 r1, -0x8 -ldxb r3, [r1 + 0x0] -jne r3, 0xff, +0x73 -stxdw [r2 + 0x18], r1 -ja -0x7b -lddw r0, 0x800000000 -ja +0x29 -lddw r0, 0x500000000 -ja +0x26 -lddw r0, 0x1500000000 -ja +0x23 -lddw r0, 0x900000000 -ja +0x20 -lddw r0, 0x600000000 -ja +0x1d -lddw r0, 0x300000000 -ja +0x1a -lddw r0, 0xb00000000 -ja +0x17 -lddw r0, 0xd00000000 -ja +0x14 -lddw r0, 0xf00000000 -ja +0x11 -lddw r0, 0x1200000000 -ja +0xe -lddw r0, 0x1600000000 -ja +0xb -lddw r0, 0x1800000000 -ja +0x8 -lddw r0, 0x1a00000000 -ja +0x5 -lddw r0, 0x1000000000 -ja +0x2 -lddw r0, 0x1300000000 -exit -lsh64 r2, 0x3 -mov64 r1, r10 -add64 r1, -0x7f0 -add64 r1, r2 -ldxdw r1, [r1 + 0x0] -ja -0xaf -lsh64 r3, 0x3 -mov64 r5, r10 -add64 r5, -0x7f0 -add64 r5, r3 -ldxdw r3, [r5 + 0x0] -stxdw [r2 + 0x8], r3 -add64 r1, 0x8 -ja -0x52 -lsh64 r3, 0x3 -mov64 r1, r10 -add64 r1, -0x7f0 -add64 r1, r3 -ldxdw r1, [r1 + 0x0] -stxdw [r2 + 0x10], r1 -ja -0xbd -lsh64 r3, 0x3 -mov64 r5, r10 -add64 r5, -0x7f0 -add64 r5, r3 -ldxdw r3, [r5 + 0x0] -stxdw [r2 + 0x8], r3 -add64 r1, 0x8 -ja -0x8f -lsh64 r3, 0x3 -mov64 r5, r10 -add64 r5, -0x7f0 -add64 r5, r3 -ldxdw r3, [r5 + 0x0] -stxdw [r2 + 0x10], r3 -add64 r1, 0x8 -ja -0x90 -lsh64 r3, 0x3 -mov64 r5, r10 -add64 r5, -0x7f0 -add64 r5, r3 -ldxdw r3, [r5 + 0x0] -stxdw [r2 + 0x18], r3 -add64 r1, 0x8 -ja -0x91 -lsh64 r3, 0x3 -mov64 r1, r10 -add64 r1, -0x7f0 -add64 r1, r3 -ldxdw r1, [r1 + 0x0] -stxdw [r2 + 0x20], r1 -ja -0xdc -lsh64 r3, 0x3 -mov64 r5, r10 -add64 r5, -0x7f0 -add64 r5, r3 -ldxdw r3, [r5 + 0x0] -stxdw [r2 + 0x8], r3 -add64 r1, 0x8 -ja -0x74 -lsh64 r3, 0x3 -mov64 r5, r10 -add64 r5, -0x7f0 -add64 r5, r3 -ldxdw r3, [r5 + 0x0] -stxdw [r2 + 0x10], r3 -add64 r1, 0x8 -ja -0x75 -lsh64 r3, 0x3 -mov64 r1, r10 -add64 r1, -0x7f0 -add64 r1, r3 -ldxdw r1, [r1 + 0x0] -stxdw [r2 + 0x18], r1 -ja -0xf3 -lsh64 r3, 0x3 -mov64 r1, r10 -add64 r1, -0x7f0 -add64 r1, r3 -ldxdw r1, [r1 + 0x0] -stxdw [r2 + 0x8], r1 -ja -0xfa -ldxdw r1, [r1 + 0x8] -ldxw r4, [r1 + 0x14] -ldxw r3, [r1 + 0x10] -ldxdw r2, [r1 + 0x8] -ldxdw r1, [r1 + 0x0] -call -0x1 -stxdw [r10 - 0x10], r2 -stxdw [r10 - 0x18], r1 -sth [r10 - 0x8], 0x1 -mov64 r1, r10 -add64 r1, -0x18 -call -0xc -stxdw [r10 - 0x58], r2 -stxdw [r10 - 0x60], r1 -lddw r1, 0x2198 -stxdw [r10 - 0x50], r1 -mov64 r1, r10 -add64 r1, -0x20 -stxdw [r10 - 0x40], r1 -mov64 r1, r10 -add64 r1, -0x60 -stxdw [r10 - 0x10], r1 -lddw r1, 0x1d60 -stxdw [r10 - 0x8], r1 -stxdw [r10 - 0x18], r1 -mov64 r1, r10 -add64 r1, -0x58 -stxdw [r10 - 0x20], r1 -stdw [r10 - 0x30], 0x0 -stdw [r10 - 0x48], 0x2 -stdw [r10 - 0x38], 0x2 -mov64 r1, r10 -add64 r1, -0x50 -mov64 r2, r3 -call -0x1f -mov64 r6, r1 -ldxdw r0, [r5 - 0xff8] -jne r2, 0x0, +0x3 -mov64 r2, 0x2d -ldxw r7, [r6 + 0x34] -ja +0x17 -mov64 r2, 0x110000 -ldxw r7, [r6 + 0x34] -mov64 r1, r7 -and64 r1, 0x1 -mov64 r9, r0 -jne r1, 0x0, +0x10 -stxdw [r10 - 0x28], r0 -ldxdw r1, [r5 - 0x1000] -stxdw [r10 - 0x30], r1 -mov64 r8, 0x0 -mov64 r1, r7 -and64 r1, 0x4 -jeq r1, 0x0, +0x21 -stxdw [r10 - 0x40], r2 -stxdw [r10 - 0x48], r6 -stxdw [r10 - 0x38], r4 -jlt r4, 0x20, +0x9 -mov64 r8, r3 -mov64 r1, r3 -mov64 r2, r4 -call 0xd0 -ja +0x13 -mov64 r2, 0x2b -mov64 r9, r0 -add64 r9, 0x1 -ja -0x14 -mov64 r8, r3 -mov64 r0, 0x0 -jeq r4, 0x0, +0xc -mov64 r1, r8 -ldxdw r2, [r10 - 0x38] -ldxb r4, [r1 + 0x0] -lsh64 r4, 0x38 -arsh64 r4, 0x38 -mov64 r3, 0x1 -jsgt r4, -0x41, +0x1 -mov64 r3, 0x0 -add64 r0, r3 -add64 r1, 0x1 -add64 r2, -0x1 -jne r2, 0x0, -0xa -add64 r0, r9 -mov64 r9, r0 -ldxdw r6, [r10 - 0x48] -ldxdw r4, [r10 - 0x38] -ldxdw r2, [r10 - 0x40] -ldxdw r1, [r6 + 0x0] -jne r1, 0x0, +0x6 -mov64 r1, r6 -mov64 r3, r8 -call 0x77 -mov64 r7, 0x1 -jne r0, 0x0, +0x3e -ja +0x36 -ldxdw r3, [r6 + 0x8] -jgt r3, r9, +0x1 -ja +0x2e -and64 r7, 0x8 -jeq r7, 0x0, +0x1 -ja +0x3a -stxdw [r10 - 0x40], r2 -stxdw [r10 - 0x38], r4 -sub64 r3, r9 -mov64 r1, r10 -add64 r1, -0x20 -mov64 r7, 0x1 -mov64 r2, r6 -mov64 r9, r6 -mov64 r4, 0x1 -call 0x7c -ldxw r1, [r10 - 0x18] -stxdw [r10 - 0x48], r1 -jeq r1, 0x110000, +0x2a -ldxdw r6, [r10 - 0x20] -mov64 r1, r9 -ldxdw r2, [r10 - 0x40] -mov64 r3, r8 -ldxdw r4, [r10 - 0x38] -call 0x5b -jne r0, 0x0, +0x23 -ldxdw r8, [r9 + 0x20] -ldxdw r9, [r9 + 0x28] -ldxdw r4, [r9 + 0x18] -mov64 r1, r8 -ldxdw r2, [r10 - 0x30] -ldxdw r3, [r10 - 0x28] -callx r4 -jne r0, 0x0, +0x1b -mov64 r7, 0x0 -mov64 r1, r6 -jeq r6, r7, +0x8 -ldxdw r3, [r9 + 0x20] -mov64 r1, r8 -ldxdw r2, [r10 - 0x48] -callx r3 -add64 r7, 0x1 -jeq r0, 0x0, -0x8 -add64 r7, -0x1 -mov64 r1, r7 -mov64 r7, 0x1 -jlt r1, r6, +0xe -mov64 r7, 0x0 -ja +0xc -mov64 r1, r6 -mov64 r3, r8 -call 0x40 -mov64 r7, 0x1 -jne r0, 0x0, +0x7 -ldxdw r1, [r6 + 0x20] -ldxdw r2, [r6 + 0x28] -ldxdw r4, [r2 + 0x18] -ldxdw r2, [r10 - 0x30] -ldxdw r3, [r10 - 0x28] -callx r4 -mov64 r7, r0 -and64 r7, 0x1 -mov64 r0, r7 -exit -stxdw [r10 - 0x40], r3 -ldxw r1, [r6 + 0x30] -stxdw [r10 - 0x50], r1 -stw [r6 + 0x30], 0x30 -ldxb r1, [r6 + 0x38] -stxdw [r10 - 0x58], r1 -stb [r6 + 0x38], 0x1 -mov64 r1, r6 -mov64 r3, r8 -call 0x2a -mov64 r7, 0x1 -jne r0, 0x0, -0xf -ldxdw r3, [r10 - 0x40] -sub64 r3, r9 -mov64 r1, r10 -add64 r1, -0x10 -mov64 r2, r6 -mov64 r4, 0x1 -call 0x39 -ldxw r8, [r10 - 0x8] -jeq r8, 0x110000, -0x18 -ldxdw r1, [r10 - 0x10] -stxdw [r10 - 0x38], r1 -ldxdw r1, [r6 + 0x20] -ldxdw r2, [r6 + 0x28] -stxdw [r10 - 0x48], r2 -ldxdw r4, [r2 + 0x18] -stxdw [r10 - 0x40], r1 -ldxdw r2, [r10 - 0x30] -ldxdw r3, [r10 - 0x28] -callx r4 -jne r0, 0x0, -0x23 -mov64 r9, 0x0 -mov64 r1, r6 -ldxdw r2, [r10 - 0x38] -jeq r2, r9, +0xb -ldxdw r1, [r10 - 0x48] -ldxdw r3, [r1 + 0x20] -ldxdw r1, [r10 - 0x40] -mov64 r2, r8 -callx r3 -add64 r9, 0x1 -jeq r0, 0x0, -0xa -add64 r9, -0x1 -mov64 r1, r6 -ldxdw r2, [r10 - 0x38] -jlt r9, r2, -0x32 -ldxdw r2, [r10 - 0x58] -stxb [r1 + 0x38], r2 -ldxdw r2, [r10 - 0x50] -stxw [r1 + 0x30], r2 -ja -0x45 -mov64 r6, r4 -mov64 r7, r3 -mov64 r8, r1 -mov64 r1, r2 -lsh64 r1, 0x20 -rsh64 r1, 0x20 -jeq r1, 0x110000, +0x7 -ldxdw r1, [r8 + 0x20] -ldxdw r3, [r8 + 0x28] -ldxdw r3, [r3 + 0x20] -callx r3 -mov64 r1, r0 -mov64 r0, 0x1 -jne r1, 0x0, +0x2 -mov64 r0, 0x0 -jne r7, 0x0, +0x1 -exit -ldxdw r1, [r8 + 0x20] -ldxdw r2, [r8 + 0x28] -ldxdw r4, [r2 + 0x18] -mov64 r2, r7 -mov64 r3, r6 -callx r4 -ja -0x8 -stxdw [r10 - 0x10], r1 -ldxb r6, [r2 + 0x38] -jsgt r6, 0x1, +0x2 -jeq r6, 0x0, +0xc -ja +0x4 -jeq r6, 0x2, +0x6 -mov64 r6, 0x0 -and64 r4, 0xff -jeq r4, 0x0, +0x7 -mov64 r6, r3 -mov64 r3, 0x0 -ja +0x4 -mov64 r6, r3 -rsh64 r6, 0x1 -add64 r3, 0x1 -rsh64 r3, 0x1 -stxdw [r10 - 0x8], r3 -add64 r6, 0x1 -ldxw r8, [r2 + 0x30] -ldxdw r7, [r2 + 0x28] -ldxdw r9, [r2 + 0x20] -add64 r6, -0x1 -mov64 r1, r8 -jeq r6, 0x0, +0x6 -ldxdw r3, [r7 + 0x20] -mov64 r1, r9 -mov64 r2, r8 -callx r3 -mov64 r1, 0x110000 -jeq r0, 0x0, -0x9 -ldxdw r2, [r10 - 0x10] -stxw [r2 + 0x8], r1 -ldxdw r1, [r10 - 0x8] -stxdw [r2 + 0x0], r1 -exit -mov64 r7, r1 -add64 r7, 0x7 -and64 r7, -0x8 -mov64 r3, r7 -sub64 r3, r1 -jlt r2, r3, +0x8f -mov64 r5, r2 -sub64 r5, r3 -jlt r5, 0x8, +0x8c -stxdw [r10 - 0x8], r3 -mov64 r2, r5 -and64 r2, 0x7 -mov64 r0, 0x0 -mov64 r3, 0x0 -jeq r7, r1, +0x10 -mov64 r6, r1 -sub64 r6, r7 -mov64 r7, r1 -ldxb r4, [r7 + 0x0] -lsh64 r4, 0x38 -arsh64 r4, 0x38 -mov64 r8, 0x1 -mov64 r9, 0x1 -jsgt r4, -0x41, +0x1 -mov64 r9, 0x0 -add64 r6, 0x1 -jeq r6, 0x0, +0x1 -mov64 r8, 0x0 -add64 r3, r9 -add64 r7, 0x1 -jne r8, 0x1, -0xd -ldxdw r4, [r10 - 0x8] -add64 r1, r4 -jeq r2, 0x0, +0xf -mov64 r0, r5 -and64 r0, -0x8 -mov64 r4, r1 -add64 r4, r0 -mov64 r0, 0x0 -ldxb r7, [r4 + 0x0] -lsh64 r7, 0x38 -arsh64 r7, 0x38 -mov64 r6, 0x1 -jsgt r7, -0x41, +0x1 -mov64 r6, 0x0 -add64 r0, r6 -add64 r4, 0x1 -add64 r2, -0x1 -jne r2, 0x0, -0xa -rsh64 r5, 0x3 -add64 r0, r3 -lddw r9, 0x101010101010101 -mov64 r3, r5 -jeq r3, 0x0, +0x6b -stxdw [r10 - 0x8], r1 -mov64 r5, r3 -jlt r3, 0xc0, +0x1 -mov64 r5, 0xc0 -stxdw [r10 - 0x10], r5 -lsh64 r5, 0x3 -mov64 r4, 0x0 -jlt r3, 0x4, +0x19 -mov64 r2, r5 -and64 r2, 0x7e0 -ldxdw r6, [r10 - 0x8] -mov64 r1, r6 -add64 r1, r2 -mov64 r2, r6 -ja +0x2 -add64 r2, 0x20 -jeq r2, r1, +0x10 -mov64 r6, r4 -mov64 r7, 0x0 -mov64 r4, r2 -add64 r4, r7 -ldxdw r4, [r4 + 0x0] -mov64 r8, r4 -rsh64 r8, 0x6 -xor64 r4, -0x1 -rsh64 r4, 0x7 -or64 r4, r8 -and64 r4, r9 -add64 r4, r6 -add64 r7, 0x8 -mov64 r6, r4 -jeq r7, 0x20, -0x11 -ja -0xe -ldxdw r1, [r10 - 0x8] -add64 r1, r5 -ldxdw r7, [r10 - 0x10] -mov64 r2, r7 -and64 r2, 0x3 -mov64 r8, r3 -sub64 r3, r7 -mov64 r6, r4 -lddw r5, 0xff00ff00ff00ff -and64 r6, r5 -rsh64 r4, 0x8 -and64 r4, r5 -mov64 r5, r3 -add64 r4, r6 -lddw r6, 0x1000100010001 -mul64 r4, r6 -rsh64 r4, 0x30 -add64 r4, r0 -mov64 r0, r4 -jeq r2, 0x0, -0x39 -mov64 r0, 0x0 -ldxdw r6, [r10 - 0x8] -jeq r2, 0x0, +0x17 -and64 r7, 0xfc -lsh64 r7, 0x3 -jlt r8, 0xc0, +0x1 -mov64 r8, 0xc0 -add64 r6, r7 -mov64 r2, 0x0 -and64 r8, 0x3 -lsh64 r8, 0x3 -lddw r1, 0x101010101010101 -ldxdw r0, [r6 + 0x0] -mov64 r5, r0 -rsh64 r5, 0x6 -xor64 r0, -0x1 -rsh64 r0, 0x7 -or64 r0, r5 -and64 r0, r1 -add64 r0, r2 -add64 r6, 0x8 -add64 r8, -0x8 -mov64 r2, r0 -jeq r8, 0x0, +0x1 -ja -0xd -lddw r1, 0xff00ff00ff00ff -mov64 r2, r0 -and64 r2, r1 -rsh64 r0, 0x8 -and64 r0, r1 -add64 r0, r2 -lddw r1, 0x1000100010001 -mul64 r0, r1 -rsh64 r0, 0x30 -add64 r0, r4 -ja +0xd -mov64 r0, 0x0 -jeq r2, 0x0, +0xb -ldxb r4, [r1 + 0x0] -lsh64 r4, 0x38 -arsh64 r4, 0x38 -mov64 r3, 0x1 -jsgt r4, -0x41, +0x1 -mov64 r3, 0x0 -add64 r0, r3 -add64 r1, 0x1 -add64 r2, -0x1 -jeq r2, 0x0, +0x1 -ja -0xb -exit -mov64 r3, r2 -ldxdw r1, [r1 + 0x0] -mov64 r2, 0x1 -call 0x1 -exit -mov64 r4, 0x14 -jlt r1, 0x2710, +0x20 -mov64 r4, 0x0 -mov64 r5, r1 -div64 r1, 0x2710 -mov64 r6, r1 -mul64 r6, 0x2710 -mov64 r0, r5 -sub64 r0, r6 -mov64 r6, r0 -and64 r6, 0xffff -div64 r6, 0x64 -mov64 r7, r6 -mul64 r7, 0x64 -sub64 r0, r7 -mov64 r7, r10 -add64 r7, -0x14 -add64 r7, r4 -lsh64 r6, 0x1 -lddw r8, 0x209e -add64 r8, r6 -ldxh r6, [r8 + 0x0] -stxh [r7 + 0x10], r6 -lsh64 r0, 0x1 -and64 r0, 0xfffe -lddw r6, 0x209e -add64 r6, r0 -ldxh r0, [r6 + 0x0] -stxh [r7 + 0x12], r0 -add64 r4, -0x4 -jgt r5, 0x5f5e0ff, -0x1e -add64 r4, 0x14 -jgt r1, 0x63, +0x1 -ja +0x12 -mov64 r5, r1 -and64 r5, 0xffff -div64 r5, 0x64 -mov64 r0, r5 -mul64 r0, 0x64 -sub64 r1, r0 -lsh64 r1, 0x1 -and64 r1, 0xfffe -lddw r0, 0x209e -add64 r0, r1 -add64 r4, -0x2 -mov64 r1, r10 -add64 r1, -0x14 -add64 r1, r4 -ldxh r0, [r0 + 0x0] -stxh [r1 + 0x0], r0 -mov64 r1, r5 -jlt r1, 0xa, +0xb -lsh64 r1, 0x1 -lddw r5, 0x209e -add64 r5, r1 -add64 r4, -0x2 -mov64 r1, r10 -add64 r1, -0x14 -add64 r1, r4 -ldxh r5, [r5 + 0x0] -stxh [r1 + 0x0], r5 -ja +0x6 -add64 r4, -0x1 -mov64 r5, r10 -add64 r5, -0x14 -add64 r5, r4 -or64 r1, 0x30 -stxb [r5 + 0x0], r1 -mov64 r1, 0x14 -sub64 r1, r4 -stxdw [r10 - 0xff8], r1 -mov64 r1, r10 -add64 r1, -0x14 -add64 r1, r4 -stxdw [r10 - 0x1000], r1 -mov64 r5, r10 -mov64 r1, r3 -mov64 r3, 0x1 -mov64 r4, 0x0 -call -0x1e7 -exit diff --git a/parts_dump_asm.txt b/parts_dump_asm.txt deleted file mode 100644 index 7132a214..00000000 --- a/parts_dump_asm.txt +++ /dev/null @@ -1,848 +0,0 @@ -0000000000000490 -ldxdw r4, [r1 + 0x0] -jeq r4, 0x0, +0x6b -mov64 r2, r1 -add64 r2, 0x8 -stxdw [r10 - 0x7f0], r2 -jeq r4, 0x1, +0x67 -ldxdw r2, [r1 + 0x58] -add64 r1, r2 -add64 r1, 0x286f -and64 r1, -0x8 -jeq r4, 0x2, +0x5f -mov64 r2, r10 -add64 r2, -0x7f0 -mov64 r3, r4 -jlt r4, 0x6, +0x54 -mov64 r2, r10 -add64 r2, -0x7f0 -mov64 r3, r4 -ldxb r5, [r1 + 0x0] -jeq r5, 0xff, +0x1 -ja +0x25 -stxdw [r2 + 0x8], r1 -ldxdw r5, [r1 + 0x50] -add64 r1, r5 -add64 r1, 0x2867 -and64 r1, -0x8 -ldxb r5, [r1 + 0x0] -jne r5, 0xff, +0x26 -stxdw [r2 + 0x10], r1 -ldxdw r5, [r1 + 0x50] -add64 r1, r5 -add64 r1, 0x2867 -and64 r1, -0x8 -ldxb r5, [r1 + 0x0] -jne r5, 0xff, +0x27 -stxdw [r2 + 0x18], r1 -ldxdw r5, [r1 + 0x50] -add64 r1, r5 -add64 r1, 0x2867 -and64 r1, -0x8 -ldxb r5, [r1 + 0x0] -jne r5, 0xff, +0x28 -stxdw [r2 + 0x20], r1 -ldxdw r5, [r1 + 0x50] -add64 r1, r5 -add64 r1, 0x2867 -and64 r1, -0x8 -add64 r2, 0x28 -ldxb r5, [r1 + 0x0] -jne r5, 0xff, +0x28 -stxdw [r2 + 0x0], r1 -ldxdw r5, [r1 + 0x50] -add64 r1, r5 -add64 r1, 0x2867 -and64 r1, -0x8 -add64 r3, -0x5 -jgt r3, 0x5, -0x27 -ja +0x29 -lsh64 r5, 0x3 -mov64 r0, r10 -add64 r0, -0x7f0 -add64 r0, r5 -ldxdw r5, [r0 + 0x0] -stxdw [r2 + 0x8], r5 -add64 r1, 0x8 -ja -0x28 -lsh64 r5, 0x3 -mov64 r0, r10 -add64 r0, -0x7f0 -add64 r0, r5 -ldxdw r5, [r0 + 0x0] -stxdw [r2 + 0x10], r5 -add64 r1, 0x8 -ja -0x29 -lsh64 r5, 0x3 -mov64 r0, r10 -add64 r0, -0x7f0 -add64 r0, r5 -ldxdw r5, [r0 + 0x0] -stxdw [r2 + 0x18], r5 -add64 r1, 0x8 -ja -0x2a -lsh64 r5, 0x3 -mov64 r0, r10 -add64 r0, -0x7f0 -add64 r0, r5 -ldxdw r5, [r0 + 0x0] -stxdw [r2 + 0x20], r5 -add64 r1, 0x8 -ja -0x2b -lsh64 r5, 0x3 -mov64 r0, r10 -add64 r0, -0x7f0 -add64 r0, r5 -ldxdw r5, [r0 + 0x0] -stxdw [r2 + 0x0], r5 -add64 r1, 0x8 -add64 r3, -0x5 -jgt r3, 0x5, -0x51 -jsgt r3, 0x2, +0x35 -jeq r3, 0x1, +0x8 -ldxb r3, [r1 + 0x0] -jeq r3, 0xff, +0x1 -ja +0xf8 -stxdw [r2 + 0x8], r1 -ja +0x3 -ldxb r2, [r1 + 0x0] -jne r2, 0xff, +0xa9 -stxdw [r10 - 0x7e8], r1 -mov64 r1, r10 -add64 r1, -0x7f8 -mov64 r3, r10 -add64 r3, -0x7f0 -mov64 r5, r10 -call -0xe1 -ldxw r1, [r10 - 0x7f8] -jsgt r1, 0xd, +0x7 -jsgt r1, 0x6, +0xd -jsgt r1, 0x3, +0x3e -jlt r1, 0x2, +0x47 -jeq r1, 0x2, +0x7e -lddw r0, 0x400000000 -ja +0x98 -jsgt r1, 0x13, +0xc -jsgt r1, 0x10, +0x3c -jeq r1, 0xe, +0x81 -jeq r1, 0xf, +0x8f -lddw r0, 0x1100000000 -ja +0x91 -jsgt r1, 0x9, +0xb -jeq r1, 0x7, +0x63 -jeq r1, 0x8, +0x6b -lddw r0, 0xa00000000 -ja +0x8b -jsgt r1, 0x16, +0xa -jeq r1, 0x14, +0x63 -jeq r1, 0x15, +0x7a -lddw r0, 0x1700000000 -ja +0x85 -jsgt r1, 0xb, +0x32 -jeq r1, 0xa, +0x69 -lddw r0, 0xc00000000 -ja +0x80 -jsgt r1, 0x18, +0x31 -jeq r1, 0x17, +0x73 -lddw r0, 0x1900000000 -ja +0x7b -jeq r3, 0x3, +0x2f -jeq r3, 0x4, +0x3a -ldxb r3, [r1 + 0x0] -jeq r3, 0xff, +0x1 -ja +0x8c -stxdw [r2 + 0x8], r1 -ldxdw r3, [r1 + 0x50] -add64 r1, r3 -add64 r1, 0x2867 -and64 r1, -0x8 -ldxb r3, [r1 + 0x0] -jne r3, 0xff, +0x8d -stxdw [r2 + 0x10], r1 -ldxdw r3, [r1 + 0x50] -add64 r1, r3 -add64 r1, 0x2867 -and64 r1, -0x8 -ldxb r3, [r1 + 0x0] -jne r3, 0xff, +0x8e -stxdw [r2 + 0x18], r1 -ldxdw r3, [r1 + 0x50] -add64 r1, r3 -add64 r1, 0x2867 -and64 r1, -0x8 -ldxb r3, [r1 + 0x0] -jne r3, 0xff, +0x8f -stxdw [r2 + 0x20], r1 -ja -0x48 -jeq r1, 0x4, +0x35 -jeq r1, 0x5, +0x3d -lddw r0, 0x700000000 -ja +0x5a -jeq r1, 0x11, +0x48 -jeq r1, 0x12, +0x56 -lddw r0, 0x1400000000 -ja +0x55 -lddw r0, 0x200000000 -ja +0x52 -jeq r1, 0xc, +0x3a -lddw r0, 0xe00000000 -ja +0x4e -jeq r1, 0x19, +0x45 -mov64 r0, 0x0 -ja +0x4b -ldxb r3, [r1 + 0x0] -jeq r3, 0xff, +0x1 -ja +0x4f -stxdw [r2 + 0x8], r1 -ldxdw r3, [r1 + 0x50] -add64 r1, r3 -add64 r1, 0x2867 -and64 r1, -0x8 -ldxb r3, [r1 + 0x0] -jne r3, 0xff, +0x50 -stxdw [r2 + 0x10], r1 -ja -0x68 -ldxb r3, [r1 + 0x0] -jeq r3, 0xff, +0x1 -ja +0x71 -stxdw [r2 + 0x8], r1 -ldxdw r3, [r1 + 0x50] -add64 r1, r3 -add64 r1, 0x2867 -and64 r1, -0x8 -ldxb r3, [r1 + 0x0] -jne r3, 0xff, +0x72 -stxdw [r2 + 0x10], r1 -ldxdw r3, [r1 + 0x50] -add64 r1, r3 -add64 r1, 0x2867 -and64 r1, -0x8 -ldxb r3, [r1 + 0x0] -jne r3, 0xff, +0x73 -stxdw [r2 + 0x18], r1 -ja -0x7b -lddw r0, 0x800000000 -ja +0x29 -lddw r0, 0x500000000 -ja +0x26 -lddw r0, 0x1500000000 -ja +0x23 -lddw r0, 0x900000000 -ja +0x20 -lddw r0, 0x600000000 -ja +0x1d -lddw r0, 0x300000000 -ja +0x1a -lddw r0, 0xb00000000 -ja +0x17 -lddw r0, 0xd00000000 -ja +0x14 -lddw r0, 0xf00000000 -ja +0x11 -lddw r0, 0x1200000000 -ja +0xe -lddw r0, 0x1600000000 -ja +0xb -lddw r0, 0x1800000000 -ja +0x8 -lddw r0, 0x1a00000000 -ja +0x5 -lddw r0, 0x1000000000 -ja +0x2 -lddw r0, 0x1300000000 -exit -lsh64 r2, 0x3 -mov64 r1, r10 -add64 r1, -0x7f0 -add64 r1, r2 -ldxdw r1, [r1 + 0x0] -ja -0xaf -lsh64 r3, 0x3 -mov64 r5, r10 -add64 r5, -0x7f0 -add64 r5, r3 -ldxdw r3, [r5 + 0x0] -stxdw [r2 + 0x8], r3 -add64 r1, 0x8 -ja -0x52 -lsh64 r3, 0x3 -mov64 r1, r10 -add64 r1, -0x7f0 -add64 r1, r3 -ldxdw r1, [r1 + 0x0] -stxdw [r2 + 0x10], r1 -ja -0xbd -lsh64 r3, 0x3 -mov64 r5, r10 -add64 r5, -0x7f0 -add64 r5, r3 -ldxdw r3, [r5 + 0x0] -stxdw [r2 + 0x8], r3 -add64 r1, 0x8 -ja -0x8f -lsh64 r3, 0x3 -mov64 r5, r10 -add64 r5, -0x7f0 -add64 r5, r3 -ldxdw r3, [r5 + 0x0] -stxdw [r2 + 0x10], r3 -add64 r1, 0x8 -ja -0x90 -lsh64 r3, 0x3 -mov64 r5, r10 -add64 r5, -0x7f0 -add64 r5, r3 -ldxdw r3, [r5 + 0x0] -stxdw [r2 + 0x18], r3 -add64 r1, 0x8 -ja -0x91 -lsh64 r3, 0x3 -mov64 r1, r10 -add64 r1, -0x7f0 -add64 r1, r3 -ldxdw r1, [r1 + 0x0] -stxdw [r2 + 0x20], r1 -ja -0xdc -lsh64 r3, 0x3 -mov64 r5, r10 -add64 r5, -0x7f0 -add64 r5, r3 -ldxdw r3, [r5 + 0x0] -stxdw [r2 + 0x8], r3 -add64 r1, 0x8 -ja -0x74 -lsh64 r3, 0x3 -mov64 r5, r10 -add64 r5, -0x7f0 -add64 r5, r3 -ldxdw r3, [r5 + 0x0] -stxdw [r2 + 0x10], r3 -add64 r1, 0x8 -ja -0x75 -lsh64 r3, 0x3 -mov64 r1, r10 -add64 r1, -0x7f0 -add64 r1, r3 -ldxdw r1, [r1 + 0x0] -stxdw [r2 + 0x18], r1 -ja -0xf3 -lsh64 r3, 0x3 -mov64 r1, r10 -add64 r1, -0x7f0 -add64 r1, r3 -ldxdw r1, [r1 + 0x0] -stxdw [r2 + 0x8], r1 -ja -0xfa -ldxdw r1, [r1 + 0x8] -ldxw r4, [r1 + 0x14] -ldxw r3, [r1 + 0x10] -ldxdw r2, [r1 + 0x8] -ldxdw r1, [r1 + 0x0] -call -0x1 -stxdw [r10 - 0x10], r2 -stxdw [r10 - 0x18], r1 -sth [r10 - 0x8], 0x1 -mov64 r1, r10 -add64 r1, -0x18 -call -0xc -stxdw [r10 - 0x58], r2 -stxdw [r10 - 0x60], r1 -lddw r1, 0x2198 -stxdw [r10 - 0x50], r1 -mov64 r1, r10 -add64 r1, -0x20 -stxdw [r10 - 0x40], r1 -mov64 r1, r10 -add64 r1, -0x60 -stxdw [r10 - 0x10], r1 -lddw r1, 0x1d60 -stxdw [r10 - 0x8], r1 -stxdw [r10 - 0x18], r1 -mov64 r1, r10 -add64 r1, -0x58 -stxdw [r10 - 0x20], r1 -stdw [r10 - 0x30], 0x0 -stdw [r10 - 0x48], 0x2 -stdw [r10 - 0x38], 0x2 -mov64 r1, r10 -add64 r1, -0x50 -mov64 r2, r3 -call -0x1f -mov64 r6, r1 -ldxdw r0, [r5 - 0xff8] -jne r2, 0x0, +0x3 -mov64 r2, 0x2d -ldxw r7, [r6 + 0x34] -ja +0x17 -mov64 r2, 0x110000 -ldxw r7, [r6 + 0x34] -mov64 r1, r7 -and64 r1, 0x1 -mov64 r9, r0 -jne r1, 0x0, +0x10 -stxdw [r10 - 0x28], r0 -ldxdw r1, [r5 - 0x1000] -stxdw [r10 - 0x30], r1 -mov64 r8, 0x0 -mov64 r1, r7 -and64 r1, 0x4 -jeq r1, 0x0, +0x21 -stxdw [r10 - 0x40], r2 -stxdw [r10 - 0x48], r6 -stxdw [r10 - 0x38], r4 -jlt r4, 0x20, +0x9 -mov64 r8, r3 -mov64 r1, r3 -mov64 r2, r4 -call 0xd0 -ja +0x13 -mov64 r2, 0x2b -mov64 r9, r0 -add64 r9, 0x1 -ja -0x14 -mov64 r8, r3 -mov64 r0, 0x0 -jeq r4, 0x0, +0xc -mov64 r1, r8 -ldxdw r2, [r10 - 0x38] -ldxb r4, [r1 + 0x0] -lsh64 r4, 0x38 -arsh64 r4, 0x38 -mov64 r3, 0x1 -jsgt r4, -0x41, +0x1 -mov64 r3, 0x0 -add64 r0, r3 -add64 r1, 0x1 -add64 r2, -0x1 -jne r2, 0x0, -0xa -add64 r0, r9 -mov64 r9, r0 -ldxdw r6, [r10 - 0x48] -ldxdw r4, [r10 - 0x38] -ldxdw r2, [r10 - 0x40] -ldxdw r1, [r6 + 0x0] -jne r1, 0x0, +0x6 -mov64 r1, r6 -mov64 r3, r8 -call 0x77 -mov64 r7, 0x1 -jne r0, 0x0, +0x3e -ja +0x36 -ldxdw r3, [r6 + 0x8] -jgt r3, r9, +0x1 -ja +0x2e -and64 r7, 0x8 -jeq r7, 0x0, +0x1 -ja +0x3a -stxdw [r10 - 0x40], r2 -stxdw [r10 - 0x38], r4 -sub64 r3, r9 -mov64 r1, r10 -add64 r1, -0x20 -mov64 r7, 0x1 -mov64 r2, r6 -mov64 r9, r6 -mov64 r4, 0x1 -call 0x7c -ldxw r1, [r10 - 0x18] -stxdw [r10 - 0x48], r1 -jeq r1, 0x110000, +0x2a -ldxdw r6, [r10 - 0x20] -mov64 r1, r9 -ldxdw r2, [r10 - 0x40] -mov64 r3, r8 -ldxdw r4, [r10 - 0x38] -call 0x5b -jne r0, 0x0, +0x23 -ldxdw r8, [r9 + 0x20] -ldxdw r9, [r9 + 0x28] -ldxdw r4, [r9 + 0x18] -mov64 r1, r8 -ldxdw r2, [r10 - 0x30] -ldxdw r3, [r10 - 0x28] -callx r4 -jne r0, 0x0, +0x1b -mov64 r7, 0x0 -mov64 r1, r6 -jeq r6, r7, +0x8 -ldxdw r3, [r9 + 0x20] -mov64 r1, r8 -ldxdw r2, [r10 - 0x48] -callx r3 -add64 r7, 0x1 -jeq r0, 0x0, -0x8 -add64 r7, -0x1 -mov64 r1, r7 -mov64 r7, 0x1 -jlt r1, r6, +0xe -mov64 r7, 0x0 -ja +0xc -mov64 r1, r6 -mov64 r3, r8 -call 0x40 -mov64 r7, 0x1 -jne r0, 0x0, +0x7 -ldxdw r1, [r6 + 0x20] -ldxdw r2, [r6 + 0x28] -ldxdw r4, [r2 + 0x18] -ldxdw r2, [r10 - 0x30] -ldxdw r3, [r10 - 0x28] -callx r4 -mov64 r7, r0 -and64 r7, 0x1 -mov64 r0, r7 -exit -stxdw [r10 - 0x40], r3 -ldxw r1, [r6 + 0x30] -stxdw [r10 - 0x50], r1 -stw [r6 + 0x30], 0x30 -ldxb r1, [r6 + 0x38] -stxdw [r10 - 0x58], r1 -stb [r6 + 0x38], 0x1 -mov64 r1, r6 -mov64 r3, r8 -call 0x2a -mov64 r7, 0x1 -jne r0, 0x0, -0xf -ldxdw r3, [r10 - 0x40] -sub64 r3, r9 -mov64 r1, r10 -add64 r1, -0x10 -mov64 r2, r6 -mov64 r4, 0x1 -call 0x39 -ldxw r8, [r10 - 0x8] -jeq r8, 0x110000, -0x18 -ldxdw r1, [r10 - 0x10] -stxdw [r10 - 0x38], r1 -ldxdw r1, [r6 + 0x20] -ldxdw r2, [r6 + 0x28] -stxdw [r10 - 0x48], r2 -ldxdw r4, [r2 + 0x18] -stxdw [r10 - 0x40], r1 -ldxdw r2, [r10 - 0x30] -ldxdw r3, [r10 - 0x28] -callx r4 -jne r0, 0x0, -0x23 -mov64 r9, 0x0 -mov64 r1, r6 -ldxdw r2, [r10 - 0x38] -jeq r2, r9, +0xb -ldxdw r1, [r10 - 0x48] -ldxdw r3, [r1 + 0x20] -ldxdw r1, [r10 - 0x40] -mov64 r2, r8 -callx r3 -add64 r9, 0x1 -jeq r0, 0x0, -0xa -add64 r9, -0x1 -mov64 r1, r6 -ldxdw r2, [r10 - 0x38] -jlt r9, r2, -0x32 -ldxdw r2, [r10 - 0x58] -stxb [r1 + 0x38], r2 -ldxdw r2, [r10 - 0x50] -stxw [r1 + 0x30], r2 -ja -0x45 -mov64 r6, r4 -mov64 r7, r3 -mov64 r8, r1 -mov64 r1, r2 -lsh64 r1, 0x20 -rsh64 r1, 0x20 -jeq r1, 0x110000, +0x7 -ldxdw r1, [r8 + 0x20] -ldxdw r3, [r8 + 0x28] -ldxdw r3, [r3 + 0x20] -callx r3 -mov64 r1, r0 -mov64 r0, 0x1 -jne r1, 0x0, +0x2 -mov64 r0, 0x0 -jne r7, 0x0, +0x1 -exit -ldxdw r1, [r8 + 0x20] -ldxdw r2, [r8 + 0x28] -ldxdw r4, [r2 + 0x18] -mov64 r2, r7 -mov64 r3, r6 -callx r4 -ja -0x8 -stxdw [r10 - 0x10], r1 -ldxb r6, [r2 + 0x38] -jsgt r6, 0x1, +0x2 -jeq r6, 0x0, +0xc -ja +0x4 -jeq r6, 0x2, +0x6 -mov64 r6, 0x0 -and64 r4, 0xff -jeq r4, 0x0, +0x7 -mov64 r6, r3 -mov64 r3, 0x0 -ja +0x4 -mov64 r6, r3 -rsh64 r6, 0x1 -add64 r3, 0x1 -rsh64 r3, 0x1 -stxdw [r10 - 0x8], r3 -add64 r6, 0x1 -ldxw r8, [r2 + 0x30] -ldxdw r7, [r2 + 0x28] -ldxdw r9, [r2 + 0x20] -add64 r6, -0x1 -mov64 r1, r8 -jeq r6, 0x0, +0x6 -ldxdw r3, [r7 + 0x20] -mov64 r1, r9 -mov64 r2, r8 -callx r3 -mov64 r1, 0x110000 -jeq r0, 0x0, -0x9 -ldxdw r2, [r10 - 0x10] -stxw [r2 + 0x8], r1 -ldxdw r1, [r10 - 0x8] -stxdw [r2 + 0x0], r1 -exit -mov64 r7, r1 -add64 r7, 0x7 -and64 r7, -0x8 -mov64 r3, r7 -sub64 r3, r1 -jlt r2, r3, +0x8f -mov64 r5, r2 -sub64 r5, r3 -jlt r5, 0x8, +0x8c -stxdw [r10 - 0x8], r3 -mov64 r2, r5 -and64 r2, 0x7 -mov64 r0, 0x0 -mov64 r3, 0x0 -jeq r7, r1, +0x10 -mov64 r6, r1 -sub64 r6, r7 -mov64 r7, r1 -ldxb r4, [r7 + 0x0] -lsh64 r4, 0x38 -arsh64 r4, 0x38 -mov64 r8, 0x1 -mov64 r9, 0x1 -jsgt r4, -0x41, +0x1 -mov64 r9, 0x0 -add64 r6, 0x1 -jeq r6, 0x0, +0x1 -mov64 r8, 0x0 -add64 r3, r9 -add64 r7, 0x1 -jne r8, 0x1, -0xd -ldxdw r4, [r10 - 0x8] -add64 r1, r4 -jeq r2, 0x0, +0xf -mov64 r0, r5 -and64 r0, -0x8 -mov64 r4, r1 -add64 r4, r0 -mov64 r0, 0x0 -ldxb r7, [r4 + 0x0] -lsh64 r7, 0x38 -arsh64 r7, 0x38 -mov64 r6, 0x1 -jsgt r7, -0x41, +0x1 -mov64 r6, 0x0 -add64 r0, r6 -add64 r4, 0x1 -add64 r2, -0x1 -jne r2, 0x0, -0xa -rsh64 r5, 0x3 -add64 r0, r3 -lddw r9, 0x101010101010101 -mov64 r3, r5 -jeq r3, 0x0, +0x6b -stxdw [r10 - 0x8], r1 -mov64 r5, r3 -jlt r3, 0xc0, +0x1 -mov64 r5, 0xc0 -stxdw [r10 - 0x10], r5 -lsh64 r5, 0x3 -mov64 r4, 0x0 -jlt r3, 0x4, +0x19 -mov64 r2, r5 -and64 r2, 0x7e0 -ldxdw r6, [r10 - 0x8] -mov64 r1, r6 -add64 r1, r2 -mov64 r2, r6 -ja +0x2 -add64 r2, 0x20 -jeq r2, r1, +0x10 -mov64 r6, r4 -mov64 r7, 0x0 -mov64 r4, r2 -add64 r4, r7 -ldxdw r4, [r4 + 0x0] -mov64 r8, r4 -rsh64 r8, 0x6 -xor64 r4, -0x1 -rsh64 r4, 0x7 -or64 r4, r8 -and64 r4, r9 -add64 r4, r6 -add64 r7, 0x8 -mov64 r6, r4 -jeq r7, 0x20, -0x11 -ja -0xe -ldxdw r1, [r10 - 0x8] -add64 r1, r5 -ldxdw r7, [r10 - 0x10] -mov64 r2, r7 -and64 r2, 0x3 -mov64 r8, r3 -sub64 r3, r7 -mov64 r6, r4 -lddw r5, 0xff00ff00ff00ff -and64 r6, r5 -rsh64 r4, 0x8 -and64 r4, r5 -mov64 r5, r3 -add64 r4, r6 -lddw r6, 0x1000100010001 -mul64 r4, r6 -rsh64 r4, 0x30 -add64 r4, r0 -mov64 r0, r4 -jeq r2, 0x0, -0x39 -mov64 r0, 0x0 -ldxdw r6, [r10 - 0x8] -jeq r2, 0x0, +0x17 -and64 r7, 0xfc -lsh64 r7, 0x3 -jlt r8, 0xc0, +0x1 -mov64 r8, 0xc0 -add64 r6, r7 -mov64 r2, 0x0 -and64 r8, 0x3 -lsh64 r8, 0x3 -lddw r1, 0x101010101010101 -ldxdw r0, [r6 + 0x0] -mov64 r5, r0 -rsh64 r5, 0x6 -xor64 r0, -0x1 -rsh64 r0, 0x7 -or64 r0, r5 -and64 r0, r1 -add64 r0, r2 -add64 r6, 0x8 -add64 r8, -0x8 -mov64 r2, r0 -jeq r8, 0x0, +0x1 -ja -0xd -lddw r1, 0xff00ff00ff00ff -mov64 r2, r0 -and64 r2, r1 -rsh64 r0, 0x8 -and64 r0, r1 -add64 r0, r2 -lddw r1, 0x1000100010001 -mul64 r0, r1 -rsh64 r0, 0x30 -add64 r0, r4 -ja +0xd -mov64 r0, 0x0 -jeq r2, 0x0, +0xb -ldxb r4, [r1 + 0x0] -lsh64 r4, 0x38 -arsh64 r4, 0x38 -mov64 r3, 0x1 -jsgt r4, -0x41, +0x1 -mov64 r3, 0x0 -add64 r0, r3 -add64 r1, 0x1 -add64 r2, -0x1 -jeq r2, 0x0, +0x1 -ja -0xb -exit -mov64 r3, r2 -ldxdw r1, [r1 + 0x0] -mov64 r2, 0x1 -call 0x1 -exit -mov64 r4, 0x14 -jlt r1, 0x2710, +0x20 -mov64 r4, 0x0 -mov64 r5, r1 -div64 r1, 0x2710 -mov64 r6, r1 -mul64 r6, 0x2710 -mov64 r0, r5 -sub64 r0, r6 -mov64 r6, r0 -and64 r6, 0xffff -div64 r6, 0x64 -mov64 r7, r6 -mul64 r7, 0x64 -sub64 r0, r7 -mov64 r7, r10 -add64 r7, -0x14 -add64 r7, r4 -lsh64 r6, 0x1 -lddw r8, 0x209e -add64 r8, r6 -ldxh r6, [r8 + 0x0] -stxh [r7 + 0x10], r6 -lsh64 r0, 0x1 -and64 r0, 0xfffe -lddw r6, 0x209e -add64 r6, r0 -ldxh r0, [r6 + 0x0] -stxh [r7 + 0x12], r0 -add64 r4, -0x4 -jgt r5, 0x5f5e0ff, -0x1e -add64 r4, 0x14 -jgt r1, 0x63, +0x1 -ja +0x12 -mov64 r5, r1 -and64 r5, 0xffff -div64 r5, 0x64 -mov64 r0, r5 -mul64 r0, 0x64 -sub64 r1, r0 -lsh64 r1, 0x1 -and64 r1, 0xfffe -lddw r0, 0x209e -add64 r0, r1 -add64 r4, -0x2 -mov64 r1, r10 -add64 r1, -0x14 -add64 r1, r4 -ldxh r0, [r0 + 0x0] -stxh [r1 + 0x0], r0 -mov64 r1, r5 -jlt r1, 0xa, +0xb -lsh64 r1, 0x1 -lddw r5, 0x209e -add64 r5, r1 -add64 r4, -0x2 -mov64 r1, r10 -add64 r1, -0x14 -add64 r1, r4 -ldxh r5, [r5 + 0x0] -stxh [r1 + 0x0], r5 -ja +0x6 -add64 r4, -0x1 -mov64 r5, r10 -add64 r5, -0x14 -add64 r5, r4 -or64 r1, 0x30 -stxb [r5 + 0x0], r1 -mov64 r1, 0x14 -sub64 r1, r4 -stxdw [r10 - 0xff8], r1 -mov64 r1, r10 -add64 r1, -0x14 -add64 r1, r4 -stxdw [r10 - 0x1000], r1 -mov64 r5, r10 -mov64 r1, r3 -mov64 r3, 0x1 -mov64 r4, 0x0 -call -0x1e7 -exit