// File: /workspace/github_cpp_makefile_star2_O1/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 0x60a6
movq %r9, %rbp
movq %r8, %rbx
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r13
movl 0x8(%rdx), %eax
leaq 0x4ebc(%rip), %rdx      # 0xac00
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
cmpl $0xf, %eax
jg 0x6369
testl %eax, %eax
je 0x63fe
cmpl $0x1, %eax
jne 0x60a6
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x487c(%rip), %rsi      # 0xa5f3
leaq 0x4879(%rip), %rdx      # 0xa5f7
leaq 0x8(%rsp), %rdi
callq 0x40c4
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71df
jmp 0x647c
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x49e4(%rip), %rsi      # 0xa79e
leaq 0x49e0(%rip), %rdx      # 0xa7a1
leaq 0x8(%rsp), %rdi
callq 0x40c4
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71df
jmp 0x647c
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x4aa2(%rip), %rsi      # 0xa89f
leaq 0x4a9d(%rip), %rdx      # 0xa8a1
leaq 0x8(%rsp), %rdi
callq 0x40c4
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71df
jmp 0x647c
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x4928(%rip), %rsi      # 0xa768
leaq 0x4923(%rip), %rdx      # 0xa76a
leaq 0x8(%rsp), %rdi
callq 0x40c4
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71df
jmp 0x647c
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x4bbd(%rip), %rsi      # 0xaa40
leaq 0x4bb9(%rip), %rdx      # 0xaa43
leaq 0x8(%rsp), %rdi
callq 0x40c4
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71df
jmp 0x647c
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x4824(%rip), %rsi      # 0xa6ea
leaq 0x4820(%rip), %rdx      # 0xa6ed
leaq 0x8(%rsp), %rdi
callq 0x40c4
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71df
jmp 0x647c
testl %eax, %eax
jne 0x60a6
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x4747(%rip), %rsi      # 0xa658
leaq 0x4744(%rip), %rdx      # 0xa65c
leaq 0x8(%rsp), %rdi
callq 0x40c4
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71df
jmp 0x647c
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x4ac4(%rip), %rsi      # 0xaa18
leaq 0x4abf(%rip), %rdx      # 0xaa1a
leaq 0x8(%rsp), %rdi
callq 0x40c4
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71df
jmp 0x647c
cmpl $0x0, 0x4(%r15)
jne 0x60a6
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x4818(%rip), %rsi      # 0xa7ba
leaq 0x4814(%rip), %rdx      # 0xa7bd
leaq 0x8(%rsp), %rdi
callq 0x40c4
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71df
jmp 0x647c
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x480e(%rip), %rsi      # 0xa7f3
leaq 0x480a(%rip), %rdx      # 0xa7f6
leaq 0x8(%rsp), %rdi
callq 0x40c4
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71df
jmp 0x647c
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x451e(%rip), %rsi      # 0xa546
leaq 0x451b(%rip), %rdx      # 0xa54a
leaq 0x8(%rsp), %rdi
callq 0x40c4
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71df
jmp 0x647c
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x49d4(%rip), %rsi      # 0xaa3f
leaq 0x49d1(%rip), %rdx      # 0xaa43
leaq 0x8(%rsp), %rdi
callq 0x40c4
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71df
jmp 0x647c
testl %eax, %eax
je 0x63be
movq 0x8(%r14), %rdx
leaq 0x4bfb(%rip), %rcx      # 0xacac
movl $0x1a, %r8d
movq %r14, %rdi
xorl %esi, %esi
callq 0x32d0
movl $0x2005, %ebx           # imm = 0x2005
jmp 0x649a
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x4504(%rip), %rsi      # 0xa5df
leaq 0x4500(%rip), %rdx      # 0xa5e2
leaq 0x8(%rsp), %rdi
callq 0x40c4
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71df
jmp 0x647c
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x444b(%rip), %rsi      # 0xa569
leaq 0x4449(%rip), %rdx      # 0xa56e
leaq 0x8(%rsp), %rdi
callq 0x40c4
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71df
jmp 0x647c
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x47a7(%rip), %rsi      # 0xa908
leaq 0x47a4(%rip), %rdx      # 0xa90c
leaq 0x8(%rsp), %rdi
callq 0x40c4
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71df
jmp 0x647c
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x45e8(%rip), %rsi      # 0xa78c
leaq 0x45e3(%rip), %rdx      # 0xa78e
leaq 0x8(%rsp), %rdi
callq 0x40c4
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71df
jmp 0x647c
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x45f9(%rip), %rsi      # 0xa7e0
leaq 0x45f5(%rip), %rdx      # 0xa7e3
leaq 0x8(%rsp), %rdi
callq 0x40c4
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71df
jmp 0x647c
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x439a(%rip), %rsi      # 0xa5c4
leaq 0x4397(%rip), %rdx      # 0xa5c8
leaq 0x8(%rsp), %rdi
callq 0x40c4
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71df
jmp 0x647c
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x46c4(%rip), %rsi      # 0xa931
leaq 0x46c2(%rip), %rdx      # 0xa936
leaq 0x8(%rsp), %rdi
callq 0x40c4
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71df
jmp 0x647c
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x44c5(%rip), %rsi      # 0xa775
leaq 0x44c1(%rip), %rdx      # 0xa778
leaq 0x8(%rsp), %rdi
callq 0x40c4
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71df
jmp 0x647c
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x44e0(%rip), %rsi      # 0xa7d3
leaq 0x44db(%rip), %rdx      # 0xa7d5
leaq 0x8(%rsp), %rdi
callq 0x40c4
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71df
jmp 0x647c
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x455b(%rip), %rsi      # 0xa891
leaq 0x4556(%rip), %rdx      # 0xa893
leaq 0x8(%rsp), %rdi
callq 0x40c4
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71df
jmp 0x647c
cmpl $0x10, %eax
je 0x643e
cmpl $0x11, %eax
jne 0x60a6
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x4295(%rip), %rsi      # 0xa620
leaq 0x4294(%rip), %rdx      # 0xa626
leaq 0x8(%rsp), %rdi
callq 0x40c4
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71df
jmp 0x647c
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x42ab(%rip), %rsi      # 0xa679
leaq 0x42a8(%rip), %rdx      # 0xa67d
leaq 0x8(%rsp), %rdi
callq 0x40c4
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71df
jmp 0x647c
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x4295(%rip), %rsi      # 0xa6a3
leaq 0x4292(%rip), %rdx      # 0xa6a7
leaq 0x8(%rsp), %rdi
callq 0x40c4
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71df
jmp 0x647c
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x4273(%rip), %rsi      # 0xa6c1
leaq 0x4272(%rip), %rdx      # 0xa6c7
leaq 0x8(%rsp), %rdi
callq 0x40c4
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %rbx, %r9
callq 0x71df
movl %eax, %ebx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x649a
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 0x64eb
jmp 0x64eb
jmp 0x64eb
jmp 0x64eb
jmp 0x6530
jmp 0x6530
jmp 0x6530
jmp 0x6530
jmp 0x64eb
jmp 0x64eb
jmp 0x64eb
jmp 0x6530
jmp 0x6530
jmp 0x6530
jmp 0x64eb
jmp 0x64eb
jmp 0x64eb
jmp 0x64eb
jmp 0x64eb
jmp 0x64eb
jmp 0x64eb
jmp 0x64eb
jmp 0x64eb
jmp 0x64eb
jmp 0x64eb
jmp 0x64eb
jmp 0x64eb
jmp 0x64eb
jmp 0x64eb
jmp 0x64eb
jmp 0x64eb
jmp 0x64eb
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x6533
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x31e0
jmp 0x6533
jmp 0x6530
jmp 0x6530
jmp 0x6530
jmp 0x6530
jmp 0x6530
jmp 0x6530
jmp 0x6530
jmp 0x6530
jmp 0x6530
jmp 0x6530
jmp 0x6530
jmp 0x6530
jmp 0x6530
jmp 0x6530
jmp 0x6530
jmp 0x6530
jmp 0x6530
jmp 0x6530
movq %rax, %rbx
movq %rbx, %rdi
callq 0x3330