// File: tomfunkhouser[P]gaps/apps/prpview/prpview.cpp
// Function: ParseArgs(int, char**)
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, "-points")) { argc--; argv++; points_name = *argv; show_points = 1; }
      else if (!strcmp(*argv, "-image")) { argc--; argv++; image_name = *argv; }
      else if (!strcmp(*argv, "-no_statistics")) { show_statistics = 0; }
      else if (!strcmp(*argv, "-faces")) { show_faces = 1; show_values = 0; }
      else if (!strcmp(*argv, "-redness")) { color_with_redness = 1; }
      else if (!strcmp(*argv, "-flip_color_range")) { flip_color_range = 1; }
      else if (!strcmp(*argv, "-labels")) { color_with_labels = 1; }
      else if (!strcmp(*argv, "-back")) { show_backfacing = 1; }
      else if (!strcmp(*argv, "-property_index")) { 
        argv++; argc--; initial_property_index = atoi(*argv);
      }
      else if (!strcmp(*argv, "-value_range")) { 
        RNScalar min_value, max_value;
        argv++; argc--; min_value = atof(*argv);
        argv++; argc--; max_value = atof(*argv);
        input_value_range.Reset(min_value, max_value);
      }
      else if (!strcmp(*argv, "-origin")) {
        RNCoord x, y, z;
        argv++; argc--; x = atof(*argv);
        argv++; argc--; y = atof(*argv);
        argv++; argc--; z = atof(*argv);
        initial_world_origin.Reset(x, y, z);
      }
      else if (!strcmp(*argv, "-camera")) {
        RNCoord x, y, z, tx, ty, tz, ux, uy, uz;
        argv++; argc--; x = atof(*argv);
        argv++; argc--; y = atof(*argv);
        argv++; argc--; z = atof(*argv);
        argv++; argc--; tx = atof(*argv);
        argv++; argc--; ty = atof(*argv);
        argv++; argc--; tz = atof(*argv);
        argv++; argc--; ux = atof(*argv);
        argv++; argc--; uy = atof(*argv);
        argv++; argc--; uz = atof(*argv);
        initial_camera_origin = R3Point(x, y, z);
        initial_camera_towards.Reset(tx, ty, tz);
        initial_camera_up.Reset(ux, uy, uz);
        initial_camera = TRUE;
      }
      else { RNFail("Invalid program argument: %s", *argv); exit(1); }
      argv++; argc--;
    }
    else {
      if (!mesh_name) mesh_name = *argv;
      else if (!properties_name) properties_name = *argv;
      else { RNFail("Invalid program argument: %s", *argv); exit(1); }
      argv++; argc--;
    }
  }

  // Check mesh filename
  if (!mesh_name || !properties_name) {
    RNFail("Usage: prpview meshfile propertiesfile.\n");
    return 0;
  }

  // Return OK status 
  return 1;
}

