// File: /workspace/github_c_makefile_star2_O3/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 0x3a58
cmpb $0x0, 0x3c(%rbx)
jne 0xbf47
movq %rbx, %rdi
callq 0x55db
movq %rbx, %rdi
callq 0x52a6
movslq 0x20(%rbx), %rdi
shlq $0x3, %rdi
callq 0xc70e
movq %rax, %r14
movq %rax, 0x5118(%rbx)
movslq 0x38(%rbx), %rdi
shlq $0x3, %rdi
callq 0xc70e
movq %rax, 0x5108(%rbx)
testq %r14, %r14
je 0xbf84
testq %rax, %rax
jne 0xbf90
leaq 0x4376(%rip), %rdi      # 0x10301
callq 0x39fc
cmpb $0x1, 0x68(%rbx)
jne 0xbfa3
movq %rbx, %rdi
callq 0xc20d
jmp 0xc069
movslq 0x20(%rbx), %r14
movq %r14, %rdi
shlq $0x3, %rdi
callq 0xc70e
movq %rax, 0x18(%rbx)
testq %rax, %rax
jne 0xbfcc
leaq 0x42bd(%rip), %rdi      # 0x10280
callq 0x39fc
movl 0x20(%rbx), %r14d
testl %r14d, %r14d
jle 0xc02e
xorl %r15d, %r15d
leaq 0x42a5(%rip), %r14      # 0x10280
movslq 0x38(%rbx), %rdi
movl $0x8, %esi
callq 0xc860
movq 0x18(%rbx), %rcx
movq %rax, (%rcx,%r15,8)
movq 0x18(%rbx), %rax
movq (%rax,%r15,8), %rdx
testq %rdx, %rdx
jne 0xc00e
movq %r14, %rdi
callq 0x39fc
movq 0x18(%rbx), %rax
movq (%rax,%r15,8), %rdx
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
movq (%rax,%r15,8), %rdi
movq (%rcx,%r15,8), %rsi
callq 0xc4d7
incq %r15
movslq 0x20(%rbx), %rax
cmpq %rax, %r15
jl 0xbfdb
movq %rbx, %rdi
callq 0xc20d
cmpl $0x0, 0x20(%rbx)
jle 0xc058
xorl %r14d, %r14d
movq 0x18(%rbx), %rax
movq (%rax,%r14,8), %rdi
callq 0xc7ba
incq %r14
movslq 0x20(%rbx), %rax
cmpq %rax, %r14
jl 0xc03f
movq 0x18(%rbx), %rdi
callq 0xc7ba
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 0xc094
cmpb $0x0, 0x3c(%rbx)
je 0xc1ab
movq %r13, %rdi
movq %rbx, %rsi
callq 0xc2be
addl %eax, %r12d
movl 0x94(%rbx), %eax
cmpl $0x3, %eax
setl %cl
cmpl $0x2, %eax
setne %al
orb %r15b, %al
testb %al, %cl
jne 0xc19c
leaq 0x4248(%rip), %rdi      # 0x1030e
movq %rbp, %rsi
movl %r12d, %edx
xorl %eax, %eax
callq 0x2100
callq 0xc6e8
movq %rax, %rbp
callq 0xc6e0
movq %rax, %r14
callq 0xc6e8
movq %rax, %xmm0
movq 0x1f1b(%rip), %xmm3     # 0xe010
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0x1f1f(%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 0xc6e0
movq %rax, %xmm0
movq 0x1ec6(%rip), %xmm2     # 0xe010
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
movapd 0x1eca(%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 0x4198(%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 0xc07d
jmp 0xc1b5
callq 0x2623
jmp 0xc094
movzbl 0xc(%rsp), %esi
movq %rbx, %rdi
callq 0x3d14
movq 0x5108(%rbx), %rdi
callq 0xc7ba
movq 0x5118(%rbx), %rdi
callq 0xc7ba
movq %rbx, %rdi
callq 0x5445
cmpb $0x0, 0x3c(%rbx)
je 0xc1f7
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 0x563a