// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/GSV/GSVRun.cpp
// Function: gaps::GSVRun::ReadCameraInfoFile()
int GSVRun::
ReadCameraInfoFile(void)
{
  // Create filename
  char filename[4096];
  sprintf(filename, "%s/%s/camera_info.txt", scene->RawDataDirectoryName(), Name());

  // Open file
  FILE *fp = fopen(filename, "r");
  if (!fp) {
    RNFail("Unable to open camera info file: %s\n", filename);
    return 0;
  }

  // Read camera information
  GSVCamera *camera = NULL;
  const int buffer_size = 16*1024;
  char buffer[buffer_size];
  while (fgets(buffer, buffer_size, fp)) {
    // Parse line
    char *keyword = strtok(buffer, ": \t\n");
    if (!keyword) continue;
    if (keyword[0] == '#') continue;
    char *string = strtok(NULL, ": \t\n");
    RNScalar value = atof(string);

    // First line should have number
    if (!strcmp(keyword, "camera_number")) {
      int ncameras = atoi(string);
      for (int i = 0; i < ncameras; i++) {
        GSVCamera *camera = new GSVCamera();
        InsertCamera(camera);
      }
    }
    else if (!strcmp(keyword, "camera_index")) {
      int index = atoi(string);
      if ((index >= 0) && (index < NCameras())) {
        camera = Camera(index);
      }
    }
    else if (camera) {
      if (!strcmp(keyword, "focal_x")) camera->SetXFocal(value);
      else if (!strcmp(keyword, "focal_y")) camera->SetYFocal(value);
      else if (!strcmp(keyword, "center_x")) camera->SetXCenter(value);
      else if (!strcmp(keyword, "center_y")) camera->SetYCenter(value);
      else if (!strcmp(keyword, "distortion_type")) camera->SetDistortionType((!strcmp(string, "PERSPECTIVE")) ? 0 : 1);
      else if (!strcmp(keyword, "k1")) camera->SetK1(value);
      else if (!strcmp(keyword, "k2")) camera->SetK2(value);
      else if (!strcmp(keyword, "k3")) camera->SetK3(value);
      else if (!strcmp(keyword, "p1")) camera->SetP1(value);
      else if (!strcmp(keyword, "p2")) camera->SetP2(value);
      else if (!strcmp(keyword, "fov_max")) camera->SetMaxFov(RN_PI*value/180.0);
    }
  }

  // Close file
  fclose(fp);

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x5028, %rsp           # imm = 0x5028
movq %rdi, %rbx
movq 0x8(%rdi), %rax
movq 0x48(%rdi), %rcx
movq 0x20(%rax), %rdx
leaq 0x1167b9(%rip), %rsi    # 0x14ecc8
xorl %ebp, %ebp
leaq 0x4020(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x27140
leaq 0x137eb9(%rip), %rsi    # 0x1703e3
movq %r14, %rdi
callq 0x27b30
testq %rax, %rax
je 0x388a8
movq %rax, %r14
leaq 0x20(%rsp), %rdi
movl $0x4000, %esi           # imm = 0x4000
movq %rax, %rdx
callq 0x27fd0
testq %rax, %rax
je 0x38899
leaq 0x121d58(%rip), %rax    # 0x15a2b8
movsd (%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0x28(%rbx), %r15
movq $0x0, 0x8(%rsp)
leaq 0x116785(%rip), %r12    # 0x14ed03
leaq 0x20(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x27f90
testq %rax, %rax
je 0x38836
movq %rax, %rbp
cmpb $0x23, (%rax)
je 0x38836
xorl %edi, %edi
movq %r12, %r13
movq %r12, %rsi
callq 0x27f90
movq %rax, %r12
movq %rax, %rdi
callq 0x27c10
movsd %xmm0, 0x10(%rsp)
movq %rbp, %rdi
leaq 0x11673d(%rip), %rsi    # 0x14ed08
callq 0x27d90
testl %eax, %eax
je 0x38723
movq %rbp, %rdi
leaq 0x116734(%rip), %rsi    # 0x14ed16
callq 0x27d90
testl %eax, %eax
je 0x38773
cmpq $0x0, 0x8(%rsp)
je 0x387a8
movq %rbp, %rdi
leaq 0x11671e(%rip), %rsi    # 0x14ed23
callq 0x27d90
testl %eax, %eax
je 0x387b3
movq %rbp, %rdi
leaq 0x11670f(%rip), %rsi    # 0x14ed2b
callq 0x27d90
testl %eax, %eax
je 0x387c5
movq %rbp, %rdi
leaq 0x116700(%rip), %rsi    # 0x14ed33
callq 0x27d90
testl %eax, %eax
je 0x387d7
movq %rbp, %rdi
leaq 0x1166f2(%rip), %rsi    # 0x14ed3c
callq 0x27d90
testl %eax, %eax
je 0x387e9
movq %rbp, %rdi
leaq 0x1166e4(%rip), %rsi    # 0x14ed45
callq 0x27d90
testl %eax, %eax
je 0x387fb
movq %rbp, %rdi
leaq 0x1166e9(%rip), %rsi    # 0x14ed61
callq 0x27d90
testl %eax, %eax
je 0x3881e
movq %rbp, %rdi
leaq 0x1166d5(%rip), %rsi    # 0x14ed64
callq 0x27d90
testl %eax, %eax
movq %r13, %r12
je 0x38851
movq %rbp, %rdi
leaq 0x1166be(%rip), %rsi    # 0x14ed67
callq 0x27d90
testl %eax, %eax
leaq 0x20(%rsp), %r13
je 0x38863
movq %rbp, %rdi
leaq 0x1166a5(%rip), %rsi    # 0x14ed6a
callq 0x27d90
testl %eax, %eax
je 0x38875
movq %rbp, %rdi
leaq 0x116691(%rip), %rsi    # 0x14ed6d
callq 0x27d90
testl %eax, %eax
je 0x38887
movq %rbp, %rdi
leaq 0x11667d(%rip), %rsi    # 0x14ed70
callq 0x27d90
testl %eax, %eax
jne 0x38836
movsd 0x10(%rsp), %xmm0
mulsd 0x18(%rsp), %xmm0
divsd 0x11658c(%rip), %xmm0   # 0x14eca0
movq 0x8(%rsp), %rdi
callq 0x3bd90
jmp 0x38836
movq %r12, %rdi
callq 0x27f80
testl %eax, %eax
jle 0x3882e
movl %eax, %ebp
movl $0xc8, %edi
callq 0x27930
movq %rax, %r12
movq %rax, %rdi
callq 0x3bae8
movq %rbx, 0x8(%r12)
movl 0x34(%rbx), %edx
movl %edx, 0x10(%r12)
movq %r15, %rdi
movq %r12, %rsi
callq 0xfa862
movq %rbx, %rdi
callq 0x38086
decl %ebp
jne 0x38735
jmp 0x3882e
movq %r12, %rdi
callq 0x27f80
testl %eax, %eax
js 0x3882e
cmpl 0x34(%rbx), %eax
movq %r13, %r12
leaq 0x20(%rsp), %r13
jge 0x38836
movq 0x28(%rbx), %rcx
movl %eax, %eax
movq (%rcx,%rax,8), %rax
movq %rax, 0x8(%rsp)
jmp 0x38836
movq $0x0, 0x8(%rsp)
jmp 0x3882e
movq 0x8(%rsp), %rdi
movsd 0x10(%rsp), %xmm0
callq 0x3bd5a
jmp 0x3882e
movq 0x8(%rsp), %rdi
movsd 0x10(%rsp), %xmm0
callq 0x3bd60
jmp 0x3882e
movq 0x8(%rsp), %rdi
movsd 0x10(%rsp), %xmm0
callq 0x3bd66
jmp 0x3882e
movq 0x8(%rsp), %rdi
movsd 0x10(%rsp), %xmm0
callq 0x3bd6c
jmp 0x3882e
movq %r12, %rdi
leaq 0x116550(%rip), %rsi    # 0x14ed55
callq 0x27d90
xorl %esi, %esi
testl %eax, %eax
setne %sil
movq 0x8(%rsp), %rdi
callq 0x3bd4e
jmp 0x3882e
movq 0x8(%rsp), %rdi
movsd 0x10(%rsp), %xmm0
callq 0x3bd72
movq %r13, %r12
leaq 0x20(%rsp), %r13
movq %r13, %rdi
movl $0x4000, %esi           # imm = 0x4000
movq %r14, %rdx
callq 0x27fd0
testq %rax, %rax
jne 0x38583
jmp 0x38899
movq 0x8(%rsp), %rdi
movsd 0x10(%rsp), %xmm0
callq 0x3bd78
jmp 0x38831
movq 0x8(%rsp), %rdi
movsd 0x10(%rsp), %xmm0
callq 0x3bd7e
jmp 0x38836
movq 0x8(%rsp), %rdi
movsd 0x10(%rsp), %xmm0
callq 0x3bd84
jmp 0x38836
movq 0x8(%rsp), %rdi
movsd 0x10(%rsp), %xmm0
callq 0x3bd8a
jmp 0x38836
movq %r14, %rdi
callq 0x27920
movl $0x1, %ebp
jmp 0x388be
leaq 0x11642f(%rip), %rdi    # 0x14ecde
leaq 0x4020(%rsp), %rsi
xorl %eax, %eax
callq 0xfd64a
movl %ebp, %eax
addq $0x5028, %rsp           # imm = 0x5028
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movl $0xc8, %esi
movq %r12, %rdi
callq 0x27950
movq %rbx, %rdi
callq 0x28160