LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/test/hfile.c
// Function: slurp
char *slurp(const char *filename)
{
    char *text;
    struct stat sbuf;
    size_t filesize;
    FILE *f = fopen(filename, "rb");
    if (f == NULL) fail("fopen(\"%s\", \"rb\")", filename);
    if (fstat(fileno(f), &sbuf) != 0) fail("fstat(\"%s\")", filename);
    filesize = sbuf.st_size;

    text = (char *) malloc(filesize + 1);
    if (text == NULL) fail("malloc(text)");

    if (fread(text, 1, filesize, f) != filesize) fail("fread");
    fclose(f);

    text[filesize] = '\0';
    return text;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x90, %rsp
movq %rdi, %r14
leaq 0x8a167(%rip), %rsi     # 0x90069
callq 0x45a0
testq %rax, %rax
je 0x5f70
movq %rax, %rbx
movq %rax, %rdi
callq 0x44e0
movq %rsp, %rsi
movl %eax, %edi
callq 0x4870
testl %eax, %eax
jne 0x5f79
movq 0x30(%rsp), %r14
leaq 0x1(%r14), %rdi
callq 0x4670
testq %rax, %rax
je 0x5f8a
movq %rax, %r15
movl $0x1, %esi
movq %rax, %rdi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x4780
cmpq %r14, %rax
jne 0x5f93
movq %rbx, %rdi
callq 0x44a0
movb $0x0, (%r15,%r14)
movq %r15, %rax
addq $0x90, %rsp
popq %rbx
popq %r14
popq %r15
retq
leaq 0x8a0f5(%rip), %rdi     # 0x9006c
jmp 0x5f80
leaq 0x8a0fe(%rip), %rdi     # 0x9007e
movq %r14, %rsi
xorl %eax, %eax
callq 0x5dcc
leaq 0x8a0f9(%rip), %rdi     # 0x9008a
jmp 0x5f9a
leaq 0x8a0fd(%rip), %rdi     # 0x90097
xorl %eax, %eax
callq 0x5dcc
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/test/hfile.c
// Function: reopen
void reopen(const char *infname, const char *outfname)
{
    if (fin) { if (hclose(fin) != 0) fail("hclose(input)"); }
    if (fout) { if (hclose(fout) != 0) fail("hclose(output)"); }

    fin = hopen(infname, "r");
    if (fin == NULL) fail("hopen(\"%s\")", infname);

    fout = hopen(outfname, "w");
    if (fout == NULL) fail("hopen(\"%s\")", outfname);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq 0xac556(%rip), %rdi     # 0xb2508
testq %rdi, %rdi
je 0x5fc0
callq 0x7eb7
testl %eax, %eax
jne 0x6034
movq 0xac549(%rip), %rdi     # 0xb2510
testq %rdi, %rdi
je 0x5fd5
callq 0x7eb7
testl %eax, %eax
jne 0x603d
leaq 0x8dc60(%rip), %rsi     # 0x93c3c
movq %r14, %rdi
xorl %eax, %eax
callq 0x881c
movq %rax, 0xac51b(%rip)     # 0xb2508
testq %rax, %rax
je 0x6017
leaq 0x8ce68(%rip), %rsi     # 0x92e61
movq %rbx, %rdi
xorl %eax, %eax
callq 0x881c
movq %rax, 0xac506(%rip)     # 0xb2510
testq %rax, %rax
je 0x6023
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0x8a09c(%rip), %rdi     # 0x900ba
movq %r14, %rsi
jmp 0x602d
leaq 0x8a090(%rip), %rdi     # 0x900ba
movq %rbx, %rsi
xorl %eax, %eax
callq 0x5dcc
leaq 0x8a062(%rip), %rdi     # 0x9009d
jmp 0x6044
leaq 0x8a067(%rip), %rdi     # 0x900ab
xorl %eax, %eax
callq 0x5dcc
// File: /workspace/github_c_makefile_star2_O3/morozov312[P]documentary/./src/main.c
// Function: main
int main(int argc, char** argv)
{
    char *start_dir, *dest_dir;
    int argc_flag = Check_argc(argc, argv);
    if (!argc_flag) {
        return 0;
    }
    int argv_flag = Check_argv(argc, argv, &start_dir, &dest_dir);
    if (!argv_flag) {
        return 0;
    }
    if (strcmp(start_dir, "") == 0) {
        printf("\x1b[31m Error! \x1b[0m\n");
        Print_help();
        return 0;
    }
    char** paths_array = (char**)calloc(MAX_COUNT_OF_FILES, sizeof(char*));
    for (int i = 0; i < MAX_COUNT_OF_FILES; i++) {
        paths_array[i] = (char*)calloc(MAX_PATH_LEN, sizeof(char));
    }
    int recursive_exit_flag = 0;
    int recursive_res = Search_files_recursive(
            start_dir, paths_array, &recursive_exit_flag);
    if (recursive_res == -1) {
        printf("%s\n",
               "\x1b[36mWarning!\x1b[0m limit of files for this "
               "folder "
               "overpassed!");
    }
    for (int i = 0; i < MAX_COUNT_OF_FILES; i++) {
        size_t len = strlen(paths_array[i]);
        if (len > 0) {
            Create_document(paths_array[i], dest_dir);
        }
    }
    for (int i = 0; i < MAX_COUNT_OF_FILES; i++) {
        free(paths_array[i]);
    }
    free(paths_array);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movl %edi, %r14d
callq 0x170f
testl %eax, %eax
je 0x136c
leaq -0x28(%rbp), %rdx
leaq -0x20(%rbp), %rcx
movl %r14d, %edi
movq %rbx, %rsi
callq 0x17ad
testl %eax, %eax
je 0x136c
movq -0x28(%rbp), %r14
cmpb $0x0, (%r14)
je 0x1359
movl $0x1e, %edi
movl $0x8, %esi
callq 0x1110
movq %rax, %rbx
xorl %r15d, %r15d
movl $0xff, %edi
movl $0x1, %esi
callq 0x1110
movq %rax, (%rbx,%r15,8)
incq %r15
cmpq $0x1e, %r15
jne 0x12da
leaq -0x2c(%rbp), %rdx
movl $0x0, (%rdx)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1483
cmpl $-0x1, %eax
jne 0x131c
leaq 0x1ced(%rip), %rdi      # 0x3004
callq 0x1060
xorl %r14d, %r14d
movq (%rbx,%r14,8), %rdi
cmpb $0x0, (%rdi)
je 0x1331
movq -0x20(%rbp), %rsi
callq 0x20cc
incq %r14
cmpq $0x1e, %r14
jne 0x131f
xorl %r14d, %r14d
movq (%rbx,%r14,8), %rdi
callq 0x1030
incq %r14
cmpq $0x1e, %r14
jne 0x133d
movq %rbx, %rdi
callq 0x1030
jmp 0x136c
leaq 0x1ce1(%rip), %rdi      # 0x3041
callq 0x1060
xorl %eax, %eax
callq 0x1690
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O3/hamsternz[P]emulate-risc-v/main.c
// Function: main
int main(int argc, char *argv[]) {
  int run = 1, quit = 0, trace = 1, reset = 0;

  if(!display_start()) {
    fprintf(stderr,"Unable to initialise display\n");
    return 0;
  }

  if(!memory_initialise()) {
    return 0;
  }
  display_log("Memory inisitalised");

  if(!riscv_initialise()) {
    return 0;
  }
  display_log("RISC-V initalised");
  riscv_reset();
  display_log("Press SPACE to run a sigle instruction, or 'r' to run. 'q' to quit");

  while(!quit) {
    if(run) {
       if(!memory_run())
         run = 0;
    }
    if(run) {
       if(!riscv_run() ||run == 1)
         run = 0;
    }
    display_update();
    display_process_input(&run, &quit, &trace, &reset);
    if(reset) {
      riscv_reset();
      reset = 0;
    }
  }
  riscv_dump();
  riscv_finish();
  display_log("RISC-V shutdown");
  memory_finish();
  display_log("Memory shutdown");
  display_update();
  display_end();
  
  return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl $0x1, %eax
movl %eax, 0x8(%rsp)
xorl %ecx, %ecx
movl %ecx, 0x10(%rsp)
movl %eax, 0x14(%rsp)
movl %ecx, 0xc(%rsp)
callq 0x485c
testl %eax, %eax
je 0x2571
callq 0x5f9a
testl %eax, %eax
je 0x2563
leaq 0x4b93(%rip), %rdi      # 0x7022
callq 0x4d36
callq 0x2ef1
testl %eax, %eax
je 0x2563
leaq 0x4b8e(%rip), %rdi      # 0x7036
callq 0x4d36
callq 0x2e86
leaq 0x4b8f(%rip), %rdi      # 0x7048
callq 0x4d36
leaq 0x8(%rsp), %rbx
leaq 0x10(%rsp), %r14
leaq 0x14(%rsp), %r15
leaq 0xc(%rsp), %r12
cmpl $0x0, 0x8(%rsp)
je 0x2501
callq 0x616d
testl %eax, %eax
je 0x24f9
cmpl $0x0, 0x8(%rsp)
je 0x2501
callq 0x2fa1
testl %eax, %eax
je 0x24f9
cmpl $0x1, 0x8(%rsp)
jne 0x2501
movl $0x0, 0x8(%rsp)
callq 0x4a33
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %r12, %rcx
callq 0x4ebe
cmpl $0x0, 0xc(%rsp)
je 0x252b
callq 0x2e86
movl $0x0, 0xc(%rsp)
cmpl $0x0, 0x10(%rsp)
je 0x24d2
callq 0x3200
callq 0x3201
leaq 0x4b48(%rip), %rdi      # 0x708b
callq 0x4d36
callq 0x62bd
leaq 0x4b47(%rip), %rdi      # 0x709b
callq 0x4d36
callq 0x4a33
callq 0x5018
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
callq 0x2250
jmp 0x2563
// File: /workspace/github_c_makefile_star2_O3/hamsternz[P]emulate-risc-v/riscv.c
// Function: riscv_reset
void riscv_reset(void) {
  memory_reset();
  memset(regs,0xFF,sizeof(regs));
  regs[0] = 0;
  pc = 0x20400000;
  display_log("RISC-V reset");
}

// Assembly:
pushq %rax
callq 0x5f58
pcmpeqd %xmm0, %xmm0
movdqa %xmm0, 0xdb98(%rip)     # 0x10a30
movdqa %xmm0, 0xdc00(%rip)     # 0x10aa0
movdqa %xmm0, 0xdbe8(%rip)     # 0x10a90
movdqa %xmm0, 0xdbd0(%rip)     # 0x10a80
movdqa %xmm0, 0xdbb8(%rip)     # 0x10a70
movdqa %xmm0, 0xdba0(%rip)     # 0x10a60
movdqa %xmm0, 0xdb88(%rip)     # 0x10a50
movdqa %xmm0, 0xdb70(%rip)     # 0x10a40
movl $0x0, 0xdb56(%rip)      # 0x10a30
movl $0x20400000, 0x9b2c(%rip) # imm = 0x20400000
leaq 0x49b9(%rip), %rdi      # 0x78a4
popq %rax
jmp 0x4d36
// File: /workspace/github_c_makefile_star2_O3/hamsternz[P]emulate-risc-v/riscv.c
// Function: trace
static void trace(char *fmt, uint32_t a, uint32_t b, uint32_t c) {
  char buffer[128];
  if(!trace_active)
    return;
  sprintf(buffer,"%08X:%c",pc, stalled ? '*' : ' ');
  sprintf(buffer+10, fmt, a, b, c);
  display_trace(buffer);
}

// Assembly:
cmpl $0x0, 0x8f27(%rip)      # 0xc130
je 0x3280
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x80, %rsp
movl %ecx, %ebx
movl %edx, %ebp
movl %esi, %r14d
movq %rdi, %r15
movl 0x97e6(%rip), %edx      # 0xca10
cmpb $0x0, 0xd897(%rip)      # 0x10ac8
movl $0x2a, %eax
movl $0x20, %ecx
cmovnel %eax, %ecx
leaq 0x46ad(%rip), %rsi      # 0x78f2
movq %rsp, %r12
movq %r12, %rdi
xorl %eax, %eax
callq 0x2210
leaq 0xa(%rsp), %rdi
movq %r15, %rsi
movl %r14d, %edx
movl %ebp, %ecx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x2210
movq %r12, %rdi
callq 0x4e05
addq $0x80, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/hamsternz[P]emulate-risc-v/memorymap.c
// Function: memorymap_aligned_read
int memorymap_aligned_read(uint32_t address, uint32_t *value) {
   struct region *r = first_region;

   /* Find the region */
   while(r != NULL) {
     if(address >= r->base && address < r->base+r->size)
       break;
     r = r->next;
   }

   /* If no region found then exit */
   if(r == NULL) {
     char buffer[128];
     sprintf(buffer, "Read of invalid address %08X",address);
     display_log(buffer);
     return 0;
   }

   /* Trap a currently unhandled error */
   if(address+4 > r->base + r->size) {
     display_log("Need to split the read of address as it crosses boundary");
     return 0;
   }
   return r->get(r, address-r->base, value);
}

// Assembly:
pushq %rbx
subq $0x80, %rsp
movl %edi, %edx
movq 0xd3a7(%rip), %rdi      # 0x10af8
testq %rdi, %rdi
je 0x3771
movq %rsi, %rax
movl 0x8(%rdi), %ecx
movl %edx, %esi
subl %ecx, %esi
jb 0x3769
addl 0xc(%rdi), %ecx
cmpl %edx, %ecx
ja 0x3798
movq (%rdi), %rdi
testq %rdi, %rdi
jne 0x3759
leaq 0x46a0(%rip), %rsi      # 0x7e18
movq %rsp, %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2210
movq %rbx, %rdi
callq 0x4d36
xorl %eax, %eax
addq $0x80, %rsp
popq %rbx
retq
addl $0x4, %edx
cmpl %ecx, %edx
jbe 0x37a8
leaq 0x468f(%rip), %rdi      # 0x7e35
jmp 0x3788
movq 0x20(%rdi), %rcx
movq %rax, %rdx
addq $0x80, %rsp
popq %rbx
jmpq *%rcx
// File: /workspace/github_c_makefile_star2_O3/hamsternz[P]emulate-risc-v/memorymap.c
// Function: memorymap_aligned_write
int memorymap_aligned_write(uint32_t address, uint8_t mask, uint32_t value) {
   struct region *r = first_region;

   /* Find the region */
   while(r != NULL) {
     if(address >= r->base && address < r->base+r->size)
       break;
     r = r->next;
   }

   /* If no region found then exit */
   if(r == NULL) {
     char buffer[128];
     sprintf(buffer, "Write of invalid address %08X",address);
     display_log(buffer);
     return 0;
   }

   /* Trap a currently unhandled error */
   if(address+4 > r->base + r->size) {
     display_log("Write to split the read of address as it crosses boundary");
     return 0;
   }
   return r->set(r, address-r->base, mask, value);
}

// Assembly:
pushq %rbx
subq $0x80, %rsp
movl %edx, %ecx
movl %edi, %edx
movq 0xd32c(%rip), %rdi      # 0x10af8
testq %rdi, %rdi
je 0x37ea
movl 0x8(%rdi), %r8d
movl %edx, %eax
subl %r8d, %eax
jb 0x37e5
addl 0xc(%rdi), %r8d
cmpl %edx, %r8d
ja 0x3811
movq (%rdi), %rdi
jmp 0x37cc
leaq 0x467d(%rip), %rsi      # 0x7e6e
movq %rsp, %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2210
movq %rbx, %rdi
callq 0x4d36
xorl %eax, %eax
addq $0x80, %rsp
popq %rbx
retq
addl $0x4, %edx
cmpl %r8d, %edx
jbe 0x3822
leaq 0x466c(%rip), %rdi      # 0x7e8c
jmp 0x3801
movq 0x18(%rdi), %r8
movzbl %sil, %edx
movl %eax, %esi
addq $0x80, %rsp
popq %rbx
jmpq *%r8
// File: /workspace/github_c_makefile_star2_O3/hamsternz[P]emulate-risc-v/memorymap.c
// Function: add_region
static int add_region(uint32_t base, uint32_t size, 
  int  (*init)(struct region *r),
  int (*get)(struct region *r, uint32_t address, uint32_t *value),
  int (*set)(struct region *r, uint32_t address, uint8_t mask, uint32_t value),
  void (*free)(struct region *r),
  void (*dump)(struct region *r)) {
  struct region *r = NULL;

  /* Allocate space */
  r = malloc(sizeof(struct region));
  if(r == NULL) {
    return 0;
  }

  /* Initialise it */
  memset(r,0,sizeof(struct region));
  r->base = base;
  r->size = size;
  r->init = init;
  r->get  = get;
  r->set  = set;
  r->free = free;
  r->dump = dump;

  /* Add to list */
  if(first_region == NULL) {
    first_region = r;
    r->next = NULL;
  } else {
    struct region *c = first_region;
    while(c->next != NULL)
      c = c->next;
    c->next = r;
    r->next = NULL;
  }
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r9, %rbx
movq %r8, %r14
movq %rcx, %r15
movq %rdx, %r12
movl %esi, %ebp
movl %edi, %r13d
movl $0x1, %edi
movl $0x40, %esi
callq 0x2140
testq %rax, %rax
je 0x3ad0
movq 0x40(%rsp), %rcx
movl %r13d, 0x8(%rax)
movl %ebp, 0xc(%rax)
movq %r12, 0x10(%rax)
movq %r15, 0x20(%rax)
movq %r14, 0x18(%rax)
movq %rbx, 0x28(%rax)
movq %rcx, 0x30(%rax)
movq 0xd03a(%rip), %rcx      # 0x10af8
testq %rcx, %rcx
je 0x3ad4
movq %rcx, %rdx
movq (%rcx), %rcx
testq %rcx, %rcx
jne 0x3ac3
jmp 0x3adb
xorl %eax, %eax
jmp 0x3aea
leaq 0xd01d(%rip), %rdx      # 0x10af8
movq %rax, (%rdx)
movq $0x0, (%rax)
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/hamsternz[P]emulate-risc-v/memorymap.c
// Function: memorymap_read
int memorymap_read(uint32_t address, uint8_t width, uint32_t *value) {
   uint32_t v, v1, mask;

   /* Mask out data we don't want */
   switch(width) {
     case 1:
       mask = 0xFF;
       break; 
     case 2:
       mask = 0xFFFF;
       break; 
     case 4:
       mask = 0xFFFFFFFF;
       break; 
     default:
       display_log("Invalid read width at address 0x%08x");
       return 0;
   }

   /* Read the memory region */
   switch(address & 3) {
     case 0:
       if(!memorymap_aligned_read(address+0, &v))  return 0;
       break;
     case 1:
       if(!memorymap_aligned_read(address-1, &v))  return 0;
       if(!memorymap_aligned_read(address+3, &v1)) return 0;
       v = (v>>8) | (v1 <<24);
       break;
     case 2:
       if(!memorymap_aligned_read(address-2, &v))  return 0;
       if(!memorymap_aligned_read(address+2, &v1)) return 0;
       v = (v>>16) | (v1 <<16);
       break;
     default:
       if(!memorymap_aligned_read(address-3, &v))  return 0;
       if(!memorymap_aligned_read(address+1, &v1)) return 0;
       v = (v>>24) | (v1 <<8);
       break;
   }
   /* Set the return value */
   *value = v & mask;
   return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movl %edi, %r14d
cmpl $0x1, %esi
je 0x3b4d
cmpl $0x4, %esi
je 0x3b31
cmpl $0x2, %esi
jne 0x3b80
movl $0xffff, %r15d          # imm = 0xFFFF
movl %r14d, %eax
andl $0x3, %eax
leaq 0x4270(%rip), %rcx      # 0x7d98
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movl %r14d, %eax
andl $0x3, %eax
leaq 0x4254(%rip), %rcx      # 0x7d98
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0xff, %r15d
movl %r14d, %eax
andl $0x3, %eax
leaq 0x4238(%rip), %rcx      # 0x7d98
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rsp, %rsi
movl %r14d, %edi
callq 0x3740
testl %eax, %eax
je 0x3b8c
movl (%rsp), %eax
jmp 0x3c30
leaq 0x4390(%rip), %rdi      # 0x7f17
callq 0x4d36
xorl %ebp, %ebp
jmp 0x3c3b
leal -0x2(%r14), %edi
movq %rsp, %rsi
callq 0x3740
xorl %ebp, %ebp
testl %eax, %eax
je 0x3c3b
addl $0x2, %r14d
leaq 0x4(%rsp), %rsi
movl %r14d, %edi
callq 0x3740
testl %eax, %eax
je 0x3c3b
movl (%rsp), %ecx
movl 0x4(%rsp), %eax
shldl $0x10, %ecx, %eax
jmp 0x3c30
leal -0x3(%r14), %edi
movq %rsp, %rsi
callq 0x3740
xorl %ebp, %ebp
testl %eax, %eax
je 0x3c3b
incl %r14d
leaq 0x4(%rsp), %rsi
movl %r14d, %edi
callq 0x3740
testl %eax, %eax
je 0x3c3b
movl (%rsp), %ecx
movl 0x4(%rsp), %eax
shldl $0x8, %ecx, %eax
jmp 0x3c30
leal -0x1(%r14), %edi
movq %rsp, %rsi
callq 0x3740
xorl %ebp, %ebp
testl %eax, %eax
je 0x3c3b
addl $0x3, %r14d
leaq 0x4(%rsp), %rsi
movl %r14d, %edi
callq 0x3740
testl %eax, %eax
je 0x3c3b
movl (%rsp), %ecx
movl 0x4(%rsp), %eax
shldl $0x18, %ecx, %eax
andl %eax, %r15d
movl %r15d, (%rbx)
movl $0x1, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/hamsternz[P]emulate-risc-v/memorymap.c
// Function: memorymap_finish
void memorymap_finish(void) {
   while(first_region != NULL) {
      struct region *r = first_region;
      first_region = first_region->next;
      r->free(r);
      free(r);
   }
}

// Assembly:
pushq %rbx
movq 0xcc43(%rip), %rbx      # 0x10af8
testq %rbx, %rbx
je 0x3ed4
movq (%rbx), %rax
movq %rax, 0xcc34(%rip)      # 0x10af8
movq %rbx, %rdi
callq *0x28(%rbx)
movq %rbx, %rdi
callq 0x2040
jmp 0x3eae
popq %rbx
retq
nop
// File: /workspace/github_c_makefile_star2_O3/hamsternz[P]emulate-risc-v/ram.c
// Function: RAM_init
int RAM_init(struct region *r) {
  uint32_t *data;

  if(r->data != NULL) {
    display_log("RAM already initialized");
    return 0;
  }
 
  data = malloc(r->size);
  if(data == NULL){
    return 0;
  }
  r->data = (void *)data;
  memset(r->data, 0, r->size);
  attempt_to_read(r);
  display_log("Set up memory region");
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
cmpq $0x0, 0x38(%rdi)
je 0x3efd
leaq 0x4081(%rip), %rdi      # 0x7f72
callq 0x4d36
xorl %eax, %eax
jmp 0x4089
movq %rdi, %rbx
movl 0xc(%rdi), %esi
movl $0x1, %edi
callq 0x2140
testq %rax, %rax
je 0x3ef6
movq %rax, %r14
movq %rax, 0x38(%rbx)
movl 0x8(%rbx), %edx
leaq 0x4121(%rip), %rsi      # 0x8044
movq %rsp, %rdi
xorl %eax, %eax
callq 0x21b0
testl %eax, %eax
jle 0x4048
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x406c
leaq 0x415c(%rip), %rsi      # 0x80a5
callq 0x21d0
testq %rax, %rax
je 0x4098
movq %rax, %r15
movq (%rsp), %rdi
callq 0x2040
xorl %r12d, %r12d
movq %r15, %rdi
callq 0x2110
cmpl $0xa, %eax
je 0x3f66
cmpl $0xd, %eax
je 0x3f66
cmpl $-0x1, %eax
je 0x4051
leal -0x30(%rax), %ebp
cmpl $0x9, %ebp
jbe 0x3fb0
leal -0x41(%rax), %ecx
cmpl $0x5, %ecx
ja 0x3f96
addl $-0x37, %eax
jmp 0x3fa1
leal -0x61(%rax), %ecx
cmpl $0x5, %ecx
ja 0x3fa5
addl $-0x57, %eax
movl %eax, %ebp
jmp 0x3fb0
xorl %ebp, %ebp
cmpl $0x20, %eax
jne 0x40ab
movl $0x7, %r13d
movq %r15, %rdi
callq 0x2110
leal -0x30(%rax), %ecx
cmpl $0x9, %ecx
ja 0x3fcd
shll $0x4, %ebp
orl %ecx, %ebp
jmp 0x3fef
leal -0x41(%rax), %ecx
cmpl $0x5, %ecx
ja 0x3fdf
shll $0x4, %ebp
addl %eax, %ebp
addl $-0x37, %ebp
jmp 0x3fef
leal -0x61(%rax), %ecx
cmpl $0x5, %ecx
ja 0x4017
shll $0x4, %ebp
addl %eax, %ebp
addl $-0x57, %ebp
decl %r13d
jne 0x3fb6
movl %ebp, (%r14,%r12,4)
incq %r12
cmpl $-0x1, %eax
je 0x3f66
cmpl $0xa, %eax
je 0x3f66
movq %r15, %rdi
callq 0x2110
jmp 0x3ffb
cmpl $0x20, %eax
ja 0x40a2
movl %eax, %ecx
movabsq $0x100000600, %rdx      # imm = 0x100000600
btq %rcx, %rdx
jae 0x40a2
leal 0x3(,%r12,4), %ecx
cmpl 0xc(%rbx), %ecx
jb 0x3ff4
leaq 0x40b3(%rip), %rdi      # 0x80f9
jmp 0x4073
leaq 0x4002(%rip), %rdi      # 0x8051
jmp 0x4073
leaq 0x4067(%rip), %rdi      # 0x80bf
movl %r12d, %esi
xorl %eax, %eax
callq 0x20c0
movq %r15, %rdi
callq 0x2090
jmp 0x4078
leaq 0x4009(%rip), %rdi      # 0x807c
callq 0x4d36
leaq 0x3f0b(%rip), %rdi      # 0x7f8a
callq 0x4d36
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsp, %rdi
callq 0x22ac
jmp 0x4078
leaq 0x4070(%rip), %rdi      # 0x8119
jmp 0x4073
callq 0x228a
jmp 0x4078
// File: /workspace/github_c_makefile_star2_O3/hamsternz[P]emulate-risc-v/ram.c
// Function: RAM_set
int RAM_set(struct region *r, uint32_t address, uint8_t mask, uint32_t value) {

   if(address+4 > r->size) {
     fprintf(stderr,"Memory region boundary crossed at 0x%08x\n", r->base+address);
     return 0;
   }

   if((address & 3) != 0) {
     fprintf(stderr,"Unaligned memory write 0x%08x\n", r->base+address);
   }
#if 0
   fprintf(stderr, "Write %08x %x, 0x%08x\n", address, mask, value);
#endif
   if(mask & 1) {
      ((unsigned char *)r->data)[address+0] = value; 
   }
   if(mask & 2) {
      ((unsigned char *)r->data)[address+1] = value>>8; 
   }
   if(mask & 4) {
      ((unsigned char *)r->data)[address+2] = value>>16; 
   }
   if(mask & 8) {
      ((unsigned char *)r->data)[address+3] = value>>24; 
   }
   return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %esi, %ebx
movq %rdi, %r14
leal 0x4(%rbx), %eax
cmpl 0xc(%rdi), %eax
ja 0x4137
movl %ecx, %r12d
movl %edx, %ebp
testb $0x3, %bl
jne 0x415a
testb $0x1, %bpl
je 0x40e7
movq 0x38(%r14), %rax
movl %ebx, %ecx
movl %r12d, %edx
movb %dl, (%rax,%rcx)
testb $0x2, %bpl
je 0x40fa
movq 0x38(%r14), %rax
leal 0x1(%rbx), %ecx
movl %r12d, %edx
movb %dh, (%rax,%rcx)
testb $0x4, %bpl
je 0x4110
movl %r12d, %eax
shrl $0x10, %eax
movq 0x38(%r14), %rcx
leal 0x2(%rbx), %edx
movb %al, (%rcx,%rdx)
movl $0x1, %r15d
testb $0x8, %bpl
je 0x412b
shrl $0x18, %r12d
movq 0x38(%r14), %rax
addl $0x3, %ebx
movb %r12b, (%rax,%rbx)
movl %r15d, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x7eba(%rip), %rax      # 0xbff8
movq (%rax), %rdi
addl 0x8(%r14), %ebx
leaq 0x3e53(%rip), %rsi      # 0x7f9f
xorl %r15d, %r15d
movl %ebx, %edx
xorl %eax, %eax
callq 0x2150
jmp 0x412b
movq 0x7e97(%rip), %rax      # 0xbff8
movq (%rax), %rdi
movl 0x8(%r14), %edx
addl %ebx, %edx
leaq 0x3e58(%rip), %rsi      # 0x7fc9
xorl %eax, %eax
callq 0x2150
jmp 0x40d5
// File: /workspace/github_c_makefile_star2_O3/hamsternz[P]emulate-risc-v/ram.c
// Function: RAM_get
int RAM_get(struct region *r, uint32_t address, uint32_t *value) {
   uint32_t v = 0;
   if((address & 3) != 0) {
     fprintf(stderr,"Unaligned memory read 0x%08x\n", r->base+address);
     return 0;
   }

   if(address+4 > r->size) {
     fprintf(stderr,"Memory region boundary crossed at 0x%08x\n", r->base+address);
     return 0;
   }

   v = ((unsigned char *)r->data)[address++]; 
   v = v + (((unsigned char *)r->data)[address++] << 8); 
   v = v + (((unsigned char *)r->data)[address++] << 16); 
   v = v + (((unsigned char *)r->data)[address++] << 24); 
   *value = v;
   return 1;
}

// Assembly:
pushq %rbx
movl %esi, %eax
testb $0x3, %al
jne 0x41a0
leal 0x4(%rax), %ecx
cmpl 0xc(%rdi), %ecx
ja 0x41b6
movq 0x38(%rdi), %rcx
movl %eax, %eax
movl (%rcx,%rax), %eax
movl %eax, (%rdx)
movl $0x1, %ebx
movl %ebx, %eax
popq %rbx
retq
movq 0x7e51(%rip), %rcx      # 0xbff8
movq (%rcx), %rcx
addl 0x8(%rdi), %eax
leaq 0x3e34(%rip), %rsi      # 0x7fe8
jmp 0x41ca
movq 0x7e3b(%rip), %rcx      # 0xbff8
movq (%rcx), %rcx
addl 0x8(%rdi), %eax
leaq 0x3dd5(%rip), %rsi      # 0x7f9f
xorl %ebx, %ebx
movq %rcx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0x2150
jmp 0x419c
// File: /workspace/github_c_makefile_star2_O3/hamsternz[P]emulate-risc-v/ram.c
// Function: RAM_dump
void RAM_dump(struct region *r) {
   int i;

   printf("RAM 0x%08x length 0x%08x\n", r->base, r->size);
   for(i = 0; i < r->size && i < 4096; i++) {
      if(i%32 == 0) {
	 printf("%08x:", r->base+i);
      }
      printf(" %02x", ((unsigned char *)(r->data))[i]);
      if(i%32 == 31)
	 printf("\n");
   }
   if(i%32 != 0)
     printf("\n");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
movl 0x8(%rdi), %esi
movl 0xc(%rdi), %edx
leaq 0x3e14(%rip), %rdi      # 0x8006
xorl %eax, %eax
callq 0x20c0
cmpl $0x0, 0xc(%rbx)
je 0x4279
leaq 0x3e1a(%rip), %r14      # 0x8020
leaq 0x3e19(%rip), %r15      # 0x8026
xorl %r12d, %r12d
movl %r12d, %ebp
andl $0x1f, %ebp
jne 0x4228
movl 0x8(%rbx), %esi
addl %r12d, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x20c0
movq 0x38(%rbx), %rax
movzbl (%rax,%r12), %esi
movq %r15, %rdi
xorl %eax, %eax
callq 0x20c0
cmpl $0x1f, %ebp
jne 0x424a
movl $0xa, %edi
callq 0x2050
leaq 0x1(%r12), %rax
cmpq $0xffe, %r12            # imm = 0xFFE
ja 0x4263
movl 0xc(%rbx), %ecx
movq %rax, %r12
cmpq %rcx, %rax
jb 0x4210
testb $0x1f, %al
je 0x4279
movl $0xa, %edi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x2050
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/hamsternz[P]emulate-risc-v/ram.c
// Function: RAM_free
void RAM_free(struct region *r) {
   char buffer[100];
   sprintf(buffer, "Releasing RAM at 0x%08x", r->base);
   display_log(buffer);
   if(r->data != NULL) 
     free(r->data);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x68, %rsp
movq %rdi, %rbx
movl 0x8(%rdi), %edx
leaq 0x3d96(%rip), %rsi      # 0x802c
movq %rsp, %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x2210
movq %r14, %rdi
callq 0x4d36
movq 0x38(%rbx), %rdi
testq %rdi, %rdi
je 0x42b9
callq 0x2040
addq $0x68, %rsp
popq %rbx
popq %r14
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O3/hamsternz[P]emulate-risc-v/uart.c
// Function: UART_init
int UART_init(struct region *r) {
  struct uart_data *data;

  if(r->data != NULL) {
    display_log("UART already initialized");
    return 0;
  }
 
  data = malloc(sizeof(struct uart_data));
  if(data == NULL){
    return 0;
  }

  memset(data, 0, sizeof(struct uart_data));
  data->divisor = 0xffff;
  data->debug   = UART_DEBUG;
  r->data = (void *)data;

  display_log("Set up UART region");
  return 1;
}

// Assembly:
pushq %rbx
cmpq $0x0, 0x38(%rdi)
je 0x42d7
xorl %ebx, %ebx
leaq 0x3e9b(%rip), %rdi      # 0x8170
jmp 0x4303
movq %rdi, %rbx
movl $0x1, %edi
movl $0x22, %esi
callq 0x2140
testq %rax, %rax
je 0x430c
movw $0xffff, (%rax)         # imm = 0xFFFF
movq %rax, 0x38(%rbx)
movl $0x1, %ebx
leaq 0x3e86(%rip), %rdi      # 0x8189
callq 0x4d36
movl %ebx, %eax
popq %rbx
retq
xorl %ebx, %ebx
jmp 0x4308
// File: /workspace/github_c_makefile_star2_O3/hamsternz[P]emulate-risc-v/uart.c
// Function: UART_rx_enqueue
void UART_rx_enqueue(struct region *r, uint8_t c) {
  char buffer[100];
  struct uart_data *data = r->data;
  if(data->rx_enable) {
    if(data->rx_count < UART_QUEUE_DEPTH) {
      data->rx_fifo[data->tx_write_ptr] = c;
      data->rx_count++;
      data->tx_write_ptr = (data->tx_write_ptr == UART_FIFO_SIZE-1) ? 0 : data->tx_write_ptr+1;
      if(data->debug) {
        sprintf(buffer,"UART data added to rx queue 0x%02x", c);
        display_log(buffer);
      }
    } else {
      if(data->debug) {
        sprintf(buffer,"UART rx queue overflow adding 0x%02x", c);
        display_log(buffer);
      }
    }
  } else {
    if(data->debug) {
      sprintf(buffer,"UART rx disabled while adding 0x%02x", c);
      display_log(buffer);
    }
  }
}

// Assembly:
movq 0x38(%rdi), %rax
cmpb $0x0, 0x1b(%rax)
je 0x457d
cmpb $0x7, 0x17(%rax)
ja 0x458c
movzbl 0xb(%rax), %ecx
movb %sil, 0xd(%rax,%rcx)
incb 0x17(%rax)
leal 0x1(%rcx), %edx
xorl %edi, %edi
cmpq $0x7, %rcx
movzbl %dl, %ecx
cmovel %edi, %ecx
movb %cl, 0xb(%rax)
cmpb $0x0, 0x21(%rax)
je 0x45bf
leaq 0x3d40(%rip), %rax      # 0x82bb
jmp 0x4599
cmpb $0x0, 0x21(%rax)
je 0x45bf
leaq 0x3d79(%rip), %rax      # 0x8303
jmp 0x4599
cmpb $0x0, 0x21(%rax)
je 0x45bf
leaq 0x3d45(%rip), %rax      # 0x82de
pushq %rbx
subq $0x70, %rsp
movzbl %sil, %edx
movq %rsp, %rbx
movq %rbx, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0x2210
movq %rbx, %rdi
callq 0x4d36
addq $0x70, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/hamsternz[P]emulate-risc-v/uart.c
// Function: UART_free
void UART_free(struct region *r) {
   char buffer[100];
   sprintf(buffer, "Releasing UART at 0x%08x", r->base);
   display_log(buffer);
   if(r->data != NULL) 
     free(r->data);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x68, %rsp
movq %rdi, %rbx
movl 0x8(%rdi), %edx
leaq 0x3c50(%rip), %rsi      # 0x847f
movq %rsp, %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x2210
movq %r14, %rdi
callq 0x4d36
movq 0x38(%rbx), %rdi
testq %rdi, %rdi
je 0x4852
callq 0x2040
addq $0x68, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_c_makefile_star2_O3/hamsternz[P]emulate-risc-v/display.c
// Function: display_log
void display_log(char *str) {
  if(log_file != NULL) {
    fprintf(log_file,"%s\n",str);
  }
  if(log_index == N_LOG) {
    ////////////////////
    // Free up a line 
    ////////////////////
    int i;
    if(log_lines[0] != NULL)
      free(log_lines[0]);
    for(i = 1; i < N_LOG; i++) {
      log_lines[i-1] = log_lines[i];
    }	    
    log_lines[N_LOG-1] = NULL;
    log_index--;
    log_changed = 1;
  }  

  log_lines[log_index] = malloc(strlen(str)+1);

  if(log_lines[log_index] == NULL)
    return;

  log_changed = 1;
  strcpy(log_lines[log_index],str);
  log_index++;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0xbdbd(%rip), %rdi      # 0x10b00
testq %rdi, %rdi
je 0x4d59
leaq 0x3801(%rip), %rsi      # 0x8550
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2150
movl 0xbed5(%rip), %ebp      # 0x10c34
cmpl $0x6, %ebp
jne 0x4dc0
movq 0xbed5(%rip), %rdi      # 0x10c40
testq %rdi, %rdi
je 0x4d75
callq 0x2040
movups 0xbecc(%rip), %xmm0     # 0x10c48
movaps %xmm0, 0xbebd(%rip)     # 0x10c40
movups 0xbece(%rip), %xmm0     # 0x10c58
movaps %xmm0, 0xbebf(%rip)     # 0x10c50
movq 0xbed0(%rip), %rax      # 0x10c68
movq %rax, 0xbec1(%rip)      # 0x10c60
movq $0x0, 0xbebe(%rip) # 0x10c68
movl $0x5, 0xbe80(%rip)      # 0x10c34
movb $0x0, 0xbe6d(%rip)      # 0x10c28
movl $0x5, %ebp
movq %rbx, %rdi
callq 0x20a0
leaq 0x1(%rax), %rdi
callq 0x21a0
movslq %ebp, %rcx
leaq 0xbe65(%rip), %rdx      # 0x10c40
movq %rax, (%rdx,%rcx,8)
testq %rax, %rax
je 0x4dfe
movb $0x0, 0xbe3d(%rip)      # 0x10c28
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2070
incl %ebp
movl %ebp, 0xbe36(%rip)      # 0x10c34
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/hamsternz[P]emulate-risc-v/display.c
// Function: display_trace
void display_trace(char *str) {
  int i; 
  trace_changed = 1;

  if(trace_index == N_TRACE) {
    char *temp;
    ////////////////////
    // Move top line to the bottom (to be overwritten)
    ////////////////////
    temp = trace_lines[0];
    for(i = 1; i < N_TRACE; i++) {
      trace_lines[i-1] = trace_lines[i];
    }
    trace_lines[N_TRACE-1] = temp;
    trace_index--;
  } 

  if(trace_lines[trace_index] == NULL)
    return;

  for(i = 0; str[i] != '\0' && i < TRACE_WIDTH; i++){
    trace_lines[trace_index][i] = str[i];
  }

  for(; i < TRACE_WIDTH; i++) {
    trace_lines[trace_index][i] = ' ';
  }

  trace_index++;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %r14
movb $0x0, 0xbe19(%rip)      # 0x10c2c
movslq 0xbe56(%rip), %rax      # 0x10c70
cmpq $0x11, %rax
jne 0x4e57
movq 0xbce9(%rip), %rbx      # 0x10b10
leaq 0xbce2(%rip), %rdi      # 0x10b10
leaq 0xbce3(%rip), %rsi      # 0x10b18
movl $0x80, %edx
callq 0x21c0
movq %rbx, 0xbd4a(%rip)      # 0x10b90
movl $0x10, 0xbe20(%rip)     # 0x10c70
movl $0x11, %ebp
jmp 0x4e65
leaq 0xbcb2(%rip), %rcx      # 0x10b10
movq (%rcx,%rax,8), %rbx
leal 0x1(%rax), %ebp
testq %rbx, %rbx
je 0x4eb9
movb (%r14), %dl
testb %dl, %dl
je 0x4e98
xorl %ecx, %ecx
movb %dl, (%rbx,%rcx)
leaq 0x1(%rcx), %rax
cmpq $0x32, %rcx
ja 0x4e8c
movb 0x1(%r14,%rcx), %dl
movq %rax, %rcx
testb %dl, %dl
jne 0x4e73
leaq -0x1(%rax), %rcx
cmpq $0x32, %rcx
jbe 0x4e9a
jmp 0x4eb3
xorl %eax, %eax
movl %eax, %ecx
addq %rcx, %rbx
movl $0x34, %edx
subl %eax, %edx
movq %rbx, %rdi
movl $0x20, %esi
callq 0x20f0
movl %ebp, 0xbdb7(%rip)      # 0x10c70
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/hamsternz[P]emulate-risc-v/display.c
// Function: display_process_input
void display_process_input(int *run, int *quit, int *trace, int *reset) {
  int key = getch();
  switch(key) {
    case 'R':
       *reset = 1;
       break;
    case 'r':
       *run = *run ? 0 : 2;
       break;
    case 't':
       *trace = !*trace;
       break;
    case 'q':
       *quit = !*quit;
       break;
    case ' ':
       *run = 1;
       break;
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r15
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %rbx
movq 0x70ff(%rip), %rax      # 0xbfd8
movq (%rax), %rdi
callq 0x2080
cmpl $0x70, %eax
jle 0x4f03
cmpl $0x71, %eax
je 0x4f16
cmpl $0x72, %eax
je 0x4f26
cmpl $0x74, %eax
jne 0x4f3a
xorl %eax, %eax
cmpl $0x0, (%r14)
sete %al
movl %eax, (%r14)
jmp 0x4f3a
cmpl $0x20, %eax
je 0x4f34
cmpl $0x52, %eax
jne 0x4f3a
movl $0x1, (%r15)
jmp 0x4f3a
xorl %eax, %eax
cmpl $0x0, (%r12)
sete %al
movl %eax, (%r12)
jmp 0x4f3a
xorl %eax, %eax
cmpl $0x0, (%rbx)
sete %al
addl %eax, %eax
movl %eax, (%rbx)
jmp 0x4f3a
movl $0x1, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/hamsternz[P]emulate-risc-v/display.c
// Function: display_uart_write
void display_uart_write(char c) {

  /* Only display printable characters */
  if(c > 27 && c < 127) {
    uart_lines[uart_cursor_y][uart_cursor_x] = c;
    uart_cursor_x++;
  }

  /* Caridge return brings the cursor to the left */
  if(c == '\r') {
    uart_cursor_x = 0;
  }

  /* Do we need to move to the next line? */
  if(c == '\n' || uart_cursor_x == UART_WIDTH) {
    uart_cursor_y++;
    uart_cursor_x = 0;
    /* Have we run out of lines */
    if(uart_cursor_y == N_UART) {
      /* shuffle the lines up, moving the first line to the end */
      int i;
      char *t = uart_lines[0];
      for(i = 1; i < N_UART; i++) {
	uart_lines[i-1] = uart_lines[i];
      }
      uart_lines[N_UART-1] = t;

      /* Empty out the first line */
      memset(uart_lines[N_UART-1],' ', UART_WIDTH);
      uart_cursor_y--;
    }
  }
  uart_changed = 1;
}

// Assembly:
leal -0x1c(%rdi), %eax
cmpb $0x62, %al
ja 0x4f75
movslq 0xbd20(%rip), %rax      # 0x10c74
leaq 0xbc45(%rip), %rcx      # 0x10ba0
movq (%rcx,%rax,8), %rax
movslq 0xbd12(%rip), %rcx      # 0x10c78
movb %dil, (%rax,%rcx)
leal 0x1(%rcx), %eax
movl %eax, 0xbd05(%rip)      # 0x10c78
jmp 0x4f8f
cmpb $0xd, %dil
jne 0x4f89
movl $0x0, 0xbcf3(%rip)      # 0x10c78
xorl %eax, %eax
jmp 0x4f8f
movl 0xbce9(%rip), %eax      # 0x10c78
cmpb $0xa, %dil
je 0x4f9a
cmpl $0x50, %eax
jne 0x5010
movl 0xbcd4(%rip), %eax      # 0x10c74
leal 0x1(%rax), %ecx
movl %ecx, 0xbccb(%rip)      # 0x10c74
movl $0x0, 0xbcc5(%rip)      # 0x10c78
cmpl $0x6, %ecx
jne 0x5010
movq 0xbbe1(%rip), %rcx      # 0x10ba0
movups 0xbbe2(%rip), %xmm0     # 0x10ba8
movups 0xbbeb(%rip), %xmm1     # 0x10bb8
movaps %xmm1, 0xbbdc(%rip)     # 0x10bb0
movq 0xbbed(%rip), %rdx      # 0x10bc8
movq %rdx, 0xbbde(%rip)      # 0x10bc0
movaps %xmm0, 0xbbb7(%rip)     # 0x10ba0
movq %rcx, 0xbbd8(%rip)      # 0x10bc8
movaps 0x34a9(%rip), %xmm0     # 0x84a0
movups %xmm0, 0x40(%rcx)
movups %xmm0, 0x30(%rcx)
movups %xmm0, 0x20(%rcx)
movups %xmm0, 0x10(%rcx)
movups %xmm0, (%rcx)
movl %eax, 0xbc64(%rip)      # 0x10c74
movb $0x0, 0xbc19(%rip)      # 0x10c30
retq
// File: /workspace/github_c_makefile_star2_O3/hamsternz[P]emulate-risc-v/display.c
// Function: display_end
void display_end(void) {
  int i;
  if(log_file != NULL) {
    fclose(log_file);
    log_file = NULL;
  }
  for(i = 0; i < N_TRACE; i++) {
    if(trace_lines[i] != NULL)
      free(trace_lines[i]);
  }
  endwin();
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq 0xbadd(%rip), %rdi      # 0x10b00
testq %rdi, %rdi
je 0x5038
callq 0x2090
movq $0x0, 0xbac8(%rip) # 0x10b00
xorl %ebx, %ebx
leaq 0xbacf(%rip), %r14      # 0x10b10
movq (%rbx,%r14), %rdi
testq %rdi, %rdi
je 0x504f
callq 0x2040
addq $0x8, %rbx
cmpq $0x88, %rbx
jne 0x5041
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2230
// File: /workspace/github_c_makefile_star2_O3/hamsternz[P]emulate-risc-v/prci.c
// Function: PRCI_init
int PRCI_init(struct region *r) {
  uint32_t *data;

  if(r->data != NULL) {
    display_log("PRCI already initialized");
    return 0;
  }
 
  data = malloc(r->size);
  if(data == NULL){
    return 0;
  }
  r->data = (void *)data;
  memset(r->data, 0, r->size);
  display_log("Set up PRCI region");
  return 1;
}

// Assembly:
pushq %rbx
cmpq $0x0, 0x38(%rdi)
je 0x507b
xorl %ebx, %ebx
leaq 0x3546(%rip), %rdi      # 0x85bf
jmp 0x50a0
movq %rdi, %rbx
movl 0xc(%rdi), %esi
movl $0x1, %edi
callq 0x2140
testq %rax, %rax
je 0x50a9
movq %rax, 0x38(%rbx)
movl $0x1, %ebx
leaq 0x3538(%rip), %rdi      # 0x85d8
callq 0x4d36
movl %ebx, %eax
popq %rbx
retq
xorl %ebx, %ebx
jmp 0x50a5
// File: /workspace/github_c_makefile_star2_O3/hamsternz[P]emulate-risc-v/prci.c
// Function: PRCI_set
int PRCI_set(struct region *r, uint32_t address, uint8_t mask, uint32_t value) {
   char buffer[100];
   if(address+4 > r->size) {
     fprintf(stderr,"Memory region boundary crossed at 0x%08x\n", r->base+address);
     return 0;
   }

   if((address & 3) != 0) {
     fprintf(stderr,"Unaligned memory write 0x%08x\n", r->base+address);
   }
   sprintf(buffer,"PRCI Wr address 0x%08x: 0x%08x", address, value);
   display_log(buffer);

   if(mask & 1) {
      ((unsigned char *)r->data)[address+0] = value; 
   }
   if(mask & 2) {
      ((unsigned char *)r->data)[address+1] = value>>8; 
   }
   if(mask & 4) {
      ((unsigned char *)r->data)[address+2] = value>>16; 
   }
   if(mask & 8) {
      ((unsigned char *)r->data)[address+3] = value>>24; 
   }
   return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x70, %rsp
movl %esi, %ebx
movq %rdi, %r14
leal 0x4(%rbx), %eax
cmpl 0xc(%rdi), %eax
ja 0x515f
movl %ecx, %r12d
movl %edx, %ebp
testb $0x3, %bl
jne 0x5182
leaq 0x350c(%rip), %rsi      # 0x85eb
movq %rsp, %r15
movq %r15, %rdi
movl %ebx, %edx
movl %r12d, %ecx
xorl %eax, %eax
callq 0x2210
movq %r15, %rdi
callq 0x4d36
testb $0x1, %bpl
je 0x510b
movq 0x38(%r14), %rax
movl %ebx, %ecx
movl %r12d, %edx
movb %dl, (%rax,%rcx)
testb $0x2, %bpl
je 0x511e
movq 0x38(%r14), %rax
leal 0x1(%rbx), %ecx
movl %r12d, %edx
movb %dh, (%rax,%rcx)
testb $0x4, %bpl
je 0x5134
movl %r12d, %eax
shrl $0x10, %eax
movq 0x38(%r14), %rcx
leal 0x2(%rbx), %edx
movb %al, (%rcx,%rdx)
movl $0x1, %r15d
testb $0x8, %bpl
je 0x514f
shrl $0x18, %r12d
movq 0x38(%r14), %rax
addl $0x3, %ebx
movb %r12b, (%rax,%rbx)
movl %r15d, %eax
addq $0x70, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x6e92(%rip), %rax      # 0xbff8
movq (%rax), %rdi
addl 0x8(%r14), %ebx
leaq 0x2e2b(%rip), %rsi      # 0x7f9f
xorl %r15d, %r15d
movl %ebx, %edx
xorl %eax, %eax
callq 0x2150
jmp 0x514f
movq 0x6e6f(%rip), %rax      # 0xbff8
movq (%rax), %rdi
movl 0x8(%r14), %edx
addl %ebx, %edx
leaq 0x2e30(%rip), %rsi      # 0x7fc9
xorl %eax, %eax
callq 0x2150
jmp 0x50d8
// File: /workspace/github_c_makefile_star2_O3/hamsternz[P]emulate-risc-v/prci.c
// Function: PRCI_get
int PRCI_get(struct region *r, uint32_t address, uint32_t *value) {
   uint32_t v = 0;
   char buffer[100];
   if((address & 3) != 0) {
     fprintf(stderr,"Unaligned memory read 0x%08x\n", r->base+address);
     return 0;
   }

   if(address+4 > r->size) {
     fprintf(stderr,"Memory region boundary crossed at 0x%08x\n", r->base+address);
     return 0;
   }

   v = ((unsigned char *)r->data)[address]; 
   v = v + (((unsigned char *)r->data)[address+1] << 8); 
   v = v + (((unsigned char *)r->data)[address+2] << 16); 
   v = v + (((unsigned char *)r->data)[address+3] << 24); 

   switch(address) {
     case 0:
       v |= 1<<31; // HF Lock flag
       break;
     case 8:
       v |= 1<<31; // PLL Lock flag
       break;    
   }
   *value = v;
     
   sprintf(buffer,"PRCI Rd address 0x%08x: 0x%08x", address, v);
   display_log(buffer);

   return 1;
}

// Assembly:
pushq %rbx
subq $0x70, %rsp
movq %rdx, %rax
movl %esi, %edx
testb $0x3, %dl
jne 0x51ff
leal 0x4(%rdx), %ecx
cmpl 0xc(%rdi), %ecx
ja 0x5215
movq 0x38(%rdi), %rcx
movl %edx, %esi
movl (%rcx,%rsi), %ecx
cmpl $0x8, %edx
je 0x51ce
testl %edx, %edx
jne 0x51d4
orl $0x80000000, %ecx       # imm = 0x80000000
movl %ecx, (%rax)
leaq 0x342d(%rip), %rsi      # 0x860a
movq %rsp, %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2210
movq %rbx, %rdi
callq 0x4d36
movl $0x1, %ebx
movl %ebx, %eax
addq $0x70, %rsp
popq %rbx
retq
movq 0x6df2(%rip), %rax      # 0xbff8
movq (%rax), %rax
addl 0x8(%rdi), %edx
leaq 0x2dd5(%rip), %rsi      # 0x7fe8
jmp 0x5229
movq 0x6ddc(%rip), %rax      # 0xbff8
movq (%rax), %rax
addl 0x8(%rdi), %edx
leaq 0x2d76(%rip), %rsi      # 0x7f9f
xorl %ebx, %ebx
movq %rax, %rdi
xorl %eax, %eax
callq 0x2150
jmp 0x51f7
// File: /workspace/github_c_makefile_star2_O3/hamsternz[P]emulate-risc-v/prci.c
// Function: PRCI_free
void PRCI_free(struct region *r) {
   char buffer[100];
   sprintf(buffer, "Releasing PRCI at 0x%08x", r->base);
   display_log(buffer);
   if(r->data != NULL) 
     free(r->data);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x68, %rsp
movq %rdi, %rbx
movl 0x8(%rdi), %edx
leaq 0x3351(%rip), %rsi      # 0x8644
movq %rsp, %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x2210
movq %r14, %rdi
callq 0x4d36
movq 0x38(%rbx), %rdi
testq %rdi, %rdi
je 0x5316
callq 0x2040
addq $0x68, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_c_makefile_star2_O3/hamsternz[P]emulate-risc-v/rom.c
// Function: ROM_init
int ROM_init(struct region *r) {
  uint32_t *data;

  if(r->data != NULL) {
    display_log("ROM already initialized");
    return 0;
  }
 
  data = malloc(r->size);
  if(data == NULL){
    return 0;
  }
  r->data = (void *)data;
  memset(r->data, 0, r->size);
  attempt_to_read(r);
  display_log("Set up memory region");
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
cmpq $0x0, 0x38(%rdi)
je 0x5348
leaq 0x3321(%rip), %rdi      # 0x865d
callq 0x4d36
xorl %eax, %eax
jmp 0x54dc
movq %rdi, %rbx
movl 0xc(%rdi), %esi
movl $0x1, %edi
callq 0x2140
testq %rax, %rax
je 0x5341
movq %rax, %r14
movq %rax, 0x38(%rbx)
movl 0x8(%rbx), %edx
leaq 0x3352(%rip), %rsi      # 0x86c0
leaq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0x21b0
testl %eax, %eax
jle 0x549b
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x54bf
leaq 0x2d0e(%rip), %rsi      # 0x80a5
callq 0x21d0
testq %rax, %rax
je 0x54eb
movq %rax, %r15
movq 0x8(%rsp), %rdi
callq 0x2040
xorl %r12d, %r12d
movq %r15, %rdi
callq 0x2110
cmpl $0xa, %eax
je 0x53b5
cmpl $0xd, %eax
je 0x53b5
cmpl $-0x1, %eax
je 0x54a4
leal -0x30(%rax), %ebp
cmpl $0x9, %ebp
jbe 0x53ff
leal -0x41(%rax), %ecx
cmpl $0x5, %ecx
ja 0x53e5
addl $-0x37, %eax
jmp 0x53f0
leal -0x61(%rax), %ecx
cmpl $0x5, %ecx
ja 0x53f4
addl $-0x57, %eax
movl %eax, %ebp
jmp 0x53ff
xorl %ebp, %ebp
cmpl $0x20, %eax
jne 0x5523
movl $0x7, %r13d
movq %r15, %rdi
callq 0x2110
leal -0x30(%rax), %ecx
cmpl $0x9, %ecx
ja 0x541c
shll $0x4, %ebp
orl %ecx, %ebp
jmp 0x543e
leal -0x41(%rax), %ecx
cmpl $0x5, %ecx
ja 0x542e
shll $0x4, %ebp
addl %eax, %ebp
addl $-0x37, %ebp
jmp 0x543e
leal -0x61(%rax), %ecx
cmpl $0x5, %ecx
ja 0x5466
shll $0x4, %ebp
addl %eax, %ebp
addl $-0x57, %ebp
decl %r13d
jne 0x5405
movl %ebp, (%r14,%r12,4)
incq %r12
cmpl $-0x1, %eax
je 0x53b5
cmpl $0xa, %eax
je 0x53b5
movq %r15, %rdi
callq 0x2110
jmp 0x544a
cmpl $0x20, %eax
ja 0x551a
movl %eax, %ecx
movabsq $0x100000600, %rdx      # imm = 0x100000600
btq %rcx, %rdx
jae 0x551a
leal 0x3(,%r12,4), %ecx
cmpl 0xc(%rbx), %ecx
jb 0x5443
leaq 0x2c60(%rip), %rdi      # 0x80f9
jmp 0x54c6
leaq 0x2baf(%rip), %rdi      # 0x8051
jmp 0x54c6
leaq 0x2c14(%rip), %rdi      # 0x80bf
movl %r12d, %esi
xorl %eax, %eax
callq 0x20c0
movq %r15, %rdi
callq 0x2090
jmp 0x54cb
leaq 0x2bb6(%rip), %rdi      # 0x807c
callq 0x4d36
leaq 0x2ab8(%rip), %rdi      # 0x7f8a
callq 0x4d36
movl $0x1, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rsp), %rdx
leaq 0x2bb1(%rip), %rsi      # 0x80a8
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2210
movq %rbx, %rdi
callq 0x4d36
movq 0x8(%rsp), %rdi
callq 0x2040
jmp 0x54cb
leaq 0x2bf8(%rip), %rdi      # 0x8119
jmp 0x54c6
callq 0x2330
jmp 0x54cb
// File: /workspace/github_c_makefile_star2_O3/hamsternz[P]emulate-risc-v/rom.c
// Function: ROM_set
int ROM_set(struct region *r, uint32_t address, uint8_t mask, uint32_t value) {

   if(address+4 > r->size) {
     fprintf(stderr,"Memory region boundary crossed at 0x%08x\n", r->base+address);
     return 0;
   }

   if((address & 3) != 0) {
     fprintf(stderr,"Unaligned memory write 0x%08x\n", r->base+address);
   }
   display_log("Attempt to write to ROM\n");
   return 1;
}

// Assembly:
pushq %rbx
movl %esi, %edx
leal 0x4(%rdx), %eax
cmpl 0xc(%rdi), %eax
ja 0x554f
testb $0x3, %dl
jne 0x5571
leaq 0x3134(%rip), %rdi      # 0x8675
callq 0x4d36
movl $0x1, %ebx
movl %ebx, %eax
popq %rbx
retq
movq 0x6aa2(%rip), %rax      # 0xbff8
movq (%rax), %rax
addl 0x8(%rdi), %edx
leaq 0x2a3c(%rip), %rsi      # 0x7f9f
xorl %ebx, %ebx
movq %rax, %rdi
xorl %eax, %eax
callq 0x2150
jmp 0x554b
movq 0x6a80(%rip), %rax      # 0xbff8
movq (%rax), %rax
addl 0x8(%rdi), %edx
leaq 0x2a44(%rip), %rsi      # 0x7fc9
movq %rax, %rdi
xorl %eax, %eax
callq 0x2150
jmp 0x553a
// File: /workspace/github_c_makefile_star2_O3/hamsternz[P]emulate-risc-v/rom.c
// Function: ROM_free
void ROM_free(struct region *r) {
   char buffer[100];
   sprintf(buffer, "Releasing ROM at 0x%08x", r->base);
   display_log(buffer);
   if(r->data != NULL) 
     free(r->data);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x68, %rsp
movq %rdi, %rbx
movl 0x8(%rdi), %edx
leaq 0x2ffe(%rip), %rsi      # 0x86a8
movq %rsp, %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x2210
movq %r14, %rdi
callq 0x4d36
movq 0x38(%rbx), %rdi
testq %rdi, %rdi
je 0x56cd
callq 0x2040
addq $0x68, %rsp
popq %rbx
popq %r14
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O3/hamsternz[P]emulate-risc-v/spi.c
// Function: SPI_init
int SPI_init(struct region *r) {
  uint32_t *data;

  if(r->data != NULL) {
    display_log("SPI already initialized");
    return 0;
  }
 
  data = malloc(r->size);
  if(data == NULL){
    return 0;
  }
  r->data = (void *)data;
  memset(r->data, 0, r->size);
  display_log("Set up SPI region");
  return 1;
}

// Assembly:
pushq %rbx
cmpq $0x0, 0x38(%rdi)
je 0x56eb
xorl %ebx, %ebx
leaq 0x2fe4(%rip), %rdi      # 0x86cd
jmp 0x5710
movq %rdi, %rbx
movl 0xc(%rdi), %esi
movl $0x1, %edi
callq 0x2140
testq %rax, %rax
je 0x5719
movq %rax, 0x38(%rbx)
movl $0x1, %ebx
leaq 0x2fd5(%rip), %rdi      # 0x86e5
callq 0x4d36
movl %ebx, %eax
popq %rbx
retq
xorl %ebx, %ebx
jmp 0x5715
// File: /workspace/github_c_makefile_star2_O3/hamsternz[P]emulate-risc-v/spi.c
// Function: SPI_get
int SPI_get(struct region *r, uint32_t address, uint32_t *value) {
   uint32_t v = 0;
   char buffer[100];
   if((address & 3) != 0) {
     fprintf(stderr,"Unaligned memory read 0x%08x\n", r->base+address);
     return 0;
   }

   if(address+4 > r->size) {
     fprintf(stderr,"Memory region boundary crossed at 0x%08x\n", r->base+address);
     return 0;
   }

   v = ((unsigned char *)r->data)[address]; 
   v = v + (((unsigned char *)r->data)[address+1] << 8); 
   v = v + (((unsigned char *)r->data)[address+2] << 16); 
   v = v + (((unsigned char *)r->data)[address+3] << 24); 

   if(address == 0)
     v |= 1<<31;
   *value = v;
     
   sprintf(buffer,"SPI Rd address 0x%08x: 0x%08x", address, v);
   display_log(buffer);

   return 1;
}

// Assembly:
pushq %rbx
subq $0x70, %rsp
movq %rdx, %rax
movl %esi, %edx
testb $0x3, %dl
jne 0x586d
leal 0x4(%rdx), %ecx
cmpl 0xc(%rdi), %ecx
ja 0x5883
movq 0x38(%rdi), %rcx
movl %edx, %esi
movl (%rcx,%rsi), %esi
movl %esi, %ecx
orl $0x80000000, %ecx       # imm = 0x80000000
testl %edx, %edx
cmovnel %esi, %ecx
movl %ecx, (%rax)
leaq 0x2eca(%rip), %rsi      # 0x8715
movq %rsp, %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2210
movq %rbx, %rdi
callq 0x4d36
movl $0x1, %ebx
movl %ebx, %eax
addq $0x70, %rsp
popq %rbx
retq
movq 0x6784(%rip), %rax      # 0xbff8
movq (%rax), %rax
addl 0x8(%rdi), %edx
leaq 0x2767(%rip), %rsi      # 0x7fe8
jmp 0x5897
movq 0x676e(%rip), %rax      # 0xbff8
movq (%rax), %rax
addl 0x8(%rdi), %edx
leaq 0x2708(%rip), %rsi      # 0x7f9f
xorl %ebx, %ebx
movq %rax, %rdi
xorl %eax, %eax
callq 0x2150
jmp 0x5865
// File: /workspace/github_c_makefile_star2_O3/hamsternz[P]emulate-risc-v/spi.c
// Function: SPI_free
void SPI_free(struct region *r) {
   char buffer[100];
   sprintf(buffer, "Releasing SPI at 0x%08x", r->base);
   display_log(buffer);
   if(r->data != NULL) 
     free(r->data);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x68, %rsp
movq %rdi, %rbx
movl 0x8(%rdi), %edx
leaq 0x2dec(%rip), %rsi      # 0x874d
movq %rsp, %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x2210
movq %r14, %rdi
callq 0x4d36
movq 0x38(%rbx), %rdi
testq %rdi, %rdi
je 0x5984
callq 0x2040
addq $0x68, %rsp
popq %rbx
popq %r14
retq