// File: saeefahmad[P]MIPS-pipeline-simulator/decode.cpp
// Function: DecodeStage::process()
void DecodeStage::process() {
	if(resolveDependence(this->ins)){
		this->setStalled();
	} else {
		this->setUnstalled();
	}
	if(this->isStalled()){
		this->incStatistics((StatisticsType) 0);
	}

	Instruction instr;
	instr = this->ins;
	if(!instr.isNop() && !this->isStalled()){
		if(instr.isAluReg()){
			instr.setA(this->getReg(instr.getArg2()));
			instr.setB(this->getReg(instr.getArg3()));
		} else if(instr.isAluImm()){
			instr.setA(this->getReg(instr.getArg2()));
			instr.setB(this->getReg(instr.getArg1()));
		} else if(instr.isMemory()){
			instr.setA(this->getReg(instr.getArg2()));
			instr.setB(this->getReg(instr.getArg1()));
		} else if(instr.isBranch()){
			instr.setA(this->getReg(instr.getArg1()));
		} else if(instr.isHlt()){
		}
	}
	this->nextStage->setInstruction(instr);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x80(%rbp)
leaq 0x6682(%rip), %rax      # 0xd750
movq (%rax), %rax
addq $0x8, %rdi
callq *%rax
testb $0x1, %al
jne 0x70dd
jmp 0x70e8
movq -0x80(%rbp), %rdi
callq 0x6cb0
jmp 0x70f1
movq -0x80(%rbp), %rdi
callq 0x6cf0
movq -0x80(%rbp), %rdi
callq 0x74f0
testb $0x1, %al
jne 0x7100
jmp 0x710b
xorl %edi, %edi
leaq 0x6697(%rip), %rax      # 0xd7a0
callq *(%rax)
leaq -0x64(%rbp), %rdi
movq %rdi, -0x88(%rbp)
callq 0x8480
movq -0x80(%rbp), %rsi
movq -0x88(%rbp), %rdi
addq $0x8, %rsi
callq 0x86a0
jmp 0x7131
leaq -0x64(%rbp), %rdi
callq 0x7510
movb %al, -0x89(%rbp)
jmp 0x7142
movb -0x89(%rbp), %al
testb $0x1, %al
jne 0x744a
jmp 0x7152
movq -0x80(%rbp), %rdi
callq 0x74f0
movb %al, -0x8a(%rbp)
jmp 0x7163
movb -0x8a(%rbp), %al
testb $0x1, %al
jne 0x744a
jmp 0x7173
leaq -0x64(%rbp), %rdi
callq 0x65e0
movb %al, -0x8b(%rbp)
jmp 0x7184
movb -0x8b(%rbp), %al
testb $0x1, %al
jne 0x7193
jmp 0x7246
leaq 0x65d6(%rip), %rax      # 0xd770
movq (%rax), %rax
movq %rax, -0x98(%rbp)
leaq -0x64(%rbp), %rdi
callq 0x6620
movl %eax, -0x90(%rbp)
jmp 0x71b5
movq -0x98(%rbp), %rax
movl -0x90(%rbp), %edi
callq *%rax
movl %eax, -0x9c(%rbp)
jmp 0x71cc
movl -0x9c(%rbp), %esi
leaq -0x64(%rbp), %rdi
callq 0x7530
jmp 0x71dd
leaq 0x658c(%rip), %rax      # 0xd770
movq (%rax), %rax
movq %rax, -0xa8(%rbp)
leaq -0x64(%rbp), %rdi
callq 0x6640
movl %eax, -0xa0(%rbp)
jmp 0x71ff
movq -0xa8(%rbp), %rax
movl -0xa0(%rbp), %edi
callq *%rax
movl %eax, -0xac(%rbp)
jmp 0x7216
movl -0xac(%rbp), %esi
leaq -0x64(%rbp), %rdi
callq 0x7550
jmp 0x7227
jmp 0x7448
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x64(%rbp), %rdi
callq 0x87e0
jmp 0x746f
leaq -0x64(%rbp), %rdi
callq 0x6680
movb %al, -0xad(%rbp)
jmp 0x7257
movb -0xad(%rbp), %al
testb $0x1, %al
jne 0x7266
jmp 0x72ff
leaq 0x6503(%rip), %rax      # 0xd770
movq (%rax), %rax
movq %rax, -0xc0(%rbp)
leaq -0x64(%rbp), %rdi
callq 0x6620
movl %eax, -0xb4(%rbp)
jmp 0x7288
movq -0xc0(%rbp), %rax
movl -0xb4(%rbp), %edi
callq *%rax
movl %eax, -0xc4(%rbp)
jmp 0x729f
movl -0xc4(%rbp), %esi
leaq -0x64(%rbp), %rdi
callq 0x7530
jmp 0x72b0
leaq 0x64b9(%rip), %rax      # 0xd770
movq (%rax), %rax
movq %rax, -0xd0(%rbp)
leaq -0x64(%rbp), %rdi
callq 0x6660
movl %eax, -0xc8(%rbp)
jmp 0x72d2
movq -0xd0(%rbp), %rax
movl -0xc8(%rbp), %edi
callq *%rax
movl %eax, -0xd4(%rbp)
jmp 0x72e9
movl -0xd4(%rbp), %esi
leaq -0x64(%rbp), %rdi
callq 0x7550
jmp 0x72fa
jmp 0x7446
leaq -0x64(%rbp), %rdi
callq 0x7570
movb %al, -0xd5(%rbp)
jmp 0x7310
movb -0xd5(%rbp), %al
testb $0x1, %al
jne 0x731f
jmp 0x73b8
leaq 0x644a(%rip), %rax      # 0xd770
movq (%rax), %rax
movq %rax, -0xe8(%rbp)
leaq -0x64(%rbp), %rdi
callq 0x6620
movl %eax, -0xdc(%rbp)
jmp 0x7341
movq -0xe8(%rbp), %rax
movl -0xdc(%rbp), %edi
callq *%rax
movl %eax, -0xec(%rbp)
jmp 0x7358
movl -0xec(%rbp), %esi
leaq -0x64(%rbp), %rdi
callq 0x7530
jmp 0x7369
leaq 0x6400(%rip), %rax      # 0xd770
movq (%rax), %rax
movq %rax, -0xf8(%rbp)
leaq -0x64(%rbp), %rdi
callq 0x6660
movl %eax, -0xf0(%rbp)
jmp 0x738b
movq -0xf8(%rbp), %rax
movl -0xf0(%rbp), %edi
callq *%rax
movl %eax, -0xfc(%rbp)
jmp 0x73a2
movl -0xfc(%rbp), %esi
leaq -0x64(%rbp), %rdi
callq 0x7550
jmp 0x73b3
jmp 0x7444
leaq -0x64(%rbp), %rdi
callq 0x66a0
movb %al, -0xfd(%rbp)
jmp 0x73c9
movb -0xfd(%rbp), %al
testb $0x1, %al
jne 0x73d5
jmp 0x7421
leaq 0x6394(%rip), %rax      # 0xd770
movq (%rax), %rax
movq %rax, -0x110(%rbp)
leaq -0x64(%rbp), %rdi
callq 0x6660
movl %eax, -0x104(%rbp)
jmp 0x73f7
movq -0x110(%rbp), %rax
movl -0x104(%rbp), %edi
callq *%rax
movl %eax, -0x114(%rbp)
jmp 0x740e
movl -0x114(%rbp), %esi
leaq -0x64(%rbp), %rdi
callq 0x7530
jmp 0x741f
jmp 0x7442
leaq -0x64(%rbp), %rdi
callq 0x7590
movb %al, -0x115(%rbp)
jmp 0x7432
movb -0x115(%rbp), %al
testb $0x1, %al
jne 0x743e
jmp 0x7440
jmp 0x7440
jmp 0x7442
jmp 0x7444
jmp 0x7446
jmp 0x7448
jmp 0x744a
movq -0x80(%rbp), %rax
movq 0x78(%rax), %rdi
leaq -0x64(%rbp), %rsi
callq 0x6d40
jmp 0x745d
leaq -0x64(%rbp), %rdi
callq 0x87e0
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
movq -0x70(%rbp), %rdi
callq 0x2200
nopl (%rax,%rax)