// Assembly:
subq $0x98, %rsp
movl %edi, 0x90(%rsp)
movq %rsi, 0x88(%rsp)
movl 0x90(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x90(%rsp)
movq 0x88(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x88(%rsp)
cmpl $0x0, 0x90(%rsp)
jle 0x29b8e
movq 0x88(%rsp), %rax
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x29b03
movq 0x88(%rsp), %rax
movq (%rax), %rdi
leaq 0x16ce9e(%rip), %rsi    # 0x1962b0
callq 0x22ea0
cmpl $0x0, %eax
jne 0x2942b
movl $0x1, 0x1db8ee(%rip)    # 0x204d14
jmp 0x29ad9
movq 0x88(%rsp), %rax
movq (%rax), %rdi
leaq 0x16ce76(%rip), %rsi    # 0x1962b3
callq 0x22ea0
cmpl $0x0, %eax
jne 0x2948d
movl 0x90(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x90(%rsp)
movq 0x88(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x88(%rsp)
movq 0x88(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x1db89a(%rip)    # 0x204d18
movl $0x1, 0x1db810(%rip)    # 0x204c98
jmp 0x29ad7
movq 0x88(%rsp), %rax
movq (%rax), %rdi
leaq 0x16ce1c(%rip), %rsi    # 0x1962bb
callq 0x22ea0
cmpl $0x0, %eax
jne 0x294e5
movl 0x90(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x90(%rsp)
movq 0x88(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x88(%rsp)
movq 0x88(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x1db7f0(%rip)    # 0x204cd0
jmp 0x29ad5
movq 0x88(%rsp), %rax
movq (%rax), %rdi
leaq 0x16cdcb(%rip), %rsi    # 0x1962c2
callq 0x22ea0
cmpl $0x0, %eax
jne 0x29510
movl $0x0, 0x1d55b1(%rip)    # 0x1feabc
jmp 0x29ad3
movq 0x88(%rsp), %rax
movq (%rax), %rdi
leaq 0x16cdaf(%rip), %rsi    # 0x1962d1
callq 0x22ea0
cmpl $0x0, %eax
jne 0x29545
movl $0x1, 0x1d557a(%rip)    # 0x1feab0
movl $0x0, 0x1d5574(%rip)    # 0x1feab4
jmp 0x29ad1
movq 0x88(%rsp), %rax
movq (%rax), %rdi
leaq 0x16cd81(%rip), %rsi    # 0x1962d8
callq 0x22ea0
cmpl $0x0, %eax
jne 0x29570
movl $0x1, 0x1db731(%rip)    # 0x204c9c
jmp 0x29acf
movq 0x88(%rsp), %rax
movq (%rax), %rdi
leaq 0x16cd5f(%rip), %rsi    # 0x1962e1
callq 0x22ea0
cmpl $0x0, %eax
jne 0x2959b
movl $0x1, 0x1db78a(%rip)    # 0x204d20
jmp 0x29acd
movq 0x88(%rsp), %rax
movq (%rax), %rdi
leaq 0x16cd46(%rip), %rsi    # 0x1962f3
callq 0x22ea0
cmpl $0x0, %eax
jne 0x295c6
movl $0x1, 0x1db763(%rip)    # 0x204d24
jmp 0x29acb
movq 0x88(%rsp), %rax
movq (%rax), %rdi
leaq 0x16cd23(%rip), %rsi    # 0x1962fb
callq 0x22ea0
cmpl $0x0, %eax
jne 0x295f1
movl $0x1, 0x1db690(%rip)    # 0x204c7c
jmp 0x29ac9
movq 0x88(%rsp), %rax
movq (%rax), %rdi
leaq 0x16ccfe(%rip), %rsi    # 0x196301
callq 0x22ea0
cmpl $0x0, %eax
jne 0x2964d
movq 0x88(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x88(%rsp)
movl 0x90(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x90(%rsp)
movq 0x88(%rsp), %rax
movq (%rax), %rdi
callq 0x23070
movl %eax, 0x1db6c8(%rip)    # 0x204d10
jmp 0x29ac7
movq 0x88(%rsp), %rax
movq (%rax), %rdi
leaq 0x16ccb2(%rip), %rsi    # 0x196311
callq 0x22ea0
cmpl $0x0, %eax
jne 0x29706
movq 0x88(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x88(%rsp)
movl 0x90(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x90(%rsp)
movq 0x88(%rsp), %rax
movq (%rax), %rdi
callq 0x22ce0
movsd %xmm0, 0x80(%rsp)
movq 0x88(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x88(%rsp)
movl 0x90(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x90(%rsp)
movq 0x88(%rsp), %rax
movq (%rax), %rdi
callq 0x22ce0
movsd %xmm0, 0x78(%rsp)
movsd 0x80(%rsp), %xmm0
movsd 0x78(%rsp), %xmm1
leaq 0x1db514(%rip), %rdi    # 0x204c10
callq 0x2aef0
jmp 0x29ac5
movq 0x88(%rsp), %rax
movq (%rax), %rdi
leaq 0x16cc06(%rip), %rsi    # 0x19631e
callq 0x22ea0
cmpl $0x0, %eax
jne 0x297fa
movq 0x88(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x88(%rsp)
movl 0x90(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x90(%rsp)
movq 0x88(%rsp), %rax
movq (%rax), %rdi
callq 0x22ce0
movsd %xmm0, 0x70(%rsp)
movq 0x88(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x88(%rsp)
movl 0x90(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x90(%rsp)
movq 0x88(%rsp), %rax
movq (%rax), %rdi
callq 0x22ce0
movsd %xmm0, 0x68(%rsp)
movq 0x88(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x88(%rsp)
movl 0x90(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x90(%rsp)
movq 0x88(%rsp), %rax
movq (%rax), %rdi
callq 0x22ce0
movsd %xmm0, 0x60(%rsp)
movsd 0x70(%rsp), %xmm0
movsd 0x68(%rsp), %xmm1
movsd 0x60(%rsp), %xmm2
leaq 0x1db430(%rip), %rdi    # 0x204c20
callq 0x2af20
jmp 0x29ac3
movq 0x88(%rsp), %rax
movq (%rax), %rdi
leaq 0x16cb1a(%rip), %rsi    # 0x196326
callq 0x22ea0
cmpl $0x0, %eax
jne 0x29a9e
movq 0x88(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x88(%rsp)
movl 0x90(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x90(%rsp)
movq 0x88(%rsp), %rax
movq (%rax), %rdi
callq 0x22ce0
movsd %xmm0, 0x58(%rsp)
movq 0x88(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x88(%rsp)
movl 0x90(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x90(%rsp)
movq 0x88(%rsp), %rax
movq (%rax), %rdi
callq 0x22ce0
movsd %xmm0, 0x50(%rsp)
movq 0x88(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x88(%rsp)
movl 0x90(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x90(%rsp)
movq 0x88(%rsp), %rax
movq (%rax), %rdi
callq 0x22ce0
movsd %xmm0, 0x48(%rsp)
movq 0x88(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x88(%rsp)
movl 0x90(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x90(%rsp)
movq 0x88(%rsp), %rax
movq (%rax), %rdi
callq 0x22ce0
movsd %xmm0, 0x40(%rsp)
movq 0x88(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x88(%rsp)
movl 0x90(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x90(%rsp)
movq 0x88(%rsp), %rax
movq (%rax), %rdi
callq 0x22ce0
movsd %xmm0, 0x38(%rsp)
movq 0x88(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x88(%rsp)
movl 0x90(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x90(%rsp)
movq 0x88(%rsp), %rax
movq (%rax), %rdi
callq 0x22ce0
movsd %xmm0, 0x30(%rsp)
movq 0x88(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x88(%rsp)
movl 0x90(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x90(%rsp)
movq 0x88(%rsp), %rax
movq (%rax), %rdi
callq 0x22ce0
movsd %xmm0, 0x28(%rsp)
movq 0x88(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x88(%rsp)
movl 0x90(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x90(%rsp)
movq 0x88(%rsp), %rax
movq (%rax), %rdi
callq 0x22ce0
movsd %xmm0, 0x20(%rsp)
movq 0x88(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x88(%rsp)
movl 0x90(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x90(%rsp)
movq 0x88(%rsp), %rax
movq (%rax), %rdi
callq 0x22ce0
movsd %xmm0, 0x18(%rsp)
movsd 0x58(%rsp), %xmm0
movsd 0x50(%rsp), %xmm1
movsd 0x48(%rsp), %xmm2
movq %rsp, %rdi
callq 0xd49a0
leaq 0x1db1aa(%rip), %rdi    # 0x204bf8
movq %rsp, %rsi
callq 0xd5030
movsd 0x40(%rsp), %xmm0
movsd 0x38(%rsp), %xmm1
movsd 0x30(%rsp), %xmm2
leaq 0x1db159(%rip), %rdi    # 0x204bc8
callq 0x2af60
movsd 0x28(%rsp), %xmm0
movsd 0x20(%rsp), %xmm1
movsd 0x18(%rsp), %xmm2
leaq 0x1db153(%rip), %rdi    # 0x204be0
callq 0x2af60
movl $0x1, 0x1db28c(%rip)    # 0x204d28
jmp 0x29ac1
movq 0x88(%rsp), %rax
movq (%rax), %rsi
leaq 0x16c87e(%rip), %rdi    # 0x19632e
movb $0x0, %al
callq 0xfbc30
movl $0x1, %edi
callq 0x22c40
jmp 0x29ac3
jmp 0x29ac5
jmp 0x29ac7
jmp 0x29ac9
jmp 0x29acb
jmp 0x29acd
jmp 0x29acf
jmp 0x29ad1
jmp 0x29ad3
jmp 0x29ad5
jmp 0x29ad7
jmp 0x29ad9
movq 0x88(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x88(%rsp)
movl 0x90(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x90(%rsp)
jmp 0x29b89
cmpq $0x0, 0x1db225(%rip)    # 0x204d30
jne 0x29b21
movq 0x88(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x1db211(%rip)    # 0x204d30
jmp 0x29b64
cmpq $0x0, 0x1db20f(%rip)    # 0x204d38
jne 0x29b3f
movq 0x88(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x1db1fb(%rip)    # 0x204d38
jmp 0x29b62
movq 0x88(%rsp), %rax
movq (%rax), %rsi
leaq 0x16c7dd(%rip), %rdi    # 0x19632e
movb $0x0, %al
callq 0xfbc30
movl $0x1, %edi
callq 0x22c40
jmp 0x29b64
movq 0x88(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x88(%rsp)
movl 0x90(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x90(%rsp)
jmp 0x293db
cmpq $0x0, 0x1db19a(%rip)    # 0x204d30
je 0x29ba2
cmpq $0x0, 0x1db198(%rip)    # 0x204d38
jne 0x29bbd
leaq 0x16c7a2(%rip), %rdi    # 0x19634b
movb $0x0, %al
callq 0xfbc30
movl $0x0, 0x94(%rsp)
jmp 0x29bc8
movl $0x1, 0x94(%rsp)
movl 0x94(%rsp), %eax
addq $0x98, %rsp
retq
nopw (%rax,%rax)