// File: /workspace/github_cpp_makefile_star2_O1/ys1998[P]spsim/src/alu.cpp
// Function: ALU1::tick()
void ALU1::tick(void){
	if(stall_cycles == 0){
		if(i.is_valid()){	
			operate();
			in->read();
		}
		if(in->valid() && read){
			auto inp = in->read();
			in->write(inp);
			i = std::get<0>(inp);
			if(i.is_valid())
				read = false;
			in1 = std::get<1>(inp);
			in2 = std::get<2>(inp);
			i.EXEC = CLOCK;
			i.MEM = CLOCK + 1;
			if(i.is_valid() && latencies[std::get<1>(i.type())] == 1){
				operate();
				in->read();
			}else{
				stall_cycles = latencies[std::get<1>(i.type())] - 1;	
			}
		}
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x190, %rsp            # imm = 0x190
cmpl $0x0, 0xb0(%rdi)
jne 0x3fd5
movq %rdi, %rbx
cmpl $-0x1, 0xc(%rdi)
je 0x3dc7
cmpl $-0x1, 0x8(%rbx)
je 0x3dc7
movq %rbx, %rdi
callq 0x3984
movq 0xc8(%rbx), %r14
movb $0x0, 0x80(%r14)
movq (%r14), %rax
leaq 0x118(%rsp), %rdi
movq %rax, -0x8(%rdi)
leaq 0x8(%r14), %rsi
movl $0xa, %ecx
rep  movsq (%rsi), %es:(%rdi)
leaq 0x168(%rsp), %rdi
leaq 0x178(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x58(%r14), %rsi
movq 0x60(%r14), %rdx
addq %rsi, %rdx
callq 0x52b6
movq 0x78(%r14), %rax
movq %rax, 0x10(%r15)
movq -0x10(%r15), %rdi
cmpq %r15, %rdi
je 0x3dc7
movq 0x178(%rsp), %rsi
incq %rsi
callq 0x3200
movq 0xc8(%rbx), %r13
cmpb $0x1, 0x80(%r13)
jne 0x3fd5
cmpb $0x1, 0xc0(%rbx)
jne 0x3fd5
movb $0x0, 0x80(%r13)
movq (%r13), %rax
leaq 0x18(%rsp), %r15
movq %rax, -0x8(%r15)
leaq 0x8(%r13), %rsi
movl $0xa, %ecx
movq %r15, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x68(%rsp), %r14
leaq 0x78(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x58(%r13), %rsi
movq 0x60(%r13), %rdx
addq %rsi, %rdx
movq %r14, %rdi
callq 0x52b6
movq 0x78(%r13), %rax
movq %rax, 0x10(%r12)
movq 0xc8(%rbx), %r13
movb $0x1, 0x80(%r13)
leaq 0x8(%r13), %rdi
movl $0xa, %ecx
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x58(%r13), %rdi
movq %r14, %rsi
callq 0x3140
leaq 0x8(%rbx), %r14
leaq 0x68(%rsp), %rax
movq 0x20(%rax), %rcx
movq %rcx, 0x78(%r13)
movl -0x54(%rax), %ecx
movl %ecx, 0x4(%r13)
movl -0x58(%rax), %ecx
movl %ecx, (%r13)
movl $0xa, %ecx
movq %r14, %rdi
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x58(%rbx), %rdi
movq %rax, %rsi
callq 0x3140
movq 0x88(%rsp), %rax
movq %rax, 0x78(%rbx)
cmpl $-0x1, 0xc(%rbx)
setne %cl
cmpl $-0x1, 0x8(%rbx)
setne %al
andb %cl, %al
cmpb $0x1, %al
jne 0x3ec2
movb $0x0, 0xc0(%rbx)
movl 0x14(%rsp), %ecx
movl %ecx, 0xb4(%rbx)
movl 0x10(%rsp), %ecx
movl %ecx, 0xb8(%rbx)
leaq 0x19327(%rip), %rcx     # 0x1d204
movl (%rcx), %ecx
movl %ecx, 0x48(%rbx)
incl %ecx
movl %ecx, 0x50(%rbx)
testb %al, %al
je 0x3f96
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0xac8c
leaq 0x80(%rbx), %rdi
leaq 0x8(%rsp), %rsi
callq 0x51f6
cmpl $0x1, (%rax)
jne 0x3f96
movq %rbx, %rdi
callq 0x3984
movq 0xc8(%rbx), %rbx
movb $0x0, 0x80(%rbx)
movq (%rbx), %rax
leaq 0x98(%rsp), %rdi
movq %rax, -0x8(%rdi)
leaq 0x8(%rbx), %rsi
movl $0xa, %ecx
rep  movsq (%rsi), %es:(%rdi)
leaq 0xe8(%rsp), %rdi
leaq 0xf8(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x58(%rbx), %rsi
movq 0x60(%rbx), %rdx
addq %rsi, %rdx
callq 0x52b6
movq 0x78(%rbx), %rax
movq %rax, 0x108(%rsp)
movq 0xe8(%rsp), %rdi
cmpq %r14, %rdi
je 0x3fbe
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x3200
jmp 0x3fbe
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0xac8c
leaq 0x80(%rbx), %rdi
leaq 0x8(%rsp), %rsi
callq 0x51f6
movl (%rax), %eax
decl %eax
movl %eax, 0xb0(%rbx)
movq 0x68(%rsp), %rdi
cmpq %r12, %rdi
je 0x3fd5
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x3200
addq $0x190, %rsp            # imm = 0x190
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
jmp 0x3fea
jmp 0x3fea
movq %rax, %rbx
movq 0x68(%rsp), %rdi
cmpq %r12, %rdi
je 0x4004
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x3200
movq %rbx, %rdi
callq 0x3340