// File: /workspace/github_cpp_makefile_star2_O2/martinferianc[P]CPUSimulator-EIE2/src/mips_cpu_execute.cpp
// Function: mips_execute_I(mips_cpu_impl*, mips_mem_provider*, unsigned int const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, unsigned int&, unsigned int&)
mips_error mips_execute_I(mips_cpu_h state, mips_mem_h mem, const uint32_t* instruction_data, string& instruction, uint32_t& pcN, uint32_t& pc ){
	uint32_t source1 = instruction_data[1];
	uint32_t destination = instruction_data[2];

	switch(instruction_data[0]){
		case 0b001001:
			return mips_execute_I_X(state, mem, instruction_data,"ADDIU", instruction, pcN, pc);
		case 0b001000:
			return mips_execute_I_X(state, mem, instruction_data,"ADDI", instruction, pcN, pc);
		case 0b001100:
			return mips_execute_I_X(state, mem, instruction_data,"ANDI", instruction, pcN, pc);
		case 0b001101:
			return mips_execute_I_X(state, mem, instruction_data,"ORI", instruction, pcN, pc);
		case 0b001110:
			return mips_execute_I_X(state, mem, instruction_data,"XORI", instruction, pcN, pc);
		case 0b001011:
			return mips_execute_I_X(state, mem, instruction_data,"SLTIU", instruction, pcN, pc);
		case 0b001010:
			return mips_execute_I_X(state, mem, instruction_data,"SLTI", instruction, pcN, pc);
		case 0b000100:
			return mips_execute_I_X(state, mem, instruction_data,"BEQ", instruction, pcN, pc);
		case 0b000101:
			return mips_execute_I_X(state, mem, instruction_data,"BNE", instruction, pcN, pc);
		case 0b000001:
			if (destination==0b00001)
				return mips_execute_I_X(state, mem, instruction_data,"BGEZ", instruction, pcN, pc);
			if (destination==0b00000)
				return mips_execute_I_X(state, mem, instruction_data,"BLTZ", instruction, pcN, pc);
			if (destination==0b10000)
				return mips_execute_I_X(state, mem, instruction_data,"BLTZAL", instruction, pcN, pc);
			if (destination==0b10001)
				return mips_execute_I_X(state, mem, instruction_data,"BGEZAL", instruction, pcN, pc);
		break;
		case 0b000111:
		if (destination==0)
			return mips_execute_I_X(state, mem, instruction_data,"BGTZ", instruction, pcN, pc);
		break;
		case 0b000110:
		if (destination==0)
			return mips_execute_I_X(state, mem, instruction_data,"BLEZ", instruction, pcN, pc);
		break;
		case 0b100011:
			return mips_execute_I_X(state, mem, instruction_data,"LW", instruction, pcN, pc);
		case 0b101011:
			return mips_execute_I_X(state, mem, instruction_data,"SW", instruction, pcN, pc);
		case 0b100100:
			return mips_execute_I_X(state, mem, instruction_data,"LBU", instruction, pcN, pc);
		case 0b101000:
			return mips_execute_I_X(state, mem, instruction_data,"SB", instruction, pcN, pc);
		case 0b100000:
			return mips_execute_I_X(state, mem, instruction_data,"LB", instruction, pcN, pc);
		case 0b101001:
			return mips_execute_I_X(state, mem, instruction_data,"SH", instruction, pcN, pc);
		case 0b100001:
			return mips_execute_I_X(state, mem, instruction_data,"LH", instruction, pcN, pc);
		case 0b100101:
			return mips_execute_I_X(state, mem, instruction_data,"LHU", instruction, pcN, pc);
		case 0b001111:
		if (source1==0)
			return mips_execute_I_X(state, mem, instruction_data,"LUI", instruction, pcN, pc);
		break;
		case 0b100010:
			return mips_execute_I_X(state, mem, instruction_data,"LWL", instruction, pcN, pc);
		case 0b100110:
			return mips_execute_I_X(state, mem, instruction_data,"LWR", instruction, pcN, pc);
		default:
		break;
	}
	instruction = "Invalid instruction format";
	return mips_ExceptionInvalidInstruction;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, %r14
movl (%rdx), %ecx
decl %ecx
cmpl $0x2a, %ecx
ja 0x58e2
movq %r9, %rbp
movq %r8, %rbx
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r13
movl 0x8(%rdx), %eax
leaq 0x4605(%rip), %rdx      # 0x9c00
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
testl %eax, %eax
je 0x5bcd
cmpl $0x11, %eax
je 0x5b63
cmpl $0x10, %eax
je 0x5b98
cmpl $0x1, %eax
jne 0x58e2
leaq 0x3fc5(%rip), %rsi      # 0x95f3
leaq 0x18(%rsp), %rdi
leaq 0x17(%rsp), %rdx
callq 0x3bee
movq %rbp, (%rsp)
leaq 0x18(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x67bf
jmp 0x5c00
leaq 0x4138(%rip), %rsi      # 0x979e
leaq 0x18(%rsp), %rdi
leaq 0x17(%rsp), %rdx
callq 0x3bee
movq %rbp, (%rsp)
leaq 0x18(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x67bf
jmp 0x5c00
leaq 0x4201(%rip), %rsi      # 0x989f
leaq 0x18(%rsp), %rdi
leaq 0x17(%rsp), %rdx
callq 0x3bee
movq %rbp, (%rsp)
leaq 0x18(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x67bf
jmp 0x5c00
leaq 0x4092(%rip), %rsi      # 0x9768
leaq 0x18(%rsp), %rdi
leaq 0x17(%rsp), %rdx
callq 0x3bee
movq %rbp, (%rsp)
leaq 0x18(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x67bf
jmp 0x5c00
leaq 0x4332(%rip), %rsi      # 0x9a40
leaq 0x18(%rsp), %rdi
leaq 0x17(%rsp), %rdx
callq 0x3bee
movq %rbp, (%rsp)
leaq 0x18(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x67bf
jmp 0x5c00
leaq 0x3fa4(%rip), %rsi      # 0x96ea
leaq 0x18(%rsp), %rdi
leaq 0x17(%rsp), %rdx
callq 0x3bee
movq %rbp, (%rsp)
leaq 0x18(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x67bf
jmp 0x5c00
testl %eax, %eax
jne 0x58e2
leaq 0x3ed2(%rip), %rsi      # 0x9658
leaq 0x18(%rsp), %rdi
leaq 0x17(%rsp), %rdx
callq 0x3bee
movq %rbp, (%rsp)
leaq 0x18(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x67bf
jmp 0x5c00
leaq 0x425a(%rip), %rsi      # 0x9a18
leaq 0x18(%rsp), %rdi
leaq 0x17(%rsp), %rdx
callq 0x3bee
movq %rbp, (%rsp)
leaq 0x18(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x67bf
jmp 0x5c00
cmpl $0x0, 0x4(%r15)
jne 0x58e2
leaq 0x3fb9(%rip), %rsi      # 0x97ba
leaq 0x18(%rsp), %rdi
leaq 0x17(%rsp), %rdx
callq 0x3bee
movq %rbp, (%rsp)
leaq 0x18(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x67bf
jmp 0x5c00
leaq 0x3fba(%rip), %rsi      # 0x97f3
leaq 0x18(%rsp), %rdi
leaq 0x17(%rsp), %rdx
callq 0x3bee
movq %rbp, (%rsp)
leaq 0x18(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x67bf
jmp 0x5c00
leaq 0x3cd5(%rip), %rsi      # 0x9546
leaq 0x18(%rsp), %rdi
leaq 0x17(%rsp), %rdx
callq 0x3bee
movq %rbp, (%rsp)
leaq 0x18(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x67bf
jmp 0x5c00
leaq 0x4196(%rip), %rsi      # 0x9a3f
leaq 0x18(%rsp), %rdi
leaq 0x17(%rsp), %rdx
callq 0x3bee
movq %rbp, (%rsp)
leaq 0x18(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x67bf
jmp 0x5c00
testl %eax, %eax
je 0x5b2b
leaq 0x43c3(%rip), %rsi      # 0x9cac
movq %r14, %rdi
callq 0x3360
movl $0x2005, %ebx           # imm = 0x2005
jmp 0x5c0c
leaq 0x3cdd(%rip), %rsi      # 0x95df
leaq 0x18(%rsp), %rdi
leaq 0x17(%rsp), %rdx
callq 0x3bee
movq %rbp, (%rsp)
leaq 0x18(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x67bf
jmp 0x5c00
leaq 0x3c2f(%rip), %rsi      # 0x9569
leaq 0x18(%rsp), %rdi
leaq 0x17(%rsp), %rdx
callq 0x3bee
movq %rbp, (%rsp)
leaq 0x18(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x67bf
jmp 0x5c00
leaq 0x3f96(%rip), %rsi      # 0x9908
leaq 0x18(%rsp), %rdi
leaq 0x17(%rsp), %rdx
callq 0x3bee
movq %rbp, (%rsp)
leaq 0x18(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x67bf
jmp 0x5c00
leaq 0x3de2(%rip), %rsi      # 0x978c
leaq 0x18(%rsp), %rdi
leaq 0x17(%rsp), %rdx
callq 0x3bee
movq %rbp, (%rsp)
leaq 0x18(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x67bf
jmp 0x5c00
leaq 0x3dfe(%rip), %rsi      # 0x97e0
leaq 0x18(%rsp), %rdi
leaq 0x17(%rsp), %rdx
callq 0x3bee
movq %rbp, (%rsp)
leaq 0x18(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x67bf
jmp 0x5c00
leaq 0x3baa(%rip), %rsi      # 0x95c4
leaq 0x18(%rsp), %rdi
leaq 0x17(%rsp), %rdx
callq 0x3bee
movq %rbp, (%rsp)
leaq 0x18(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x67bf
jmp 0x5c00
leaq 0x3edf(%rip), %rsi      # 0x9931
leaq 0x18(%rsp), %rdi
leaq 0x17(%rsp), %rdx
callq 0x3bee
movq %rbp, (%rsp)
leaq 0x18(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x67bf
jmp 0x5c00
leaq 0x3ceb(%rip), %rsi      # 0x9775
leaq 0x18(%rsp), %rdi
leaq 0x17(%rsp), %rdx
callq 0x3bee
movq %rbp, (%rsp)
leaq 0x18(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x67bf
jmp 0x5c00
leaq 0x3d11(%rip), %rsi      # 0x97d3
leaq 0x18(%rsp), %rdi
leaq 0x17(%rsp), %rdx
callq 0x3bee
movq %rbp, (%rsp)
leaq 0x18(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x67bf
jmp 0x5c00
leaq 0x3d97(%rip), %rsi      # 0x9891
leaq 0x18(%rsp), %rdi
leaq 0x17(%rsp), %rdx
callq 0x3bee
movq %rbp, (%rsp)
leaq 0x18(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x67bf
jmp 0x5c00
leaq 0x3b47(%rip), %rsi      # 0x9679
leaq 0x18(%rsp), %rdi
leaq 0x17(%rsp), %rdx
callq 0x3bee
movq %rbp, (%rsp)
leaq 0x18(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x67bf
jmp 0x5c00
leaq 0x3ab6(%rip), %rsi      # 0x9620
leaq 0x18(%rsp), %rdi
leaq 0x17(%rsp), %rdx
callq 0x3bee
movq %rbp, (%rsp)
leaq 0x18(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x67bf
jmp 0x5c00
leaq 0x3b22(%rip), %rsi      # 0x96c1
leaq 0x18(%rsp), %rdi
leaq 0x17(%rsp), %rdx
callq 0x3bee
movq %rbp, (%rsp)
leaq 0x18(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x67bf
jmp 0x5c00
leaq 0x3acf(%rip), %rsi      # 0x96a3
leaq 0x18(%rsp), %rdi
leaq 0x17(%rsp), %rdx
callq 0x3bee
movq %rbp, (%rsp)
leaq 0x18(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x67bf
movl %eax, %ebx
leaq 0x18(%rsp), %rdi
callq 0x30d0
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5c5d
jmp 0x5c5d
jmp 0x5c5d
jmp 0x5c5d
jmp 0x5c90
jmp 0x5c90
jmp 0x5c90
jmp 0x5c90
jmp 0x5c5d
jmp 0x5c5d
jmp 0x5c5d
jmp 0x5c90
jmp 0x5c90
jmp 0x5c90
jmp 0x5c5d
jmp 0x5c5d
jmp 0x5c5d
jmp 0x5c5d
jmp 0x5c5d
jmp 0x5c5d
jmp 0x5c5d
jmp 0x5c5d
jmp 0x5c5d
jmp 0x5c5d
jmp 0x5c5d
jmp 0x5c5d
jmp 0x5c5d
jmp 0x5c5d
jmp 0x5c5d
jmp 0x5c5d
jmp 0x5c5d
jmp 0x5c5d
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x30d0
jmp 0x5c93
jmp 0x5c90
jmp 0x5c90
jmp 0x5c90
jmp 0x5c90
jmp 0x5c90
jmp 0x5c90
jmp 0x5c90
jmp 0x5c90
jmp 0x5c90
jmp 0x5c90
jmp 0x5c90
jmp 0x5c90
jmp 0x5c90
jmp 0x5c90
jmp 0x5c90
jmp 0x5c90
jmp 0x5c90
jmp 0x5c90
movq %rax, %rbx
movq %rbx, %rdi
callq 0x3330