// File: /workspace/github_c_makefile_star2_O0/felipelouza[P]egap/mergegap.c
// Function: gap
void gap(g_data *g, bool lastRound) {
  
  // maybe there is nothing to do
  if(g->numBwt<2 && !g->lcpCompute && g->dbOrder==0) {
    assert(g->numBwt==1);
    if(g->verbose>0) puts("Single BWT/LCP merging: nothing to do!");
    return;
  }
  // try preferred algorithm
  if(g->algorithm==8 && g->numBwt <=8 && !g->lcpMerge)
    return gap8(g,lastRound);
  else if(g->algorithm==16 && g->numBwt <=16 && !g->extMem &&!g->lcpCompute)
    return gap16(g,lastRound);    
  else if(g->algorithm==128 && g->numBwt <=128 && !g->lcpMerge)
    return g->extMem ? gap128ext(g,lastRound) : gap128(g,lastRound);    
  else if(g->algorithm==256 && g->numBwt <=256 && g->lcpCompute && !g->mwXMerge)
    return gap256(g,lastRound);
  else if(!g->algorithm) {      
    // use a best fit strategy
    if(g->numBwt<=128 && g->extMem)
      return gap128ext(g,lastRound); // gap128ext is the best extMem also since uses o(n) RAM 
    // case of lcpCompute or bwtOnly not in external memory for at most 128 bwts
    if(!g->lcpMerge && g->numBwt <= 128 && !g->extMem) 
      return gap128(g,lastRound);  // possibly use gap8 or gap16      
    // case <=16 with lcpMerge not in external memory
    if(g->numBwt<=16 && g->lcpMerge && !g->extMem) return gap16(g,lastRound);
  }

  // everything else is handled here!
  if(g->verbose>0) {
    if(g->lcpCompute) puts("BWT Merge + LCP compute with gap");
    else if(g->lcpMerge) puts("BWT/LCP Merge with gap");  
    else puts("BWT only merging with gap");
  }
  assert(g->numBwt <= MAX_NUMBER_OF_BWTS);
  if(g->lcpCompute) {       // we compute LCP values only if we are at the last round 
    assert(!g->bwtOnly && lastRound);
    open_unsortedLCP_files(g);
  }
  else assert(g->bwtOnly || g->lcpMerge);
  
  // init local global vars
  check_g_data(g);
  if(g->extMem) open_bw_files(g);
  // allocate and clear bit/int array B 
  if(!g->lcpMerge) g->bitB = tba_alloc(g->mergeLen, g->mmapB);
  else alloc0_B_array(g); // alloc and clear blockBeginsAt array
        
  // allocate Z (merge) Znew 
  alloc_merge_arrays(g);
  // allocate other useful arrays
  g->inCnt = malloc(g->numBwt*sizeof(customInt));
  g->firstColumn = malloc(g->sizeOfAlpha*sizeof(customInt));
  g->F = malloc(g->sizeOfAlpha*sizeof(customInt));
  if(!g->inCnt || !g->firstColumn || !g->F)  die(__func__);
  // init the above arrays
  if(g->smallAlpha) init_arrays(g);
  else init_arrays_largealpha(g);
  // we are now ready to give mmap advise
  #ifdef USE_MMAP_ADVISE
  if(g->mmapZ) { // advise on g->mergeColor
    for (int i = 0; i < g->sizeOfAlpha-1; ++i)
      madvise(g->mergeColor + g->firstColumn[i], (g->firstColumn[i+1]-g->firstColumn[i])*sizeof(palette), MADV_SEQUENTIAL);
    madvise(g->mergeColor + g->firstColumn[g->sizeOfAlpha-1], (g->mergeLen-g->firstColumn[g->sizeOfAlpha-1])*sizeof(palette), MADV_SEQUENTIAL);
  }
  #endif

  // init liquid block (containing list of allocated mem)
  liquidBlock *liquid = liquid_new(g); 
  // init list (on disk) of irrelevant blocks, initially empty 
  solidBlockFile *ibList = ibHead_new(g);

  // main loop
  customInt prefixLength = 1;      
  int lcpSize = POS_SIZE + BSIZE;   // number of bytes for each pos,lcp pair: see writeLcp()
  int round=0;
  bool merge_completed; 
  do {
    prefixLength+= 1;
    if(prefixLength>MAX_LCP_SIZE && g->lcpMerge) {fprintf(stderr,"LCP too large (use --lbytes=4)\n");exit(EXIT_FAILURE);}
    if(g->lcpCompute && prefixLength-2>MAX_LCP_SIZE) {fprintf(stderr,"LCP too large (2) (use --lbytes=4)\n");exit(EXIT_FAILURE);}
    bool mergeChanged = false; // the Z vector has changed in this iteration (used when g->bwtOnly)
    ibList->fout = gap_tmpfile(g->outPath);
    merge_completed=addCharToPrefix(ibList,liquid,prefixLength,&mergeChanged,round,g);
    if (g->verbose>1 && lastRound) {
      #if MALLOC_COUNT_FLAG
        printf("Lcp: "CUSTOM_FORMAT". Memory peak/current: %.2lf/%.2lf bytes/symbol. ibList: %ju\n", prefixLength-1, (double)malloc_count_peak()/g->mergeLen, (double)malloc_count_current()/g->mergeLen, (uintmax_t) ftello(ibList->fout));
      #else
        printf("Lcp: "CUSTOM_FORMAT". ibList: %ju\n", prefixLength-1, (uintmax_t) ftello(ibList->fout));
      #endif
      // also EOF are written to unsortedLcp file so percentages are not accurate     
      if(g->unsortedLcp) printf("   unsorted lcp values: %ju (%.2lf%%)\n",  
      (uintmax_t) ftello(g->unsortedLcp)/lcpSize, (double) 100*ftello(g->unsortedLcp)/(lcpSize*g->mergeLen));
    }
    round  = 1 - round; // change round parity
    if(g->bwtOnly && !mergeChanged) {
      if(g->verbose>1) puts("Gap bwt-only early termination");
      fclose(ibList->fout);
      break;
    }
    if(ibList->fin!=NULL) fclose(ibList->fin);
    rewind(ibList->fout);
    ibList->fin = ibList->fout;
  } while(!merge_completed);  // end main loop
  if(ibList->fin!=NULL) fclose(ibList->fin);

  #if MALLOC_COUNT_FLAG
    if (g->verbose>0) {
      if(lastRound)
        printf("Merge completed (%d bwts). Mem: %zu peak, %zu current, %.2lf/%.2lf bytes/symbol\n", g->numBwt, malloc_count_peak(),
             malloc_count_current(), (double)malloc_count_peak()/g->mergeLen,
             (double)malloc_count_current()/g->mergeLen);
      else if(g->verbose>1)
        printf("Merge completed (%d bwts). Mem: %zu peak, %zu current\n", g->numBwt, malloc_count_peak(),
             malloc_count_current());
    }
  #else
    if (g->verbose>0) {
        printf("Merge completed (%d bwts).\n", g->numBwt);
    }
  #endif
  liquid_free(liquid);
  ibHead_free(ibList);
  if(g->extMem) close_bw_files(g);

  // computation complete, do the merging. The following call writes the
  // (possibly remapped) merged BWT back to g->bws[0]; and if lcpMerge==true the merged LCP to g->lcps[0] 
  mergeBWTandLCP(g,lastRound);
  if(g->lcpCompute) {
    assert(lastRound);
    // close lcp file (and merge them?)
    close_unsortedLCP_files(g);
    if(g->verbose>0) printf("Remind to run mergelcp to obtain the final LCP array\n"); 
  }

  // free B array 
  if(!g->lcpMerge) tba_free(g->bitB, g->mergeLen, g->mmapB);
  else free_B_array(g); 
  free(g->F); // last five arrays deallocated
  free(g->firstColumn); 
  free(g->inCnt);
  free_merge_arrays(g);
}

