// File: tomfunkhouser[P]gaps/apps/sfl2pts/sfl2pts.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, "-omit_corners")) omit_corners = 1; 
      else if (!strcmp(*argv, "-dont_omit_corners")) omit_corners = 0; 
      else if (!strcmp(*argv, "-omit_boundaries")) omit_boundaries = 1; 
      else if (!strcmp(*argv, "-dont_omit_boundaries")) omit_boundaries = 0; 
      else if (!strcmp(*argv, "-scale_normals_by_confidence")) scale_normals_by_confidence = 1; 
      else if (!strcmp(*argv, "-dont_scale_normals_by_confidence")) scale_normals_by_confidence = 0; 
      else if (!strcmp(*argv, "-sample_by_confidence")) sample_by_confidence = 1; 
      else if (!strcmp(*argv, "-dont_sample_by_confidence")) sample_by_confidence = 0; 
      else if (!strcmp(*argv, "-sample_probability")) { argc--; argv++; sample_probability = atof(*argv); }
      else if (!strcmp(*argv, "-load_every_kth_image")) { argc--; argv++; load_every_kth_image = atoi(*argv); }
      else if (!strcmp(*argv, "-load_every_kth_pixel")) { argc--; argv++; load_every_kth_pixel = atoi(*argv); }
      else if (!strcmp(*argv, "-max_points")) { argc--; argv++; max_points = atoi(*argv); }
      else if (!strcmp(*argv, "-max_depth")) { argc--; argv++; max_depth = atof(*argv); }
      else { RNFail("Invalid program argument: %s", *argv); exit(1); }
      argv++; argc--;
    }
    else {
      if (!input_surfel_scene_name) input_surfel_scene_name = *argv;
      else if (!input_surfel_database_name) input_surfel_database_name = *argv;
      else if (!output_points_name) output_points_name = *argv;
      else { RNFail("Invalid program argument: %s", *argv); exit(1); }
      argv++; argc--;
    }
  }

  // Check file names
  if (!input_surfel_scene_name || !input_surfel_database_name || !output_points_name) {
    RNFail("Usage: sfl2pts scenefile databasefile pointsfile [options]\n");
    return FALSE;
  }
  
  // Return OK status 
  return 1;
}

