// File: zerolfx[P]P-Machine/in.cpp
// Function: In::execute(StackMachine*)
void In::execute(StackMachine *stack) 
{	
	switch(fType)
	{
		case integer:
		{
			int inputvalue;
			cin >> inputvalue;
			stack->fStore.push_back(new StackInteger(inputvalue));
			break;
		}	
		case real:
		{
			double inputvalue;
			cin >> inputvalue;
			stack->fStore.push_back(new StackReal(inputvalue));
			break;
		}
		case character:
		{
			char inputvalue;
			cin >> inputvalue;
			stack->fStore.push_back(new StackCharacter(inputvalue));
			break;
		}
		case boolean:
		{
			bool inputvalue;
			cin >> inputvalue;
			stack->fStore.push_back(new StackBoolean(inputvalue));
			break;
		}
		case address:
		{
			throw ExecutionError("instruction in: input of address at runtime is not allowed");
		}
	}
	
	// SP := SP + 1
	++stack->fSP;
	
	// adding cost of this instruction
	stack->fTime.count("in");

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movl 0x8(%rax), %eax
movq %rax, -0xb8(%rbp)
subq $0x4, %rax
ja 0x24188
movq -0xb8(%rbp), %rax
leaq 0x161bf(%rip), %rcx     # 0x3a068
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x2711f(%rip), %rdi     # 0x4afd8
leaq -0x14(%rbp), %rsi
callq 0x7160
movq -0x10(%rbp), %rax
addq $0x18, %rax
movq %rax, -0xc8(%rbp)
movl $0x10, %edi
callq 0x7270
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xc0(%rbp)
movl -0x14(%rbp), %esi
callq 0x27340
jmp 0x23ef2
movq -0xc8(%rbp), %rdi
movq -0xc0(%rbp), %rax
movq %rax, -0x20(%rbp)
leaq -0x20(%rbp), %rsi
callq 0xd2a0
jmp 0x24188
movq -0xc0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x10, %esi
callq 0x7280
jmp 0x24240
movq 0x2709d(%rip), %rdi     # 0x4afd8
leaq -0x38(%rbp), %rsi
callq 0x71f0
movq -0x10(%rbp), %rax
addq $0x18, %rax
movq %rax, -0xd8(%rbp)
movl $0x10, %edi
callq 0x7270
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xd0(%rbp)
movsd -0x38(%rbp), %xmm0
callq 0x27840
jmp 0x23f76
movq -0xd8(%rbp), %rdi
movq -0xd0(%rbp), %rax
movq %rax, -0x40(%rbp)
leaq -0x40(%rbp), %rsi
callq 0xd2a0
jmp 0x24188
movq -0xd0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x10, %esi
callq 0x7280
jmp 0x24240
movq 0x27019(%rip), %rdi     # 0x4afd8
leaq -0x41(%rbp), %rsi
callq 0x73b0
movq -0x10(%rbp), %rax
addq $0x18, %rax
movq %rax, -0xe8(%rbp)
movl $0x10, %edi
callq 0x7270
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xe0(%rbp)
movsbl -0x41(%rbp), %esi
callq 0x28170
jmp 0x23ff9
movq -0xe8(%rbp), %rdi
movq -0xe0(%rbp), %rax
movq %rax, -0x50(%rbp)
leaq -0x50(%rbp), %rsi
callq 0xd2a0
jmp 0x24188
movq -0xe0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x10, %esi
callq 0x7280
jmp 0x24240
movq 0x26f96(%rip), %rdi     # 0x4afd8
leaq -0x51(%rbp), %rsi
callq 0x7220
movq -0x10(%rbp), %rax
addq $0x18, %rax
movq %rax, -0xf8(%rbp)
movl $0x10, %edi
callq 0x7270
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xf0(%rbp)
movzbl -0x51(%rbp), %esi
andl $0x1, %esi
callq 0x27d20
jmp 0x2407f
movq -0xf8(%rbp), %rdi
movq -0xf0(%rbp), %rax
movq %rax, -0x60(%rbp)
leaq -0x60(%rbp), %rsi
callq 0xd2a0
jmp 0x24188
movq -0xf0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x10, %esi
callq 0x7280
jmp 0x24240
movb $0x1, -0x82(%rbp)
movl $0x20, %edi
callq 0x7110
movq %rax, -0x108(%rbp)
leaq -0x81(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x74f0
movq -0x100(%rbp), %rdx
leaq 0x15f86(%rip), %rsi     # 0x3a080
leaq -0x80(%rbp), %rdi
callq 0x8940
jmp 0x24105
movq -0x108(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x283d0
jmp 0x24117
movq -0x108(%rbp), %rdi
movb $0x0, -0x82(%rbp)
leaq 0x25954(%rip), %rsi     # 0x49a80
leaq 0x42cd(%rip), %rdx      # 0x28400
callq 0x74a0
jmp 0x24249
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x24160
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x7170
leaq -0x81(%rbp), %rdi
callq 0x72e0
testb $0x1, -0x82(%rbp)
jne 0x24177
jmp 0x24183
movq -0x108(%rbp), %rdi
callq 0x71c0
jmp 0x24240
movq -0x10(%rbp), %rax
movl 0xb4(%rax), %ecx
incl %ecx
movl %ecx, 0xb4(%rax)
movq -0x10(%rbp), %rax
addq $0x78, %rax
movq %rax, -0x118(%rbp)
leaq -0xa9(%rbp), %rdi
movq %rdi, -0x110(%rbp)
callq 0x74f0
movq -0x110(%rbp), %rdx
leaq 0x15ef1(%rip), %rsi     # 0x3a0bb
leaq -0xa8(%rbp), %rdi
callq 0x8940
jmp 0x241d8
movq -0x118(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x2c4d0
jmp 0x241ed
leaq -0xa8(%rbp), %rdi
callq 0x7170
leaq -0xa9(%rbp), %rdi
callq 0x72e0
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x24234
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x7170
leaq -0xa9(%rbp), %rdi
callq 0x72e0
movq -0x28(%rbp), %rdi
callq 0x74e0
nopl (%rax)