// File: ys1998[P]spsim/src/issuer.cpp
// Function: Issuer::flush(int)
void Issuer::flush(int id){
	iq->flush(id);

	for(int j=0; j < NUM_ALU; ++j){
		if(i[j].is_valid() && i[j].get_id() > id){
			i[j] = Instruction();
		}
	}

	for(int j=0; j < NUM_ALU; ++j){
		if(l[j]->valid()){
			auto inp = l[j]->read();
			auto iRead = std::get<0>(inp);
			auto in1 = std::get<1>(inp);
			auto in2 = std::get<2>(inp);
			if(iRead.get_id() < id){
				l[j]->write(std::make_tuple(iRead, in1, in2 ));
			}
		}
	}
	if(outer_latch->valid()){
			auto inp = outer_latch->read();
			auto iRead = std::get<0>(inp);
			auto in1 = std::get<1>(inp);
			if(iRead.get_id() < id){
				outer_latch->write(std::make_tuple(iRead, in1));
			}
		}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x3e0, %rsp            # imm = 0x3E0
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x3a8(%rbp)
movq 0x208(%rax), %rdi
movl -0xc(%rbp), %esi
callq 0x1c590
movl $0x0, -0x10(%rbp)
cmpl $0x4, -0x10(%rbp)
jge 0x121b8
movq -0x3a8(%rbp), %rdi
addq $0x8, %rdi
movslq -0x10(%rbp), %rax
imulq $0x78, %rax, %rax
addq %rax, %rdi
callq 0x6280
testb $0x1, %al
jne 0x1214e
jmp 0x121a8
movq -0x3a8(%rbp), %rdi
addq $0x8, %rdi
movslq -0x10(%rbp), %rax
imulq $0x78, %rax, %rax
addq %rax, %rdi
callq 0x6270
cmpl -0xc(%rbp), %eax
jle 0x121a8
leaq -0x88(%rbp), %rdi
callq 0xe8a0
movq -0x3a8(%rbp), %rdi
addq $0x8, %rdi
movslq -0x10(%rbp), %rax
imulq $0x78, %rax, %rax
addq %rax, %rdi
leaq -0x88(%rbp), %rsi
callq 0xd230
leaq -0x88(%rbp), %rdi
callq 0x61d0
jmp 0x121aa
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x12123
movl $0x0, -0x8c(%rbp)
cmpl $0x4, -0x8c(%rbp)
jge 0x12383
movq -0x3a8(%rbp), %rax
movslq -0x8c(%rbp), %rcx
movq 0x1e8(%rax,%rcx,8), %rdi
callq 0x6310
testb $0x1, %al
jne 0x121f3
jmp 0x1236d
movq -0x3a8(%rbp), %rax
movslq -0x8c(%rbp), %rcx
movq 0x1e8(%rax,%rcx,8), %rsi
leaq -0x110(%rbp), %rdi
movq %rdi, -0x3b0(%rbp)
callq 0x62b0
movq -0x3b0(%rbp), %rdi
callq 0x6360
movq %rax, %rsi
leaq -0x188(%rbp), %rdi
callq 0x6c70
jmp 0x12239
leaq -0x110(%rbp), %rdi
movq %rdi, -0x3c0(%rbp)
callq 0x63e0
movq -0x3c0(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x198(%rbp)
callq 0x6400
movl (%rax), %eax
movl %eax, -0x19c(%rbp)
leaq -0x188(%rbp), %rdi
callq 0x6270
movl %eax, -0x3b4(%rbp)
jmp 0x1227c
movl -0x3b4(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x12336
movq -0x3a8(%rbp), %rax
movslq -0x8c(%rbp), %rcx
movq 0x1e8(%rax,%rcx,8), %rax
movq %rax, -0x3c8(%rbp)
leaq -0x220(%rbp), %rdi
leaq -0x188(%rbp), %rsi
leaq -0x198(%rbp), %rdx
leaq -0x19c(%rbp), %rcx
callq 0x6500
jmp 0x122cb
movq -0x3c8(%rbp), %rdi
leaq -0x220(%rbp), %rsi
callq 0x6330
jmp 0x122e0
leaq -0x220(%rbp), %rdi
callq 0x62f0
jmp 0x12336
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x190(%rbp)
movl %eax, -0x194(%rbp)
jmp 0x1235c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x190(%rbp)
movl %eax, -0x194(%rbp)
jmp 0x12350
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x190(%rbp)
movl %eax, -0x194(%rbp)
leaq -0x220(%rbp), %rdi
callq 0x62f0
jmp 0x12350
leaq -0x188(%rbp), %rdi
callq 0x61d0
leaq -0x110(%rbp), %rdi
callq 0x62f0
jmp 0x1236d
leaq -0x188(%rbp), %rdi
callq 0x61d0
leaq -0x110(%rbp), %rdi
callq 0x62f0
jmp 0x124ed
jmp 0x1236f
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0x121c2
movq -0x3a8(%rbp), %rax
movq 0x238(%rax), %rdi
callq 0x6420
testb $0x1, %al
jne 0x1239f
jmp 0x124e4
movq -0x3a8(%rbp), %rax
movq 0x238(%rax), %rsi
leaq -0x2a0(%rbp), %rdi
movq %rdi, -0x3d0(%rbp)
callq 0x12500
movq -0x3d0(%rbp), %rdi
callq 0x12590
movq %rax, %rsi
leaq -0x318(%rbp), %rdi
callq 0x6c70
jmp 0x123dd
leaq -0x2a0(%rbp), %rdi
callq 0x12540
movl (%rax), %eax
movl %eax, -0x31c(%rbp)
leaq -0x318(%rbp), %rdi
callq 0x6270
movl %eax, -0x3d4(%rbp)
jmp 0x12405
movl -0x3d4(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x124b0
movq -0x3a8(%rbp), %rax
movq 0x238(%rax), %rax
movq %rax, -0x3e0(%rbp)
leaq -0x3a0(%rbp), %rdi
leaq -0x318(%rbp), %rsi
leaq -0x31c(%rbp), %rdx
callq 0x6470
jmp 0x12445
movq -0x3e0(%rbp), %rdi
leaq -0x3a0(%rbp), %rsi
callq 0x6440
jmp 0x1245a
leaq -0x3a0(%rbp), %rdi
callq 0x64b0
jmp 0x124b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x190(%rbp)
movl %eax, -0x194(%rbp)
jmp 0x124d6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x190(%rbp)
movl %eax, -0x194(%rbp)
jmp 0x124ca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x190(%rbp)
movl %eax, -0x194(%rbp)
leaq -0x3a0(%rbp), %rdi
callq 0x64b0
jmp 0x124ca
leaq -0x318(%rbp), %rdi
callq 0x61d0
leaq -0x2a0(%rbp), %rdi
callq 0x64b0
jmp 0x124e4
leaq -0x318(%rbp), %rdi
callq 0x61d0
leaq -0x2a0(%rbp), %rdi
callq 0x64b0
jmp 0x124ed
addq $0x3e0, %rsp            # imm = 0x3E0
popq %rbp
retq
movq -0x190(%rbp), %rdi
callq 0x3480
nopl (%rax)