// File: /workspace/github_cpp_makefile_star2_O3/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 $0x28, %rsp
movq %rcx, %r14
movl (%rdx), %ecx
decl %ecx
cmpl $0x2a, %ecx
ja 0x609e
movq %r9, %rbp
movq %r8, %rbx
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r13
movl 0x8(%rdx), %eax
leaq 0x4ec4(%rip), %rdx      # 0xac00
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
cmpl $0xf, %eax
jg 0x6361
testl %eax, %eax
je 0x63f6
cmpl $0x1, %eax
jne 0x609e
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x4884(%rip), %rsi      # 0xa5f3
leaq 0x4881(%rip), %rdx      # 0xa5f7
leaq 0x8(%rsp), %rdi
callq 0x40ba
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71d7
jmp 0x6474
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x49ec(%rip), %rsi      # 0xa79e
leaq 0x49e8(%rip), %rdx      # 0xa7a1
leaq 0x8(%rsp), %rdi
callq 0x40ba
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71d7
jmp 0x6474
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x4aaa(%rip), %rsi      # 0xa89f
leaq 0x4aa5(%rip), %rdx      # 0xa8a1
leaq 0x8(%rsp), %rdi
callq 0x40ba
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71d7
jmp 0x6474
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x4930(%rip), %rsi      # 0xa768
leaq 0x492b(%rip), %rdx      # 0xa76a
leaq 0x8(%rsp), %rdi
callq 0x40ba
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71d7
jmp 0x6474
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x4bc5(%rip), %rsi      # 0xaa40
leaq 0x4bc1(%rip), %rdx      # 0xaa43
leaq 0x8(%rsp), %rdi
callq 0x40ba
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71d7
jmp 0x6474
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x482c(%rip), %rsi      # 0xa6ea
leaq 0x4828(%rip), %rdx      # 0xa6ed
leaq 0x8(%rsp), %rdi
callq 0x40ba
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71d7
jmp 0x6474
testl %eax, %eax
jne 0x609e
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x474f(%rip), %rsi      # 0xa658
leaq 0x474c(%rip), %rdx      # 0xa65c
leaq 0x8(%rsp), %rdi
callq 0x40ba
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71d7
jmp 0x6474
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x4acc(%rip), %rsi      # 0xaa18
leaq 0x4ac7(%rip), %rdx      # 0xaa1a
leaq 0x8(%rsp), %rdi
callq 0x40ba
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71d7
jmp 0x6474
cmpl $0x0, 0x4(%r15)
jne 0x609e
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x4820(%rip), %rsi      # 0xa7ba
leaq 0x481c(%rip), %rdx      # 0xa7bd
leaq 0x8(%rsp), %rdi
callq 0x40ba
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71d7
jmp 0x6474
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x4816(%rip), %rsi      # 0xa7f3
leaq 0x4812(%rip), %rdx      # 0xa7f6
leaq 0x8(%rsp), %rdi
callq 0x40ba
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71d7
jmp 0x6474
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x4526(%rip), %rsi      # 0xa546
leaq 0x4523(%rip), %rdx      # 0xa54a
leaq 0x8(%rsp), %rdi
callq 0x40ba
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71d7
jmp 0x6474
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x49dc(%rip), %rsi      # 0xaa3f
leaq 0x49d9(%rip), %rdx      # 0xaa43
leaq 0x8(%rsp), %rdi
callq 0x40ba
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71d7
jmp 0x6474
testl %eax, %eax
je 0x63b6
movq 0x8(%r14), %rdx
leaq 0x4c03(%rip), %rcx      # 0xacac
movl $0x1a, %r8d
movq %r14, %rdi
xorl %esi, %esi
callq 0x32d0
movl $0x2005, %ebx           # imm = 0x2005
jmp 0x6492
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x450c(%rip), %rsi      # 0xa5df
leaq 0x4508(%rip), %rdx      # 0xa5e2
leaq 0x8(%rsp), %rdi
callq 0x40ba
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71d7
jmp 0x6474
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x4453(%rip), %rsi      # 0xa569
leaq 0x4451(%rip), %rdx      # 0xa56e
leaq 0x8(%rsp), %rdi
callq 0x40ba
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71d7
jmp 0x6474
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x47af(%rip), %rsi      # 0xa908
leaq 0x47ac(%rip), %rdx      # 0xa90c
leaq 0x8(%rsp), %rdi
callq 0x40ba
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71d7
jmp 0x6474
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x45f0(%rip), %rsi      # 0xa78c
leaq 0x45eb(%rip), %rdx      # 0xa78e
leaq 0x8(%rsp), %rdi
callq 0x40ba
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71d7
jmp 0x6474
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x4601(%rip), %rsi      # 0xa7e0
leaq 0x45fd(%rip), %rdx      # 0xa7e3
leaq 0x8(%rsp), %rdi
callq 0x40ba
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71d7
jmp 0x6474
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x43a2(%rip), %rsi      # 0xa5c4
leaq 0x439f(%rip), %rdx      # 0xa5c8
leaq 0x8(%rsp), %rdi
callq 0x40ba
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71d7
jmp 0x6474
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x46cc(%rip), %rsi      # 0xa931
leaq 0x46ca(%rip), %rdx      # 0xa936
leaq 0x8(%rsp), %rdi
callq 0x40ba
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71d7
jmp 0x6474
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x44cd(%rip), %rsi      # 0xa775
leaq 0x44c9(%rip), %rdx      # 0xa778
leaq 0x8(%rsp), %rdi
callq 0x40ba
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71d7
jmp 0x6474
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x44e8(%rip), %rsi      # 0xa7d3
leaq 0x44e3(%rip), %rdx      # 0xa7d5
leaq 0x8(%rsp), %rdi
callq 0x40ba
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71d7
jmp 0x6474
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x4563(%rip), %rsi      # 0xa891
leaq 0x455e(%rip), %rdx      # 0xa893
leaq 0x8(%rsp), %rdi
callq 0x40ba
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71d7
jmp 0x6474
cmpl $0x10, %eax
je 0x6436
cmpl $0x11, %eax
jne 0x609e
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x429d(%rip), %rsi      # 0xa620
leaq 0x429c(%rip), %rdx      # 0xa626
leaq 0x8(%rsp), %rdi
callq 0x40ba
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71d7
jmp 0x6474
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x42b3(%rip), %rsi      # 0xa679
leaq 0x42b0(%rip), %rdx      # 0xa67d
leaq 0x8(%rsp), %rdi
callq 0x40ba
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71d7
jmp 0x6474
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x429d(%rip), %rsi      # 0xa6a3
leaq 0x429a(%rip), %rdx      # 0xa6a7
leaq 0x8(%rsp), %rdi
callq 0x40ba
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71d7
jmp 0x6474
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x427b(%rip), %rsi      # 0xa6c1
leaq 0x427a(%rip), %rdx      # 0xa6c7
leaq 0x8(%rsp), %rdi
callq 0x40ba
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71d7
movl %eax, %ebx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x6492
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x31e0
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x64e3
jmp 0x64e3
jmp 0x64e3
jmp 0x64e3
jmp 0x6528
jmp 0x6528
jmp 0x6528
jmp 0x6528
jmp 0x64e3
jmp 0x64e3
jmp 0x64e3
jmp 0x6528
jmp 0x6528
jmp 0x6528
jmp 0x64e3
jmp 0x64e3
jmp 0x64e3
jmp 0x64e3
jmp 0x64e3
jmp 0x64e3
jmp 0x64e3
jmp 0x64e3
jmp 0x64e3
jmp 0x64e3
jmp 0x64e3
jmp 0x64e3
jmp 0x64e3
jmp 0x64e3
jmp 0x64e3
jmp 0x64e3
jmp 0x64e3
jmp 0x64e3
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x652b
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x31e0
jmp 0x652b
jmp 0x6528
jmp 0x6528
jmp 0x6528
jmp 0x6528
jmp 0x6528
jmp 0x6528
jmp 0x6528
jmp 0x6528
jmp 0x6528
jmp 0x6528
jmp 0x6528
jmp 0x6528
jmp 0x6528
jmp 0x6528
jmp 0x6528
jmp 0x6528
jmp 0x6528
jmp 0x6528
movq %rax, %rbx
movq %rbx, %rdi
callq 0x3330