LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/io.c
// Function: open_bw_files
void open_bw_files(g_data *g) {
  assert(g->extMem);
  g->bwf = malloc(g->numBwt*sizeof(FILE *));
  if(g->bwf==NULL) die(__func__);
  for(int i=0; i< g->numBwt; i++) {
    g->bwf[i] = fopen(g->bwfname,"r");
    if(!g->bwf[i]) die(__func__);
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %rbx
movslq 0x20(%rdi), %rdi
shlq $0x3, %rdi
callq 0xbce0
movq %rax, 0x50a0(%rbx)
testq %rax, %rax
jne 0x532d
leaq 0x9184(%rip), %rdi      # 0xe4ac
callq 0x35b7
leaq 0xa0(%rbx), %r14
xorl %r13d, %r13d
leaq 0x9ea7(%rip), %r15      # 0xf1e5
leaq 0x9167(%rip), %r12      # 0xe4ac
movslq 0x20(%rbx), %rax
cmpq %rax, %r13
jge 0x537f
movq %r14, %rdi
movq %r15, %rsi
callq 0x21e0
movq 0x50a0(%rbx), %rcx
movq %rax, (%rcx,%r13,8)
movq 0x50a0(%rbx), %rax
cmpq $0x0, (%rax,%r13,8)
jne 0x537a
movq %r12, %rdi
callq 0x35b7
incq %r13
jmp 0x5345
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/io.c
// Function: rewind_bw_files
void rewind_bw_files(g_data *g) {
  assert(g->extMem);
  for(int i=0; i< g->numBwt; i++) {
    int e = fseek(g->bwf[i],sizeof(symbol)*(g->bws[i]-g->bws[0]+g->symb_offset),SEEK_SET);
    if(e!=0) die(__func__);
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
xorl %r15d, %r15d
leaq 0x911f(%rip), %r14      # 0xe4ba
movslq 0x20(%rbx), %rax
cmpq %rax, %r15
jge 0x53d5
movq 0x50a0(%rbx), %rax
movq (%rax,%r15,8), %rdi
movq (%rbx), %rax
movq (%rax,%r15,8), %rsi
subq (%rax), %rsi
addq 0x30(%rbx), %rsi
xorl %edx, %edx
callq 0x2260
testl %eax, %eax
je 0x53d0
movq %r14, %rdi
callq 0x35b7
incq %r15
jmp 0x539b
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/io.c
// Function: close_bw_files
void close_bw_files(g_data *g) {
  assert(g->extMem);
  for(int i=0; i< g->numBwt; i++) {
    int e = fclose(g->bwf[i]);
    if(e!=0) die(__func__);
  }
  free(g->bwf);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
xorl %r15d, %r15d
leaq 0x90dd(%rip), %r14      # 0xe4ca
movslq 0x20(%rbx), %rax
movq 0x50a0(%rbx), %rdi
cmpq %rax, %r15
jge 0x5417
movq (%rdi,%r15,8), %rdi
callq 0x20e0
testl %eax, %eax
je 0x5412
movq %r14, %rdi
callq 0x35b7
incq %r15
jmp 0x53ed
popq %rbx
popq %r14
popq %r15
jmp 0xbdb4
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/io.c
// Function: open_sa_files
void open_sa_files(g_data *g) {
  assert(g->extMem);
  g->saf = malloc(g->numBwt*sizeof(FILE *));
  if(g->saf==NULL) die(__func__);
  for(int i=0; i< g->numBwt; i++) {
    g->saf[i] = fopen(g->safname,"r");
    if(!g->saf[i]) die(__func__);
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %rbx
movslq 0x20(%rdi), %rdi
shlq $0x3, %rdi
callq 0xbce0
movq %rax, 0x50b0(%rbx)
testq %rax, %rax
jne 0x5452
leaq 0x908c(%rip), %rdi      # 0xe4d9
callq 0x35b7
leaq 0x20a0(%rbx), %r14
xorl %r13d, %r13d
leaq 0x9d82(%rip), %r15      # 0xf1e5
leaq 0x906f(%rip), %r12      # 0xe4d9
movslq 0x20(%rbx), %rax
cmpq %rax, %r13
jge 0x54a4
movq %r14, %rdi
movq %r15, %rsi
callq 0x21e0
movq 0x50b0(%rbx), %rcx
movq %rax, (%rcx,%r13,8)
movq 0x50b0(%rbx), %rax
cmpq $0x0, (%rax,%r13,8)
jne 0x549f
movq %r12, %rdi
callq 0x35b7
incq %r13
jmp 0x546a
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/io.c
// Function: rewind_sa_files
void rewind_sa_files(g_data *g) {
  assert(g->extMem);
  for(int i=0; i< g->numBwt; i++) {
    int e = fseek(g->saf[i],(g->outputSA)*(g->bws[i]-g->bws[0]+g->symb_offset),SEEK_SET);
    if(e!=0) die(__func__);
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
xorl %r15d, %r15d
leaq 0x9027(%rip), %r14      # 0xe4e7
movslq 0x20(%rbx), %rax
cmpq %rax, %r15
jge 0x5502
movq 0x50b0(%rbx), %rax
movq (%rax,%r15,8), %rdi
movq (%rbx), %rax
movq (%rax,%r15,8), %rsi
subq (%rax), %rsi
movslq 0x4c(%rbx), %rax
addq 0x30(%rbx), %rsi
imulq %rax, %rsi
xorl %edx, %edx
callq 0x2260
testl %eax, %eax
je 0x54fd
movq %r14, %rdi
callq 0x35b7
incq %r15
jmp 0x54c0
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/io.c
// Function: close_sa_files
void close_sa_files(g_data *g) {
  assert(g->extMem);
  for(int i=0; i< g->numBwt; i++) {
    int e = fclose(g->saf[i]);
    if(e!=0) die(__func__);
  }
  free(g->saf);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
xorl %r15d, %r15d
leaq 0x8fdd(%rip), %r14      # 0xe4f7
movslq 0x20(%rbx), %rax
movq 0x50b0(%rbx), %rdi
cmpq %rax, %r15
jge 0x5544
movq (%rdi,%r15,8), %rdi
callq 0x20e0
testl %eax, %eax
je 0x553f
movq %r14, %rdi
callq 0x35b7
incq %r15
jmp 0x551a
popq %rbx
popq %r14
popq %r15
jmp 0xbdb4
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/io.c
// Function: open_sl_files
void open_sl_files(g_data *g) {
  assert(g->extMem);
  g->slf = malloc(g->numBwt*sizeof(FILE *));
  if(g->slf==NULL) die(__func__);
  for(int i=0; i< g->numBwt; i++) {
    g->slf[i] = fopen(g->slfname,"r");
    if(!g->slf[i]) die(__func__);
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %rbx
movslq 0x20(%rdi), %rdi
shlq $0x3, %rdi
callq 0xbce0
movq %rax, 0x50b8(%rbx)
testq %rax, %rax
jne 0x557f
leaq 0x8f8c(%rip), %rdi      # 0xe506
callq 0x35b7
leaq 0x30a0(%rbx), %r14
xorl %r13d, %r13d
leaq 0x9c55(%rip), %r15      # 0xf1e5
leaq 0x8f6f(%rip), %r12      # 0xe506
movslq 0x20(%rbx), %rax
cmpq %rax, %r13
jge 0x55d1
movq %r14, %rdi
movq %r15, %rsi
callq 0x21e0
movq 0x50b8(%rbx), %rcx
movq %rax, (%rcx,%r13,8)
movq 0x50b8(%rbx), %rax
cmpq $0x0, (%rax,%r13,8)
jne 0x55cc
movq %r12, %rdi
callq 0x35b7
incq %r13
jmp 0x5597
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/io.c
// Function: rewind_sl_files
void rewind_sl_files(g_data *g) {
  assert(g->extMem);
  for(int i=0; i< g->numBwt; i++) {
    int e = fseek(g->slf[i],(g->outputSL)*(g->bws[i]-g->bws[0]+g->symb_offset),SEEK_SET);
    if(e!=0) die(__func__);
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
xorl %r15d, %r15d
leaq 0x8f27(%rip), %r14      # 0xe514
movslq 0x20(%rbx), %rax
cmpq %rax, %r15
jge 0x562f
movq 0x50b8(%rbx), %rax
movq (%rax,%r15,8), %rdi
movq (%rbx), %rax
movq (%rax,%r15,8), %rsi
subq (%rax), %rsi
movslq 0x50(%rbx), %rax
addq 0x30(%rbx), %rsi
imulq %rax, %rsi
xorl %edx, %edx
callq 0x2260
testl %eax, %eax
je 0x562a
movq %r14, %rdi
callq 0x35b7
incq %r15
jmp 0x55ed
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/io.c
// Function: close_sl_files
void close_sl_files(g_data *g) {
  assert(g->extMem);
  for(int i=0; i< g->numBwt; i++) {
    int e = fclose(g->slf[i]);
    if(e!=0) die(__func__);
  }
  free(g->slf);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
xorl %r15d, %r15d
leaq 0x8edd(%rip), %r14      # 0xe524
movslq 0x20(%rbx), %rax
movq 0x50b8(%rbx), %rdi
cmpq %rax, %r15
jge 0x5671
movq (%rdi,%r15,8), %rdi
callq 0x20e0
testl %eax, %eax
je 0x566c
movq %r14, %rdi
callq 0x35b7
incq %r15
jmp 0x5647
popq %rbx
popq %r14
popq %r15
jmp 0xbdb4
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/io.c
// Function: open_qs_files
void open_qs_files(g_data *g) {
  assert(g->extMem);
  g->qsf = malloc(g->numBwt*sizeof(FILE *));
  if(g->qsf==NULL) die(__func__);
  for(int i=0; i< g->numBwt; i++) {
    g->qsf[i] = fopen(g->qsfname,"r");
    if(!g->qsf[i]) die(__func__);
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %rbx
movslq 0x20(%rdi), %rdi
shlq $0x3, %rdi
callq 0xbce0
movq %rax, 0x50c0(%rbx)
testq %rax, %rax
jne 0x56ac
leaq 0x8e8c(%rip), %rdi      # 0xe533
callq 0x35b7
leaq 0x40a0(%rbx), %r14
xorl %r13d, %r13d
leaq 0x9b28(%rip), %r15      # 0xf1e5
leaq 0x8e6f(%rip), %r12      # 0xe533
movslq 0x20(%rbx), %rax
cmpq %rax, %r13
jge 0x56fe
movq %r14, %rdi
movq %r15, %rsi
callq 0x21e0
movq 0x50c0(%rbx), %rcx
movq %rax, (%rcx,%r13,8)
movq 0x50c0(%rbx), %rax
cmpq $0x0, (%rax,%r13,8)
jne 0x56f9
movq %r12, %rdi
callq 0x35b7
incq %r13
jmp 0x56c4
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/io.c
// Function: rewind_qs_files
void rewind_qs_files(g_data *g) {
  assert(g->extMem);
  for(int i=0; i< g->numBwt; i++) {
    int e = fseek(g->qsf[i],sizeof(symbol)*(g->bws[i]-g->bws[0]+g->symb_offset),SEEK_SET);
    if(e!=0) die(__func__);
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
xorl %r15d, %r15d
leaq 0x8e27(%rip), %r14      # 0xe541
movslq 0x20(%rbx), %rax
cmpq %rax, %r15
jge 0x5754
movq 0x50c0(%rbx), %rax
movq (%rax,%r15,8), %rdi
movq (%rbx), %rax
movq (%rax,%r15,8), %rsi
subq (%rax), %rsi
addq 0x30(%rbx), %rsi
xorl %edx, %edx
callq 0x2260
testl %eax, %eax
je 0x574f
movq %r14, %rdi
callq 0x35b7
incq %r15
jmp 0x571a
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/io.c
// Function: close_qs_files
void close_qs_files(g_data *g) {
  assert(g->extMem);
  for(int i=0; i< g->numBwt; i++) {
    int e = fclose(g->qsf[i]);
    if(e!=0) die(__func__);
  }
  free(g->qsf);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
xorl %r15d, %r15d
leaq 0x8de5(%rip), %r14      # 0xe551
movslq 0x20(%rbx), %rax
movq 0x50c0(%rbx), %rdi
cmpq %rax, %r15
jge 0x5796
movq (%rdi,%r15,8), %rdi
callq 0x20e0
testl %eax, %eax
je 0x5791
movq %r14, %rdi
callq 0x35b7
incq %r15
jmp 0x576c
popq %rbx
popq %r14
popq %r15
jmp 0xbdb4
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/io.c
// Function: open_da_files
void open_da_files(g_data *g) {
  assert(g->extMem);
  g->daf = malloc(g->numBwt*sizeof(FILE *));
  if(g->daf==NULL) die(__func__);
  for(int i=0; i< g->numBwt; i++) {
    g->daf[i] = fopen(g->dafname,"r");
    if(!g->daf[i]) die(__func__);
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %rbx
movslq 0x20(%rdi), %rdi
shlq $0x3, %rdi
callq 0xbce0
movq %rax, 0x50a8(%rbx)
testq %rax, %rax
jne 0x57d1
leaq 0x8d94(%rip), %rdi      # 0xe560
callq 0x35b7
leaq 0x10a0(%rbx), %r14
xorl %r13d, %r13d
leaq 0x9a03(%rip), %r15      # 0xf1e5
leaq 0x8d77(%rip), %r12      # 0xe560
movslq 0x20(%rbx), %rax
cmpq %rax, %r13
jge 0x5823
movq %r14, %rdi
movq %r15, %rsi
callq 0x21e0
movq 0x50a8(%rbx), %rcx
movq %rax, (%rcx,%r13,8)
movq 0x50a8(%rbx), %rax
cmpq $0x0, (%rax,%r13,8)
jne 0x581e
movq %r12, %rdi
callq 0x35b7
incq %r13
jmp 0x57e9
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/io.c
// Function: rewind_da_files
void rewind_da_files(g_data *g) {
  assert(g->extMem);
  for(int i=0; i< g->numBwt; i++) {
    int e = fseek(g->daf[i],(g->outputDA)*(g->bws[i]-g->bws[0]+g->symb_offset),SEEK_SET);
    if(e!=0) die(__func__);
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
xorl %r15d, %r15d
leaq 0x8d2f(%rip), %r14      # 0xe56e
movslq 0x20(%rbx), %rax
cmpq %rax, %r15
jge 0x5881
movq 0x50a8(%rbx), %rax
movq (%rax,%r15,8), %rdi
movq (%rbx), %rax
movq (%rax,%r15,8), %rsi
subq (%rax), %rsi
movslq 0x44(%rbx), %rax
addq 0x30(%rbx), %rsi
imulq %rax, %rsi
xorl %edx, %edx
callq 0x2260
testl %eax, %eax
je 0x587c
movq %r14, %rdi
callq 0x35b7
incq %r15
jmp 0x583f
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/io.c
// Function: close_da_files
void close_da_files(g_data *g) {
  assert(g->extMem);
  for(int i=0; i< g->numBwt; i++) {
    int e = fclose(g->daf[i]);
    if(e!=0) die(__func__);
  }
  free(g->daf);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
xorl %r15d, %r15d
leaq 0x8ce5(%rip), %r14      # 0xe57e
movslq 0x20(%rbx), %rax
movq 0x50a8(%rbx), %rdi
cmpq %rax, %r15
jge 0x58c3
movq (%rdi,%r15,8), %rdi
callq 0x20e0
testl %eax, %eax
je 0x58be
movq %r14, %rdi
callq 0x35b7
incq %r15
jmp 0x5899
popq %rbx
popq %r14
popq %r15
jmp 0xbdb4
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/io.c
// Function: gap_tmpfile
FILE *gap_tmpfile(char* path)
{
  // create local copy of template
  char s[strlen(path)+11];
  sprintf(s,"%s.tmpXXXXXX",path);
  assert(strlen(s)==strlen(path) + 10);
  // get file descriptor for tmp file 
  int fd = mkstemp(s);
  if(fd == -1) die("gap_tmpfile: Tempfile creation failed (1)");
  // get the FILE * (we need buffering)
  FILE *f = fdopen(fd,"w+"); 
  if(f==NULL)  die("gap_tmpfile: Tempfile creation failed (2)");
  // unlink file so it is deleted as soon as it is closed
  int e = unlink(s);
  if(e!=0)     die("gap_tmpfile: Tempfile creation failed (3)");
  return f;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %r14
callq 0x20f0
movq %rsp, %rbx
addq $0x1a, %rax
andq $-0x10, %rax
subq %rax, %rbx
movq %rbx, %rsp
leaq 0x8c99(%rip), %rsi      # 0xe58d
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x2370
movq %rbx, %rdi
callq 0x21a0
movl %eax, %r14d
cmpl $-0x1, %eax
jne 0x591d
leaq 0x8c82(%rip), %rdi      # 0xe59a
callq 0x35b7
leaq 0x8ca0(%rip), %rsi      # 0xe5c4
movl %r14d, %edi
callq 0x2270
movq %rax, %r14
testq %rax, %rax
jne 0x5940
leaq 0x8c8c(%rip), %rdi      # 0xe5c7
callq 0x35b7
movq %rbx, %rdi
callq 0x2060
testl %eax, %eax
je 0x5958
leaq 0x8c9e(%rip), %rdi      # 0xe5f1
callq 0x35b7
movq %r14, %rax
leaq -0x10(%rbp), %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/io.c
// Function: huge_pwrite
void huge_pwrite(int fd, const void *vbuf, size_t count, off_t offset)
{
  const char *buf = (const char *) vbuf;
  while(count>0) {
    ssize_t w = pwrite(fd,buf,count,offset);
    if(w==0) die(__func__);
    count -= w;
    buf += w;
    offset += w;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r15
movl %edi, %ebp
leaq 0x8c9a(%rip), %r12      # 0xe61b
testq %r14, %r14
je 0x59b1
movl %ebp, %edi
movq %r15, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x2210
movq %rax, %r13
testq %rax, %rax
jne 0x59a6
movq %r12, %rdi
callq 0x35b7
subq %r13, %r14
addq %r13, %r15
addq %r13, %rbx
jmp 0x5981
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/io.c
// Function: huge_pread
void huge_pread(int fd, void *vbuf, size_t count, off_t offset)
{
  char *buf = (char *) vbuf;
  while(count>0) {
    ssize_t w = pread(fd,buf,count,offset);
    if(w==0) die(__func__);
    count -= w;
    buf += w;
    offset += w;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r15
movl %edi, %ebp
leaq 0x8c4a(%rip), %r12      # 0xe627
testq %r14, %r14
je 0x5a0d
movl %ebp, %edi
movq %r15, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x2300
movq %rax, %r13
testq %rax, %rax
jne 0x5a02
movq %r12, %rdi
callq 0x35b7
subq %r13, %r14
addq %r13, %r15
addq %r13, %rbx
jmp 0x59dd
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/io.c
// Function: cwriter_flush
static void cwriter_flush(cwriter *w)
{
  if(w->cur>0) {
    huge_pwrite(w->fd,w->buffer,w->cur*sizeof(palette),w->offset);
    w->offset += w->cur*sizeof(palette);
    w->cur=0;
  }
}

// Assembly:
movslq 0x1c(%rdi), %rdx
testq %rdx, %rdx
jle 0x5a7a
pushq %rbx
movq %rdi, %rbx
movl (%rdi), %edi
movq 0x10(%rbx), %rsi
movq 0x8(%rbx), %rcx
callq 0x5964
movslq 0x1c(%rbx), %rax
addq %rax, 0x8(%rbx)
andl $0x0, 0x1c(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/io.c
// Function: cwriter_init
void cwriter_init(cwriter *w, int fd, size_t size, off_t o) {
  assert(size>0);
  w->buffer = malloc(size*sizeof(palette));
  if(!w->buffer) die(__func__);
  w->size = size;
  w->cur = 0;
  w->offset = o;
  w->fd = fd;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rcx, %rbx
movq %rdx, %r15
movl %esi, %ebp
movq %rdi, %r14
movq %rdx, %rdi
callq 0xbce0
movq %rax, 0x10(%r14)
testq %rax, %rax
jne 0x5ae1
leaq 0x8b56(%rip), %rdi      # 0xe632
callq 0x35b7
movl %r15d, 0x18(%r14)
andl $0x0, 0x1c(%r14)
movq %rbx, 0x8(%r14)
movl %ebp, (%r14)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/io.c
// Function: bitfile_save
static void bitfile_save(bitfile *b, bool endfile)
{
  if(b->cur>0) {
    if(b->cur%8!=0 && !endfile) die("Illegal bitfile save");
    size_t bytes = (b->cur+7)/8;
    assert(bytes*8 <= b->size);
    huge_pwrite(b->fd,b->buffer,bytes,b->offset);
    b->offset += bytes;
    b->cur=b->size=0;
  }
}

// Assembly:
movl 0x24(%rdi), %eax
testl %eax, %eax
jle 0x5b56
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
testb $0x7, %al
sete %cl
orb %sil, %cl
jne 0x5b28
leaq 0x8d80(%rip), %rdi      # 0xe8a0
callq 0x35b7
movl 0x24(%rbx), %eax
addl $0x7, %eax
pushq $0x8
popq %rcx
cltd
idivl %ecx
movslq %eax, %r14
movl (%rbx), %edi
movq 0x10(%rbx), %rsi
movq 0x8(%rbx), %rcx
movq %r14, %rdx
callq 0x5964
addq %r14, 0x8(%rbx)
andq $0x0, 0x20(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/io.c
// Function: bitfile_create
void bitfile_create(bitfile *b, size_t size, char *path, int order) {
  // create local copy of template
  char s[Filename_size];
  if(order==0) { // this is a temp file create unique name 
    sprintf(s,"%s.bitXXXXXX",path);
    // get file descriptor for tmp file fill it with 0s and delete file  
    b->fd = mkstemp(s);
    if(b->fd == -1) die("bitfile_create: Tempfile creation failed");
    int e = ftruncate(b->fd,(size+7)/8); // fill with size 0 bits
    if(e!=0)        die("bitfile_create: Tempfile ftruncate failed");
    e = unlink(s);
    if(e!=0)        die("bitfile_create: Tempfile unlink failed");
    }
  else { // we keep this file (to compute the DB-graph) 
    sprintf(s,"%s.%d.lcpbit1",path,order);
    // get file descriptor for bitfile fill it with 0s  
    b->fd = open(s,O_RDWR|O_CREAT|O_TRUNC, 0666);
    if(b->fd == -1) die("bitfile_create: bitfile creation failed");
    int e = ftruncate(b->fd,(size+7)/8); // fill with size 0 bits
    if(e!=0)        die("bitfile_create: bitfile ftruncate failed");
  }
  // initialization of other fields for b
  b->filesize = size;  // total size of the bitfile (in bits) 
  b->buffer = malloc(Bitfile_bufsize_bytes);
  if(!b->buffer)  die("bitfile_create: malloc error");
  b->size = 0;         // current size of the buffer in bits
  b->cur = 0;          // bit index inside buffer
  b->offset = 0;       // offset in bytes in the file 
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x1000, %rsp           # imm = 0x1000
movq %rsi, %r14
movq %rdi, %rbx
testl %ecx, %ecx
je 0x5bc6
leaq 0x8b52(%rip), %rsi      # 0xe6c6
movq %rsp, %r15
movq %r15, %rdi
xorl %eax, %eax
callq 0x2370
movq %r15, %rdi
movl $0x242, %esi            # imm = 0x242
movl $0x1b6, %edx            # imm = 0x1B6
xorl %eax, %eax
callq 0x22f0
movl %eax, (%rbx)
cmpl $-0x1, %eax
jne 0x5baa
leaq 0x8b31(%rip), %rdi      # 0xe6d4
callq 0x35b7
movl (%rbx), %eax
leaq 0x7(%r14), %rsi
shrq $0x3, %rsi
movl %eax, %edi
callq 0x22b0
testl %eax, %eax
je 0x5c2e
leaq 0x8b38(%rip), %rdi      # 0xe6fc
jmp 0x5c29
leaq 0x8a72(%rip), %rsi      # 0xe63f
movq %rsp, %r15
movq %r15, %rdi
xorl %eax, %eax
callq 0x2370
movq %r15, %rdi
callq 0x21a0
movl %eax, (%rbx)
cmpl $-0x1, %eax
jne 0x5bf7
leaq 0x8a5c(%rip), %rdi      # 0xe64c
callq 0x35b7
movl (%rbx), %eax
leaq 0x7(%r14), %rsi
shrq $0x3, %rsi
movl %eax, %edi
callq 0x22b0
testl %eax, %eax
je 0x5c16
leaq 0x8a64(%rip), %rdi      # 0xe675
callq 0x35b7
movq %rsp, %rdi
callq 0x2060
testl %eax, %eax
je 0x5c2e
leaq 0x8a76(%rip), %rdi      # 0xe69f
callq 0x35b7
movq %r14, 0x18(%rbx)
movl $0x10000, %edi          # imm = 0x10000
callq 0xbce0
movq %rax, 0x10(%rbx)
testq %rax, %rax
jne 0x5c51
leaq 0x8ad9(%rip), %rdi      # 0xe725
callq 0x35b7
andq $0x0, 0x20(%rbx)
andq $0x0, 0x8(%rbx)
addq $0x1000, %rsp           # imm = 0x1000
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/io.c
// Function: bitfile_read_or_write
bool bitfile_read_or_write(bitfile *b, bool new)
{
  // make sure there is a bit to read in the buffer, possibily reading from disk 
  if(b->cur >= b->size) {
    assert(b->cur==b->size);
    bitfile_save(b,false);
    assert(b->cur==0);
    assert(b->size==0);
    ssize_t n = pread(b->fd,b->buffer,Bitfile_bufsize_bytes,b->offset);
    if(n<=0) die("Unable to read bitfile data (bitfile_read_or_write)");
    b->size = n*8; // number of bits available for reading
    // note we did not change offset since we are going to write at this offset 
  }
  assert(b->cur<b->size);
  int i = b->cur/8;
  int j = b->cur%8;
  b->cur++;
  bool old = b->buffer[i] & (1<<j); // get old bit value
  if(new) b->buffer[i] |= (1<<j);
  return old;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl %esi, %ebx
movq %rdi, %r14
movl 0x24(%rdi), %ecx
cmpl 0x20(%rdi), %ecx
jl 0x5cf4
movq %r14, %rdi
xorl %esi, %esi
callq 0x5b01
movl (%r14), %edi
movq 0x10(%r14), %rsi
movq 0x8(%r14), %rcx
movl $0x10000, %edx          # imm = 0x10000
callq 0x2300
movq %rax, %r15
testq %rax, %rax
jg 0x5ce4
leaq 0x8a73(%rip), %rdi      # 0xe752
callq 0x35b7
leal (,%r15,8), %eax
movl %eax, 0x20(%r14)
movl 0x24(%r14), %ecx
pushq $0x8
popq %rsi
movl %ecx, %eax
cltd
idivl %esi
leal 0x1(%rcx), %edx
movl %edx, 0x24(%r14)
movq 0x10(%r14), %rdx
movslq %eax, %rsi
movzbl (%rdx,%rsi), %eax
andb $0x7, %cl
pushq $0x1
popq %rdi
shll %cl, %edi
testb %bl, %bl
je 0x5d21
movl %eax, %ecx
orl %edi, %ecx
movb %cl, (%rdx,%rsi)
testl %eax, %edi
setne %al
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/io.c
// Function: bitfile_skip
void bitfile_skip(bitfile *b, uint64_t s) {
  if(b->cur+s <= b->size) { // easy case: we stay in the current buffer
    b->cur+= s;
    return;
  }
  // complete current byte
  int delta = (8 - (b->cur%8)) % 8;
  s -= delta;
  b->cur += delta;
  assert(b->cur%8==0 && b->cur <= b->size&& s>0);
  bitfile_save(b,false); // advance offset to the current b->cur
  // skip as many full bytes as possible
  b->offset += s/8;       
  s = s%8;                // we are left with < 8 bits
  ssize_t n = pread(b->fd,b->buffer,Bitfile_bufsize_bytes,b->offset); // read a full buffer 
  if(n<0 ) die("Error reading bitfile data (bitfile_skip)");
  else if(n==0 && s>0) die("Unable to read bitfile data (bitfile_skip)");
  b->size = n*8; // number of bits available for reading
  b->cur = s;    // virtually skip the remaining bits 
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movslq 0x24(%rdi), %rax
leaq (%rax,%rsi), %r15
movslq 0x20(%rdi), %rcx
cmpq %rcx, %r15
jbe 0x5dbf
movq %rsi, %r14
movl %eax, %ecx
negl %ecx
andl $0x7, %ecx
subq %rcx, %r14
addl %eax, %ecx
movl %ecx, 0x24(%rbx)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x5b01
movq %r14, %rcx
shrq $0x3, %rcx
addq 0x8(%rbx), %rcx
movq %rcx, 0x8(%rbx)
movl %r14d, %r15d
andl $0x7, %r15d
movl (%rbx), %edi
movq 0x10(%rbx), %rsi
movl $0x10000, %edx          # imm = 0x10000
callq 0x2300
movq %rax, %r14
testq %rax, %rax
js 0x5da8
sete %al
testq %r15, %r15
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x5db4
leaq 0x8a0a(%rip), %rdi      # 0xe7b0
jmp 0x5daf
leaq 0x89d7(%rip), %rdi      # 0xe786
callq 0x35b7
leal (,%r14,8), %eax
movl %eax, 0x20(%rbx)
movl %r15d, 0x24(%rbx)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/io.c
// Function: extract_bitfile
void extract_bitfile(char *name, size_t size, char *outpath, int order)  
{
  FILE *f = fopen(name,"rb");
  if(f==NULL) die("extract_bitfile: unable to open input file");
  char s[Filename_size];
  sprintf(s,"%s.%d.lcpbit0",outpath,order);
  assert(strlen(s)==strlen(outpath) + 9);
  FILE *g = fopen(s,"wb");
  if(f==NULL) die("extract_bitfile: unable to open output file");
  uint8_t buf=0;
  palette p;
  palette mask = ((uint64_t) 1) << ((8*sizeof(palette)) -1);
  for(size_t i=0; i<size;i++) {
    if(fread(&p, sizeof(palette), 1, f)!=1) {
      die("extract_bitfile: error reading from input file");
    }
    if(p&mask) // last bit is 1
      buf |= (1u << (i%8));
    if(i%8==7) {
      if(fwrite(&buf,1,1,g)!=1) 
        die("extract_bitfile: error writing to output file");
      buf = 0;
    }
  }
  if(size%8 != 0) 
    if(fwrite(&buf,1,1,g)!=1) 
      die("extract_bitfile: error writing to output file");
  assert(ftell(g)==(size+7)/8);  
  fclose(g);
  fclose(f);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1018, %rsp           # imm = 0x1018
movl %ecx, %ebp
movq %rdx, %r15
movq %rsi, %r14
leaq 0x89e5(%rip), %rsi      # 0xe7db
callq 0x21e0
movq %rax, %rbx
testq %rax, %rax
jne 0x5e0f
leaq 0x89d4(%rip), %rdi      # 0xe7de
callq 0x35b7
leaq 0x89f3(%rip), %rsi      # 0xe809
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movq %r15, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x2370
leaq 0x7afd(%rip), %rsi      # 0xd92e
movq %r12, %rdi
callq 0x21e0
movq %rax, 0x8(%rsp)
testq %rbx, %rbx
jne 0x5e4f
leaq 0x89cd(%rip), %rdi      # 0xe817
callq 0x35b7
leaq 0x6(%rsp), %rax
movb $0x0, (%rax)
xorl %r15d, %r15d
leaq 0x7(%rsp), %r13
pushq $0x1
popq %rbp
xorl %r12d, %r12d
cmpq %r12, %r14
je 0x5ee3
movq %r13, %rdi
movq %rbp, %rsi
movq %rbp, %rdx
movq %rbx, %rcx
callq 0x20a0
cmpq $0x1, %rax
je 0x5e8d
leaq 0x89bb(%rip), %rdi      # 0xe843
callq 0x35b7
cmpb $0x0, 0x7(%rsp)
jns 0x5ea6
movl %r12d, %ecx
andb $0x7, %cl
movb $0x1, %al
shlb %cl, %al
orb %al, %r15b
movb %r15b, 0x6(%rsp)
movl %r12d, %eax
notl %eax
testb $0x7, %al
jne 0x5ede
leaq 0x6(%rsp), %rdi
movq %rbp, %rsi
movq %rbp, %rdx
movq 0x8(%rsp), %rcx
callq 0x2390
cmpq $0x1, %rax
je 0x5ed6
leaq 0x89a1(%rip), %rdi      # 0xe872
callq 0x35b7
movb $0x0, 0x6(%rsp)
xorl %r15d, %r15d
incq %r12
jmp 0x5e65
testb $0x7, %r14b
je 0x5f10
leaq 0x6(%rsp), %rdi
pushq $0x1
popq %rdx
movq %rdx, %rsi
movq 0x8(%rsp), %rcx
callq 0x2390
cmpq $0x1, %rax
je 0x5f10
leaq 0x8967(%rip), %rdi      # 0xe872
callq 0x35b7
movq 0x8(%rsp), %rdi
callq 0x20e0
movq %rbx, %rdi
addq $0x1018, %rsp           # imm = 0x1018
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x20e0
nop
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/./blocks.h
// Function: showBlock
void showBlock(solidBlock *b, g_data *g, int num)
{
  printf("Beg "CUSTOM_FORMAT" End "CUSTOM_FORMAT" ",b->beginsAt, b->endsAt);
  if(b->endsAt - b->beginsAt > SMALLSOLID_LIMIT) {
    printf("occ: ");
    for(int i=0;i<num;i++) printf(CUSTOM_FORMAT" ",b->occ[i]);
  } else {
    printf("smallOcc: ");
    for(int i=0;i<num;i++) printf(SMALLSOLID_FORMAT" ",b->smallOcc[i]);
  }
  puts("SolEND");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edx, %ebp
movq %rdi, %rbx
movq (%rdi), %rsi
movq 0x8(%rdi), %rdx
leaq 0x8971(%rip), %rdi      # 0xe8c0
xorl %r15d, %r15d
xorl %eax, %eax
callq 0x2100
movq 0x8(%rbx), %rax
subq (%rbx), %rax
testl %ebp, %ebp
cmovgl %ebp, %r15d
cmpq $0x10000, %rax          # imm = 0x10000
jb 0x5fa2
leaq 0x895c(%rip), %rdi      # 0xe8d1
xorl %eax, %eax
callq 0x2100
leaq 0x8949(%rip), %r14      # 0xe8cc
xorl %r12d, %r12d
cmpq %r12, %r15
je 0x5fd7
movq 0x10(%rbx), %rax
movq (%rax,%r12,8), %rsi
movq %r14, %rdi
xorl %eax, %eax
callq 0x2100
incq %r12
jmp 0x5f86
leaq 0x892e(%rip), %rdi      # 0xe8d7
xorl %eax, %eax
callq 0x2100
leaq 0x892b(%rip), %r14      # 0xe8e2
xorl %r12d, %r12d
cmpq %r12, %r15
je 0x5fd7
movq 0x10(%rbx), %rax
movzwl (%rax,%r12,2), %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x2100
incq %r12
jmp 0x5fba
leaq 0x8908(%rip), %rdi      # 0xe8e6
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x2090
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/./blocks.h
// Function: showLiquid
void showLiquid(liquidBlock *b)
{
  printf("Beg "CUSTOM_FORMAT" End "CUSTOM_FORMAT" ",b->beginsAt, b->endsAt);
  customInt totA=0, totB=0;
  for(int i=0;i<b->numBwt;i++) totB += b->occ[i];
  for(int i=0;i<b->sizeOfAlpha;i++) totA += b->occ[b->numBwt+i];
  printf("Chars: "CUSTOM_FORMAT" Bwts: "CUSTOM_FORMAT" Empty: %d ",totA,totB,b->empty);  
  puts("LiqEND");
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rdi), %rsi
movq 0x8(%rdi), %rdx
leaq 0x88c0(%rip), %rdi      # 0xe8c0
xorl %r14d, %r14d
xorl %eax, %eax
callq 0x2100
movslq 0x10(%rbx), %rax
testl %eax, %eax
movl $0x0, %ecx
cmovgl %eax, %ecx
xorl %edx, %edx
cmpq %r14, %rcx
je 0x602c
movq 0x20(%rbx), %rsi
addq (%rsi,%r14,8), %rdx
incq %r14
jmp 0x601a
movl 0x14(%rbx), %ecx
xorl %esi, %esi
testl %ecx, %ecx
cmovlel %esi, %ecx
subq $0x1, %rcx
jb 0x6049
movq 0x20(%rbx), %rdi
addq (%rdi,%rax,8), %rsi
incq %rax
jmp 0x6036
movzbl 0x2c(%rbx), %ecx
leaq 0x8899(%rip), %rdi      # 0xe8ed
xorl %eax, %eax
callq 0x2100
leaq 0x88ab(%rip), %rdi      # 0xe90d
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2090
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/./blocks.h
// Function: liquid_new
liquidBlock *liquid_new(g_data *g){
  liquidBlock *newB = malloc(sizeof(*newB));
  if(newB==NULL) die("Out of mem in liquid_new()");
  newB->beginsAt = 0; 
  newB->endsAt = 0; 
  newB->empty = true; 
  newB->occ_size = g->numBwt+g->sizeOfAlpha;
  newB->numBwt = g->numBwt;
  newB->sizeOfAlpha = g->sizeOfAlpha;
  newB->solid_limit = max(g->solid_limit,newB->occ_size);
  // solid limit cannot be smaller than mergeLen  
  newB->solid_limit = min(newB->solid_limit,g->mergeLen);  
  newB->occ = calloc(newB->occ_size,sizeof(customInt));
  if(newB->occ==NULL) die("Out of mem in liquid_new()");
  return newB;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
pushq $0x30
popq %rdi
callq 0xbce0
movq %rax, %rbx
testq %rax, %rax
jne 0x6091
leaq 0x8888(%rip), %rdi      # 0xe914
callq 0x35b7
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movb $0x1, 0x2c(%rbx)
movl 0x20(%r14), %eax
movl 0x38(%r14), %ecx
leal (%rcx,%rax), %edx
movl %edx, 0x18(%rbx)
movl %eax, 0x10(%rbx)
movl %ecx, 0x14(%rbx)
movl 0x90(%r14), %eax
cmpl %edx, %eax
cmovlel %edx, %eax
cltq
movq 0x28(%r14), %rcx
cmpq %rax, %rcx
cmovbel %ecx, %eax
movl %eax, 0x28(%rbx)
movslq %edx, %rdi
pushq $0x8
popq %rsi
callq 0xbe60
movq %rax, 0x20(%rbx)
testq %rax, %rax
jne 0x60ea
leaq 0x882f(%rip), %rdi      # 0xe914
callq 0x35b7
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/./blocks.h
// Function: ibHead_new
solidBlockFile *ibHead_new(g_data *g) {
  solidBlockFile *ibList = malloc(sizeof(*ibList));
  if(ibList==NULL) die("Out of mem in inHead_new");
  ibList->fin = ibList->fout = NULL;
  ibList->occ_size = g->sizeOfAlpha + g->numBwt;
  ibList->solidList = NULL;
  ibList->occList = NULL;
  ibList->smallOccList = NULL;
  return ibList;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
pushq $0x30
popq %rdi
callq 0xbce0
movq %rax, %r14
testq %rax, %rax
jne 0x612e
leaq 0x8806(%rip), %rdi      # 0xe92f
callq 0x35b7
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
movl 0x20(%rbx), %eax
addl 0x38(%rbx), %eax
movl %eax, 0x10(%r14)
movups %xmm0, 0x18(%r14)
andq $0x0, 0x28(%r14)
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/./blocks.h
// Function: ibHead_free
void ibHead_free(solidBlockFile *b)
{
  // free list of solid blocks
  assert(b!=NULL);
  {
    solidBlock *next=b->solidList; int tot=0;
    while(next!=NULL) {
      solidBlock *tmp = next->nextBlock;
      free(next); next = tmp; tot++;
    }
    assert(tot<=3); // blocks are on disk: at most three in mem simultaneously 
  }
  // free list of occList
  {customInt *next=b->occList;
  while(next!=NULL) {
    customInt **n = (customInt **) next; // pretend next is an array of pointers customInt *
    customInt *tmp = n[0];
    free(next); next = tmp;
  }}
  // free list of smallOccList
  {smallSolidInt *next= b->smallOccList;
  while(next!=NULL) {
    smallSolidInt **n = (smallSolidInt **) next; // pretend next is an array of pointers customInt *
    smallSolidInt *tmp = n[0];
    free(next); next = tmp;
  }}
  free(b);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x18(%rdi), %rdi
testq %rdi, %rdi
je 0x6172
movq 0x18(%rdi), %r14
callq 0xbdb4
movq %r14, %rdi
jmp 0x615f
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x6188
movq (%rdi), %r14
callq 0xbdb4
movq %r14, %rdi
jmp 0x6176
movq 0x28(%rbx), %rdi
testq %rdi, %rdi
je 0x619e
movq (%rdi), %r14
callq 0xbdb4
movq %r14, %rdi
jmp 0x618c
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0xbdb4
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/./blocks.h
// Function: get_block
solidBlock *get_block(solidBlockFile *s)
{
  solidBlock *newB =  s->solidList;
  if(newB!=NULL) {
    s->solidList = newB->nextBlock;
  }
  else {
    newB = malloc(sizeof(*newB));
    if(newB==NULL) die("Out of mem in get_block()");
  }
  return newB;
}

// Assembly:
pushq %rax
movq 0x18(%rdi), %rax
testq %rax, %rax
je 0x61c1
movq 0x18(%rax), %rcx
movq %rcx, 0x18(%rdi)
jmp 0x61dc
pushq $0x20
popq %rdi
callq 0xbce0
testq %rax, %rax
jne 0x61dc
leaq 0x8773(%rip), %rdi      # 0xe948
callq 0x35b7
xorl %eax, %eax
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/./blocks.h
// Function: get_occ
customInt *get_occ(solidBlockFile *s) {
  customInt *occ = s->occList;  // try occlist
  if(occ == NULL) {
    occ = malloc(s->occ_size* sizeof(customInt));
    if(occ==NULL) die("Out of mem in get_occ()");
  }
  else { // update list occList
    customInt **n = (customInt **) occ;
    s->occList = n[0];
  }
  return occ;  
}

// Assembly:
pushq %rax
movq 0x20(%rdi), %rax
testq %rax, %rax
je 0x61f1
movq (%rax), %rcx
movq %rcx, 0x20(%rdi)
jmp 0x6211
movslq 0x10(%rdi), %rdi
shlq $0x3, %rdi
callq 0xbce0
testq %rax, %rax
jne 0x6211
leaq 0x8758(%rip), %rdi      # 0xe962
callq 0x35b7
xorl %eax, %eax
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/./blocks.h
// Function: get_smallocc
smallSolidInt *get_smallocc(solidBlockFile *s) {
  smallSolidInt *occ = s->smallOccList;  // try smallOcclist
  if(occ == NULL) {
    occ = malloc(s->occ_size* sizeof(smallSolidInt));
    if(occ==NULL) die("Out of mem in get_smallocc()");
  }
  else { // update list occList
    smallSolidInt **n = (smallSolidInt **) occ;
    s->smallOccList = n[0];
  }
  return occ;  
}

// Assembly:
pushq %rax
movq 0x28(%rdi), %rax
testq %rax, %rax
je 0x6226
movq (%rax), %rcx
movq %rcx, 0x28(%rdi)
jmp 0x6245
movslq 0x10(%rdi), %rdi
addq %rdi, %rdi
callq 0xbce0
testq %rax, %rax
jne 0x6245
leaq 0x873c(%rip), %rdi      # 0xe97a
callq 0x35b7
xorl %eax, %eax
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/./blocks.h
// Function: finalize_liquid
solidBlock *finalize_liquid(solidBlock *last, liquidBlock *b, solidBlock *next, solidBlockFile *sf)
{
  assert(!b->empty);
  if(last!=NULL && last->endsAt==b->beginsAt) {
    // merge b into last and empty it 
    merge_liquid(b,last,sf);  // last and next do not change
  }
  else if(b->endsAt-b->beginsAt>= b->solid_limit) {
    // create new solid and empty b which becomes last block 
    solidBlock *s = liquidToSolid(b,sf);  
    s->nextBlock = next;
    if(last!=NULL) writeBlock(last,sf); // it was: last->nextBlock = s;
    last = s;
  }
  else { // nothing to do, just empty b
    b->empty = true;
    memset(b->occ, 0, (b->occ_size) * sizeof(customInt));
  }
  assert(b->empty);
  return last;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %rbx
movq (%rsi), %rax
testq %rdi, %rdi
je 0x62c5
cmpq %rax, 0x8(%rbx)
jne 0x62c5
movq %r12, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x63c9
jmp 0x63bc
movq 0x8(%r12), %rcx
subq %rax, %rcx
movslq 0x28(%r12), %rax
cmpq %rax, %rcx
jae 0x62f7
movb $0x1, 0x2c(%r12)
movq 0x20(%r12), %rdi
movslq 0x18(%r12), %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x2150
jmp 0x63bc
movq %r14, %rdi
callq 0x61ad
movq %rax, %r13
movq (%r12), %rax
movq %rax, (%r13)
movq 0x8(%r12), %rcx
movq %rcx, 0x8(%r13)
subq %rax, %rcx
movq %r14, %rdi
cmpq $0xffff, %rcx           # imm = 0xFFFF
ja 0x6357
callq 0x6213
movq %rax, 0x10(%r13)
movl 0x18(%r12), %eax
xorl %ecx, %ecx
testl %eax, %eax
movl $0x0, %edx
cmovgl %eax, %edx
cmpq %rcx, %rdx
je 0x638c
movq 0x20(%r12), %rsi
movzwl (%rsi,%rcx,8), %esi
movq 0x10(%r13), %rdi
movw %si, (%rdi,%rcx,2)
incq %rcx
jmp 0x633c
callq 0x61de
movq %rax, 0x10(%r13)
movl 0x18(%r12), %eax
xorl %ecx, %ecx
testl %eax, %eax
movl $0x0, %edx
cmovgl %eax, %edx
cmpq %rcx, %rdx
je 0x638c
movq 0x20(%r12), %rsi
movq (%rsi,%rcx,8), %rsi
movq 0x10(%r13), %rdi
movq %rsi, (%rdi,%rcx,8)
incq %rcx
jmp 0x6371
movb $0x1, 0x2c(%r12)
movq 0x20(%r12), %rdi
movslq %eax, %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x2150
movq %r15, 0x18(%r13)
testq %rbx, %rbx
je 0x63b9
movq %rbx, %rdi
movq %r14, %rsi
callq 0x648d
movq %r13, %rbx
movq %rbx, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/./blocks.h
// Function: merge_liquid
static void merge_liquid(liquidBlock *b, solidBlock *s, solidBlockFile *sf) {
  assert(!b->empty);
  // --- merge occs. 
  if((s->endsAt - s->beginsAt) + (b->endsAt - b->beginsAt) <= SMALLSOLID_LIMIT){
    for (int c = 0; c < b->occ_size; ++c) // merged block is small 
      s->smallOcc[c] += (smallSolidInt) b->occ[c];
  } 
  else {
    if((s->endsAt - s->beginsAt)<= SMALLSOLID_LIMIT)
      block_inflate(s,sf);       // enlarge if required 
    for (int c = 0; c < b->occ_size; ++c) 
      s->occ[c] += b->occ[c];
  }
  // --- update extremes
  if(b->endsAt==s->beginsAt)
    s->beginsAt = b->beginsAt;  // liquid before solid
  else {
    assert(s->endsAt==b->beginsAt); // solid before liquid
    s->endsAt = b->endsAt;
  }
  // --- clear b
  b->empty = true;
  memset(b->occ, 0, (b->occ_size) * sizeof(customInt));
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq (%rsi), %rsi
movq 0x8(%r14), %rax
subq %rsi, %rax
movq 0x8(%rdi), %rcx
leaq (%rax,%rcx), %rdi
subq (%rbx), %rdi
cmpq $0xffff, %rdi           # imm = 0xFFFF
ja 0x641c
movl 0x18(%rbx), %eax
xorl %edx, %edx
testl %eax, %eax
movl $0x0, %edi
cmovgl %eax, %edi
cmpq %rdx, %rdi
je 0x645f
movq 0x20(%rbx), %r8
movzwl (%r8,%rdx,8), %r8d
movq 0x10(%r14), %r9
addw %r8w, (%r9,%rdx,2)
incq %rdx
jmp 0x6400
cmpq $0xffff, %rax           # imm = 0xFFFF
ja 0x642f
movq %r14, %rdi
movq %rdx, %rsi
callq 0xae60
movl 0x18(%rbx), %eax
xorl %ecx, %ecx
testl %eax, %eax
movl $0x0, %edx
cmovgl %eax, %edx
cmpq %rcx, %rdx
je 0x6458
movq 0x20(%rbx), %rsi
movq (%rsi,%rcx,8), %rsi
movq 0x10(%r14), %rdi
addq %rsi, (%rdi,%rcx,8)
incq %rcx
jmp 0x643e
movq 0x8(%rbx), %rcx
movq (%r14), %rsi
cmpq %rsi, %rcx
jne 0x646c
movq (%rbx), %rcx
movq %rcx, (%r14)
jmp 0x6470
movq %rcx, 0x8(%r14)
movb $0x1, 0x2c(%rbx)
movq 0x20(%rbx), %rdi
movslq %eax, %rdx
shlq $0x3, %rdx
xorl %esi, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2150
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/./blocks.h
// Function: writeBlock
static void writeBlock(solidBlock *s, solidBlockFile *sf)
{
  assert(s!=NULL);
  assert(sf!=NULL && sf->fout!=NULL);
  customInt buffer[SIZE_OF_ALPHABET+MAX_NUMBER_OF_BWTS];
  buffer[0] = s->beginsAt;
  buffer[1] = s->endsAt;
  int e = fwrite(buffer,sizeof(customInt),2,sf->fout);
  if(e!=2) die("tmp file write in writeBlock (1)");
  if (s->endsAt - s->beginsAt <= SMALLSOLID_LIMIT) {
    // small solid block
    e = fwrite(s->smallOcc,sizeof(smallSolidInt),sf->occ_size,sf->fout);
    if(e!=sf->occ_size) die("tmp file write error in writeBlock (2)");
  }  
  else { // large solid block 
    uint8_t *byteBuffer = (uint8_t *) buffer;
    // fill newB->occ using five bytes for entry
    for(int j=0;j<sf->occ_size;j++) {
      if(s->occ[j]>= (1Ull<<(8*POS_SIZE))) {
        fprintf(stderr,"%d bytes per position are not enough. Increase POS_SIZE and recompile\n",POS_SIZE); 
        exit(EXIT_FAILURE);
      }
      for(int i=0;i<POS_SIZE;i++)
        byteBuffer[j*POS_SIZE+i] = (s->occ[j]>>(8*i)) & 0xFF;  
    }
    e= fwrite(byteBuffer,POS_SIZE,sf->occ_size,sf->fout); // read POS_SIZE bytes for customInt
    if(e!=sf->occ_size) die("tmp file write error in writeBlock (3)");
  }
  block_free(s,sf);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x1000, %rsp           # imm = 0x1000
movq %rsi, %rbx
movq %rdi, %r14
movups (%rdi), %xmm0
movq %rsp, %r15
movaps %xmm0, (%r15)
movq 0x8(%rsi), %rcx
pushq $0x8
popq %rsi
pushq $0x2
popq %rdx
movq %r15, %rdi
callq 0x2390
cmpl $0x2, %eax
je 0x64cc
leaq 0x8b03(%rip), %rdi      # 0xefca
callq 0x35b7
movq 0x8(%r14), %rax
subq (%r14), %rax
cmpq $0x10000, %rax          # imm = 0x10000
jae 0x64fd
movq 0x10(%r14), %rdi
movslq 0x10(%rbx), %rdx
movq 0x8(%rbx), %rcx
pushq $0x2
popq %rsi
callq 0x2390
cmpl %eax, 0x10(%rbx)
je 0x6569
leaq 0x8af0(%rip), %rdi      # 0xefeb
jmp 0x6564
movslq 0x10(%rbx), %rdx
xorl %eax, %eax
testl %edx, %edx
movl $0x0, %esi
cmovgl %edx, %esi
cmpq %rsi, %rax
je 0x6549
movq 0x10(%r14), %rcx
movq (%rcx,%rax,8), %rdi
movq %rdi, %rcx
shrq $0x28, %rcx
jne 0x6580
xorl %ecx, %ecx
movq %r15, %r8
cmpq $0x28, %rcx
je 0x6540
movq %rdi, %r9
shrq %cl, %r9
movb %r9b, (%r8)
incq %r8
addq $0x8, %rcx
jmp 0x6528
incq %rax
addq $0x5, %r15
jmp 0x650d
movq 0x8(%rbx), %rcx
movq %rsp, %rdi
pushq $0x5
popq %rsi
callq 0x2390
cmpl %eax, 0x10(%rbx)
je 0x6569
leaq 0x8aae(%rip), %rdi      # 0xf012
callq 0x35b7
movq %r14, %rdi
movq %rbx, %rsi
addq $0x1000, %rsp           # imm = 0x1000
popq %rbx
popq %r14
popq %r15
jmp 0x625f
movq 0xca71(%rip), %rax      # 0x12ff8
movq (%rax), %rdi
leaq 0x7691(%rip), %rsi      # 0xdc22
pushq $0x5
popq %rdx
xorl %eax, %eax
callq 0x21c0
pushq $0x1
popq %rdi
callq 0x2380
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/./blocks.h
// Function: tba_alloc
uint64_t *tba_alloc(customInt n, bool mmapB)
{
  uint64_t *a;
  customInt j = (n+31)/32;
  if(mmapB) {
    a = mmap(NULL,j*sizeof(*a),PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANONYMOUS,-1,0);
    if(a== MAP_FAILED) die(__func__);
  }
  else {
    a = calloc(j,sizeof(*a));
    if(a==NULL) die(__func__);
  }
  return a;
}

// Assembly:
pushq %rbx
movq %rdi, %rax
addq $0x1f, %rax
shrq $0x5, %rax
testl %esi, %esi
je 0x65d9
shlq $0x3, %rax
pushq $0x3
popq %rdx
pushq $0x22
popq %rcx
pushq $-0x1
popq %r8
xorl %edi, %edi
movq %rax, %rsi
xorl %r9d, %r9d
callq 0x2230
cmpq $-0x1, %rax
jne 0x65e9
pushq $-0x1
popq %rbx
jmp 0x65f0
pushq $0x8
popq %rsi
movq %rax, %rdi
callq 0xbe60
testq %rax, %rax
je 0x65ee
movq %rax, %rbx
jmp 0x65fc
xorl %ebx, %ebx
leaq 0x83a0(%rip), %rdi      # 0xe997
callq 0x35b7
movq %rbx, %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/./blocks.h
// Function: tba_free
void tba_free(uint64_t *a, customInt n, bool mmap)
{
  if(mmap) {
    customInt j = (n+31)/32;
    int e = munmap(a,j*sizeof(*a));
    if(e!=0) die(__func__);
  }
  else free(a);
}

// Assembly:
testl %edx, %edx
je 0xbdb4
pushq %rax
addq $0x1f, %rsi
shrq $0x2, %rsi
andq $-0x8, %rsi
callq 0x2290
testl %eax, %eax
leaq 0x8(%rsp), %rsp
je 0x6630
leaq 0x8376(%rip), %rdi      # 0xe9a1
jmp 0x35b7
retq
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/./merge8.h
// Function: init_arrays8
static void init_arrays8(g_data *g)
{
  assert(g->numBwt<=8);
  customInt i=0; // position inside Z newZ and B  

  for(int j=0;j<g->sizeOfAlpha;j++) {
    tba_or_m8(g->mergeColor,i,1);
    g->firstColumn[j] = i;  // symbol j starts at position i
    for(int b=0;b<g->numBwt;b++) {
      for(customInt t=0;t<g->bwtOcc[b][j];t++) {
        if(j==0)   // zero chars are all different, Z are newZ do not change 
          tba_or_m8(g->mergeColor,i,1);
        g->mergeColor[i++] |= b*9;      // write b in both cur and next
      } // end for t
    } // end for b 
  } // end for j
  assert(i==g->mergeLen); 
  // extra check on mergeColor, can be commented out
  #ifndef NDEBUG
  customInt cnt[MAX_NUMBER_OF_BWTS] = {0};
  for(i=0;i<g->mergeLen;i++) cnt[g->mergeColor[i]&0x7]++;
  bool stop=false;
  for(int i=0; i<g->numBwt; i++)
    if(cnt[i]!=g->bwtLen[i]) {
      printf("INIT %d cnt:"CUSTOM_FORMAT" len:"CUSTOM_FORMAT"\n",i,cnt[i],g->bwtLen[i]);
      stop=true;
    }
  assert(!stop);
  #endif
}

// Assembly:
xorl %eax, %eax
xorl %ecx, %ecx
movslq 0x38(%rdi), %rdx
cmpq %rdx, %rax
jge 0x6cc2
movq 0x50e8(%rdi), %rdx
orb $0x40, (%rdx,%rcx)
movq 0x5108(%rdi), %rdx
movq %rcx, (%rdx,%rax,8)
xorl %edx, %edx
movslq 0x20(%rdi), %rsi
cmpq %rsi, %rdx
jge 0x6cbd
leal (%rdx,%rdx,8), %esi
xorl %r8d, %r8d
movq 0x18(%rdi), %r9
movq (%r9,%rdx,8), %r9
cmpq (%r9,%rax,8), %r8
jae 0x6cb8
testq %rax, %rax
jne 0x6ca5
movq 0x50e8(%rdi), %r9
orb $0x40, (%r9,%rcx)
movq 0x50e8(%rdi), %r9
orb %sil, (%r9,%rcx)
incq %rcx
incq %r8
jmp 0x6c86
incq %rdx
jmp 0x6c77
incq %rax
jmp 0x6c56
retq
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/./merge16.h
// Function: init_arrays16
static void init_arrays16(g_data *g)
{
  assert(g->numBwt<=16);
  customInt i=0; // position inside Z newZ and B  

  for(int j=0;j<g->sizeOfAlpha;j++) {
    if(g->bwtOnly) tba_or_m(g->bitB,i,1);
    else g->blockBeginsAt[i]=1;  // start of symbol j, correct lcp is 0
    g->firstColumn[j] = i;  // symbol j starts at position i    
    for(int b=0;b<g->numBwt;b++) {
      for(customInt t=0;t<g->bwtOcc[b][j];t++) {
        if(j==0) { // zero chars are all different, Z are newZ do not change 
          if(g->bwtOnly) tba_or_m(g->bitB,i,1);
          else g->blockBeginsAt[i]=1;  
        }
        g->mergeColor[i++] = b*17;      // write b in both cur and next
      } // end for t
    } // end for b 
  } // end for j
  assert(i==g->mergeLen);
  // extra check on mergeColor, can be commented out
  #ifndef NDEBUG
  customInt cnt[MAX_NUMBER_OF_BWTS] = {0};
  for(i=0;i<g->mergeLen;i++) cnt[g->mergeColor[i]&0xF]++;
  bool stop=false;
  for(int i=0; i<g->numBwt; i++)
    if(cnt[i]!=g->bwtLen[i]) {
      printf("INIT %d cnt:"CUSTOM_FORMAT" len:"CUSTOM_FORMAT"\n",i,cnt[i],g->bwtLen[i]);
      stop=true;
    }
  assert(!stop);
  #endif
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
xorl %eax, %eax
movabsq $0x1, %rdx
xorl %esi, %esi
movslq 0x38(%rdi), %rcx
cmpq %rcx, %rax
jge 0x7890
movq 0x98(%rdi), %r8
cmpb $0x1, 0x3c(%rdi)
jne 0x7808
movq %rsi, %r9
leal (%rsi,%rsi), %ecx
movq %rdx, %r10
shlq %cl, %r10
shrq $0x5, %r9
orq %r10, (%r8,%r9,8)
jmp 0x780d
movb $0x1, (%r8,%rsi)
movq 0x5108(%rdi), %rcx
movq %rsi, (%rcx,%rax,8)
xorl %r8d, %r8d
movslq 0x20(%rdi), %rcx
cmpq %rcx, %r8
jge 0x7888
imull $0x11, %r8d, %r9d
leaq (%rsi,%rsi), %r10
xorl %r11d, %r11d
movq 0x18(%rdi), %rcx
movq (%rcx,%r8,8), %rcx
cmpq (%rcx,%rax,8), %r11
jae 0x7883
testq %rax, %rax
jne 0x786c
movq 0x98(%rdi), %rbx
cmpb $0x1, 0x3c(%rdi)
jne 0x7868
movq %rsi, %r14
movl %r10d, %ecx
andb $0x3e, %cl
movq %rdx, %r15
shlq %cl, %r15
shrq $0x5, %r14
orq %r15, (%rbx,%r14,8)
jmp 0x786c
movb $0x1, (%rbx,%rsi)
movq 0x50e8(%rdi), %rcx
movb %r9b, (%rcx,%rsi)
incq %rsi
incq %r11
addq $0x2, %r10
jmp 0x782f
incq %r8
jmp 0x781b
incq %rax
jmp 0x77d8
popq %rbx
popq %r14
popq %r15
retq