// File: ys1998[P]spsim/src/alu.cpp
// Function: ALU2::ALU2(Latch<std::tuple<Instruction, int, int>>*, Latch<std::tuple<Instruction, int, int>>*, bool*)
ALU2::ALU2(	Latch< std::tuple<Instruction, int, int> >* in, 
			Latch< std::tuple<Instruction, int, int> >* out, bool* b){
	this->in = in; this->out = out; this->b = b;
	// store latencies of operations
	latencies[FUNCT["add"]] = LATENCY_ADD;
	latencies[FUNCT["sub"]] = LATENCY_SUB;
	latencies[FUNCT["mult"]] = LATENCY_MULT;
	latencies[FUNCT["div"]] = LATENCY_DIV;
	// set stall cycles to zero
	stall_cycles = 0;
	read = true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x5e20
movq -0xe0(%rbp), %rdi
leaq 0x2a1df(%rip), %rax     # 0x2eba8
movq %rax, (%rdi)
addq $0x8, %rdi
movq %rdi, -0xf8(%rbp)
callq 0xe8a0
movq -0xe0(%rbp), %rdi
subq $-0x80, %rdi
movq %rdi, -0xf0(%rbp)
movq %rdi, %rax
movq %rax, -0xe8(%rbp)
callq 0x5e40
movq -0xe0(%rbp), %rax
movq -0x10(%rbp), %rcx
movq %rcx, 0xc8(%rax)
movq -0x18(%rbp), %rcx
movq %rcx, 0xd0(%rax)
movq -0x20(%rbp), %rcx
movq %rcx, 0xd8(%rax)
leaq -0x41(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0x3490
movq -0xd8(%rbp), %rdx
leaq 0x1d5c1(%rip), %rsi     # 0x22004
leaq -0x40(%rbp), %rdi
callq 0x6020
jmp 0x4a4e
leaq 0x2a8a3(%rip), %rdi     # 0x2f2f8
leaq -0x40(%rbp), %rsi
callq 0x5f40
movq %rax, -0x100(%rbp)
jmp 0x4a67
movq -0x100(%rbp), %rsi
movq -0xf0(%rbp), %rdi
callq 0x5e60
movq %rax, -0x108(%rbp)
jmp 0x4a83
movq -0x108(%rbp), %rax
movl $0x1, (%rax)
leaq -0x40(%rbp), %rdi
callq 0x31e0
leaq -0x41(%rbp), %rdi
callq 0x3300
movq -0xe0(%rbp), %rax
subq $-0x80, %rax
movq %rax, -0x118(%rbp)
leaq -0x79(%rbp), %rdi
movq %rdi, -0x110(%rbp)
callq 0x3490
movq -0x110(%rbp), %rdx
leaq 0x1d536(%rip), %rsi     # 0x22008
leaq -0x78(%rbp), %rdi
callq 0x6020
jmp 0x4add
leaq 0x2a814(%rip), %rdi     # 0x2f2f8
leaq -0x78(%rbp), %rsi
callq 0x5f40
movq %rax, -0x120(%rbp)
jmp 0x4af6
movq -0x120(%rbp), %rsi
movq -0x118(%rbp), %rdi
callq 0x5e60
movq %rax, -0x128(%rbp)
jmp 0x4b12
movq -0x128(%rbp), %rax
movl $0x1, (%rax)
leaq -0x78(%rbp), %rdi
callq 0x31e0
leaq -0x79(%rbp), %rdi
callq 0x3300
movq -0xe0(%rbp), %rax
subq $-0x80, %rax
movq %rax, -0x138(%rbp)
leaq -0xa1(%rbp), %rdi
movq %rdi, -0x130(%rbp)
callq 0x3490
movq -0x130(%rbp), %rdx
leaq 0x1d4b0(%rip), %rsi     # 0x22014
leaq -0xa0(%rbp), %rdi
callq 0x6020
jmp 0x4b72
leaq 0x2a77f(%rip), %rdi     # 0x2f2f8
leaq -0xa0(%rbp), %rsi
callq 0x5f40
movq %rax, -0x140(%rbp)
jmp 0x4b8e
movq -0x140(%rbp), %rsi
movq -0x138(%rbp), %rdi
callq 0x5e60
movq %rax, -0x148(%rbp)
jmp 0x4baa
movq -0x148(%rbp), %rax
movl $0x6, (%rax)
leaq -0xa0(%rbp), %rdi
callq 0x31e0
leaq -0xa1(%rbp), %rdi
callq 0x3300
movq -0xe0(%rbp), %rax
subq $-0x80, %rax
movq %rax, -0x158(%rbp)
leaq -0xc9(%rbp), %rdi
movq %rdi, -0x150(%rbp)
callq 0x3490
movq -0x150(%rbp), %rdx
leaq 0x1d417(%rip), %rsi     # 0x22019
leaq -0xc8(%rbp), %rdi
callq 0x6020
jmp 0x4c10
leaq 0x2a6e1(%rip), %rdi     # 0x2f2f8
leaq -0xc8(%rbp), %rsi
callq 0x5f40
movq %rax, -0x160(%rbp)
jmp 0x4c2c
movq -0x160(%rbp), %rsi
movq -0x158(%rbp), %rdi
callq 0x5e60
movq %rax, -0x168(%rbp)
jmp 0x4c48
movq -0x168(%rbp), %rax
movl $0x23, (%rax)
leaq -0xc8(%rbp), %rdi
callq 0x31e0
leaq -0xc9(%rbp), %rdi
callq 0x3300
movq -0xe0(%rbp), %rax
movl $0x0, 0xb0(%rax)
movb $0x1, 0xc4(%rax)
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x4cb1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x31e0
leaq -0x41(%rbp), %rdi
callq 0x3300
jmp 0x4d53
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x4ce2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x31e0
leaq -0x79(%rbp), %rdi
callq 0x3300
jmp 0x4d53
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x4d13
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x31e0
leaq -0xa1(%rbp), %rdi
callq 0x3300
jmp 0x4d53
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x4d47
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x31e0
leaq -0xc9(%rbp), %rdi
callq 0x3300
movq -0xe8(%rbp), %rdi
callq 0x61b0
movq -0xf8(%rbp), %rdi
callq 0x61d0
movq -0x50(%rbp), %rdi
callq 0x3480
nopw %cs:(%rax,%rax)