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

  // Read file
  int id, npoints, primitive_type;
  double area, total_affinity, possible_affinity, timestamp;
  R3Point centroid, center;
  R3Plane plane;
  RNRgb color;
  R3Vector axes[3];
  double variances[3];
  R3Box extent;
  while (fscanf(fp, "%d%d%lf%lf%lf%d%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf",
    &id, &npoints, &area,
    &total_affinity, &possible_affinity, &primitive_type,
    &centroid[0], &centroid[1], &centroid[2],
    &plane[0], &plane[1], &plane[2], &plane[3], 
    &color[0], &color[1], &color[2],
    &timestamp,
    &center[0], &center[1], &center[2],
    &axes[0][0], &axes[0][1], &axes[0][2],
    &axes[1][0], &axes[1][1], &axes[1][2],
    &axes[2][0], &axes[2][1], &axes[2][2],
    &variances[0], &variances[1], &variances[2],
    &extent[0][0], &extent[0][1], &extent[0][2],
    &extent[1][0], &extent[1][1], &extent[1][2]) == (unsigned int) 38) {

    // Determine radii
    RNLength radius0 = 0.5 * (extent[1][0] - extent[0][0]);
    if (RNIsZero(radius0)) continue;
    RNLength radius1 = 0.5 * (extent[1][1] - extent[0][1]);
    if (RNIsZero(radius1)) continue;
    RNLength radius2 = 0.5 * (extent[1][2] - extent[0][2]);

    // Determine center of extent
    center += (radius0 + extent[0][0]) * axes[0];
    center += (radius1 + extent[0][1]) * axes[1];

    // Create rectangle
    R3Rectangle *rectangle = new R3Rectangle(center, axes[0], axes[1], radius0, radius1);

    // Create RGBD surface
    double texel_spacing = 0.01;
    RGBDSurface *rgbd_surface = new RGBDSurface(NULL, rectangle, texel_spacing);
    rgbd_surface->thickness = radius2;

    // 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 $0x178, %rsp            # imm = 0x178
movq %rsi, %rbx
movq %rdi, 0x50(%rsp)
leaq 0xa95db(%rip), %rsi     # 0xc1a63
movq %rbx, %rdi
callq 0x11700
testq %rax, %rax
je 0x187c2
movq %rax, %r14
leaq 0x88(%rsp), %rdi
callq 0x4b600
leaq 0x128(%rsp), %r12
movq %r12, %rdi
callq 0x4b600
leaq 0xa0(%rsp), %rdi
callq 0x4a0f0
leaq 0x70(%rsp), %rdi
callq 0x75224
xorl %ebx, %ebx
leaq (%rsp,%rbx), %rdi
addq $0xc0, %rdi
callq 0x4c094
addq $0x18, %rbx
cmpq $0x48, %rbx
jne 0x184d2
leaq 0x18(%rsp), %rdi
callq 0x42ed0
leaq 0xd8(%rsp), %rbx
leaq 0xc0(%rsp), %r15
movq %r14, %rdi
leaq 0xa35cd(%rip), %rsi     # 0xbbadd
leaq 0x6c(%rsp), %rdx
leaq 0x68(%rsp), %rcx
leaq 0x158(%rsp), %r8
leaq 0x150(%rsp), %r9
xorl %eax, %eax
leaq 0x48(%rsp), %r10
pushq %r10
leaq 0x48(%rsp), %r10
pushq %r10
leaq 0x48(%rsp), %r10
pushq %r10
leaq 0x48(%rsp), %r10
pushq %r10
leaq 0x48(%rsp), %r10
pushq %r10
leaq 0x48(%rsp), %r10
pushq %r10
leaq 0x150(%rsp), %r10
pushq %r10
leaq 0x150(%rsp), %r10
pushq %r10
leaq 0x150(%rsp), %r10
pushq %r10
leaq 0x148(%rsp), %r10
pushq %r10
leaq 0x148(%rsp), %r10
pushq %r10
leaq 0x148(%rsp), %r10
pushq %r10
leaq 0x148(%rsp), %r10
pushq %r10
leaq 0x148(%rsp), %r10
pushq %r10
pushq %rbx
leaq 0x148(%rsp), %r10
pushq %r10
leaq 0x148(%rsp), %r10
pushq %r10
pushq %r15
leaq 0x1c8(%rsp), %r10
pushq %r10
leaq 0x1c8(%rsp), %r10
pushq %r10
pushq %r12
leaq 0x1e8(%rsp), %r10
pushq %r10
leaq 0x130(%rsp), %r10
pushq %r10
leaq 0x130(%rsp), %r10
pushq %r10
leaq 0x130(%rsp), %r10
pushq %r10
leaq 0x180(%rsp), %r10
pushq %r10
leaq 0x180(%rsp), %r10
pushq %r10
leaq 0x180(%rsp), %r10
pushq %r10
leaq 0x180(%rsp), %r10
pushq %r10
leaq 0x180(%rsp), %r10
pushq %r10
leaq 0x180(%rsp), %r10
pushq %r10
leaq 0x180(%rsp), %r10
pushq %r10
leaq 0x164(%rsp), %r10
pushq %r10
leaq 0x250(%rsp), %r10
pushq %r10
callq 0x11ad0
addq $0x110, %rsp            # imm = 0x110
cmpl $0x26, %eax
jne 0x187a9
movsd 0x20(%rsp), %xmm0
movsd 0x38(%rsp), %xmm3
subsd %xmm0, %xmm3
mulsd 0xa299e(%rip), %xmm3    # 0xbb020
leaq 0xec64f(%rip), %rax     # 0x104cd8
movsd (%rax), %xmm1
movapd %xmm1, %xmm2
xorpd 0xa29b7(%rip), %xmm2    # 0xbb050
movsd %xmm3, 0x8(%rsp)
ucomisd %xmm2, %xmm3
jb 0x186b1
ucomisd 0x8(%rsp), %xmm1
jae 0x18506
movsd 0x40(%rsp), %xmm3
subsd 0x28(%rsp), %xmm3
mulsd 0xa295b(%rip), %xmm3    # 0xbb020
ucomisd %xmm2, %xmm3
jb 0x186d5
ucomisd %xmm3, %xmm1
jae 0x18506
movsd %xmm3, 0x10(%rsp)
movsd 0x48(%rsp), %xmm1
subsd 0x30(%rsp), %xmm1
mulsd 0xa2931(%rip), %xmm1    # 0xbb020
movsd %xmm1, 0x58(%rsp)
addsd 0x8(%rsp), %xmm0
leaq 0x160(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0x4ca32
movq %r12, %rdi
movq %r13, %rsi
callq 0x4b9e4
movsd 0x28(%rsp), %xmm0
addsd 0x10(%rsp), %xmm0
movq %r13, %rdi
movq %rbx, %rsi
callq 0x4ca32
movq %r12, %rdi
movq %r13, %rsi
callq 0x4b9e4
movl $0x78, %edi
callq 0x115b0
movq %rax, %rbp
movq %rax, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %rbx, %rcx
movsd 0x8(%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
callq 0x40bf4
movl $0xa0, %edi
callq 0x115b0
movq %rax, %r13
movq %rax, %rdi
xorl %esi, %esi
movq %rbp, %rdx
movsd 0xa2d2e(%rip), %xmm0    # 0xbb4b0
callq 0x1a9be
movsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x98(%r13)
movq 0x50(%rsp), %rdi
movq (%rdi), %rax
movq %r13, %rsi
callq *0x20(%rax)
jmp 0x18506
movq %r14, %rdi
callq 0x115a0
leaq 0x18(%rsp), %rdi
callq 0x43d34
movl $0x1, %ebp
jmp 0x187d5
leaq 0xa32ef(%rip), %rdi     # 0xbbab8
xorl %ebp, %ebp
movq %rbx, %rsi
xorl %eax, %eax
callq 0x77f42
movl %ebp, %eax
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movl $0x78, %esi
movq %rbp, %rdi
jmp 0x18801
movq %rax, %rbx
movl $0xa0, %esi
movq %r13, %rdi
callq 0x115c0
jmp 0x18813
jmp 0x18810
jmp 0x18810
jmp 0x18810
jmp 0x18810
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x43d34
movq %rbx, %rdi
callq 0x11a60
nop