LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/evanwire[P]GitClone/client.c
// Function: readFile
char* readFile(char* fileName){
  //Finding file's size
  struct stat st;
  stat(fileName, &st);
  int size = st.st_size;

  char* file_contents = malloc(size * sizeof(char));
  if(!file_contents){
    printf("\nError: was unable to use malloc(). Please try again.\n");
    exit(1);
  }
  memset(file_contents, 0, size);

  int file_fd = open(fileName, O_RDONLY);
  if(file_fd < 0){
    printf("\nError: Ran into trouble reading file %s.", fileName);
    return "Error";
  }

  int bytes_read = read(file_fd, file_contents, size);
  file_contents[bytes_read] = '\0';
  close(file_fd);
  return file_contents;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x90, %rsp
movq %rdi, %r14
leaq -0xb0(%rbp), %rbx
movq %rbx, %rsi
callq 0x1130
movslq 0x30(%rbx), %r15
pushq $0x1
popq %rdi
movq %r15, %rsi
callq 0x10e0
testq %rax, %rax
je 0x424a
movq %rax, %rbx
movq %r14, %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x10f0
testl %eax, %eax
js 0x421f
movl %eax, %r12d
movl %eax, %edi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x11b0
cltq
movb $0x0, (%rbx,%rax)
movl %r12d, %edi
callq 0x1240
jmp 0x4237
leaq 0x139e(%rip), %rdi      # 0x55c4
movq %r14, %rsi
xorl %eax, %eax
callq 0x1040
leaq 0x13b7(%rip), %rbx      # 0x55ee
movq %rbx, %rax
addq $0x90, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1ff3(%rip), %rdi      # 0x6244
callq 0x11d0
pushq $0x1
popq %rdi
callq 0x1170
// File: /workspace/github_c_makefile_star2_O2/evanwire[P]GitClone/client.c
// Function: hashIt
char* hashIt(char* input){
  unsigned char digest[MD5_DIGEST_LENGTH];
  MD5(input, strlen(input), digest);
  int i;
  char * result=(char*)malloc(34*sizeof(char));
  memset(result,'\0',34);
  for(i = 0; i < MD5_DIGEST_LENGTH; i++){
     sprintf(result+2*i, "%02x", digest[i]);
  }

  return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
callq 0x10a0
leaq -0x30(%rbp), %rdx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x11e0
pushq $0x1
popq %rdi
pushq $0x22
popq %rsi
callq 0x10e0
movq %rax, %rbx
leaq 0x1326(%rip), %r14      # 0x55bf
movq %rax, %r15
xorl %r12d, %r12d
cmpq $0x10, %r12
je 0x42c1
movzbl -0x30(%rbp,%r12), %edx
movq %r15, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x1050
incq %r12
addq $0x2, %r15
jmp 0x429f
movq %rbx, %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/evanwire[P]GitClone/client.c
// Function: copyFile
void copyFile(char* from_file_name, int to_fd){
  char* from_file_contents = readFile(from_file_name);

  int bytes_written = write(to_fd, from_file_contents, strlen(from_file_contents));
  if(bytes_written < 0){
    printf("\nError: unable to execute the write() function. Please try again.\n");
    exit(1);
  }

  free(from_file_contents);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl %esi, %r14d
callq 0x41b4
movq %rax, %rbx
movq %rax, %rdi
callq 0x10a0
movl %r14d, %edi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x1080
testl %eax, %eax
js 0x4309
movq %rbx, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0x1160
leaq 0x1ef2(%rip), %rdi      # 0x6202
callq 0x11d0
pushq $0x1
popq %rdi
callq 0x1170
// File: /workspace/github_c_makefile_star2_O2/evanwire[P]GitClone/client.c
// Function: read_line
char* read_line(int fd){
  //Creating a buffer to hold the entire file
  int file_storage_size = 10;
  int file_idx = 0;
  char* file_contents = malloc(file_storage_size * sizeof(char));
  if(!file_contents){
    printf("\nError: was unable to use malloc(). Please try again.\n");
    exit(1);
  }

  //buffer to read character of the file to
  char buffer[1];


  //Copy from file to buffer until \n is reached
  while((read(fd, buffer, 1)) == 1){
    if(buffer[0] == '\n' || buffer[0] == 0 || buffer[0] == EOF){
      break;
    }else{
      file_contents[file_idx] = buffer[0];
      file_idx++;
       if(file_idx == file_storage_size){
        char* larger_file = realloc(file_contents, 2 * file_storage_size * sizeof(char));

        if(!larger_file){
          printf("\nError: was unable to use realloc(). Please try again.\n");
          exit(1);
        }

        file_contents = larger_file;
      }

    }


  }
  //Eliminate any unwanted characters from the realloc
  char* fixed_file_contents = malloc(file_idx * sizeof(char));
  strcpy(fixed_file_contents, file_contents);
  fixed_file_contents[file_idx] = '\0';

  //free the original file_contents
  free(file_contents);

  return fixed_file_contents;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edi, %r14d
pushq $0xa
popq %rdi
callq 0x1180
testq %rax, %rax
je 0x43d6
movq %rax, %rbx
xorl %r13d, %r13d
leaq -0x29(%rbp), %r15
pushq $0x1
popq %r12
movl %r14d, %edi
movq %r15, %rsi
movq %r12, %rdx
callq 0x11b0
cmpq $0x1, %rax
jne 0x439e
movzbl -0x29(%rbp), %eax
testl %eax, %eax
je 0x439e
cmpl $0xa, %eax
je 0x439e
cmpl $0xff, %eax
je 0x439e
movb %al, (%rbx,%r13)
incq %r13
cmpq $0xa, %r13
jne 0x434d
movq %rbx, %rdi
pushq $0x14
popq %rsi
callq 0x1210
movq %rax, %rbx
testq %rax, %rax
jne 0x434d
leaq 0x1ede(%rip), %rdi      # 0x627a
jmp 0x43dd
movl %r13d, %r14d
movq %r14, %rdi
callq 0x1180
movq %rax, %r15
movq %rax, %rdi
movq %rbx, %rsi
callq 0x1140
movb $0x0, (%r15,%r14)
movq %rbx, %rdi
callq 0x1160
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1e67(%rip), %rdi      # 0x6244
callq 0x11d0
pushq $0x1
popq %rdi
callq 0x1170
// File: /workspace/github_c_makefile_star2_O2/ramirezsebas[P]TP-LISTINGS/./src/capitulo_5/5.4/semaphoreImplementation.c
// Function: main
int main (void)
{
  key_t key=123;
  int semid= binary_semaphore_allocation (key, IPC_CREAT | 0600);
  id= semid;
  pthread_t t1, t2;
  binary_semaphore_initialize(id);
  printf ("Contador antes de entrar al semaforo : %d \n", contador);
  pthread_create (&t1, NULL, *t1_function, NULL);
  pthread_create (&t2, NULL, *t2_function, NULL);

  pthread_join(t1, NULL);
  pthread_join(t2, NULL);

  //El contador vuelve a ser cero, ya que el semaforo
  //Es el que permite que la variable no sea alterada por ambos a la vez

  printf ("Valor final del contador: %d \n", contador);
  binary_semaphore_deallocate (id);
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
pushq $0x7b
popq %rdi
movl $0x380, %esi            # imm = 0x380
callq 0x129c
movl %eax, 0x2eb2(%rip)      # 0x405c
movl %eax, %edi
callq 0x12c0
movl 0x2ea9(%rip), %esi      # 0x4060
leaq 0xe46(%rip), %rdi       # 0x2004
xorl %eax, %eax
callq 0x1040
leaq 0x65(%rip), %rdx        # 0x1231
leaq -0x20(%rbp), %rbx
movq %rbx, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x1050
leaq 0x83(%rip), %rdx        # 0x1266
leaq -0x18(%rbp), %r14
movq %r14, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x1050
movq (%rbx), %rdi
xorl %esi, %esi
callq 0x1080
movq (%r14), %rdi
xorl %esi, %esi
callq 0x1080
movl 0x2e53(%rip), %esi      # 0x4060
leaq 0xe1c(%rip), %rdi       # 0x2030
xorl %eax, %eax
callq 0x1040
movl 0x2e3b(%rip), %edi      # 0x405c
callq 0x12ad
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/ramirezsebas[P]TP-LISTINGS/./src/capitulo_5/5.4/semaphoreImplementation.c
// Function: t1_function
static void *t1_function (void* arg)
{
  for (int i = 0; i< LOOP ; i++){
    binary_semaphore_wait (id);
    contador +=1;
    binary_semaphore_post (id);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movl $0x1388, %ebx           # imm = 0x1388
subl $0x1, %ebx
jb 0x125f
movl 0x2e15(%rip), %edi      # 0x405c
callq 0x12e4
incl 0x2e0e(%rip)            # 0x4060
movl 0x2e04(%rip), %edi      # 0x405c
callq 0x130a
jmp 0x123c
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/ramirezsebas[P]TP-LISTINGS/./src/capitulo_5/5.4/semaphoreImplementation.c
// Function: t2_function
static void *t2_function (void* arg)
{
  for (int i = 0; i< LOOP ; i++){
    binary_semaphore_wait (id);
    contador -=1;
    binary_semaphore_post (id);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movl $0x1388, %ebx           # imm = 0x1388
subl $0x1, %ebx
jb 0x1294
movl 0x2de0(%rip), %edi      # 0x405c
callq 0x12e4
decl 0x2dd9(%rip)            # 0x4060
movl 0x2dcf(%rip), %edi      # 0x405c
callq 0x130a
jmp 0x1271
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O2/moefh[P]hed/src/main.c
// Function: print_version
static void print_version(void)
{
  printf("hed, a tiny hex editor\n");
  printf("Version " HED_VERSION " compiled on " __DATE__ "\n");
  printf("Copyright (C) 2017 Ricardo R. Massaro\n");
  printf("Source code: https://github.com/ricardo-massaro/hed\n");
}

// Assembly:
pushq %rax
leaq 0x4a70(%rip), %rdi      # 0x7084
callq 0x2060
leaq 0x4a7b(%rip), %rdi      # 0x709b
callq 0x2060
leaq 0x4a93(%rip), %rdi      # 0x70bf
callq 0x2060
leaq 0x4aad(%rip), %rdi      # 0x70e5
popq %rax
jmp 0x2060
// File: /workspace/github_c_makefile_star2_O2/moefh[P]hed/src/term.c
// Function: term_setup_raw
int term_setup_raw(int use_term_fd)
{
  struct termios term;

  term_fd = use_term_fd;
  if (! isatty(term_fd))
    return -1;
  if (tcgetattr(term_fd, &old_term) < 0)
    return -1;
  restored_old_term = 0;
  
  term = old_term;
  term.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON);
  term.c_oflag &= ~OPOST;
  term.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
  term.c_cflag &= ~(CSIZE | PARENB);
  term.c_cflag |= CS8;
  term.c_cc[VMIN] = 0;
  term.c_cc[VTIME] = 1;
  if (tcsetattr(term_fd, TCSAFLUSH, &term) < 0 || atexit(term_restore) != 0)
    return -1;
  return 0;
}

// Assembly:
pushq %rbx
subq $0x40, %rsp
movl %edi, 0x8c12(%rip)      # 0xb2a8
callq 0x2080
pushq $-0x1
popq %rbx
testl %eax, %eax
je 0x273a
movl 0x8bfc(%rip), %edi      # 0xb2a8
leaq 0x8bf9(%rip), %rsi      # 0xb2ac
callq 0x2220
testl %eax, %eax
js 0x273a
movups 0x8be9(%rip), %xmm0     # 0xb2ac
movq %rsp, %rdx
movaps %xmm0, (%rdx)
movups 0x8bec(%rip), %xmm0     # 0xb2bc
movaps %xmm0, 0x10(%rdx)
movups 0x8bf1(%rip), %xmm0     # 0xb2cc
movaps %xmm0, 0x20(%rdx)
movups 0x8bf2(%rip), %xmm0     # 0xb2d8
andl $0xfffffa14, (%rdx)     # imm = 0xFFFFFA14
movups %xmm0, 0x2c(%rdx)
andb $-0x2, 0x4(%rdx)
andl $0xffff7fb4, 0xc(%rdx)  # imm = 0xFFFF7FB4
movb $0x0, 0x8ba2(%rip)      # 0xb2a4
movl $0xfffffecf, %eax       # imm = 0xFFFFFECF
andl 0x8(%rdx), %eax
orl $0x30, %eax
movl %eax, 0x8(%rdx)
movw $0x1, 0x16(%rdx)
movl 0x8b8c(%rip), %edi      # 0xb2a8
pushq $0x2
popq %rsi
callq 0x2230
testl %eax, %eax
js 0x273a
leaq -0xcf(%rip), %rdi       # 0x2660
callq 0x60f0
xorl %ebx, %ebx
negl %eax
sbbl %ebx, %ebx
movl %ebx, %eax
addq $0x40, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/moefh[P]hed/src/input.c
// Function: read_key
int read_key(int fd, char *seq, size_t max_seq_len)
{
  int nread;
  unsigned char c;
  while ((nread = read(fd, &c, 1)) != 1) {
    if (nread == -1 && errno != EAGAIN && errno != EINTR)
      return KEY_READ_ERROR;
    if (nread == -1 && errno == EINTR)
      return KEY_REDRAW;
  }

#define NEXT()        do { if (read(fd, &seq[len], 1) != 1) return read_key_seq(seq, len); len++; } while (0)
#define CUR           seq[len-1]
  
  size_t len = 0;
  if (c == '\x1b') {
    if (read(fd, &seq[len++], 1) != 1)
      return c;
    
    while (len < max_seq_len-3) {
      NEXT();
      if (CUR == '~' || CUR == '^' || IS_LETTER(CUR))
        return read_key_seq(seq, len);
      if (CUR == ';') {
        NEXT();
        continue;
      }
      //if (! IS_DIGIT(CUR)) return read_key_seq(seq, len);
    }
    return read_key_seq(seq, len);
  }
  //if (c >= 32) return -1;
  return c;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %rbx
movl %edi, %ebp
leaq 0x7(%rsp), %r15
pushq $0x1
popq %r12
movl %ebp, %edi
movq %r15, %rsi
movq %r12, %rdx
callq 0x2140
cmpl $-0x1, %eax
je 0x27c1
cmpl $0x1, %eax
jne 0x27a8
jmp 0x27e0
callq 0x2040
movl (%rax), %eax
cmpl $0xb, %eax
je 0x27a8
cmpl $0x4, %eax
jne 0x2860
movl $0x110002, %eax         # imm = 0x110002
jmp 0x2867
movzbl 0x7(%rsp), %eax
cmpl $0x1b, %eax
jne 0x2867
pushq $0x1
popq %r13
movl %ebp, %edi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x2140
cmpq $0x1, %rax
jne 0x2864
addq $-0x3, %r14
movq %r13, %r12
cmpq %r14, %r13
jae 0x287e
leaq (%rbx,%r12), %r15
movl %ebp, %edi
movq %r15, %rsi
pushq $0x1
popq %rdx
callq 0x2140
cmpq $0x1, %rax
jne 0x287e
leaq 0x1(%r12), %r13
movzbl (%r15), %eax
movl %eax, %ecx
orl $0x20, %ecx
cmpl $0x7e, %ecx
je 0x2876
leal -0x41(%rax), %ecx
cmpb $0x19, %cl
jbe 0x2876
cmpb $0x3b, %al
jne 0x2805
leaq (%rbx,%r13), %rsi
movl %ebp, %edi
pushq $0x1
popq %rdx
callq 0x2140
cmpq $0x1, %rax
jne 0x2876
addq $0x2, %r12
movq %r12, %r13
jmp 0x2805
pushq $-0x1
jmp 0x2866
pushq $0x1b
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
movq %r13, %rsi
jmp 0x2884
movq %rbx, %rdi
movq %r12, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2894
// File: /workspace/github_c_makefile_star2_O2/moefh[P]hed/src/screen.c
// Function: hed_init_screen
int hed_init_screen(struct hed_screen *scr)
{
  signal(SIGWINCH, SIG_DFL);
  screen = scr;

  screen->term_fd = (isatty(STDIN_FILENO)) ? STDIN_FILENO : STDOUT_FILENO;
  if (term_setup_raw(screen->term_fd) < 0)
    return -1;
  
  term_get_window_size(&screen->w, &screen->h);
  screen->window_changed = true;
  screen->redraw_needed = true;
  screen->utf8_box_draw = true;
  screen->vt100_box_draw = true;
  screen->msg_was_set = false;
  screen->cur_msg[0] = '\0';
  screen->out_buf_len = 0;
  
  signal(SIGWINCH, handle_sigwinch);
  return 0;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
xorl %ebx, %ebx
pushq $0x1c
popq %rdi
xorl %esi, %esi
callq 0x2160
movq %r14, 0x87e6(%rip)      # 0xb2f0
xorl %edi, %edi
callq 0x2080
xorl %edi, %edi
testl %eax, %eax
sete %dil
movq 0x87d0(%rip), %rax      # 0xb2f0
movl %edi, (%rax)
callq 0x268b
testl %eax, %eax
js 0x2b6b
movq 0x87be(%rip), %rsi      # 0xb2f0
leaq 0x4(%rsi), %rdi
addq $0x8, %rsi
callq 0x2742
movq 0x87aa(%rip), %rax      # 0xb2f0
movl $0x1010101, 0xc(%rax)   # imm = 0x1010101
andw $0x0, 0x10(%rax)
andq $0x0, 0x518(%rax)
leaq 0x17(%rip), %rsi        # 0x2b78
pushq $0x1c
popq %rdi
callq 0x2160
jmp 0x2b6e
pushq $-0x1
popq %rbx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/moefh[P]hed/src/screen.c
// Function: handle_sigwinch
static void handle_sigwinch(int signum)
{
  if (screen) {
    term_get_window_size(&screen->w, &screen->h);
    screen->window_changed = true;
    screen->redraw_needed = true;
  }
  signal(signum, handle_sigwinch);
}

// Assembly:
pushq %rbx
movl %edi, %ebx
movq 0x876e(%rip), %rsi      # 0xb2f0
testq %rsi, %rsi
je 0x2ba1
leaq 0x4(%rsi), %rdi
addq $0x8, %rsi
callq 0x2742
movq 0x8755(%rip), %rax      # 0xb2f0
movw $0x101, 0xc(%rax)       # imm = 0x101
leaq -0x30(%rip), %rsi       # 0x2b78
movl %ebx, %edi
popq %rbx
jmp 0x2160
// File: /workspace/github_c_makefile_star2_O2/moefh[P]hed/src/screen.c
// Function: hed_scr_show_msg
int hed_scr_show_msg(const char *fmt, ...)
{
  va_list ap;
  va_start(ap, fmt);
  if (screen)
    vsnprintf(screen->cur_msg, sizeof(screen->cur_msg), fmt, ap);
  else {
    vfprintf(stderr, fmt, ap);
    fprintf(stderr, "\n");
  }
  va_end(ap);
  
  if (screen) {
    screen->redraw_needed = true;
    screen->msg_was_set = true;
  }
  return -1;
}

// Assembly:
pushq %rbx
subq $0xd0, %rsp
movq %rdi, %r10
leaq 0x20(%rsp), %rdi
movq %rsi, 0x8(%rdi)
movq %rdx, 0x10(%rdi)
movq %rcx, 0x18(%rdi)
movq %r8, 0x20(%rdi)
movq %r9, 0x28(%rdi)
testb %al, %al
je 0x2c0f
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
movq %rdi, 0x10(%rsp)
leaq 0xe0(%rsp), %rax
movq %rax, 0x8(%rsp)
movabsq $0x3000000008, %rax     # imm = 0x3000000008
movq %rax, (%rsp)
movq 0x86ba(%rip), %rdi      # 0xb2f0
testq %rdi, %rdi
je 0x2c6f
addq $0x11, %rdi
movq %rsp, %rcx
movl $0x100, %esi            # imm = 0x100
movq %r10, %rdx
callq 0x20a0
movq 0x869a(%rip), %rax      # 0xb2f0
testq %rax, %rax
je 0x2c63
movb $0x1, %cl
movb %cl, 0xd(%rax)
movb %cl, 0x10(%rax)
pushq $-0x1
popq %rax
addq $0xd0, %rsp
popq %rbx
retq
movq 0x8382(%rip), %rbx      # 0xaff8
movq (%rbx), %rdi
movq %rsp, %rdx
movq %r10, %rsi
callq 0x2250
movq (%rbx), %rsi
pushq $0xa
popq %rdi
callq 0x2130
jmp 0x2c4f
// File: /workspace/github_c_makefile_star2_O2/moefh[P]hed/src/screen.c
// Function: hed_scr_clear_msg
int hed_scr_clear_msg(void)
{
  screen->cur_msg[0] = '\0';
  screen->redraw_needed = true;
  screen->msg_was_set = true;
  return -1;
}

// Assembly:
movq 0x8658(%rip), %rax      # 0xb2f0
movb $0x1, 0xd(%rax)
movw $0x1, 0x10(%rax)
pushq $-0x1
popq %rax
retq
// File: /workspace/github_c_makefile_star2_O2/moefh[P]hed/src/screen.c
// Function: hed_scr_flush
void hed_scr_flush(void)
{
  if (screen->out_buf_len > 0) {
    size_t pos = 0;
    while (pos < screen->out_buf_len) {
      ssize_t n = write(screen->term_fd, screen->out_buf + pos, screen->out_buf_len - pos);
      if (n < 0) {
        if (errno != EINTR)
          break;
      } else if (n == 0)
        break;
      pos += n;
    }
    screen->out_buf_len = 0;
  }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq 0x862a(%rip), %rax      # 0xb2f0
movq 0x518(%rax), %rdx
testq %rdx, %rdx
je 0x2d24
xorl %r14d, %r14d
subq %r14, %rdx
jbe 0x2d15
movl (%rax), %edi
leaq (%rax,%r14), %rsi
addq $0x111, %rsi            # imm = 0x111
callq 0x20b0
movq %rax, %rbx
testq %rax, %rax
js 0x2cf8
jne 0x2d02
jmp 0x2d15
callq 0x2040
cmpl $0x4, (%rax)
jne 0x2d15
addq %rbx, %r14
movq 0x85e4(%rip), %rax      # 0xb2f0
movq 0x518(%rax), %rdx
jmp 0x2cd5
movq 0x85d4(%rip), %rax      # 0xb2f0
andq $0x0, 0x518(%rax)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/moefh[P]hed/src/screen.c
// Function: hed_scr_out
void hed_scr_out(const char *fmt, ...)
{
  static char buf[1024];

  va_list ap;
  va_start(ap, fmt);
  vsnprintf(buf, sizeof(buf), fmt, ap);
  va_end(ap);

  size_t len = strlen(buf);
  if (screen->out_buf_len + len > sizeof(screen->out_buf))
    hed_scr_flush();
  memcpy(screen->out_buf + screen->out_buf_len, buf, len);
  screen->out_buf_len += len;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0xd8, %rsp
movq %rdi, %r10
leaq 0x20(%rsp), %rdi
movq %rsi, 0x8(%rdi)
movq %rdx, 0x10(%rdi)
movq %rcx, 0x18(%rdi)
movq %r8, 0x20(%rdi)
movq %r9, 0x28(%rdi)
testb %al, %al
je 0x2d8d
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
movq %rsp, %rcx
movq %rdi, 0x10(%rcx)
leaq 0xf0(%rsp), %rax
movq %rax, 0x8(%rcx)
movabsq $0x3000000008, %rax     # imm = 0x3000000008
movq %rax, (%rcx)
leaq 0x854c(%rip), %rbx      # 0xb300
movl $0x400, %esi            # imm = 0x400
movq %rbx, %rdi
movq %r10, %rdx
callq 0x20a0
movq %rbx, %rdi
callq 0x20e0
movq %rax, %rbx
movq 0x851a(%rip), %r14      # 0xb2f0
movq 0x518(%r14), %rax
movq %rbx, %rcx
addq %rax, %rcx
cmpq $0x401, %rcx            # imm = 0x401
jb 0x2dff
callq 0x2cbb
movq 0x84f8(%rip), %r14      # 0xb2f0
movq 0x518(%r14), %rax
leaq (%r14,%rax), %rdi
addq $0x111, %rdi            # imm = 0x111
leaq 0x84ef(%rip), %rsi      # 0xb300
movq %rbx, %rdx
callq 0x21b0
addq %rbx, 0x518(%r14)
addq $0xd8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/moefh[P]hed/src/screen.c
// Function: hed_scr_set_color
void hed_scr_set_color(int c1, int c2)
{
  if (c1 >= 0)
    hed_scr_out("\x1b[%dm", c1);
  if (c2 >= 0)
    hed_scr_out("\x1b[%dm", c2);
}

// Assembly:
pushq %rbx
movl %esi, %ebx
testl %edi, %edi
js 0x3009
movl %edi, %esi
leaq 0x4389(%rip), %rdi      # 0x738b
xorl %eax, %eax
callq 0x2d2c
testl %ebx, %ebx
js 0x301e
leaq 0x4377(%rip), %rdi      # 0x738b
movl %ebx, %esi
xorl %eax, %eax
popq %rbx
jmp 0x2d2c
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/moefh[P]hed/src/screen.c
// Function: hed_scr_move_cursor
void hed_scr_move_cursor(int x, int y)
{
  if (x < 1) x = 1;
  if (y < 1) y = 1;
  if (x > screen->w) x = screen->w;
  if (y > screen->h) y = screen->h;
  hed_scr_out("\x1b[%d;%dH", y, x);
}

// Assembly:
cmpl $0x2, %edi
pushq $0x1
popq %rax
cmovll %eax, %edi
cmpl $0x2, %esi
cmovll %eax, %esi
movq 0x8262(%rip), %rax      # 0xb2f0
movl 0x4(%rax), %edx
movl 0x8(%rax), %eax
cmpl %edx, %edi
cmovll %edi, %edx
cmpl %eax, %esi
cmovgel %eax, %esi
leaq 0x430b(%rip), %rdi      # 0x73b0
xorl %eax, %eax
jmp 0x2d2c
// File: /workspace/github_c_makefile_star2_O2/moefh[P]hed/src/file.c
// Function: hed_new_file_from_data
struct hed_file *hed_new_file_from_data(uint8_t *data, size_t data_len)
{
  struct hed_file *file = new_file();
  if (! file)
    return NULL;
  
  file->data = data;
  file->data_len = data_len;
  file->modified = (data != NULL);
  return file;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
callq 0x3113
testq %rax, %rax
je 0x310b
movq %rbx, 0x10(%rax)
movq %r14, 0x18(%rax)
testq %rbx, %rbx
setne 0x28(%rax)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/moefh[P]hed/src/file.c
// Function: hed_free_file
void hed_free_file(struct hed_file *file)
{
  if (file->filename)
    free(file->filename);
  if (file->data)
    free(file->data);
  free(file);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x20(%rdi), %rdi
callq 0x2030
movq 0x10(%rbx), %rdi
callq 0x2030
movq %rbx, %rdi
popq %rbx
jmp 0x2030
// File: /workspace/github_c_makefile_star2_O2/moefh[P]hed/src/file.c
// Function: hed_read_file
struct hed_file *hed_read_file(const char *filename)
{
  FILE *f = fopen(filename, "r");
  if (! f) {
    show_msg("ERROR: can't open file '%s'", filename);
    return NULL;
  }

  uint8_t *data = NULL;
  char *new_filename = malloc(strlen(filename) + 1);
  if (! new_filename) {
    show_msg("ERROR: out of memory");
    goto err;
  }
  strcpy(new_filename, filename);
  
  if (fseek(f, 0, SEEK_END) < 0) {
    show_msg("ERROR: can't determine file size");
    goto err;
  }
  long size = ftell(f);
  if (size < 0 || (unsigned long) size > SIZE_MAX) {
    show_msg("ERROR: file is too large");
    goto err;
  }
  if (fseek(f, 0, SEEK_SET) == -1) {
    show_msg("ERROR: can't seek to start of file");
    goto err;
  }
  data = malloc((size_t) size);
  if (! data) {
    show_msg("ERROR: not enough memory for %ld bytes", size);
    goto err;
  }
  
  if (fread(data, 1, size, f) != (size_t) size) {
    show_msg("ERROR: error reading file");
    goto err;
  }
  
  struct hed_file *file = new_file();
  if (! file) {
    show_msg("ERROR: error reading file");
    goto err;
  }
  file->data = data;
  file->data_len = size;
  file->filename = new_filename;
  fclose(f);
  return file;

 err:
  if (new_filename)
    free(new_filename);
  if (data)
    free(data);
  fclose(f);
  return NULL;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %r15
leaq 0x4596(%rip), %rsi      # 0x76fc
callq 0x2240
testq %rax, %rax
je 0x3232
movq %rax, %rbx
movq %r15, %rdi
callq 0x20e0
leaq 0x1(%rax), %rdi
callq 0x21d0
movq %rax, %r14
testq %rax, %rax
je 0x3248
movq %r14, %rdi
movq %r15, %rsi
callq 0x2050
pushq $0x2
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x21f0
testl %eax, %eax
js 0x3251
movq %rbx, %rdi
callq 0x2180
testq %rax, %rax
js 0x325a
movq %rax, %r12
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x21f0
cmpl $-0x1, %eax
je 0x3263
movq %r12, %rdi
callq 0x21d0
testq %rax, %rax
je 0x32a5
movq %rax, %r15
pushq $0x1
popq %rsi
movq %rax, %rdi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x2090
cmpq %r12, %rax
jne 0x329c
callq 0x3113
testq %rax, %rax
je 0x329c
movq %rax, %r13
movq %r15, 0x10(%rax)
movq %r12, 0x18(%rax)
movq %r14, 0x20(%rax)
movq %rbx, %rdi
callq 0x20c0
jmp 0x328f
leaq 0x4197(%rip), %rdi      # 0x73d0
xorl %r13d, %r13d
movq %r15, %rsi
xorl %eax, %eax
callq 0x2bb0
jmp 0x328f
leaq 0x419d(%rip), %rdi      # 0x73ec
jmp 0x326a
leaq 0x41a9(%rip), %rdi      # 0x7401
jmp 0x326a
leaq 0x41c1(%rip), %rdi      # 0x7422
jmp 0x326a
leaq 0x41d1(%rip), %rdi      # 0x743b
xorl %r15d, %r15d
xorl %eax, %eax
callq 0x2bb0
movq %r14, %rdi
callq 0x2030
movq %r15, %rdi
callq 0x2030
movq %rbx, %rdi
callq 0x20c0
xorl %r13d, %r13d
movq %r13, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x41e2(%rip), %rdi      # 0x7485
jmp 0x326d
leaq 0x41b2(%rip), %rdi      # 0x745e
xorl %r15d, %r15d
movq %r12, %rsi
xorl %eax, %eax
callq 0x2bb0
jmp 0x3274
// File: /workspace/github_c_makefile_star2_O2/moefh[P]hed/src/file.c
// Function: hed_write_file
int hed_write_file(struct hed_file *file, const char *filename)
{
  if (! file->data)
    return 0;

  char *new_filename = NULL;
  if (! file->filename || strcmp(filename, file->filename) != 0) {
    new_filename = malloc(strlen(filename) + 1);
    if (! new_filename)
      return show_msg("ERROR: out of memory");
    strcpy(new_filename, filename);
  }
  
  FILE *f = fopen(filename, "w");
  if (! f) {
    free(new_filename);
    return show_msg("ERROR: can't open file '%s'", filename);
  }
  if (fwrite(file->data, 1, file->data_len, f) != file->data_len) {
    free(new_filename);
    fclose(f);
    return show_msg("ERROR: can't write file '%s'", filename);
  }
  fclose(f);
  show_msg("File saved: '%s'", filename);
  file->modified = false;

  if (new_filename) {
    if (file->filename)
      free(file->filename);
    file->filename = new_filename;
  }
  return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
cmpq $0x0, 0x10(%rdi)
je 0x338b
movq %rsi, %rbx
movq %rdi, %r14
movq 0x20(%rdi), %rsi
testq %rsi, %rsi
je 0x32e9
movq %rbx, %rdi
callq 0x2150
testl %eax, %eax
je 0x3328
movq %rbx, %rdi
callq 0x20e0
leaq 0x1(%rax), %rdi
callq 0x21d0
testq %rax, %rax
je 0x330f
movq %rax, %r15
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2050
jmp 0x332b
leaq 0x40d6(%rip), %rdi      # 0x73ec
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x2bb0
xorl %r15d, %r15d
leaq 0x416d(%rip), %rsi      # 0x749f
movq %rbx, %rdi
callq 0x2240
testq %rax, %rax
je 0x3399
movq %rax, %r12
movq 0x10(%r14), %rdi
movq 0x18(%r14), %rdx
pushq $0x1
popq %rsi
movq %rax, %rcx
callq 0x22a0
cmpq 0x18(%r14), %rax
jne 0x33aa
movq %r12, %rdi
callq 0x20c0
leaq 0x4154(%rip), %rdi      # 0x74be
movq %rbx, %rsi
xorl %eax, %eax
callq 0x2bb0
movb $0x0, 0x28(%r14)
testq %r15, %r15
je 0x338b
movq 0x20(%r14), %rdi
callq 0x2030
movq %r15, 0x20(%r14)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %r15, %rdi
callq 0x2030
leaq 0x4028(%rip), %rdi      # 0x73d0
jmp 0x33c1
movq %r15, %rdi
callq 0x2030
movq %r12, %rdi
callq 0x20c0
leaq 0x40e0(%rip), %rdi      # 0x74a1
movq %rbx, %rsi
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x2bb0
// File: /workspace/github_c_makefile_star2_O2/moefh[P]hed/src/file.c
// Function: get_file_u16
bool get_file_u16(struct hed_file *file, size_t pos, uint16_t *data)
{
  if (! file->data || pos + 2 > file->data_len) return false;

  if (file->endianess == HED_DATA_LITTLE_ENDIAN) {
    *data = (((uint16_t) file->data[pos+1] << 8) |
             ((uint16_t) file->data[pos+0] << 0));
  } else {
    *data = (((uint16_t) file->data[pos+0] << 8) |
             ((uint16_t) file->data[pos+1] << 0));
  }
  return true;
}

// Assembly:
movq 0x10(%rdi), %rax
testq %rax, %rax
je 0x3407
leaq 0x2(%rsi), %rcx
cmpq 0x18(%rdi), %rcx
jbe 0x340a
xorl %eax, %eax
retq
cmpl $0x0, 0x2c(%rdi)
je 0x341a
movzwl (%rax,%rsi), %eax
rolw $0x8, %ax
jmp 0x341e
movzwl (%rax,%rsi), %eax
movw %ax, (%rdx)
movb $0x1, %al
retq
// File: /workspace/github_c_makefile_star2_O2/moefh[P]hed/src/file.c
// Function: get_file_u32
bool get_file_u32(struct hed_file *file, size_t pos, uint32_t *data)
{
  if (! file->data || pos + 4 > file->data_len) return false;

  if (file->endianess == HED_DATA_LITTLE_ENDIAN) {
    *data = (((uint32_t) file->data[pos+3] << 24) |
             ((uint32_t) file->data[pos+2] << 16) |
             ((uint32_t) file->data[pos+1] <<  8) |
             ((uint32_t) file->data[pos+0] <<  0));
  } else {
    *data = (((uint32_t) file->data[pos+0] << 24) |
             ((uint32_t) file->data[pos+1] << 16) |
             ((uint32_t) file->data[pos+2] <<  8) |
             ((uint32_t) file->data[pos+3] <<  0));
  }
  return true;
}

// Assembly:
movq 0x10(%rdi), %rax
testq %rax, %rax
je 0x3437
leaq 0x4(%rsi), %rcx
cmpq 0x18(%rdi), %rcx
jbe 0x343a
xorl %eax, %eax
retq
cmpl $0x0, 0x2c(%rdi)
je 0x3447
movl (%rax,%rsi), %eax
bswapl %eax
jmp 0x344a
movl (%rax,%rsi), %eax
movl %eax, (%rdx)
movb $0x1, %al
retq
// File: /workspace/github_c_makefile_star2_O2/moefh[P]hed/src/file.c
// Function: get_file_f32
bool get_file_f32(struct hed_file *file, size_t pos, float *data)
{
  if (! file->data || pos + 4 > file->data_len) return false;
  if (is_cpu_float_little_endian() == (file->endianess == HED_DATA_LITTLE_ENDIAN)) {
    memcpy(data, &file->data[pos], 4);
    return true;
  }
  uint8_t buf[4] = { file->data[pos+3], file->data[pos+2], file->data[pos+1], file->data[pos+0] };
  memcpy(data, buf, 4);
  return true;
}

// Assembly:
movq 0x10(%rdi), %rax
testq %rax, %rax
je 0x3491
leaq 0x4(%rsi), %rcx
cmpq 0x18(%rdi), %rcx
jbe 0x3494
xorl %eax, %eax
retq
cmpb $0x0, 0x8265(%rip)      # 0xb700
jne 0x34a4
movb $0x1, 0x825c(%rip)      # 0xb700
cmpl $0x0, 0x2c(%rdi)
je 0x34ca
movb 0x3(%rax,%rsi), %cl
movb 0x2(%rax,%rsi), %dil
movb (%rax,%rsi), %r8b
movb 0x1(%rax,%rsi), %al
movb %cl, (%rdx)
movb %dil, 0x1(%rdx)
movb %al, 0x2(%rdx)
movb %r8b, 0x3(%rdx)
jmp 0x34cf
movl (%rax,%rsi), %eax
movl %eax, (%rdx)
movb $0x1, %al
retq
// File: /workspace/github_c_makefile_star2_O2/moefh[P]hed/src/file.c
// Function: get_file_f64
bool get_file_f64(struct hed_file *file, size_t pos, double *data)
{
  if (! file->data || pos + 8 > file->data_len) return false;

  if (is_cpu_float_little_endian() == (file->endianess == HED_DATA_LITTLE_ENDIAN)) {
    memcpy(data, &file->data[pos], 8);
    return true;
  }
  uint8_t buf[8] = {
    file->data[pos+7], file->data[pos+6], file->data[pos+5], file->data[pos+4],
    file->data[pos+3], file->data[pos+2], file->data[pos+1], file->data[pos+0],
  };
  memcpy(data, buf, 8);
  return true;
}

// Assembly:
movq 0x10(%rdi), %rax
testq %rax, %rax
je 0x34e5
leaq 0x8(%rsi), %rcx
cmpq 0x18(%rdi), %rcx
jbe 0x34e8
xorl %eax, %eax
retq
cmpb $0x0, 0x8211(%rip)      # 0xb700
jne 0x34f8
movb $0x1, 0x8208(%rip)      # 0xb700
cmpl $0x0, 0x2c(%rdi)
je 0x3543
pushq %rbx
movb 0x7(%rax,%rsi), %cl
movb 0x6(%rax,%rsi), %dil
movb 0x5(%rax,%rsi), %r8b
movb 0x4(%rax,%rsi), %r9b
movb 0x3(%rax,%rsi), %r10b
movb 0x2(%rax,%rsi), %r11b
movb (%rax,%rsi), %bl
movb 0x1(%rax,%rsi), %al
movb %cl, (%rdx)
movb %dil, 0x1(%rdx)
movb %r8b, 0x2(%rdx)
movb %r9b, 0x3(%rdx)
movb %r10b, 0x4(%rdx)
movb %r11b, 0x5(%rdx)
movb %al, 0x6(%rdx)
movb %bl, 0x7(%rdx)
movb $0x1, %al
popq %rbx
retq
movq (%rax,%rsi), %rax
movq %rax, (%rdx)
movb $0x1, %al
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O2/moefh[P]hed/src/utf8.c
// Function: utf8_prev
const void *utf8_prev(const void *start, const void *str)
{
  const uint8_t *s = str;

  s--;
  while ((const void *)s > start && (*s & 0xc0) == 0x80) {
    s--;
  }
  const void *last = s;
  const void *next;
  while ((next = utf8_next(last)) != NULL && next < str) {
    last = next;
  }
  return last;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
leaq -0x1(%rsi), %rcx
movq %rcx, %rax
cmpq %rdi, %rcx
jbe 0x3577
movb (%rax), %dl
andb $-0x40, %dl
leaq -0x1(%rax), %rcx
negb %dl
jo 0x355b
jmp 0x3577
cmpq %rbx, %rax
jae 0x3587
movq %rax, %r14
movq %rax, %rdi
callq 0x3592
testq %rax, %rax
jne 0x3572
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/moefh[P]hed/src/utf8.c
// Function: utf8_next
const void *utf8_next(const void *str)
{
  const uint8_t *s = str;

  if (*s == 0)
    return NULL;
  
  if ((s[0] & 0x80) == 0) {
    return s + 1;
  }
  
  if ((s[0] & 0xe0) == 0xc0) {
    if ((s[1] & 0xc0) != 0x80)
      return s + 1;
    uint32_t val = ((s[0] & 0x1f) << 6) | (s[1] & 0x3f);
    if (val <= 0x7f)
      return s + 1;
    return s + 2;
  }

  if ((s[0] & 0xf0) == 0xe0) {
    if ((s[1] & 0xc0) != 0x80 || (s[2] & 0xc0) != 0x80)
      return s + 1;
    uint32_t val = ((s[0] & 0x0f) << 12) | ((s[1] & 0x3f) << 6) | (s[2] & 0x3f);
    if (val <= 0x7ff)
      return s + 1;
    return s + 3;
  }

  if ((s[0] & 0xf8) == 0xf0) {
    if ((s[1] & 0xc0) != 0x80 || (s[2] & 0xc0) != 0x80 || (s[3] & 0xc0) != 0x80)
      return s + 1;
    uint32_t val = ((s[0] & 0x07) << 18) | ((s[1] & 0x3f) << 12) | ((s[2] & 0x3f) << 6) | (s[3] & 0x3f);
    if (val <= 0xffff || val > 0x10ffff)
      return s + 1;
    return s + 4;
  }

  return s + 1;
}

// Assembly:
movzbl (%rdi), %ecx
testl %ecx, %ecx
je 0x35a4
testb %cl, %cl
js 0x35a7
incq %rdi
movq %rdi, %rax
retq
xorl %eax, %eax
retq
movl %ecx, %eax
andl $-0x20, %eax
cmpl $0xc0, %eax
jne 0x35d1
leaq 0x1(%rdi), %rax
movb 0x1(%rdi), %dl
andb $-0x40, %dl
negb %dl
jno 0x3670
addq $0x2, %rdi
testb $0x1e, %cl
cmovneq %rdi, %rax
retq
movl %ecx, %eax
andl $-0x10, %eax
cmpl $0xe0, %eax
jne 0x3613
leaq 0x1(%rdi), %rax
movzbl 0x1(%rdi), %edx
movl %edx, %esi
andl $-0x40, %esi
cmpl $0x80, %esi
jne 0x3670
movb 0x2(%rdi), %sil
andb $-0x40, %sil
negb %sil
jno 0x3670
shll $0xc, %ecx
movzwl %cx, %ecx
andl $0x20, %edx
shll $0x6, %edx
addq $0x3, %rdi
orl %ecx, %edx
jmp 0x35cc
movl %ecx, %edx
andl $-0x8, %edx
leaq 0x1(%rdi), %rax
cmpl $0xf0, %edx
jne 0x3670
movzbl (%rax), %edx
movl %edx, %esi
andl $-0x40, %esi
cmpl $0x80, %esi
jne 0x3670
movb 0x2(%rdi), %sil
andb $-0x40, %sil
negb %sil
jno 0x3670
movb 0x3(%rdi), %sil
andb $-0x40, %sil
negb %sil
jno 0x3670
andl $0x7, %ecx
shll $0x12, %ecx
andl $0x30, %edx
shll $0xc, %edx
addl %edx, %ecx
addl $0xffef0000, %ecx       # imm = 0xFFEF0000
addq $0x4, %rdi
cmpl $0xfff00000, %ecx       # imm = 0xFFF00000
cmovaeq %rdi, %rax
retq
// File: /workspace/github_c_makefile_star2_O2/moefh[P]hed/src/file_sel.c
// Function: free_dir_list
static void free_dir_list(struct file_item *list)
{
  while (list != NULL) {
    struct file_item *next = list->next;
    free(list);
    list = next;
  }
}

// Assembly:
pushq %rbx
testq %rdi, %rdi
je 0x3ef5
movq (%rdi), %rbx
callq 0x2030
movq %rbx, %rdi
jmp 0x3ee3
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/moefh[P]hed/src/file_sel.c
// Function: compare_files
static int compare_files(const void *p1, const void *p2)
{
  const struct file_item *f1 = *(struct file_item **)p1;
  const struct file_item *f2 = *(struct file_item **)p2;
  if (f1->is_file == f2->is_file)
    return strcmp(f1->filename, f2->filename);
  return (! f1->is_file) ? -1 : 1;
}

// Assembly:
movq (%rdi), %rdi
movq (%rsi), %rsi
movb 0x18(%rdi), %al
cmpb 0x18(%rsi), %al
jne 0x3f12
addq $0x28, %rdi
addq $0x28, %rsi
jmp 0x2150
movzbl %al, %eax
decl %eax
orl $0x1, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/moefh[P]hed/src/file_sel.c
// Function: move_sel_down
static void move_sel_down(struct file_sel *fs)
{
  struct hed_screen *scr = &fs->editor->screen;
  size_t n_page_lines = scr->h - 1 - EDITOR_BORDER_LINES;

  if (fs->sel->next) {
    fs->sel = fs->sel->next;
    if (fs->top_line + n_page_lines - 1 < fs->sel->index)
      fs->top_line = fs->sel->index - n_page_lines + 1;
    scr->redraw_needed = true;
  }
}

// Assembly:
movq 0x28(%rdi), %rax
movq (%rax), %rdx
testq %rdx, %rdx
je 0x3f5d
movq (%rdi), %rax
movslq 0x110(%rax), %rcx
addq $-0x6, %rcx
movq %rdx, 0x28(%rdi)
movq 0x30(%rdi), %rsi
addq %rcx, %rsi
decq %rsi
movq 0x10(%rdx), %rdx
cmpq %rdx, %rsi
jae 0x3f56
subq %rcx, %rdx
incq %rdx
movq %rdx, 0x30(%rdi)
movb $0x1, 0x115(%rax)
retq
// File: /workspace/github_c_makefile_star2_O2/moefh[P]hed/src/file_sel.c
// Function: move_sel_page_up
static void move_sel_page_up(struct file_sel *fs)
{
  struct hed_screen *scr = &fs->editor->screen;
  size_t n_page_lines = scr->h - 1 - EDITOR_BORDER_LINES;

  for (size_t i = 0; i < n_page_lines; i++) {
    if (fs->sel->prev)
      fs->sel = fs->sel->prev;
    else
      break;
  }
  if (fs->sel->index < fs->top_line) {
    if (fs->sel->index > n_page_lines/2)
      fs->top_line = fs->sel->index - n_page_lines/2;
    else
      fs->top_line = 0;
  }
  scr->redraw_needed = true;
}

// Assembly:
movq (%rdi), %rax
movq 0x28(%rdi), %rdx
movslq 0x110(%rax), %rcx
addq $-0x6, %rcx
movq %rcx, %rsi
subq $0x1, %rsi
jb 0x3f8b
movq 0x8(%rdx), %r8
testq %r8, %r8
je 0x3f8b
movq %r8, 0x28(%rdi)
movq %r8, %rdx
jmp 0x3f73
movq 0x10(%rdx), %rdx
cmpq 0x30(%rdi), %rdx
jae 0x3fa5
shrq %rcx
xorl %esi, %esi
subq %rcx, %rdx
cmovaeq %rdx, %rsi
movq %rsi, 0x30(%rdi)
movb $0x1, 0x115(%rax)
retq
// File: /workspace/github_c_makefile_star2_O2/moefh[P]hed/src/file_sel.c
// Function: move_sel_page_down
static void move_sel_page_down(struct file_sel *fs)
{
  struct hed_screen *scr = &fs->editor->screen;
  size_t n_page_lines = scr->h - 1 - EDITOR_BORDER_LINES;

  for (size_t i = 0; i < n_page_lines; i++) {
    if (fs->sel->next)
      fs->sel = fs->sel->next;
    else
      break;
  }
  if (fs->top_line + n_page_lines - 1 < fs->sel->index) {
    if (fs->sel->index > n_page_lines/2)
      fs->top_line = fs->sel->index - n_page_lines/2;
    else
      fs->top_line = 0;
  }
  scr->redraw_needed = true;
}

// Assembly:
movq (%rdi), %rax
movq 0x28(%rdi), %rdx
movslq 0x110(%rax), %rcx
addq $-0x6, %rcx
movq %rcx, %rsi
subq $0x1, %rsi
jb 0x3fd9
movq (%rdx), %r8
testq %r8, %r8
je 0x3fd9
movq %r8, 0x28(%rdi)
movq %r8, %rdx
jmp 0x3fc2
movq 0x30(%rdi), %rsi
addq %rcx, %rsi
decq %rsi
movq 0x10(%rdx), %rdx
cmpq %rdx, %rsi
jae 0x3ffc
shrq %rcx
xorl %esi, %esi
subq %rcx, %rdx
cmovaeq %rdx, %rsi
movq %rsi, 0x30(%rdi)
movb $0x1, 0x115(%rax)
retq
// File: /workspace/github_c_makefile_star2_O2/moefh[P]hed/src/editor.c
// Function: hed_add_file
void hed_add_file(struct hed_editor *editor, struct hed_file *file)
{
  // close current file if it's the only one and it's empty
  if (editor->file && editor->file == editor->file->next && ! editor->file->data)
    close_current_file(editor);
  
  if (! editor->file) {
    file->next = file;
    file->prev = file;
    editor->file = file;
    return;
  }
  
  file->next = editor->file;
  file->prev = editor->file->prev;
  file->prev->next = file;
  file->next->prev = file;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq 0x628(%rdi), %rax
testq %rax, %rax
je 0x406a
cmpq (%rax), %rax
jne 0x4053
cmpq $0x0, 0x10(%rax)
jne 0x4053
movq %r14, %rdi
callq 0x4083
movq 0x628(%r14), %rax
testq %rax, %rax
je 0x406a
movq %rax, (%rbx)
movq 0x8(%rax), %rax
movq %rax, 0x8(%rbx)
movq %rbx, (%rax)
movq (%rbx), %r14
addq $0x8, %r14
jmp 0x4078
addq $0x628, %r14            # imm = 0x628
movq %rbx, (%rbx)
movq %rbx, 0x8(%rbx)
movq %rbx, (%r14)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/moefh[P]hed/src/editor.c
// Function: close_current_file
static void close_current_file(struct hed_editor *editor)
{
  struct hed_file *file = editor->file;
  if (! file)
    return;
  if (file->next == file) {
    hed_free_file(file);
    editor->file = NULL;
    return;
  }
  
  file->next->prev = file->prev;
  file->prev->next = file->next;
  editor->file = file->next;
  hed_free_file(file);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x628(%rdi), %rdi
testq %rdi, %rdi
je 0x40c3
movq (%rdi), %rax
cmpq %rdi, %rax
je 0x40b6
movq 0x8(%rdi), %rcx
movq %rcx, 0x8(%rax)
movq %rax, (%rcx)
movq (%rdi), %rax
movq %rax, 0x628(%rbx)
popq %rbx
jmp 0x3134
callq 0x3134
andq $0x0, 0x628(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/moefh[P]hed/src/editor.c
// Function: hed_draw_key_help
void hed_draw_key_help(int x, int y, const char *key, const char *help)
{
  move_cursor(x, y);
  set_color(FG_BLACK, BG_GRAY);
  out("%s", key);
  reset_color();
  out(" %s", help);

  size_t txt_len = strlen(key) + strlen(help) + 1;
  for (size_t i = txt_len; i < EDITOR_KEY_HELP_SPACING-1; i++)
    out(" ");
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rcx, %rbx
movq %rdx, %r14
callq 0x3078
pushq $0x1e
popq %rdi
pushq $0x2f
popq %rsi
callq 0x2ff2
leaq 0x3869(%rip), %rdi      # 0x794f
movq %r14, %rsi
xorl %eax, %eax
callq 0x2d2c
callq 0x305c
leaq 0x3852(%rip), %rdi      # 0x794e
movq %rbx, %rsi
xorl %eax, %eax
callq 0x2d2c
movq %r14, %rdi
callq 0x20e0
movq %rax, %r14
movq %rbx, %rdi
callq 0x20e0
addq %rax, %r14
incq %r14
leaq 0x36db(%rip), %rbx      # 0x7801
cmpq $0xf, %r14
jae 0x413b
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2d2c
incq %r14
jmp 0x4126
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/moefh[P]hed/src/editor.c
// Function: hed_set_cursor_pos
void hed_set_cursor_pos(struct hed_editor *editor, size_t pos, size_t visible_len_after)
{
  struct hed_screen *scr = &editor->screen;
  struct hed_file *file = editor->file;
  size_t n_page_lines = get_num_displayed_file_lines(editor);
  size_t last_line = file->data_len / 16 + (file->data_len % 16 != 0);

  if (pos >= file->data_len)
    pos = (file->data_len == 0) ? 0 : file->data_len-1;
  if (pos + visible_len_after >= file->data_len)
    visible_len_after = file->data_len - pos;
  
  file->cursor_pos = pos;

  // If the cursor or 'visible_len_after' bytes after it are not visible,
  // center the screen vertically around the cursor
  if (! (file->cursor_pos / 16 >= file->top_line
         && (file->cursor_pos+visible_len_after) / 16 >= file->top_line
         && file->cursor_pos / 16 <= file->top_line + n_page_lines
         && (file->cursor_pos+visible_len_after) / 16 <= file->top_line + n_page_lines)) {
    if (file->cursor_pos / 16 < n_page_lines/2)
      file->top_line = 0;
    else {
      file->top_line = file->cursor_pos / 16 - n_page_lines/2;
      if (file->top_line + n_page_lines > last_line)
        file->top_line = last_line - n_page_lines;
    }
  }
  scr->redraw_needed = true;
}

// Assembly:
pushq %r14
pushq %rbx
movq 0x628(%rdi), %rax
movzbl 0x29(%rax), %ecx
movslq 0x110(%rdi), %r8
xorq $0x1, %rcx
leaq (%rcx,%rcx,4), %rcx
addq %rcx, %r8
addq $-0xa, %r8
movq 0x18(%rax), %r10
movq 0x40(%rax), %r9
movq %r10, %rcx
shrq $0x4, %rcx
movl %r10d, %r11d
andl $0xf, %r11d
cmpq $0x1, %r11
sbbq $-0x1, %rcx
xorl %r11d, %r11d
movq %r10, %rbx
subq $0x1, %rbx
cmovaeq %rbx, %r11
cmpq %rsi, %r10
cmovaq %rsi, %r11
movq %r11, 0x38(%rax)
movq %r11, %rsi
shrq $0x4, %rsi
cmpq %r9, %rsi
jb 0x41d8
leaq (%r11,%rdx), %r14
movq %r10, %rbx
subq %r11, %rbx
cmpq %r10, %r14
cmovbq %rdx, %rbx
addq %r11, %rbx
shrq $0x4, %rbx
cmpq %r9, %rbx
jae 0x4205
movq %r8, %rdx
shrq %rdx
subq %rdx, %rsi
jae 0x41e7
xorl %ecx, %ecx
jmp 0x41f6
movq %rsi, 0x40(%rax)
addq %r8, %rsi
cmpq %rcx, %rsi
jbe 0x41fa
subq %r8, %rcx
movq %rcx, 0x40(%rax)
movb $0x1, 0x115(%rdi)
popq %rbx
popq %r14
retq
addq %r8, %r9
cmpq %r9, %rsi
ja 0x41d8
cmpq %r9, %rbx
jbe 0x41fa
jmp 0x41d8
// File: /workspace/github_c_makefile_star2_O2/moefh[P]hed/src/editor.c
// Function: prompt_save_file
static int prompt_save_file(struct hed_editor *editor)
{
  char filename[256];
  if (editor->file->filename)
    snprintf(filename, sizeof(filename), "%s", editor->file->filename);
  else
    filename[0] = '\0';
  if (prompt_get_filename(editor, "Write file", filename, sizeof(filename)) < 0) {
    editor->screen.redraw_needed = true;
    return -1;
  }
  editor->screen.redraw_needed = true;
  return hed_write_file(editor->file, filename);
}

// Assembly:
pushq %rbx
subq $0x100, %rsp            # imm = 0x100
movq %rdi, %rbx
movq 0x628(%rdi), %rax
movq 0x20(%rax), %rcx
testq %rcx, %rcx
je 0x5534
leaq 0x242c(%rip), %rdx      # 0x794f
movq %rsp, %rdi
movl $0x100, %esi            # imm = 0x100
xorl %eax, %eax
callq 0x2100
jmp 0x5538
movb $0x0, (%rsp)
leaq 0x25ff(%rip), %rsi      # 0x7b3e
movq %rsp, %rdx
movq %rbx, %rdi
callq 0x5995
movb $0x1, 0x115(%rbx)
testl %eax, %eax
js 0x5566
movq 0x628(%rbx), %rdi
movq %rsp, %rsi
callq 0x32bb
jmp 0x5569
pushq $-0x1
popq %rax
addq $0x100, %rsp            # imm = 0x100
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/moefh[P]hed/src/editor.c
// Function: perform_search
static int perform_search(struct hed_editor *editor)
{
  struct hed_file *file = editor->file;

  size_t search_len = strlen(editor->search_str);
  uint8_t *search_bytes;
  uint8_t search_buf[sizeof(editor->search_str)];
  if (file->pane == HED_PANE_TEXT) {
    search_bytes = (uint8_t *) editor->search_str;
  } else {
    search_len = conv_search_bytes(search_buf, sizeof(search_buf), editor->search_str);
    if (search_len == 0)
      return show_msg("Invalid byte sequence (must be a list pairs of hex numbers)");
    search_bytes = search_buf;
  }

  // TODO: Boyer-Moore search?
  bool found = false;
  size_t pos;
  for (pos = file->cursor_pos+1; pos + search_len < file->data_len; pos++) {
    if (memcmp(file->data + pos, search_bytes, search_len) == 0) {
      found = true;
      file->cursor_pos = pos;
      break;
    }
  }
  if (! found)
    return show_msg((file->pane == HED_PANE_HEX) ? "Byte sequence not found" : "Text not found");
  hed_set_cursor_pos(editor, pos, search_len);
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdi, %rbx
movq 0x628(%rdi), %r13
leaq 0x3(%rdi), %r15
movq %r15, %rdi
callq 0x20e0
movl 0x34(%r13), %edx
cmpl $0x1, %edx
jne 0x5600
movq %rax, %r14
movl %edx, 0xc(%rsp)
movq 0x18(%r13), %rbp
movq 0x38(%r13), %r12
incq %r12
leaq (%r14,%r12), %rax
cmpq %rbp, %rax
jae 0x567a
movq 0x10(%r13), %rdi
addq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x21e0
incq %r12
testl %eax, %eax
jne 0x55b4
decq %r12
movq %r12, 0x38(%r13)
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4154
xorl %r14d, %r14d
movb (%r15), %al
testb %al, %al
je 0x5693
cmpq $0x1ff, %r14            # imm = 0x1FF
ja 0x5693
incq %r15
testb %al, %al
je 0x5647
leal -0x30(%rax), %ecx
cmpb $0xa, %cl
jb 0x5656
leal -0x61(%rax), %ecx
cmpb $0x5, %cl
jbe 0x564e
leal -0x41(%rax), %ecx
cmpb $0x5, %cl
jbe 0x5652
cmpb $0x2c, %al
je 0x5642
movzbl %al, %eax
cmpl $0x20, %eax
jne 0x56a4
movb (%r15), %al
jmp 0x5617
decq %r15
xorl %ecx, %ecx
jmp 0x5656
addb $-0x57, %al
jmp 0x5654
addb $-0x37, %al
movl %eax, %ecx
testb $0x1, %r14b
jne 0x566b
shlb $0x4, %cl
movq %r14, %rax
shrq %rax
movb %cl, 0x10(%rsp,%rax)
jmp 0x5675
movq %r14, %rax
shrq %rax
orb %cl, 0x10(%rsp,%rax)
incq %r14
jmp 0x5603
cmpl $0x0, 0xc(%rsp)
leaq 0x2312(%rip), %rax      # 0x7998
leaq 0x2323(%rip), %rdi      # 0x79b0
cmoveq %rax, %rdi
jmp 0x56ab
testb $0x1, %r14b
sete %al
testq %r14, %r14
setne %cl
testb %al, %cl
jne 0x56c3
leaq 0x22b1(%rip), %rdi      # 0x795c
xorl %eax, %eax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2bb0
movl %edx, 0xc(%rsp)
shrq %r14
leaq 0x10(%rsp), %r15
jmp 0x55a9
// File: /workspace/github_c_makefile_star2_O2/moefh[P]hed/src/editor.c
// Function: cursor_end
static void cursor_end(struct hed_editor *editor)
{
  struct hed_screen *scr = &editor->screen;
  struct hed_file *file = editor->file;

  file->cursor_pos = file->cursor_pos / 16 * 16 + 15;
  if (file->cursor_pos >= file->data_len)
    file->cursor_pos = file->data_len - 1;
  scr->redraw_needed = true;
}

// Assembly:
movq 0x628(%rdi), %rax
movq 0x18(%rax), %rcx
movq 0x38(%rax), %rdx
orq $0xf, %rdx
movq %rdx, 0x38(%rax)
cmpq %rcx, %rdx
jb 0x574e
decq %rcx
movq %rcx, 0x38(%rax)
movb $0x1, 0x115(%rdi)
retq
// File: /workspace/github_c_makefile_star2_O2/moefh[P]hed/src/editor.c
// Function: cursor_left
static void cursor_left(struct hed_editor *editor)
{
  struct hed_screen *scr = &editor->screen;
  struct hed_file *file = editor->file;

  if (file->cursor_pos >= 1) {
    file->cursor_pos--;
    while (file->cursor_pos < 16 * file->top_line)
      file->top_line--;
    scr->redraw_needed = true;
  }
}

// Assembly:
movq 0x628(%rdi), %rax
movq 0x38(%rax), %rcx
testq %rcx, %rcx
je 0x5792
decq %rcx
movq %rcx, 0x38(%rax)
movq 0x40(%rax), %rdx
leaq -0x1(%rdx), %rsi
shlq $0x4, %rdx
cmpq %rdx, %rcx
jae 0x578b
movq %rsi, 0x40(%rax)
decq %rsi
addq $-0x10, %rdx
jmp 0x5779
movb $0x1, 0x115(%rdi)
retq