LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O1/rohitrangan[P]3PC/src/message.cpp
// Function: Message::createMessage[abi:cxx11]()
std::string Message::createMessage ()
{
    std::stringstream s;
    s << message_strings[message] << DELIM << transaction_id;
    s << DELIM << site_id << DELIM << failed_id;
    return s.str ();
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x190, %rsp            # imm = 0x190
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x8(%rsp), %rdi
callq 0x2190
leaq 0x18(%rsp), %r15
movl (%r14), %eax
shlq $0x5, %rax
leaq 0x53e1(%rip), %rcx      # 0xc240
movq (%rax,%rcx), %rsi
movq 0x8(%rax,%rcx), %rdx
movq %r15, %rdi
callq 0x22d0
leaq 0x7(%rsp), %rsi
movb $0x2c, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x22d0
movl 0x4(%r14), %esi
movq %rax, %rdi
callq 0x23b0
leaq 0x7(%rsp), %rsi
movb $0x2c, (%rsi)
movl $0x1, %edx
movq %r15, %rdi
callq 0x22d0
movl 0x8(%r14), %esi
movq %rax, %rdi
callq 0x23b0
leaq 0x7(%rsp), %rsi
movb $0x2c, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x22d0
movl 0xc(%r14), %esi
movq %rax, %rdi
callq 0x23b0
leaq 0x20(%rsp), %rsi
movq %rbx, %rdi
callq 0x2390
movq 0x50d1(%rip), %rsi      # 0xbfb8
leaq 0x8(%rsp), %rdi
callq 0x21c0
leaq 0x88(%rsp), %rdi
callq 0x20d0
movq %rbx, %rax
addq $0x190, %rsp            # imm = 0x190
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %rbx
movq 0x50a0(%rip), %rsi      # 0xbfb8
leaq 0x8(%rsp), %rdi
callq 0x21c0
leaq 0x88(%rsp), %rdi
callq 0x20d0
movq %rbx, %rdi
callq 0x23c0
nop
// File: /workspace/github_cpp_makefile_star2_O1/rohitrangan[P]3PC/src/message.cpp
// Function: Message::messageIndex(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
message_id Message::messageIndex (std::string message_str)
{
    for (int i = 0; i < NUM_MESSAGES; ++i)
    {
        if (message_strings[i] == message_str)
            return (message_id) i;
    }
    return ERROR;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq 0x8(%rsi), %r15
leaq 0x52fa(%rip), %r12      # 0xc248
xorl %r14d, %r14d
movq (%r12), %rdx
cmpq %r15, %rdx
jne 0x6f70
testq %rdx, %rdx
je 0x6f83
movq (%rbx), %rsi
movq -0x8(%r12), %rdi
callq 0x2280
testl %eax, %eax
je 0x6f83
incq %r14
addq $0x20, %r12
cmpq $0xa, %r14
jne 0x6f51
movl $0xa, %r14d
cmpl $0x9, %r14d
movl $0x9, %eax
cmovbl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/amukherj[P]concurrencyts/./barrier.h
// Function: concurrencyts::barrier_base<concurrencyts::flex_barrier>::arrive_and_wait()
void arrive_and_wait() {
    std::unique_lock<std::mutex> ul{lock};
    allow.wait(ul, [this]()->bool { return count > 0; });
  
    if (--count == 0) {
      ul.unlock();

      auto ffunc = static_cast<T*>(this)->final_func();
      if (ffunc) {
        // run the completion block
        auto tmp_count = ffunc();
        if (tmp_count >= 0) {
          // readjust max_count for next phase of barrier.
          max_count = tmp_count;
        }
      }

      // release all waiting threads
      done.notify_all();
    } else {
      done.wait(ul, [this]()->bool { return count == 0; });
      ul.unlock();
    }
  
    ul.lock();
    if (++released_count == max_count) {
      count = max_count;
      released_count = 0;
      ul.unlock();
      // allow all waiting threads
      allow.notify_all();
    }
  }

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r14
leaq 0x8(%rdi), %rax
leaq 0x8(%rsp), %rbx
movq %rax, (%rbx)
movb $0x0, 0x8(%rbx)
movq %rbx, %rdi
callq 0x281a
movb $0x1, 0x8(%rbx)
leaq 0x30(%r14), %rbx
cmpq $0x0, 0x90(%r14)
jne 0x2716
leaq 0x8(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2050
cmpq $0x0, 0x90(%r14)
je 0x2701
decq 0x90(%r14)
je 0x2749
leaq 0x60(%r14), %r15
leaq 0x8(%rsp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x2050
cmpq $0x0, 0x90(%r14)
jne 0x2728
leaq 0x8(%rsp), %rdi
callq 0x27f2
jmp 0x2773
leaq 0x8(%rsp), %rdi
callq 0x27f2
movq 0xa0(%r14), %rax
testq %rax, %rax
je 0x276a
callq *%rax
testl %eax, %eax
js 0x276a
movl %eax, %eax
movq %rax, (%r14)
leaq 0x60(%r14), %rdi
callq 0x2130
leaq 0x8(%rsp), %rdi
callq 0x281a
movq (%r14), %rax
movq 0x98(%r14), %rcx
incq %rcx
movq %rcx, 0x98(%r14)
cmpq %rax, %rcx
jne 0x27ba
movq %rax, 0x90(%r14)
movq $0x0, 0x98(%r14)
leaq 0x8(%rsp), %rdi
callq 0x27f2
movq %rbx, %rdi
callq 0x2130
leaq 0x8(%rsp), %rdi
callq 0x2856
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
jmp 0x27d2
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x2856
movq %rbx, %rdi
callq 0x2170
// File: /workspace/github_cpp_makefile_star2_O1/ArashPartow[P]exprtk-extras/exprtk_vector_benchmark.cpp
// Function: main
int main(int argc, char* argv[])
{
   const std::size_t vec_size  = ((argc >= 2) ? atoi(argv[1]) : 100000);
   const std::string file_name = ((argc >  3) ? argv[2] : ""          );

   switch (argc)
   {
      case 2 : run_benchmark     <numeric_type>(vec_size          ); break;
      case 3 : run_file_benchmark<numeric_type>(vec_size,file_name); break;
   }

   return 0;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r14
movl %edi, %ebx
movl $0x186a0, %eax          # imm = 0x186A0
cmpl $0x2, %edi
jl 0x11d5bd
movq 0x8(%r14), %rdi
callq 0x118190
cltq
movq %rax, 0x10(%rsp)
cmpl $0x4, %ebx
jl 0x11d5cd
movq 0x10(%r14), %rsi
jmp 0x11d5d4
leaq 0x1b868b(%rip), %rsi    # 0x2d5c5f
leaq 0x18(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x11d6fc
cmpl $0x3, %ebx
je 0x11d5f9
cmpl $0x2, %ebx
jne 0x11d608
leaq 0x10(%rsp), %rdi
callq 0x11d739
jmp 0x11d608
leaq 0x10(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x11d7f0
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x11d623
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x1180c0
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r14
retq
movq %rax, %rbx
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x11d64b
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x1180c0
movq %rbx, %rdi
callq 0x118330
// File: /workspace/github_cpp_makefile_star2_O1/ArashPartow[P]exprtk-extras/exprtk_vector_benchmark.cpp
// Function: void run_benchmark<double>(unsigned long const&)
void run_benchmark(const std::size_t& vec_size)
{
   T total_time = 0.0;

   for (std::size_t i = 0; i < global_expression_list_size; ++i)
   {
      total_time +=
      run_expression_benchmark<T>(vec_size,
                                  global_expression_list[i].e,
                                  global_expression_list[i].cost);
   }

   unsigned long long total_flops = 0;

   for (std::size_t i = 0; i < global_expression_list_size; ++i)
   {
      total_flops += global_expression_list[i].cost;
   }

   total_flops *= (rounds * vec_size);

   printf("Total Time:%10.7f FLOP: %llu Perf: %7.4fGFLOPS\n",
          total_time,
          total_flops,
          total_flops / (1e9 * total_time));
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
xorpd %xmm2, %xmm2
movl $0x28, %r15d
leaq 0x32a6ba(%rip), %r14    # 0x447e10
movsd %xmm2, 0x8(%rsp)
movq (%rbx), %rdi
leaq 0x8(%r14), %rsi
movq %r14, %rdx
callq 0x11daca
movsd 0x8(%rsp), %xmm2
addsd %xmm0, %xmm2
addq $0x28, %r14
decq %r15
jne 0x11d756
xorl %eax, %eax
leaq 0x32a689(%rip), %rdx    # 0x447e10
xorl %ecx, %ecx
addq (%rax,%rdx), %rcx
addq $0x28, %rax
cmpq $0x640, %rax            # imm = 0x640
jne 0x11d789
imulq (%rbx), %rcx
imulq $0x7d0, %rcx, %rsi      # imm = 0x7D0
movq %rsi, %xmm0
punpckldq 0x1b385f(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1b3867(%rip), %xmm0   # 0x2d1020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd 0x1b3913(%rip), %xmm0   # 0x2d10e0
mulsd %xmm2, %xmm0
divsd %xmm0, %xmm1
leaq 0x1b8454(%rip), %rdi    # 0x2d5c30
movapd %xmm2, %xmm0
movb $0x2, %al
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
jmp 0x118080
// File: /workspace/github_cpp_makefile_star2_O1/ArashPartow[P]exprtk-extras/exprtk_vector_benchmark.cpp
// Function: void run_file_benchmark<double>(unsigned long const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void run_file_benchmark(const std::size_t& vec_size, const std::string& file_name)
{
   std::ifstream stream(file_name.c_str());

   if (!stream)
   {
      printf("run_file_benchmark() - Failed to open file: %s\n",
             file_name.c_str());
      return;
   }

   std::string line;
   std::vector<std::string> expr_list;

   while (std::getline(stream, line))
   {
      if (line.empty())
         continue;
      else if ('#' == line[0])
         continue;

      expr_list.push_back(line);
   }

   T total_time = T(0);

   for (std::size_t i = 0; i < expr_list.size(); ++i)
   {
      total_time += run_expression_benchmark<T>(vec_size,expr_list[i],0);
   }

   printf("Total Time:%10.7f\n", total_time);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x250, %rsp            # imm = 0x250
movq %rsi, %r15
movq %rdi, %rbx
movq (%rsi), %rsi
leaq 0x48(%rsp), %r14
movq %r14, %rdi
movl $0x8, %edx
callq 0x118050
movq (%r14), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x68(%rsp,%rax)
je 0x11d83f
movq (%r15), %rsi
leaq 0x1bd18a(%rip), %rdi    # 0x2da9bd
xorl %eax, %eax
callq 0x118080
jmp 0x11d94d
leaq 0x38(%rsp), %r13
movq %r13, -0x10(%r13)
xorl %eax, %eax
movq %rax, -0x8(%r13)
movb $0x0, (%r13)
movq %rsp, %r15
movq %rax, 0x10(%r15)
xorpd %xmm0, %xmm0
movapd %xmm0, (%r15)
leaq 0x28(%rsp), %r12
movq 0x48(%rsp), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x118520
movsbl %al, %edx
movq %r14, %rdi
movq %r12, %rsi
callq 0x118030
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x11d8b9
cmpq $0x0, 0x30(%rsp)
je 0x11d868
movq 0x28(%rsp), %rax
cmpb $0x23, (%rax)
je 0x11d868
movq %r15, %rdi
movq %r12, %rsi
callq 0x298c66
jmp 0x11d868
movq (%rsp), %rsi
cmpq %rsi, 0x8(%rsp)
je 0x11d91c
xorpd %xmm0, %xmm0
xorl %r15d, %r15d
leaq 0x20(%rsp), %r14
xorl %r12d, %r12d
movsd %xmm0, 0x18(%rsp)
movq (%rbx), %rdi
addq %r15, %rsi
movq $0x0, 0x20(%rsp)
movq %r14, %rdx
callq 0x11daca
movsd 0x18(%rsp), %xmm1
addsd %xmm0, %xmm1
movapd %xmm1, %xmm0
incq %r12
movq (%rsp), %rsi
movq 0x8(%rsp), %rax
subq %rsi, %rax
sarq $0x5, %rax
addq $0x20, %r15
cmpq %rax, %r12
jb 0x11d8d3
jmp 0x11d920
xorpd %xmm0, %xmm0
leaq 0x1bd0c6(%rip), %rdi    # 0x2da9ed
movb $0x1, %al
callq 0x118080
movq %rsp, %rdi
callq 0x19fc4e
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x11d94d
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x1180c0
leaq 0x48(%rsp), %rdi
callq 0x118040
addq $0x250, %rsp            # imm = 0x250
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
jmp 0x11d96a
movq %rax, %rbx
movq %rsp, %rdi
callq 0x19fc4e
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x11d98c
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x1180c0
leaq 0x48(%rsp), %rdi
callq 0x118040
movq %rbx, %rdi
callq 0x118330
// File: /workspace/github_cpp_makefile_star2_O1/martinferianc[P]CPUSimulator-EIE2/src/shared/mips_test_framework.cpp
// Function: mips_test_begin_suite
void mips_test_begin_suite()
{
    if(sg_started){
        fprintf(stderr, "Error:mips_test_begin_suite - Test suite has already been started\n");
        exit(1);
    }
    
    // Build up a list of known instruction names
    for(unsigned i=0; i<sg_instructionsCount; i++){
        sg_knownInstructions.insert(std::string(sg_instructionsArray[i].instruction));
    }
    
    sg_started=true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
cmpb $0x0, 0xba8f(%rip)      # 0xf220
jne 0x3808
leaq 0x18(%rsp), %r12
xorl %r13d, %r13d
leaq 0xb29e(%rip), %rbp      # 0xea40
leaq 0x8(%rsp), %rbx
leaq 0x7(%rsp), %r14
leaq 0xba3d(%rip), %r15      # 0xf1f0
movq (%r13,%rbp), %rsi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x3e54
movq %r15, %rdi
movq %rbx, %rsi
callq 0x4154
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x37e5
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x31e0
addq $0x10, %r13
cmpq $0x360, %r13            # imm = 0x360
jne 0x37b3
movb $0x1, 0xba27(%rip)      # 0xf220
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x3380
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x3827
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x31e0
movq %rbx, %rdi
callq 0x3330
// File: /workspace/github_cpp_makefile_star2_O1/martinferianc[P]CPUSimulator-EIE2/src/shared/mips_test_framework.cpp
// Function: mips_test_begin_test
int mips_test_begin_test(const char *instruction)
{
    if(!sg_started){
        fprintf(stderr, "Error:mips_test_begin_test - Test suite has not been started with mips_test_begin_suite.\n");
        exit(1);
    }
    
    if(sg_tests.size()>0){
        if(sg_tests.back().status == -1){
            fprintf(stderr, "Error:mips_test_begin_test - Attempt to start new test of '%s', but previous test with id %u has not been completed.\n", instruction, sg_tests.back().testId);
            exit(1);
        }
    }
    
    int testId=sg_tests.size();
    
    test_info_t info;
    info.testId=testId;
    
    info.instruction=instruction; // We want the string in upper case (shouting!)
    std::transform(info.instruction.begin(), info.instruction.end(), info.instruction.begin(), ::toupper);
    
    if(sg_knownInstructions.find(info.instruction)==sg_knownInstructions.end()){
        fprintf(stderr, "Warning:mips_test_begin_test - Unknown instruction '%s', might want to check the spelling.\n", instruction);
    }
    
    info.status=-1;
    sg_tests.push_back(info);
    
    return testId;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
cmpb $0x0, 0xb9dc(%rip)      # 0xf220
je 0x3982
movq %rdi, %r14
movq 0xb98c(%rip), %rdi      # 0xf1e0
movq 0xb97d(%rip), %rcx      # 0xf1d8
movq %rdi, %rax
subq %rcx, %rax
je 0x386d
cmpl $-0x1, -0x28(%rdi)
je 0x3987
sarq $0x4, %rax
movabsq $-0x3333333333333333, %rbx # imm = 0xCCCCCCCCCCCCCCCD
imulq %rax, %rbx
leaq 0x10(%rsp), %r15
leaq 0x20(%rsp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x48(%rsp), %r13
movq %r13, -0x10(%r13)
movq %rax, -0x8(%r13)
movb %al, (%r13)
movl %ebx, -0x40(%r13)
movq %r14, %rdi
callq 0x30e0
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
movq %r14, %rcx
movq %rax, %r8
callq 0x32d0
movq 0x18(%rsp), %rbp
testq %rbp, %rbp
je 0x38ec
movq 0x10(%rsp), %r15
xorl %r12d, %r12d
movsbl (%r15,%r12), %edi
callq 0x3350
movb %al, (%r15,%r12)
incq %r12
cmpq %r12, %rbp
jne 0x38d6
leaq 0xb8fd(%rip), %rdi      # 0xf1f0
leaq 0x10(%rsp), %rsi
callq 0x42e6
leaq 0xb8f4(%rip), %rcx      # 0xf1f8
cmpq %rcx, %rax
leaq 0x20(%rsp), %r15
je 0x3965
leaq 0x8(%rsp), %rsi
movl $0xffffffff, 0x28(%rsi) # imm = 0xFFFFFFFF
leaq 0xb8b7(%rip), %rdi      # 0xf1d8
callq 0x3e92
movq 0x38(%rsp), %rdi
cmpq %r13, %rdi
je 0x393d
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x31e0
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x3954
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x31e0
movl %ebx, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xb664(%rip), %rax      # 0xefd0
movq (%rax), %rdi
leaq 0x67ad(%rip), %rsi      # 0xa123
movq %r14, %rdx
xorl %eax, %eax
callq 0x32a0
jmp 0x390e
callq 0x33a5
movq %r14, %rsi
callq 0x33ca
jmp 0x3991
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x3ebc
movq %rbx, %rdi
callq 0x3330
// File: /workspace/github_cpp_makefile_star2_O1/martinferianc[P]CPUSimulator-EIE2/src/shared/mips_test_framework.cpp
// Function: mips_test_end_test
void mips_test_end_test(int testId, int passed, const char *msg)
{
    if(!sg_started){
        fprintf(stderr, "Error:mips_test_finish_test - Test suite has not been started with mips_test_begin_suite.");
        exit(1);
    }
    
    if(sg_tests.size()==0){
        fprintf(stderr, "Error:mips_test_finish_test - No tests have been started.\n");
        exit(1);
    }
    if(sg_tests.back().testId!=testId){
        fprintf(stderr, "Error:mips_test_finish_test - Attempt to finish test %u, but last test started was %u.\n", testId, sg_tests.back().testId);
        exit(1);
    }
    if(sg_tests.back().status!=-1){
        fprintf(stderr, "Error:mips_test_finish_test - Attempt to finish test %u, but it already finished with status %u.\n", testId, sg_tests.back().status);
        exit(1);  
    }
    
    sg_tests.back().status=passed ? 1 : 0;
    if(msg){
        sg_tests.back().message=msg;
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
cmpb $0x0, 0xb86e(%rip)      # 0xf220
je 0x3a16
movq 0xb825(%rip), %r14      # 0xf1e0
cmpq 0xb816(%rip), %r14      # 0xf1d8
je 0x3a1b
movl -0x50(%r14), %eax
cmpl %edi, %eax
jne 0x3a20
movl -0x28(%r14), %eax
cmpl $-0x1, %eax
jne 0x3a27
movq %rdx, %rbx
xorl %eax, %eax
testl %esi, %esi
setne %al
movl %eax, -0x28(%r14)
testq %rdx, %rdx
je 0x3a10
movq -0x18(%r14), %r15
addq $-0x20, %r14
movq %rbx, %rdi
callq 0x30e0
movq %r14, %rdi
xorl %esi, %esi
movq %r15, %rdx
movq %rbx, %rcx
movq %rax, %r8
popq %rbx
popq %r14
popq %r15
jmp 0x32d0
popq %rbx
popq %r14
popq %r15
retq
callq 0x33f4
callq 0x3463
movl %eax, %esi
callq 0x3419
movl %eax, %esi
callq 0x343e
// File: /workspace/github_cpp_makefile_star2_O1/martinferianc[P]CPUSimulator-EIE2/src/shared/mips_mem_ram.cpp
// Function: mips_mem_create_ram
mips_mem_h mips_mem_create_ram(
                                          uint32_t cbMem	//!< Total number of bytes of ram
){
    if(cbMem>0x20000000){
        return 0; // No more than 512MB of RAM
    }
    
    uint8_t *data=(uint8_t*)malloc(cbMem);
    if(data==0)
        return 0;
    
    struct mips_mem_provider *mem=(struct mips_mem_provider*)malloc(sizeof(struct mips_mem_provider));
    if(mem==0){
        free(data);
        return 0;
    }
    
    mem->length=cbMem;
    mem->data=data;
    
    return mem;
}

// Assembly:
cmpl $0x20000000, %edi       # imm = 0x20000000
jbe 0x4a9b
xorl %eax, %eax
retq
pushq %r14
pushq %rbx
pushq %rax
movl %edi, %ebx
movl %edi, %edi
callq 0x3290
testq %rax, %rax
je 0x4acf
movq %rax, %r14
movl $0x10, %edi
callq 0x3290
testq %rax, %rax
je 0x4ac7
movl %ebx, (%rax)
movq %r14, 0x8(%rax)
jmp 0x4ad1
movq %r14, %rdi
callq 0x3230
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O1/martinferianc[P]CPUSimulator-EIE2/src/shared/mips_mem_ram.cpp
// Function: mips_mem_read_write(bool, mips_mem_provider*, unsigned int, unsigned int, unsigned char*)
static mips_error mips_mem_read_write(
                                      bool write,
                                      mips_mem_h mem,
                                      uint32_t address,
                                      uint32_t length,
                                      uint8_t *dataOut
                                      )
{
    if(mem==0){
        return mips_ErrorInvalidHandle;
    }
    
    if( (length!=1) && (length!=2) && (length!=4) ){
        return mips_ExceptionInvalidLength;
    }
    
    if(0 != (address % length) ){
        return mips_ExceptionInvalidAlignment;
    }
    if(((address+length) > mem->length) || (address > (UINT32_MAX - length))){	// A subtle bug here, maybe?
        return mips_ExceptionInvalidAddress;
    }
    
    if(write){
        for(unsigned i=0; i<length; i++){
            mem->data[address+i]=dataOut[i];
        }
    }else{
        for(unsigned i=0; i<length; i++){
            dataOut[i]=mem->data[address+i];
        }
    }
    return mips_Success;
}

// Assembly:
testq %rsi, %rsi
je 0x4b14
movl $0x2001, %eax           # imm = 0x2001
cmpl $0x4, %ecx
ja 0x4b13
movl %edx, %r9d
movl $0x16, %edx
btl %ecx, %edx
jae 0x4b13
movl %r9d, %eax
xorl %edx, %edx
divl %ecx
movl $0x2003, %eax           # imm = 0x2003
testl %edx, %edx
je 0x4b1a
retq
movl $0x1002, %eax           # imm = 0x1002
retq
movl %ecx, %edx
movl $0x2002, %eax           # imm = 0x2002
addl %r9d, %edx
jb 0x4b13
cmpl (%rsi), %edx
ja 0x4b13
cmpl $0x1, %ecx
adcl $0x0, %ecx
movl %r9d, %edx
xorl %eax, %eax
testb %dil, %dil
je 0x4b56
xorl %edi, %edi
movb (%r8,%rdi), %r9b
movq 0x8(%rsi), %r10
leal (%rdx,%rdi), %r11d
movb %r9b, (%r10,%r11)
incq %rdi
cmpq %rdi, %rcx
jne 0x4b3c
jmp 0x4b13
xorl %edi, %edi
movq 0x8(%rsi), %r9
leal (%rdx,%rdi), %r10d
movb (%r9,%r10), %r9b
movb %r9b, (%r8,%rdi)
incq %rdi
cmpq %rdi, %rcx
jne 0x4b58
jmp 0x4b13
// File: /workspace/github_cpp_makefile_star2_O1/martinferianc[P]CPUSimulator-EIE2/src/shared/mips_mem_ram.cpp
// Function: mips_mem_free
void mips_mem_free(mips_mem_h mem)
{
    if(mem){
        free(mem->data);
        mem->data=0;
        free(mem);
    }
}

// Assembly:
testq %rdi, %rdi
je 0x4ba9
pushq %rbx
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
callq 0x3230
movq $0x0, 0x8(%rbx)
movq %rbx, %rdi
popq %rbx
jmp 0x3230
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/martinferianc[P]CPUSimulator-EIE2/src/mips_cpu.cpp
// Function: mips_cpu_create
mips_cpu_h mips_cpu_create(mips_mem_h mem){
	if (mem==0)
		return NULL;

	mips_cpu_h state = new mips_cpu_impl;
	state->hi = 0;
	state->lo = 0;
	state->pc = 0;
	state->pcN = 4;
	state->mem=mem;
	for (unsigned i = 0; i < 32; ++i)
		state->regs[i]=0;

	return state;
}

// Assembly:
testq %rdi, %rdi
je 0x4bf8
pushq %rbx
movq %rdi, %rbx
movl $0xa8, %edi
callq 0x31d0
movaps 0x5eea(%rip), %xmm0     # 0xaab0
movups %xmm0, (%rax)
movq %rbx, 0xa0(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x30(%rax)
movups %xmm0, 0x40(%rax)
movups %xmm0, 0x50(%rax)
movups %xmm0, 0x60(%rax)
movups %xmm0, 0x70(%rax)
movups %xmm0, 0x80(%rax)
popq %rbx
retq
xorl %eax, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O1/martinferianc[P]CPUSimulator-EIE2/src/mips_cpu.cpp
// Function: mips_cpu_reset
mips_error mips_cpu_reset(mips_cpu_h state){
	if (state==0)
		return mips_ErrorInvalidHandle;

	state->pc = 0;
	state->pcN = 4;
	state->hi = 0;
	state->lo = 0;
	for (unsigned i = 0; i < 32; ++i)
		state->regs[i]=0;

	return mips_Success;
}

// Assembly:
testq %rdi, %rdi
je 0x4c3e
movq $0x0, (%rdi)
movabsq $0x400000000, %rax      # imm = 0x400000000
movq %rax, 0x8(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rdi)
movups %xmm0, 0x20(%rdi)
movups %xmm0, 0x30(%rdi)
movups %xmm0, 0x40(%rdi)
movups %xmm0, 0x50(%rdi)
movups %xmm0, 0x60(%rdi)
movups %xmm0, 0x70(%rdi)
movups %xmm0, 0x80(%rdi)
xorl %eax, %eax
retq
movl $0x1002, %eax           # imm = 0x1002
retq
// File: /workspace/github_cpp_makefile_star2_O1/martinferianc[P]CPUSimulator-EIE2/src/mips_cpu.cpp
// Function: mips_cpu_set_register
mips_error mips_cpu_set_register(mips_cpu_h state, unsigned index, uint32_t value){
	if(state==0)
		return mips_ErrorInvalidHandle;

	if(index>31)
		return mips_ErrorInvalidArgument;

	if(index!=0)
		state->regs[index]=value;

	return mips_Success;
}

// Assembly:
testq %rdi, %rdi
je 0x4c80
movl $0x1001, %eax           # imm = 0x1001
cmpl $0x1f, %esi
ja 0x4c7f
xorl %eax, %eax
testl %esi, %esi
je 0x4c7f
movl %esi, %ecx
movl %edx, 0x10(%rdi,%rcx,4)
retq
movl $0x1002, %eax           # imm = 0x1002
retq
// File: /workspace/github_cpp_makefile_star2_O1/martinferianc[P]CPUSimulator-EIE2/src/mips_cpu.cpp
// Function: mips_cpu_step
mips_error mips_cpu_step(mips_cpu_h state){
	if(state==0)
		return mips_ErrorInvalidHandle;

	uint32_t* instruction_data = new uint32_t[8];
	string instruction;
	mips_error err;
	uint32_t mem_value;
	uint8_t dataOut[4];

	//FETCH
	if (state->pc % 4 == 0){
		err = mips_mem_read(state->mem, state->pc, 4, dataOut);
		mem_value = dataOut[0] | (uint32_t(dataOut[1]) << 8) | (uint32_t(dataOut[2]) << 16) | (uint32_t(dataOut[3]) << 24);
	} else {
		err = mips_ExceptionInvalidAlignment;
	}

	//DECODE
	if (err == mips_Success)
		err = mips_decode(mem_value, instruction_data);

	//EXECUTE
	if (err == mips_Success)
		err = mips_execute(state, state->mem, state->hi, state->lo, instruction_data, instruction, state->pcN, state->pc);

	//IF SUCCESS increase PC to new value and not JUMP or BRANCH
	if (err == mips_Success){
		state->pc = state->pcN;
		state->pcN = state->pcN + 4;
	}
	//IF JUMP/BRANCH - PC, PCN adjusted in execution
	if (err == mips_ExceptionBreak)
		err = mips_Success;

	//DEBUG
	switch(state->level){
		case 1:
			debug_level_1(state, instruction);
		break;

		case 2:
			debug_level_2(state, instruction);
		break;

		case 3:
			debug_level_3(state, instruction, state->dest);
		break;

		default:
		break;
	}

	delete [] instruction_data;
	return err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x38, %rsp
movq %rdi, 0x8(%rsp)
testq %rdi, %rdi
je 0x4d99
movq %rdi, %r14
movl $0x20, %edi
callq 0x3030
movq %rax, %rbx
leaq 0x28(%rsp), %r15
movq %r15, -0x10(%r15)
movq $0x0, -0x8(%r15)
movb $0x0, (%r15)
movl (%r14), %esi
movl $0x2003, %eax           # imm = 0x2003
testb $0x3, %sil
jne 0x4d17
movq 0xa0(%r14), %rdi
leaq 0x14(%rsp), %rcx
movl $0x4, %edx
callq 0x4ad9
movl 0x14(%rsp), %ecx
movl %ecx, 0x10(%rsp)
testl %eax, %eax
jne 0x4d28
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x5234
testl %eax, %eax
jne 0x4d56
movq 0xa0(%r14), %rsi
leaq 0x4(%r14), %rdx
leaq 0x8(%r14), %rcx
leaq 0xc(%r14), %rax
leaq 0x18(%rsp), %r9
movq %r14, %rdi
movq %rbx, %r8
pushq %r14
pushq %rax
callq 0x539c
addq $0x10, %rsp
testl %eax, %eax
jne 0x4d68
movl 0xc(%r14), %ecx
movl %ecx, (%r14)
addl $0x4, %ecx
movl %ecx, 0xc(%r14)
xorl %ebp, %ebp
cmpl $0x2000, %eax           # imm = 0x2000
cmovnel %eax, %ebp
movl 0x90(%r14), %eax
cmpl $0x3, %eax
je 0x4db1
cmpl $0x2, %eax
je 0x4da0
cmpl $0x1, %eax
jne 0x4dc7
leaq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x4e15
jmp 0x4dc7
movl $0x1002, %ebp           # imm = 0x1002
jmp 0x4de6
leaq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x4ef7
jmp 0x4dc7
movq 0x98(%r14), %rdx
leaq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x512f
movq %rbx, %rdi
callq 0x3280
movq 0x18(%rsp), %rdi
cmpq %r15, %rdi
je 0x4de6
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x31e0
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x18(%rsp), %rdi
cmpq %r15, %rdi
je 0x4e0d
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x31e0
movq %rbx, %rdi
callq 0x3330
// File: /workspace/github_cpp_makefile_star2_O1/martinferianc[P]CPUSimulator-EIE2/src/mips_cpu.cpp
// Function: debug_level_2(mips_cpu_impl* const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void debug_level_2(const mips_cpu_h& state, const string& instruction){
	cout<<endl<<"Executed instruction: "<<instruction<<endl;
	cout<<"Next PC:="<<state->pc<<endl;
	cout<<"HI: "<<state->hi<<" LO: "<<state->lo<<endl;
	for (int i = 0; i < 32; ++i){
		if (i % 4 == 0)
			cout<<endl;
		cout<<"R["<<i<<"]"<<":= "<<state->regs[i]<<"\t";
	}
	cout<<endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %r12
movq 0xa0b9(%rip), %rbx      # 0xefc8
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x31c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3130
movq %rax, %r15
leaq 0x5b80(%rip), %rsi      # 0xaac0
movl $0x16, %edx
movq %rax, %rdi
callq 0x3210
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq %r15, %rdi
callq 0x3210
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x31c0
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3130
leaq 0x5b4a(%rip), %rsi      # 0xaad7
movl $0x9, %edx
movq %rbx, %rdi
callq 0x3210
movq (%r12), %rax
movl (%rax), %esi
movq %rbx, %rdi
callq 0x3120
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x31c0
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3130
leaq 0x5b08(%rip), %rsi      # 0xaae1
movl $0x4, %edx
movq %rbx, %rdi
callq 0x3210
movq (%r12), %rax
movl 0x4(%rax), %esi
movq %rbx, %rdi
callq 0x3120
movq %rax, %r14
leaq 0x5ae7(%rip), %rsi      # 0xaae6
movl $0x5, %edx
movq %rax, %rdi
callq 0x3210
movq %r12, %r13
movq (%r12), %rax
movl 0x8(%rax), %esi
movq %r14, %rdi
callq 0x3120
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x31c0
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3130
xorl %r15d, %r15d
leaq 0x5a9c(%rip), %rbp      # 0xaaee
leaq 0x5adf(%rip), %r14      # 0xab38
testb $0x3, %r15b
jne 0x5086
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x31c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3130
movl $0x2, %edx
movq %rbx, %rdi
leaq 0x5c3b(%rip), %rsi      # 0xacd0
callq 0x3210
movq %rbx, %rdi
movl %r15d, %esi
callq 0x3310
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
leaq 0x5a35(%rip), %rsi      # 0xaaec
callq 0x3210
movl $0x3, %edx
movq %r12, %rdi
movq %rbp, %rsi
callq 0x3210
movq (%r13), %rax
movl 0x10(%rax,%r15,4), %esi
movq %r12, %rdi
callq 0x3120
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x3210
incq %r15
cmpq $0x20, %r15
jne 0x5059
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x31c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3130
// File: /workspace/github_cpp_makefile_star2_O1/martinferianc[P]CPUSimulator-EIE2/src/mips_cpu.cpp
// Function: debug_level_3(mips_cpu_impl* const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, _IO_FILE*)
void debug_level_3(const mips_cpu_h& state, const string& instruction, FILE* file){
	if (file == NULL) perror ("Error opening file");
	fprintf(state->dest,"Executed instruction: %s", instruction.c_str());
	fprintf(state->dest,"Next PC:= %i \n", state->pc);
	for (int i = 0; i < 32; ++i){
		if (i % 4 == 0)
			fprintf(state->dest,"\n");
		fprintf(state->dest,"R[%i]:= %i \t",i, state->regs[i]);
	}
	cout<<endl;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
testq %rdx, %rdx
je 0x51f4
movq (%rbx), %rax
movq 0x98(%rax), %rdi
movq (%r14), %rdx
leaq 0x59ae(%rip), %rsi      # 0xab05
xorl %eax, %eax
callq 0x32a0
movq (%rbx), %rax
movq 0x98(%rax), %rdi
movl (%rax), %edx
leaq 0x59ad(%rip), %rsi      # 0xab1e
xorl %eax, %eax
callq 0x32a0
leaq 0x59ae(%rip), %r14      # 0xab2d
xorl %r15d, %r15d
testb $0x3, %r15b
jne 0x519c
movq (%rbx), %rax
movq 0x98(%rax), %rsi
movl $0xa, %edi
callq 0x3260
movq (%rbx), %rax
movq 0x98(%rax), %rdi
movl 0x10(%rax,%r15,4), %ecx
movq %r14, %rsi
movl %r15d, %edx
xorl %eax, %eax
callq 0x32a0
incq %r15
cmpq $0x20, %r15
jne 0x5182
movq 0x9e00(%rip), %rbx      # 0xefc8
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x31c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x3130
leaq 0x58f7(%rip), %rdi      # 0xaaf2
callq 0x31a0
jmp 0x5143
// File: /workspace/github_cpp_makefile_star2_O1/martinferianc[P]CPUSimulator-EIE2/src/mips_cpu_decode.cpp
// Function: mips_decode(unsigned int const&, unsigned int*)
mips_error mips_decode(const uint32_t& instruction, uint32_t* instruction_data){
	uint32_t opcode = (instruction >> 2 ) & 0x3F;
	if (opcode==0)
		return mips_decode_R(instruction, instruction_data);
	if ((opcode==2) || (opcode==3) || (opcode==26))
		return mips_decode_J(instruction, instruction_data);
	return mips_decode_I(instruction, instruction_data);
}

// Assembly:
pushq %rax
movl (%rdi), %ecx
movl %ecx, %eax
shrl $0x2, %eax
andl $0x3f, %eax
je 0x529b
andl $0xf8, %ecx
cmpl $0x8, %ecx
setne %cl
cmpl $0x1a, %eax
setne %dl
testb %dl, %cl
jne 0x52a2
movl %eax, (%rsi)
movl (%rdi), %eax
movl %eax, %ecx
andl $0x30, %ecx
shll $0x16, %ecx
movl %eax, %edx
shrl $0x18, %edx
orl %ecx, %edx
movl %eax, %ecx
shrl $0x8, %ecx
andl $0xff00, %ecx           # imm = 0xFF00
orl %edx, %ecx
shll $0x8, %eax
andl $0xff0000, %eax         # imm = 0xFF0000
orl %ecx, %eax
movl %eax, 0x4(%rsi)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rsi)
movabsq $0x200000002, %rax      # imm = 0x200000002
movq %rax, 0x18(%rsi)
jmp 0x52a7
callq 0x52ab
jmp 0x52a7
callq 0x5352
xorl %eax, %eax
popq %rcx
retq
// File: /workspace/github_cpp_makefile_star2_O1/martinferianc[P]CPUSimulator-EIE2/src/mips_cpu_decode.cpp
// Function: mips_decode_R(unsigned int const&, unsigned int*)
mips_error mips_decode_R(const uint32_t& instruction, uint32_t* instruction_data){
	instruction_data[0] = (uint32_t)(instruction >> 2) & 0x3F; 																		 //OPcode
	instruction_data[1] = (uint32_t)(((instruction >> 13) & 0x7) | ((instruction << 3) & 0x18)) ;  //Source 1
	instruction_data[2] = (uint32_t)(instruction >> 8) & 0x1F; 																		 //Source 2
	instruction_data[3] = (uint32_t)(instruction >> 19) & 0x1F; 																	 //Destination
	instruction_data[4] = (uint32_t)(((instruction >> 14) & 0x1C) | ((instruction >> 30) & 0x3)) ; //Shift
	instruction_data[5] = (uint32_t)(instruction >> 24) & 0x3F; 																	 //Function
	instruction_data[6] = 6; 																																			 //Relevant data size: 6
	instruction_data[7] = 0; 																																			 //R-type
	return mips_Success;
}

// Assembly:
movl (%rdi), %eax
shrl $0x2, %eax
andl $0x3f, %eax
movl %eax, (%rsi)
movl (%rdi), %eax
movl %eax, %ecx
shrl $0xd, %ecx
andl $0x7, %ecx
andl $0x3, %eax
leal (%rcx,%rax,8), %eax
movl %eax, 0x4(%rsi)
movl (%rdi), %eax
shrl $0x8, %eax
andl $0x1f, %eax
movl %eax, 0x8(%rsi)
movl (%rdi), %eax
shrl $0x13, %eax
andl $0x1f, %eax
movl %eax, 0xc(%rsi)
movl (%rdi), %eax
movl %eax, %ecx
shrl $0xe, %ecx
andl $0x1c, %ecx
shrl $0x1e, %eax
orl %ecx, %eax
movl %eax, 0x10(%rsi)
movzbl 0x3(%rdi), %eax
andl $0x3f, %eax
movl %eax, 0x14(%rsi)
movq $0x6, 0x18(%rsi)
xorl %eax, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O1/martinferianc[P]CPUSimulator-EIE2/src/mips_cpu_decode.cpp
// Function: mips_decode_J(unsigned int const&, unsigned int*)
mips_error mips_decode_J(const uint32_t& instruction, uint32_t* instruction_data){
	instruction_data[0] = (uint32_t)(instruction >> 2)  & 0x3F; 																		//OPcode
	instruction_data[1] =
		(uint32_t)(((instruction << 22) & 0xC000000) |
		((instruction >> 24) & 0xFF) |
		((instruction >> 8) & 0xFF00) |
		((instruction << 8) & 0xFF0000)); 																		  											//Memory address
	instruction_data[2] = 0; 																																				//Leave Blank
	instruction_data[3] = 0; 																																				//Leave Blank
	instruction_data[4] = 0; 																																				//Leave Blank
	instruction_data[5] = 0; 																																				//Leave Blank
	instruction_data[6] = 2; 																																				//Relevant data size: 2
	instruction_data[7] = 2; 																																			  //J-type
	return mips_Success;
}

// Assembly:
movl (%rdi), %eax
shrl $0x2, %eax
andl $0x3f, %eax
movl %eax, (%rsi)
movl (%rdi), %eax
movl %eax, %ecx
andl $0x30, %ecx
shll $0x16, %ecx
movl %eax, %edx
shrl $0x18, %edx
orl %ecx, %edx
movl %eax, %ecx
shrl $0x8, %ecx
andl $0xff00, %ecx           # imm = 0xFF00
orl %edx, %ecx
shll $0x8, %eax
andl $0xff0000, %eax         # imm = 0xFF0000
orl %ecx, %eax
movl %eax, 0x4(%rsi)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rsi)
movabsq $0x200000002, %rax      # imm = 0x200000002
movq %rax, 0x18(%rsi)
xorl %eax, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O1/martinferianc[P]CPUSimulator-EIE2/src/mips_cpu_decode.cpp
// Function: mips_decode_I(unsigned int const&, unsigned int*)
mips_error mips_decode_I(const uint32_t& instruction, uint32_t* instruction_data){
	instruction_data[0] = (uint32_t)(instruction >> 2) & 0x3F; 																		  //OPcode
	instruction_data[1] = (uint32_t)(((instruction << 3) & 0x18) | ((instruction >> 13) & 0x7)) ;   //Source 1
	instruction_data[2] = (uint32_t)(instruction >> 8) & 0x1F; 																			//Destination
	instruction_data[3] = (uint32_t)(((instruction >> 24) & 0xFF) | ((instruction >> 8) & 0xFF00)); //Immediate Constant
	instruction_data[4] = 0; 																																				//Leave Blank
	instruction_data[5] = 0; 																																				//Leave Blank
	instruction_data[6] = 4; 																																				//Relevant data size: 4
	instruction_data[7] = 1; 																																				//I-type
	return mips_Success;
}

// Assembly:
movl (%rdi), %eax
shrl $0x2, %eax
andl $0x3f, %eax
movl %eax, (%rsi)
movl (%rdi), %eax
movl %eax, %ecx
andl $0x3, %ecx
shrl $0xd, %eax
andl $0x7, %eax
leal (%rax,%rcx,8), %eax
movl %eax, 0x4(%rsi)
movl (%rdi), %eax
shrl $0x8, %eax
andl $0x1f, %eax
movl %eax, 0x8(%rsi)
movl (%rdi), %eax
movl %eax, %ecx
shrl $0x18, %ecx
shrl $0x8, %eax
andl $0xff00, %eax           # imm = 0xFF00
orl %ecx, %eax
movl %eax, 0xc(%rsi)
movaps 0x57ab(%rip), %xmm0     # 0xab40
movups %xmm0, 0x10(%rsi)
xorl %eax, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O1/martinferianc[P]CPUSimulator-EIE2/src/mips_cpu_execute.cpp
// Function: mips_execute(mips_cpu_impl*, mips_mem_provider*, unsigned int&, unsigned int&, unsigned int const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, unsigned int&, unsigned int&)
mips_error mips_execute(mips_cpu_h state, mips_mem_h mem, uint32_t& hi, uint32_t& lo, const uint32_t* instruction_data, string& instruction, uint32_t& pcN, uint32_t& pc){
	uint32_t type = instruction_data[7];
	switch (type) {
		case 0: return mips_execute_R(state, hi, lo, instruction_data, instruction, pcN, pc);
		case 1: return mips_execute_I(state, mem, instruction_data, instruction, pcN, pc);
		case 2: return mips_execute_J(state, instruction_data, instruction, pcN, pc);
	}
	return mips_InternalError;
}

// Assembly:
pushq %rax
movq 0x18(%rsp), %r10
movq 0x10(%rsp), %rax
movl 0x1c(%r8), %r11d
cmpl $0x2, %r11d
je 0x53e8
cmpl $0x1, %r11d
je 0x53d6
testl %r11d, %r11d
jne 0x53fa
movq %r10, (%rsp)
movq %rdx, %rsi
movq %rcx, %rdx
movq %r8, %rcx
movq %r9, %r8
movq %rax, %r9
callq 0x5401
jmp 0x53ff
movq %r8, %rdx
movq %r9, %rcx
movq %rax, %r8
movq %r10, %r9
popq %rax
jmp 0x5d0d
movq %r8, %rsi
movq %r9, %rdx
movq %rax, %rcx
movq %r10, %r8
popq %rax
jmp 0x653b
movl $0x3000, %eax           # imm = 0x3000
popq %rcx
retq
// File: /workspace/github_cpp_makefile_star2_O1/martinferianc[P]CPUSimulator-EIE2/src/mips_cpu_execute.cpp
// Function: mips_execute_J(mips_cpu_impl*, unsigned int const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, unsigned int&, unsigned int&)
mips_error mips_execute_J(mips_cpu_h state, const uint32_t* instruction_data, string& instruction, uint32_t& pcN, uint32_t& pc){

	switch(instruction_data[0]){
		case 0b000010:
			return mips_execute_J_X(state, instruction_data, "JUMP", instruction, pcN, pc);
		case 0b000011:
			return mips_execute_J_X(state, instruction_data, "JAL", 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 %r8, %r14
movq %rcx, %r15
movq %rdx, %rbx
movq %rsi, %r12
movq %rdi, %r13
movl (%rsi), %eax
cmpl $0x3, %eax
je 0x65a4
cmpl $0x2, %eax
jne 0x65f9
leaq 0x18(%rsp), %rbp
movq %rbp, -0x10(%rbp)
leaq 0x474f(%rip), %rsi      # 0xacc7
leaq 0x474c(%rip), %rdx      # 0xaccb
leaq 0x8(%rsp), %rdi
callq 0x40c4
leaq 0x8(%rsp), %rdx
movq %r13, %rdi
movq %r12, %rsi
movq %rbx, %rcx
movq %r15, %r8
movq %r14, %r9
callq 0x7e73
jmp 0x65de
leaq 0x18(%rsp), %rbp
movq %rbp, -0x10(%rbp)
leaq 0x4175(%rip), %rsi      # 0xa729
leaq 0x4171(%rip), %rdx      # 0xa72c
leaq 0x8(%rsp), %rdi
callq 0x40c4
leaq 0x8(%rsp), %rdx
movq %r13, %rdi
movq %r12, %rsi
movq %rbx, %rcx
movq %r15, %r8
movq %r14, %r9
callq 0x7e73
movl %eax, %ebx
movq 0x8(%rsp), %rdi
cmpq %rbp, %rdi
je 0x6619
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x31e0
jmp 0x6619
movq 0x8(%rbx), %rdx
leaq 0x46a8(%rip), %rcx      # 0xacac
movl $0x1a, %r8d
movq %rbx, %rdi
xorl %esi, %esi
callq 0x32d0
movl $0x2005, %ebx           # imm = 0x2005
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x662c
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %rbp, %rdi
je 0x664d
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x31e0
jmp 0x664d
jmp 0x664a
movq %rax, %rbx
movq %rbx, %rdi
callq 0x3330
// File: /workspace/github_cpp_makefile_star2_O1/martinferianc[P]CPUSimulator-EIE2/src/mips_cpu_execute.cpp
// Function: mips_execute_J_X(mips_cpu_impl*, unsigned int const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, unsigned int&, unsigned int&)
mips_error mips_execute_J_X(mips_cpu_h state, const uint32_t* instruction_data, const string& op, string& instruction, uint32_t& pcN, uint32_t& pc){

	stringstream ss;
	mips_error err = mips_ExceptionInvalidInstruction;
	uint32_t imm_unsigned = uint32_t(instruction_data[1]);

	if (op.compare("JUMP")==0){
		pc = pcN;
		pcN = (pc & 0xF0000000) | (imm_unsigned << 2);
		err = mips_ExceptionBreak;
	}

	if (op.compare("JAL")==0){
		mips_cpu_set_register(state, 31, pc + 8);
		pc = pcN;
		pcN = (pc & 0xF0000000) | (imm_unsigned << 2);
		err = mips_ExceptionBreak;
	}

	ss <<op<<" "<<"#"<<instruction_data[1];

	instruction = ss.str();
	return err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1b8, %rsp            # imm = 0x1B8
movq %r9, %r13
movq %r8, %r12
movq %rcx, 0x8(%rsp)
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, (%rsp)
leaq 0x30(%rsp), %rdi
callq 0x3150
movl 0x4(%r14), %ebx
leaq 0x2e19(%rip), %rsi      # 0xacc7
movq %r15, %rdi
callq 0x30a0
movl $0x2005, %ebp           # imm = 0x2005
testl %eax, %eax
jne 0x7ede
movl (%r12), %eax
movl %eax, (%r13)
andl $0xf0000000, %eax       # imm = 0xF0000000
leal (,%rbx,4), %ecx
orl %eax, %ecx
movl %ecx, (%r12)
movl $0x2000, %ebp           # imm = 0x2000
leaq 0x2844(%rip), %rsi      # 0xa729
movq %r15, %rdi
callq 0x30a0
testl %eax, %eax
jne 0x7f21
movl (%r13), %edx
addl $0x8, %edx
movq (%rsp), %rdi
movl $0x1f, %esi
callq 0x4c64
movl (%r12), %eax
movl %eax, (%r13)
andl $0xf0000000, %eax       # imm = 0xF0000000
shll $0x2, %ebx
orl %eax, %ebx
movl %ebx, (%r12)
movl $0x2000, %ebp           # imm = 0x2000
leaq 0x40(%rsp), %rdi
movq (%r15), %rsi
movq 0x8(%r15), %rdx
callq 0x3210
movq %rax, %rbx
leaq 0x2db8(%rip), %rsi      # 0xacf4
movl $0x1, %edx
movq %rax, %rdi
callq 0x3210
leaq 0x2d86(%rip), %rsi      # 0xacd6
movl $0x1, %edx
movq %rbx, %rdi
callq 0x3210
movl 0x4(%r14), %esi
movq %rbx, %rdi
callq 0x3120
leaq 0x48(%rsp), %rsi
leaq 0x10(%rsp), %rdi
callq 0x32f0
leaq 0x10(%rsp), %rbx
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x3250
movq (%rbx), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x7fa4
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x31e0
movq 0x7005(%rip), %rsi      # 0xefb0
leaq 0x30(%rsp), %rdi
callq 0x3170
leaq 0xb0(%rsp), %rdi
callq 0x30b0
movl %ebp, %eax
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x7fd8
movq %rax, %rbx
movq 0x6fce(%rip), %rsi      # 0xefb0
leaq 0x30(%rsp), %rdi
callq 0x3170
leaq 0xb0(%rsp), %rdi
callq 0x30b0
movq %rbx, %rdi
callq 0x3330
nopl (%rax)
// File: /workspace/github_cpp_makefile_star2_O1/martinferianc[P]CPUSimulator-EIE2/src/mips_cpu_execute_help.cpp
// Function: addition_overflow(unsigned int, unsigned int)
size_t highestOneBitPosition(uint32_t a) {
    size_t bits=0;
    while (a!=0) {
        ++bits;
        a>>=1;
    };
    return bits;
}

// Assembly:
bsrl %edi, %eax
xorl $-0x20, %eax
addl $0x21, %eax
xorl %ecx, %ecx
testl %edi, %edi
sete %cl
cmovel %edi, %eax
bsrl %esi, %edx
xorl $-0x20, %edx
addl $0x21, %edx
xorl %r8d, %r8d
cmpl %eax, %edx
sete %r8b
testl %esi, %esi
cmovnel %r8d, %ecx
cmpb $0x1, %cl
jne 0x80a2
addl %edi, %esi
bsrl %esi, %ecx
xorl $-0x20, %ecx
addl $0x21, %ecx
testl %esi, %esi
cmovel %esi, %ecx
cmpl %eax, %ecx
setne %al
retq
xorl %eax, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O1/martinferianc[P]CPUSimulator-EIE2/src/test_mips.cpp
// Function: print_registers(unsigned int const*)
void print_registers(const uint32_t *array){
  for (size_t i = 0; i < 32; i++) {
    if (i % 4 == 0)
    cout<<endl;
    cout<<"R["<<i<<"]"<<":= "<<array[i]<<"\t";
  }
  cout<<endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
xorl %r15d, %r15d
movq 0x6ac7(%rip), %rbx      # 0xefc8
leaq 0x25e6(%rip), %rbp      # 0xaaee
leaq 0x2629(%rip), %r12      # 0xab38
testb $0x3, %r15b
jne 0x853c
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x31c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3130
movl $0x2, %edx
movq %rbx, %rdi
leaq 0x2785(%rip), %rsi      # 0xacd0
callq 0x3210
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3120
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x257f(%rip), %rsi      # 0xaaec
callq 0x3210
movl $0x3, %edx
movq %r13, %rdi
movq %rbp, %rsi
callq 0x3210
movl (%r14,%r15,4), %esi
movq %r13, %rdi
callq 0x3120
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x3210
incq %r15
cmpq $0x20, %r15
jne 0x850f
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x31c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3130
// File: /workspace/github_cpp_makefile_star2_O1/martinferianc[P]CPUSimulator-EIE2/src/test_mips.cpp
// Function: load_registers(unsigned int*, mips_cpu_impl*)
void load_registers(uint32_t* array, mips_cpu_h cpu){
  for (size_t i = 0; i < 32; i++) {
    uint32_t* reg = new uint32_t;
    mips_cpu_get_register(cpu, i, reg);
    array[i] = uint32_t(*reg);
    delete reg;
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
xorl %r15d, %r15d
movl $0x4, %edi
callq 0x31d0
movq %rax, %r12
movq %rbx, %rdi
movl %r15d, %esi
movq %rax, %rdx
callq 0x4c44
movl (%r12), %eax
movl %eax, (%r14,%r15,4)
movl $0x4, %esi
movq %r12, %rdi
callq 0x31e0
incq %r15
cmpq $0x20, %r15
jne 0x85f1
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/martinferianc[P]CPUSimulator-EIE2/src/test_mips.cpp
// Function: test::str[abi:cxx11]()
string str(){
    stringstream ss;
    ss<<std::hex<<instruction_code<<" "
    <<instruction_name<<" "
    <<" R2: "<<instruction_r1
    <<" R3: "<<instruction_r2
    <<" Ex. Result: "<<instruction_result;
    return ss.str();
  }

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x190, %rsp            # imm = 0x190
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x8(%rsp), %rdi
callq 0x3150
leaq 0x18(%rsp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
movl 0x30(%rsp,%rax), %ecx
andl $-0x4b, %ecx
orl $0x8, %ecx
movl %ecx, 0x30(%rsp,%rax)
movl (%r14), %esi
callq 0x3120
movq %rax, %r15
leaq 0x1862(%rip), %rsi      # 0xacf4
movl $0x1, %edx
movq %rax, %rdi
callq 0x3210
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rdx
movq %r15, %rdi
callq 0x3210
movq %rax, %r15
leaq 0x183b(%rip), %rsi      # 0xacf4
movl $0x1, %edx
movq %rax, %rdi
callq 0x3210
leaq 0x1ad4(%rip), %rsi      # 0xafa1
movl $0x5, %edx
movq %r15, %rdi
callq 0x3210
movl 0x2c(%r14), %esi
movq %r15, %rdi
callq 0x3120
movq %rax, %r15
leaq 0x1ab7(%rip), %rsi      # 0xafa7
movl $0x5, %edx
movq %rax, %rdi
callq 0x3210
movl 0x30(%r14), %esi
movq %r15, %rdi
callq 0x3120
movq %rax, %r15
leaq 0x1a9a(%rip), %rsi      # 0xafad
movl $0xd, %edx
movq %rax, %rdi
callq 0x3210
movl 0x28(%r14), %esi
movq %r15, %rdi
callq 0x3120
leaq 0x20(%rsp), %rsi
movq %rbx, %rdi
callq 0x32f0
movq 0x5a70(%rip), %rsi      # 0xefb0
leaq 0x8(%rsp), %rdi
callq 0x3170
leaq 0x88(%rsp), %rdi
callq 0x30b0
movq %rbx, %rax
addq $0x190, %rsp            # imm = 0x190
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %rbx
movq 0x5a3f(%rip), %rsi      # 0xefb0
leaq 0x8(%rsp), %rdi
callq 0x3170
leaq 0x88(%rsp), %rdi
callq 0x30b0
movq %rbx, %rdi
callq 0x3330
// File: /workspace/github_cpp_makefile_star2_O1/coduin[P]epiphany-bin-info/epiphany-bin-info.cpp
// Function: operator<<(std::ostream&, addr const&)
ostream& operator<<(ostream& stream, const addr& addr) {
    if (isExtmem(addr.val)) {
        outputSetWhite();
        stream << ashex(addr.val);
        outputReset();
    } else {
        stream << ashex(addr.val);
    }
    return stream;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl (%rsi), %eax
cmpl $0x100000, %eax         # imm = 0x100000
jb 0x25d2
movq %rsi, %r14
cmpb $0x1, 0x5bfe(%rip)      # 0x8181
jne 0x259d
movq 0x5a44(%rip), %rdi      # 0x7fd0
leaq 0x2a71(%rip), %rsi      # 0x5004
movl $0x5, %edx
callq 0x21a0
movl (%r14), %eax
leaq 0x4(%rsp), %rsi
movl %eax, (%rsi)
movq %rbx, %rdi
callq 0x24cc
cmpb $0x1, 0x5bcb(%rip)      # 0x8181
jne 0x25df
movq 0x5a11(%rip), %rdi      # 0x7fd0
leaq 0x2a4a(%rip), %rsi      # 0x5010
movl $0x4, %edx
callq 0x21a0
jmp 0x25df
movq %rsp, %rsi
movl %eax, (%rsi)
movq %rbx, %rdi
callq 0x24cc
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq