// File: /workspace/github_cpp_makefile_star2_O2/ys1998[P]spsim/src/queues.cpp
// Function: AddressQueue::MEMissue()
std::tuple<Instruction, int ,int> AddressQueue::MEMissue(){
	for(size_t i=0; i < _q.size(); ++i){
		Instruction temp = _q[i];
		auto type = temp.type();

		if(temp.is_valid() && (std::get<0>(type) == OPCODE["lw"])){
			auto regs = temp.physical_regs();
			if(!*(b + std::get<1>(regs)) && (_addr[i] != -2) && (_addr[i] != -1) && findswaddr(i)){
				_q.erase(_q.begin() + i);
				int addr = _addr[i];
				_addr.erase(_addr.begin() + i);
				return std::make_tuple(temp, addr , i);
			}
		}
		if(temp.is_valid() && (std::get<0>(type) == OPCODE["sw"])  && findswaddr(i) && no_notcalculated_branch_above(temp))
		{
			auto regs = temp.physical_regs();
			if(!*(b + std::get<1>(regs)) && (_addr[i] != -2) && (_addr[i] != -1)){
				if (!*(b + std::get<0>(regs))){
					_q.erase(_q.begin() + i);
					int addr = _addr[i];
					_addr.erase(_addr.begin() + i);
					return std::make_tuple(temp, addr , i);
				}
			}
            else {
                break;
            }
		}
	}
	return std::make_tuple(Instruction(), -1, -1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x288, %rsp            # imm = 0x288
movq %rsi, %r13
movq %rdi, 0x10(%rsp)
leaq 0x10(%rsi), %rax
movq %rax, 0x38(%rsp)
leaq 0x58(%rsi), %rax
movq %rax, 0x18(%rsp)
leaq 0x68(%rsi), %rax
movq %rax, 0x8(%rsp)
leaq 0x160(%rsp), %r14
xorl %r15d, %r15d
leaq 0x110(%rsp), %r12
leaq 0x60(%rsp), %rbp
movq %r13, %rdi
callq 0x5968
cmpq %rax, %r15
jae 0xd340
movq 0x38(%rsp), %rdi
movq %r15, %rsi
callq 0x5e92
movq %r12, %rdi
movq %rax, %rsi
callq 0x49ba
leaq 0x20(%rsp), %rdi
movq %r12, %rsi
callq 0x7c7c
cmpl $-0x1, 0x114(%rsp)
je 0xd236
cmpl $-0x1, 0x110(%rsp)
je 0xd236
movl 0x24(%rsp), %ebx
movq %rbp, %rdi
leaq 0x2ebb(%rip), %rsi      # 0x1006d
leaq 0x40(%rsp), %rdx
callq 0x4860
leaq 0xa045(%rip), %rdi      # 0x17208
movq %rbp, %rsi
callq 0x47fa
movl (%rax), %r14d
movq %rbp, %rdi
callq 0x3100
cmpl %r14d, %ebx
leaq 0x160(%rsp), %r14
jne 0xd236
leaq 0x28(%rsp), %rdi
movq %r12, %rsi
callq 0x7c52
movq 0x50(%r13), %rax
movslq 0x30(%rsp), %rcx
cmpb $0x0, (%rax,%rcx)
jne 0xd236
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x872a
cmpl $-0x2, (%rax)
je 0xd236
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x872a
cmpl $-0x1, (%rax)
je 0xd236
movq %r13, %rdi
movl %r15d, %esi
callq 0xd598
testb %al, %al
jne 0xd45b
cmpl $-0x1, 0x114(%rsp)
je 0xd328
cmpl $-0x1, 0x110(%rsp)
je 0xd328
movl 0x24(%rsp), %ebx
movq %rbp, %rdi
leaq 0x2dbd(%rip), %rsi      # 0x1001d
leaq 0x40(%rsp), %rdx
callq 0x4860
leaq 0x9f97(%rip), %rdi      # 0x17208
movq %rbp, %rsi
callq 0x47fa
cmpl (%rax), %ebx
jne 0xd320
movq %r13, %rdi
movl %r15d, %esi
callq 0xd598
testb %al, %al
je 0xd320
leaq 0x188(%rsp), %rdi
movq %r12, %rsi
callq 0x49ba
movq %r13, %rdi
leaq 0x188(%rsp), %rsi
callq 0xd6a6
movl %eax, %ebx
leaq 0x1d8(%rsp), %rdi
callq 0x3100
movq %rbp, %rdi
callq 0x3100
testb %bl, %bl
je 0xd328
leaq 0x28(%rsp), %rdi
movq %r12, %rsi
callq 0x7c52
movq 0x50(%r13), %rax
movslq 0x30(%rsp), %rcx
cmpb $0x0, (%rax,%rcx)
jne 0xd338
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x872a
cmpl $-0x2, (%rax)
je 0xd338
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x872a
cmpl $-0x1, (%rax)
je 0xd338
movq 0x50(%r13), %rax
movslq 0x34(%rsp), %rcx
cmpb $0x0, (%rax,%rcx)
jne 0xd328
jmp 0xd392
movq %rbp, %rdi
callq 0x3100
movq %r14, %rdi
callq 0x3100
incq %r15
jmp 0xd152
movq %r14, %rdi
callq 0x3100
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
callq 0x6dd2
leaq 0x110(%rsp), %rdx
orl $-0x1, (%rdx)
leaq 0x40(%rsp), %rcx
orl $-0x1, (%rcx)
movq 0x10(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0xdcbc
leaq 0xb0(%rsp), %rdi
callq 0x3100
movq %r15, %rax
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movups 0x10(%r13), %xmm0
leaq 0x40(%rsp), %rsi
movaps %xmm0, (%rsi)
movups 0x20(%r13), %xmm0
movaps %xmm0, 0x10(%rsi)
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rdx
callq 0x59b0
movaps (%rbx), %xmm0
movaps 0x10(%rbx), %xmm1
leaq 0x220(%rsp), %rdx
movaps %xmm0, (%rdx)
movaps %xmm1, 0x10(%rdx)
leaq 0xf0(%rsp), %rdi
movq %r13, %rsi
callq 0x5978
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x872a
movl (%rax), %ebp
movups 0x68(%r13), %xmm0
leaq 0x40(%rsp), %rsi
movaps %xmm0, (%rsi)
movups 0x78(%r13), %xmm0
movaps %xmm0, 0x10(%rsi)
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rdx
callq 0x8749
movaps (%rbx), %xmm0
movaps 0x10(%rbx), %xmm1
leaq 0x200(%rsp), %rdx
movaps %xmm0, (%rdx)
movaps %xmm1, 0x10(%rdx)
leaq 0xf0(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0xda6c
movq %r15, 0x60(%rsp)
movl %ebp, 0x68(%rsp)
leaq 0x110(%rsp), %rsi
leaq 0x70(%rsp), %rdi
callq 0x49ba
jmp 0xd51f
movups 0x10(%r13), %xmm0
leaq 0x40(%rsp), %rsi
movaps %xmm0, (%rsi)
movups 0x20(%r13), %xmm0
movaps %xmm0, 0x10(%rsi)
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rdx
callq 0x59b0
movaps (%rbx), %xmm0
movaps 0x10(%rbx), %xmm1
leaq 0x260(%rsp), %rdx
movaps %xmm0, (%rdx)
movaps %xmm1, 0x10(%rdx)
leaq 0xf0(%rsp), %rdi
movq %r13, %rsi
callq 0x5978
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x872a
movl (%rax), %ebp
movups 0x68(%r13), %xmm0
leaq 0x40(%rsp), %rsi
movaps %xmm0, (%rsi)
movups 0x78(%r13), %xmm0
movaps %xmm0, 0x10(%rsi)
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rdx
callq 0x8749
movaps (%rbx), %xmm0
movaps 0x10(%rbx), %xmm1
leaq 0x240(%rsp), %rdx
movaps %xmm0, (%rdx)
movaps %xmm1, 0x10(%rdx)
leaq 0xf0(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0xda6c
movq %r15, 0x60(%rsp)
movl %ebp, 0x68(%rsp)
leaq 0x110(%rsp), %rsi
leaq 0x70(%rsp), %rdi
callq 0x49ba
leaq 0x60(%rsp), %rsi
movq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0xdaa4
leaq 0xc0(%rsp), %rdi
callq 0x3100
movq %r14, %rdi
jmp 0xd378
jmp 0xd585
jmp 0xd585
jmp 0xd585
jmp 0xd585
jmp 0xd585
jmp 0xd585
jmp 0xd585
movq %rax, %rbx
leaq 0x1d8(%rsp), %rdi
callq 0x3100
jmp 0xd571
jmp 0xd585
jmp 0xd585
jmp 0xd56e
jmp 0xd585
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x3100
leaq 0x160(%rsp), %r14
jmp 0xd588
movq %rax, %rbx
movq %r14, %rdi
callq 0x3100
movq %rbx, %rdi
callq 0x3320