// File: /workspace/github_c_makefile_star2_O2/richarddurbin[P]hash10x/hash10x.c
// Function: hashNeighbours
Array hashNeighbours (int x)
{ /* return array of hashes that share between min and max codes with x */
  /* abuse ClusterHash structure for this array, storing the number of shared codes in ->read */
  if (!hashWithinRange) die ("hashNeighbours() called without setting hashDepthRange") ;
  Array ch = arrayCreate (1000, ClusterHash) ;
  int i,j ;
  U32 xCount = arr(hashDepth,x,U32) ; if (!xCount) return 0 ;
  for (i = 0 ; i < xCount ; ++i)
    { ClusterBlock *b = arrp(clusterBlocks, arr(hashCodes,x,U32*)[i], ClusterBlock) ;
      ClusterHash *c = b->clusHash ;
      for (j = 0 ; j < b->nHash ; ++j, ++c)
	if (c->hash != x && hashWithinRange[c->hash])
	  array(ch, arrayMax(ch), ClusterHash) = *c ;
    }
  arraySort (ch, compareClusterHash) ;
  Array shared = arrayCreate (256, ClusterHash) ; /* abuse structure esp. read field */
  ClusterHash *last = arrayp (shared, 0, ClusterHash) ;
  last->hash = arrp(ch, 0, ClusterHash)->hash ; last->read = 1 ;
  for (i = 1 ; i < arrayMax(ch) ; ++i)
    if (arrp(ch, i, ClusterHash)->hash == last->hash) ++last->read ;
    else
      { last = arrayp (shared, arrayMax(shared), ClusterHash) ;
	last->hash = arrp(ch, i, ClusterHash)->hash ; last->read = 1 ;
      }
  arrayDestroy (ch) ;
  return shared ;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edi, %ebp
cmpq $0x0, 0xd7f0(%rip)      # 0x10410
jne 0x2c30
leaq 0x69d9(%rip), %rdi      # 0x9602
xorl %eax, %eax
callq 0x8a3c
pushq $0x8
popq %rsi
movl $0x3e8, %edi            # imm = 0x3E8
callq 0x82c8
movq %rax, %rbx
movq 0xd749(%rip), %rax      # 0x10390
movq 0x8(%rax), %rcx
movslq 0x14(%rax), %rax
movslq %ebp, %rdx
movq %rdx, (%rsp)
imulq %rdx, %rax
movl (%rcx,%rax), %eax
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x2d79
xorl %esi, %esi
cmpq 0x8(%rsp), %rsi
je 0x2cea
movq 0xd71d(%rip), %rax      # 0x10398
movq 0x8(%rax), %r13
movq 0xd742(%rip), %rcx      # 0x103c8
movq 0x8(%rcx), %rdx
movslq 0x14(%rcx), %rcx
imulq (%rsp), %rcx
movq (%rdx,%rcx), %rcx
movl 0x14(%rax), %r14d
movq %rsi, 0x10(%rsp)
imull (%rcx,%rsi,4), %r14d
movq 0x10(%r13,%r14), %r15
xorl %r12d, %r12d
cmpl 0x4(%r13,%r14), %r12d
jae 0x2ce0
movl (%r15,%r12,8), %eax
cmpl %ebp, %eax
je 0x2cdb
movq 0xd74d(%rip), %rcx      # 0x10410
cmpb $0x0, (%rcx,%rax)
je 0x2cdb
movl 0x18(%rbx), %esi
movq %rbx, %rdi
callq 0x8560
movq (%r15,%r12,8), %rcx
movq %rcx, (%rax)
incq %r12
jmp 0x2cad
movq 0x10(%rsp), %rsi
incq %rsi
jmp 0x2c6d
movq 0x8(%rbx), %rdi
movslq 0x18(%rbx), %rsi
movslq 0x14(%rbx), %rdx
leaq -0x1971(%rip), %rcx     # 0x138c
callq 0x1090
pushq $0x8
popq %rsi
movl $0x100, %edi            # imm = 0x100
callq 0x82c8
movq %rax, %r14
movq %rax, %rdi
xorl %esi, %esi
callq 0x8560
movq 0x8(%rbx), %rcx
movl (%rcx), %edx
movl %edx, (%rax)
movw $0x1, 0x4(%rax)
pushq $0x1
popq %rbp
cmpl 0x18(%rbx), %ebp
jge 0x2d6f
movslq 0x14(%rbx), %rsi
movslq %ebp, %r15
imulq %r15, %rsi
cmpl %edx, (%rcx,%rsi)
jne 0x2d48
incw 0x4(%rax)
jmp 0x2d6b
movl 0x18(%r14), %esi
movq %r14, %rdi
callq 0x8560
movq 0x8(%rbx), %rcx
movslq 0x14(%rbx), %rdx
imulq %r15, %rdx
movl (%rcx,%rdx), %edx
movl %edx, (%rax)
movw $0x1, 0x4(%rax)
incl %ebp
jmp 0x2d2d
movq %rbx, %rdi
callq 0x8408
jmp 0x2d7c
xorl %r14d, %r14d
movq %r14, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq