// File: /workspace/github_c_makefile_star2_O1/felipelouza[P]egap/mergehm.c
// Function: holtMcMillan
void holtMcMillan(g_data *g, bool lastRound) {
  // init local global vars
  check_g_data(g);
  assert(g->numBwt <= MAX_NUMBER_OF_BWTS); 
  int stop = 0; 
  
  // clear array B if necessary
  if(g->bwtOnly) assert(g->blockBeginsAt==NULL);
  else alloc0_B_array(g); // alloc and clear blockBeginsAt array

  // allocate Z (merge) Znew 
  alloc_merge_arrays(g);
  // allocate firstColumn and inCnt
  g->inCnt = malloc(g->numBwt*sizeof(customInt)); 
  g->firstColumn = malloc(g->sizeOfAlpha*sizeof(customInt));
  if(!g->firstColumn || !g->inCnt) die(__func__);
  // init the above arrays
  if(g->smallAlpha) init_arrays(g);
  else init_arrays_largealpha(g);

  customInt prefixLength = 1;  
  do { // main loop. Add something to do nothing if there is a single BWT as in Gap? 
    prefixLength+= 1;
    if(prefixLength>MAX_LCP_SIZE && !g->bwtOnly) {fprintf(stderr,"LCP too large\n");die(__func__);}
    stop += addCharToPrefix_HM(prefixLength, g);
    if(g->verbose>2 || (g->verbose>1 && lastRound)) { 
      printf("Lcp: "CUSTOM_FORMAT" Stop=%d   ",prefixLength-1,stop);
      #if MALLOC_COUNT_FLAG
        printf("Mem: %zu peak, %zu current, %.2lf/%.2lf bytes/symb\n", malloc_count_peak(),
             malloc_count_current(), (double)malloc_count_peak()/g->mergeLen,
             (double)malloc_count_current()/g->mergeLen);
      #endif
    }
  } while(stop<2);
  
  // 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);

  free(g->firstColumn); // last four arrays deallocated
  free(g->inCnt);
  free_merge_arrays(g);
  if(!g->bwtOnly) free_B_array(g);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %esi, %r12d
movq %rdi, %rbx
callq 0x39cf
cmpb $0x0, 0x3c(%rbx)
jne 0xbe97
movq %rbx, %rdi
callq 0x5535
movq %rbx, %rdi
callq 0x5200
movslq 0x20(%rbx), %rdi
shlq $0x3, %rdi
callq 0xc63a
movq %rax, %r14
movq %rax, 0x5118(%rbx)
movslq 0x38(%rbx), %rdi
shlq $0x3, %rdi
callq 0xc63a
movq %rax, 0x5108(%rbx)
testq %r14, %r14
je 0xbed4
testq %rax, %rax
jne 0xbee0
leaq 0x4426(%rip), %rdi      # 0x10301
callq 0x3973
cmpb $0x1, 0x68(%rbx)
jne 0xbef3
movq %rbx, %rdi
callq 0xc155
jmp 0xbfb1
movslq 0x20(%rbx), %rdi
shlq $0x3, %rdi
callq 0xc63a
movq %rax, 0x18(%rbx)
testq %rax, %rax
jne 0xbf15
leaq 0x4370(%rip), %rdi      # 0x10280
callq 0x3973
cmpl $0x0, 0x20(%rbx)
jle 0xbf76
xorl %r15d, %r15d
leaq 0x435b(%rip), %r14      # 0x10280
movslq 0x38(%rbx), %rdi
movl $0x8, %esi
callq 0xc78c
movq 0x18(%rbx), %rcx
movq %rax, (%rcx,%r15,8)
movq 0x18(%rbx), %rax
cmpq $0x0, (%rax,%r15,8)
jne 0xbf4e
movq %r14, %rdi
callq 0x3973
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
movq (%rax,%r15,8), %rdi
movq (%rcx,%r15,8), %rsi
movq 0x18(%rbx), %rax
movq (%rax,%r15,8), %rdx
callq 0xc41b
incq %r15
movslq 0x20(%rbx), %rax
cmpq %rax, %r15
jl 0xbf25
movq %rbx, %rdi
callq 0xc155
cmpl $0x0, 0x20(%rbx)
jle 0xbfa0
xorl %r14d, %r14d
movq 0x18(%rbx), %rax
movq (%rax,%r14,8), %rdi
callq 0xc6e6
incq %r14
movslq 0x20(%rbx), %rax
cmpq %rax, %r14
jl 0xbf87
movq 0x18(%rbx), %rdi
callq 0xc6e6
movq $0x0, 0x18(%rbx)
movl $0x1, %ebp
movl %r12d, 0xc(%rsp)
movl %r12d, %r15d
xorb $0x1, %r15b
xorl %r12d, %r12d
leaq 0x1(%rbp), %r13
cmpq $0x100, %r13            # imm = 0x100
jb 0xbfdc
cmpb $0x0, 0x3c(%rbx)
je 0xc0f3
movq %r13, %rdi
movq %rbx, %rsi
callq 0xc1ff
addl %eax, %r12d
movl 0x94(%rbx), %eax
cmpl $0x3, %eax
setl %cl
cmpl $0x2, %eax
setne %al
orb %r15b, %al
testb %al, %cl
jne 0xc0e4
leaq 0x4300(%rip), %rdi      # 0x1030e
movq %rbp, %rsi
movl %r12d, %edx
xorl %eax, %eax
callq 0x2100
callq 0xc614
movq %rax, %rbp
callq 0xc60c
movq %rax, %r14
callq 0xc614
movq %rax, %xmm0
movq 0x1fd3(%rip), %xmm3     # 0xe010
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0x1fd7(%rip), %xmm4     # 0xe020
subpd %xmm4, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movapd %xmm1, %xmm2
movq 0x28(%rbx), %xmm0
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
subpd %xmm4, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
divsd %xmm1, %xmm2
movapd %xmm2, 0x10(%rsp)
callq 0xc60c
movq %rax, %xmm0
movq 0x1f7e(%rip), %xmm2     # 0xe010
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
movapd 0x1f82(%rip), %xmm3     # 0xe020
subpd %xmm3, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movq 0x28(%rbx), %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
subpd %xmm3, %xmm0
movapd %xmm0, %xmm2
unpckhpd %xmm0, %xmm2            # xmm2 = xmm2[1],xmm0[1]
addsd %xmm0, %xmm2
divsd %xmm2, %xmm1
leaq 0x4250(%rip), %rdi      # 0x10322
movq %rbp, %rsi
movq %r14, %rdx
movaps 0x10(%rsp), %xmm0
movb $0x2, %al
callq 0x2100
movq %r13, %rbp
cmpl $0x2, %r12d
jb 0xbfc5
jmp 0xc0fd
callq 0x2623
jmp 0xbfdc
movzbl 0xc(%rsp), %esi
movq %rbx, %rdi
callq 0x3c93
movq 0x5108(%rbx), %rdi
callq 0xc6e6
movq 0x5118(%rbx), %rdi
callq 0xc6e6
movq %rbx, %rdi
callq 0x539f
cmpb $0x0, 0x3c(%rbx)
je 0xc13f
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5594