// File: /workspace/github_c_makefile_star2_O2/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, %ebp
movq %rdi, %rbx
callq 0x3610
cmpb $0x0, 0x3c(%rbx)
jne 0xb57e
movq %rbx, %rdi
callq 0x5110
movq %rbx, %rdi
callq 0x4df5
movslq 0x20(%rbx), %rdi
shlq $0x3, %rdi
callq 0xbce0
movq %rax, %r14
movq %rax, 0x5118(%rbx)
movslq 0x38(%rbx), %rdi
shlq $0x3, %rdi
callq 0xbce0
movq %rax, 0x5108(%rbx)
testq %r14, %r14
je 0xb5bb
testq %rax, %rax
jne 0xb5c7
leaq 0x3cf7(%rip), %rdi      # 0xf2b9
callq 0x35b7
cmpb $0x1, 0x68(%rbx)
jne 0xb5da
movq %rbx, %rdi
callq 0xb852
jmp 0xb68d
movslq 0x20(%rbx), %rdi
shlq $0x3, %rdi
callq 0xbce0
movq %rax, 0x18(%rbx)
testq %rax, %rax
jne 0xb5fc
leaq 0x3c41(%rip), %rdi      # 0xf238
callq 0x35b7
xorl %r12d, %r12d
pushq $0x8
popq %r14
leaq 0x3c2e(%rip), %r15      # 0xf238
movslq 0x20(%rbx), %rax
cmpq %rax, %r12
jge 0xb65d
movslq 0x38(%rbx), %rdi
movq %r14, %rsi
callq 0xbe60
movq 0x18(%rbx), %rcx
movq %rax, (%rcx,%r12,8)
movq 0x18(%rbx), %rax
movq (%rax,%r12,8), %rdx
testq %rdx, %rdx
jne 0xb644
movq %r15, %rdi
callq 0x35b7
movq 0x18(%rbx), %rax
movq (%rax,%r12,8), %rdx
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
movq (%rax,%r12,8), %rdi
movq (%rcx,%r12,8), %rsi
callq 0xbad1
incq %r12
jmp 0xb60a
movq %rbx, %rdi
callq 0xb852
xorl %r14d, %r14d
movslq 0x20(%rbx), %rax
movq 0x18(%rbx), %rdi
cmpq %rax, %r14
jge 0xb683
movq (%rdi,%r14,8), %rdi
callq 0xbdb4
incq %r14
jmp 0xb668
callq 0xbdb4
andq $0x0, 0x18(%rbx)
pushq $0x1
popq %r15
movl %ebp, 0xc(%rsp)
movl %ebp, %r12d
xorb $0x1, %r12b
xorl %r13d, %r13d
leaq 0x1(%r15), %r14
cmpq $0x100, %r14            # imm = 0x100
jb 0xb6b6
cmpb $0x0, 0x3c(%rbx)
je 0xb7cd
movq %r14, %rdi
movq %rbx, %rsi
callq 0xb8d6
addl %eax, %r13d
movl 0x94(%rbx), %eax
cmpl $0x3, %eax
setl %cl
cmpl $0x2, %eax
setne %al
orb %r12b, %al
testb %al, %cl
jne 0xb7be
leaq 0x3bde(%rip), %rdi      # 0xf2c6
movq %r15, %rsi
movl %r13d, %edx
xorl %eax, %eax
callq 0x2100
callq 0xbc94
movq %rax, %rbp
callq 0xbc8c
movq %rax, %r15
callq 0xbc94
movq %rax, %xmm0
movq 0x18f9(%rip), %xmm3     # 0xd010
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0x18fd(%rip), %xmm4     # 0xd020
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 0xbc8c
movq %rax, %xmm0
movq 0x18a4(%rip), %xmm2     # 0xd010
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
movapd 0x18a8(%rip), %xmm3     # 0xd020
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 0x3b2e(%rip), %rdi      # 0xf2da
movq %rbp, %rsi
movq %r15, %rdx
movaps 0x10(%rsp), %xmm0
movb $0x2, %al
callq 0x2100
movq %r14, %r15
cmpl $0x2, %r13d
jb 0xb69f
jmp 0xb7fa
movq 0x7824(%rip), %rax      # 0x12ff8
movq (%rax), %rcx
leaq 0x3336(%rip), %rdi      # 0xeb14
pushq $0xe
popq %rsi
pushq $0x1
popq %rdx
callq 0x2390
leaq 0x3ac9(%rip), %rdi      # 0xf2b9
callq 0x35b7
jmp 0xb6b6
movzbl 0xc(%rsp), %esi
movq %rbx, %rdi
callq 0x38c8
movq 0x5108(%rbx), %rdi
callq 0xbdb4
movq 0x5118(%rbx), %rdi
callq 0xbdb4
movq %rbx, %rdi
callq 0x4f88
cmpb $0x0, 0x3c(%rbx)
je 0xb83c
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 0x5167