// File: /workspace/github_cpp_makefile_star2_O2/martinferianc[P]CPUSimulator-EIE2/src/test_mips.cpp
// Function: load_instructions(std::vector<test, std::allocator<test>>&)
mips_error load_instructions(vector<test>& instructions){
  ifstream file;
  file.open("mips_cpu_instructions.txt");
  test temp;
  string t1, t2, t3, t4, t5;
  while(file >> t1 >> t2 >> t3 >> t4 >> t5){
    stringstream ss;
    ss << std::hex << t1;
    ss >> temp.instruction_code;
    //Change the endianness
    temp.instruction_code =
      uint32_t((temp.instruction_code & 0x000000FF) << 24) |
      uint32_t((temp.instruction_code & 0x0000FF00) << 8) |
      uint32_t((temp.instruction_code & 0x00FF0000) >> 8) |
      uint32_t((temp.instruction_code & 0xFF000000) >> 24);
    temp.instruction_name = t2;
    temp.instruction_r1 = atoi(t3.c_str());
    temp.instruction_r2 = atoi(t4.c_str());
    temp.instruction_result = atoi(t5.c_str());
    instructions.push_back(temp);
  }
  file.close();
  return mips_Success;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x468, %rsp            # imm = 0x468
movq %rdi, %r14
leaq 0x260(%rsp), %rbx
movq %rbx, %rdi
callq 0x3200
leaq 0x28fb(%rip), %rsi      # 0x9dbe
pushq $0x8
popq %rdx
movq %rbx, %rdi
callq 0x3110
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
leaq 0xc8(%rsp), %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
xorl %edx, %edx
movb %dl, (%rax)
leaq 0xa8(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
leaq 0x88(%rsp), %rsi
movq %rsi, -0x10(%rsi)
andq $0x0, -0x8(%rsi)
movb %dl, (%rcx)
movb %dl, (%rax)
leaq 0x68(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
leaq 0x48(%rsp), %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
movb %dl, (%rsi)
movb %dl, (%rax)
movb %dl, (%rcx)
leaq 0xb8(%rsp), %r13
leaq 0x98(%rsp), %rbp
leaq 0x38(%rsp), %r12
leaq 0xd8(%rsp), %rbx
movq %rsp, %r15
leaq 0x260(%rsp), %rdi
movq %r13, %rsi
callq 0x3260
movq %rax, %rdi
movq %rbp, %rsi
callq 0x3260
movq %rax, %rdi
leaq 0x78(%rsp), %rsi
callq 0x3260
movq %rax, %rdi
leaq 0x58(%rsp), %rsi
callq 0x3260
movq %rax, %rdi
movq %r12, %rsi
callq 0x3260
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x7645
movq %rbx, %rdi
callq 0x3140
movq 0xe8(%rsp), %rax
movq -0x18(%rax), %rax
movl 0x100(%rsp,%rax), %ecx
andl $-0x4b, %ecx
orl $0x8, %ecx
movl %ecx, 0x100(%rsp,%rax)
leaq 0xe8(%rsp), %rdi
movq %r13, %rsi
callq 0x31b0
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3320
movl (%rsp), %eax
bswapl %eax
movl %eax, (%rsp)
leaq 0x8(%rsp), %rdi
movq %rbp, %rsi
callq 0x3100
movq 0x78(%rsp), %rdi
callq 0x32e0
movl %eax, 0x2c(%rsp)
movq 0x58(%rsp), %rdi
callq 0x32e0
movl %eax, 0x30(%rsp)
movq 0x38(%rsp), %rdi
callq 0x32e0
movl %eax, 0x28(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x817a
movq %rbx, %rdi
callq 0x3160
jmp 0x7559
leaq 0x260(%rsp), %rdi
callq 0x3060
leaq 0x38(%rsp), %rdi
callq 0x30d0
leaq 0x58(%rsp), %rdi
callq 0x30d0
leaq 0x78(%rsp), %rdi
callq 0x30d0
leaq 0x98(%rsp), %rdi
callq 0x30d0
leaq 0xb8(%rsp), %rdi
callq 0x30d0
leaq 0x8(%rsp), %rdi
callq 0x30d0
leaq 0x260(%rsp), %rdi
callq 0x3070
xorl %eax, %eax
addq $0x468, %rsp            # imm = 0x468
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x76d0
movq %rax, %rbx
jmp 0x7715
jmp 0x76d0
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
callq 0x3160
jmp 0x76d3
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x30d0
leaq 0x58(%rsp), %rdi
callq 0x30d0
leaq 0x78(%rsp), %rdi
callq 0x30d0
leaq 0x98(%rsp), %rdi
callq 0x30d0
leaq 0xb8(%rsp), %rdi
callq 0x30d0
leaq 0x8(%rsp), %rdi
callq 0x30d0
leaq 0x260(%rsp), %rdi
callq 0x3070
movq %rbx, %rdi
callq 0x3330