// File: zerolfx[P]P-Machine/sro.cpp
// Function: Sro::execute(StackMachine*)
void Sro::execute(StackMachine *stack)
{
	if(stack->fSP < 1)
		throw ExecutionError("instruction sro: at least 1 stackelement is required for this operation");

				
	switch(fType)
	{
		case integer:
		{
			StackInteger p1;

			if(typeid(p1) != typeid(*(stack->fStore[stack->fSP])))
			{
				throw ExecutionError("instruction sro: type pointed to by SP is not of type integer.");
			}
				
			break;
		}	
		case real:
		{
			StackReal p1;

			if(typeid(p1) != typeid(*(stack->fStore[stack->fSP])))
			{
				throw ExecutionError("instruction sro: type pointed to by SP is not of type real.");
			}

			break;
		}
		case boolean:
		{
			StackBoolean p1;
			
			if(typeid(p1) != typeid(*(stack->fStore[stack->fSP])))
			{
				throw ExecutionError("instruction sro: type pointed to by SP is not of type boolean.");
			}

			break;
		}
		case character:
		{
			StackCharacter p1;
			
			if(typeid(p1) != typeid(*(stack->fStore[stack->fSP])))
			{
				throw ExecutionError("instruction sro: type pointed to by SP is not of type character.");
			}


			break;
		}
		case address:
		{
			StackAddress p1;

			if(typeid(p1) != typeid(*(stack->fStore[stack->fSP])))
			{
				throw ExecutionError("instruction sro: type pointed to by SP is not of type address.");
			}
				
			break;
		}
	}
	
	if(fQ < 0)
	{
		// address on the heap
		if(fQ < stack->fNP)
			throw ExecutionError("instruction ind: invalid heap address.");
		else
		{
			stack->fHeap[fQ] = stack->fStore[stack->fSP];
		}
	}
	else
	{
		// address on the stack
		if(fQ > stack->fSP)
			throw ExecutionError("instruction ind: invalid stack address.");
		else
		{
			stack->fStore[fQ] = stack->fStore[stack->fSP];
		}
	}
	
	stack->fStore.pop_back();

	--stack->fSP;
	
	// adding cost of this instruction
	stack->fTime.count("sro");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2b0, %rsp            # imm = 0x2B0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x1e0(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x1, 0xb4(%rax)
jge 0x20a87
movb $0x1, -0x45(%rbp)
movl $0x20, %edi
callq 0x7110
movq %rax, -0x1f0(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0x1e8(%rbp)
callq 0x74f0
movq -0x1e8(%rbp), %rdx
leaq 0x18f6f(%rip), %rsi     # 0x39971
leaq -0x30(%rbp), %rdi
callq 0x8940
jmp 0x20a0d
movq -0x1f0(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x283d0
jmp 0x20a1f
movq -0x1f0(%rbp), %rdi
movb $0x0, -0x45(%rbp)
leaq 0x2904f(%rip), %rsi     # 0x49a80
leaq 0x79c8(%rip), %rdx      # 0x28400
callq 0x74a0
jmp 0x214b2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x20a65
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x7170
leaq -0x31(%rbp), %rdi
callq 0x72e0
testb $0x1, -0x45(%rbp)
jne 0x20a76
jmp 0x20a82
movq -0x1f0(%rbp), %rdi
callq 0x71c0
jmp 0x214a9
movq -0x1e0(%rbp), %rax
movl 0x8(%rax), %eax
movq %rax, -0x1f8(%rbp)
subq $0x4, %rax
ja 0x2116a
movq -0x1f8(%rbp), %rax
leaq 0x18ea8(%rip), %rcx     # 0x39958
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x58(%rbp), %rdi
xorl %esi, %esi
callq 0x27340
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movslq 0xb4(%rax), %rsi
callq 0x8e70
movq (%rax), %rax
movq %rax, -0x200(%rbp)
cmpq $0x0, %rax
jne 0x20af3
callq 0x7300
jmp 0x20af3
movq -0x200(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x29fe8(%rip), %rdi     # 0x4aaf0
callq 0x9370
testb $0x1, %al
jne 0x20b16
jmp 0x20bd9
movb $0x1, -0x7a(%rbp)
movl $0x20, %edi
callq 0x7110
movq %rax, -0x210(%rbp)
leaq -0x79(%rbp), %rdi
movq %rdi, -0x208(%rbp)
callq 0x74f0
movq -0x208(%rbp), %rdx
leaq 0x18e70(%rip), %rsi     # 0x399b9
leaq -0x78(%rbp), %rdi
callq 0x8940
jmp 0x20b54
movq -0x210(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x283d0
jmp 0x20b66
movq -0x210(%rbp), %rdi
movb $0x0, -0x7a(%rbp)
leaq 0x28f08(%rip), %rsi     # 0x49a80
leaq 0x7881(%rip), %rdx      # 0x28400
callq 0x74a0
jmp 0x214b2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x20be7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x20bba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x7170
leaq -0x79(%rbp), %rdi
callq 0x72e0
testb $0x1, -0x7a(%rbp)
jne 0x20bcb
jmp 0x20bd7
movq -0x210(%rbp), %rdi
callq 0x71c0
jmp 0x20be7
leaq -0x58(%rbp), %rdi
callq 0x27380
jmp 0x2116a
leaq -0x58(%rbp), %rdi
callq 0x27380
jmp 0x214a9
leaq -0x90(%rbp), %rdi
xorps %xmm0, %xmm0
callq 0x27840
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movslq 0xb4(%rax), %rsi
callq 0x8e70
movq (%rax), %rax
movq %rax, -0x218(%rbp)
cmpq $0x0, %rax
jne 0x20c33
callq 0x7300
jmp 0x20c33
movq -0x218(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x29f78(%rip), %rdi     # 0x4abc0
callq 0x9370
testb $0x1, %al
jne 0x20c56
jmp 0x20d31
movb $0x1, -0xb2(%rbp)
movl $0x20, %edi
callq 0x7110
movq %rax, -0x228(%rbp)
leaq -0xb1(%rbp), %rdi
movq %rdi, -0x220(%rbp)
callq 0x74f0
movq -0x220(%rbp), %rdx
leaq 0x18d69(%rip), %rsi     # 0x399f8
leaq -0xb0(%rbp), %rdi
callq 0x8940
jmp 0x20c9d
movq -0x228(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x283d0
jmp 0x20cb2
movq -0x228(%rbp), %rdi
movb $0x0, -0xb2(%rbp)
leaq 0x28db9(%rip), %rsi     # 0x49a80
leaq 0x7732(%rip), %rdx      # 0x28400
callq 0x74a0
jmp 0x214b2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x20d42
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x20d0c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x7170
leaq -0xb1(%rbp), %rdi
callq 0x72e0
testb $0x1, -0xb2(%rbp)
jne 0x20d23
jmp 0x20d2f
movq -0x228(%rbp), %rdi
callq 0x71c0
jmp 0x20d42
leaq -0x90(%rbp), %rdi
callq 0x27880
jmp 0x2116a
leaq -0x90(%rbp), %rdi
callq 0x27880
jmp 0x214a9
leaq -0xc8(%rbp), %rdi
xorl %esi, %esi
callq 0x27d20
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movslq 0xb4(%rax), %rsi
callq 0x8e70
movq (%rax), %rax
movq %rax, -0x230(%rbp)
cmpq $0x0, %rax
jne 0x20d90
callq 0x7300
jmp 0x20d90
movq -0x230(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x29eeb(%rip), %rdi     # 0x4ac90
callq 0x9370
testb $0x1, %al
jne 0x20db3
jmp 0x20e8e
movb $0x1, -0xea(%rbp)
movl $0x20, %edi
callq 0x7110
movq %rax, -0x240(%rbp)
leaq -0xe9(%rbp), %rdi
movq %rdi, -0x238(%rbp)
callq 0x74f0
movq -0x238(%rbp), %rdx
leaq 0x18c48(%rip), %rsi     # 0x39a34
leaq -0xe8(%rbp), %rdi
callq 0x8940
jmp 0x20dfa
movq -0x240(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x283d0
jmp 0x20e0f
movq -0x240(%rbp), %rdi
movb $0x0, -0xea(%rbp)
leaq 0x28c5c(%rip), %rsi     # 0x49a80
leaq 0x75d5(%rip), %rdx      # 0x28400
callq 0x74a0
jmp 0x214b2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x20e9f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x20e69
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x7170
leaq -0xe9(%rbp), %rdi
callq 0x72e0
testb $0x1, -0xea(%rbp)
jne 0x20e80
jmp 0x20e8c
movq -0x240(%rbp), %rdi
callq 0x71c0
jmp 0x20e9f
leaq -0xc8(%rbp), %rdi
callq 0x27d70
jmp 0x2116a
leaq -0xc8(%rbp), %rdi
callq 0x27d70
jmp 0x214a9
leaq -0x100(%rbp), %rdi
movl $0x61, %esi
callq 0x28170
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movslq 0xb4(%rax), %rsi
callq 0x8e70
movq (%rax), %rax
movq %rax, -0x248(%rbp)
cmpq $0x0, %rax
jne 0x20ef0
callq 0x7300
jmp 0x20ef0
movq -0x248(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x29e5b(%rip), %rdi     # 0x4ad60
callq 0x9370
testb $0x1, %al
jne 0x20f13
jmp 0x20fee
movb $0x1, -0x122(%rbp)
movl $0x20, %edi
callq 0x7110
movq %rax, -0x258(%rbp)
leaq -0x121(%rbp), %rdi
movq %rdi, -0x250(%rbp)
callq 0x74f0
movq -0x250(%rbp), %rdx
leaq 0x18b27(%rip), %rsi     # 0x39a73
leaq -0x120(%rbp), %rdi
callq 0x8940
jmp 0x20f5a
movq -0x258(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x283d0
jmp 0x20f6f
movq -0x258(%rbp), %rdi
movb $0x0, -0x122(%rbp)
leaq 0x28afc(%rip), %rsi     # 0x49a80
leaq 0x7475(%rip), %rdx      # 0x28400
callq 0x74a0
jmp 0x214b2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x20fff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x20fc9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x7170
leaq -0x121(%rbp), %rdi
callq 0x72e0
testb $0x1, -0x122(%rbp)
jne 0x20fe0
jmp 0x20fec
movq -0x258(%rbp), %rdi
callq 0x71c0
jmp 0x20fff
leaq -0x100(%rbp), %rdi
callq 0x281b0
jmp 0x2116a
leaq -0x100(%rbp), %rdi
callq 0x281b0
jmp 0x214a9
leaq -0x138(%rbp), %rdi
xorl %esi, %esi
callq 0x26800
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movslq 0xb4(%rax), %rsi
callq 0x8e70
movq (%rax), %rax
movq %rax, -0x260(%rbp)
cmpq $0x0, %rax
jne 0x2104d
callq 0x7300
jmp 0x2104d
movq -0x260(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x298f6(%rip), %rdi     # 0x4a958
callq 0x9370
testb $0x1, %al
jne 0x21070
jmp 0x2114b
movb $0x1, -0x15a(%rbp)
movl $0x20, %edi
callq 0x7110
movq %rax, -0x270(%rbp)
leaq -0x159(%rbp), %rdi
movq %rdi, -0x268(%rbp)
callq 0x74f0
movq -0x268(%rbp), %rdx
leaq 0x18a0b(%rip), %rsi     # 0x39ab4
leaq -0x158(%rbp), %rdi
callq 0x8940
jmp 0x210b7
movq -0x270(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x283d0
jmp 0x210cc
movq -0x270(%rbp), %rdi
movb $0x0, -0x15a(%rbp)
leaq 0x2899f(%rip), %rsi     # 0x49a80
leaq 0x7318(%rip), %rdx      # 0x28400
callq 0x74a0
jmp 0x214b2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x21159
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x21126
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x158(%rbp), %rdi
callq 0x7170
leaq -0x159(%rbp), %rdi
callq 0x72e0
testb $0x1, -0x15a(%rbp)
jne 0x2113d
jmp 0x21149
movq -0x270(%rbp), %rdi
callq 0x71c0
jmp 0x21159
leaq -0x138(%rbp), %rdi
callq 0x26840
jmp 0x2116a
leaq -0x138(%rbp), %rdi
callq 0x26840
jmp 0x214a9
movq -0x1e0(%rbp), %rax
cmpl $0x0, 0xc(%rax)
jge 0x212b1
movq -0x1e0(%rbp), %rax
movl 0xc(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0xb8(%rcx), %eax
jge 0x21265
movb $0x1, -0x182(%rbp)
movl $0x20, %edi
callq 0x7110
movq %rax, -0x280(%rbp)
leaq -0x181(%rbp), %rdi
movq %rdi, -0x278(%rbp)
callq 0x74f0
movq -0x278(%rbp), %rdx
leaq 0x17236(%rip), %rsi     # 0x38404
leaq -0x180(%rbp), %rdi
callq 0x8940
jmp 0x211dc
movq -0x280(%rbp), %rdi
leaq -0x180(%rbp), %rsi
callq 0x283d0
jmp 0x211f1
movq -0x280(%rbp), %rdi
movb $0x0, -0x182(%rbp)
leaq 0x2887a(%rip), %rsi     # 0x49a80
leaq 0x71f3(%rip), %rdx      # 0x28400
callq 0x74a0
jmp 0x214b2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x2123d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x180(%rbp), %rdi
callq 0x7170
leaq -0x181(%rbp), %rdi
callq 0x72e0
testb $0x1, -0x182(%rbp)
jne 0x21254
jmp 0x21260
movq -0x280(%rbp), %rdi
callq 0x71c0
jmp 0x214a9
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movslq 0xb4(%rax), %rsi
callq 0x8e70
movq %rax, %rcx
movq -0x1e0(%rbp), %rax
movq (%rcx), %rcx
movq %rcx, -0x288(%rbp)
movq -0x10(%rbp), %rdi
addq $0x30, %rdi
movslq 0xc(%rax), %rsi
callq 0x8e70
movq -0x288(%rbp), %rcx
movq %rcx, (%rax)
jmp 0x213e4
movq -0x1e0(%rbp), %rax
movl 0xc(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0xb4(%rcx), %eax
jle 0x2139b
movb $0x1, -0x1aa(%rbp)
movl $0x20, %edi
callq 0x7110
movq %rax, -0x298(%rbp)
leaq -0x1a9(%rbp), %rdi
movq %rdi, -0x290(%rbp)
callq 0x74f0
movq -0x290(%rbp), %rdx
leaq 0x17127(%rip), %rsi     # 0x3842b
leaq -0x1a8(%rbp), %rdi
callq 0x8940
jmp 0x21312
movq -0x298(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
callq 0x283d0
jmp 0x21327
movq -0x298(%rbp), %rdi
movb $0x0, -0x1aa(%rbp)
leaq 0x28744(%rip), %rsi     # 0x49a80
leaq 0x70bd(%rip), %rdx      # 0x28400
callq 0x74a0
jmp 0x214b2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x21373
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x1a8(%rbp), %rdi
callq 0x7170
leaq -0x1a9(%rbp), %rdi
callq 0x72e0
testb $0x1, -0x1aa(%rbp)
jne 0x2138a
jmp 0x21396
movq -0x298(%rbp), %rdi
callq 0x71c0
jmp 0x214a9
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movslq 0xb4(%rax), %rsi
callq 0x8e70
movq %rax, %rcx
movq -0x1e0(%rbp), %rax
movq (%rcx), %rcx
movq %rcx, -0x2a0(%rbp)
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movslq 0xc(%rax), %rsi
callq 0x8e70
movq -0x2a0(%rbp), %rcx
movq %rcx, (%rax)
jmp 0x213e4
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
callq 0x8e90
movq -0x10(%rbp), %rax
movl 0xb4(%rax), %ecx
decl %ecx
movl %ecx, 0xb4(%rax)
movq -0x10(%rbp), %rax
addq $0x78, %rax
movq %rax, -0x2b0(%rbp)
leaq -0x1d1(%rbp), %rdi
movq %rdi, -0x2a8(%rbp)
callq 0x74f0
movq -0x2a8(%rbp), %rdx
leaq 0x186c0(%rip), %rsi     # 0x39af3
leaq -0x1d0(%rbp), %rdi
callq 0x8940
jmp 0x21441
movq -0x2b0(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
callq 0x2c4d0
jmp 0x21456
leaq -0x1d0(%rbp), %rdi
callq 0x7170
leaq -0x1d1(%rbp), %rdi
callq 0x72e0
addq $0x2b0, %rsp            # imm = 0x2B0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x2149d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x1d0(%rbp), %rdi
callq 0x7170
leaq -0x1d1(%rbp), %rdi
callq 0x72e0
movq -0x40(%rbp), %rdi
callq 0x74e0
nopw %cs:(%rax,%rax)