// File: /workspace/github_cpp_makefile_star2_O3/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 $0x68, %rsp
movl %edx, %ebx
movq %rsi, %r12
movq %rdi, %r14
leaq 0xa4287(%rip), %rsi     # 0xbdc4a
movq %r12, %rdi
callq 0x11700
testq %rax, %rax
je 0x19b7e
movq %rax, %r15
movl 0x14(%r14), %ecx
testl %ecx, %ecx
jle 0x19b6f
xorl %r12d, %r12d
cmpl $0x2, %ebx
jl 0x199fa
movl %r12d, %eax
xorl %edx, %edx
divl %ebx
testl %edx, %edx
jne 0x19b60
movq 0x8(%r14), %rax
movq (%rax,%r12,8), %r13
leaq 0x38(%r13), %rbp
leaq 0x50(%rsp), %rdi
movq %rbp, %rsi
leaq 0xec18b(%rip), %rdx     # 0x105ba0
callq 0x49ffa
leaq 0x38(%rsp), %rdi
movq %rbp, %rsi
leaq 0xa35bf(%rip), %rdx     # 0xbcfe8
callq 0x49f82
leaq 0x20(%rsp), %rdi
movq %rbp, %rsi
leaq 0xa354b(%rip), %rdx     # 0xbcf88
callq 0x49f82
movsd 0x140(%r13), %xmm2
leaq 0xeb286(%rip), %rax     # 0x104cd8
movsd (%rax), %xmm0
movapd %xmm0, %xmm1
xorpd 0xa15ee(%rip), %xmm1    # 0xbb050
ucomisd %xmm1, %xmm2
jb 0x19a7c
ucomisd %xmm2, %xmm0
jb 0x19a7c
leaq 0xeb273(%rip), %rax     # 0x104ce8
movsd (%rax), %xmm10
jmp 0x19ab2
xorps %xmm0, %xmm0
cvtsi2sdl 0x28(%r13), %xmm0
mulsd 0xa1593(%rip), %xmm0    # 0xbb020
divsd %xmm2, %xmm0
callq 0x114c0
movapd %xmm0, %xmm10
leaq 0xeb236(%rip), %rax     # 0x104cd8
movsd (%rax), %xmm0
movapd %xmm0, %xmm1
xorpd 0xa159e(%rip), %xmm1    # 0xbb050
movsd 0x160(%r13), %xmm2
ucomisd %xmm1, %xmm2
jb 0x19ad4
ucomisd %xmm2, %xmm0
jb 0x19ad4
leaq 0xeb21a(%rip), %rax     # 0x104ce8
movsd (%rax), %xmm0
jmp 0x19afc
xorps %xmm0, %xmm0
cvtsi2sdl 0x2c(%r13), %xmm0
mulsd 0xa153b(%rip), %xmm0    # 0xbb020
divsd %xmm2, %xmm0
movsd %xmm10, 0x18(%rsp)
callq 0x114c0
movsd 0x18(%rsp), %xmm10
movsd 0x50(%rsp), %xmm8
movsd 0x58(%rsp), %xmm1
movsd 0x60(%rsp), %xmm2
movsd 0x38(%rsp), %xmm3
movsd 0x40(%rsp), %xmm4
movsd 0x48(%rsp), %xmm5
movsd 0x20(%rsp), %xmm6
movsd 0x28(%rsp), %xmm7
movsd 0x30(%rsp), %xmm9
movsd %xmm0, 0x10(%rsp)
movsd %xmm10, 0x8(%rsp)
movsd %xmm9, (%rsp)
movq %r15, %rdi
leaq 0xa2223(%rip), %rsi     # 0xbbd74
movaps %xmm8, %xmm0
movb $0x8, %al
callq 0x11880
movl 0x14(%r14), %ecx
incq %r12
movslq %ecx, %rax
cmpq %rax, %r12
jl 0x199e6
movq %r15, %rdi
callq 0x115a0
movl $0x1, %ebx
jmp 0x19b91
leaq 0xa21d0(%rip), %rdi     # 0xbbd55
xorl %ebx, %ebx
movq %r12, %rsi
xorl %eax, %eax
callq 0x77f42
movl %ebx, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq