// File: /workspace/github_cpp_makefile_star2_O1/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 $0x228, %rsp            # imm = 0x228
movq %rsi, %r12
leaq 0x58(%rsi), %rax
movq %rax, 0xb0(%rsp)
leaq 0x8(%rdi), %rax
movq %rax, 0x10(%rsp)
movq %rdi, 0x20(%rsp)
leaq 0x68(%rdi), %rax
movq %rax, 0x18(%rsp)
leaq 0xe0(%rsp), %rax
movq %rax, 0x110(%rsp)
movq $0x0, 0x8(%rsp)
movabsq $-0x1111111111111111, %r14 # imm = 0xEEEEEEEEEEEEEEEF
xorl %ebx, %ebx
xorl %r13d, %r13d
movq 0x48(%r12), %rcx
movq 0x28(%r12), %rax
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq $0x1, %rcx
adcq $-0x1, %rdx
movq 0x30(%r12), %rcx
subq 0x38(%r12), %rcx
sarq $0x3, %rcx
imulq %r14, %rcx
leaq (%rcx,%rdx,4), %rcx
movq 0x10(%r12), %rbp
movq 0x20(%r12), %rdx
subq %rbp, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
addq %rcx, %rdx
cmpq %rdx, %r13
jae 0x1410a
movq %rbp, %rcx
subq 0x18(%r12), %rcx
sarq $0x3, %rcx
imulq %r14, %rcx
leaq (%rcx,%r13), %rdx
cmpq $0x3, %rdx
ja 0x13777
addq %rbx, %rbp
jmp 0x137ab
movq %rdx, %rsi
shrq $0x2, %rsi
movq %rsi, %rdi
movabsq $-0x4000000000000000, %r8 # imm = 0xC000000000000000
orq %r8, %rdi
testq %rdx, %rdx
cmovgq %rsi, %rdi
leaq (,%rdi,4), %rdx
subq %rdx, %rcx
addq %r13, %rcx
imulq $0x78, %rcx, %rbp
addq (%rax,%rdi,8), %rbp
movl $0xa, %ecx
leaq 0x118(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x178(%rsp), %rax
movq %rax, 0x168(%rsp)
movq 0x50(%rbp), %rsi
movq 0x58(%rbp), %rdx
addq %rsi, %rdx
leaq 0x168(%rsp), %rdi
callq 0x52b6
movq 0x70(%rbp), %rax
movq %rax, 0x188(%rsp)
leaq 0xb8(%rsp), %rdi
movq %r14, %rsi
callq 0xac8c
cmpl $-0x1, 0x11c(%rsp)
setne %al
cmpl $-0x1, 0x118(%rsp)
setne %bpl
andb %al, %bpl
cmpb $0x1, %bpl
jne 0x13873
movl 0xbc(%rsp), %r14d
leaq 0x100(%rsp), %rax
movq %rax, 0xf0(%rsp)
leaq 0xf0(%rsp), %r15
movq %r15, %rdi
leaq 0x381e(%rip), %rsi      # 0x1706d
leaq 0x3819(%rip), %rdx      # 0x1706f
callq 0x5346
leaq 0x99ae(%rip), %rdi      # 0x1d210
movq %r15, %rsi
callq 0x517a
cmpl (%rax), %r14d
sete %r14b
jmp 0x13876
xorl %r14d, %r14d
testb %bpl, %bpl
je 0x138a0
movq 0xf0(%rsp), %rdi
leaq 0x100(%rsp), %rax
cmpq %rax, %rdi
je 0x138a0
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x3200
testb %r14b, %r14b
je 0x139d3
leaq 0xc0(%rsp), %rdi
leaq 0x118(%rsp), %rsi
callq 0xac5a
movabsq $-0x1111111111111111, %r14 # imm = 0xEEEEEEEEEEEEEEEF
movq 0x50(%r12), %rax
movslq 0xc8(%rsp), %rcx
cmpb $0x0, (%rax,%rcx)
jne 0x139d3
movq 0x68(%r12), %rcx
movq %rcx, %rax
subq 0x70(%r12), %rax
sarq $0x2, %rax
addq %r13, %rax
cmpq $0x7f, %rax
ja 0x13903
movq 0x8(%rsp), %rdx
addq %rcx, %rdx
jmp 0x1393e
movq %rax, %rdx
shrq $0x7, %rdx
movq %rdx, %rsi
movabsq $-0x200000000000000, %rdi # imm = 0xFE00000000000000
orq %rdi, %rsi
testq %rax, %rax
cmovgq %rdx, %rsi
movq 0x80(%r12), %rdi
movq %rsi, %r8
shlq $0x7, %r8
movq %rax, %rdx
subq %r8, %rdx
shlq $0x2, %rdx
addq (%rdi,%rsi,8), %rdx
cmpl $-0x2, (%rdx)
je 0x139d3
cmpq $0x7f, %rax
ja 0x13954
addq 0x8(%rsp), %rcx
jmp 0x1398f
movq %rax, %rcx
shrq $0x7, %rcx
movq %rcx, %rdx
movabsq $-0x200000000000000, %rsi # imm = 0xFE00000000000000
orq %rsi, %rdx
testq %rax, %rax
cmovgq %rcx, %rdx
movq 0x80(%r12), %rcx
movq %rdx, %rsi
shlq $0x7, %rsi
subq %rsi, %rax
shlq $0x2, %rax
addq (%rcx,%rdx,8), %rax
movq %rax, %rcx
cmpl $-0x1, (%rcx)
je 0x139d3
movq %r12, %rdi
movl %r13d, %esi
callq 0x1427a
testb %al, %al
je 0x139d3
movq 0x10(%r12), %rcx
movq 0x28(%r12), %rax
movq %rcx, %rdx
subq 0x18(%r12), %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
leaq (%rdx,%r13), %rsi
cmpq $0x3, %rsi
ja 0x13c95
addq %rbx, %rcx
jmp 0x13cc8
cmpl $-0x1, 0x11c(%rsp)
setne %al
cmpl $-0x1, 0x118(%rsp)
setne %r14b
andb %al, %r14b
cmpb $0x1, %r14b
jne 0x13abc
movl 0xbc(%rsp), %ebp
leaq 0xe0(%rsp), %rax
movq %rax, 0xd0(%rsp)
leaq 0xd0(%rsp), %r15
movq %r15, %rdi
leaq 0x35fd(%rip), %rsi      # 0x1701d
leaq 0x35f8(%rip), %rdx      # 0x1701f
callq 0x5346
leaq 0x97dd(%rip), %rdi      # 0x1d210
movq %r15, %rsi
callq 0x517a
cmpl (%rax), %ebp
jne 0x13abc
movq %r12, %rdi
movl %r13d, %esi
callq 0x1427a
testb %al, %al
je 0x13abc
movl $0xa, %ecx
leaq 0x1b0(%rsp), %rdi
leaq 0x118(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x210(%rsp), %rax
movq %rax, 0x200(%rsp)
movq 0x168(%rsp), %rsi
movq 0x170(%rsp), %rdx
addq %rsi, %rdx
leaq 0x200(%rsp), %rdi
callq 0x52b6
movq 0x188(%rsp), %rax
movq %rax, 0x220(%rsp)
movq %r12, %rdi
leaq 0x1b0(%rsp), %rsi
callq 0x144ec
movl %eax, %ebp
movb $0x1, %al
jmp 0x13ac0
xorl %eax, %eax
xorl %ebp, %ebp
testb %al, %al
je 0x13ae9
movq 0x200(%rsp), %rdi
leaq 0x210(%rsp), %rax
cmpq %rax, %rdi
je 0x13ae9
movq 0x210(%rsp), %rsi
incq %rsi
callq 0x3200
testb %r14b, %r14b
movabsq $-0x1111111111111111, %r14 # imm = 0xEEEEEEEEEEEEEEEF
je 0x13b1d
movq 0xd0(%rsp), %rdi
leaq 0xe0(%rsp), %rax
cmpq %rax, %rdi
je 0x13b1d
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x3200
testb %bpl, %bpl
je 0x13c54
leaq 0xc0(%rsp), %rdi
leaq 0x118(%rsp), %rsi
callq 0xac5a
movq 0x50(%r12), %rax
movslq 0xc8(%rsp), %rcx
cmpb $0x0, (%rax,%rcx)
jne 0x13c49
movq 0x68(%r12), %rdx
movq %rdx, %rcx
subq 0x70(%r12), %rcx
sarq $0x2, %rcx
addq %r13, %rcx
cmpq $0x7f, %rcx
ja 0x13b76
movq 0x8(%rsp), %rsi
addq %rdx, %rsi
jmp 0x13bb1
movq %rcx, %rsi
shrq $0x7, %rsi
movq %rsi, %rdi
movabsq $-0x200000000000000, %r8 # imm = 0xFE00000000000000
orq %r8, %rdi
testq %rcx, %rcx
cmovgq %rsi, %rdi
movq 0x80(%r12), %r8
movq %rdi, %r9
shlq $0x7, %r9
movq %rcx, %rsi
subq %r9, %rsi
shlq $0x2, %rsi
addq (%r8,%rdi,8), %rsi
cmpl $-0x2, (%rsi)
je 0x13c49
cmpq $0x7f, %rcx
ja 0x13bc7
addq 0x8(%rsp), %rdx
jmp 0x13c02
movq %rcx, %rdx
shrq $0x7, %rdx
movq %rdx, %rsi
movabsq $-0x200000000000000, %rdi # imm = 0xFE00000000000000
orq %rdi, %rsi
testq %rcx, %rcx
cmovgq %rdx, %rsi
movq 0x80(%r12), %rdx
movq %rsi, %rdi
shlq $0x7, %rdi
subq %rdi, %rcx
shlq $0x2, %rcx
addq (%rdx,%rsi,8), %rcx
movq %rcx, %rdx
xorl %ebp, %ebp
cmpl $-0x1, (%rdx)
je 0x13c49
movslq 0xcc(%rsp), %rdx
movb $0x1, %cl
cmpb $0x0, (%rax,%rdx)
jne 0x13c50
movq 0x10(%r12), %rcx
movq 0x28(%r12), %rax
movq %rcx, %rdx
subq 0x18(%r12), %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
leaq (%rdx,%r13), %rsi
cmpq $0x3, %rsi
ja 0x13e8b
addq %rbx, %rcx
jmp 0x13ebe
xorl %ecx, %ecx
movl $0x2, %ebp
testb %cl, %cl
je 0x13c56
xorl %ebp, %ebp
movq 0x168(%rsp), %rdi
leaq 0x178(%rsp), %rax
cmpq %rax, %rdi
je 0x13c7b
movq 0x178(%rsp), %rsi
incq %rsi
callq 0x3200
incq %r13
addq $0x78, %rbx
addq $0x4, 0x8(%rsp)
testl %ebp, %ebp
je 0x13705
jmp 0x1410f
movq %rsi, %rcx
shrq $0x2, %rcx
movq %rcx, %rdi
movabsq $-0x4000000000000000, %r8 # imm = 0xC000000000000000
orq %r8, %rdi
testq %rsi, %rsi
cmovgq %rcx, %rdi
leaq (%rax,%rdi,8), %rax
shlq $0x2, %rdi
subq %rdi, %rdx
addq %r13, %rdx
imulq $0x78, %rdx, %rcx
addq (%rax), %rcx
leaq 0x190(%rsp), %r14
movq %rcx, 0x28(%rsp)
movq (%rax), %rcx
movq %rcx, 0x30(%rsp)
addq $0x1e0, %rcx            # imm = 0x1E0
movq %rcx, 0x38(%rsp)
movq %rax, 0x40(%rsp)
movq %r14, %rdi
movq %r12, %rsi
leaq 0x28(%rsp), %rdx
callq 0x6a0a
movq 0x68(%r12), %rcx
movq %rcx, %rax
subq 0x70(%r12), %rax
sarq $0x2, %rax
addq %r13, %rax
cmpq $0x7f, %rax
ja 0x13d22
movq 0x8(%rsp), %rdx
addq %rcx, %rdx
jmp 0x13d5d
movq %rax, %rdx
shrq $0x7, %rdx
movq %rdx, %rsi
movabsq $-0x200000000000000, %rdi # imm = 0xFE00000000000000
orq %rdi, %rsi
testq %rax, %rax
cmovgq %rdx, %rsi
movq 0x80(%r12), %rdi
movq %rsi, %r8
shlq $0x7, %r8
movq %rax, %rdx
subq %r8, %rdx
shlq $0x2, %rdx
addq (%rdi,%rsi,8), %rdx
movq 0x80(%r12), %rsi
cmpq $0x7f, %rax
ja 0x13d72
addq 0x8(%rsp), %rcx
jmp 0x13da5
movq %rax, %rcx
shrq $0x7, %rcx
movq %rcx, %rdi
movabsq $-0x200000000000000, %r8 # imm = 0xFE00000000000000
orq %r8, %rdi
testq %rax, %rax
cmovgq %rcx, %rdi
leaq (%rsi,%rdi,8), %rsi
shlq $0x7, %rdi
subq %rdi, %rax
shlq $0x2, %rax
addq (%rsi), %rax
movq %rax, %rcx
movl (%rdx), %ebp
movq %rcx, 0x28(%rsp)
movq (%rsi), %rax
movq %rax, 0x30(%rsp)
addq $0x200, %rax            # imm = 0x200
movq %rax, 0x38(%rsp)
movq %rsi, 0x40(%rsp)
movq %r14, %rdi
movq 0xb0(%rsp), %rsi
leaq 0x28(%rsp), %rdx
callq 0x15104
movq %r13, 0x28(%rsp)
movl %ebp, 0x30(%rsp)
movl $0xa, %ecx
leaq 0x38(%rsp), %r14
movq %r14, %rdi
leaq 0x118(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x98(%rsp), %rbp
movq %rbp, 0x88(%rsp)
movq 0x168(%rsp), %rsi
movq 0x170(%rsp), %rdx
addq %rsi, %rdx
leaq 0x88(%rsp), %rdi
callq 0x52b6
movq 0x188(%rsp), %rax
movq %rax, 0xa8(%rsp)
movl 0x28(%rsp), %ecx
movq 0x20(%rsp), %rdx
movl %ecx, (%rdx)
movl 0x30(%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 0x88(%rsp), %rcx
cmpq %rbp, %rcx
je 0x1407a
movq %rcx, 0x58(%rdx)
movq 0x98(%rsp), %rcx
movq %rcx, 0x68(%rdx)
jmp 0x14081
movq %rsi, %rcx
shrq $0x2, %rcx
movq %rcx, %rdi
movabsq $-0x4000000000000000, %r8 # imm = 0xC000000000000000
orq %r8, %rdi
testq %rsi, %rsi
cmovgq %rcx, %rdi
leaq (%rax,%rdi,8), %rax
shlq $0x2, %rdi
subq %rdi, %rdx
addq %r13, %rdx
imulq $0x78, %rdx, %rcx
addq (%rax), %rcx
leaq 0x190(%rsp), %r14
movq %rcx, 0x28(%rsp)
movq (%rax), %rcx
movq %rcx, 0x30(%rsp)
addq $0x1e0, %rcx            # imm = 0x1E0
movq %rcx, 0x38(%rsp)
movq %rax, 0x40(%rsp)
movq %r14, %rdi
movq %r12, %rsi
leaq 0x28(%rsp), %rdx
callq 0x6a0a
movq 0x68(%r12), %rcx
movq %rcx, %rax
subq 0x70(%r12), %rax
sarq $0x2, %rax
addq %r13, %rax
cmpq $0x7f, %rax
ja 0x13f18
movq 0x8(%rsp), %rdx
addq %rcx, %rdx
jmp 0x13f53
movq %rax, %rdx
shrq $0x7, %rdx
movq %rdx, %rsi
movabsq $-0x200000000000000, %rdi # imm = 0xFE00000000000000
orq %rdi, %rsi
testq %rax, %rax
cmovgq %rdx, %rsi
movq 0x80(%r12), %rdi
movq %rsi, %r8
shlq $0x7, %r8
movq %rax, %rdx
subq %r8, %rdx
shlq $0x2, %rdx
addq (%rdi,%rsi,8), %rdx
movq 0x80(%r12), %rsi
cmpq $0x7f, %rax
ja 0x13f68
addq 0x8(%rsp), %rcx
jmp 0x13f9b
movq %rax, %rcx
shrq $0x7, %rcx
movq %rcx, %rdi
movabsq $-0x200000000000000, %r8 # imm = 0xFE00000000000000
orq %r8, %rdi
testq %rax, %rax
cmovgq %rcx, %rdi
leaq (%rsi,%rdi,8), %rsi
shlq $0x7, %rdi
subq %rdi, %rax
shlq $0x2, %rax
addq (%rsi), %rax
movq %rax, %rcx
movl (%rdx), %ebp
movq %rcx, 0x28(%rsp)
movq (%rsi), %rax
movq %rax, 0x30(%rsp)
addq $0x200, %rax            # imm = 0x200
movq %rax, 0x38(%rsp)
movq %rsi, 0x40(%rsp)
movq %r14, %rdi
movq 0xb0(%rsp), %rsi
leaq 0x28(%rsp), %rdx
callq 0x15104
movq %r13, 0x28(%rsp)
movl %ebp, 0x30(%rsp)
movl $0xa, %ecx
leaq 0x38(%rsp), %rbp
movq %rbp, %rdi
leaq 0x118(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x98(%rsp), %r14
movq %r14, 0x88(%rsp)
movq 0x168(%rsp), %rsi
movq 0x170(%rsp), %rdx
addq %rsi, %rdx
leaq 0x88(%rsp), %rdi
callq 0x52b6
movq 0x188(%rsp), %rax
movq %rax, 0xa8(%rsp)
movl 0x28(%rsp), %ecx
movq 0x20(%rsp), %rdx
movl %ecx, (%rdx)
movl 0x30(%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 0x88(%rsp), %rcx
cmpq %r14, %rcx
je 0x140c1
movq %rcx, 0x58(%rdx)
movq 0x98(%rsp), %rcx
movq %rcx, 0x68(%rdx)
jmp 0x140c8
movups (%rbp), %xmm0
movups %xmm0, (%rsi)
movabsq $-0x1111111111111111, %r14 # imm = 0xEEEEEEEEEEEEEEEF
movq 0x90(%rsp), %rcx
movq %rcx, 0x60(%rdx)
movq %rbp, 0x88(%rsp)
movq $0x0, 0x90(%rsp)
movb $0x0, 0x98(%rsp)
movq %rax, 0x78(%rdx)
movl $0x1, %ebp
jmp 0x13c56
movups (%r14), %xmm0
movups %xmm0, (%rsi)
movq 0x90(%rsp), %rcx
movq %rcx, 0x60(%rdx)
movq %r14, 0x88(%rsp)
movq $0x0, 0x90(%rsp)
movb $0x0, 0x98(%rsp)
movq %rax, 0x78(%rdx)
movl $0x1, %ebp
xorl %ecx, %ecx
movabsq $-0x1111111111111111, %r14 # imm = 0xEEEEEEEEEEEEEEEF
jmp 0x13c50
movl $0x2, %ebp
cmpl $0x2, %ebp
movq 0x20(%rsp), %rbx
jne 0x141a4
leaq 0x28(%rsp), %r14
movq %r14, %rdi
callq 0x7c0a
movq $-0x1, (%rbx)
movl $0xa, %ecx
movq 0x10(%rsp), %rdi
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq 0x18(%rsp), %rdx
movq %rdx, 0x58(%rbx)
movq 0x50(%r14), %rax
leaq 0x88(%rsp), %rcx
cmpq %rcx, %rax
je 0x1416d
movq %rax, 0x58(%rbx)
movq 0x88(%rsp), %rax
movq %rax, 0x68(%rbx)
jmp 0x14173
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq 0x80(%rsp), %rax
movq %rax, 0x60(%rbx)
movq %rcx, 0x78(%rsp)
movq $0x0, 0x80(%rsp)
movb $0x0, 0x88(%rsp)
movq 0x98(%rsp), %rax
movq %rax, 0x78(%rbx)
movq %rbx, %rax
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x14249
jmp 0x14249
jmp 0x14249
jmp 0x14249
jmp 0x14249
jmp 0x14249
movq %rax, %r14
movq 0x200(%rsp), %rdi
leaq 0x210(%rsp), %rax
cmpq %rax, %rdi
je 0x14225
movq 0x210(%rsp), %rsi
incq %rsi
callq 0x3200
jmp 0x14225
jmp 0x14249
jmp 0x14249
jmp 0x14249
movq %rax, %r14
movq 0xf0(%rsp), %rdi
leaq 0x100(%rsp), %rax
cmpq %rax, %rdi
je 0x1424c
movq 0x100(%rsp), %rsi
jmp 0x1423f
jmp 0x14249
movq %rax, %r14
movq 0xd0(%rsp), %rdi
cmpq 0x110(%rsp), %rdi
je 0x1424c
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x3200
jmp 0x1424c
movq %rax, %r14
movq 0x168(%rsp), %rdi
leaq 0x178(%rsp), %rax
cmpq %rax, %rdi
je 0x14271
movq 0x178(%rsp), %rsi
incq %rsi
callq 0x3200
movq %r14, %rdi
callq 0x3340
nop