// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2PixelDatabase.cpp
// Function: gaps::R2PixelDatabase::WriteEntries(_IO_FILE*, int)
int R2PixelDatabase::
WriteEntries(FILE *fp, int swap_endian)
{
  // Seek to entries seek
  RNFileSeek(fp, entries_seek, RN_FILE_SEEK_SET);

  // Write entries
  int dummy = 0;
  char buffer[128] = { '\0' };
  std::map<std::string, R2PixelDatabaseEntry, RNMapComparator<std::string> >::iterator it;
  for (it = map.m->begin(); it != map.m->end(); ++it) {
    R2PixelDatabaseEntry entry = it->second;
    strncpy(buffer, entry.key, 128);
    if (!RNWriteChar(fp, buffer, 128, swap_endian)) return 0;
    if (!RNWriteUnsignedInt(fp, &entry.format, 1, swap_endian)) return 0;
    if (!RNWriteUnsignedInt(fp, &entry.size, 1, swap_endian)) return 0;
    if (!RNWriteUnsignedLongLong(fp, &entry.seek, 1, swap_endian)) return 0;
    if (!RNWriteDouble(fp, &entry.offset, 1, swap_endian)) return 0;
    if (!RNWriteDouble(fp, &entry.scale, 1, swap_endian)) return 0;
    if (!RNWriteDouble(fp, &entry.exponent, 1, swap_endian)) return 0;
    for (int j = 0; j < 12; j++) RNWriteInt(fp, &dummy, 1, swap_endian);
  }

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %r15
movq 0x38(%rdi), %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x9c462
leaq 0x14(%rsp), %r12
andl $0x0, (%r12)
xorps %xmm0, %xmm0
leaq 0xc0(%rsp), %rax
movaps %xmm0, 0x70(%rax)
movaps %xmm0, 0x60(%rax)
movaps %xmm0, 0x50(%rax)
movaps %xmm0, 0x40(%rax)
movaps %xmm0, 0x30(%rax)
movaps %xmm0, 0x20(%rax)
movaps %xmm0, 0x10(%rax)
movaps %xmm0, (%rax)
movq %r15, (%rsp)
movq 0x40(%r15), %rax
movq 0x18(%rax), %rcx
pushq $0x1
popq %rbp
addq $0x8, %rax
cmpq %rax, %rcx
je 0x8e417
movq %rcx, 0x8(%rsp)
leaq 0x40(%rcx), %r13
movl $0xa8, %edx
leaq 0x18(%rsp), %rdi
movq %r13, %rsi
callq 0x13400
movl $0x80, %edx
leaq 0xc0(%rsp), %r15
movq %r15, %rdi
movq %r13, %rsi
callq 0x13290
movq %r14, %rdi
movq %r15, %rsi
movl $0x80, %edx
movl %ebx, %ecx
callq 0x9c7f2
testl %eax, %eax
je 0x8e415
movq %r14, %rdi
leaq 0x98(%rsp), %rsi
movl %ebp, %edx
movl %ebx, %ecx
callq 0x9c99c
testl %eax, %eax
je 0x8e415
movq %r14, %rdi
leaq 0x9c(%rsp), %rsi
movl %ebp, %edx
movl %ebx, %ecx
callq 0x9c99c
testl %eax, %eax
je 0x8e415
movq %r14, %rdi
leaq 0xa0(%rsp), %rsi
movl %ebp, %edx
movl %ebx, %ecx
callq 0x9cb44
testl %eax, %eax
je 0x8e415
movq %r14, %rdi
leaq 0xa8(%rsp), %rsi
movl %ebp, %edx
movl %ebx, %ecx
callq 0x9ca70
testl %eax, %eax
je 0x8e415
movq %r14, %rdi
leaq 0xb0(%rsp), %rsi
movl %ebp, %edx
movl %ebx, %ecx
callq 0x9ca70
testl %eax, %eax
je 0x8e415
movq %r14, %rdi
leaq 0xb8(%rsp), %rsi
movl %ebp, %edx
movl %ebx, %ecx
callq 0x9ca70
testl %eax, %eax
je 0x8e415
pushq $0xc
popq %r13
subl $0x1, %r13d
jb 0x8e3fb
movq %r14, %rdi
movq %r12, %rsi
movl %ebp, %edx
movl %ebx, %ecx
callq 0x9c932
jmp 0x8e3e4
movq 0x8(%rsp), %rdi
callq 0x13380
movq %rax, %rcx
movq (%rsp), %rax
movq 0x40(%rax), %rax
jmp 0x8e2ee
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop