// File: tomfunkhouser[P]gaps/apps/grd2pts/grd2pts.cpp
// Function: ParseArgs(int, char**)
static int 
ParseArgs(int argc, char **argv)
{
  // Check number of arguments
  if ((argc == 2) && (*argv[1] == '-')) {
    printf("Usage: grd2pts gridfile [gridfiles] pointfile\n");
    exit(0);
  }

  // Parse arguments
  argc--; argv++;
  while (argc > 0) {
    if ((*argv)[0] == '-') {
      if (!strcmp(*argv, "-v")) print_verbose = TRUE; 
      else if (!strcmp(*argv, "-ascii")) ascii = TRUE; 
      else if (!strcmp(*argv, "-npoints")) { argv++; argc--; npoints = atoi(*argv); }
      else if (!strcmp(*argv, "-min_spacing")) { argv++; argc--; min_spacing = atof(*argv); }
      else if (!strcmp(*argv, "-sigma")) { argv++; argc--; sigma = atof(*argv); }
      else if (!strcmp(*argv, "-local_maxima_only")) local_maxima_only = TRUE; 
      else { 
        RNFail("Invalid program argument: %s\n", *argv); 
        exit(1); 
      }
    }
    else {
      grid_names.Insert(*argv);
    }
    argv++; argc--;
  }

  // Check grid filenames
  if (grid_names.IsEmpty()) {
    RNFail("You did not specify any files.\n");
    return 0;
  }

  // Check points filename
  if (grid_names.NEntries() < 2) {
    RNFail("You did not specify a points file.\n");
    return 0;
  }

  // Get points filename
  points_name = grid_names.Tail();
  grid_names.RemoveTail();

  // Return OK status 
  return 1;
}

// Assembly:
subq $0x18, %rsp
movl %edi, 0x10(%rsp)
movq %rsi, 0x8(%rsp)
cmpl $0x2, 0x10(%rsp)
jne 0x12afa
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x12afa
leaq 0x1215ce(%rip), %rdi    # 0x1340ba
movb $0x0, %al
callq 0xf070
xorl %edi, %edi
callq 0xf600
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 0x12ce4
movq 0x8(%rsp), %rax
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x12cb2
movq 0x8(%rsp), %rax
movq (%rax), %rdi
leaq 0x1215a8(%rip), %rsi    # 0x1340e9
callq 0xf700
cmpl $0x0, %eax
jne 0x12b5a
movl $0x1, 0x166a07(%rip)    # 0x17955c
jmp 0x12cb0
movq 0x8(%rsp), %rax
movq (%rax), %rdi
leaq 0x121583(%rip), %rsi    # 0x1340ec
callq 0xf700
cmpl $0x0, %eax
jne 0x12b82
movl $0x1, 0x1669db(%rip)    # 0x179558
jmp 0x12cae
movq 0x8(%rsp), %rax
movq (%rax), %rdi
leaq 0x121562(%rip), %rsi    # 0x1340f3
callq 0xf700
cmpl $0x0, %eax
jne 0x12bcc
movq 0x8(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x8(%rsp)
movl 0x10(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x10(%rsp)
movq 0x8(%rsp), %rax
movq (%rax), %rdi
callq 0xf7b0
movl %eax, 0x15d939(%rip)    # 0x170500
jmp 0x12cac
movq 0x8(%rsp), %rax
movq (%rax), %rdi
leaq 0x121521(%rip), %rsi    # 0x1340fc
callq 0xf700
cmpl $0x0, %eax
jne 0x12c18
movq 0x8(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x8(%rsp)
movl 0x10(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x10(%rsp)
movq 0x8(%rsp), %rax
movq (%rax), %rdi
callq 0xf640
movsd %xmm0, 0x16695d(%rip)   # 0x179570
jmp 0x12caa
movq 0x8(%rsp), %rax
movq (%rax), %rdi
leaq 0x1214e2(%rip), %rsi    # 0x134109
callq 0xf700
cmpl $0x0, %eax
jne 0x12c61
movq 0x8(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x8(%rsp)
movl 0x10(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x10(%rsp)
movq 0x8(%rsp), %rax
movq (%rax), %rdi
callq 0xf640
movsd %xmm0, 0x166901(%rip)   # 0x179560
jmp 0x12ca8
movq 0x8(%rsp), %rax
movq (%rax), %rdi
leaq 0x1214a0(%rip), %rsi    # 0x134110
callq 0xf700
cmpl $0x0, %eax
jne 0x12c86
movl $0x1, 0x1668e4(%rip)    # 0x179568
jmp 0x12ca6
movq 0x8(%rsp), %rax
movq (%rax), %rsi
leaq 0x12148e(%rip), %rdi    # 0x134123
movb $0x0, %al
callq 0xd5a50
movl $0x1, %edi
callq 0xf600
jmp 0x12ca8
jmp 0x12caa
jmp 0x12cac
jmp 0x12cae
jmp 0x12cb0
jmp 0x12cc6
movq 0x8(%rsp), %rax
movq (%rax), %rsi
leaq 0x166887(%rip), %rdi    # 0x179548
callq 0x140b0
movq 0x8(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x8(%rsp)
movl 0x10(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x10(%rsp)
jmp 0x12b13
leaq 0x16685d(%rip), %rdi    # 0x179548
callq 0x140e0
cmpl $0x0, %eax
je 0x12d0d
leaq 0x121445(%rip), %rdi    # 0x134141
movb $0x0, %al
callq 0xd5a50
movl $0x0, 0x14(%rsp)
jmp 0x12d5d
leaq 0x166834(%rip), %rdi    # 0x179548
callq 0x14000
cmpl $0x2, %eax
jge 0x12d36
leaq 0x12143c(%rip), %rdi    # 0x134161
movb $0x0, %al
callq 0xd5a50
movl $0x0, 0x14(%rsp)
jmp 0x12d5d
leaq 0x16680b(%rip), %rdi    # 0x179548
callq 0x14100
movq %rax, 0x16682f(%rip)    # 0x179578
leaq 0x1667f8(%rip), %rdi    # 0x179548
callq 0x14110
movl $0x1, 0x14(%rsp)
movl 0x14(%rsp), %eax
addq $0x18, %rsp
retq
nopw %cs:(%rax,%rax)