// Assembly:
subq $0xd8, %rsp
movb %sil, %al
movq %rdi, 0xd0(%rsp)
andb $0x1, %al
movb %al, 0xcf(%rsp)
movq 0xd0(%rsp), %rax
cmpl $0x2, 0x20(%rax)
jge 0xec67
movq 0xd0(%rsp), %rax
testb $0x1, 0x3e(%rax)
jne 0xec67
movq 0xd0(%rsp), %rax
cmpl $0x0, 0x40(%rax)
jne 0xec67
movq 0xd0(%rsp), %rax
cmpl $0x0, 0x94(%rax)
jle 0xec62
leaq 0x7240(%rip), %rdi      # 0x15e9d
callq 0x2080
jmp 0xf84c
movq 0xd0(%rsp), %rax
cmpl $0x8, 0x6c(%rax)
jne 0xecaf
movq 0xd0(%rsp), %rax
cmpl $0x8, 0x20(%rax)
jg 0xecaf
movq 0xd0(%rsp), %rax
testb $0x1, 0x3d(%rax)
jne 0xecaf
movq 0xd0(%rsp), %rdi
movb 0xcf(%rsp), %al
andb $0x1, %al
movzbl %al, %esi
callq 0x9150
jmp 0xf84c
movq 0xd0(%rsp), %rax
cmpl $0x10, 0x6c(%rax)
jne 0xed05
movq 0xd0(%rsp), %rax
cmpl $0x10, 0x20(%rax)
jg 0xed05
movq 0xd0(%rsp), %rax
testb $0x1, 0x69(%rax)
jne 0xed05
movq 0xd0(%rsp), %rax
testb $0x1, 0x3e(%rax)
jne 0xed05
movq 0xd0(%rsp), %rdi
movb 0xcf(%rsp), %al
andb $0x1, %al
movzbl %al, %esi
callq 0xa500
jmp 0xf84c
movq 0xd0(%rsp), %rax
cmpl $0x80, 0x6c(%rax)
jne 0xed7c
movq 0xd0(%rsp), %rax
cmpl $0x80, 0x20(%rax)
jg 0xed7c
movq 0xd0(%rsp), %rax
testb $0x1, 0x3d(%rax)
jne 0xed7c
movq 0xd0(%rsp), %rax
testb $0x1, 0x69(%rax)
je 0xed5e
movq 0xd0(%rsp), %rdi
movb 0xcf(%rsp), %al
andb $0x1, %al
movzbl %al, %esi
callq 0xca80
jmp 0xed77
movq 0xd0(%rsp), %rdi
movb 0xcf(%rsp), %al
andb $0x1, %al
movzbl %al, %esi
callq 0xb710
jmp 0xf84c
movq 0xd0(%rsp), %rax
cmpl $0x100, 0x6c(%rax)      # imm = 0x100
jne 0xedd8
movq 0xd0(%rsp), %rax
cmpl $0x100, 0x20(%rax)      # imm = 0x100
jg 0xedd8
movq 0xd0(%rsp), %rax
testb $0x1, 0x3e(%rax)
je 0xedd8
movq 0xd0(%rsp), %rax
testb $0x1, 0x3f(%rax)
jne 0xedd8
movq 0xd0(%rsp), %rdi
movb 0xcf(%rsp), %al
andb $0x1, %al
movzbl %al, %esi
callq 0xdaf0
jmp 0xf84c
movq 0xd0(%rsp), %rax
cmpl $0x0, 0x6c(%rax)
jne 0xeebc
movq 0xd0(%rsp), %rax
cmpl $0x80, 0x20(%rax)
jg 0xee27
movq 0xd0(%rsp), %rax
testb $0x1, 0x69(%rax)
je 0xee27
movq 0xd0(%rsp), %rdi
movb 0xcf(%rsp), %al
andb $0x1, %al
movzbl %al, %esi
callq 0xca80
jmp 0xf84c
movq 0xd0(%rsp), %rax
testb $0x1, 0x3d(%rax)
jne 0xee72
movq 0xd0(%rsp), %rax
cmpl $0x80, 0x20(%rax)
jg 0xee72
movq 0xd0(%rsp), %rax
testb $0x1, 0x69(%rax)
jne 0xee72
movq 0xd0(%rsp), %rdi
movb 0xcf(%rsp), %al
andb $0x1, %al
movzbl %al, %esi
callq 0xb710
jmp 0xf84c
movq 0xd0(%rsp), %rax
cmpl $0x10, 0x20(%rax)
jg 0xeeba
movq 0xd0(%rsp), %rax
testb $0x1, 0x3d(%rax)
je 0xeeba
movq 0xd0(%rsp), %rax
testb $0x1, 0x69(%rax)
jne 0xeeba
movq 0xd0(%rsp), %rdi
movb 0xcf(%rsp), %al
andb $0x1, %al
movzbl %al, %esi
callq 0xa500
jmp 0xf84c
jmp 0xeebc
jmp 0xeebe
jmp 0xeec0
jmp 0xeec2
jmp 0xeec4
movq 0xd0(%rsp), %rax
cmpl $0x0, 0x94(%rax)
jle 0xef1d
movq 0xd0(%rsp), %rax
testb $0x1, 0x3e(%rax)
je 0xeef1
leaq 0x6fda(%rip), %rdi      # 0x15ec4
callq 0x2080
jmp 0xef1b
movq 0xd0(%rsp), %rax
testb $0x1, 0x3d(%rax)
je 0xef0d
leaq 0x6fdf(%rip), %rdi      # 0x15ee5
callq 0x2080
jmp 0xef19
leaq 0x6fe8(%rip), %rdi      # 0x15efc
callq 0x2080
jmp 0xef1b
jmp 0xef1d
movq 0xd0(%rsp), %rax
testb $0x1, 0x3e(%rax)
je 0xef3a
movq 0xd0(%rsp), %rdi
callq 0x3ed0
jmp 0xef3c
jmp 0xef3c
movq 0xd0(%rsp), %rdi
callq 0x3dd0
movq 0xd0(%rsp), %rax
testb $0x1, 0x69(%rax)
je 0xef64
movq 0xd0(%rsp), %rdi
callq 0x6da0
movq 0xd0(%rsp), %rax
testb $0x1, 0x3d(%rax)
jne 0xefa7
movq 0xd0(%rsp), %rax
movq 0x28(%rax), %rdi
movq 0xd0(%rsp), %rax
movb 0x71(%rax), %al
andb $0x1, %al
movzbl %al, %esi
callq 0x8fe0
movq %rax, %rcx
movq 0xd0(%rsp), %rax
movq %rcx, 0x98(%rax)
jmp 0xefb4
movq 0xd0(%rsp), %rdi
callq 0x69b0
movq 0xd0(%rsp), %rdi
callq 0x6440
movq 0xd0(%rsp), %rax
movslq 0x20(%rax), %rdi
shlq $0x3, %rdi
callq 0x127b0
movq %rax, %rcx
movq 0xd0(%rsp), %rax
movq %rcx, 0x5118(%rax)
movq 0xd0(%rsp), %rax
movslq 0x38(%rax), %rdi
shlq $0x3, %rdi
callq 0x127b0
movq %rax, %rcx
movq 0xd0(%rsp), %rax
movq %rcx, 0x5108(%rax)
movq 0xd0(%rsp), %rax
movslq 0x38(%rax), %rdi
shlq $0x3, %rdi
callq 0x127b0
movq %rax, %rcx
movq 0xd0(%rsp), %rax
movq %rcx, 0x5110(%rax)
movq 0xd0(%rsp), %rax
cmpq $0x0, 0x5118(%rax)
je 0xf06c
movq 0xd0(%rsp), %rax
cmpq $0x0, 0x5108(%rax)
je 0xf06c
movq 0xd0(%rsp), %rax
cmpq $0x0, 0x5110(%rax)
jne 0xf078
leaq 0x6e85(%rip), %rdi      # 0x15ef8
callq 0x3ce0
movq 0xd0(%rsp), %rax
testb $0x1, 0x68(%rax)
je 0xf095
movq 0xd0(%rsp), %rdi
callq 0xf860
jmp 0xf0a2
movq 0xd0(%rsp), %rdi
callq 0xfaf0
movq 0xd0(%rsp), %rax
testb $0x1, 0x70(%rax)
je 0xf1d6
movl $0x0, 0xc8(%rsp)
movl 0xc8(%rsp), %eax
movq 0xd0(%rsp), %rcx
movl 0x38(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0xf165
movq 0xd0(%rsp), %rax
movq 0x50e8(%rax), %rdi
movq 0xd0(%rsp), %rax
movq 0x5108(%rax), %rax
movslq 0xc8(%rsp), %rcx
addq (%rax,%rcx,8), %rdi
movq 0xd0(%rsp), %rax
movq 0x5108(%rax), %rax
movl 0xc8(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
movq 0xd0(%rsp), %rax
movq 0x5108(%rax), %rax
movslq 0xc8(%rsp), %rcx
subq (%rax,%rcx,8), %rsi
shlq $0x0, %rsi
movl $0x2, %edx
callq 0x22d0
movl 0xc8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc8(%rsp)
jmp 0xf0bf
movq 0xd0(%rsp), %rax
movq 0x50e8(%rax), %rdi
movq 0xd0(%rsp), %rax
movq 0x5108(%rax), %rax
movq 0xd0(%rsp), %rcx
movl 0x38(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
addq (%rax,%rcx,8), %rdi
movq 0xd0(%rsp), %rax
movq 0x28(%rax), %rsi
movq 0xd0(%rsp), %rax
movq 0x5108(%rax), %rax
movq 0xd0(%rsp), %rcx
movl 0x38(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
subq (%rax,%rcx,8), %rsi
shlq $0x0, %rsi
movl $0x2, %edx
callq 0x22d0
movq 0xd0(%rsp), %rdi
callq 0x84d0
movq %rax, 0xc0(%rsp)
movq 0xd0(%rsp), %rdi
callq 0x8640
movq %rax, 0xb8(%rsp)
movq $0x1, 0xb0(%rsp)
movl $0x6, 0xac(%rsp)
movl $0x0, 0xa8(%rsp)
movq 0xb0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xb0(%rsp)
cmpq $0xff, 0xb0(%rsp)
jbe 0xf274
movq 0xd0(%rsp), %rax
testb $0x1, 0x3d(%rax)
je 0xf274
movq 0x9d9f(%rip), %rax      # 0x18ff8
movq (%rax), %rdi
leaq 0x6cb3(%rip), %rsi      # 0x15f16
movb $0x0, %al
callq 0x21b0
movl $0x1, %edi
callq 0x2370
movq 0xd0(%rsp), %rax
testb $0x1, 0x3e(%rax)
je 0xf2b8
movq 0xb0(%rsp), %rax
subq $0x2, %rax
cmpq $0xff, %rax
jbe 0xf2b8
movq 0x9d5b(%rip), %rax      # 0x18ff8
movq (%rax), %rdi
leaq 0x6c8f(%rip), %rsi      # 0x15f36
movb $0x0, %al
callq 0x21b0
movl $0x1, %edi
callq 0x2370
movb $0x0, 0xa6(%rsp)
movq 0xd0(%rsp), %rax
movq 0x80(%rax), %rdi
callq 0x7750
movq %rax, %rcx
movq 0xb8(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0xb8(%rsp), %rdi
movq 0xc0(%rsp), %rsi
movq 0xb0(%rsp), %rdx
movl 0xa8(%rsp), %r8d
movq 0xd0(%rsp), %r9
leaq 0xa6(%rsp), %rcx
callq 0xfc40
andb $0x1, %al
movb %al, 0xa7(%rsp)
movq 0xd0(%rsp), %rax
cmpl $0x1, 0x94(%rax)
jle 0xf4fa
testb $0x1, 0xcf(%rsp)
je 0xf4fa
movq 0xb0(%rsp), %rax
decq %rax
movq %rax, 0x88(%rsp)
callq 0x12730
movq %rax, %xmm0
movaps 0x4ca8(%rip), %xmm3     # 0x14010
movaps %xmm3, 0x60(%rsp)
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0x4ca7(%rip), %xmm2     # 0x14020
movaps %xmm2, 0x70(%rsp)
subpd %xmm2, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq 0xd0(%rsp), %rax
movq 0x28(%rax), %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x90(%rsp)
callq 0x12720
movaps 0x60(%rsp), %xmm3
movaps 0x70(%rsp), %xmm2
movq %rax, %xmm0
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
subpd %xmm2, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq 0xd0(%rsp), %rax
movq 0x28(%rax), %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x98(%rsp)
movq 0xb8(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x2180
movq 0x88(%rsp), %rsi
movsd 0x90(%rsp), %xmm0
movsd 0x98(%rsp), %xmm1
movq %rax, %rdx
leaq 0x6b17(%rip), %rdi      # 0x15f5a
movb $0x2, %al
callq 0x20f0
movq 0xd0(%rsp), %rax
cmpq $0x0, 0x58(%rax)
je 0xf4f8
movq 0xd0(%rsp), %rax
movq 0x58(%rax), %rdi
callq 0x2180
movslq 0xac(%rsp), %rcx
xorl %edx, %edx
divq %rcx
movq %rax, 0x58(%rsp)
movq 0xd0(%rsp), %rax
movq 0x58(%rax), %rdi
callq 0x2180
movq 0x58(%rsp), %rsi
cvtsi2sd %rax, %xmm0
movsd 0x643d(%rip), %xmm1     # 0x158e0
mulsd %xmm1, %xmm0
movslq 0xac(%rsp), %rax
movq 0xd0(%rsp), %rcx
movq 0x28(%rcx), %rcx
imulq %rcx, %rax
movq %rax, %xmm1
movaps 0x4b45(%rip), %xmm2     # 0x14010
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x4b49(%rip), %xmm2     # 0x14020
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
leaq 0x6564(%rip), %rdi      # 0x15a55
movb $0x1, %al
callq 0x20f0
jmp 0xf4fa
movl $0x1, %eax
subl 0xa8(%rsp), %eax
movl %eax, 0xa8(%rsp)
movq 0xd0(%rsp), %rax
testb $0x1, 0x3c(%rax)
je 0xf555
testb $0x1, 0xa6(%rsp)
jne 0xf555
movq 0xd0(%rsp), %rax
cmpl $0x1, 0x94(%rax)
jle 0xf542
leaq 0x653f(%rip), %rdi      # 0x15a7c
callq 0x2080
movq 0xb8(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x20d0
jmp 0xf5ac
movq 0xb8(%rsp), %rax
cmpq $0x0, (%rax)
je 0xf573
movq 0xb8(%rsp), %rax
movq (%rax), %rdi
callq 0x20d0
movq 0xb8(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x2110
movq 0xb8(%rsp), %rax
movq 0x8(%rax), %rcx
movq 0xb8(%rsp), %rax
movq %rcx, (%rax)
movb 0xa7(%rsp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0xf222
movq 0xb8(%rsp), %rax
cmpq $0x0, (%rax)
je 0xf5ca
movq 0xb8(%rsp), %rax
movq (%rax), %rdi
callq 0x20d0
movq 0xd0(%rsp), %rax
cmpl $0x0, 0x94(%rax)
jle 0xf72c
testb $0x1, 0xcf(%rsp)
je 0xf6df
movq 0xd0(%rsp), %rax
movl 0x20(%rax), %eax
movl %eax, 0x3c(%rsp)
callq 0x12730
movq %rax, 0x40(%rsp)
callq 0x12720
movq %rax, 0x48(%rsp)
callq 0x12730
movq %rax, %xmm0
movaps 0x49ef(%rip), %xmm3     # 0x14010
movaps %xmm3, 0x10(%rsp)
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0x49ee(%rip), %xmm2     # 0x14020
movaps %xmm2, 0x20(%rsp)
subpd %xmm2, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq 0xd0(%rsp), %rax
movq 0x28(%rax), %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x50(%rsp)
callq 0x12720
movaps 0x10(%rsp), %xmm4
movaps 0x20(%rsp), %xmm3
movl 0x3c(%rsp), %esi
movq 0x40(%rsp), %rdx
movq 0x48(%rsp), %rcx
movsd 0x50(%rsp), %xmm0
movq %rax, %xmm1
punpckldq %xmm4, %xmm1    # xmm1 = xmm1[0],xmm4[0],xmm1[1],xmm4[1]
subpd %xmm3, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
movq 0xd0(%rsp), %rax
movq 0x28(%rax), %xmm2
punpckldq %xmm4, %xmm2    # xmm2 = xmm2[0],xmm4[0],xmm2[1],xmm4[1]
subpd %xmm3, %xmm2
movaps %xmm2, %xmm3
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
addsd %xmm3, %xmm2
divsd %xmm2, %xmm1
leaq 0x68ca(%rip), %rdi      # 0x15fa0
movb $0x2, %al
callq 0x20f0
jmp 0xf72a
movq 0xd0(%rsp), %rax
cmpl $0x1, 0x94(%rax)
jle 0xf728
movq 0xd0(%rsp), %rax
movl 0x20(%rax), %eax
movl %eax, 0x4(%rsp)
callq 0x12730
movq %rax, 0x8(%rsp)
callq 0x12720
movl 0x4(%rsp), %esi
movq 0x8(%rsp), %rdx
movq %rax, %rcx
leaq 0x68d0(%rip), %rdi      # 0x15ff1
movb $0x0, %al
callq 0x20f0
jmp 0xf72a
jmp 0xf72c
movq 0xc0(%rsp), %rdi
callq 0x8620
movq 0xb8(%rsp), %rdi
callq 0x86d0
movq 0xd0(%rsp), %rax
testb $0x1, 0x69(%rax)
je 0xf761
movq 0xd0(%rsp), %rdi
callq 0x6f10
movq 0xd0(%rsp), %rdi
movb 0xcf(%rsp), %al
andb $0x1, %al
movzbl %al, %esi
callq 0x4390
movq 0xd0(%rsp), %rax
testb $0x1, 0x3e(%rax)
je 0xf7b6
movq 0xd0(%rsp), %rdi
callq 0x4180
movq 0xd0(%rsp), %rax
cmpl $0x0, 0x94(%rax)
jle 0xf7b4
leaq 0x687b(%rip), %rdi      # 0x16028
movb $0x0, %al
callq 0x20f0
jmp 0xf7b6
movq 0xd0(%rsp), %rax
testb $0x1, 0x3d(%rax)
jne 0xf7f6
movq 0xd0(%rsp), %rax
movq 0x98(%rax), %rdi
movq 0xd0(%rsp), %rax
movq 0x28(%rax), %rsi
movq 0xd0(%rsp), %rax
movb 0x71(%rax), %al
andb $0x1, %al
movzbl %al, %edx
callq 0x9090
jmp 0xf803
movq 0xd0(%rsp), %rdi
callq 0x6a60
movq 0xd0(%rsp), %rax
movq 0x5110(%rax), %rdi
callq 0x12940
movq 0xd0(%rsp), %rax
movq 0x5108(%rax), %rdi
callq 0x12940
movq 0xd0(%rsp), %rax
movq 0x5118(%rax), %rdi
callq 0x12940
movq 0xd0(%rsp), %rdi
callq 0x66e0
addq $0xd8, %rsp
retq
nopw %cs:(%rax,%rax)