// File: /workspace/github_cpp_makefile_star2_O3/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
cmpl $0x0, 0xb0(%rdi)
jne 0x3fb7
movq %rdi, %rbx
cmpl $-0x1, 0xc(%rdi)
je 0x3dbc
cmpl $-0x1, 0x8(%rbx)
je 0x3dbc
movq %rbx, %rdi
callq 0x3984
movq 0xc8(%rbx), %r14
movb $0x0, 0x80(%r14)
movq (%r14), %rax
leaq 0x110(%rsp), %rdi
movq %rax, -0x8(%rdi)
leaq 0x8(%r14), %rsi
movl $0xa, %ecx
rep  movsq (%rsi), %es:(%rdi)
leaq 0x160(%rsp), %rdi
leaq 0x170(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x58(%r14), %rsi
movq 0x60(%r14), %rdx
addq %rsi, %rdx
callq 0x5274
movq 0x78(%r14), %rax
movq %rax, 0x10(%r15)
movq -0x10(%r15), %rdi
cmpq %r15, %rdi
je 0x3dbc
movq 0x170(%rsp), %rsi
incq %rsi
callq 0x3200
movq 0xc8(%rbx), %r14
cmpb $0x1, 0x80(%r14)
jne 0x3fb7
cmpb $0x1, 0xc0(%rbx)
jne 0x3fb7
movb $0x0, 0x80(%r14)
movq (%r14), %rax
leaq 0x10(%rsp), %r15
movq %rax, -0x8(%r15)
leaq 0x8(%r14), %rsi
movl $0xa, %ecx
movq %r15, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x60(%rsp), %r12
leaq 0x70(%rsp), %r13
movq %r13, -0x10(%r13)
movq 0x58(%r14), %rsi
movq 0x60(%r14), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x5274
movq 0x78(%r14), %rax
movq %rax, 0x10(%r13)
movq 0xc8(%rbx), %rbp
movb $0x1, 0x80(%rbp)
leaq 0x8(%rbp), %rdi
movl $0xa, %ecx
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x58(%rbp), %rdi
movq %r12, %rsi
callq 0x3140
leaq 0x8(%rbx), %r14
movq 0x80(%rsp), %rax
movq %rax, 0x78(%rbp)
movq 0x8(%rsp), %rax
movq %rax, (%rbp)
movl $0xa, %ecx
movq %r14, %rdi
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x58(%rbx), %rdi
movq %r12, %rsi
callq 0x3140
movq 0x80(%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 0x3ead
movb $0x0, 0xc0(%rbx)
movq 0x8(%rsp), %xmm0
pshufd $0xe1, %xmm0, %xmm0     # xmm0 = xmm0[1,0,2,3]
movq %xmm0, 0xb4(%rbx)
leaq 0x1833d(%rip), %rcx     # 0x1c204
movl (%rcx), %ecx
movl %ecx, 0x48(%rbx)
incl %ecx
movl %ecx, 0x50(%rbx)
testb %al, %al
je 0x3f7c
movq %rsp, %rdi
movq %r14, %rsi
callq 0xa8b8
leaq 0x80(%rbx), %rdi
movq %rsp, %rsi
callq 0x51b2
cmpl $0x1, (%rax)
jne 0x3f7c
movq %rbx, %rdi
callq 0x3984
movq 0xc8(%rbx), %rbx
movb $0x0, 0x80(%rbx)
movq (%rbx), %rax
leaq 0x90(%rsp), %rdi
movq %rax, -0x8(%rdi)
leaq 0x8(%rbx), %rsi
movl $0xa, %ecx
rep  movsq (%rsi), %es:(%rdi)
leaq 0xe0(%rsp), %rdi
leaq 0xf0(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x58(%rbx), %rsi
movq 0x60(%rbx), %rdx
addq %rsi, %rdx
callq 0x5274
movq 0x78(%rbx), %rax
movq %rax, 0x100(%rsp)
movq 0xe0(%rsp), %rdi
cmpq %r14, %rdi
je 0x3fa0
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x3200
jmp 0x3fa0
movq %rsp, %rdi
movq %r14, %rsi
callq 0xa8b8
leaq 0x80(%rbx), %rdi
movq %rsp, %rsi
callq 0x51b2
movl (%rax), %eax
decl %eax
movl %eax, 0xb0(%rbx)
movq 0x60(%rsp), %rdi
cmpq %r13, %rdi
je 0x3fb7
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x3200
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3fcd
jmp 0x3fcd
movq %rax, %rbx
movq 0x60(%rsp), %rdi
cmpq %r13, %rdi
je 0x3fe7
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x3200
movq %rbx, %rdi
callq 0x3340
nop