// File: saeefahmad[P]MIPS-pipeline-simulator/pipeline.cpp
// Function: resolveDependence(Instruction&)
bool resolveDependence(Instruction& _instr) {
	instr = _instr;
	bool flag = 0;
	if(instr.isAluReg()){
		if(instr.getDecodeCycle() < regDependence[instr.getArg2()] || instr.getDecodeCycle() < regDependence[instr.getArg3()]){
			flag = 0;
		} else {
			flag = 1;
		}
		if((instr.getDecodeCycle() + 3) > regDependence[instr.getArg1()]){
			regDependence[instr.getArg1()] = instr.getDecodeCycle() + 3;
		}
	} else if(instr.isAluImm()){
		if(instr.getDecodeCycle() < regDependence[instr.getArg2()]){
			flag = 0;
		} else {
			flag = 1;
		}
		if((instr.getDecodeCycle() + 3) > regDependence[instr.getArg1()]){
			regDependence[instr.getArg1()] = instr.getDecodeCycle() + 3;
		}
	} else if(instr.isBranch()){
		if(instr.getDecodeCycle() < regDependence[instr.getArg1()]){
			flag = 0;
		} else {
			flag = 1;
		}
	} else if(instr.isLoad()){
		if(instr.getDecodeCycle() < regDependence[instr.getArg2()]){
			flag = 0;
		} else {
			flag = 1;
		}
		if((instr.getDecodeCycle() + 3) > regDependence[instr.getArg1()]){
			regDependence[instr.getArg1()] = instr.getDecodeCycle() + 3;
		}
	} else if(instr.isStore()){
		if(instr.getDecodeCycle() < regDependence[instr.getArg2()]){
			flag = 0;
		} else {
			flag = 1;
		}
	}
	return flag;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rsi
leaq 0x78bd(%rip), %rdi      # 0xd6b4
callq 0x86a0
movb $0x0, -0x9(%rbp)
leaq 0x78ad(%rip), %rdi      # 0xd6b4
callq 0x65e0
testb $0x1, %al
jne 0x5e15
jmp 0x5efa
leaq 0x7898(%rip), %rdi      # 0xd6b4
callq 0x6600
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x10(%rbp)
leaq 0x7884(%rip), %rdi      # 0xd6b4
callq 0x6620
movl %eax, %ecx
movl -0x10(%rbp), %eax
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x78cb(%rip), %rcx      # 0xd710
cmpl (%rcx,%rdx,4), %eax
jl 0x5e7f
leaq 0x7863(%rip), %rdi      # 0xd6b4
callq 0x6600
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x14(%rbp)
leaq 0x784f(%rip), %rdi      # 0xd6b4
callq 0x6640
movl %eax, %ecx
movl -0x14(%rbp), %eax
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x7896(%rip), %rcx      # 0xd710
cmpl (%rcx,%rdx,4), %eax
jge 0x5e85
movb $0x0, -0x9(%rbp)
jmp 0x5e89
movb $0x1, -0x9(%rbp)
leaq 0x7824(%rip), %rdi      # 0xd6b4
callq 0x6600
andb $0x1, %al
movzbl %al, %eax
addl $0x3, %eax
movl %eax, -0x18(%rbp)
leaq 0x780d(%rip), %rdi      # 0xd6b4
callq 0x6660
movl %eax, %ecx
movl -0x18(%rbp), %eax
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x7854(%rip), %rcx      # 0xd710
cmpl (%rcx,%rdx,4), %eax
jle 0x5ef5
leaq 0x77ec(%rip), %rdi      # 0xd6b4
callq 0x6600
andb $0x1, %al
movzbl %al, %eax
addl $0x3, %eax
movl %eax, -0x1c(%rbp)
leaq 0x77d5(%rip), %rdi      # 0xd6b4
callq 0x6660
movl -0x1c(%rbp), %edx
movl %eax, %eax
movl %eax, %ecx
leaq 0x781e(%rip), %rax      # 0xd710
movl %edx, (%rax,%rcx,4)
jmp 0x6132
leaq 0x77b3(%rip), %rdi      # 0xd6b4
callq 0x6680
testb $0x1, %al
jne 0x5f0f
jmp 0x5fbf
leaq 0x779e(%rip), %rdi      # 0xd6b4
callq 0x6600
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x20(%rbp)
leaq 0x778a(%rip), %rdi      # 0xd6b4
callq 0x6620
movl %eax, %ecx
movl -0x20(%rbp), %eax
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x77d1(%rip), %rcx      # 0xd710
cmpl (%rcx,%rdx,4), %eax
jge 0x5f4a
movb $0x0, -0x9(%rbp)
jmp 0x5f4e
movb $0x1, -0x9(%rbp)
leaq 0x775f(%rip), %rdi      # 0xd6b4
callq 0x6600
andb $0x1, %al
movzbl %al, %eax
addl $0x3, %eax
movl %eax, -0x24(%rbp)
leaq 0x7748(%rip), %rdi      # 0xd6b4
callq 0x6660
movl %eax, %ecx
movl -0x24(%rbp), %eax
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x778f(%rip), %rcx      # 0xd710
cmpl (%rcx,%rdx,4), %eax
jle 0x5fba
leaq 0x7727(%rip), %rdi      # 0xd6b4
callq 0x6600
andb $0x1, %al
movzbl %al, %eax
addl $0x3, %eax
movl %eax, -0x28(%rbp)
leaq 0x7710(%rip), %rdi      # 0xd6b4
callq 0x6660
movl -0x28(%rbp), %edx
movl %eax, %eax
movl %eax, %ecx
leaq 0x7759(%rip), %rax      # 0xd710
movl %edx, (%rax,%rcx,4)
jmp 0x6130
leaq 0x76ee(%rip), %rdi      # 0xd6b4
callq 0x66a0
testb $0x1, %al
jne 0x5fd1
jmp 0x6015
leaq 0x76dc(%rip), %rdi      # 0xd6b4
callq 0x6600
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x2c(%rbp)
leaq 0x76c8(%rip), %rdi      # 0xd6b4
callq 0x6660
movl %eax, %ecx
movl -0x2c(%rbp), %eax
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x770f(%rip), %rcx      # 0xd710
cmpl (%rcx,%rdx,4), %eax
jge 0x600c
movb $0x0, -0x9(%rbp)
jmp 0x6010
movb $0x1, -0x9(%rbp)
jmp 0x612e
leaq 0x7698(%rip), %rdi      # 0xd6b4
callq 0x66c0
testb $0x1, %al
jne 0x602a
jmp 0x60d7
leaq 0x7683(%rip), %rdi      # 0xd6b4
callq 0x6600
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x30(%rbp)
leaq 0x766f(%rip), %rdi      # 0xd6b4
callq 0x6620
movl %eax, %ecx
movl -0x30(%rbp), %eax
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x76b6(%rip), %rcx      # 0xd710
cmpl (%rcx,%rdx,4), %eax
jge 0x6065
movb $0x0, -0x9(%rbp)
jmp 0x6069
movb $0x1, -0x9(%rbp)
leaq 0x7644(%rip), %rdi      # 0xd6b4
callq 0x6600
andb $0x1, %al
movzbl %al, %eax
addl $0x3, %eax
movl %eax, -0x34(%rbp)
leaq 0x762d(%rip), %rdi      # 0xd6b4
callq 0x6660
movl %eax, %ecx
movl -0x34(%rbp), %eax
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x7674(%rip), %rcx      # 0xd710
cmpl (%rcx,%rdx,4), %eax
jle 0x60d5
leaq 0x760c(%rip), %rdi      # 0xd6b4
callq 0x6600
andb $0x1, %al
movzbl %al, %eax
addl $0x3, %eax
movl %eax, -0x38(%rbp)
leaq 0x75f5(%rip), %rdi      # 0xd6b4
callq 0x6660
movl -0x38(%rbp), %edx
movl %eax, %eax
movl %eax, %ecx
leaq 0x763e(%rip), %rax      # 0xd710
movl %edx, (%rax,%rcx,4)
jmp 0x612c
leaq 0x75d6(%rip), %rdi      # 0xd6b4
callq 0x66e0
testb $0x1, %al
jne 0x60e9
jmp 0x612a
leaq 0x75c4(%rip), %rdi      # 0xd6b4
callq 0x6600
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x3c(%rbp)
leaq 0x75b0(%rip), %rdi      # 0xd6b4
callq 0x6620
movl %eax, %ecx
movl -0x3c(%rbp), %eax
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x75f7(%rip), %rcx      # 0xd710
cmpl (%rcx,%rdx,4), %eax
jge 0x6124
movb $0x0, -0x9(%rbp)
jmp 0x6128
movb $0x1, -0x9(%rbp)
jmp 0x612a
jmp 0x612c
jmp 0x612e
jmp 0x6130
jmp 0x6132
movb -0x9(%rbp), %al
andb $0x1, %al
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)