// File: tomfunkhouser[P]gaps/apps/msh2grd/msh2grd.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, "-sdf")) sdf = 1; 
      else if (!strcmp(*argv, "-spacing")) { argc--; argv++; grid_spacing = atof(*argv); }
      else if (!strcmp(*argv, "-min_resolution")) { argc--; argv++; min_resolution = atoi(*argv); }
      else if (!strcmp(*argv, "-max_resolution")) { argc--; argv++; max_resolution = atoi(*argv); }
      else { RNFail("Invalid program argument: %s", *argv); exit(1); }
    }
    else {
      if (!mesh_name) mesh_name = *argv;
      else if (!grid_name) grid_name = *argv;
      else { RNFail("Invalid program argument: %s", *argv); exit(1); }
    }
    argv++; argc--;
  }

  // Check mesh filename
  if (!mesh_name || !grid_name) {
    RNFail("Usage: msh2grd mesh grid [options]\n");
    return 0;
  }

  // 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 0x12781
movq 0x8(%rsp), %rax
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x12709
movq 0x8(%rsp), %rax
movq (%rax), %rdi
leaq 0x120a7c(%rip), %rsi    # 0x133040
callq 0xf700
cmpl $0x0, %eax
jne 0x125dd
movl $0x1, 0x165fa0(%rip)    # 0x178578
jmp 0x12707
movq 0x8(%rsp), %rax
movq (%rax), %rdi
leaq 0x120a57(%rip), %rsi    # 0x133043
callq 0xf700
cmpl $0x0, %eax
jne 0x12605
movl $0x1, 0x165f7c(%rip)    # 0x17857c
jmp 0x12705
movq 0x8(%rsp), %rax
movq (%rax), %rdi
leaq 0x120a34(%rip), %rsi    # 0x133048
callq 0xf700
cmpl $0x0, %eax
jne 0x12651
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 0xf640
movsd %xmm0, 0x15ceb4(%rip)   # 0x16f500
jmp 0x12703
movq 0x8(%rsp), %rax
movq (%rax), %rdi
leaq 0x1209f1(%rip), %rsi    # 0x133051
callq 0xf700
cmpl $0x0, %eax
jne 0x12698
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 0xf7b0
movl %eax, 0x15ce72(%rip)    # 0x16f508
jmp 0x12701
movq 0x8(%rsp), %rax
movq (%rax), %rdi
leaq 0x1209ba(%rip), %rsi    # 0x133061
callq 0xf700
cmpl $0x0, %eax
jne 0x126df
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 0xf7b0
movl %eax, 0x15ce2f(%rip)    # 0x16f50c
jmp 0x126ff
movq 0x8(%rsp), %rax
movq (%rax), %rsi
leaq 0x120983(%rip), %rdi    # 0x133071
movb $0x0, %al
callq 0xd4f30
movl $0x1, %edi
callq 0xf600
jmp 0x12701
jmp 0x12703
jmp 0x12705
jmp 0x12707
jmp 0x12763
cmpq $0x0, 0x165e57(%rip)    # 0x178568
jne 0x12724
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x165e46(%rip)    # 0x178568
jmp 0x12761
cmpq $0x0, 0x165e44(%rip)    # 0x178570
jne 0x1273f
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x165e33(%rip)    # 0x178570
jmp 0x1275f
movq 0x8(%rsp), %rax
movq (%rax), %rsi
leaq 0x120923(%rip), %rdi    # 0x133071
movb $0x0, %al
callq 0xd4f30
movl $0x1, %edi
callq 0xf600
jmp 0x12761
jmp 0x12763
movq 0x8(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x8(%rsp)
movl 0x10(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x10(%rsp)
jmp 0x12596
cmpq $0x0, 0x165ddf(%rip)    # 0x178568
je 0x12795
cmpq $0x0, 0x165ddd(%rip)    # 0x178570
jne 0x127ad
leaq 0x1208f2(%rip), %rdi    # 0x13308e
movb $0x0, %al
callq 0xd4f30
movl $0x0, 0x14(%rsp)
jmp 0x127b5
movl $0x1, 0x14(%rsp)
movl 0x14(%rsp), %eax
addq $0x18, %rsp
retq
nop