// File: /workspace/github_cpp_makefile_star2_O2/ys1998[P]spsim/src/writer.cpp
// Function: Writer::tick()
void Writer::tick(void){
	if(in1->valid()){
		t1 = in1->read();
		Instruction i1 = std::get<0>(t1);
		if(i1.is_valid() && std::get<0>(i1.type()) == 0){
			rf->write(std::get<2>(i1.physical_regs()), std::get<1>(t1));
			*(b + std::get<2>(i1.physical_regs())) = false;
		}
	}
	if(in2->valid()){
		t2 = in2->read();
		Instruction i2 = std::get<0>(t2);
		if(i2.is_valid()){
			if(std::get<0>(i2.type()) == 0 && std::get<1>(i2.type()) != FUNCT["div"])
				rf->write(std::get<2>(i2.physical_regs()), std::get<1>(t2));
			else{
				rf->write_lo(std::get<1>(t2));
				rf->write_hi(std::get<2>(t2));
			}
			*(b + std::get<2>(i2.physical_regs())) = false;
		}
	}
	if(in3->valid()){
		t3 = in3->read();
		Instruction i3 = std::get<0>(t3);
		if(i3.is_valid()){
			if(std::get<0>(i3.type()) == OPCODE["lw"]){
				rf->write(std::get<2>(i3.physical_regs()), std::get<1>(t3));
				*(b + std::get<2>(i3.physical_regs())) = false;
			}
		}
	}

}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0xc0, %rsp
movq %rdi, %rbx
movq 0x188(%rdi), %rsi
cmpb $0x1, 0x80(%rsi)
jne 0xe8c1
leaq 0x40(%rsp), %r14
movq %r14, %rdi
callq 0x86f0
leaq 0x8(%rbx), %rdi
movq %r14, %rsi
callq 0xef90
leaq 0x98(%rsp), %rdi
callq 0x3100
leaq 0x10(%rbx), %rsi
leaq 0x40(%rsp), %r14
movq %r14, %rdi
callq 0x49ba
cmpl $-0x1, 0x4(%r14)
je 0xe8b4
cmpl $-0x1, 0x40(%rsp)
je 0xe8b4
leaq 0x10(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x7c7c
cmpl $0x0, 0x14(%rsp)
jne 0xe8b4
movq 0x1a8(%rbx), %r14
leaq 0x10(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x7c52
leaq 0x10(%rsp), %rdi
movslq 0x4(%rdi), %rax
movl 0x8(%rbx), %ecx
movl %ecx, (%r14,%rax,4)
movq 0x1b0(%rbx), %r14
leaq 0x40(%rsp), %rsi
callq 0x7c52
movslq 0x14(%rsp), %rax
movb $0x0, (%r14,%rax)
leaq 0x90(%rsp), %rdi
callq 0x3100
movq 0x198(%rbx), %rsi
cmpb $0x1, 0x80(%rsi)
jne 0xe9de
leaq 0x40(%rsp), %r14
movq %r14, %rdi
callq 0x48ea
leaq 0x108(%rbx), %rdi
movq %r14, %rsi
callq 0xefa6
leaq 0x98(%rsp), %rdi
callq 0x3100
leaq 0x110(%rbx), %rsi
leaq 0x40(%rsp), %r14
movq %r14, %rdi
callq 0x49ba
cmpl $-0x1, 0x4(%r14)
je 0xe9d1
cmpl $-0x1, 0x40(%rsp)
je 0xe9d1
leaq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x7c7c
cmpl $0x0, 0x34(%rsp)
jne 0xe98e
leaq 0x38(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x7c7c
movl 0x38(%rsp), %ebp
leaq 0x16c1(%rip), %rsi      # 0x10019
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x4860
leaq 0x88ca(%rip), %rdi      # 0x17238
leaq 0x10(%rsp), %rsi
callq 0x47fa
movl (%rax), %r14d
leaq 0x10(%rsp), %rdi
callq 0x3100
cmpl %r14d, %ebp
jne 0xeaed
movq 0x1a8(%rbx), %rax
movslq 0x10c(%rbx), %rcx
movq %rcx, 0x108(%rax)
movslq 0x108(%rbx), %rcx
movq %rcx, 0x100(%rax)
movq 0x1b0(%rbx), %r14
leaq 0x10(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x7c52
movslq 0x14(%rsp), %rax
movb $0x0, (%r14,%rax)
leaq 0x90(%rsp), %rdi
callq 0x3100
movq 0x190(%rbx), %rsi
cmpb $0x1, 0x80(%rsi)
jne 0xeae1
leaq 0x40(%rsp), %r14
movq %r14, %rdi
callq 0x86f0
leaq 0x88(%rbx), %rdi
movq %r14, %rsi
callq 0xef90
leaq 0x98(%rsp), %rdi
callq 0x3100
leaq 0x90(%rbx), %rsi
leaq 0x40(%rsp), %r14
movq %r14, %rdi
callq 0x49ba
cmpl $-0x1, 0x4(%r14)
je 0xead4
cmpl $-0x1, 0x40(%rsp)
je 0xead4
leaq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x7c7c
movl 0x34(%rsp), %ebp
leaq 0x160e(%rip), %rsi      # 0x1006d
leaq 0x10(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x4860
leaq 0x8793(%rip), %rdi      # 0x17208
leaq 0x10(%rsp), %rsi
callq 0x47fa
movl (%rax), %r14d
leaq 0x10(%rsp), %rdi
callq 0x3100
cmpl %r14d, %ebp
jne 0xead4
movq 0x1a8(%rbx), %r14
leaq 0x10(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x7c52
leaq 0x10(%rsp), %rdi
movslq 0x4(%rdi), %rax
movl 0x88(%rbx), %ecx
movl %ecx, (%r14,%rax,4)
movq 0x1b0(%rbx), %rbx
leaq 0x40(%rsp), %rsi
callq 0x7c52
movslq 0x14(%rsp), %rax
movb $0x0, (%rbx,%rax)
leaq 0x90(%rsp), %rdi
callq 0x3100
addq $0xc0, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movq 0x1a8(%rbx), %r14
leaq 0x10(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x7c52
movslq 0x14(%rsp), %rax
movl 0x10c(%rbx), %ecx
movl %ecx, (%r14,%rax,4)
jmp 0xe9b1
jmp 0xeb3e
jmp 0xeb27
jmp 0xeb3e
jmp 0xeb3e
jmp 0xeb3e
jmp 0xeb3e
jmp 0xeb3e
jmp 0xeb3e
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x3100
jmp 0xeb41
jmp 0xeb3e
jmp 0xeb3e
jmp 0xeb3e
jmp 0xeb3e
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x3100
movq %rbx, %rdi
callq 0x3320