// File: zerolfx[P]P-Machine/ixa.cpp
// Function: Ixa::execute(StackMachine*)
void Ixa::execute(StackMachine *stack)
{
	StackAddress p1;
	StackInteger p2;
	
	if(typeid(p1) != typeid(*(stack->fStore[stack->fSP - 1])))
		throw ExecutionError("instruction ixa: STORE[SP-1] does not contain an element of type address.");
		
	if(typeid(p2) != typeid(*(stack->fStore[stack->fSP])))
		throw ExecutionError("instruction ixa: STORE[SP] does not contain an element of type integer.");
		
	StackInteger temp(fQ);
	
	int newaddress = stack->fStore[stack->fSP - 1]->getValue() + stack->fStore[stack->fSP]->getValue() * fQ;
	
	delete stack->fStore[stack->fSP - 1];
	delete stack->fStore[stack->fSP];
	stack->fStore.pop_back();
	
	--stack->fSP;
	
	stack->fStore[stack->fSP] = new StackAddress(newaddress);
	
	// adding cost of this instruction
	stack->fTime.count("ixa");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xd8(%rbp)
leaq -0x20(%rbp), %rdi
xorl %esi, %esi
movl %esi, -0xd0(%rbp)
callq 0x26800
movl -0xd0(%rbp), %esi
leaq -0x30(%rbp), %rdi
callq 0x27340
jmp 0x13520
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movl 0xb4(%rax), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x8e70
movq (%rax), %rax
movq %rax, -0xe0(%rbp)
cmpq $0x0, %rax
jne 0x13554
callq 0x7300
jmp 0x13554
movq -0xe0(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x373ef(%rip), %rdi     # 0x4a958
callq 0x9370
testb $0x1, %al
jne 0x13577
jmp 0x13651
movb $0x1, -0x62(%rbp)
movl $0x20, %edi
callq 0x7110
movq %rax, -0xf0(%rbp)
leaq -0x61(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0x74f0
movq -0xe8(%rbp), %rdx
leaq 0x24fce(%rip), %rsi     # 0x38578
leaq -0x60(%rbp), %rdi
callq 0x8940
jmp 0x135b5
movq -0xf0(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x283d0
jmp 0x135c7
movq -0xf0(%rbp), %rdi
movb $0x0, -0x62(%rbp)
leaq 0x364a7(%rip), %rsi     # 0x49a80
leaq 0x14e20(%rip), %rdx     # 0x28400
callq 0x74a0
jmp 0x13a12
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x13a00
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x139f7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x1362f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x7170
leaq -0x61(%rbp), %rdi
callq 0x72e0
testb $0x1, -0x62(%rbp)
jne 0x13640
jmp 0x1364c
movq -0xf0(%rbp), %rdi
callq 0x71c0
jmp 0x139f7
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movslq 0xb4(%rax), %rsi
callq 0x8e70
movq (%rax), %rax
movq %rax, -0xf8(%rbp)
cmpq $0x0, %rax
jne 0x13680
callq 0x7300
jmp 0x13680
movq -0xf8(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x3745b(%rip), %rdi     # 0x4aaf0
callq 0x9370
testb $0x1, %al
jne 0x136a3
jmp 0x13773
movb $0x1, -0x8a(%rbp)
movl $0x20, %edi
callq 0x7110
movq %rax, -0x108(%rbp)
leaq -0x89(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x74f0
movq -0x100(%rbp), %rdx
leaq 0x24ee6(%rip), %rsi     # 0x385c2
leaq -0x88(%rbp), %rdi
callq 0x8940
jmp 0x136ea
movq -0x108(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x283d0
jmp 0x136ff
movq -0x108(%rbp), %rdi
movb $0x0, -0x8a(%rbp)
leaq 0x3636c(%rip), %rsi     # 0x49a80
leaq 0x14ce5(%rip), %rdx     # 0x28400
callq 0x74a0
jmp 0x13a12
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x1374b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x7170
leaq -0x89(%rbp), %rdi
callq 0x72e0
testb $0x1, -0x8a(%rbp)
jne 0x13762
jmp 0x1376e
movq -0x108(%rbp), %rdi
callq 0x71c0
jmp 0x139f7
movq -0xd8(%rbp), %rax
movl 0x8(%rax), %esi
leaq -0xa0(%rbp), %rdi
callq 0x27340
jmp 0x1378b
movq -0x10(%rbp), %rax
movq %rax, %rdi
addq $0x18, %rdi
movl 0xb4(%rax), %eax
decl %eax
movslq %eax, %rsi
callq 0x8e70
movq (%rax), %rdi
movq (%rdi), %rax
movq 0x68(%rax), %rax
callq *%rax
movl %eax, -0x10c(%rbp)
jmp 0x137ba
movq -0x10(%rbp), %rax
movq %rax, %rdi
addq $0x18, %rdi
movslq 0xb4(%rax), %rsi
callq 0x8e70
movq (%rax), %rdi
movq (%rdi), %rax
movq 0x68(%rax), %rax
callq *%rax
movl %eax, -0x110(%rbp)
jmp 0x137e5
movl -0x10c(%rbp), %eax
movq -0xd8(%rbp), %rdx
movl -0x110(%rbp), %ecx
imull 0x8(%rdx), %ecx
addl %ecx, %eax
movl %eax, -0xa4(%rbp)
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movl 0xb4(%rax), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x8e70
movq (%rax), %rax
movq %rax, -0x118(%rbp)
cmpq $0x0, %rax
je 0x1384e
movq -0x118(%rbp), %rdi
callq 0x26ca0
movq -0x118(%rbp), %rdi
movl $0x8, %esi
callq 0x7280
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movslq 0xb4(%rax), %rsi
callq 0x8e70
movq (%rax), %rax
movq %rax, -0x120(%rbp)
cmpq $0x0, %rax
je 0x13893
movq -0x120(%rbp), %rdi
callq 0x26ca0
movq -0x120(%rbp), %rdi
movl $0x8, %esi
callq 0x7280
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
callq 0x8e90
movq -0x10(%rbp), %rax
movl 0xb4(%rax), %ecx
decl %ecx
movl %ecx, 0xb4(%rax)
movl $0x10, %edi
callq 0x7270
movq %rax, -0x128(%rbp)
jmp 0x138c5
movq -0x128(%rbp), %rdi
movl -0xa4(%rbp), %esi
callq 0x26800
jmp 0x138d9
movq -0x10(%rbp), %rax
movq %rax, %rdi
addq $0x18, %rdi
movslq 0xb4(%rax), %rsi
callq 0x8e70
movq -0x128(%rbp), %rcx
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
addq $0x78, %rax
movq %rax, -0x138(%rbp)
leaq -0xc9(%rbp), %rdi
movq %rdi, -0x130(%rbp)
callq 0x74f0
movq -0x130(%rbp), %rdx
leaq 0x24ce0(%rip), %rsi     # 0x3860a
leaq -0xc8(%rbp), %rdi
callq 0x8940
jmp 0x13938
movq -0x138(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x2c4d0
jmp 0x1394d
leaq -0xc8(%rbp), %rdi
callq 0x7170
leaq -0xc9(%rbp), %rdi
callq 0x72e0
leaq -0xa0(%rbp), %rdi
callq 0x27380
leaq -0x30(%rbp), %rdi
callq 0x27380
leaq -0x20(%rbp), %rdi
callq 0x26840
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x139eb
movq -0x128(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x10, %esi
callq 0x7280
jmp 0x139eb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x139df
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x7170
leaq -0xc9(%rbp), %rdi
callq 0x72e0
leaq -0xa0(%rbp), %rdi
callq 0x27380
leaq -0x30(%rbp), %rdi
callq 0x27380
leaq -0x20(%rbp), %rdi
callq 0x26840
movq -0x38(%rbp), %rdi
callq 0x74e0
nopw %cs:(%rax,%rax)