// File: /workspace/github_cpp_makefile_star2_O3/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 $0x1d8, %rsp            # imm = 0x1D8
movq %rsi, %r13
leaq 0x58(%rsi), %rax
movq %rax, 0xa8(%rsp)
leaq 0x30(%rsp), %r12
leaq 0x90(%rsp), %rbx
leaq 0x8(%rdi), %rax
movq %rax, 0x10(%rsp)
movq %rdi, 0x8(%rsp)
leaq 0x68(%rdi), %rax
movq %rax, 0x18(%rsp)
xorl %r15d, %r15d
movabsq $-0x1111111111111111, %rsi # imm = 0xEEEEEEEEEEEEEEEF
movq 0x48(%r13), %rcx
movq 0x28(%r13), %rax
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq $0x1, %rcx
adcq $-0x1, %rdx
movq 0x30(%r13), %rcx
subq 0x38(%r13), %rcx
sarq $0x3, %rcx
imulq %rsi, %rcx
leaq (%rcx,%rdx,4), %rcx
movq 0x10(%r13), %r14
movq 0x20(%r13), %rdx
subq %r14, %rdx
sarq $0x3, %rdx
imulq %rsi, %rdx
addq %rcx, %rdx
cmpq %rdx, %r15
jae 0x136c6
movq %r14, %rcx
subq 0x18(%r13), %rcx
sarq $0x3, %rcx
imulq %rsi, %rcx
addq %r15, %rcx
js 0x12f3f
cmpq $0x3, %rcx
ja 0x12f48
imulq $0x78, %r15, %rax
addq %rax, %r14
jmp 0x12f62
movq %rcx, %rdx
sarq $0x2, %rdx
jmp 0x12f4f
movq %rcx, %rdx
shrq $0x2, %rdx
leaq (,%rdx,4), %rsi
subq %rsi, %rcx
imulq $0x78, %rcx, %r14
addq (%rax,%rdx,8), %r14
movl $0xa, %ecx
leaq 0xc8(%rsp), %rbp
movq %rbp, %rdi
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x128(%rsp), %rax
movq %rax, 0x118(%rsp)
movq 0x50(%r14), %rsi
movq 0x58(%r14), %rdx
addq %rsi, %rdx
leaq 0x118(%rsp), %rdi
callq 0x5274
movq 0x70(%r14), %rax
movq %rax, 0x138(%rsp)
leaq 0xb0(%rsp), %rdi
movq %rbp, %rsi
callq 0xa8b8
cmpl $-0x1, 0xcc(%rsp)
je 0x13119
cmpl $-0x1, 0xc8(%rsp)
je 0x13119
movl 0xb4(%rsp), %ebp
leaq 0x30(%rsp), %rax
movq %rax, 0x20(%rsp)
leaq 0x20(%rsp), %r14
movq %r14, %rdi
leaq 0x3075(%rip), %rsi      # 0x1606d
leaq 0x3070(%rip), %rdx      # 0x1606f
callq 0x530a
leaq 0x9205(%rip), %rdi      # 0x1c210
movq %r14, %rsi
callq 0x5136
movl (%rax), %r14d
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x13032
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3200
cmpl %r14d, %ebp
jne 0x13119
leaq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0xa88e
movabsq $-0x1111111111111111, %r14 # imm = 0xEEEEEEEEEEEEEEEF
leaq 0x20(%rsp), %rbp
movq 0x50(%r13), %rax
movslq 0xc0(%rsp), %rcx
cmpb $0x0, (%rax,%rcx)
jne 0x13119
movq 0x68(%r13), %rcx
movq 0x80(%r13), %rdx
movq %rcx, %rax
subq 0x70(%r13), %rax
sarq $0x2, %rax
addq %r15, %rax
js 0x130a3
cmpq $0x80, %rax
jae 0x130ac
movl (%rcx,%r15,4), %eax
cmpl $-0x2, %eax
jne 0x130cc
jmp 0x13119
movq %rax, %rcx
sarq $0x7, %rcx
jmp 0x130b3
movq %rax, %rcx
shrq $0x7, %rcx
movq (%rdx,%rcx,8), %rdx
movl %eax, %esi
andl $0x7f, %esi
cmpl $-0x2, (%rdx,%rsi,4)
je 0x13119
shlq $0x7, %rcx
subq %rcx, %rax
movl (%rdx,%rax,4), %eax
cmpl $-0x1, %eax
je 0x13119
movq %r13, %rdi
movl %r15d, %esi
callq 0x137ec
testb %al, %al
je 0x13119
movq 0x10(%r13), %rcx
movq %rcx, %rdx
subq 0x18(%r13), %rdx
movq 0x28(%r13), %rax
sarq $0x3, %rdx
imulq %r14, %rdx
addq %r15, %rdx
js 0x1333e
cmpq $0x3, %rdx
ja 0x13358
imulq $0x78, %r15, %rdx
addq %rdx, %rcx
movq (%rax), %rsi
jmp 0x13374
xorl %ebp, %ebp
cmpl $-0x1, 0xcc(%rsp)
je 0x13690
cmpl $-0x1, 0xc8(%rsp)
je 0x13690
movl 0xb4(%rsp), %ebp
movq %r12, 0x20(%rsp)
leaq 0x20(%rsp), %r14
movq %r14, %rdi
leaq 0x2ecb(%rip), %rsi      # 0x1601d
leaq 0x2ec6(%rip), %rdx      # 0x1601f
callq 0x530a
leaq 0x90ab(%rip), %rdi      # 0x1c210
movq %r14, %rsi
callq 0x5136
cmpl (%rax), %ebp
jne 0x1321d
movq %r13, %rdi
movl %r15d, %esi
callq 0x137ec
testb %al, %al
je 0x13225
movl $0xa, %ecx
leaq 0x160(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x1c0(%rsp), %rax
movq %rax, 0x1b0(%rsp)
movq 0x118(%rsp), %rsi
movq 0x120(%rsp), %rdx
addq %rsi, %rdx
leaq 0x1b0(%rsp), %rdi
callq 0x5274
movq 0x138(%rsp), %rax
movq %rax, 0x1d0(%rsp)
movq %r13, %rdi
leaq 0x160(%rsp), %rsi
callq 0x13a3a
movl %eax, %r14d
movq 0x1b0(%rsp), %rdi
leaq 0x1c0(%rsp), %rax
cmpq %rax, %rdi
movq %r12, %rbp
je 0x1322b
movq 0x1c0(%rsp), %rsi
incq %rsi
callq 0x3200
jmp 0x1322b
xorl %r14d, %r14d
movq %r12, %rbp
jmp 0x1322b
movq %r12, %rbp
xorl %r14d, %r14d
movq 0x20(%rsp), %rdi
cmpq %rbp, %rdi
je 0x13242
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3200
xorl %ebp, %ebp
testb %r14b, %r14b
je 0x13690
leaq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0xa88e
movq 0x50(%r13), %rcx
movslq 0xc0(%rsp), %rdx
movl $0x2, %eax
cmpb $0x0, (%rcx,%rdx)
jne 0x1368e
movq 0x68(%r13), %rsi
movq 0x80(%r13), %rdi
movq %rsi, %rdx
subq 0x70(%r13), %rdx
sarq $0x2, %rdx
addq %r15, %rdx
js 0x132af
cmpq $0x80, %rdx
jae 0x132b8
movl (%rsi,%r15,4), %edx
cmpl $-0x2, %edx
jne 0x132df
jmp 0x1368e
movq %rdx, %rsi
sarq $0x7, %rsi
jmp 0x132bf
movq %rdx, %rsi
shrq $0x7, %rsi
movq (%rdi,%rsi,8), %rdi
movl %edx, %r8d
andl $0x7f, %r8d
cmpl $-0x2, (%rdi,%r8,4)
je 0x1368e
shlq $0x7, %rsi
subq %rsi, %rdx
movl (%rdi,%rdx,4), %edx
cmpl $-0x1, %edx
je 0x1368e
movslq 0xc4(%rsp), %rax
cmpb $0x0, (%rcx,%rax)
jne 0x13690
movq 0x10(%r13), %rcx
movq %rcx, %rdi
subq 0x18(%r13), %rdi
movq 0x28(%r13), %rax
sarq $0x3, %rdi
movabsq $-0x1111111111111111, %rsi # imm = 0xEEEEEEEEEEEEEEEF
imulq %rsi, %rdi
addq %r15, %rdi
js 0x13347
cmpq $0x3, %rdi
leaq 0x20(%rsp), %rdx
ja 0x134f6
imulq $0x78, %r15, %rsi
addq %rsi, %rcx
movq (%rax), %rsi
jmp 0x13512
movq %rdx, %rcx
sarq $0x2, %rcx
jmp 0x1335f
movq %rdi, %rcx
sarq $0x2, %rcx
leaq 0x20(%rsp), %rdx
jmp 0x134fd
movq %rdx, %rcx
shrq $0x2, %rcx
leaq (%rax,%rcx,8), %rax
movq (%rax), %rsi
shlq $0x2, %rcx
subq %rcx, %rdx
imulq $0x78, %rdx, %rcx
addq %rsi, %rcx
movq %rcx, 0x20(%rsp)
movq %rsi, 0x28(%rsp)
addq $0x1e0, %rsi            # imm = 0x1E0
movq %rsi, 0x30(%rsp)
movq %rax, 0x38(%rsp)
leaq 0x140(%rsp), %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x6972
movq 0x68(%r13), %rdx
movq 0x80(%r13), %rax
movq %rdx, %rcx
subq 0x70(%r13), %rcx
sarq $0x2, %rcx
addq %r15, %rcx
js 0x133cf
cmpq $0x7f, %rcx
ja 0x133d8
leaq (%rdx,%r15,4), %rsi
movq (%rax), %rdx
movq %rsi, %rcx
jmp 0x133fa
movq %rcx, %rdi
sarq $0x7, %rdi
jmp 0x133df
movq %rcx, %rdi
shrq $0x7, %rdi
leaq (%rax,%rdi,8), %rax
movq (%rax), %rdx
movl %ecx, %esi
andl $0x7f, %esi
leaq (%rdx,%rsi,4), %rsi
shlq $0x7, %rdi
subq %rdi, %rcx
leaq (%rdx,%rcx,4), %rcx
movl (%rsi), %ebp
movq %rcx, 0x20(%rsp)
movq %rdx, 0x28(%rsp)
addq $0x200, %rdx            # imm = 0x200
movq %rdx, 0x30(%rsp)
movq %rax, 0x38(%rsp)
leaq 0x140(%rsp), %rdi
movq 0xa8(%rsp), %rsi
leaq 0x20(%rsp), %rdx
callq 0x14528
movq %r15, 0x20(%rsp)
movl %ebp, 0x28(%rsp)
movl $0xa, %ecx
movq %r12, %r14
movq %r12, %rdi
leaq 0xc8(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %rbx, %rbp
movq %rbx, 0x80(%rsp)
movq 0x118(%rsp), %rsi
movq 0x120(%rsp), %rdx
addq %rsi, %rdx
leaq 0x80(%rsp), %rdi
callq 0x5274
movq 0x138(%rsp), %rax
movq %rax, 0xa0(%rsp)
movl 0x20(%rsp), %ecx
movq 0x8(%rsp), %rdx
movl %ecx, (%rdx)
movl 0x28(%rsp), %ecx
movl %ecx, 0x4(%rdx)
movl $0xa, %ecx
movq 0x10(%rsp), %rdi
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq 0x18(%rsp), %rsi
movq %rsi, 0x58(%rdx)
movq 0x80(%rsp), %rcx
cmpq %rbp, %rcx
je 0x134d5
movq %rcx, 0x58(%rdx)
movq 0x90(%rsp), %rcx
movq %rcx, 0x68(%rdx)
jmp 0x134dc
movups (%rbp), %xmm0
movups %xmm0, (%rsi)
movq 0x88(%rsp), %rcx
movq %rcx, 0x60(%rdx)
movq %rax, 0x78(%rdx)
movl $0x1, %ebp
jmp 0x13690
movq %rdi, %rcx
shrq $0x2, %rcx
leaq (%rax,%rcx,8), %rax
movq (%rax), %rsi
shlq $0x2, %rcx
subq %rcx, %rdi
imulq $0x78, %rdi, %rcx
addq %rsi, %rcx
movq %rcx, 0x20(%rsp)
movq %rsi, 0x28(%rsp)
addq $0x1e0, %rsi            # imm = 0x1E0
movq %rsi, 0x30(%rsp)
movq %rax, 0x38(%rsp)
leaq 0x140(%rsp), %rdi
movq %r13, %rsi
callq 0x6972
movq 0x68(%r13), %rdx
movq 0x80(%r13), %rax
movq %rdx, %rcx
subq 0x70(%r13), %rcx
sarq $0x2, %rcx
addq %r15, %rcx
js 0x1356a
cmpq $0x7f, %rcx
ja 0x13573
leaq (%rdx,%r15,4), %rsi
movq (%rax), %rdx
movq %rsi, %rcx
jmp 0x13595
movq %rcx, %rdi
sarq $0x7, %rdi
jmp 0x1357a
movq %rcx, %rdi
shrq $0x7, %rdi
leaq (%rax,%rdi,8), %rax
movq (%rax), %rdx
movl %ecx, %esi
andl $0x7f, %esi
leaq (%rdx,%rsi,4), %rsi
shlq $0x7, %rdi
subq %rdi, %rcx
leaq (%rdx,%rcx,4), %rcx
movl (%rsi), %ebp
movq %rcx, 0x20(%rsp)
movq %rdx, 0x28(%rsp)
addq $0x200, %rdx            # imm = 0x200
movq %rdx, 0x30(%rsp)
movq %rax, 0x38(%rsp)
leaq 0x140(%rsp), %rdi
movq 0xa8(%rsp), %rsi
leaq 0x20(%rsp), %rdx
callq 0x14528
movq %r15, 0x20(%rsp)
movl %ebp, 0x28(%rsp)
movl $0xa, %ecx
leaq 0x30(%rsp), %rbp
movq %rbp, %rdi
leaq 0xc8(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %rbx, %r14
movq %rbx, 0x80(%rsp)
movq 0x118(%rsp), %rsi
movq 0x120(%rsp), %rdx
addq %rsi, %rdx
leaq 0x80(%rsp), %rdi
callq 0x5274
movq 0x138(%rsp), %rax
movq %rax, 0xa0(%rsp)
movl 0x20(%rsp), %ecx
movq 0x8(%rsp), %rdx
movl %ecx, (%rdx)
movl 0x28(%rsp), %ecx
movl %ecx, 0x4(%rdx)
movl $0xa, %ecx
movq 0x10(%rsp), %rdi
movq %rbp, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq 0x18(%rsp), %rsi
movq %rsi, 0x58(%rdx)
movq 0x80(%rsp), %rcx
cmpq %r14, %rcx
je 0x13672
movq %rcx, 0x58(%rdx)
movq 0x90(%rsp), %rcx
movq %rcx, 0x68(%rdx)
jmp 0x13679
movups (%r14), %xmm0
movups %xmm0, (%rsi)
movq 0x88(%rsp), %rcx
movq %rcx, 0x60(%rdx)
movq %rax, 0x78(%rdx)
movl $0x1, %eax
movl %eax, %ebp
movq 0x118(%rsp), %rdi
leaq 0x128(%rsp), %rax
cmpq %rax, %rdi
je 0x136b5
movq 0x128(%rsp), %rsi
incq %rsi
callq 0x3200
testl %ebp, %ebp
jne 0x136c1
incq %r15
jmp 0x12ec5
cmpl $0x2, %ebp
jne 0x13736
leaq 0x20(%rsp), %r14
movq %r14, %rdi
callq 0x7a5a
movq 0x8(%rsp), %rdx
movq $-0x1, (%rdx)
movl $0xa, %ecx
movq 0x10(%rsp), %rdi
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq 0x18(%rsp), %rcx
movq %rcx, 0x58(%rdx)
movq 0x50(%r14), %rax
leaq 0x80(%rsp), %rsi
cmpq %rsi, %rax
je 0x1371b
movq %rax, 0x58(%rdx)
movq 0x80(%rsp), %rax
movq %rax, 0x68(%rdx)
jmp 0x13721
movups (%rsi), %xmm0
movups %xmm0, (%rcx)
movq 0x78(%rsp), %rax
movq %rax, 0x60(%rdx)
movq 0x90(%rsp), %rax
movq %rax, 0x78(%rdx)
movq 0x8(%rsp), %rax
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x137bb
jmp 0x137bb
jmp 0x137bb
jmp 0x137bb
jmp 0x137bb
jmp 0x137bb
movq %rax, %rbx
movq 0x1b0(%rsp), %rdi
leaq 0x1c0(%rsp), %rax
cmpq %rax, %rdi
je 0x137a2
movq 0x1c0(%rsp), %rsi
incq %rsi
callq 0x3200
jmp 0x137a2
jmp 0x137bb
jmp 0x137bb
jmp 0x137bb
movq %rax, %rbx
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
jne 0x137ac
jmp 0x137be
jmp 0x137bb
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x137be
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3200
jmp 0x137be
movq %rax, %rbx
movq 0x118(%rsp), %rdi
leaq 0x128(%rsp), %rax
cmpq %rax, %rdi
je 0x137e3
movq 0x128(%rsp), %rsi
incq %rsi
callq 0x3200
movq %rbx, %rdi
callq 0x3340
nop