// File: tomfunkhouser[P]gaps/apps/conf2conf/conf2conf.cpp
// Function: ParseArgs(int, char**)
static int 
ParseArgs(int argc, char **argv)
{
  // Parse arguments (this has to mimic the code in main)
  argc--; argv++;
  while (argc > 0) {
    if ((*argv)[0] == '-') {
      if (!strcmp(*argv, "-v")) print_verbose = 1;
      else if (!strcmp(*argv, "-input_mesh")) { argc--; argv++; input_mesh_filename = *argv; }
      else if (!strcmp(*argv, "-input_depth_directory")) { argc--; argv++; input_depth_directory = *argv; }
      else if (!strcmp(*argv, "-input_color_directory")) { argc--; argv++; input_color_directory = *argv; }
      else if (!strcmp(*argv, "-input_texture_directory")) { argc--; argv++; input_texture_directory = *argv; }
      else if (!strcmp(*argv, "-output_depth_directory")) { argc--; argv++; output_depth_directory = *argv; }
      else if (!strcmp(*argv, "-output_color_directory")) { argc--; argv++; output_color_directory = *argv; }
      else if (!strcmp(*argv, "-output_texture_directory")) { argc--; argv++; output_texture_directory = *argv; }
      else if (!strcmp(*argv, "-load_images_starting_at_index")) { argc--; argv++; load_images_starting_at_index = atoi(*argv); }
      else if (!strcmp(*argv, "-load_images_ending_at_index")) { argc--; argv++; load_images_ending_at_index = atoi(*argv); }
      else if (!strcmp(*argv, "-load_every_kth_image")) { argc--; argv++; load_every_kth_image = atoi(*argv); }
      else if (!strcmp(*argv, "-write_every_kth_image")) { argc--; argv++; write_every_kth_image = atoi(*argv); }
      else if (!strcmp(*argv, "-texture_aggregation_method")) { argc--; argv++; texture_aggregation_method = atoi(*argv); }
      else if (!strcmp(*argv, "-texture_aggregation_weighting")) { argc--; argv++; texture_aggregation_weighting = atoi(*argv); }
      else if (!strcmp(*argv, "-texel_spacing")) { argc--; argv++; texel_spacing = atof(*argv); }
      else if (!strcmp(*argv, "-compute_surface_textures")) {}
      else if (!strcmp(*argv, "-negate_yz")) {}
      else if (!strcmp(*argv, "-transform")) { argc-=16; argv+=16; }
      else if (!strcmp(*argv, "-viewpoint_bbox")) {
        argc--; argv++; viewpoint_bbox[0][0] = atof(*argv);
        argc--; argv++; viewpoint_bbox[0][1] = atof(*argv);
        argc--; argv++; viewpoint_bbox[0][2] = atof(*argv);
        argc--; argv++; viewpoint_bbox[1][0] = atof(*argv);
        argc--; argv++; viewpoint_bbox[1][1] = atof(*argv);
        argc--; argv++; viewpoint_bbox[1][2] = atof(*argv);
      }    
      else if (!strcmp(*argv, "-observation_bbox")) {
        argc--; argv++; observation_bbox[0][0] = atof(*argv);
        argc--; argv++; observation_bbox[0][1] = atof(*argv);
        argc--; argv++; observation_bbox[0][2] = atof(*argv);
        argc--; argv++; observation_bbox[1][0] = atof(*argv);
        argc--; argv++; observation_bbox[1][1] = atof(*argv);
        argc--; argv++; observation_bbox[1][2] = atof(*argv);
      }    
      else { RNFail("Invalid program argument: %s", *argv); exit(1); }
      argv++; argc--;
    }
    else {
      if (!input_configuration_filename) input_configuration_filename = *argv;
      else if (!output_configuration_filename) output_configuration_filename = *argv;
      else { RNFail("Invalid program argument: %s", *argv); exit(1); }
      argv++; argc--;
    }
  }

  // Check filenames
  if (!input_configuration_filename || !output_configuration_filename) {
    RNFail("Usage: texture inputconfigurationfile outputconfigurationfile [options]\n");
    return 0;
  }

  // Return OK status 
  return 1;
}

