// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x819f(%rip), %rsi      # 0xa0e6
leaq 0x88a4(%rip), %rdx      # 0xa7f2
callq 0x9010
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
jne 0x1f6f
movq -0x8(%rbp), %rsi
leaq 0x82a3(%rip), %rdi      # 0xa20b
movb $0x0, %al
callq 0x8ca0
movq -0x10(%rbp), %rdi
callq 0x6310
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1090
movq -0x8(%rbp), %rdi
leaq 0x817b(%rip), %rsi      # 0xa10b
leaq 0x885b(%rip), %rdx      # 0xa7f2
callq 0x9010
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
jne 0x1fb8
movq -0x8(%rbp), %rsi
leaq 0x8279(%rip), %rdi      # 0xa22a
movb $0x0, %al
callq 0x8ca0
leaq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rcx
movl $0x8, %esi
movl $0x1, %edx
callq 0x1080
cmpq $0x1, %rax
je 0x1fe3
leaq 0x826c(%rip), %rdi      # 0xa248
movb $0x0, %al
callq 0x8ca0
leaq -0x20(%rbp), %rdi
leaq 0x8140(%rip), %rsi      # 0xa12e
callq 0x1110
cmpl $0x0, %eax
je 0x2006
leaq 0x8269(%rip), %rdi      # 0xa268
movb $0x0, %al
callq 0x8ca0
movq -0x10(%rbp), %rcx
leaq -0x24(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x1080
cmpq $0x1, %rax
je 0x2031
leaq 0x8253(%rip), %rdi      # 0xa27d
movb $0x0, %al
callq 0x8ca0
movq -0x18(%rbp), %rdi
movl -0x24(%rbp), %esi
callq 0x1320
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
addq $0xc, %rdi
movq -0x10(%rbp), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x1080
cmpq $0x1, %rax
je 0x2070
leaq 0x8228(%rip), %rdi      # 0xa291
movb $0x0, %al
callq 0x8ca0
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rdi
movl -0x24(%rbp), %eax
movl %eax, %edx
movq -0x10(%rbp), %rcx
movl $0x4, %esi
callq 0x1080
movl -0x24(%rbp), %ecx
cmpq %rcx, %rax
je 0x20a1
leaq 0x820a(%rip), %rdi      # 0xa2a4
movb $0x0, %al
callq 0x8ca0
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rdi
movl -0x24(%rbp), %eax
movl %eax, %edx
movq -0x10(%rbp), %rcx
movl $0x4, %esi
callq 0x1080
movl -0x24(%rbp), %ecx
cmpq %rcx, %rax
je 0x20d2
leaq 0x81ef(%rip), %rdi      # 0xa2ba
movb $0x0, %al
callq 0x8ca0
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rdi
movl -0x24(%rbp), %eax
movl %eax, %edx
movq -0x10(%rbp), %rcx
movl $0x4, %esi
callq 0x1080
movl -0x24(%rbp), %ecx
cmpq %rcx, %rax
je 0x2103
leaq 0x81d5(%rip), %rdi      # 0xa2d1
movb $0x0, %al
callq 0x8ca0
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rdi
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl 0x40(%rax), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %edx
movq -0x10(%rbp), %rcx
movl $0x4, %esi
callq 0x1080
movq -0x30(%rbp), %rcx
movq (%rcx), %rcx
movl 0x40(%rcx), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
cmpq %rcx, %rax
je 0x214c
leaq 0x807e(%rip), %rdi      # 0xa1c3
movb $0x0, %al
callq 0x8ca0
movl -0x24(%rbp), %eax
movl %eax, %edi
shlq $0x2, %rdi
callq 0x8d80
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl 0x40(%rax), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %edi
shlq $0x2, %rdi
callq 0x8d80
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rdi
movl -0x24(%rbp), %eax
movl %eax, %edx
movq -0x10(%rbp), %rcx
movl $0x4, %esi
callq 0x1080
movl -0x24(%rbp), %ecx
cmpq %rcx, %rax
je 0x21bb
leaq 0x801a(%rip), %rdi      # 0xa1ce
movb $0x0, %al
callq 0x8ca0
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rdi
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl 0x40(%rax), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %edx
movq -0x10(%rbp), %rcx
movl $0x4, %esi
callq 0x1080
movq -0x30(%rbp), %rcx
movq (%rcx), %rcx
movl 0x40(%rcx), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
cmpq %rcx, %rax
je 0x2204
leaq 0x7fda(%rip), %rdi      # 0xa1d7
movb $0x0, %al
callq 0x8ca0
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x7fc0
movq -0x10(%rbp), %rdi
callq 0x8400
movq -0x30(%rbp), %rcx
movq %rax, 0x48(%rcx)
cmpq $0x0, %rax
jne 0x2236
leaq 0x80b5(%rip), %rdi      # 0xa2e4
movb $0x0, %al
callq 0x8ca0
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rdi
callq 0x7530
movq -0x10(%rbp), %rdi
callq 0x7710
movq -0x30(%rbp), %rcx
movq %rax, 0x40(%rcx)
cmpq $0x0, %rax
jne 0x2268
leaq 0x8097(%rip), %rdi      # 0xa2f8
movb $0x0, %al
callq 0x8ca0
movq -0x10(%rbp), %rdi
callq 0x1090
movq -0x30(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)