// File: /workspace/github_cpp_makefile_star2_O3/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 0x114989(%rip), %rsi    # 0x14ccd8
xorl %ebp, %ebp
leaq 0x4020(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x27140
leaq 0x1360d9(%rip), %rsi    # 0x16e443
movq %r14, %rdi
callq 0x27b20
testq %rax, %rax
je 0x386e6
movq %rax, %r14
leaq 0x20(%rsp), %rdi
movl $0x4000, %esi           # imm = 0x4000
movq %rax, %rdx
callq 0x27fc0
testq %rax, %rax
je 0x386d7
leaq 0x11ff58(%rip), %rax    # 0x1582f8
movsd (%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0x28(%rbx), %r15
movq $0x0, 0x8(%rsp)
leaq 0x114955(%rip), %r12    # 0x14cd13
leaq 0x20(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x27f80
testq %rax, %rax
je 0x38612
movq %rax, %rbp
cmpb $0x23, (%rax)
je 0x38612
xorl %edi, %edi
movq %r12, %r13
movq %r12, %rsi
callq 0x27f80
movq %rax, %r12
movq %rax, %rdi
callq 0x27c00
movsd %xmm0, 0x10(%rsp)
movq %rbp, %rdi
leaq 0x11490d(%rip), %rsi    # 0x14cd18
callq 0x27d80
testl %eax, %eax
je 0x38515
movq %rbp, %rdi
leaq 0x114904(%rip), %rsi    # 0x14cd26
callq 0x27d80
testl %eax, %eax
je 0x38565
cmpq $0x0, 0x8(%rsp)
je 0x38596
movq %rbp, %rdi
leaq 0x1148ee(%rip), %rsi    # 0x14cd33
callq 0x27d80
testl %eax, %eax
je 0x385a1
movq %rbp, %rdi
leaq 0x1148df(%rip), %rsi    # 0x14cd3b
callq 0x27d80
testl %eax, %eax
je 0x385b3
movq %rbp, %rdi
leaq 0x1148d0(%rip), %rsi    # 0x14cd43
callq 0x27d80
testl %eax, %eax
je 0x385c5
movq %rbp, %rdi
leaq 0x1148c2(%rip), %rsi    # 0x14cd4c
callq 0x27d80
testl %eax, %eax
je 0x385d7
movq %rbp, %rdi
leaq 0x1148b4(%rip), %rsi    # 0x14cd55
callq 0x27d80
testl %eax, %eax
je 0x385e9
movzbl (%rbp), %eax
cmpl $0x70, %eax
je 0x38630
cmpl $0x6b, %eax
movq %r13, %r12
leaq 0x20(%rsp), %r13
jne 0x38650
cmpb $0x31, 0x1(%rbp)
jne 0x384dc
cmpb $0x0, 0x2(%rbp)
je 0x38683
cmpb $0x32, 0x1(%rbp)
jne 0x384ec
cmpb $0x0, 0x2(%rbp)
je 0x386ad
cmpb $0x33, 0x1(%rbp)
jne 0x38650
cmpb $0x0, 0x2(%rbp)
jne 0x38650
movq 0x8(%rsp), %rdi
movsd 0x10(%rsp), %xmm0
callq 0x3ba46
jmp 0x38612
movq %r12, %rdi
callq 0x27f70
testl %eax, %eax
jle 0x3860a
movl %eax, %ebp
movl $0xc8, %edi
callq 0x27930
movq %rax, %r12
movq %rax, %rdi
callq 0x3b7a8
movq %rbx, 0x8(%r12)
movl 0x34(%rbx), %edx
movl %edx, 0x10(%r12)
movq %r15, %rdi
movq %r12, %rsi
callq 0xf8c16
movq %rbx, %rdi
callq 0x37ec6
decl %ebp
jne 0x38527
jmp 0x3860a
movq %r12, %rdi
callq 0x27f70
testl %eax, %eax
js 0x3860a
cmpl 0x34(%rbx), %eax
movq %r13, %r12
leaq 0x20(%rsp), %r13
jge 0x38612
movq (%r15), %rcx
movl %eax, %eax
movq (%rcx,%rax,8), %rax
movq %rax, 0x8(%rsp)
jmp 0x38612
movq $0x0, 0x8(%rsp)
jmp 0x3860a
movq 0x8(%rsp), %rdi
movsd 0x10(%rsp), %xmm0
callq 0x3ba22
jmp 0x3860a
movq 0x8(%rsp), %rdi
movsd 0x10(%rsp), %xmm0
callq 0x3ba28
jmp 0x3860a
movq 0x8(%rsp), %rdi
movsd 0x10(%rsp), %xmm0
callq 0x3ba2e
jmp 0x3860a
movq 0x8(%rsp), %rdi
movsd 0x10(%rsp), %xmm0
callq 0x3ba34
jmp 0x3860a
movq %r12, %rdi
leaq 0x114772(%rip), %rsi    # 0x14cd65
callq 0x27d80
xorl %esi, %esi
testl %eax, %eax
setne %sil
movq 0x8(%rsp), %rdi
callq 0x3ba16
movq %r13, %r12
leaq 0x20(%rsp), %r13
movq %r13, %rdi
movl $0x4000, %esi           # imm = 0x4000
movq %r14, %rdx
callq 0x27fc0
testq %rax, %rax
jne 0x383c3
jmp 0x386d7
cmpb $0x31, 0x1(%rbp)
movq %r13, %r12
jne 0x3863f
cmpb $0x0, 0x2(%rbp)
je 0x38698
cmpb $0x32, 0x1(%rbp)
leaq 0x20(%rsp), %r13
jne 0x38650
cmpb $0x0, 0x2(%rbp)
je 0x386c2
movq %rbp, %rdi
leaq 0x114717(%rip), %rsi    # 0x14cd71
callq 0x27d80
testl %eax, %eax
jne 0x38612
movsd 0x10(%rsp), %xmm0
mulsd 0x18(%rsp), %xmm0
divsd 0x114639(%rip), %xmm0   # 0x14ccb0
movq 0x8(%rsp), %rdi
callq 0x3ba58
jmp 0x38612
movq 0x8(%rsp), %rdi
movsd 0x10(%rsp), %xmm0
callq 0x3ba3a
jmp 0x38612
movq 0x8(%rsp), %rdi
movsd 0x10(%rsp), %xmm0
callq 0x3ba4c
jmp 0x3860d
movq 0x8(%rsp), %rdi
movsd 0x10(%rsp), %xmm0
callq 0x3ba40
jmp 0x38612
movq 0x8(%rsp), %rdi
movsd 0x10(%rsp), %xmm0
callq 0x3ba52
jmp 0x38612
movq %r14, %rdi
callq 0x27920
movl $0x1, %ebp
jmp 0x386fc
leaq 0x114601(%rip), %rdi    # 0x14ccee
leaq 0x4020(%rsp), %rsi
xorl %eax, %eax
callq 0xfb6f2
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 0x28150