// Assembly:
subq $0x78, %rsp
movl %edi, 0x70(%rsp)
movq %rsi, 0x68(%rsp)
movl 0x70(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x70(%rsp)
movq 0x68(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x68(%rsp)
cmpl $0x0, 0x70(%rsp)
jle 0x170ce
movq 0x68(%rsp), %rax
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x17058
movq 0x68(%rsp), %rax
movq (%rax), %rdi
leaq 0x14f8d4(%rip), %rsi    # 0x166038
callq 0x12a00
cmpl $0x0, %eax
jne 0x1677d
movl $0x1, 0x19b870(%rip)    # 0x1b1fe8
jmp 0x1703d
movq 0x68(%rsp), %rax
movq (%rax), %rdi
leaq 0x14f8d2(%rip), %rsi    # 0x16605e
callq 0x12a00
cmpl $0x0, %eax
jne 0x167c3
movl 0x70(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x70(%rsp)
movq 0x68(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x19b802(%rip)    # 0x1b1fc0
jmp 0x1703b
movq 0x68(%rsp), %rax
movq (%rax), %rdi
leaq 0x14f898(%rip), %rsi    # 0x16606a
callq 0x12a00
cmpl $0x0, %eax
jne 0x16809
movl 0x70(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x70(%rsp)
movq 0x68(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x19b7ec(%rip)    # 0x1b1ff0
jmp 0x17039
movq 0x68(%rsp), %rax
movq (%rax), %rdi
leaq 0x14f869(%rip), %rsi    # 0x166081
callq 0x12a00
cmpl $0x0, %eax
jne 0x1684f
movl 0x70(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x70(%rsp)
movq 0x68(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x19b7ae(%rip)    # 0x1b1ff8
jmp 0x17037
movq 0x68(%rsp), %rax
movq (%rax), %rdi
leaq 0x14f83a(%rip), %rsi    # 0x166098
callq 0x12a00
cmpl $0x0, %eax
jne 0x16895
movl 0x70(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x70(%rsp)
movq 0x68(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x19b770(%rip)    # 0x1b2000
jmp 0x17035
movq 0x68(%rsp), %rax
movq (%rax), %rdi
leaq 0x14f80d(%rip), %rsi    # 0x1660b1
callq 0x12a00
cmpl $0x0, %eax
jne 0x168db
movl 0x70(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x70(%rsp)
movq 0x68(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x19b732(%rip)    # 0x1b2008
jmp 0x17033
movq 0x68(%rsp), %rax
movq (%rax), %rdi
leaq 0x14f7df(%rip), %rsi    # 0x1660c9
callq 0x12a00
cmpl $0x0, %eax
jne 0x16921
movl 0x70(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x70(%rsp)
movq 0x68(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x19b6f4(%rip)    # 0x1b2010
jmp 0x17031
movq 0x68(%rsp), %rax
movq (%rax), %rdi
leaq 0x14f7b1(%rip), %rsi    # 0x1660e1
callq 0x12a00
cmpl $0x0, %eax
jne 0x16967
movl 0x70(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x70(%rsp)
movq 0x68(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x19b6b6(%rip)    # 0x1b2018
jmp 0x1702f
movq 0x68(%rsp), %rax
movq (%rax), %rdi
leaq 0x14f785(%rip), %rsi    # 0x1660fb
callq 0x12a00
cmpl $0x0, %eax
jne 0x169b1
movl 0x70(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x70(%rsp)
movq 0x68(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
movq (%rax), %rdi
callq 0x12ac0
movl %eax, 0x19b674(%rip)    # 0x1b2020
jmp 0x1702d
movq 0x68(%rsp), %rax
movq (%rax), %rdi
leaq 0x14f75a(%rip), %rsi    # 0x16611a
callq 0x12a00
cmpl $0x0, %eax
jne 0x169fb
movl 0x70(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x70(%rsp)
movq 0x68(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
movq (%rax), %rdi
callq 0x12ac0
movl %eax, 0x19ad0a(%rip)    # 0x1b1700
jmp 0x1702b
movq 0x68(%rsp), %rax
movq (%rax), %rdi
leaq 0x14f72d(%rip), %rsi    # 0x166137
callq 0x12a00
cmpl $0x0, %eax
jne 0x16a45
movl 0x70(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x70(%rsp)
movq 0x68(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
movq (%rax), %rdi
callq 0x12ac0
movl %eax, 0x19acc4(%rip)    # 0x1b1704
jmp 0x17029
movq 0x68(%rsp), %rax
movq (%rax), %rdi
leaq 0x14f6f9(%rip), %rsi    # 0x16614d
callq 0x12a00
cmpl $0x0, %eax
jne 0x16a8f
movl 0x70(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x70(%rsp)
movq 0x68(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
movq (%rax), %rdi
callq 0x12ac0
movl %eax, 0x19ac7e(%rip)    # 0x1b1708
jmp 0x17027
movq 0x68(%rsp), %rax
movq (%rax), %rdi
leaq 0x14f6c6(%rip), %rsi    # 0x166164
callq 0x12a00
cmpl $0x0, %eax
jne 0x16ad9
movl 0x70(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x70(%rsp)
movq 0x68(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
movq (%rax), %rdi
callq 0x12ac0
movl %eax, 0x19b550(%rip)    # 0x1b2024
jmp 0x17025
movq 0x68(%rsp), %rax
movq (%rax), %rdi
leaq 0x14f698(%rip), %rsi    # 0x166180
callq 0x12a00
cmpl $0x0, %eax
jne 0x16b23
movl 0x70(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x70(%rsp)
movq 0x68(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
movq (%rax), %rdi
callq 0x12ac0
movl %eax, 0x19abee(%rip)    # 0x1b170c
jmp 0x17023
movq 0x68(%rsp), %rax
movq (%rax), %rdi
leaq 0x14f66d(%rip), %rsi    # 0x16619f
callq 0x12a00
cmpl $0x0, %eax
jne 0x16b6f
movl 0x70(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x70(%rsp)
movq 0x68(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
movq (%rax), %rdi
callq 0x128e0
movsd %xmm0, 0x19b4be(%rip)   # 0x1b2028
jmp 0x17021
movq 0x68(%rsp), %rax
movq (%rax), %rdi
leaq 0x14f652(%rip), %rsi    # 0x1661d0
callq 0x12a00
cmpl $0x0, %eax
jne 0x16b8d
jmp 0x1701f
movq 0x68(%rsp), %rax
movq (%rax), %rdi
leaq 0x14f64e(%rip), %rsi    # 0x1661ea
callq 0x12a00
cmpl $0x0, %eax
jne 0x16bab
jmp 0x1701d
movq 0x68(%rsp), %rax
movq (%rax), %rdi
leaq 0x14f655(%rip), %rsi    # 0x16620f
callq 0x12a00
cmpl $0x0, %eax
jne 0x16be4
movl 0x70(%rsp), %eax
subl $0x10, %eax
movl %eax, 0x70(%rsp)
movq 0x68(%rsp), %rax
addq $0x80, %rax
movq %rax, 0x68(%rsp)
jmp 0x1701b
movq 0x68(%rsp), %rax
movq (%rax), %rdi
leaq 0x14f5bb(%rip), %rsi    # 0x1661ae
callq 0x12a00
cmpl $0x0, %eax
jne 0x16def
movl 0x70(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x70(%rsp)
movq 0x68(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
movq (%rax), %rdi
callq 0x128e0
movsd %xmm0, 0x38(%rsp)
leaq 0x19b34c(%rip), %rdi    # 0x1b1f80
xorl %esi, %esi
callq 0x19bc0
movq %rax, %rdi
xorl %esi, %esi
callq 0x19c00
movsd 0x38(%rsp), %xmm0
movsd %xmm0, (%rax)
movl 0x70(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x70(%rsp)
movq 0x68(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
movq (%rax), %rdi
callq 0x128e0
movsd %xmm0, 0x40(%rsp)
leaq 0x19b2fe(%rip), %rdi    # 0x1b1f80
xorl %esi, %esi
callq 0x19bc0
movq %rax, %rdi
movl $0x1, %esi
callq 0x19c00
movsd 0x40(%rsp), %xmm0
movsd %xmm0, (%rax)
movl 0x70(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x70(%rsp)
movq 0x68(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
movq (%rax), %rdi
callq 0x128e0
movsd %xmm0, 0x48(%rsp)
leaq 0x19b2ad(%rip), %rdi    # 0x1b1f80
xorl %esi, %esi
callq 0x19bc0
movq %rax, %rdi
movl $0x2, %esi
callq 0x19c00
movsd 0x48(%rsp), %xmm0
movsd %xmm0, (%rax)
movl 0x70(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x70(%rsp)
movq 0x68(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
movq (%rax), %rdi
callq 0x128e0
movsd %xmm0, 0x50(%rsp)
leaq 0x19b25c(%rip), %rdi    # 0x1b1f80
movl $0x1, %esi
callq 0x19bc0
movq %rax, %rdi
xorl %esi, %esi
callq 0x19c00
movsd 0x50(%rsp), %xmm0
movsd %xmm0, (%rax)
movl 0x70(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x70(%rsp)
movq 0x68(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
movq (%rax), %rdi
callq 0x128e0
movsd %xmm0, 0x58(%rsp)
leaq 0x19b20b(%rip), %rdi    # 0x1b1f80
movl $0x1, %esi
callq 0x19bc0
movq %rax, %rdi
movl $0x1, %esi
callq 0x19c00
movsd 0x58(%rsp), %xmm0
movsd %xmm0, (%rax)
movl 0x70(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x70(%rsp)
movq 0x68(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
movq (%rax), %rdi
callq 0x128e0
movsd %xmm0, 0x60(%rsp)
leaq 0x19b1b7(%rip), %rdi    # 0x1b1f80
movl $0x1, %esi
callq 0x19bc0
movq %rax, %rdi
movl $0x2, %esi
callq 0x19c00
movsd 0x60(%rsp), %xmm0
movsd %xmm0, (%rax)
jmp 0x17019
movq 0x68(%rsp), %rax
movq (%rax), %rdi
leaq 0x14f3c0(%rip), %rsi    # 0x1661be
callq 0x12a00
cmpl $0x0, %eax
jne 0x16ff7
movl 0x70(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x70(%rsp)
movq 0x68(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
movq (%rax), %rdi
callq 0x128e0
movsd %xmm0, 0x8(%rsp)
leaq 0x19b109(%rip), %rdi    # 0x1b1f48
xorl %esi, %esi
callq 0x19bc0
movq %rax, %rdi
xorl %esi, %esi
callq 0x19c00
movsd 0x8(%rsp), %xmm0
movsd %xmm0, (%rax)
movl 0x70(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x70(%rsp)
movq 0x68(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
movq (%rax), %rdi
callq 0x128e0
movsd %xmm0, 0x10(%rsp)
leaq 0x19b0bb(%rip), %rdi    # 0x1b1f48
xorl %esi, %esi
callq 0x19bc0
movq %rax, %rdi
movl $0x1, %esi
callq 0x19c00
movsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rax)
movl 0x70(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x70(%rsp)
movq 0x68(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
movq (%rax), %rdi
callq 0x128e0
movsd %xmm0, 0x18(%rsp)
leaq 0x19b06a(%rip), %rdi    # 0x1b1f48
xorl %esi, %esi
callq 0x19bc0
movq %rax, %rdi
movl $0x2, %esi
callq 0x19c00
movsd 0x18(%rsp), %xmm0
movsd %xmm0, (%rax)
movl 0x70(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x70(%rsp)
movq 0x68(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
movq (%rax), %rdi
callq 0x128e0
movsd %xmm0, 0x20(%rsp)
leaq 0x19b019(%rip), %rdi    # 0x1b1f48
movl $0x1, %esi
callq 0x19bc0
movq %rax, %rdi
xorl %esi, %esi
callq 0x19c00
movsd 0x20(%rsp), %xmm0
movsd %xmm0, (%rax)
movl 0x70(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x70(%rsp)
movq 0x68(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
movq (%rax), %rdi
callq 0x128e0
movsd %xmm0, 0x28(%rsp)
leaq 0x19afc8(%rip), %rdi    # 0x1b1f48
movl $0x1, %esi
callq 0x19bc0
movq %rax, %rdi
movl $0x1, %esi
callq 0x19c00
movsd 0x28(%rsp), %xmm0
movsd %xmm0, (%rax)
movl 0x70(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x70(%rsp)
movq 0x68(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
movq (%rax), %rdi
callq 0x128e0
movsd %xmm0, 0x30(%rsp)
leaq 0x19af74(%rip), %rdi    # 0x1b1f48
movl $0x1, %esi
callq 0x19bc0
movq %rax, %rdi
movl $0x2, %esi
callq 0x19c00
movsd 0x30(%rsp), %xmm0
movsd %xmm0, (%rax)
jmp 0x17017
movq 0x68(%rsp), %rax
movq (%rax), %rsi
leaq 0x14f214(%rip), %rdi    # 0x16621a
movb $0x0, %al
callq 0xdf990
movl $0x1, %edi
callq 0x12880
jmp 0x17019
jmp 0x1701b
jmp 0x1701d
jmp 0x1701f
jmp 0x17021
jmp 0x17023
jmp 0x17025
jmp 0x17027
jmp 0x17029
jmp 0x1702b
jmp 0x1702d
jmp 0x1702f
jmp 0x17031
jmp 0x17033
jmp 0x17035
jmp 0x17037
jmp 0x17039
jmp 0x1703b
jmp 0x1703d
movq 0x68(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x68(%rsp)
movl 0x70(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x70(%rsp)
jmp 0x170c9
cmpq $0x0, 0x19af58(%rip)    # 0x1b1fb8
jne 0x17073
movq 0x68(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x19af47(%rip)    # 0x1b1fb8
jmp 0x170b0
cmpq $0x0, 0x19af65(%rip)    # 0x1b1fe0
jne 0x1708e
movq 0x68(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x19af54(%rip)    # 0x1b1fe0
jmp 0x170ae
movq 0x68(%rsp), %rax
movq (%rax), %rsi
leaq 0x14f17d(%rip), %rdi    # 0x16621a
movb $0x0, %al
callq 0xdf990
movl $0x1, %edi
callq 0x12880
jmp 0x170b0
movq 0x68(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x68(%rsp)
movl 0x70(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x70(%rsp)
jmp 0x16736
cmpq $0x0, 0x19aee2(%rip)    # 0x1b1fb8
je 0x170e2
cmpq $0x0, 0x19af00(%rip)    # 0x1b1fe0
jne 0x170fa
leaq 0x14f14e(%rip), %rdi    # 0x166237
movb $0x0, %al
callq 0xdf990
movl $0x0, 0x74(%rsp)
jmp 0x17102
movl $0x1, 0x74(%rsp)
movl 0x74(%rsp), %eax
addq $0x78, %rsp
retq
nopl (%rax,%rax)