// File: /workspace/github_c_makefile_star2_O1/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 0x4d27(%rip), %rsi      # 0x7102
leaq 0x542c(%rip), %rdx      # 0x780e
callq 0x63a3
movq %rax, %rbx
testq %rax, %rax
jne 0x2400
leaq 0x4e31(%rip), %rdi      # 0x7227
movq %r15, %rsi
xorl %eax, %eax
callq 0x614c
movq %rbx, %rdi
callq 0x49f8
movq %rax, %r14
movq %rbx, %rdi
callq 0x1090
leaq 0x4d0d(%rip), %rsi      # 0x7127
leaq 0x53ed(%rip), %rdx      # 0x780e
movq %r15, %rdi
callq 0x63a3
movq %rax, %rbx
testq %rax, %rax
jne 0x2442
leaq 0x4e0e(%rip), %rdi      # 0x7246
movq %r15, %rsi
xorl %eax, %eax
callq 0x614c
leaq 0x8(%rsp), %rdi
movl $0x8, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x1080
cmpq $0x1, %rax
je 0x246d
leaq 0x4dfe(%rip), %rdi      # 0x7264
xorl %eax, %eax
callq 0x614c
movabsq $0x317648534d4652, %rax # imm = 0x317648534D4652
cmpq %rax, 0x8(%rsp)
je 0x248c
leaq 0x4dff(%rip), %rdi      # 0x7284
xorl %eax, %eax
callq 0x614c
leaq 0x4(%rsp), %rdi
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x1080
cmpq $0x1, %rax
je 0x24b7
leaq 0x4de9(%rip), %rdi      # 0x7299
xorl %eax, %eax
callq 0x614c
movl 0x4(%rsp), %r15d
movq %r14, %rdi
movl %r15d, %esi
callq 0x1c1c
movq %rax, %r14
leaq 0xc(%rax), %rdi
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x1080
cmpq $0x1, %rax
je 0x24f4
leaq 0x4dc0(%rip), %rdi      # 0x72ad
xorl %eax, %eax
callq 0x614c
movq 0x10(%r14), %rdi
movl $0x4, %esi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x1080
cmpq %r15, %rax
je 0x251b
leaq 0x4dac(%rip), %rdi      # 0x72c0
xorl %eax, %eax
callq 0x614c
movq 0x18(%r14), %rdi
movl $0x4, %esi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x1080
cmpq %r15, %rax
je 0x2542
leaq 0x4d9b(%rip), %rdi      # 0x72d6
xorl %eax, %eax
callq 0x614c
movq 0x20(%r14), %rdi
movl $0x4, %esi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x1080
cmpq %r15, %rax
je 0x2569
leaq 0x4d8b(%rip), %rdi      # 0x72ed
xorl %eax, %eax
callq 0x614c
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 0x259d
leaq 0x4c49(%rip), %rdi      # 0x71df
xorl %eax, %eax
callq 0x614c
leaq (,%r15,4), %rdi
callq 0x6214
movq %rax, 0x30(%r14)
movq (%r14), %rax
movl 0x40(%rax), %edi
incl %edi
shlq $0x2, %rdi
callq 0x6214
movq %rax, 0x38(%r14)
movq 0x30(%r14), %rdi
movl $0x4, %esi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x1080
cmpq %r15, %rax
je 0x25ea
leaq 0x4c07(%rip), %rdi      # 0x71ea
xorl %eax, %eax
callq 0x614c
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 0x261e
leaq 0x4bdc(%rip), %rdi      # 0x71f3
xorl %eax, %eax
callq 0x614c
movq 0x48(%r14), %rdi
callq 0x5b0d
movq %rbx, %rdi
callq 0x5da1
movq %rax, 0x48(%r14)
testq %rax, %rax
jne 0x2646
leaq 0x4cc1(%rip), %rdi      # 0x7300
xorl %eax, %eax
callq 0x614c
movq 0x40(%r14), %rdi
callq 0x5417
movq %rbx, %rdi
callq 0x5575
movq %rax, 0x40(%r14)
testq %rax, %rax
jne 0x266e
leaq 0x4cad(%rip), %rdi      # 0x7314
xorl %eax, %eax
callq 0x614c
movq %rbx, %rdi
callq 0x1090
movq %r14, %rax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq