// File: ys1998[P]spsim/src/alu.cpp
// Function: ALU1::ALU1(Latch<std::tuple<Instruction, int, int>>*, Latch<std::tuple<Instruction, int>>*, bool*, ALU2*, ALU3*, Flusher*, int*, int*)
ALU1::ALU1(	Latch< std::tuple<Instruction, int, int> >* in, 
			Latch< std::tuple<Instruction, int> >* out, bool* b,
			ALU2 *a, ALU3* a3, Flusher *f, int* p, int* pa){
	this->in = in; this->out = out; this->b = b; this->a = a; this->f = f;
	this->predict = p; this->predict_addr = pa; this->a3 = a3;
	// store latencies of operations
	latencies[FUNCT["add"]] = LATENCY_ADD;
	latencies[FUNCT["sub"]] = LATENCY_SUB;
	latencies[0] = 1;
	// set stall cycles to zero
	stall_cycles = 0;
	read = true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xa0(%rbp)
callq 0x5e20
movq -0xa0(%rbp), %rdi
leaq 0x2b1c3(%rip), %rax     # 0x2eb80
movq %rax, (%rdi)
addq $0x8, %rdi
movq %rdi, -0xb8(%rbp)
callq 0xe8a0
movq -0xa0(%rbp), %rdi
subq $-0x80, %rdi
movq %rdi, -0xb0(%rbp)
movq %rdi, %rax
movq %rax, -0xa8(%rbp)
callq 0x5e40
movq -0xa0(%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)
movq -0x28(%rbp), %rcx
movq %rcx, 0xe0(%rax)
movq 0x10(%rbp), %rcx
movq %rcx, 0xf0(%rax)
movq 0x18(%rbp), %rcx
movq %rcx, 0xf8(%rax)
movq 0x20(%rbp), %rcx
movq %rcx, 0x100(%rax)
movq -0x30(%rbp), %rcx
movq %rcx, 0xe8(%rax)
leaq -0x51(%rbp), %rdi
movq %rdi, -0x98(%rbp)
callq 0x3490
movq -0x98(%rbp), %rdx
leaq 0x1e596(%rip), %rsi     # 0x22004
leaq -0x50(%rbp), %rdi
callq 0x6020
jmp 0x3a79
leaq 0x2b878(%rip), %rdi     # 0x2f2f8
leaq -0x50(%rbp), %rsi
callq 0x5f40
movq %rax, -0xc0(%rbp)
jmp 0x3a92
movq -0xc0(%rbp), %rsi
movq -0xb0(%rbp), %rdi
callq 0x5e60
movq %rax, -0xc8(%rbp)
jmp 0x3aae
movq -0xc8(%rbp), %rax
movl $0x1, (%rax)
leaq -0x50(%rbp), %rdi
callq 0x31e0
leaq -0x51(%rbp), %rdi
callq 0x3300
movq -0xa0(%rbp), %rax
subq $-0x80, %rax
movq %rax, -0xd8(%rbp)
leaq -0x89(%rbp), %rdi
movq %rdi, -0xd0(%rbp)
callq 0x3490
movq -0xd0(%rbp), %rdx
leaq 0x1e508(%rip), %rsi     # 0x22008
leaq -0x88(%rbp), %rdi
callq 0x6020
jmp 0x3b0e
leaq 0x2b7e3(%rip), %rdi     # 0x2f2f8
leaq -0x88(%rbp), %rsi
callq 0x5f40
movq %rax, -0xe0(%rbp)
jmp 0x3b2a
movq -0xe0(%rbp), %rsi
movq -0xd8(%rbp), %rdi
callq 0x5e60
movq %rax, -0xe8(%rbp)
jmp 0x3b46
movq -0xe8(%rbp), %rax
movl $0x1, (%rax)
leaq -0x88(%rbp), %rdi
callq 0x31e0
leaq -0x89(%rbp), %rdi
callq 0x3300
movq -0xa0(%rbp), %rdi
subq $-0x80, %rdi
movl $0x0, -0x90(%rbp)
leaq -0x90(%rbp), %rsi
callq 0x60d0
movq %rax, -0xf0(%rbp)
jmp 0x3b95
movq -0xa0(%rbp), %rax
movq -0xf0(%rbp), %rcx
movl $0x1, (%rcx)
movl $0x0, 0xb0(%rax)
movb $0x1, 0xc0(%rax)
addq $0xf0, %rsp
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x3be6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x31e0
leaq -0x51(%rbp), %rdi
callq 0x3300
jmp 0x3c31
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x3c17
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x31e0
leaq -0x89(%rbp), %rdi
callq 0x3300
jmp 0x3c31
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
movq -0xa8(%rbp), %rdi
callq 0x61b0
movq -0xb8(%rbp), %rdi
callq 0x61d0
movq -0x60(%rbp), %rdi
callq 0x3480
nopw %cs:(%rax,%rax)