// File: /workspace/github_cpp_makefile_star2_O3/sopanpatra160[P]OOO_Superscalar_Processor_Simulator/main.cc
// Function: Fetch(_IO_FILE*, unsigned int)
void Fetch(FILE *file, unsigned int n)
{
	unsigned int 	pc;
        unsigned int    op_type;
        int             dest_reg_num;
        int             src1_reg_num;
        int             src2_reg_num;
	unsigned int	fetch_count = 0;
	unsigned int 	mem_address;

	struct instruction instr;
	
	while( !feof(file) && fetch_count<n && dispatch_list.size()<2*n )
        {
	        
        	fscanf (file,"%x %d %d %d %d %x\n",&pc,&op_type,&dest_reg_num,&src1_reg_num,&src2_reg_num,&mem_address);
		instr.operation_type 	= 	op_type;
		instr.dest_regno	=	dest_reg_num;
		instr.src1_regno	=	src1_reg_num;
		instr.src2_regno	=	src2_reg_num;
		instr.src1_regno_new	=	src1_reg_num;
		instr.src2_regno_new	=	src2_reg_num;
		instr.state		=	IF;
		instr.tag		=	tag_num;
		instr.if_begin_cycle	=	cycles;
		instr.ex_latency	=	1;
		instr.mem_latency	=	0;
		if(op_type ==2 )
		{
		instr.mem_addr		=	mem_address;
		}

		dispatch_list.push_back(instr);
		fake_rob.push_back(instr);
		tag_num++;
		fetch_count++;
	
	}
	
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %esi, %ebx
movq %rdi, %r14
callq 0x1110
testl %eax, %eax
setne %al
testl %ebx, %ebx
sete %cl
orb %al, %cl
jne 0x2fc4
leal (%rbx,%rbx), %r13d
movl $0x1, %ebp
leaq 0x10(%rsp), %r15
leaq 0x20(%rsp), %r12
movq 0x4534(%rip), %rax      # 0x73b0
subq 0x4525(%rip), %rax      # 0x73a8
sarq $0x3, %rax
movabsq $0x2e8ba2e8ba2e8ba3, %rcx # imm = 0x2E8BA2E8BA2E8BA3
imulq %rcx, %rax
cmpq %r13, %rax
jae 0x2fc4
movq %r14, %rdi
leaq 0x23d8(%rip), %rsi      # 0x5280
leaq 0x1c(%rsp), %rdx
leaq 0x18(%rsp), %rcx
leaq 0x14(%rsp), %r8
movq %r15, %r9
xorl %eax, %eax
leaq 0x8(%rsp), %r10
pushq %r10
leaq 0x14(%rsp), %r10
pushq %r10
callq 0x1160
addq $0x10, %rsp
movl 0x18(%rsp), %eax
movl %eax, 0x20(%rsp)
movl 0x14(%rsp), %ecx
movl %ecx, 0x28(%rsp)
movl 0x10(%rsp), %ecx
movl %ecx, 0x2c(%rsp)
movl 0xc(%rsp), %edx
movl %edx, 0x30(%rsp)
movl %ecx, 0x34(%rsp)
movl %edx, 0x38(%rsp)
movl $0x0, 0x6c(%rsp)
movl 0x41db(%rip), %ecx      # 0x70e4
movl %ecx, 0x70(%rsp)
movl 0x41d5(%rip), %ecx      # 0x70e8
movl %ecx, 0x3c(%rsp)
movq $0x1, 0x64(%rsp)
cmpl $0x2, %eax
jne 0x2f2d
movl 0x8(%rsp), %eax
movl %eax, 0x74(%rsp)
movq 0x447c(%rip), %rax      # 0x73b0
cmpq 0x447d(%rip), %rax      # 0x73b8
je 0x2f57
movl $0x16, %ecx
movq %rax, %rdi
movq %r12, %rsi
rep  movsl (%rsi), %es:(%rdi)
addq $0x58, %rax
movq %rax, 0x445b(%rip)      # 0x73b0
jmp 0x2f69
leaq 0x444a(%rip), %rdi      # 0x73a8
movq %rax, %rsi
movq %r12, %rdx
callq 0x3d6c
movq 0x4428(%rip), %rax      # 0x7398
cmpq 0x4429(%rip), %rax      # 0x73a0
je 0x2f93
movl $0x16, %ecx
movq %rax, %rdi
movq %r12, %rsi
rep  movsl (%rsi), %es:(%rdi)
addq $0x58, %rax
movq %rax, 0x4407(%rip)      # 0x7398
jmp 0x2fa5
leaq 0x43f6(%rip), %rdi      # 0x7390
movq %rax, %rsi
movq %r12, %rdx
callq 0x3d6c
incl 0x4139(%rip)            # 0x70e4
movq %r14, %rdi
callq 0x1110
testl %eax, %eax
jne 0x2fc4
leal 0x1(%rbp), %eax
cmpl %ebx, %ebp
movl %eax, %ebp
jb 0x2e75
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq