// File: /workspace/github_cpp_makefile_star2_O3/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 $0xb8, %rsp
movq %rdi, %rbx
movq 0x188(%rdi), %r14
cmpb $0x1, 0x80(%r14)
jne 0x14e1b
movb $0x0, 0x80(%r14)
movl (%r14), %eax
leaq 0x38(%rsp), %r15
movl %eax, -0x8(%r15)
leaq 0x8(%r14), %rsi
movl $0xa, %ecx
movq %r15, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x88(%rsp), %r12
leaq 0x98(%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)
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 0x14d5a
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x3200
leaq 0x30(%rsp), %rdi
movl $0xa, %ecx
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x60(%rbx), %rsi
movq 0x68(%rbx), %rdx
addq %rsi, %rdx
callq 0x5274
movq 0x80(%rbx), %rax
movq %rax, 0x10(%r14)
cmpl $-0x1, -0x5c(%r14)
je 0x14dfe
cmpl $-0x1, 0x30(%rsp)
je 0x14dfe
leaq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0xa8b8
cmpl $0x0, 0xc(%rsp)
jne 0x14dfe
movq 0x1a8(%rbx), %r15
leaq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0xa88e
leaq 0x8(%rsp), %rdi
movslq 0x4(%rdi), %rax
movl 0x8(%rbx), %ecx
movl %ecx, (%r15,%rax,4)
movq 0x1b0(%rbx), %r15
leaq 0x30(%rsp), %rsi
callq 0xa88e
movslq 0xc(%rsp), %rax
movb $0x0, (%r15,%rax)
movq 0x80(%rsp), %rdi
cmpq %r14, %rdi
je 0x14e1b
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x3200
movq 0x198(%rbx), %r14
cmpb $0x1, 0x80(%r14)
jne 0x15014
movb $0x0, 0x80(%r14)
movq (%r14), %rax
leaq 0x38(%rsp), %r15
movq %rax, -0x8(%r15)
leaq 0x8(%r14), %rsi
movl $0xa, %ecx
movq %r15, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x88(%rsp), %r12
leaq 0x98(%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)
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)
movq -0x68(%r13), %rax
movq %rax, 0x108(%rbx)
movq -0x10(%r13), %rdi
cmpq %r13, %rdi
je 0x14ed5
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x3200
leaq 0x30(%rsp), %rdi
movl $0xa, %ecx
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x160(%rbx), %rsi
movq 0x168(%rbx), %rdx
addq %rsi, %rdx
callq 0x5274
movq 0x180(%rbx), %rax
movq %rax, 0x10(%r14)
cmpl $-0x1, -0x5c(%r14)
je 0x14ff7
cmpl $-0x1, 0x30(%rsp)
je 0x14ff7
leaq 0x28(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0xa8b8
cmpl $0x0, 0x2c(%rsp)
jne 0x14fb4
leaq 0xb0(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0xa8b8
movl 0xb0(%rsp), %ebp
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x10aa(%rip), %rsi      # 0x16019
leaq 0x10a6(%rip), %rdx      # 0x1601c
leaq 0x8(%rsp), %rdi
callq 0x530a
leaq 0x72b9(%rip), %rdi      # 0x1c240
leaq 0x8(%rsp), %rsi
callq 0x5136
movl (%rax), %r12d
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x14fab
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3200
cmpl %r12d, %ebp
jne 0x151fe
movq 0x1a8(%rbx), %rax
movslq 0x10c(%rbx), %rcx
movq %rcx, 0x108(%rax)
movslq 0x108(%rbx), %rcx
movq %rcx, 0x100(%rax)
movq 0x1b0(%rbx), %r15
leaq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0xa88e
movslq 0xc(%rsp), %rax
movb $0x0, (%r15,%rax)
movq 0x80(%rsp), %rdi
cmpq %r14, %rdi
je 0x15014
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x3200
movq 0x190(%rbx), %r14
cmpb $0x1, 0x80(%r14)
jne 0x151ec
movb $0x0, 0x80(%r14)
movl (%r14), %eax
leaq 0x38(%rsp), %r15
movl %eax, -0x8(%r15)
leaq 0x8(%r14), %rsi
movl $0xa, %ecx
movq %r15, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x88(%rsp), %r12
leaq 0x98(%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)
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 0x150cd
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x3200
leaq 0x30(%rsp), %rdi
movl $0xa, %ecx
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0xe0(%rbx), %rsi
movq 0xe8(%rbx), %rdx
addq %rsi, %rdx
callq 0x5274
movq 0x100(%rbx), %rax
movq %rax, 0x10(%r14)
cmpl $-0x1, -0x5c(%r14)
je 0x151cf
cmpl $-0x1, 0x30(%rsp)
je 0x151cf
leaq 0x28(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0xa8b8
movl 0x2c(%rsp), %ebp
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xf22(%rip), %rsi       # 0x1606d
leaq 0xf1d(%rip), %rdx       # 0x1606f
leaq 0x8(%rsp), %rdi
callq 0x530a
leaq 0x70ad(%rip), %rdi      # 0x1c210
leaq 0x8(%rsp), %rsi
callq 0x5136
movl (%rax), %r12d
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x15187
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3200
cmpl %r12d, %ebp
jne 0x151cf
movq 0x1a8(%rbx), %r15
leaq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0xa88e
leaq 0x8(%rsp), %rdi
movslq 0x4(%rdi), %rax
movl 0x88(%rbx), %ecx
movl %ecx, (%r15,%rax,4)
movq 0x1b0(%rbx), %rbx
leaq 0x30(%rsp), %rsi
callq 0xa88e
movslq 0xc(%rsp), %rax
movb $0x0, (%rbx,%rax)
movq 0x80(%rsp), %rdi
cmpq %r14, %rdi
je 0x151ec
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x3200
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1a8(%rbx), %r15
leaq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0xa88e
movslq 0xc(%rsp), %rax
movl 0x10c(%rbx), %ecx
movl %ecx, (%r15,%rax,4)
jmp 0x14fd7
jmp 0x1525c
jmp 0x15238
jmp 0x1525c
jmp 0x1525c
jmp 0x1525c
jmp 0x1525c
jmp 0x1525c
jmp 0x1525c
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x1525f
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3200
jmp 0x1525f
jmp 0x1525c
jmp 0x1525c
jmp 0x1525c
jmp 0x1525c
movq %rax, %rbx
movq 0x80(%rsp), %rdi
cmpq %r14, %rdi
je 0x1527c
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x3200
movq %rbx, %rdi
callq 0x3340