// File: /workspace/github_c_makefile_star2_O1/richarddurbin[P]hash10x/hash10x.c
// Function: processBlock
void processBlock (U32 *readData, ClusterBlock *b)
{
  Array a = arrayCreate (4096, HashTemp) ;
  int i, j, n ;
  char s1[160], s2[160] ;

  for (i = 0 ; i < b->nRead ; ++i, readData += 30)
    { unpackFQB (readData, s1, 0, s2, 0) ;
      seqAddHashes (&s1[23], 127, a, i) ; /* ignore 16bp of barcode and 7bp of spacer */
      seqAddHashes (s2, 150, a, i) ;
    }
  
  arraySort (a, compareHashTemp) ; /* sort then remove duplicate hash values */
  U64 hash, lastHash = arrp(a,0,HashTemp)->hash ;
  for (n = 1, j = 1 ; j < arrayMax(a) ; ++j)
    { hash = arrp(a,j,HashTemp)->hash ;
      if (hash != lastHash)
	arr(a,n++,HashTemp) = arr(a,j,HashTemp) ; lastHash = hash ;
    }

  b->nHash = n ;
  b->clusHash = new (n, ClusterHash) ;
  for (i = 0 ; i < n ; ++i)
    { int index = hashIndexFind (arrp(a,i,HashTemp)->hash, TRUE) ;
      ++array(hashDepth, index, U32) ;
      b->clusHash[i].hash = index ;
      b->clusHash[i].read = arrp(a,i,HashTemp)->read ;
    }

  qsort (b->clusHash, n, sizeof(ClusterHash), compareClusterHash) ; /* sort so hashes are in order */
  
  arrayDestroy (a) ;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movq %rsi, %r13
movq %rdi, %r15
movl $0x1000, %edi           # imm = 0x1000
movl $0x10, %esi
callq 0x8c70
movq %rax, %rbx
cmpl $0x0, (%r13)
je 0x1ea4
xorl %r12d, %r12d
movq %rsp, %rbp
leaq 0xa0(%rsp), %r14
movq %r15, %rdi
movq %rbp, %rsi
xorl %edx, %edx
movq %r14, %rcx
xorl %r8d, %r8d
callq 0x1ca4
leaq 0x17(%rsp), %rdi
movl $0x7f, %esi
movq %rbx, %rdx
movl %r12d, %ecx
callq 0x1d5b
movq %r14, %rdi
movl $0x96, %esi
movq %rbx, %rdx
movl %r12d, %ecx
callq 0x1d5b
incl %r12d
addq $0x78, %r15
cmpl (%r13), %r12d
jb 0x1e5c
movq 0x8(%rbx), %rdi
movslq 0x18(%rbx), %rsi
movslq 0x14(%rbx), %rdx
leaq -0xad(%rip), %rcx       # 0x1e0a
callq 0x1090
movl $0x1, %eax
cmpl $0x2, 0x18(%rbx)
movq %r13, %rbp
jl 0x1f10
movq 0x8(%rbx), %rax
movq (%rax), %rdx
movl $0x1, %eax
movl $0x1, %ecx
movq %rdx, %r9
movq 0x8(%rbx), %rsi
movl 0x14(%rbx), %edi
movl %edi, %edx
imull %ecx, %edx
movslq %edx, %r8
movq (%rsi,%r8), %rdx
cmpq %r9, %rdx
je 0x1f09
addq %rsi, %r8
imull %eax, %edi
incl %eax
movslq %edi, %rdi
movups (%r8), %xmm0
movups %xmm0, (%rsi,%rdi)
incl %ecx
cmpl 0x18(%rbx), %ecx
jl 0x1edb
movl %eax, 0x4(%rbp)
movslq %eax, %r15
leaq (,%r15,8), %rdi
callq 0x94d0
movq %rax, 0x10(%rbp)
testl %r15d, %r15d
jle 0x2034
leaq 0x96de(%rip), %r12      # 0xb615
xorl %r14d, %r14d
movq 0x8(%rbx), %rax
movslq 0x14(%rbx), %rcx
movslq %r14d, %rdx
imulq %rcx, %rdx
movq (%rax,%rdx), %rax
movq 0xe4f4(%rip), %rsi      # 0x10448
movq %rsi, %rdx
andq %rax, %rdx
movb 0xd1f0(%rip), %cl       # 0xf150
movq %rax, %rdi
shrq %cl, %rdi
movq 0xe42b(%rip), %rcx      # 0x10398
movl (%rcx,%rdx,4), %r13d
testq %r13, %r13
sete %r8b
je 0x1fac
movq 0xe42f(%rip), %r9       # 0x103b0
cmpq %rax, (%r9,%r13,8)
jne 0x1f8c
xorl %r8d, %r8d
jmp 0x1fac
andq %rsi, %rdi
orq $0x1, %rdi
addq %rdi, %rdx
andq %rsi, %rdx
movl (%rcx,%rdx,4), %r13d
testq %r13, %r13
sete %r8b
je 0x1fac
cmpq %rax, (%r9,%r13,8)
jne 0x1f93
testb %r8b, %r8b
je 0x1ff5
movl 0xe3f0(%rip), %r13d     # 0x103a8
leal 0x1(%r13), %esi
movl %esi, 0xe3e6(%rip)      # 0x103a8
movl %r13d, (%rcx,%rdx,4)
movq 0xe3e3(%rip), %rcx      # 0x103b0
movq %rax, (%rcx,%r13,8)
movl 0xe3d1(%rip), %eax      # 0x103a8
movq 0xe3c2(%rip), %rcx      # 0x103a0
shrq $0x2, %rcx
addq $-0x2, %rcx
cmpq %rax, %rcx
jae 0x1ff5
movq %r12, %rdi
xorl %eax, %eax
callq 0x9408
movq 0xe384(%rip), %rdi      # 0x10380
movl %r13d, %esi
callq 0x8f2b
incl (%rax)
movq 0x10(%rbp), %rax
movl %r13d, (%rax,%r14,8)
movq 0x8(%rbx), %rcx
movslq 0x14(%rbx), %rdx
movslq %r14d, %rsi
imulq %rdx, %rsi
movzwl 0x8(%rcx,%rsi), %ecx
movw %cx, 0x4(%rax,%r14,8)
incq %r14
cmpq %r15, %r14
jne 0x1f3a
movq 0x10(%rbp), %rdi
leaq -0x3c3(%rip), %rcx      # 0x1c7c
movl $0x8, %edx
movq %r15, %rsi
callq 0x1090
movq %rbx, %rdi
callq 0x8dc9
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq