// File: ys1998[P]spsim/src/alu.cpp
// Function: ALU2::operate()
void ALU2::operate(void){
	int funct = std::get<1>(i.type());
	if(funct == FUNCT["add"]){
		lo = in1 + in2; hi = 0;
	}else if(funct == FUNCT["sub"]){
		lo = in1 - in2; hi = 0;
	}else if(funct == FUNCT["mult"]){
		lo = (long)((long)in1 * (long)in2) % (long)pow(2, 32); 
		hi = (long)(((long)in1 * (long)in2) / (long)pow(2, 32)); 
	}else if(funct == FUNCT["div"]){
		lo = in1 % in2; hi = (long)(in1 / in2);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rsi
movq %rsi, -0xe8(%rbp)
addq $0x8, %rsi
leaq -0x14(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x105b0
movq -0xe0(%rbp), %rdi
callq 0x61f0
movl (%rax), %eax
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0xd4(%rbp)
leaq -0x39(%rbp), %rdi
movq %rdi, -0xd0(%rbp)
callq 0x3490
movq -0xd0(%rbp), %rdx
leaq 0x1d21e(%rip), %rsi     # 0x22004
leaq -0x38(%rbp), %rdi
callq 0x6020
jmp 0x4df1
leaq 0x2a500(%rip), %rdi     # 0x2f2f8
leaq -0x38(%rbp), %rsi
callq 0x5f40
movq %rax, -0xf0(%rbp)
jmp 0x4e0a
movq -0xf0(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xf4(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x31e0
leaq -0x39(%rbp), %rdi
callq 0x3300
movl -0xf4(%rbp), %ecx
movl -0xd4(%rbp), %eax
cmpl %ecx, %eax
jne 0x4e94
movq -0xe8(%rbp), %rax
movl 0xb4(%rax), %ecx
addl 0xb8(%rax), %ecx
movl %ecx, 0xc0(%rax)
movl $0x0, 0xbc(%rax)
jmp 0x51cc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x4e86
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x31e0
leaq -0x39(%rbp), %rdi
callq 0x3300
jmp 0x51d5
movl -0xc(%rbp), %eax
movl %eax, -0x104(%rbp)
leaq -0x71(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x3490
movq -0x100(%rbp), %rdx
leaq 0x1d14d(%rip), %rsi     # 0x22008
leaq -0x70(%rbp), %rdi
callq 0x6020
jmp 0x4ec6
leaq 0x2a42b(%rip), %rdi     # 0x2f2f8
leaq -0x70(%rbp), %rsi
callq 0x5f40
movq %rax, -0x110(%rbp)
jmp 0x4edf
movq -0x110(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x114(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x31e0
leaq -0x71(%rbp), %rdi
callq 0x3300
movl -0x114(%rbp), %ecx
movl -0x104(%rbp), %eax
cmpl %ecx, %eax
jne 0x4f69
movq -0xe8(%rbp), %rax
movl 0xb4(%rax), %ecx
subl 0xb8(%rax), %ecx
movl %ecx, 0xc0(%rax)
movl $0x0, 0xbc(%rax)
jmp 0x51ca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x4f5b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x31e0
leaq -0x71(%rbp), %rdi
callq 0x3300
jmp 0x51d5
movl -0xc(%rbp), %eax
movl %eax, -0x124(%rbp)
leaq -0x99(%rbp), %rdi
movq %rdi, -0x120(%rbp)
callq 0x3490
movq -0x120(%rbp), %rdx
leaq 0x1d081(%rip), %rsi     # 0x22014
leaq -0x98(%rbp), %rdi
callq 0x6020
jmp 0x4fa1
leaq 0x2a350(%rip), %rdi     # 0x2f2f8
leaq -0x98(%rbp), %rsi
callq 0x5f40
movq %rax, -0x130(%rbp)
jmp 0x4fbd
movq -0x130(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x134(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x31e0
leaq -0x99(%rbp), %rdi
callq 0x3300
movl -0x134(%rbp), %ecx
movl -0x124(%rbp), %eax
cmpl %ecx, %eax
jne 0x50cc
movq -0xe8(%rbp), %rcx
movslq 0xb4(%rcx), %rax
movslq 0xb8(%rcx), %rcx
imulq %rcx, %rax
movq %rax, -0x148(%rbp)
movl $0x2, %edi
movl $0x20, %esi
callq 0x64d0
movq -0x148(%rbp), %rax
movq -0xe8(%rbp), %rcx
cvttsd2si %xmm0, %rsi
cqto
idivq %rsi
movl %edx, %eax
movl %eax, 0xc0(%rcx)
movslq 0xb4(%rcx), %rax
movslq 0xb8(%rcx), %rcx
imulq %rcx, %rax
movq %rax, -0x140(%rbp)
movl $0x2, %edi
movl $0x20, %esi
callq 0x64d0
movq -0x140(%rbp), %rax
cvttsd2si %xmm0, %rcx
cqto
idivq %rcx
movq %rax, %rcx
movq -0xe8(%rbp), %rax
movl %ecx, 0xbc(%rax)
jmp 0x51c8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x50bb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x31e0
leaq -0x99(%rbp), %rdi
callq 0x3300
jmp 0x51d5
movl -0xc(%rbp), %eax
movl %eax, -0x154(%rbp)
leaq -0xc1(%rbp), %rdi
movq %rdi, -0x150(%rbp)
callq 0x3490
movq -0x150(%rbp), %rdx
leaq 0x1cf23(%rip), %rsi     # 0x22019
leaq -0xc0(%rbp), %rdi
callq 0x6020
jmp 0x5104
leaq 0x2a1ed(%rip), %rdi     # 0x2f2f8
leaq -0xc0(%rbp), %rsi
callq 0x5f40
movq %rax, -0x160(%rbp)
jmp 0x5120
movq -0x160(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x164(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x31e0
leaq -0xc1(%rbp), %rdi
callq 0x3300
movl -0x164(%rbp), %ecx
movl -0x154(%rbp), %eax
cmpl %ecx, %eax
jne 0x51c6
movq -0xe8(%rbp), %rcx
movl 0xb4(%rcx), %eax
cltd
idivl 0xb8(%rcx)
movl %edx, 0xc0(%rcx)
movl 0xb4(%rcx), %eax
cltd
idivl 0xb8(%rcx)
movl %eax, %ecx
movq -0xe8(%rbp), %rax
movslq %ecx, %rcx
movl %ecx, 0xbc(%rax)
jmp 0x51c6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x51b8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x31e0
leaq -0xc1(%rbp), %rdi
callq 0x3300
jmp 0x51d5
jmp 0x51c8
jmp 0x51ca
jmp 0x51cc
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x3480
nop