// File: /workspace/github_c_makefile_star2_O0/richarddurbin[P]hash10x/hash10x.c
// Function: readHashFile
void readHashFile (FILE *f)
{
  int B ; U32 version ; U16 clusterHashSize, clusterBlockSize ;
  char name[5] = "abcd" ;
  if ((fread (name, 4, 1, f) != 1) || (fread (&version, 4, 1, f) != 1) ||
      (fread (&clusterHashSize, 2, 1, f) != 1) || (fread (&clusterBlockSize, 2, 1, f) != 1))
    die ("read fail 0") ;
  if (strcmp (name, "10XH")) die ("not a 10X hash file") ;
  if (version > HASHFILE_VERSION)
    die ("hash file version mismatch: file %d > code %d", version, HASHFILE_VERSION) ;
  if (clusterHashSize != CLUSTERHASH_SIZE)
    die ("ClusterHash structure size mismatch: file %d != code %d", clusterHashSize, CLUSTERHASH_SIZE) ;
  if (clusterBlockSize != CLUSTERBLOCK_SIZE)
    die ("ClusterBlock structure size mismatch: file %d != code %d", clusterBlockSize, CLUSTERBLOCK_SIZE) ;
  if (fread (&B, 4, 1, f) != 1) die ("read fail 1") ;
  if (B != hashTableBits) die ("incompatible hash table size: rerun with -B %d", B) ;
  if (fread (hashIndex, sizeof(U32), hashTableSize, f) != hashTableSize) die ("read fail 2") ;
  if (version == 1)
    { Array a ;
      if (!(a = arrayRead (f))) die ("failed to read hashValue array") ;
      hashNumber = arrayMax(a) ; hashValue = new(hashNumber, U64) ;
      memcpy (hashValue, arrp(a,0,U64), hashNumber*sizeof(U64)) ;
      arrayDestroy (a) ;
    }
  else if (version == 2)
    { if (fread (&hashNumber, sizeof(U32), 1, f) != 1) die ("failed to read hashNumber") ;
      if (fread (hashValue, sizeof(U64), hashNumber, f) != hashNumber) die ("failed to read hashValue") ;
    }

  if (!(hashDepth = arrayRead (f))) die ("failed to read hashDepth array") ;
  if (!(clusterBlocks = arrayRead (f))) die ("failed to read clusterBlocks array") ;
  int i ;
  U64 nReads = 0, nHashes = 0 ;
  for (i = 1 ; i < arrayMax(clusterBlocks) ; ++i)
    { ClusterBlock *b = arrayp(clusterBlocks, i, ClusterBlock) ;
      nReads += b->nRead ; nHashes += b->nHash ;
      b->clusHash = new(b->nHash, ClusterHash) ;
      if (fread (b->clusHash, sizeof(ClusterHash), b->nHash, f) != b->nHash) die ("read fail 3") ;
    }
  fclose (f) ;

  fprintf (outFile, "  read %ld hashes for %ld reads in %d barcode blocks\n",
	  (long)nHashes, (long)nReads, arrayMax(clusterBlocks)) ;
  if (outFile != stdout)
    printf ("  read %ld hashes for %ld reads in %d barcode blocks\n",
	    (long)nHashes, (long)nReads, arrayMax(clusterBlocks)) ;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movl 0xc155(%rip), %eax      # 0xe237
movl %eax, -0x19(%rbp)
movb 0xc150(%rip), %al       # 0xe23b
movb %al, -0x15(%rbp)
leaq -0x19(%rbp), %rdi
movq -0x8(%rbp), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x10a0
cmpq $0x1, %rax
jne 0x2162
movq -0x8(%rbp), %rcx
leaq -0x10(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x10a0
cmpq $0x1, %rax
jne 0x2162
movq -0x8(%rbp), %rcx
leaq -0x12(%rbp), %rdi
movl $0x2, %esi
movl $0x1, %edx
callq 0x10a0
cmpq $0x1, %rax
jne 0x2162
movq -0x8(%rbp), %rcx
leaq -0x14(%rbp), %rdi
movl $0x2, %esi
movl $0x1, %edx
callq 0x10a0
cmpq $0x1, %rax
je 0x2170
leaq 0xc0d3(%rip), %rdi      # 0xe23c
movb $0x0, %al
callq 0xd0c0
leaq -0x19(%rbp), %rdi
leaq 0xbfe0(%rip), %rsi      # 0xe15b
callq 0x1130
cmpl $0x0, %eax
je 0x2193
leaq 0xc0bc(%rip), %rdi      # 0xe248
movb $0x0, %al
callq 0xd0c0
movl -0x10(%rbp), %eax
cmpl 0x10fbc(%rip), %eax     # 0x13158
jbe 0x21b5
movl -0x10(%rbp), %esi
movl 0x10fb1(%rip), %edx     # 0x13158
leaq 0xc0ae(%rip), %rdi      # 0xe25c
movb $0x0, %al
callq 0xd0c0
movzwl -0x12(%rbp), %eax
movzwl 0x10f9c(%rip), %ecx     # 0x1315c
cmpl %ecx, %eax
je 0x21dd
movzwl -0x12(%rbp), %esi
movzwl 0x10f8d(%rip), %edx     # 0x1315c
leaq 0xc0b4(%rip), %rdi      # 0xe28a
movb $0x0, %al
callq 0xd0c0
movzwl -0x14(%rbp), %eax
movzwl 0x10f76(%rip), %ecx     # 0x1315e
cmpl %ecx, %eax
je 0x2205
movzwl -0x14(%rbp), %esi
movzwl 0x10f67(%rip), %edx     # 0x1315e
leaq 0xc0c4(%rip), %rdi      # 0xe2c2
movb $0x0, %al
callq 0xd0c0
movq -0x8(%rbp), %rcx
leaq -0xc(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x10a0
cmpq $0x1, %rax
je 0x2230
leaq 0xc0d2(%rip), %rdi      # 0xe2fb
movb $0x0, %al
callq 0xd0c0
movl -0xc(%rbp), %eax
cmpl 0x10f17(%rip), %eax     # 0x13150
je 0x224c
movl -0xc(%rbp), %esi
leaq 0xc0c2(%rip), %rdi      # 0xe307
movb $0x0, %al
callq 0xd0c0
movq 0x12185(%rip), %rdi     # 0x143d8
movq 0x12186(%rip), %rdx     # 0x143e0
movq -0x8(%rbp), %rcx
movl $0x4, %esi
callq 0x10a0
cmpq 0x12171(%rip), %rax     # 0x143e0
je 0x227f
leaq 0xc0be(%rip), %rdi      # 0xe336
movb $0x0, %al
callq 0xd0c0
cmpl $0x1, -0x10(%rbp)
jne 0x2303
movq -0x8(%rbp), %rdi
callq 0xc820
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0x22a6
leaq 0xc0a3(%rip), %rdi      # 0xe342
movb $0x0, %al
callq 0xd0c0
movq -0x28(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, 0x12135(%rip)     # 0x143e8
movl 0x1212f(%rip), %eax     # 0x143e8
movl %eax, %edi
shlq $0x3, %rdi
callq 0xd1a0
movq %rax, 0x12125(%rip)     # 0x143f0
movq 0x1211e(%rip), %rdi     # 0x143f0
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x28(%rbp), %rax
imull $0x0, 0x14(%rax), %eax
cltq
addq %rax, %rsi
movl 0x120fb(%rip), %eax     # 0x143e8
movl %eax, %edx
shlq $0x3, %rdx
callq 0x1170
movq -0x28(%rbp), %rdi
callq 0xc3e0
jmp 0x2371
cmpl $0x2, -0x10(%rbp)
jne 0x236f
movq -0x8(%rbp), %rcx
leaq 0x120d4(%rip), %rdi     # 0x143e8
movl $0x4, %esi
movl $0x1, %edx
callq 0x10a0
cmpq $0x1, %rax
je 0x2337
leaq 0xc031(%rip), %rdi      # 0xe361
movb $0x0, %al
callq 0xd0c0
movq 0x120b2(%rip), %rdi     # 0x143f0
movl 0x120a4(%rip), %eax     # 0x143e8
movl %eax, %edx
movq -0x8(%rbp), %rcx
movl $0x8, %esi
callq 0x10a0
movl 0x1208e(%rip), %ecx     # 0x143e8
cmpq %rcx, %rax
je 0x236d
leaq 0xc015(%rip), %rdi      # 0xe37b
movb $0x0, %al
callq 0xd0c0
jmp 0x236f
jmp 0x2371
movq -0x8(%rbp), %rdi
callq 0xc820
movq %rax, 0x1203f(%rip)     # 0x143c0
cmpq $0x0, %rax
jne 0x2395
leaq 0xc006(%rip), %rdi      # 0xe394
movb $0x0, %al
callq 0xd0c0
movq -0x8(%rbp), %rdi
callq 0xc820
movq %rax, 0x12023(%rip)     # 0x143c8
cmpq $0x0, %rax
jne 0x23b9
leaq 0xc001(%rip), %rdi      # 0xe3b3
movb $0x0, %al
callq 0xd0c0
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movl $0x1, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq 0x11fee(%rip), %rcx     # 0x143c8
cmpl 0x18(%rcx), %eax
jge 0x2479
movq 0x11fde(%rip), %rdi     # 0x143c8
movl -0x2c(%rbp), %esi
callq 0xc640
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movl (%rax), %eax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x48(%rbp), %rax
movl 0x4(%rax), %eax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x48(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, %edi
shlq $0x3, %rdi
callq 0xd1a0
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x48(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, %edx
movq -0x8(%rbp), %rcx
movl $0x8, %esi
callq 0x10a0
movq -0x48(%rbp), %rcx
movl 0x4(%rcx), %ecx
cmpq %rcx, %rax
je 0x2469
leaq 0xbf74(%rip), %rdi      # 0xe3d6
movb $0x0, %al
callq 0xd0c0
jmp 0x246b
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x23d0
movq -0x8(%rbp), %rdi
callq 0x10b0
movq 0x11f47(%rip), %rdi     # 0x143d0
movq -0x40(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq 0x11f30(%rip), %rax     # 0x143c8
movl 0x18(%rax), %r8d
leaq 0xbf3f(%rip), %rsi      # 0xe3e2
movb $0x0, %al
callq 0x1150
movq 0x11f1f(%rip), %rax     # 0x143d0
movq 0x10b18(%rip), %rcx     # 0x12fd0
cmpq (%rcx), %rax
je 0x24dd
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq 0x11efc(%rip), %rax     # 0x143c8
movl 0x18(%rax), %ecx
leaq 0xbf0c(%rip), %rdi      # 0xe3e2
movb $0x0, %al
callq 0x10d0
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)