// File: ys1998[P]spsim/src/issuer.cpp
// Function: Issuer::tick()
void Issuer::tick(void){
	if(outer_latch->valid()){
		auto temp = outer_latch->read();
		if (last_index_issued >= 0 && last_index_issued < 1e8){
			aq->_addr[last_index_issued] = std::get<1>(temp);
			aq->_q[last_index_issued] = std::get<0>(temp); 
		}
	}

	for(int j=0; j < NUM_ALU; ++j){
		if(!l[j]->valid()){
			if(j == addrescal_latch){
				auto temp = aq->ALUissue();				
				i[j] = std::get<0>(temp);
				last_index_issued = present_index_issued;
				present_index_issued = std::get<1>(temp);
			}else if(j == memory_latch){
				auto temp = aq->MEMissue();
				i[j] = std::get<0>(temp);
				mem_address = std::get<1>(temp);
				int temp_index = std::get<2>(temp);
				if(i[j].is_valid()){
					if(temp_index <= last_index_issued)
						--last_index_issued;
					if(temp_index <= present_index_issued)
						--present_index_issued;
				}
			}else{
				i[j] = iq->issue(j);
			}
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x260, %rsp            # imm = 0x260
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x220(%rbp)
movq 0x238(%rax), %rdi
callq 0x6420
testb $0x1, %al
jne 0x118af
jmp 0x119b4
movq -0x220(%rbp), %rax
movq 0x238(%rax), %rsi
leaq -0x88(%rbp), %rdi
callq 0x12500
movq -0x220(%rbp), %rax
cmpl $0x0, 0x228(%rax)
jl 0x119a8
movq -0x220(%rbp), %rax
cvtsi2sdl 0x228(%rax), %xmm1
movsd 0x1094c(%rip), %xmm0    # 0x22240
ucomisd %xmm1, %xmm0
jbe 0x119a8
leaq -0x88(%rbp), %rdi
movq %rdi, -0x230(%rbp)
callq 0x12540
movq %rax, %rcx
movq -0x220(%rbp), %rax
movl (%rcx), %ecx
movl %ecx, -0x234(%rbp)
movq 0x210(%rax), %rdi
addq $0x58, %rdi
movslq 0x228(%rax), %rsi
callq 0x12560
movl -0x234(%rbp), %ecx
movq -0x230(%rbp), %rdi
movl %ecx, (%rax)
callq 0x12590
movq %rax, %rcx
movq -0x220(%rbp), %rax
movq %rcx, -0x228(%rbp)
movq 0x210(%rax), %rdi
movslq 0x228(%rax), %rsi
callq 0xaca0
movq -0x228(%rbp), %rsi
movq %rax, %rdi
callq 0x6380
jmp 0x11983
jmp 0x119a8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x64b0
jmp 0x11c8c
leaq -0x88(%rbp), %rdi
callq 0x64b0
movl $0x0, -0x98(%rbp)
cmpl $0x4, -0x98(%rbp)
jge 0x11c83
movq -0x220(%rbp), %rax
movslq -0x98(%rbp), %rcx
movq 0x1e8(%rax,%rcx,8), %rdi
callq 0x6310
testb $0x1, %al
jne 0x11c6d
movq -0x220(%rbp), %rcx
movl -0x98(%rbp), %eax
cmpl 0x220(%rcx), %eax
jne 0x11aba
movq -0x220(%rbp), %rax
movq 0x210(%rax), %rsi
leaq -0x118(%rbp), %rdi
movq %rdi, -0x240(%rbp)
callq 0x1d540
movq -0x240(%rbp), %rdi
callq 0x12590
movq %rax, %rsi
movq -0x220(%rbp), %rax
movslq -0x98(%rbp), %rcx
imulq $0x78, %rcx, %rcx
leaq 0x8(%rax,%rcx), %rdi
callq 0x6380
jmp 0x11a55
movq -0x220(%rbp), %rax
movl 0x22c(%rax), %ecx
movl %ecx, 0x228(%rax)
leaq -0x118(%rbp), %rdi
callq 0x12540
movq %rax, %rcx
movq -0x220(%rbp), %rax
movl (%rcx), %ecx
movl %ecx, 0x22c(%rax)
leaq -0x118(%rbp), %rdi
callq 0x64b0
jmp 0x11c6b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x64b0
jmp 0x11c8c
movq -0x220(%rbp), %rcx
movl -0x98(%rbp), %eax
cmpl 0x224(%rcx), %eax
jne 0x11c18
movq -0x220(%rbp), %rax
movq 0x210(%rax), %rsi
leaq -0x198(%rbp), %rdi
movq %rdi, -0x248(%rbp)
callq 0x1c750
movq -0x248(%rbp), %rdi
callq 0x6360
movq %rax, %rsi
movq -0x220(%rbp), %rax
movslq -0x98(%rbp), %rcx
imulq $0x78, %rcx, %rcx
leaq 0x8(%rax,%rcx), %rdi
callq 0x6380
jmp 0x11b21
leaq -0x198(%rbp), %rdi
movq %rdi, -0x258(%rbp)
callq 0x63e0
movq -0x258(%rbp), %rdi
movq %rax, %rcx
movq -0x220(%rbp), %rax
movl (%rcx), %ecx
movl %ecx, 0x230(%rax)
callq 0x6400
movq %rax, %rcx
movq -0x220(%rbp), %rax
movl (%rcx), %ecx
movl %ecx, -0x19c(%rbp)
movslq -0x98(%rbp), %rcx
imulq $0x78, %rcx, %rcx
leaq 0x8(%rax,%rcx), %rdi
callq 0x6280
movb %al, -0x249(%rbp)
jmp 0x11b81
movb -0x249(%rbp), %al
testb $0x1, %al
jne 0x11b8d
jmp 0x11c0a
movq -0x220(%rbp), %rcx
movl -0x19c(%rbp), %eax
cmpl 0x228(%rcx), %eax
jg 0x11bdd
movq -0x220(%rbp), %rax
movl 0x228(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x228(%rax)
jmp 0x11bdd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x198(%rbp), %rdi
callq 0x62f0
jmp 0x11c8c
movq -0x220(%rbp), %rcx
movl -0x19c(%rbp), %eax
cmpl 0x22c(%rcx), %eax
jg 0x11c08
movq -0x220(%rbp), %rax
movl 0x22c(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x22c(%rax)
jmp 0x11c0a
leaq -0x198(%rbp), %rdi
callq 0x62f0
jmp 0x11c69
movq -0x220(%rbp), %rax
movq 0x208(%rax), %rsi
movl -0x98(%rbp), %edx
leaq -0x218(%rbp), %rdi
callq 0x1b3f0
movq -0x220(%rbp), %rdi
addq $0x8, %rdi
movslq -0x98(%rbp), %rax
imulq $0x78, %rax, %rax
addq %rax, %rdi
leaq -0x218(%rbp), %rsi
callq 0xd230
leaq -0x218(%rbp), %rdi
callq 0x61d0
jmp 0x11c6b
jmp 0x11c6d
jmp 0x11c6f
movl -0x98(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x98(%rbp)
jmp 0x119be
addq $0x260, %rsp            # imm = 0x260
popq %rbp
retq
movq -0x90(%rbp), %rdi
callq 0x3480
nopl (%rax,%rax)