// File: /workspace/github_cpp_makefile_star2_O1/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rdi, %rbx
movq 0x188(%rdi), %r14
cmpb $0x1, 0x80(%r14)
jne 0x15acf
movb $0x0, 0x80(%r14)
movl (%r14), %eax
leaq 0x50(%rsp), %r15
movl %eax, -0x8(%r15)
leaq 0x8(%r14), %rsi
movl $0xa, %ecx
movq %r15, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq 0xa0(%rsp), %r12
leaq 0xb0(%rsp), %r13
movq %r13, -0x10(%r13)
movq 0x58(%r14), %rsi
movq 0x60(%r14), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x52b6
movq 0x78(%r14), %rax
movq %rax, 0x10(%r13)
leaq 0x10(%rbx), %r14
movl $0xa, %ecx
movq %r14, %rdi
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x60(%rbx), %rdi
movq %r12, %rsi
callq 0x3270
movq 0x10(%r13), %rax
movq %rax, 0x80(%rbx)
movl -0x68(%r13), %eax
movl %eax, 0x8(%rbx)
movq -0x10(%r13), %rdi
cmpq %r13, %rdi
je 0x15a0e
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x3200
leaq 0x48(%rsp), %rdi
movl $0xa, %ecx
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x60(%rbx), %rsi
movq 0x68(%rbx), %rdx
addq %rsi, %rdx
callq 0x52b6
movq 0x80(%rbx), %rax
movq %rax, 0x10(%r14)
cmpl $-0x1, -0x5c(%r14)
je 0x15ab2
cmpl $-0x1, 0x48(%rsp)
je 0x15ab2
leaq 0x28(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0xac8c
cmpl $0x0, 0x2c(%rsp)
jne 0x15ab2
movq 0x1a8(%rbx), %r15
leaq 0x28(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0xac5a
leaq 0x28(%rsp), %rdi
movslq 0x4(%rdi), %rax
movl 0x8(%rbx), %ecx
movl %ecx, (%r15,%rax,4)
movq 0x1b0(%rbx), %r15
leaq 0x48(%rsp), %rsi
callq 0xac5a
movslq 0x2c(%rsp), %rax
movb $0x0, (%r15,%rax)
movq 0x98(%rsp), %rdi
cmpq %r14, %rdi
je 0x15acf
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x3200
movq 0x198(%rbx), %r14
cmpb $0x1, 0x80(%r14)
jne 0x15cf6
movb $0x0, 0x80(%r14)
movq (%r14), %rax
leaq 0x50(%rsp), %r15
movq %rax, -0x8(%r15)
leaq 0x8(%r14), %rsi
movl $0xa, %ecx
movq %r15, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq 0xa0(%rsp), %r12
leaq 0xb0(%rsp), %r13
movq %r13, -0x10(%r13)
movq 0x58(%r14), %rsi
movq 0x60(%r14), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x52b6
movq 0x78(%r14), %rax
movq %rax, 0x10(%r13)
leaq 0x110(%rbx), %r14
movl $0xa, %ecx
movq %r14, %rdi
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x160(%rbx), %rdi
movq %r12, %rsi
callq 0x3270
movq 0x10(%r13), %rax
movq %rax, 0x180(%rbx)
movl -0x64(%r13), %eax
movl %eax, 0x10c(%rbx)
movl -0x68(%r13), %eax
movl %eax, 0x108(%rbx)
movq -0x10(%r13), %rdi
cmpq %r13, %rdi
je 0x15b92
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x3200
leaq 0x48(%rsp), %rdi
movl $0xa, %ecx
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x160(%rbx), %rsi
movq 0x168(%rbx), %rdx
addq %rsi, %rdx
callq 0x52b6
movq 0x180(%rbx), %rax
movq %rax, 0x10(%r14)
cmpl $-0x1, -0x5c(%r14)
je 0x15cd9
cmpl $-0x1, 0x48(%rsp)
je 0x15cd9
movq %rsp, %rdi
leaq 0x48(%rsp), %rsi
callq 0xac8c
movl 0x4(%rsp), %ebp
testl %ebp, %ebp
je 0x15c07
xorl %r15d, %r15d
jmp 0x15c54
leaq 0x20(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0xac8c
movl 0x20(%rsp), %r12d
leaq 0x38(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x13ee(%rip), %rsi      # 0x17019
leaq 0x13ea(%rip), %rdx      # 0x1701c
leaq 0x28(%rsp), %rdi
callq 0x5346
leaq 0x75fd(%rip), %rdi      # 0x1d240
leaq 0x28(%rsp), %rsi
callq 0x517a
cmpl (%rax), %r12d
setne %r15b
testl %ebp, %ebp
jne 0x15c73
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x15c73
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x3200
movq 0x1a8(%rbx), %r12
testb %r15b, %r15b
je 0x15c9d
movq %rsp, %rdi
leaq 0x48(%rsp), %rsi
callq 0xac5a
movslq 0x4(%rsp), %rax
movl 0x10c(%rbx), %ecx
movl %ecx, (%r12,%rax,4)
jmp 0x15cbb
movslq 0x10c(%rbx), %rax
movq %rax, 0x108(%r12)
movslq 0x108(%rbx), %rax
movq %rax, 0x100(%r12)
movq 0x1b0(%rbx), %r15
movq %rsp, %rdi
leaq 0x48(%rsp), %rsi
callq 0xac5a
movslq 0x4(%rsp), %rax
movb $0x0, (%r15,%rax)
movq 0x98(%rsp), %rdi
cmpq %r14, %rdi
je 0x15cf6
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x3200
movq 0x190(%rbx), %r14
cmpb $0x1, 0x80(%r14)
jne 0x15ec5
movb $0x0, 0x80(%r14)
movl (%r14), %eax
leaq 0x50(%rsp), %r15
movl %eax, -0x8(%r15)
leaq 0x8(%r14), %rsi
movl $0xa, %ecx
movq %r15, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq 0xa0(%rsp), %r12
leaq 0xb0(%rsp), %r13
movq %r13, -0x10(%r13)
movq 0x58(%r14), %rsi
movq 0x60(%r14), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x52b6
movq 0x78(%r14), %rax
movq %rax, 0x10(%r13)
leaq 0x90(%rbx), %r14
movl $0xa, %ecx
movq %r14, %rdi
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0xe0(%rbx), %rdi
movq %r12, %rsi
callq 0x3270
movq 0x10(%r13), %rax
movq %rax, 0x100(%rbx)
movl -0x68(%r13), %eax
movl %eax, 0x88(%rbx)
movq -0x10(%r13), %rdi
cmpq %r13, %rdi
je 0x15daf
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x3200
leaq 0x48(%rsp), %rdi
movl $0xa, %ecx
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0xe0(%rbx), %rsi
movq 0xe8(%rbx), %rdx
addq %rsi, %rdx
callq 0x52b6
movq 0x100(%rbx), %rax
movq %rax, 0x10(%r14)
cmpl $-0x1, -0x5c(%r14)
je 0x15ea8
cmpl $-0x1, 0x48(%rsp)
je 0x15ea8
leaq 0x20(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0xac8c
movl 0x24(%rsp), %ebp
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x1240(%rip), %rsi      # 0x1706d
leaq 0x123b(%rip), %rdx      # 0x1706f
movq %rsp, %rdi
callq 0x5346
leaq 0x73cd(%rip), %rdi      # 0x1d210
movq %rsp, %rsi
callq 0x517a
movl (%rax), %r12d
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x15e64
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3200
cmpl %r12d, %ebp
jne 0x15ea8
movq 0x1a8(%rbx), %r15
movq %rsp, %rdi
leaq 0x48(%rsp), %rsi
callq 0xac5a
movq %rsp, %rdi
movslq 0x4(%rdi), %rax
movl 0x88(%rbx), %ecx
movl %ecx, (%r15,%rax,4)
movq 0x1b0(%rbx), %rbx
leaq 0x48(%rsp), %rsi
callq 0xac5a
movslq 0x4(%rsp), %rax
movb $0x0, (%rbx,%rax)
movq 0x98(%rsp), %rdi
cmpq %r14, %rdi
je 0x15ec5
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x3200
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x15f1f
movq 0x38(%rsp), %rsi
jmp 0x15f0a
jmp 0x15f1c
jmp 0x15f1c
jmp 0x15f1c
jmp 0x15f1c
jmp 0x15f1c
jmp 0x15f1c
jmp 0x15f1c
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x15f1f
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3200
jmp 0x15f1f
jmp 0x15f1c
jmp 0x15f1c
jmp 0x15f1c
jmp 0x15f1c
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r14, %rdi
je 0x15f3c
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x3200
movq %rbx, %rdi
callq 0x3340