// File: tomfunkhouser[P]gaps/apps/conf2sfl/conf2sfl.cpp
// Function: ParseArgs(int, char**)
static int 
ParseArgs(int argc, char **argv)
{
  // Parse arguments
  argc--; argv++;
  while (argc > 0) {
    if ((*argv)[0] == '-') {
      if (!strcmp(*argv, "-v")) print_verbose = 1;
      else if (!strcmp(*argv, "-debug")) print_debug = 1;
      else if (!strcmp(*argv, "-create_planar_segments")) { create_planar_segments = TRUE; }
      else if (!strcmp(*argv, "-create_multiresolution_hierarchy")) create_multiresolution_hierarchy = TRUE;
      else if (!strcmp(*argv, "-max_image_resolution")) { argc--; argv++; max_image_resolution = atoi(*argv); }
      else if (!strcmp(*argv, "-max_depth")) { argc--; argv++; max_depth = atof(*argv); }
      else if (!strcmp(*argv, "-pixel_stride")) { argc--; argv++; pixel_stride = atoi(*argv); }
      else if (!strcmp(*argv, "-omit_corners")) omit_corners = 1;
      else if (!strcmp(*argv, "-load_image_at_index")) { argc--; argv++; load_images_starting_at_index = load_images_ending_at_index = atoi(*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, "-load_images_bbox")) {
        argc--; argv++; load_images_bbox[0][0] = atof(*argv);
        argc--; argv++; load_images_bbox[0][1] = atof(*argv);
        argc--; argv++; load_images_bbox[0][2] = atof(*argv);
        argc--; argv++; load_images_bbox[1][0] = atof(*argv);
        argc--; argv++; load_images_bbox[1][1] = atof(*argv);
        argc--; argv++; load_images_bbox[1][2] = atof(*argv);
      }      
      else {
        RNFail("Invalid program argument: %s", *argv);
        exit(1);
      }
      argv++; argc--;
    }
    else {
      if (!input_configuration_name) input_configuration_name = *argv;
      else if (!output_ssa_name) output_ssa_name = *argv;
      else if (!output_ssb_name) output_ssb_name = *argv;
      else { RNFail("Invalid program argument: %s", *argv); exit(1); }
      argv++; argc--;
    }
  }

  // Check filenames
  if (!input_configuration_name || !output_ssa_name || !output_ssb_name) {
    RNFail("Usage: conf2sfl inputconfigurationfile outputssafile outputssbfile [options]\n");
    return 0;
  }

  // Return OK status 
  return 1;
}

