// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/RGBD/RGBDConfiguration.cpp
// Function: gaps::RGBDConfiguration::WriteCameraFile(char const*, int) const
int RGBDConfiguration::
WriteCameraFile(const char *filename, int write_every_kth_image) const
{
  // Open file
  FILE *fp = fopen(filename, "w");
  if (!fp) {
    RNFail("Unable to open camera file %s\n", filename);
    return 0;
  }

  // Write images
  for (int i = 0; i < NImages(); i++) {
    if ((write_every_kth_image > 1) && ((i % write_every_kth_image) != 0)) continue;
    RGBDImage *image = Image(i);
    R3Point viewpoint = image->WorldViewpoint();
    R3Vector towards = image->WorldTowards();
    R3Vector up = image->WorldUp();
    RNAngle xfov = image->XFov();
    RNAngle yfov = image->YFov();
    fprintf(fp, "%f %f %f   %f %f %f   %f %f %f  %f %f  1\n",
      viewpoint[0], viewpoint[1], viewpoint[2],
      towards[0], towards[1], towards[2],
      up[0], up[1], up[2],
      xfov, yfov);
  }
  
  // Close file
  fclose(fp);

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %edx, %ebx
movq %rsi, %r12
movq %rdi, %r14
leaq 0xa5f9f(%rip), %rsi     # 0xbfc4a
movq %r12, %rdi
callq 0x11710
movq %rax, 0x20(%rsp)
testq %rax, %rax
je 0x19e63
cmpl $0x0, 0x14(%r14)
jle 0x19e52
xorl %r12d, %r12d
leaq 0xed012(%rip), %r15     # 0x106ce8
cmpl $0x2, %ebx
jl 0x19cea
movl %r12d, %eax
xorl %edx, %edx
divl %ebx
testl %edx, %edx
jne 0x19e42
movq 0x8(%r14), %rax
movq (%rax,%r12,8), %r13
leaq 0x38(%r13), %rbp
leaq 0x60(%rsp), %rdi
movq %rbp, %rsi
leaq 0xedeab(%rip), %rdx     # 0x107bb0
callq 0x4a83e
leaq 0x48(%rsp), %rdi
movq %rbp, %rsi
leaq 0xa52cf(%rip), %rdx     # 0xbefe8
callq 0x4a7c6
leaq 0x30(%rsp), %rdi
movq %rbp, %rsi
leaq 0xa525b(%rip), %rdx     # 0xbef88
callq 0x4a7c6
movsd 0x140(%r13), %xmm1
movsd (%r15), %xmm0
movapd %xmm0, %xmm2
xorpd 0xa3304(%rip), %xmm2    # 0xbd050
ucomisd %xmm2, %xmm1
jb 0x19d66
ucomisd %xmm1, %xmm0
jb 0x19d66
leaq 0xecf99(%rip), %rax     # 0x106cf8
movsd (%rax), %xmm10
jmp 0x19d85
xorps %xmm0, %xmm0
cvtsi2sdl 0x28(%r13), %xmm0
mulsd 0xa32a9(%rip), %xmm0    # 0xbd020
divsd %xmm1, %xmm0
callq 0x114c0
movapd %xmm0, %xmm10
movsd 0x160(%r13), %xmm1
movsd (%r15), %xmm0
movapd %xmm0, %xmm2
xorpd 0xa32b1(%rip), %xmm2    # 0xbd050
ucomisd %xmm2, %xmm1
jb 0x19db8
ucomisd %xmm1, %xmm0
jb 0x19db8
leaq 0xecf46(%rip), %rax     # 0x106cf8
movsd (%rax), %xmm0
jmp 0x19de0
xorps %xmm0, %xmm0
cvtsi2sdl 0x2c(%r13), %xmm0
mulsd 0xa3257(%rip), %xmm0    # 0xbd020
divsd %xmm1, %xmm0
movsd %xmm10, 0x28(%rsp)
callq 0x114c0
movsd 0x28(%rsp), %xmm10
movsd 0x60(%rsp), %xmm8
movsd 0x68(%rsp), %xmm1
movsd 0x70(%rsp), %xmm2
movsd 0x48(%rsp), %xmm3
movsd 0x50(%rsp), %xmm4
movsd 0x58(%rsp), %xmm5
movsd 0x30(%rsp), %xmm6
movsd 0x38(%rsp), %xmm7
movsd 0x40(%rsp), %xmm9
movsd %xmm0, 0x10(%rsp)
movsd %xmm10, 0x8(%rsp)
movsd %xmm9, (%rsp)
movq 0x20(%rsp), %rdi
leaq 0xa3f3d(%rip), %rsi     # 0xbdd74
movaps %xmm8, %xmm0
movb $0x8, %al
callq 0x11890
incq %r12
movslq 0x14(%r14), %rax
cmpq %rax, %r12
jl 0x19cd6
movq 0x20(%rsp), %rdi
callq 0x115a0
movl $0x1, %ebx
jmp 0x19e76
leaq 0xa3eeb(%rip), %rdi     # 0xbdd55
xorl %ebx, %ebx
movq %r12, %rsi
xorl %eax, %eax
callq 0x79092
movl %ebx, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop