// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/apps/grd2txt/grd2txt.cpp
// Function: main
static int 
ParseArgs(int argc, char **argv)
{
  // Check number of arguments
  if (argc < 2) {
    printf("Usage: grd2txt gridfile [txtfile] [-v]\n");
    exit(0);
  }

  // Parse arguments
  argc--; argv++;
  while (argc > 0) {
    if ((*argv)[0] == '-') {
      if (!strcmp(*argv, "-v")) { 
        print_verbose = 1; 
      }
      else { 
        RNFail("Invalid program argument: %s", *argv); 
        exit(1); 
      }
    }
    else {
      if (!grid_name) grid_name = *argv;
      else if (!txt_name) txt_name = *argv;
      else { 
        RNFail("Invalid program argument: %s", *argv); 
        exit(1); 
      }
    }
    argv++; argc--;
  }

  // Check grid filename
  if (!grid_name) {
    RNFail("You did not specify a grid file.\n");
    return 0;
  }

  // Return OK status 
  return 1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
cmpl $0x2, %edi
jl 0x10d38
movq 0xd40d3(%rip), %r14     # 0xe4bf8
movq 0xd40d4(%rip), %rcx     # 0xe4c00
incl %edi
addq $0x8, %rsi
movq (%rsi), %rax
cmpb $0x2d, (%rax)
jne 0x10b57
cmpb $0x76, 0x1(%rax)
jne 0x10d1d
cmpb $0x0, 0x2(%rax)
jne 0x10d1d
movb $0x1, 0xd40b3(%rip)     # 0xe4c08
jmp 0x10b7b
testq %r14, %r14
je 0x10b71
testq %rcx, %rcx
jne 0x10d1d
movq %rax, 0xd4094(%rip)     # 0xe4c00
movq %rax, %rcx
jmp 0x10b7b
movq %rax, 0xd4080(%rip)     # 0xe4bf8
movq %rax, %r14
decl %edi
addq $0x8, %rsi
cmpl $0x2, %edi
ja 0x10b32
testq %r14, %r14
je 0x10d4b
movq %rsp, %rbx
movq %rbx, %rdi
callq 0x6eadc
movq %rbx, %rdi
xorl %esi, %esi
callq 0xe760
movl $0x250, %edi            # imm = 0x250
callq 0xe440
movq %rax, %rbx
movq %rax, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x10d98
movq %rbx, %rdi
movq %r14, %rsi
callq 0x18542
testl %eax, %eax
je 0x10d5b
cmpb $0x1, 0xd402f(%rip)     # 0xe4c08
jne 0x10c57
leaq 0x9050e(%rip), %rdi     # 0xa10f0
callq 0xe6f0
movq %rsp, %rdi
callq 0x6eb3e
leaq 0x90469(%rip), %rdi     # 0xa105f
movb $0x1, %al
callq 0xe070
movl 0x238(%rbx), %esi
movl 0x23c(%rbx), %edx
movl 0x240(%rbx), %ecx
leaq 0x90460(%rip), %rdi     # 0xa1076
xorl %eax, %eax
callq 0xe070
movq %rbx, %rdi
callq 0x119b8
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x10c35
sqrtsd %xmm0, %xmm0
jmp 0x10c3a
callq 0xe340
leaq 0x9044c(%rip), %rdi     # 0xa108d
movb $0x1, %al
callq 0xe070
movq 0xd3321(%rip), %rax     # 0xe3f70
movq (%rax), %rdi
callq 0xe520
movq 0xd3fa2(%rip), %r14     # 0xe4c00
movq %rsp, %r15
movq %r15, %rdi
callq 0x6eadc
movq %r15, %rdi
xorl %esi, %esi
callq 0xe760
testq %r14, %r14
je 0x10ca8
leaq 0x94dc5(%rip), %rsi     # 0xa5a44
movq %r14, %rdi
callq 0xe530
testq %rax, %rax
je 0x10d64
movq %rax, %r15
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1c404
movq %r15, %rdi
callq 0xe430
jmp 0x10cba
movq 0xd32c1(%rip), %rax     # 0xe3f70
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x1c404
cmpb $0x1, 0xd3f47(%rip)     # 0xe4c08
jne 0x10d08
leaq 0x90434(%rip), %rdi     # 0xa10fe
callq 0xe6f0
movq %rsp, %rdi
callq 0x6eb3e
leaq 0x90381(%rip), %rdi     # 0xa105f
movb $0x1, %al
callq 0xe070
movl 0x24c(%rbx), %esi
leaq 0x903c6(%rip), %rdi     # 0xa10b8
xorl %eax, %eax
callq 0xe070
movq 0xd3270(%rip), %rax     # 0xe3f70
movq (%rax), %rdi
callq 0xe520
cmpl $0x0, 0x24c(%rbx)
je 0x10d75
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
leaq 0x902e0(%rip), %rdi     # 0xa1004
movq %rax, %rsi
xorl %eax, %eax
callq 0x7123e
movl $0x1, %edi
callq 0xe550
leaq 0x9038a(%rip), %rdi     # 0xa10c9
callq 0xe6f0
xorl %edi, %edi
callq 0xe550
leaq 0x902cf(%rip), %rdi     # 0xa1021
xorl %eax, %eax
callq 0x7123e
jmp 0x10d75
leaq 0x902e1(%rip), %rdi     # 0xa1043
jmp 0x10d6b
leaq 0x90331(%rip), %rdi     # 0xa109c
movq %r14, %rsi
xorl %eax, %eax
callq 0x7123e
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0xe550
movq %rax, %r14
movl $0x250, %esi            # imm = 0x250
movq %rbx, %rdi
callq 0xe450
movq %r14, %rdi
callq 0xe7e0
nop