// Assembly:
subq $0x48, %rsp
movl %edi, 0x40(%rsp)
movq %rsi, 0x38(%rsp)
movl 0x40(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x40(%rsp)
movq 0x38(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x38(%rsp)
cmpl $0x0, 0x40(%rsp)
jle 0x1a12c
movq 0x38(%rsp), %rax
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x1a099
movq 0x38(%rsp), %rax
movq (%rax), %rdi
leaq 0x1e3510(%rip), %rsi    # 0x1fd084
callq 0x16a80
cmpl $0x0, %eax
jne 0x19b8d
movl $0x1, 0x24ec94(%rip)    # 0x26881c
jmp 0x1a07b
movq 0x38(%rsp), %rax
movq (%rax), %rdi
leaq 0x1e34eb(%rip), %rsi    # 0x1fd087
callq 0x16a80
cmpl $0x0, %eax
jne 0x19bb5
movl $0x1, 0x24ec70(%rip)    # 0x268820
jmp 0x1a079
movq 0x38(%rsp), %rax
movq (%rax), %rdi
leaq 0x1e34ca(%rip), %rsi    # 0x1fd08e
callq 0x16a80
cmpl $0x0, %eax
jne 0x19bdd
movl $0x1, 0x24ec4c(%rip)    # 0x268824
jmp 0x1a077
movq 0x38(%rsp), %rax
movq (%rax), %rdi
leaq 0x1e34ba(%rip), %rsi    # 0x1fd0a6
callq 0x16a80
cmpl $0x0, %eax
jne 0x19c05
movl $0x1, 0x24ec18(%rip)    # 0x268818
jmp 0x1a075
movq 0x38(%rsp), %rax
movq (%rax), %rdi
leaq 0x1e34b4(%rip), %rsi    # 0x1fd0c8
callq 0x16a80
cmpl $0x0, %eax
jne 0x19c4f
movl 0x40(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x40(%rsp)
movq 0x38(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
movq (%rax), %rdi
callq 0x16b40
movl %eax, 0x24ebde(%rip)    # 0x268828
jmp 0x1a073
movq 0x38(%rsp), %rax
movq (%rax), %rdi
leaq 0x1e3480(%rip), %rsi    # 0x1fd0de
callq 0x16a80
cmpl $0x0, %eax
jne 0x19c9b
movl 0x40(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x40(%rsp)
movq 0x38(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
movq (%rax), %rdi
callq 0x16950
movsd %xmm0, 0x24eb9a(%rip)   # 0x268830
jmp 0x1a071
movq 0x38(%rsp), %rax
movq (%rax), %rdi
leaq 0x1e343f(%rip), %rsi    # 0x1fd0e9
callq 0x16a80
cmpl $0x0, %eax
jne 0x19ce5
movl 0x40(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x40(%rsp)
movq 0x38(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
movq (%rax), %rdi
callq 0x16b40
movl %eax, 0x245a80(%rip)    # 0x25f760
jmp 0x1a06f
movq 0x38(%rsp), %rax
movq (%rax), %rdi
leaq 0x1e3403(%rip), %rsi    # 0x1fd0f7
callq 0x16a80
cmpl $0x0, %eax
jne 0x19d0d
movl $0x1, 0x24eb30(%rip)    # 0x268838
jmp 0x1a06d
movq 0x38(%rsp), %rax
movq (%rax), %rdi
leaq 0x1e33e9(%rip), %rsi    # 0x1fd105
callq 0x16a80
cmpl $0x0, %eax
jne 0x19d5d
movl 0x40(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x40(%rsp)
movq 0x38(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
movq (%rax), %rdi
callq 0x16b40
movl %eax, 0x245a12(%rip)    # 0x25f764
movl %eax, 0x24eae4(%rip)    # 0x26883c
jmp 0x1a06b
movq 0x38(%rsp), %rax
movq (%rax), %rdi
leaq 0x1e33ae(%rip), %rsi    # 0x1fd11a
callq 0x16a80
cmpl $0x0, %eax
jne 0x19da7
movl 0x40(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x40(%rsp)
movq 0x38(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
movq (%rax), %rdi
callq 0x16b40
movl %eax, 0x24ea9a(%rip)    # 0x26883c
jmp 0x1a069
movq 0x38(%rsp), %rax
movq (%rax), %rdi
leaq 0x1e3383(%rip), %rsi    # 0x1fd139
callq 0x16a80
cmpl $0x0, %eax
jne 0x19df1
movl 0x40(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x40(%rsp)
movq 0x38(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
movq (%rax), %rdi
callq 0x16b40
movl %eax, 0x245978(%rip)    # 0x25f764
jmp 0x1a067
movq 0x38(%rsp), %rax
movq (%rax), %rdi
leaq 0x1e3356(%rip), %rsi    # 0x1fd156
callq 0x16a80
cmpl $0x0, %eax
jne 0x19e3b
movl 0x40(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x40(%rsp)
movq 0x38(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
movq (%rax), %rdi
callq 0x16b40
movl %eax, 0x245932(%rip)    # 0x25f768
jmp 0x1a065
movq 0x38(%rsp), %rax
movq (%rax), %rdi
leaq 0x1e3322(%rip), %rsi    # 0x1fd16c
callq 0x16a80
cmpl $0x0, %eax
jne 0x1a043
movl 0x40(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x40(%rsp)
movq 0x38(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
movq (%rax), %rdi
callq 0x16950
movsd %xmm0, 0x8(%rsp)
leaq 0x24e93d(%rip), %rdi    # 0x2687c8
xorl %esi, %esi
callq 0x1ec30
movq %rax, %rdi
xorl %esi, %esi
callq 0x1ec70
movsd 0x8(%rsp), %xmm0
movsd %xmm0, (%rax)
movl 0x40(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x40(%rsp)
movq 0x38(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
movq (%rax), %rdi
callq 0x16950
movsd %xmm0, 0x10(%rsp)
leaq 0x24e8ef(%rip), %rdi    # 0x2687c8
xorl %esi, %esi
callq 0x1ec30
movq %rax, %rdi
movl $0x1, %esi
callq 0x1ec70
movsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rax)
movl 0x40(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x40(%rsp)
movq 0x38(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
movq (%rax), %rdi
callq 0x16950
movsd %xmm0, 0x18(%rsp)
leaq 0x24e89e(%rip), %rdi    # 0x2687c8
xorl %esi, %esi
callq 0x1ec30
movq %rax, %rdi
movl $0x2, %esi
callq 0x1ec70
movsd 0x18(%rsp), %xmm0
movsd %xmm0, (%rax)
movl 0x40(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x40(%rsp)
movq 0x38(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
movq (%rax), %rdi
callq 0x16950
movsd %xmm0, 0x20(%rsp)
leaq 0x24e84d(%rip), %rdi    # 0x2687c8
movl $0x1, %esi
callq 0x1ec30
movq %rax, %rdi
xorl %esi, %esi
callq 0x1ec70
movsd 0x20(%rsp), %xmm0
movsd %xmm0, (%rax)
movl 0x40(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x40(%rsp)
movq 0x38(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
movq (%rax), %rdi
callq 0x16950
movsd %xmm0, 0x28(%rsp)
leaq 0x24e7fc(%rip), %rdi    # 0x2687c8
movl $0x1, %esi
callq 0x1ec30
movq %rax, %rdi
movl $0x1, %esi
callq 0x1ec70
movsd 0x28(%rsp), %xmm0
movsd %xmm0, (%rax)
movl 0x40(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x40(%rsp)
movq 0x38(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
movq (%rax), %rdi
callq 0x16950
movsd %xmm0, 0x30(%rsp)
leaq 0x24e7a8(%rip), %rdi    # 0x2687c8
movl $0x1, %esi
callq 0x1ec30
movq %rax, %rdi
movl $0x2, %esi
callq 0x1ec70
movsd 0x30(%rsp), %xmm0
movsd %xmm0, (%rax)
jmp 0x1a063
movq 0x38(%rsp), %rax
movq (%rax), %rsi
leaq 0x1e312c(%rip), %rdi    # 0x1fd17e
movb $0x0, %al
callq 0x1779b0
movl $0x1, %edi
callq 0x168f0
jmp 0x1a065
jmp 0x1a067
jmp 0x1a069
jmp 0x1a06b
jmp 0x1a06d
jmp 0x1a06f
jmp 0x1a071
jmp 0x1a073
jmp 0x1a075
jmp 0x1a077
jmp 0x1a079
jmp 0x1a07b
movq 0x38(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x38(%rsp)
movl 0x40(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x40(%rsp)
jmp 0x1a127
cmpq $0x0, 0x24e75f(%rip)    # 0x268800
jne 0x1a0b4
movq 0x38(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x24e74e(%rip)    # 0x268800
jmp 0x1a10e
cmpq $0x0, 0x24e74c(%rip)    # 0x268808
jne 0x1a0cf
movq 0x38(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x24e73b(%rip)    # 0x268808
jmp 0x1a10c
cmpq $0x0, 0x24e739(%rip)    # 0x268810
jne 0x1a0ea
movq 0x38(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x24e728(%rip)    # 0x268810
jmp 0x1a10a
movq 0x38(%rsp), %rax
movq (%rax), %rsi
leaq 0x1e3085(%rip), %rdi    # 0x1fd17e
movb $0x0, %al
callq 0x1779b0
movl $0x1, %edi
callq 0x168f0
jmp 0x1a10c
jmp 0x1a10e
movq 0x38(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x38(%rsp)
movl 0x40(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x40(%rsp)
jmp 0x19b46
cmpq $0x0, 0x24e6cc(%rip)    # 0x268800
je 0x1a14a
cmpq $0x0, 0x24e6ca(%rip)    # 0x268808
je 0x1a14a
cmpq $0x0, 0x24e6c8(%rip)    # 0x268810
jne 0x1a162
leaq 0x1e304a(%rip), %rdi    # 0x1fd19b
movb $0x0, %al
callq 0x1779b0
movl $0x0, 0x44(%rsp)
jmp 0x1a16a
movl $0x1, 0x44(%rsp)
movl 0x44(%rsp), %eax
addq $0x48, %rsp
retq
nopw %cs:(%rax,%rax)