// File: /workspace/github_cpp_makefile_star2_O1/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 0x2dc0
leal (%rbx,%rbx), %r13d
movl $0x1, %ebp
leaq 0x10(%rsp), %r15
leaq 0x20(%rsp), %r12
movq 0x3738(%rip), %rax      # 0x63b0
subq 0x3729(%rip), %rax      # 0x63a8
sarq $0x3, %rax
movabsq $0x2e8ba2e8ba2e8ba3, %rcx # imm = 0x2E8BA2E8BA2E8BA3
imulq %rcx, %rax
cmpq %r13, %rax
jae 0x2dc0
movq %r14, %rdi
leaq 0x158c(%rip), %rsi      # 0x4230
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 0x33df(%rip), %ecx      # 0x60e4
movl %ecx, 0x70(%rsp)
movl 0x33d9(%rip), %ecx      # 0x60e8
movl %ecx, 0x3c(%rsp)
movq $0x1, 0x64(%rsp)
cmpl $0x2, %eax
jne 0x2d29
movl 0x8(%rsp), %eax
movl %eax, 0x74(%rsp)
movq 0x3680(%rip), %rax      # 0x63b0
cmpq 0x3681(%rip), %rax      # 0x63b8
je 0x2d53
movl $0x16, %ecx
movq %rax, %rdi
movq %r12, %rsi
rep  movsl (%rsi), %es:(%rdi)
addq $0x58, %rax
movq %rax, 0x365f(%rip)      # 0x63b0
jmp 0x2d65
leaq 0x364e(%rip), %rdi      # 0x63a8
movq %rax, %rsi
movq %r12, %rdx
callq 0x3b0c
movq 0x362c(%rip), %rax      # 0x6398
cmpq 0x362d(%rip), %rax      # 0x63a0
je 0x2d8f
movl $0x16, %ecx
movq %rax, %rdi
movq %r12, %rsi
rep  movsl (%rsi), %es:(%rdi)
addq $0x58, %rax
movq %rax, 0x360b(%rip)      # 0x6398
jmp 0x2da1
leaq 0x35fa(%rip), %rdi      # 0x6390
movq %rax, %rsi
movq %r12, %rdx
callq 0x3b0c
incl 0x333d(%rip)            # 0x60e4
movq %r14, %rdi
callq 0x1110
testl %eax, %eax
jne 0x2dc0
leal 0x1(%rbp), %eax
cmpl %ebx, %ebp
movl %eax, %ebp
jb 0x2c71
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq