// File: /workspace/github_c_makefile_star2_O3/richarddurbin[P]hash10x/moshmap.c
// Function: referenceRead
Reference *referenceRead (char *root)
{
  FILE *f ;
  if (!(f = fopenTag (root, "mosh", "r"))) die ("failed to open %s.mosh to read", root) ;
  Moshset *ms = moshsetRead (f) ;
  fclose (f) ;
  if (!(f = fopenTag (root, "ref", "r"))) die ("failed to open %s.ref to read", root) ;
  char name[8] ;
  if (fread (name,8,1,f) != 1) die ("failed to read reference header") ;
  if (strcmp (name, "RFMSHv1")) die ("bad reference header") ;
  U32 size ; if (fread (&size,sizeof(U32),1,f) != 1) die ("failed to read size") ;
  Reference *ref = referenceCreate (ms, size) ;
  if (fread (&ref->max,sizeof(U32),1,f) != 1) die ("failed to read max") ;
  if (fread (ref->index,sizeof(U32),size,f) != size) die ("failed read ref index") ;
  if (fread (ref->offset,sizeof(U32),size,f) != size) die ("failed read ref offset") ;
  if (fread (ref->id,sizeof(U32),size,f) != size) die ("failed read ref id") ;
  if (fread (ref->depth,sizeof(U32),ref->ms->max+1,f) != ref->ms->max+1) die ("fail depth") ;
  ref->rev = new (size, U32) ; ref->loc = new (ref->ms->max+1, U32) ;
  if (fread (ref->rev,sizeof(U32),size,f) != size) die ("fail rev") ;
  if (fread (ref->loc,sizeof(U32),ref->ms->max+1,f) != ref->ms->max+1) die ("fail loc") ;
  arrayDestroy (ref->len) ; if (!(ref->len = arrayRead (f))) die ("failed read ref len") ;
  dictDestroy (ref->dict) ; if (!(ref->dict = dictRead (f))) die ("failed read ref dict") ;
  fclose (f) ;
  return ref ;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %r15
leaq 0x4b58(%rip), %rsi      # 0x7102
leaq 0x4ce6(%rip), %rdx      # 0x7297
callq 0x6637
movq %rax, %rbx
testq %rax, %rax
jne 0x25cf
leaq 0x4c62(%rip), %rdi      # 0x7227
movq %r15, %rsi
xorl %eax, %eax
callq 0x63e4
movq %rbx, %rdi
callq 0x4cb4
movq %rax, %r14
movq %rbx, %rdi
callq 0x1090
leaq 0x4b3e(%rip), %rsi      # 0x7127
leaq 0x4ca7(%rip), %rdx      # 0x7297
movq %r15, %rdi
callq 0x6637
movq %rax, %rbx
testq %rax, %rax
jne 0x2611
leaq 0x4c3f(%rip), %rdi      # 0x7246
movq %r15, %rsi
xorl %eax, %eax
callq 0x63e4
leaq 0x8(%rsp), %rdi
movl $0x8, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x1080
cmpq $0x1, %rax
je 0x263c
leaq 0x4c2f(%rip), %rdi      # 0x7264
xorl %eax, %eax
callq 0x63e4
movabsq $0x317648534d4652, %rax # imm = 0x317648534D4652
cmpq %rax, 0x8(%rsp)
je 0x265b
leaq 0x4c30(%rip), %rdi      # 0x7284
xorl %eax, %eax
callq 0x63e4
leaq 0x4(%rsp), %rdi
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x1080
cmpq $0x1, %rax
je 0x2686
leaq 0x4c1a(%rip), %rdi      # 0x7299
xorl %eax, %eax
callq 0x63e4
movl 0x4(%rsp), %r15d
movq %r14, %rdi
movl %r15d, %esi
callq 0x1dec
movq %rax, %r14
leaq 0xc(%rax), %rdi
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x1080
cmpq $0x1, %rax
je 0x26c3
leaq 0x4bf1(%rip), %rdi      # 0x72ad
xorl %eax, %eax
callq 0x63e4
movq 0x10(%r14), %rdi
movl $0x4, %esi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x1080
cmpq %r15, %rax
je 0x26ea
leaq 0x4bdd(%rip), %rdi      # 0x72c0
xorl %eax, %eax
callq 0x63e4
movq 0x18(%r14), %rdi
movl $0x4, %esi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x1080
cmpq %r15, %rax
je 0x2711
leaq 0x4bcc(%rip), %rdi      # 0x72d6
xorl %eax, %eax
callq 0x63e4
movq 0x20(%r14), %rdi
movl $0x4, %esi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x1080
cmpq %r15, %rax
je 0x2738
leaq 0x4bbc(%rip), %rdi      # 0x72ed
xorl %eax, %eax
callq 0x63e4
movq (%r14), %rax
movq 0x28(%r14), %rdi
movl 0x40(%rax), %edx
incl %edx
movl $0x4, %esi
movq %rbx, %rcx
callq 0x1080
movq (%r14), %rcx
movl 0x40(%rcx), %ecx
incl %ecx
cmpq %rcx, %rax
je 0x276c
leaq 0x4a7a(%rip), %rdi      # 0x71df
xorl %eax, %eax
callq 0x63e4
leaq (,%r15,4), %rdi
callq 0x64ac
movq %rax, 0x30(%r14)
movq (%r14), %rax
movl 0x40(%rax), %edi
incl %edi
shlq $0x2, %rdi
callq 0x64ac
movq %rax, 0x38(%r14)
movq 0x30(%r14), %rdi
movl $0x4, %esi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x1080
cmpq %r15, %rax
je 0x27b9
leaq 0x4a38(%rip), %rdi      # 0x71ea
xorl %eax, %eax
callq 0x63e4
movq (%r14), %rax
movq 0x38(%r14), %rdi
movl 0x40(%rax), %edx
incl %edx
movl $0x4, %esi
movq %rbx, %rcx
callq 0x1080
movq (%r14), %rcx
movl 0x40(%rcx), %ecx
incl %ecx
cmpq %rcx, %rax
je 0x27ed
leaq 0x4a0d(%rip), %rdi      # 0x71f3
xorl %eax, %eax
callq 0x63e4
movq 0x48(%r14), %rdi
callq 0x5dc2
movq %rbx, %rdi
callq 0x604f
movq %rax, 0x48(%r14)
testq %rax, %rax
jne 0x2815
leaq 0x4af2(%rip), %rdi      # 0x7300
xorl %eax, %eax
callq 0x63e4
movq 0x40(%r14), %rdi
callq 0x56d5
movq %rbx, %rdi
callq 0x5832
movq %rax, 0x40(%r14)
testq %rax, %rax
jne 0x283d
leaq 0x4ade(%rip), %rdi      # 0x7314
xorl %eax, %eax
callq 0x63e4
movq %rbx, %rdi
callq 0x1090
movq %r14, %rax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq