// File: sopanpatra160[P]OOO_Superscalar_Processor_Simulator/main.cc
// Function: Issue(unsigned int)
void Issue(unsigned int n)
{
	vector<instruction>     temp_issue_list;

	for (vector<instruction>::iterator it = issue_list.begin() ; it != issue_list.end(); ++it)
        {
		if(it->src1_ready && it->src2_ready)
		{
			temp_issue_list.push_back(*it);			
		}
	}

	unsigned int issue_count = 0;
	for (vector<instruction>::iterator it = temp_issue_list.begin() ; it != temp_issue_list.end(); ++it)
        {
	
		if(issue_count < n)
                {

                        it->state=EX;
                        it->is_duration = cycles - it->is_begin_cycle;
                        it->ex_begin_cycle = cycles;
			execute_list.push_back(*it);			

			for(int i = 0; i < issue_list.size(); i++)
                        {
                                if(issue_list[i].tag == it->tag)
                                {
					issue_list.erase(issue_list.begin()+i);
                                }
                        }

			//mp_issue_list.remove(*it);
			//issue_list.erase(issue_list.begin());
			
			issue_count++ ;
		}		
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movl %edi, -0x4(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x4ba0
leaq 0x6ac2(%rip), %rdi      # 0xa3c0
callq 0x4cc0
movq %rax, -0x28(%rbp)
leaq 0x6ab2(%rip), %rdi      # 0xa3c0
callq 0x4d30
movq %rax, -0x30(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x4cf0
testb $0x1, %al
jne 0x392a
jmp 0x398b
leaq -0x28(%rbp), %rdi
callq 0x4d60
testb $0x1, 0x4(%rax)
je 0x397b
leaq -0x28(%rbp), %rdi
callq 0x4d60
testb $0x1, 0x5(%rax)
je 0x397b
leaq -0x28(%rbp), %rdi
callq 0x4d80
movq %rax, %rsi
leaq -0x20(%rbp), %rdi
callq 0x4c50
jmp 0x395f
jmp 0x397b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x4bc0
jmp 0x3b4a
jmp 0x397d
leaq -0x28(%rbp), %rdi
callq 0x4da0
jmp 0x3907
movl $0x0, -0x40(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x4cc0
movq %rax, -0x48(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x4d30
movq %rax, -0x50(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x4cf0
testb $0x1, %al
jne 0x39c2
jmp 0x3b38
movl -0x40(%rbp), %eax
cmpl -0x4(%rbp), %eax
jae 0x3b28
leaq -0x48(%rbp), %rdi
movq %rdi, -0x80(%rbp)
callq 0x4d60
movq -0x80(%rbp), %rdi
movl $0x3, 0x4c(%rax)
movl 0x66fc(%rip), %eax      # 0xa0e8
movl %eax, -0x8c(%rbp)
callq 0x4d60
movq -0x80(%rbp), %rdi
movq %rax, %rcx
movl -0x8c(%rbp), %eax
movl 0x2c(%rcx), %ecx
subl %ecx, %eax
movl %eax, -0x88(%rbp)
callq 0x4d60
movl -0x88(%rbp), %ecx
movq -0x80(%rbp), %rdi
movl %ecx, 0x30(%rax)
movl 0x66c1(%rip), %eax      # 0xa0e8
movl %eax, -0x84(%rbp)
callq 0x4d60
movl -0x84(%rbp), %ecx
movq -0x80(%rbp), %rdi
movl %ecx, 0x34(%rax)
callq 0x4d80
movq %rax, %rsi
leaq 0x698a(%rip), %rdi      # 0xa3d8
callq 0x4c50
jmp 0x3a55
movl $0x0, -0x54(%rbp)
movslq -0x54(%rbp), %rax
movq %rax, -0x98(%rbp)
leaq 0x6952(%rip), %rdi      # 0xa3c0
callq 0x4c20
movq %rax, %rcx
movq -0x98(%rbp), %rax
cmpq %rcx, %rax
jae 0x3b1f
movslq -0x54(%rbp), %rsi
leaq 0x692f(%rip), %rdi      # 0xa3c0
callq 0x4e70
movl 0x50(%rax), %eax
movl %eax, -0x9c(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x4d60
movq %rax, %rcx
movl -0x9c(%rbp), %eax
cmpl 0x50(%rcx), %eax
jne 0x3b0f
leaq 0x6903(%rip), %rdi      # 0xa3c0
movq %rdi, -0xb0(%rbp)
callq 0x4cc0
movq %rax, -0x70(%rbp)
movslq -0x54(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x4e90
movq %rax, -0x68(%rbp)
leaq -0x60(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x4e30
movq -0xb0(%rbp), %rdi
movq -0x60(%rbp), %rsi
callq 0x4dc0
movq %rax, -0xa8(%rbp)
jmp 0x3b04
movq -0xa8(%rbp), %rax
movq %rax, -0x78(%rbp)
jmp 0x3b11
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x3a5c
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x3b2a
leaq -0x48(%rbp), %rdi
callq 0x4da0
jmp 0x399f
leaq -0x20(%rbp), %rdi
callq 0x4bc0
addq $0xb0, %rsp
popq %rbp
retq
movq -0x38(%rbp), %rdi
callq 0x1140
nopw %cs:(%rax,%rax)