// File: /workspace/github_c_makefile_star2_O1/richarddurbin[P]hash10x/hash10x.c
// Function: codeClusterReadMerge
void codeClusterReadMerge (int code)
{
  ClusterBlock *b = arrp(clusterBlocks, code, ClusterBlock) ;
  if (!b->nSubCluster) return ;	/* nothing to do */
  int i, j ;
  int *readMap = new0 (b->nRead, int), *trueCluster = new (b->nSubCluster+1, int) ;
  int *deadCluster = new0 (b->nSubCluster+1, int) ;
  for (i = 0 ; i <= b->nSubCluster ; ++i) trueCluster[i] = i ; /* initialisation */
  for (i = 0 ; i < b->nHash ; ++i)
    { int hashCluster = trueCluster[b->clusHash[i].subCluster] ; if (!hashCluster) continue ;
      int readCluster = trueCluster[readMap[b->clusHash[i].read]] ;
      if (hashCluster == readCluster) continue ;
      else if (!readCluster)
	readMap[b->clusHash[i].read] = hashCluster ;
      else			/* merge clusters hashCluster and readCluster */
	{ if (hashCluster > readCluster)
	    { int t = hashCluster ; hashCluster = readCluster ; readCluster = t ; }
	  for (j = 1 ; j <= b->nSubCluster ; ++j)
	    if (trueCluster[j] == readCluster) trueCluster[j] = hashCluster ;
	  deadCluster[readCluster] = 1 ;
	}
    }

  /* now compactify trueCluster, reusing deadCluster[] for the map removing dead indices */
  for (j = 1 ; j <= b->nSubCluster ; ++j) deadCluster[j] = deadCluster[j-1] + 1 - deadCluster[j] ;
  for (j = 1 ; j <= b->nSubCluster ; ++j) trueCluster[j] = deadCluster[trueCluster[j]] ;
  b->nSubCluster = deadCluster[b->nSubCluster] ;
  for (i = 0 ; i < b->nHash ; ++i) b->clusHash[i].subCluster = trueCluster[b->clusHash[i].subCluster] ;

  free (readMap) ; free(trueCluster) ; free(deadCluster) ;
  if (isVerbose) { fprintf (outFile, " then %d merged clusters\n", b->nSubCluster) ; fflush (stdout) ; }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq 0xbb04(%rip), %rax      # 0x10388
movq 0x8(%rax), %r12
movslq 0x14(%rax), %rax
movslq %edi, %r13
imulq %rax, %r13
cmpl $0x0, 0x8(%r12,%r13)
je 0x4a3a
movl (%r12,%r13), %edi
movl $0x4, %esi
callq 0x94f8
movq %rax, %rbx
movl 0x8(%r12,%r13), %edi
incl %edi
shlq $0x2, %rdi
callq 0x94d0
movq %rax, %r14
movl 0x8(%r12,%r13), %edi
incl %edi
movl $0x4, %esi
callq 0x94f8
movq %rax, %r15
xorl %eax, %eax
movl %eax, (%r14,%rax,4)
leaq 0x1(%rax), %rcx
movl 0x8(%r12,%r13), %edx
cmpq %rdx, %rax
movq %rcx, %rax
jb 0x48d9
cmpl $0x0, 0x4(%r12,%r13)
je 0x4969
movq 0x10(%r12,%r13), %rax
xorl %ecx, %ecx
movzbl 0x6(%rax,%rcx,8), %edx
movl (%r14,%rdx,4), %edi
testl %edi, %edi
je 0x495c
movzwl 0x4(%rax,%rcx,8), %esi
movslq (%rbx,%rsi,4), %rdx
movl (%r14,%rdx,4), %edx
cmpl %edx, %edi
je 0x495c
testl %edx, %edx
je 0x4959
cmpl %edx, %edi
movl %edx, %esi
cmovll %edi, %esi
cmovgl %edi, %edx
cmpl $0x0, 0x8(%r12,%r13)
je 0x494c
xorl %edi, %edi
cmpl %edx, 0x4(%r14,%rdi,4)
jne 0x493f
movl %esi, 0x4(%r14,%rdi,4)
movl 0x8(%r12,%r13), %r8d
incq %rdi
cmpq %r8, %rdi
jb 0x4933
movslq %edx, %rdx
movl $0x1, (%r15,%rdx,4)
jmp 0x495c
movl %edi, (%rbx,%rsi,4)
incq %rcx
movl 0x4(%r12,%r13), %edx
cmpq %rdx, %rcx
jb 0x48fd
cmpl $0x0, 0x8(%r12,%r13)
je 0x498f
movl (%r15), %eax
xorl %ecx, %ecx
subl 0x4(%r15,%rcx,4), %eax
incl %eax
movl %eax, 0x4(%r15,%rcx,4)
movl 0x8(%r12,%r13), %edx
incq %rcx
cmpq %rdx, %rcx
jb 0x4976
movl 0x8(%r12,%r13), %eax
testl %eax, %eax
je 0x49b5
xorl %ecx, %ecx
movslq 0x4(%r14,%rcx,4), %rax
movl (%r15,%rax,4), %eax
movl %eax, 0x4(%r14,%rcx,4)
movl 0x8(%r12,%r13), %eax
incq %rcx
cmpq %rax, %rcx
jb 0x499a
movl %eax, %eax
movl (%r15,%rax,4), %eax
movl %eax, 0x8(%r12,%r13)
movl 0x4(%r12,%r13), %eax
testq %rax, %rax
je 0x49e7
movq 0x10(%r12,%r13), %rcx
xorl %edx, %edx
movzbl 0x6(%rcx,%rdx,8), %esi
movb (%r14,%rsi,4), %sil
movb %sil, 0x6(%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x49d1
movq %rbx, %rdi
callq 0x1040
movq %r14, %rdi
callq 0x1040
movq %r15, %rdi
callq 0x1040
cmpb $0x0, 0xb96b(%rip)      # 0x10371
je 0x4a3a
movq 0xb981(%rip), %rdi      # 0x10390
movl 0x8(%r12,%r13), %edx
leaq 0x5f03(%rip), %rsi      # 0xa91e
xorl %eax, %eax
callq 0x1150
movq 0xa59f(%rip), %rax      # 0xefc8
movq (%rax), %rdi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x11a0
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq