// File: /workspace/github_c_makefile_star2_O0/richarddurbin[P]hash10x/hash10x.c
// Function: codeClusterFind
void codeClusterFind (int code, int clusterThreshold) /* clusters this barcode's good hashes */
{
  ClusterBlock *b = arrp(clusterBlocks, code, ClusterBlock), *c ;
  ClusterHash *cb = b->clusHash, *cc ;
  int i, j ;
  U32 x, nc ;
  int *minShare = new0 (arrayMax(clusterBlocks), int) ; /* lowest hash shared with code */
  U16 *g, *gi, *gc, *gcn ;
  Array clusterMin = arrayCreate (64, int) ;

  int n = nGoodHashes[code] ; if (!n) return ;
  int *minShareCount = new (n, int) ;

  for (i = 0 ; i < n ; ++i) b->clusHash[goodHashes[code][i]].subCluster = 0 ; /* wipe existing */

  b->nSubCluster = 0 ;
  //  if (!b->cluster) b->cluster = arrayCreate (32, ClusterInfo) ;
  b->pointToMin = 0.0 ;
  int nSubClustered = 0 ;
  for (i = 1 ; i < n ; ++i)	// shouldn't this be from i = 0 ?
    { x = b->clusHash[goodHashes[code][i]].hash ;
      nc = arr(hashDepth, x, U32) ;
      memset (minShareCount, 0, n*sizeof(int)) ;
					       
      for (j = 0 ; j < nc ; ++j)
	{ int cj = arr(hashCodes, x, U32*)[j] ;
	  if (cj == code) continue ;
	  if (!minShare[cj]) minShare[cj] = i+1 ;
	  ++minShareCount[minShare[cj]-1] ;
	}

      int msMax = 0, msTot = 0, msBest ;
      g = goodHashes[code] ;
      for (j = 0 ; j < i ; ++j)
	{ if (minShareCount[j] > msMax)  { msBest = j ; msMax = minShareCount[j] ; }
	  msTot += minShareCount[j] ;
	}
      if (msMax >= clusterThreshold)
	{ ClusterHash *ch = &b->clusHash[g[msBest]] ;
	  if (!ch->subCluster)	/* create a new cluster */
	    { if (++b->nSubCluster > U8MAX) /* abandon this clustering */
		{ b->nSubCluster = 0 ; nSubClustered = 0 ;
		  for (j = 0 ; j < i ; ++j) b->clusHash[g[j]].subCluster = 0 ;
		  fprintf (stderr, "    code %d with %d good hashes has too many clusters\n",
			   code, nGoodHashes[code]) ;
		  break ;
		}
	      ch->subCluster = b->nSubCluster ; ++nSubClustered ;
	      array(clusterMin,b->nSubCluster,int) = msBest ;
	    }
	  b->clusHash[g[i]].subCluster = ch->subCluster ; ++nSubClustered ;
	  b->pointToMin += minShareCount[arr(clusterMin,ch->subCluster,int)] / (double)msTot ;
	}
    }
  free (minShare) ;
  free (minShareCount) ;
  arrayDestroy (clusterMin) ;
  if (isVerbose)
    { if (b->nSubCluster)
	fprintf (outFile, "  code %d with %d reads %d hashes, %d good hashes, of which %d cluster into %d raw",
		 code, b->nRead, b->nHash, nGoodHashes[code], nSubClustered, b->nSubCluster) ;
      else
	fprintf (outFile, "  code %d with %d reads %d hashes, %d good hashes, 0 clusters\n",
		 code, b->nRead, b->nHash, nGoodHashes[code]) ;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movq 0xf850(%rip), %rax      # 0x143c8
movq 0x8(%rax), %rax
movl -0x4(%rbp), %ecx
movq 0xf842(%rip), %rdx      # 0x143c8
imull 0x14(%rdx), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
movq 0xf821(%rip), %rax      # 0x143c8
movslq 0x18(%rax), %rdi
movl $0x4, %esi
callq 0xd1f0
movq %rax, -0x40(%rbp)
movl $0x40, %edi
movl $0x4, %esi
callq 0xc1e0
movq %rax, -0x68(%rbp)
movq 0xf88d(%rip), %rax      # 0x14460
movslq -0x4(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x6c(%rbp)
cmpl $0x0, -0x6c(%rbp)
jne 0x4be8
jmp 0x5012
movslq -0x6c(%rbp), %rdi
shlq $0x2, %rdi
callq 0xd1a0
movq %rax, -0x78(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x6c(%rbp), %eax
jge 0x4c37
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq 0xf841(%rip), %rcx      # 0x14458
movslq -0x4(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x2c(%rbp), %rdx
movzwl (%rcx,%rdx,2), %ecx
movb $0x0, 0x6(%rax,%rcx,8)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x4c00
movq -0x10(%rbp), %rax
movl $0x0, 0x8(%rax)
movq -0x10(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x18(%rax)
movl $0x0, -0x7c(%rbp)
movl $0x1, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x6c(%rbp), %eax
jge 0x4f5f
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq 0xf7e1(%rip), %rcx      # 0x14458
movslq -0x4(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x2c(%rbp), %rdx
movzwl (%rcx,%rdx,2), %ecx
movl (%rax,%rcx,8), %eax
movl %eax, -0x34(%rbp)
movq 0xf72c(%rip), %rax      # 0x143c0
movq 0x8(%rax), %rax
movl -0x34(%rbp), %ecx
movq 0xf71e(%rip), %rdx      # 0x143c0
imull 0x14(%rdx), %ecx
movl %ecx, %ecx
movl (%rax,%rcx), %eax
movl %eax, -0x38(%rbp)
movq -0x78(%rbp), %rdi
movslq -0x6c(%rbp), %rdx
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x10f0
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x38(%rbp), %eax
jae 0x4d4e
movq 0xf721(%rip), %rax      # 0x143f8
movq 0x8(%rax), %rax
movl -0x34(%rbp), %ecx
movq 0xf713(%rip), %rdx      # 0x143f8
imull 0x14(%rdx), %ecx
movl %ecx, %ecx
movq (%rax,%rcx), %rax
movslq -0x30(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x80(%rbp)
movl -0x80(%rbp), %eax
cmpl -0x4(%rbp), %eax
jne 0x4d03
jmp 0x4d40
movq -0x40(%rbp), %rax
movslq -0x80(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0x4d22
movl -0x2c(%rbp), %edx
addl $0x1, %edx
movq -0x40(%rbp), %rax
movslq -0x80(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x78(%rbp), %rax
movq -0x40(%rbp), %rcx
movslq -0x80(%rbp), %rdx
movl (%rcx,%rdx,4), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x4cc8
movl $0x0, -0x84(%rbp)
movl $0x0, -0x88(%rbp)
movq 0xf6ef(%rip), %rax      # 0x14458
movslq -0x4(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x48(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x4dd3
movq -0x78(%rbp), %rax
movslq -0x30(%rbp), %rcx
movl (%rax,%rcx,4), %eax
cmpl -0x84(%rbp), %eax
jle 0x4db1
movl -0x30(%rbp), %eax
movl %eax, -0x8c(%rbp)
movq -0x78(%rbp), %rax
movslq -0x30(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x84(%rbp)
movq -0x78(%rbp), %rax
movslq -0x30(%rbp), %rcx
movl (%rax,%rcx,4), %eax
addl -0x88(%rbp), %eax
movl %eax, -0x88(%rbp)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x4d7c
movl -0x84(%rbp), %eax
cmpl -0x8(%rbp), %eax
jl 0x4f4f
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x48(%rbp), %rcx
movslq -0x8c(%rbp), %rdx
movzwl (%rcx,%rdx,2), %ecx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
cmpb $0x0, 0x6(%rax)
jne 0x4edf
movq -0x10(%rbp), %rcx
movl 0x8(%rcx), %eax
addl $0x1, %eax
movl %eax, 0x8(%rcx)
cmpl $0xff, %eax
jbe 0x4e9f
movq -0x10(%rbp), %rax
movl $0x0, 0x8(%rax)
movl $0x0, -0x7c(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x4e71
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x48(%rbp), %rcx
movslq -0x30(%rbp), %rdx
movzwl (%rcx,%rdx,2), %ecx
movb $0x0, 0x6(%rax,%rcx,8)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x4e45
movq 0xe180(%rip), %rax      # 0x12ff8
movq (%rax), %rdi
movl -0x4(%rbp), %edx
movq 0xf5db(%rip), %rax      # 0x14460
movslq -0x4(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
leaq 0x99b2(%rip), %rsi      # 0xe845
movb $0x0, %al
callq 0x1150
jmp 0x4f5f
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movb %al, %cl
movq -0x98(%rbp), %rax
movb %cl, 0x6(%rax)
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
movl -0x8c(%rbp), %eax
movl %eax, -0x9c(%rbp)
movq -0x68(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x8(%rax), %esi
callq 0xc640
movl -0x9c(%rbp), %ecx
movl %ecx, (%rax)
movq -0x98(%rbp), %rax
movb 0x6(%rax), %dl
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x48(%rbp), %rcx
movslq -0x2c(%rbp), %rsi
movzwl (%rcx,%rsi,2), %ecx
movb %dl, 0x6(%rax,%rcx,8)
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
movq -0x78(%rbp), %rax
movq -0x68(%rbp), %rcx
movq 0x8(%rcx), %rcx
movq -0x98(%rbp), %rdx
movzbl 0x6(%rdx), %edx
movq -0x68(%rbp), %rsi
imull 0x14(%rsi), %edx
movslq %edx, %rdx
movslq (%rcx,%rdx), %rcx
cvtsi2sdl (%rax,%rcx,4), %xmm0
cvtsi2sdl -0x88(%rbp), %xmm1
divsd %xmm1, %xmm0
movq -0x10(%rbp), %rax
addsd 0x18(%rax), %xmm0
movsd %xmm0, 0x18(%rax)
jmp 0x4f51
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x4c5c
movq -0x40(%rbp), %rdi
callq 0x1040
movq -0x78(%rbp), %rdi
callq 0x1040
movq -0x68(%rbp), %rdi
callq 0xc3e0
cmpb $0x0, 0xf430(%rip)      # 0x143b1
je 0x5012
movq -0x10(%rbp), %rax
cmpl $0x0, 0x8(%rax)
je 0x4fdb
movq 0xf438(%rip), %rdi      # 0x143d0
movl -0x4(%rbp), %edx
movq -0x10(%rbp), %rax
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movl 0x4(%rax), %r8d
movq 0xf4b0(%rip), %rax      # 0x14460
movslq -0x4(%rbp), %rsi
movl (%rax,%rsi,4), %r9d
movl -0x7c(%rbp), %r10d
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
leaq 0x98b2(%rip), %rsi      # 0xe87c
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
movb $0x0, %al
callq 0x1150
jmp 0x5010
movq 0xf3ee(%rip), %rdi      # 0x143d0
movl -0x4(%rbp), %edx
movq -0x10(%rbp), %rax
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movl 0x4(%rax), %r8d
movq 0xf466(%rip), %rax      # 0x14460
movslq -0x4(%rbp), %rsi
movl (%rax,%rsi,4), %r9d
leaq 0x98c6(%rip), %rsi      # 0xe8cf
movb $0x0, %al
callq 0x1150
jmp 0x5012
addq $0xb0, %rsp
popq %rbp
retq
nopl (%rax,%rax)