// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/tools/mergelcp.c
// Function: main
int main(int argc, char **argv) {                   
  
  extern char *optarg;
  extern int optind, opterr, optopt;
  
  int c=0, time=0, verbose=0;
  char *c_file=NULL;
  int heap_size=HEAP_SIZE;
  int pos_size=4, lcp_size=4;
  size_t RAM=0;
  int k=0, e;
  
  while ((c=getopt(argc, argv, "s:vthk:m:")) != -1) {
    switch (c)
    {
      case 's':
        heap_size=atoi(optarg); break;  // compute LCP and output in Gap format 
      case 'v':
        verbose++; break;
      case 't':
        time++; break;
      case 'h':
        usage(argv[0]); break;       // show usage and stop
      case 'k':
        k=atoi(optarg); break;       // k-truncated LCP merging
      case 'm':
        RAM=(size_t)atoi(optarg)*MB; break;
      case '?':
        exit(EXIT_FAILURE);
    }
  }
  
  if(verbose>0) {
    puts("Command line:");
    int i;
    for(i=0;i<argc;i++)
      printf(" %s",argv[i]);
    puts("");
  }

  if(optind+3==argc) {
    c_file=argv[optind++];
    pos_size=atoi(argv[optind++]);
    lcp_size=atoi(argv[optind++]);
    
    if(pos_size+lcp_size>16) {
      fprintf(stderr,"POS_SIZE+LCP_SIZE can be at most 16\n");
      exit(EXIT_FAILURE);
    } 
    if(pos_size<=0 || lcp_size<=0) {
      fprintf(stderr,"Both POS_SIZE LCP_SIZE must be at least 1\n");
      exit(EXIT_FAILURE);
    } 
  }
  else{
    usage(argv[0]);
  }
  
  if(heap_size<2){
    puts("ERROR: s must be larger than 1");
    exit(EXIT_FAILURE);
  }

  
  //config
  char c_lcp[PATH_MAX], c_size[PATH_MAX];
  char c_lcp_multi[PATH_MAX], c_size_multi[PATH_MAX]; //multilevel
  
  sprintf(c_lcp, "%s.pair.lcp",  c_file);
  sprintf(c_size, "%s.size.lcp", c_file);
  
  printf("INPUT:\t%s, %s\n", c_lcp, c_size);
  
  if(verbose){
    printf("sizeof(pos) = %d bytes\n", pos_size);
    printf("sizeof(lcp) = %d bytes\n", lcp_size);
  }

  printf("##\n");
  if(RAM){
    if(RAM<pow(2,20)) printf("RAM = %.2lf KB\n", RAM/pow(2,10));
    else if (RAM>=pow(2,20) && RAM<pow(2,30)) printf("RAM = %.2lf MB\n", RAM/pow(2,20));
    else printf("RAM = %.2lf GB\n", (double)RAM/pow(2,30));
    //fprintf(stderr,"RAM = %.2lf GB\n", (double)RAM/pow(2,30));
  }
  else printf("RAM = unlimited\n");

  // inits 
  time_t t_start=0, t_total=0;
  clock_t c_start=0, c_total=0;
   
  time_start(&t_start, &c_start);
  time_start(&t_total, &c_total);
  
  //alloc heap
  int level=0, onelevel=0;
  size_t i, blocks;
  FILE *f_size, *f_lcp;
  heap *h;
  size_t size, seek=0;
  size_t sum;

  f_size = fopen(c_size, "rb");//header file
  size_t n;
  e = fread(&n, sizeof(size_t), 1, f_size);
  if(e!=1) {perror (__func__); exit(EXIT_FAILURE);}
  printf("Number of LCP entries in output file: = %zu\n", n);
  
  //LEVEL 1 
  do{ // multilevel merging
  
    //printf("INPUT: %s\t%s\n", c_lcp, c_size);
    seek=0;
    
    blocks=1; i=0; sum=0;
    level++;
    h = heap_alloc(heap_size, c_lcp, level, pos_size, lcp_size, RAM);
    
    
    //output
    sprintf(c_lcp_multi, "%s.pair.%d.lcp", c_file, level);  
    f_lcp = file_open(c_lcp_multi, "wb");//lists file
    
    sprintf(c_size_multi, "%s.size.%d.lcp", c_file, level);
    FILE* f_size_multi = file_open(c_size_multi, "wb");
    
    /**/
    while(fread(&size, sizeof(size_t), 1, f_size)){
      //init heap
      #if DEBUG
        printf("%zu (%zu): ", size, seek);
      #endif
      heap_insert(h, seek); //size == seek
      seek+=size;
      
      if(++i == heap_size){
            
        heap_sort_level(h, f_lcp, &sum, c_file, level, k);     
        fwrite(&sum, sizeof(size_t), 1, f_size_multi);
      
        //new heap
        heap_free(h, f_lcp, level);
        h = heap_alloc(heap_size, c_lcp, level, pos_size, lcp_size, RAM);
        
        blocks++;
        i=0;
        sum=0;
      }
    }
    
    if(i){//last block
      
      if(blocks==1 && level==1){
        onelevel=1;
        fclose(f_lcp); fclose(f_size); fclose(f_size_multi);
        //empty files
        remove(c_size_multi);
        remove(c_lcp_multi);
        break;
      }
      
      heap_sort_level(h, f_lcp, &sum, c_file, level, k);
      fwrite(&sum, sizeof(size_t), 1, f_size_multi);    
    }
        
    heap_free(h, f_lcp, level);
    fclose(f_lcp); fclose(f_size); fclose(f_size_multi);
    
    if(verbose)
      printf("%zux%d+%zu\t\n", blocks-1, heap_size, i);
    
    if(level>1){//do not remove the original inputs
      remove(c_lcp);
      remove(c_size);
    }
    
    //input for the next level
    sprintf(c_lcp, "%s.pair.%d.lcp", c_file, level);
    sprintf(c_size, "%s.size.%d.lcp", c_file, level);

    f_size = fopen(c_size, "rb");//header file
  }
  while(blocks>heap_size);
  
  if(onelevel){
    if(verbose)
      printf("%zux%d+%zu\t\n", blocks-1, heap_size, i);
  }
  else{
    /**/
    if(time){
      printf("## LEVEL 1 ##\n");
      //fprintf(stderr,"%.6lf\n", time_stop(t_start, c_start));
      time_stop(t_start, c_start);
      time_start(&t_start, &c_start);
    }
    /**/
    
    //LEVEL 2
    
    //printf("INPUT: %s\t%s\n", c_lcp_multi, c_size_multi);
    if(verbose)
      printf("%dx%zu\t\n", 1, blocks);
    
    f_size = file_open(c_size_multi, "rb");//header file

    h = heap_alloc(blocks, c_lcp_multi, 0, pos_size, lcp_size, RAM);
    seek=0;
    
    while(fread(&size, sizeof(size_t), 1, f_size)){
      #if DEBUG
        printf("%zu (%zu): ", size, seek);
      #endif
      heap_insert(h, seek); //size == seek
      seek+=size;
    }
    
    fclose(f_size);
  }
  
  sprintf(c_lcp, "%s.%d.lcp", c_file, lcp_size);//linal
  f_lcp = file_open(c_lcp, "wb");
    
  size_t total=0;
  
  #if CHECK == 1
    if(heap_sort_level(h, f_lcp, &total, c_file, 0, k)) printf("isSorted!!\n");
    else printf("isNotSorted!!\n");
  #else
    heap_sort_level(h, f_lcp, &total, c_file, 0, k);
  #endif
  
  printf("N = %zu (%zu)\n", total, n);

  if(k){
    //complete LCP empty entries
    /**/
    int64_t curr=total;
    int64_t pos=n;

    pair aux=lcp(k); //k-truncated LCP-values
    for(;curr<pos;curr++){
      #if CHECK == 1
        fprintf(stderr,"** %lu, %lu (lcp = %lu)\n", pos, curr, lcp(aux));
      #endif
      heap_write(h, f_lcp, aux, level);
    }
    /**/
  }
  
  heap_free(h, f_lcp, 0);
  fclose(f_lcp);
  
  /**/
  if(time){
    printf("## LEVEL 2 ##\n");
    time_stop(t_start, c_start);
  }
  /**/
  
  if(time){
    printf("## TOTAL ##\n");
    fprintf(stderr,"%.6lf\n", time_stop(t_total, c_total));
  }
  
  printf("OUTPUT:\t%s\n", c_lcp);
  
  remove(c_lcp_multi);
  remove(c_size_multi);
  
  //checking
  #if CHECK == 2
    printf("CHECK:\t");
    char c_pos[500];
    sprintf(c_pos, "%s.pos.lcp", c_file);
    FILE* f_pos = file_open(c_pos, "rb");
    f_lcp = file_open(c_lcp, "rb");
    uint64_t pos=0,lcp=0;
    int true=1; 
    size_t previous=0;
    sum=0;
    while(fread(&pos, pos_size, 1, f_pos)){
      fread(&lcp, lcp_size, 1, f_lcp);
      #if DEBUG
        printf("<%lu, %lu> ", pos, lcp);
      #endif
      if(previous>pos){
        true=0; break;
      }
      previous=pos;
      sum++;
    }
    printf("\n");
    if(true) printf("isSorted!! (%zu)\n", sum);
    else printf("isNotSorted!!\n");

    fclose(f_pos);
    fclose(f_lcp);
  #endif

  /**/
  sprintf(c_lcp, "%s.pair.lcp",  c_file);
  sprintf(c_size, "%s.size.lcp", c_file);

  remove(c_lcp);
  remove(c_size);
  /**/


return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x40a8, %rsp           # imm = 0x40A8
movq %rsi, %rbx
movl %edi, %ebp
movl $0x100, 0xc(%rsp)       # imm = 0x100
movq $0x0, 0x28(%rsp)
leaq 0x2c91(%rip), %r14      # 0x4299
leaq 0x2a31(%rip), %r15      # 0x4040
movq 0x59c2(%rip), %r12      # 0x6fd8
movl $0x0, 0x18(%rsp)
movl $0x0, 0x10(%rsp)
movl $0x0, 0x1c(%rsp)
movl %ebp, %edi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x1180
leal -0x68(%rax), %ecx
cmpl $0xe, %ecx
ja 0x165b
movslq (%r15,%rcx,4), %rax
addq %r15, %rax
jmpq *%rax
movq (%r12), %rdi
callq 0x11a0
movl %eax, 0x18(%rsp)
jmp 0x162e
cmpl $-0x1, %eax
je 0x169b
cmpl $0x3f, %eax
jne 0x162e
jmp 0x1ec9
incl 0x1c(%rsp)
jmp 0x162e
incl 0x10(%rsp)
jmp 0x162e
movq (%r12), %rdi
callq 0x11a0
movl %eax, 0xc(%rsp)
jmp 0x162e
movq (%r12), %rdi
callq 0x11a0
cltq
shlq $0x14, %rax
movq %rax, 0x28(%rsp)
jmp 0x162e
cmpl $0x0, 0x10(%rsp)
jle 0x16e4
leaq 0x2bfa(%rip), %rdi      # 0x42a3
callq 0x1080
testl %ebp, %ebp
movl $0x0, %r15d
cmovgl %ebp, %r15d
leaq 0x2bf0(%rip), %r14      # 0x42b1
xorl %r12d, %r12d
cmpq %r12, %r15
je 0x16dc
movq (%rbx,%r12,8), %rsi
movq %r14, %rdi
xorl %eax, %eax
callq 0x10d0
incq %r12
jmp 0x16c4
pushq $0xa
popq %rdi
callq 0x1040
movq 0x58e5(%rip), %r15      # 0x6fd0
movslq (%r15), %r14
leal 0x3(%r14), %eax
cmpl %ebp, %eax
jne 0x1e74
movq (%rbx,%r14,8), %r13
leaq 0x2(%r14), %rax
movl %eax, (%r15)
movq 0x8(%rbx,%r14,8), %rdi
callq 0x11a0
movl %eax, %r12d
movl %ebp, (%r15)
movq 0x10(%rbx,%r14,8), %rdi
callq 0x11a0
movq %rax, 0x20(%rsp)
addl %r12d, %eax
cmpl $0x11, %eax
jge 0x1e7c
testl %r12d, %r12d
movq 0x28(%rsp), %r15
jle 0x1e91
cmpl $0x0, 0x20(%rsp)
jle 0x1e91
cmpl $0x1, 0xc(%rsp)
jle 0x1eaf
movq %r12, %rbp
leaq 0x2bc6(%rip), %rsi      # 0x4324
leaq 0xa0(%rsp), %rbx
movq %rbx, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0x11b0
leaq 0x2bb6(%rip), %rsi      # 0x4330
leaq 0x30a0(%rsp), %r14
movq %r14, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0x11b0
leaq 0x2ba6(%rip), %rdi      # 0x433c
movq %rbx, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x10d0
cmpl $0x0, 0x10(%rsp)
je 0x17cd
leaq 0x2b9a(%rip), %rdi      # 0x434b
movl %ebp, %esi
xorl %eax, %eax
callq 0x10d0
leaq 0x2ba2(%rip), %rdi      # 0x4363
movq 0x20(%rsp), %rsi
xorl %eax, %eax
callq 0x10d0
leaq 0x2c8a(%rip), %rdi      # 0x445e
callq 0x1080
testq %r15, %r15
je 0x1819
movq %r15, %xmm1
punpckldq 0x2825(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x282d(%rip), %xmm1     # 0x4020
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
cmpq $0x3fffffff, %r15       # imm = 0x3FFFFFFF
ja 0x1827
mulsd 0x2828(%rip), %xmm0     # 0x4038
leaq 0x2b64(%rip), %rdi      # 0x437b
jmp 0x1836
leaq 0x2c23(%rip), %rdi      # 0x4443
callq 0x1080
jmp 0x183d
mulsd 0x2801(%rip), %xmm0     # 0x4030
leaq 0x2b55(%rip), %rdi      # 0x438b
movb $0x1, %al
callq 0x10d0
movq %r15, 0x28(%rsp)
movq %r13, %r12
leaq 0x80(%rsp), %rdi
andq $0x0, (%rdi)
leaq 0x90(%rsp), %rbx
andq $0x0, (%rbx)
leaq 0x78(%rsp), %rsi
andq $0x0, (%rsi)
leaq 0x88(%rsp), %r14
andq $0x0, (%r14)
callq 0x1ed4
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1ed4
leaq 0x2b12(%rip), %rsi      # 0x439b
leaq 0x30a0(%rsp), %rdi
callq 0x1160
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
pushq $0x8
popq %rsi
pushq $0x1
popq %rdx
movq %rax, %rcx
callq 0x1090
cmpl $0x1, %eax
jne 0x1ebd
movq 0x70(%rsp), %rsi
leaq 0x2ae2(%rip), %rdi      # 0x43a3
xorl %eax, %eax
callq 0x10d0
movl 0xc(%rsp), %r14d
leaq 0xa0(%rsp), %r15
leaq 0x2af4(%rip), %r13      # 0x43d0
xorl %edx, %edx
movq %rbp, %rcx
movq %r12, 0x48(%rsp)
movq %rbp, 0x60(%rsp)
andq $0x0, 0x50(%rsp)
movq %rdx, 0x68(%rsp)
leal 0x1(%rdx), %ebp
movl 0xc(%rsp), %edi
movq %r15, %rsi
movl %ebp, %edx
movq 0x20(%rsp), %r8
movq 0x28(%rsp), %r9
callq 0x25d8
movq %rax, %r15
leaq 0x10a0(%rsp), %rdi
movq %r13, %rsi
movq %r12, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x11b0
leaq 0x10a0(%rsp), %rdi
leaq 0x2aa5(%rip), %rsi      # 0x43df
callq 0x12ec
movq %rax, 0x30(%rsp)
leaq 0x20a0(%rsp), %r13
movq %r13, %rdi
leaq 0x2a8c(%rip), %rsi      # 0x43e2
movq %r12, %rdx
movl %ebp, 0x14(%rsp)
movl %ebp, %ecx
xorl %eax, %eax
callq 0x11b0
movq %r13, %rdi
leaq 0x2a6f(%rip), %rsi      # 0x43df
callq 0x12ec
movq %rax, 0x38(%rsp)
pushq $0x1
popq %rax
movq %rax, 0x40(%rsp)
xorl %r13d, %r13d
xorl %r12d, %r12d
leaq 0x58(%rsp), %rdi
pushq $0x8
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
callq 0x1090
testq %rax, %rax
je 0x1a4b
movq 0x58(%rsp), %rbp
leaq 0x2a41(%rip), %rdi      # 0x43f1
movq %rbp, %rsi
movq %r13, %rdx
xorl %eax, %eax
callq 0x10d0
movq %r15, %rdi
movq %r13, %rsi
callq 0x2b60
addq %rbp, %r13
incq %r12
cmpq %r12, %r14
jne 0x1988
movq %r15, %rdi
movq 0x30(%rsp), %rsi
leaq 0x50(%rsp), %r12
movq %r12, %rdx
movl 0x14(%rsp), %ebp
movl %ebp, %r8d
movl 0x18(%rsp), %r9d
callq 0x131f
movq %r12, %rdi
pushq $0x8
popq %rsi
pushq $0x1
popq %rdx
movq 0x38(%rsp), %rcx
callq 0x11d0
movq %r15, %rdi
movq 0x30(%rsp), %rsi
movl %ebp, %edx
callq 0x2871
movl 0xc(%rsp), %edi
leaq 0xa0(%rsp), %rsi
movl %ebp, %edx
movq 0x60(%rsp), %rcx
movq 0x20(%rsp), %r8
movq 0x28(%rsp), %r9
callq 0x25d8
movq %rax, %r15
incq 0x40(%rsp)
andq $0x0, 0x50(%rsp)
jmp 0x1985
testq %r12, %r12
movq 0x48(%rsp), %r13
je 0x1aa0
cmpq $0x1, 0x40(%rsp)
sete %al
cmpl $0x0, 0x68(%rsp)
sete %cl
testb %al, %cl
jne 0x1c66
movq %r15, %rdi
movq 0x30(%rsp), %rsi
leaq 0x50(%rsp), %rbp
movq %rbp, %rdx
movl 0x14(%rsp), %r8d
movl 0x18(%rsp), %r9d
callq 0x131f
movq %rbp, %rdi
pushq $0x8
popq %rsi
pushq $0x1
popq %rdx
movq 0x38(%rsp), %rcx
callq 0x11d0
movq %r13, %rbp
movq %r15, %rdi
movq 0x30(%rsp), %r15
movq %r15, %rsi
movl 0x14(%rsp), %edx
callq 0x2871
movq %r15, %rdi
callq 0x10b0
movq %rbx, %rdi
callq 0x10b0
movq 0x38(%rsp), %rdi
callq 0x10b0
cmpl $0x0, 0x10(%rsp)
je 0x1af6
movq 0x40(%rsp), %rax
leaq -0x1(%rax), %rsi
leaq 0x2915(%rip), %rdi      # 0x43fd
movl 0xc(%rsp), %edx
movq %r12, %rcx
xorl %eax, %eax
callq 0x10d0
cmpl $0x0, 0x68(%rsp)
leaq 0x28ce(%rip), %r13      # 0x43d0
leaq 0x30a0(%rsp), %rbx
leaq 0xa0(%rsp), %r15
je 0x1b24
movq %r15, %rdi
callq 0x1060
movq %rbx, %rdi
callq 0x1060
movq %r15, %rdi
movq %r13, %rsi
movq %rbp, %r12
movq %rbp, %rdx
movq %rbx, %rbp
movl 0x14(%rsp), %ebx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x11b0
movq %rbp, %rdi
leaq 0x2898(%rip), %rsi      # 0x43e2
movq %r12, %rdx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x11b0
movq %rbp, %rdi
leaq 0x283b(%rip), %rsi      # 0x439b
callq 0x1160
movl %ebx, %edx
movq %rax, %rbx
movq 0x40(%rsp), %rbp
cmpq %r14, %rbp
movq 0x60(%rsp), %rcx
ja 0x18eb
movq %rcx, %r12
cmpl $0x0, 0x1c(%rsp)
je 0x1bb6
leaq 0x28c5(%rip), %rdi      # 0x4453
callq 0x1080
leaq 0x80(%rsp), %rbx
movq (%rbx), %rdi
leaq 0x78(%rsp), %r14
movq (%r14), %rsi
callq 0x1ef8
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1ed4
cmpl $0x0, 0x10(%rsp)
movq 0x28(%rsp), %r14
je 0x1bd6
leaq 0x2841(%rip), %rdi      # 0x440a
pushq $0x1
popq %rsi
movq %rbp, %rdx
xorl %eax, %eax
callq 0x10d0
leaq 0x27be(%rip), %rsi      # 0x439b
leaq 0x20a0(%rsp), %rdi
callq 0x12ec
movq %rax, %rbx
leaq 0x10a0(%rsp), %rsi
movl %ebp, %edi
xorl %edx, %edx
movl %r12d, %ecx
movq 0x20(%rsp), %r8
movq %r14, %r9
callq 0x25d8
movq %rax, %r15
pushq $0x1
popq %r13
leaq 0x27da(%rip), %rbp      # 0x43f1
xorl %r14d, %r14d
leaq 0x58(%rsp), %rdi
pushq $0x8
popq %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x1090
testq %rax, %rax
je 0x1c57
movq 0x58(%rsp), %r12
movq %rbp, %rdi
movq %r12, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x10d0
movq %r15, %rdi
movq %r14, %rsi
callq 0x2b60
addq %r12, %r14
jmp 0x1c1a
movq %rbx, %rdi
callq 0x10b0
movq 0x48(%rsp), %r13
jmp 0x1cba
movq 0x30(%rsp), %rdi
callq 0x10b0
movq %rbx, %rdi
callq 0x10b0
movq 0x38(%rsp), %rdi
callq 0x10b0
leaq 0x20a0(%rsp), %rdi
callq 0x1060
leaq 0x10a0(%rsp), %rdi
callq 0x1060
cmpl $0x0, 0x10(%rsp)
je 0x1cba
leaq 0x2753(%rip), %rdi      # 0x43fd
xorl %esi, %esi
movl 0xc(%rsp), %edx
movq %r12, %rcx
xorl %eax, %eax
callq 0x10d0
leaq 0x2752(%rip), %rsi      # 0x4413
leaq 0xa0(%rsp), %rbx
movq %rbx, %rdi
movq %r13, %rdx
movq 0x20(%rsp), %rcx
xorl %eax, %eax
callq 0x11b0
leaq 0x26fd(%rip), %rsi      # 0x43df
movq %rbx, %rdi
callq 0x12ec
movq %rax, %rbx
leaq 0x98(%rsp), %r14
andq $0x0, (%r14)
movq %r15, %rdi
movq %rax, %rsi
movq %r14, %rdx
xorl %r8d, %r8d
movl 0x18(%rsp), %ebp
movl %ebp, %r9d
callq 0x131f
movq (%r14), %r14
movq 0x70(%rsp), %r12
leaq 0x26fd(%rip), %rdi      # 0x441d
movq %r14, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0x10d0
testl %ebp, %ebp
je 0x1d69
movslq %ebp, %r13
movslq 0x218(%r15), %rax
shlq $0x4, %rax
leaq 0x233a(%rip), %rcx      # 0x4080
andq (%rax,%rcx), %r13
cmpq %r12, %r14
jge 0x1d69
movq %r15, %rdi
movq %rbx, %rsi
movq %r13, %rdx
xorl %ecx, %ecx
movl 0x14(%rsp), %r8d
callq 0x2cd6
incq %r14
jmp 0x1d4a
movq %r15, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x2871
movq %rbx, %rdi
callq 0x10b0
cmpl $0x0, 0x1c(%rsp)
jne 0x1e15
leaq 0x26a3(%rip), %rdi      # 0x4433
leaq 0xa0(%rsp), %rbx
movq %rbx, %rsi
xorl %eax, %eax
callq 0x10d0
leaq 0x10a0(%rsp), %rdi
callq 0x1060
leaq 0x20a0(%rsp), %rdi
callq 0x1060
leaq 0x2561(%rip), %rsi      # 0x4324
movq %rbx, %rdi
movq 0x48(%rsp), %r15
movq %r15, %rdx
xorl %eax, %eax
callq 0x11b0
leaq 0x2554(%rip), %rsi      # 0x4330
leaq 0x30a0(%rsp), %r14
movq %r14, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x11b0
movq %rbx, %rdi
callq 0x1060
movq %r14, %rdi
callq 0x1060
xorl %eax, %eax
addq $0x40a8, %rsp           # imm = 0x40A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2645(%rip), %rdi      # 0x4461
callq 0x1080
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
callq 0x1ef8
leaq 0x2635(%rip), %rdi      # 0x446f
callq 0x1080
movq 0x51b2(%rip), %rax      # 0x6ff8
movq (%rax), %rbx
movq 0x90(%rsp), %rdi
movq 0x88(%rsp), %rsi
callq 0x1ef8
leaq 0x25c7(%rip), %rsi      # 0x442c
movq %rbx, %rdi
movb $0x1, %al
callq 0x1100
jmp 0x1d89
movq (%rbx), %rdi
callq 0x1548
movq 0x5175(%rip), %rax      # 0x6ff8
movq (%rax), %rcx
leaq 0x2428(%rip), %rdi      # 0x42b5
pushq $0x24
jmp 0x1ea4
movq 0x5160(%rip), %rax      # 0x6ff8
movq (%rax), %rcx
leaq 0x2438(%rip), %rdi      # 0x42da
pushq $0x2a
popq %rsi
pushq $0x1
popq %rdx
callq 0x11d0
jmp 0x1ec9
leaq 0x244f(%rip), %rdi      # 0x4305
callq 0x1080
jmp 0x1ec9
leaq 0x24da(%rip), %rdi      # 0x439e
callq 0x1170
pushq $0x1
popq %rdi
callq 0x11c0
nopl (%rax)