// Assembly:
subq $0x18, %rsp
movl %edi, 0x10(%rsp)
movq %rsi, 0x8(%rsp)
movl 0x10(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x10(%rsp)
movq 0x8(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x8(%rsp)
cmpl $0x0, 0x10(%rsp)
jle 0x16cc8
movq 0x8(%rsp), %rax
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x16c35
movq 0x8(%rsp), %rax
movq (%rax), %rdi
leaq 0x18f71c(%rip), %rsi    # 0x1a6030
callq 0x137e0
cmpl $0x0, %eax
jne 0x1692d
movl $0x1, 0x1e8ea0(%rip)    # 0x1ff7c8
jmp 0x16c17
movq 0x8(%rsp), %rax
movq (%rax), %rdi
leaq 0x18f6f7(%rip), %rsi    # 0x1a6033
callq 0x137e0
cmpl $0x0, %eax
jne 0x16955
movl $0x1, 0x1e8e7c(%rip)    # 0x1ff7cc
jmp 0x16c15
movq 0x8(%rsp), %rax
movq (%rax), %rdi
leaq 0x18f6dd(%rip), %rsi    # 0x1a6041
callq 0x137e0
cmpl $0x0, %eax
jne 0x1697d
movl $0x0, 0x1e8e54(%rip)    # 0x1ff7cc
jmp 0x16c13
movq 0x8(%rsp), %rax
movq (%rax), %rdi
leaq 0x18f6c8(%rip), %rsi    # 0x1a6054
callq 0x137e0
cmpl $0x0, %eax
jne 0x169a5
movl $0x1, 0x1e8e30(%rip)    # 0x1ff7d0
jmp 0x16c11
movq 0x8(%rsp), %rax
movq (%rax), %rdi
leaq 0x18f6b1(%rip), %rsi    # 0x1a6065
callq 0x137e0
cmpl $0x0, %eax
jne 0x169cd
movl $0x0, 0x1e8e08(%rip)    # 0x1ff7d0
jmp 0x16c0f
movq 0x8(%rsp), %rax
movq (%rax), %rdi
leaq 0x18f69f(%rip), %rsi    # 0x1a607b
callq 0x137e0
cmpl $0x0, %eax
jne 0x169f5
movl $0x1, 0x1dfba0(%rip)    # 0x1f6590
jmp 0x16c0d
movq 0x8(%rsp), %rax
movq (%rax), %rdi
leaq 0x18f694(%rip), %rsi    # 0x1a6098
callq 0x137e0
cmpl $0x0, %eax
jne 0x16a1d
movl $0x0, 0x1dfb78(%rip)    # 0x1f6590
jmp 0x16c0b
movq 0x8(%rsp), %rax
movq (%rax), %rdi
leaq 0x18f68e(%rip), %rsi    # 0x1a60ba
callq 0x137e0
cmpl $0x0, %eax
jne 0x16a45
movl $0x1, 0x1e8d94(%rip)    # 0x1ff7d4
jmp 0x16c09
movq 0x8(%rsp), %rax
movq (%rax), %rdi
leaq 0x18f67c(%rip), %rsi    # 0x1a60d0
callq 0x137e0
cmpl $0x0, %eax
jne 0x16a6d
movl $0x0, 0x1e8d6c(%rip)    # 0x1ff7d4
jmp 0x16c07
movq 0x8(%rsp), %rax
movq (%rax), %rdi
leaq 0x18f66f(%rip), %rsi    # 0x1a60eb
callq 0x137e0
cmpl $0x0, %eax
jne 0x16ab9
movl 0x10(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x10(%rsp)
movq 0x8(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
movq (%rax), %rdi
callq 0x13710
movsd %xmm0, 0x1dfad4(%rip)   # 0x1f6588
jmp 0x16c05
movq 0x8(%rsp), %rax
movq (%rax), %rdi
leaq 0x18f637(%rip), %rsi    # 0x1a60ff
callq 0x137e0
cmpl $0x0, %eax
jne 0x16b03
movl 0x10(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x10(%rsp)
movq 0x8(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
movq (%rax), %rdi
callq 0x13890
movl %eax, 0x1dfa82(%rip)    # 0x1f6580
jmp 0x16c03
movq 0x8(%rsp), %rax
movq (%rax), %rdi
leaq 0x18f603(%rip), %rsi    # 0x1a6115
callq 0x137e0
cmpl $0x0, %eax
jne 0x16b4d
movl 0x10(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x10(%rsp)
movq 0x8(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
movq (%rax), %rdi
callq 0x13890
movl %eax, 0x1dfa3c(%rip)    # 0x1f6584
jmp 0x16c01
movq 0x8(%rsp), %rax
movq (%rax), %rdi
leaq 0x18f5cf(%rip), %rsi    # 0x1a612b
callq 0x137e0
cmpl $0x0, %eax
jne 0x16b94
movl 0x10(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x10(%rsp)
movq 0x8(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
movq (%rax), %rdi
callq 0x13890
movl %eax, 0x1e8c26(%rip)    # 0x1ff7b8
jmp 0x16bff
movq 0x8(%rsp), %rax
movq (%rax), %rdi
leaq 0x18f594(%rip), %rsi    # 0x1a6137
callq 0x137e0
cmpl $0x0, %eax
jne 0x16bdd
movl 0x10(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x10(%rsp)
movq 0x8(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
movq (%rax), %rdi
callq 0x13710
movsd %xmm0, 0x1e8bfd(%rip)   # 0x1ff7d8
jmp 0x16bfd
movq 0x8(%rsp), %rax
movq (%rax), %rsi
leaq 0x18f556(%rip), %rdi    # 0x1a6142
movb $0x0, %al
callq 0x148290
movl $0x1, %edi
callq 0x136b0
jmp 0x16bff
jmp 0x16c01
jmp 0x16c03
jmp 0x16c05
jmp 0x16c07
jmp 0x16c09
jmp 0x16c0b
jmp 0x16c0d
jmp 0x16c0f
jmp 0x16c11
jmp 0x16c13
jmp 0x16c15
jmp 0x16c17
movq 0x8(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x8(%rsp)
movl 0x10(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x10(%rsp)
jmp 0x16cc3
cmpq $0x0, 0x1e8b6b(%rip)    # 0x1ff7a8
jne 0x16c50
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x1e8b5a(%rip)    # 0x1ff7a8
jmp 0x16caa
cmpq $0x0, 0x1e8b58(%rip)    # 0x1ff7b0
jne 0x16c6b
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x1e8b47(%rip)    # 0x1ff7b0
jmp 0x16ca8
cmpq $0x0, 0x1e8b4d(%rip)    # 0x1ff7c0
jne 0x16c86
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x1e8b3c(%rip)    # 0x1ff7c0
jmp 0x16ca6
movq 0x8(%rsp), %rax
movq (%rax), %rsi
leaq 0x18f4ad(%rip), %rdi    # 0x1a6142
movb $0x0, %al
callq 0x148290
movl $0x1, %edi
callq 0x136b0
jmp 0x16ca8
jmp 0x16caa
movq 0x8(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x8(%rsp)
movl 0x10(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x10(%rsp)
jmp 0x168e6
cmpq $0x0, 0x1e8ad8(%rip)    # 0x1ff7a8
je 0x16ce6
cmpq $0x0, 0x1e8ad6(%rip)    # 0x1ff7b0
je 0x16ce6
cmpq $0x0, 0x1e8adc(%rip)    # 0x1ff7c0
jne 0x16cfe
leaq 0x18f472(%rip), %rdi    # 0x1a615f
movb $0x0, %al
callq 0x148290
movl $0x0, 0x14(%rsp)
jmp 0x16d06
movl $0x1, 0x14(%rsp)
movl 0x14(%rsp), %eax
addq $0x18, %rsp
retq
nop