// File: /workspace/github_c_makefile_star2_O0/richarddurbin[P]hash10x/moshmap.c
// Function: referenceWrite
void referenceWrite (Reference *ref, char *root)
{
  FILE *f ;
  if (!(f = fopenTag (root, "mosh", "w"))) die ("failed to open %s.mosh to write", root) ;
  moshsetWrite (ref->ms, f) ;
  fclose (f) ;
  if (!(f = fopenTag (root, "ref", "w"))) die ("failed to open %s.ref to write", root) ;
  if (fwrite ("RFMSHv1",8,1,f) != 1) die ("failed to write reference header") ;
  U32 size = ref->max ; if (fwrite (&size,sizeof(U32),1,f) != 1) die ("failed to write size") ;
  if (fwrite (&ref->max,sizeof(U32),1,f) != 1) die ("failed to write max") ;
  if (fwrite (ref->index,sizeof(U32),size,f) != size) die ("failed write ref index") ;
  if (fwrite (ref->offset,sizeof(U32),size,f) != size) die ("failed write ref offset") ;
  if (fwrite (ref->id,sizeof(U32),size,f) != size) die ("failed write ref id") ;
  if (fwrite (ref->depth,sizeof(U32),ref->ms->max+1,f) != ref->ms->max+1) die ("fail depth") ;
  if (fwrite (ref->rev,sizeof(U32),size,f) != size) die ("fail rev") ;
  if (fwrite (ref->loc,sizeof(U32),ref->ms->max+1,f) != ref->ms->max+1) die ("fail loc") ;
  if (!arrayWrite (ref->len, f)) die ("failed write ref len") ;
  if (!dictWrite (ref->dict, f)) die ("failed write ref dict") ;
  /* write the dict last, because it can terminate in arbitrary byte alignment */
  fclose (f) ;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x846b(%rip), %rsi      # 0xa0e6
leaq 0x8b83(%rip), %rdx      # 0xa805
callq 0x9010
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
jne 0x1ca3
movq -0x10(%rbp), %rsi
leaq 0x844f(%rip), %rdi      # 0xa0eb
movb $0x0, %al
callq 0x8ca0
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x6150
movq -0x18(%rbp), %rdi
callq 0x1090
movq -0x10(%rbp), %rdi
leaq 0x8444(%rip), %rsi      # 0xa10b
leaq 0x8b37(%rip), %rdx      # 0xa805
callq 0x9010
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
jne 0x1cef
movq -0x10(%rbp), %rsi
leaq 0x8427(%rip), %rdi      # 0xa10f
movb $0x0, %al
callq 0x8ca0
movq -0x18(%rbp), %rcx
leaq 0x8434(%rip), %rdi      # 0xa12e
movl $0x8, %esi
movl $0x1, %edx
callq 0x11f0
cmpq $0x1, %rax
je 0x1d1d
leaq 0x8420(%rip), %rdi      # 0xa136
movb $0x0, %al
callq 0x8ca0
movq -0x8(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x1c(%rbp)
movq -0x18(%rbp), %rcx
leaq -0x1c(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x11f0
cmpq $0x1, %rax
je 0x1d52
leaq 0x840c(%rip), %rdi      # 0xa157
movb $0x0, %al
callq 0x8ca0
movq -0x8(%rbp), %rdi
addq $0xc, %rdi
movq -0x18(%rbp), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x11f0
cmpq $0x1, %rax
je 0x1d81
leaq 0x83f2(%rip), %rdi      # 0xa16c
movb $0x0, %al
callq 0x8ca0
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movl -0x1c(%rbp), %eax
movl %eax, %edx
movq -0x18(%rbp), %rcx
movl $0x4, %esi
callq 0x11f0
movl -0x1c(%rbp), %ecx
cmpq %rcx, %rax
je 0x1db2
leaq 0x83d5(%rip), %rdi      # 0xa180
movb $0x0, %al
callq 0x8ca0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movl -0x1c(%rbp), %eax
movl %eax, %edx
movq -0x18(%rbp), %rcx
movl $0x4, %esi
callq 0x11f0
movl -0x1c(%rbp), %ecx
cmpq %rcx, %rax
je 0x1de3
leaq 0x83bb(%rip), %rdi      # 0xa197
movb $0x0, %al
callq 0x8ca0
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
movl -0x1c(%rbp), %eax
movl %eax, %edx
movq -0x18(%rbp), %rcx
movl $0x4, %esi
callq 0x11f0
movl -0x1c(%rbp), %ecx
cmpq %rcx, %rax
je 0x1e14
leaq 0x83a2(%rip), %rdi      # 0xa1af
movb $0x0, %al
callq 0x8ca0
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl 0x40(%rax), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %edx
movq -0x18(%rbp), %rcx
movl $0x4, %esi
callq 0x11f0
movq -0x8(%rbp), %rcx
movq (%rcx), %rcx
movl 0x40(%rcx), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
cmpq %rcx, %rax
je 0x1e5d
leaq 0x836d(%rip), %rdi      # 0xa1c3
movb $0x0, %al
callq 0x8ca0
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rdi
movl -0x1c(%rbp), %eax
movl %eax, %edx
movq -0x18(%rbp), %rcx
movl $0x4, %esi
callq 0x11f0
movl -0x1c(%rbp), %ecx
cmpq %rcx, %rax
je 0x1e8e
leaq 0x8347(%rip), %rdi      # 0xa1ce
movb $0x0, %al
callq 0x8ca0
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl 0x40(%rax), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %edx
movq -0x18(%rbp), %rcx
movl $0x4, %esi
callq 0x11f0
movq -0x8(%rbp), %rcx
movq (%rcx), %rcx
movl 0x40(%rcx), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
cmpq %rcx, %rax
je 0x1ed7
leaq 0x8307(%rip), %rdi      # 0xa1d7
movb $0x0, %al
callq 0x8ca0
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x8380
cmpb $0x0, %al
jne 0x1efa
leaq 0x82ed(%rip), %rdi      # 0xa1e0
movb $0x0, %al
callq 0x8ca0
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x75a0
cmpb $0x0, %al
jne 0x1f1d
leaq 0x82df(%rip), %rdi      # 0xa1f5
movb $0x0, %al
callq 0x8ca0
movq -0x18(%rbp), %rdi
callq 0x1090
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)