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

  // Read file
  R3Point center;
  R3Vector axis[2];
  double radius[3];
  while (fscanf(fp, "%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf",
    &center[0], &center[1], &center[2],
    &axis[0][0], &axis[0][1], &axis[0][2],
    &axis[1][0], &axis[1][1], &axis[1][2],
    &radius[0], &radius[1], &radius[2]) == (unsigned int) 12) {
    // Make sure axes are orthogonal
    axis[0].Normalize();
    R3Vector axis2 = axis[0] % axis[1];
    axis[1] = axis2 % axis[0];
    axis[1].Normalize();
    
    // Create rectangle
    R3Rectangle *rectangle = new R3Rectangle(center,
      axis[0], axis[1], radius[0], radius[1]);

    // Create RGBD surface
    RGBDSurface *rgbd_surface = new RGBDSurface(NULL, rectangle);
    rgbd_surface->thickness = radius[2];

    // Insert RGBD surface
    InsertSurface(rgbd_surface);
  }

  // Close file
  fclose(fp);

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x9699b(%rip), %rsi     # 0xae713
movq %r14, %rdi
callq 0x11700
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x17ef3
leaq 0x28(%rsp), %rdi
callq 0x45d4a
xorl %r14d, %r14d
leaq (%rsp,%r14), %rdi
addq $0x40, %rdi
callq 0x4650a
addq $0x18, %r14
cmpq $0x30, %r14
jne 0x17d9b
leaq 0x58(%rsp), %r13
leaq 0x28(%rsp), %r15
leaq 0x40(%rsp), %r12
movq 0x8(%rsp), %rdi
leaq 0x90cdb(%rip), %rsi     # 0xa8aa8
movq %r15, %rdx
leaq 0x30(%rsp), %rcx
leaq 0x38(%rsp), %r8
movq %r12, %r9
xorl %eax, %eax
leaq 0x20(%rsp), %r10
pushq %r10
leaq 0x20(%rsp), %r10
pushq %r10
leaq 0x20(%rsp), %r10
pushq %r10
leaq 0x80(%rsp), %r10
pushq %r10
leaq 0x80(%rsp), %r10
pushq %r10
pushq %r13
leaq 0x80(%rsp), %r10
pushq %r10
leaq 0x80(%rsp), %r10
pushq %r10
callq 0x11af0
addq $0x40, %rsp
cmpl $0xc, %eax
jne 0x17ee4
movq %r12, %rdi
callq 0x4680e
leaq 0x90(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x46bbe
leaq 0x78(%rsp), %rbp
movq %rbp, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x46bbe
movq %r13, %rdi
movq %rbp, %rsi
callq 0x46a7c
movq %r13, %rdi
callq 0x4680e
pushq $0x78
popq %rdi
callq 0x115c0
movq %rax, %rbp
movsd 0x10(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movq %rax, %rdi
movq %r15, %r14
movq %r15, %rsi
movq %r12, %rdx
movq %r13, %rcx
callq 0x3bfd2
movl $0xa0, %edi
callq 0x115c0
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq %rbp, %rdx
movsd 0x905fc(%rip), %xmm0    # 0xa84b8
callq 0x19b1e
movsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x98(%r15)
movq (%rbx), %rax
movq %rbx, %rdi
movq %r15, %rsi
callq *0x20(%rax)
movq %r14, %r15
jmp 0x17dc1
movq 0x8(%rsp), %rdi
callq 0x115b0
pushq $0x1
popq %rbx
jmp 0x17f06
leaq 0x90bd3(%rip), %rdi     # 0xa8acd
xorl %ebx, %ebx
movq %r14, %rsi
xorl %eax, %eax
callq 0x6e732
movl %ebx, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movl $0xa0, %esi
movq %r15, %rdi
jmp 0x17f30
movq %rax, %rbx
pushq $0x78
popq %rsi
movq %rbp, %rdi
callq 0x115d0
movq %rbx, %rdi
callq 0x11a80
nop