// File: /workspace/github_c_makefile_star2_O0/richarddurbin[P]hash10x/hash10x.c
// Function: clusterSplitCodes
void clusterSplitCodes (void)
{
  int i, j, nSubClusters = 0 ;
  int nCodes = arrayMax (clusterBlocks) ; 
  for (i = 0 ; i < nCodes ; ++i) nSubClusters += arrp(clusterBlocks, i, ClusterBlock)->nSubCluster ;
  Array newBlocks = arrayCreate (nCodes+nSubClusters, ClusterBlock) ;
  arrayMax(newBlocks) = nCodes + nSubClusters ;
  ClusterBlock *old = arrp(clusterBlocks, 0, ClusterBlock) ;
  ClusterBlock *new1 = arrp(newBlocks, 0, ClusterBlock) ;
  ClusterBlock *new2 = arrp(newBlocks, nCodes-1, ClusterBlock) ; //-1 allows for ->subCluster offset
  Array clusterHashCount = arrayCreate (256, int) ; /* how many hashes in each cluster */
  Array readMap = arrayCreate (4096, int) ;
  for (i = 0 ; i < nCodes ; ++i, ++old)
    if (old->nSubCluster)
      { arrayReCreate (clusterHashCount, old->nSubCluster+1, int) ; /* zeroes array */
	ClusterHash *c = old->clusHash ;
	for (j = 0 ; j < old->nHash ; ++j, ++c) ++arr(clusterHashCount,c->subCluster,int) ;
	new1->clusHash = new0(arr(clusterHashCount,0,int), ClusterHash) ;
	for (j = 1 ; j < old->nSubCluster+1 ; ++j)
	  { new2[j].clusHash = new0(arr(clusterHashCount,j,int), ClusterHash) ;
	    new2[j].clusterParent = i+1 ;
	  }
	arrayReCreate (clusterHashCount, old->nSubCluster+1, int) ;
	arrayReCreate (readMap, old->nRead+1, int) ;
	for (j = 0, c = old->clusHash ; j < old->nHash ; ++j, ++c)
	  { int clus = c->subCluster ; c->subCluster = 0 ;
	    if (clus)
	      { if (!array(readMap,c->read,int)) arr(readMap,c->read,int) = ++new2[clus].nRead ;
	    // previous line requires that all hashes from same read are in same cluster
		c->read = arr(readMap,c->read,int) - 1 ;
		new2[clus].clusHash[new2[clus].nHash++] = *c ;
	      }
	    else new1->clusHash[new1->nHash++] = *c ;
	  }
	new1->nRead = old->nRead ; /* not strictly true any more, but safe */
	++new1 ;
	new2 += old->nSubCluster ;
	free (old->clusHash) ;
      }
    else
      *new1++ = *old ; // also carries over existing clusHash
  
  fprintf (outFile, "  made %d additional new barcodes from clusters in %d original barcodes\n",
	   nSubClusters, arrayMax(clusterBlocks)) ;
  if (outFile != stdout)
    printf ("  made %d additional new barcodes from clusters in %d original barcodes\n",
	    nSubClusters, arrayMax(clusterBlocks)) ;
  arrayDestroy (clusterBlocks) ;
  clusterBlocks = newBlocks ;
  arrayDestroy (clusterHashCount) ; arrayDestroy (readMap) ;
  printf ("  cluster timepoint: ") ; timeUpdate (stdout) ;

  // now must rebuild the mapping from hashes to codes
  for (i = 1 ; i < hashNumber ; ++i)
    if (arr(hashDepth,i,U32)) free (arr(hashCodes,i,U32*)) ;
  arrayDestroy (hashCodes) ;
  fillHashTable () ;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl $0x0, -0xc(%rbp)
movq 0xeaa2(%rip), %rax      # 0x143c8
movl 0x18(%rax), %eax
movl %eax, -0x10(%rbp)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x596c
movq 0xea86(%rip), %rax      # 0x143c8
movq 0x8(%rax), %rax
movl -0x4(%rbp), %ecx
movq 0xea78(%rip), %rdx      # 0x143c8
imull 0x14(%rdx), %ecx
movslq %ecx, %rcx
movl 0x8(%rax,%rcx), %eax
addl -0xc(%rbp), %eax
movl %eax, -0xc(%rbp)
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x5933
movl -0x10(%rbp), %edi
addl -0xc(%rbp), %edi
movl $0x20, %esi
callq 0xc1e0
movq %rax, -0x18(%rbp)
movl -0x10(%rbp), %ecx
addl -0xc(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x18(%rax)
movq 0xea34(%rip), %rax      # 0x143c8
movq 0x8(%rax), %rax
movq 0xea29(%rip), %rcx      # 0x143c8
imull $0x0, 0x14(%rcx), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rcx
imull $0x0, 0x14(%rcx), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x10(%rbp), %ecx
subl $0x1, %ecx
movq -0x18(%rbp), %rdx
imull 0x14(%rdx), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movl $0x100, %edi            # imm = 0x100
movl $0x4, %esi
callq 0xc1e0
movq %rax, -0x38(%rbp)
movl $0x1000, %edi           # imm = 0x1000
movl $0x4, %esi
callq 0xc1e0
movq %rax, -0x40(%rbp)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x5d2e
movq -0x20(%rbp), %rax
cmpl $0x0, 0x8(%rax)
je 0x5ce1
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rax
movl 0x8(%rax), %esi
addl $0x1, %esi
movl $0x4, %edx
callq 0xc2b0
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x48(%rbp)
movl $0x0, -0x8(%rbp)
movl -0x8(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jae 0x5aa0
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x48(%rbp), %rcx
movzbl 0x6(%rcx), %ecx
movq -0x38(%rbp), %rdx
imull 0x14(%rdx), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx)
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
movq -0x48(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x48(%rbp)
jmp 0x5a59
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x38(%rbp), %rcx
imull $0x0, 0x14(%rcx), %ecx
movslq %ecx, %rcx
movslq (%rax,%rcx), %rdi
movl $0x8, %esi
callq 0xd1f0
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x10(%rax)
movl $0x1, -0x8(%rbp)
movl -0x8(%rbp), %eax
movq -0x20(%rbp), %rcx
movl 0x8(%rcx), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jae 0x5b41
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x8(%rbp), %ecx
movq -0x38(%rbp), %rdx
imull 0x14(%rdx), %ecx
movslq %ecx, %rcx
movslq (%rax,%rcx), %rdi
movl $0x8, %esi
callq 0xd1f0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movslq -0x8(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movq %rcx, 0x10(%rax)
movl -0x4(%rbp), %ecx
addl $0x1, %ecx
movq -0x30(%rbp), %rax
movslq -0x8(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movl %ecx, 0xc(%rax)
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x5ad3
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rax
movl 0x8(%rax), %esi
addl $0x1, %esi
movl $0x4, %edx
callq 0xc2b0
movq -0x40(%rbp), %rdi
movq -0x20(%rbp), %rax
movl (%rax), %esi
addl $0x1, %esi
movl $0x4, %edx
callq 0xc2b0
movl $0x0, -0x8(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x48(%rbp)
movl -0x8(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jae 0x5ca2
movq -0x48(%rbp), %rax
movzbl 0x6(%rax), %eax
movl %eax, -0x4c(%rbp)
movq -0x48(%rbp), %rax
movb $0x0, 0x6(%rax)
cmpl $0x0, -0x4c(%rbp)
je 0x5c62
movq -0x40(%rbp), %rdi
movq -0x48(%rbp), %rax
movzwl 0x4(%rax), %esi
callq 0xc640
cmpl $0x0, (%rax)
jne 0x5bfa
movq -0x30(%rbp), %rax
movslq -0x4c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl (%rax), %edx
addl $0x1, %edx
movl %edx, (%rax)
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x48(%rbp), %rcx
movzwl 0x4(%rcx), %ecx
movq -0x40(%rbp), %rsi
imull 0x14(%rsi), %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx)
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x48(%rbp), %rcx
movzwl 0x4(%rcx), %ecx
movq -0x40(%rbp), %rdx
imull 0x14(%rdx), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx), %eax
subl $0x1, %eax
movw %ax, %cx
movq -0x48(%rbp), %rax
movw %cx, 0x4(%rax)
movq -0x30(%rbp), %rax
movslq -0x4c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movq -0x30(%rbp), %rdx
movslq -0x4c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rdx
movl 0x4(%rdx), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, 0x4(%rdx)
movl %ecx, %ecx
movq -0x48(%rbp), %rdx
movq (%rdx), %rdx
movq %rdx, (%rax,%rcx,8)
jmp 0x5c86
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x28(%rbp), %rdx
movl 0x4(%rdx), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, 0x4(%rdx)
movl %ecx, %ecx
movq -0x48(%rbp), %rdx
movq (%rdx), %rdx
movq %rdx, (%rax,%rcx,8)
jmp 0x5c88
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
movq -0x48(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x48(%rbp)
jmp 0x5b83
movq -0x20(%rbp), %rax
movl (%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movq -0x28(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x1040
jmp 0x5d12
movq -0x28(%rbp), %rax
movq %rax, %rcx
addq $0x20, %rcx
movq %rcx, -0x28(%rbp)
movq -0x20(%rbp), %rcx
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0x10(%rcx), %rdx
movq %rdx, 0x10(%rax)
movq 0x18(%rcx), %rcx
movq %rcx, 0x18(%rax)
jmp 0x5d14
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
movq -0x20(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x20(%rbp)
jmp 0x5a14
movq 0xe69b(%rip), %rdi      # 0x143d0
movl -0xc(%rbp), %edx
movq 0xe689(%rip), %rax      # 0x143c8
movl 0x18(%rax), %ecx
leaq 0x8cc9(%rip), %rsi      # 0xea12
movb $0x0, %al
callq 0x1150
movq 0xe679(%rip), %rax      # 0x143d0
movq 0xd272(%rip), %rcx      # 0x12fd0
cmpq (%rcx), %rax
je 0x5d7e
movl -0xc(%rbp), %esi
movq 0xe65b(%rip), %rax      # 0x143c8
movl 0x18(%rax), %edx
leaq 0x8c9b(%rip), %rdi      # 0xea12
movb $0x0, %al
callq 0x10d0
movq 0xe643(%rip), %rdi      # 0x143c8
callq 0xc3e0
movq -0x18(%rbp), %rax
movq %rax, 0xe633(%rip)      # 0x143c8
movq -0x38(%rbp), %rdi
callq 0xc3e0
movq -0x40(%rbp), %rdi
callq 0xc3e0
leaq 0x8cad(%rip), %rdi      # 0xea5b
movb $0x0, %al
callq 0x10d0
movq 0xd214(%rip), %rax      # 0x12fd0
movq (%rax), %rdi
callq 0xd4d0
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
cmpl 0xe614(%rip), %eax      # 0x143e8
jae 0x5e2a
movq 0xe5e3(%rip), %rax      # 0x143c0
movq 0x8(%rax), %rax
movl -0x4(%rbp), %ecx
movq 0xe5d5(%rip), %rdx      # 0x143c0
imull 0x14(%rdx), %ecx
movslq %ecx, %rcx
cmpl $0x0, (%rax,%rcx)
je 0x5e1d
movq 0xe5f9(%rip), %rax      # 0x143f8
movq 0x8(%rax), %rax
movl -0x4(%rbp), %ecx
movq 0xe5eb(%rip), %rdx      # 0x143f8
imull 0x14(%rdx), %ecx
movslq %ecx, %rcx
movq (%rax,%rcx), %rdi
callq 0x1040
jmp 0x5e1f
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x5dcb
movq 0xe5c7(%rip), %rdi      # 0x143f8
callq 0xc3e0
callq 0x24f0
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)