// File: tomfunkhouser[P]gaps/apps/scnview/scnview.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, "-hide_faces")) show_faces = 0;
      else if (!strcmp(*argv, "-show_faces")) show_faces = 1;
      else if (!strcmp(*argv, "-show_edges")) show_edges = 1;
      else if (!strcmp(*argv, "-show_cameras")) show_cameras = 1;
      else if (!strcmp(*argv, "-show_lights")) show_lights = 1;
      else if (!strcmp(*argv, "-show_materials")) show_materials = 1;
      else if (!strcmp(*argv, "-show_bboxes")) show_bboxes = 1;
      else if (!strcmp(*argv, "-show_axes")) show_axes = 1;
      else if (!strcmp(*argv, "-show_rays")) show_rays = 1;
      else if (!strcmp(*argv, "-show_backfacing")) show_backfacing = 1;
      else if (!strcmp(*argv, "-draw_backfacing_in_second_pass")) show_backfacing = 2;
      else if (!strcmp(*argv, "-remove_references")) remove_references = 1;
      else if (!strcmp(*argv, "-remove_hierarchy")) remove_hierarchy = 1;
      else if (!strcmp(*argv, "-remove_transformations")) remove_transformations = 1;
      else if (!strcmp(*argv, "-headlight")) headlight = 1; 
      else if (!strcmp(*argv, "-max_vertex_spacing")) {
        argc--; argv++; max_vertex_spacing = atof(*argv);
      }
      else if (!strcmp(*argv, "-image")) {
        argc--; argv++; output_image_name = *argv;
      }
      else if (!strcmp(*argv, "-cameras")) {
        argv++; argc--; input_cameras_name = *argv;
      }
      else if (!strcmp(*argv, "-categories")) {
        argc--; argv++; input_categories_name = *argv;
      }
      else if (!strcmp(*argv, "-lights")) {
        argv++; argc--; input_lights_name = *argv;
      }
      else if (!strcmp(*argv, "-background")) {
        argv++; argc--; background_color[0] = atof(*argv);
        argv++; argc--; background_color[1] = atof(*argv);
        argv++; argc--; background_color[2] = atof(*argv);
      }
      else if (!strcmp(*argv, "-window")) { 
        argv++; argc--; GLUTwindow_width = atoi(*argv); 
        argv++; argc--; GLUTwindow_height = atoi(*argv); 
      }
      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 (!input_scene_name) input_scene_name = *argv;
      else { RNFail("Invalid program argument: %s", *argv); exit(1); }
      argv++; argc--;
    }
  }

  // Check scene filename
  if (!input_scene_name) {
    RNFail("Usage: scnview inputscenefile\n");
    return 0;
  }

  // Return OK status 
  return 1;
}

// Assembly:
subq $0x88, %rsp
movl %edi, 0x80(%rsp)
movq %rsi, 0x78(%rsp)
movl 0x80(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x80(%rsp)
movq 0x78(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x78(%rsp)
cmpl $0x0, 0x80(%rsp)
jle 0x2a3fe
movq 0x78(%rsp), %rax
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x2a39f
movq 0x78(%rsp), %rax
movq (%rax), %rdi
leaq 0x164736(%rip), %rsi    # 0x18e299
callq 0x22ec0
cmpl $0x0, %eax
jne 0x29b7c
movl $0x1, 0x1d21b1(%rip)    # 0x1fbd28
jmp 0x2a37e
movq 0x78(%rsp), %rax
movq (%rax), %rdi
leaq 0x164711(%rip), %rsi    # 0x18e29c
callq 0x22ec0
cmpl $0x0, %eax
jne 0x29ba4
movl $0x0, 0x1cbf21(%rip)    # 0x1f5ac0
jmp 0x2a37c
movq 0x78(%rsp), %rax
movq (%rax), %rdi
leaq 0x1646f5(%rip), %rsi    # 0x18e2a8
callq 0x22ec0
cmpl $0x0, %eax
jne 0x29bcc
movl $0x1, 0x1cbef9(%rip)    # 0x1f5ac0
jmp 0x2a37a
movq 0x78(%rsp), %rax
movq (%rax), %rdi
leaq 0x1646d9(%rip), %rsi    # 0x18e2b4
callq 0x22ec0
cmpl $0x0, %eax
jne 0x29bf4
movl $0x1, 0x1d20a5(%rip)    # 0x1fbc94
jmp 0x2a378
movq 0x78(%rsp), %rax
movq (%rax), %rdi
leaq 0x1646bd(%rip), %rsi    # 0x18e2c0
callq 0x22ec0
cmpl $0x0, %eax
jne 0x29c1c
movl $0x1, 0x1d2019(%rip)    # 0x1fbc30
jmp 0x2a376
movq 0x78(%rsp), %rax
movq (%rax), %rdi
leaq 0x1646a3(%rip), %rsi    # 0x18e2ce
callq 0x22ec0
cmpl $0x0, %eax
jne 0x29c44
movl $0x1, 0x1d2001(%rip)    # 0x1fbc40
jmp 0x2a374
movq 0x78(%rsp), %rax
movq (%rax), %rdi
leaq 0x164688(%rip), %rsi    # 0x18e2db
callq 0x22ec0
cmpl $0x0, %eax
jne 0x29c6c
movl $0x1, 0x1d2099(%rip)    # 0x1fbd00
jmp 0x2a372
movq 0x78(%rsp), %rax
movq (%rax), %rdi
leaq 0x164670(%rip), %rsi    # 0x18e2eb
callq 0x22ec0
cmpl $0x0, %eax
jne 0x29c94
movl $0x1, 0x1d2009(%rip)    # 0x1fbc98
jmp 0x2a370
movq 0x78(%rsp), %rax
movq (%rax), %rdi
leaq 0x164655(%rip), %rsi    # 0x18e2f8
callq 0x22ec0
cmpl $0x0, %eax
jne 0x29cbc
movl $0x1, 0x1d1fe5(%rip)    # 0x1fbc9c
jmp 0x2a36e
movq 0x78(%rsp), %rax
movq (%rax), %rdi
leaq 0x164638(%rip), %rsi    # 0x18e303
callq 0x22ec0
cmpl $0x0, %eax
jne 0x29ce4
movl $0x1, 0x1d1f69(%rip)    # 0x1fbc48
jmp 0x2a36c
movq 0x78(%rsp), %rax
movq (%rax), %rdi
leaq 0x16461b(%rip), %rsi    # 0x18e30e
callq 0x22ec0
cmpl $0x0, %eax
jne 0x29d0c
movl $0x1, 0x1d1f19(%rip)    # 0x1fbc20
jmp 0x2a36a
movq 0x78(%rsp), %rax
movq (%rax), %rdi
leaq 0x164604(%rip), %rsi    # 0x18e31f
callq 0x22ec0
cmpl $0x0, %eax
jne 0x29d34
movl $0x2, 0x1d1ef1(%rip)    # 0x1fbc20
jmp 0x2a368
movq 0x78(%rsp), %rax
movq (%rax), %rdi
leaq 0x1645fc(%rip), %rsi    # 0x18e33f
callq 0x22ec0
cmpl $0x0, %eax
jne 0x29d5c
movl $0x1, 0x1d1fd5(%rip)    # 0x1fbd2c
jmp 0x2a366
movq 0x78(%rsp), %rax
movq (%rax), %rdi
leaq 0x1645e7(%rip), %rsi    # 0x18e352
callq 0x22ec0
cmpl $0x0, %eax
jne 0x29d84
movl $0x1, 0x1d1fb1(%rip)    # 0x1fbd30
jmp 0x2a364
movq 0x78(%rsp), %rax
movq (%rax), %rdi
leaq 0x1645d1(%rip), %rsi    # 0x18e364
callq 0x22ec0
cmpl $0x0, %eax
jne 0x29dac
movl $0x1, 0x1d1f8d(%rip)    # 0x1fbd34
jmp 0x2a362
movq 0x78(%rsp), %rax
movq (%rax), %rdi
leaq 0x1645c1(%rip), %rsi    # 0x18e37c
callq 0x22ec0
cmpl $0x0, %eax
jne 0x29dd4
movl $0x1, 0x1d1ec1(%rip)    # 0x1fbc90
jmp 0x2a360
movq 0x78(%rsp), %rax
movq (%rax), %rdi
leaq 0x1645a4(%rip), %rsi    # 0x18e387
callq 0x22ec0
cmpl $0x0, %eax
jne 0x29e26
movl 0x80(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x80(%rsp)
movq 0x78(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x78(%rsp)
movq 0x78(%rsp), %rax
movq (%rax), %rdi
callq 0x22d00
movsd %xmm0, 0x1d1f17(%rip)   # 0x1fbd38
jmp 0x2a35e
movq 0x78(%rsp), %rax
movq (%rax), %rdi
leaq 0x164566(%rip), %rsi    # 0x18e39b
callq 0x22ec0
cmpl $0x0, %eax
jne 0x29e72
movl 0x80(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x80(%rsp)
movq 0x78(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x78(%rsp)
movq 0x78(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x1d1e53(%rip)    # 0x1fbcc0
jmp 0x2a35c
movq 0x78(%rsp), %rax
movq (%rax), %rdi
leaq 0x164521(%rip), %rsi    # 0x18e3a2
callq 0x22ec0
cmpl $0x0, %eax
jne 0x29ebe
movq 0x78(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x78(%rsp)
movl 0x80(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x80(%rsp)
movq 0x78(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x1d1e57(%rip)    # 0x1fbd10
jmp 0x2a35a
movq 0x78(%rsp), %rax
movq (%rax), %rdi
leaq 0x1644de(%rip), %rsi    # 0x18e3ab
callq 0x22ec0
cmpl $0x0, %eax
jne 0x29f0a
movl 0x80(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x80(%rsp)
movq 0x78(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x78(%rsp)
movq 0x78(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x1d1e13(%rip)    # 0x1fbd18
jmp 0x2a358
movq 0x78(%rsp), %rax
movq (%rax), %rdi
leaq 0x16449e(%rip), %rsi    # 0x18e3b7
callq 0x22ec0
cmpl $0x0, %eax
jne 0x29f56
movq 0x78(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x78(%rsp)
movl 0x80(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x80(%rsp)
movq 0x78(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x1d1dcf(%rip)    # 0x1fbd20
jmp 0x2a356
movq 0x78(%rsp), %rax
movq (%rax), %rdi
leaq 0x16445a(%rip), %rsi    # 0x18e3bf
callq 0x22ec0
cmpl $0x0, %eax
jne 0x2a05a
movq 0x78(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x78(%rsp)
movl 0x80(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x80(%rsp)
movq 0x78(%rsp), %rax
movq (%rax), %rdi
callq 0x22d00
movsd %xmm0, (%rsp)
leaq 0x1d1c35(%rip), %rdi    # 0x1fbbe0
xorl %esi, %esi
callq 0x2bfc0
movsd (%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0x78(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x78(%rsp)
movl 0x80(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x80(%rsp)
movq 0x78(%rsp), %rax
movq (%rax), %rdi
callq 0x22d00
movsd %xmm0, 0x8(%rsp)
leaq 0x1d1bec(%rip), %rdi    # 0x1fbbe0
movl $0x1, %esi
callq 0x2bfc0
movsd 0x8(%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0x78(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x78(%rsp)
movl 0x80(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x80(%rsp)
movq 0x78(%rsp), %rax
movq (%rax), %rdi
callq 0x22d00
movsd %xmm0, 0x10(%rsp)
leaq 0x1d1b9f(%rip), %rdi    # 0x1fbbe0
movl $0x2, %esi
callq 0x2bfc0
movsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rax)
jmp 0x2a354
movq 0x78(%rsp), %rax
movq (%rax), %rdi
leaq 0x164362(%rip), %rsi    # 0x18e3cb
callq 0x22ec0
cmpl $0x0, %eax
jne 0x2a0dc
movq 0x78(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x78(%rsp)
movl 0x80(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x80(%rsp)
movq 0x78(%rsp), %rax
movq (%rax), %rdi
callq 0x23090
movl %eax, 0x1cba1f(%rip)    # 0x1f5ac4
movq 0x78(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x78(%rsp)
movl 0x80(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x80(%rsp)
movq 0x78(%rsp), %rax
movq (%rax), %rdi
callq 0x23090
movl %eax, 0x1cb9f1(%rip)    # 0x1f5ac8
jmp 0x2a352
movq 0x78(%rsp), %rax
movq (%rax), %rdi
leaq 0x1642e8(%rip), %rsi    # 0x18e3d3
callq 0x22ec0
cmpl $0x0, %eax
jne 0x2a330
movq 0x78(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x78(%rsp)
movl 0x80(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x80(%rsp)
movq 0x78(%rsp), %rax
movq (%rax), %rdi
callq 0x22d00
movsd %xmm0, 0x70(%rsp)
movq 0x78(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x78(%rsp)
movl 0x80(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x80(%rsp)
movq 0x78(%rsp), %rax
movq (%rax), %rdi
callq 0x22d00
movsd %xmm0, 0x68(%rsp)
movq 0x78(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x78(%rsp)
movl 0x80(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x80(%rsp)
movq 0x78(%rsp), %rax
movq (%rax), %rdi
callq 0x22d00
movsd %xmm0, 0x60(%rsp)
movq 0x78(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x78(%rsp)
movl 0x80(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x80(%rsp)
movq 0x78(%rsp), %rax
movq (%rax), %rdi
callq 0x22d00
movsd %xmm0, 0x58(%rsp)
movq 0x78(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x78(%rsp)
movl 0x80(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x80(%rsp)
movq 0x78(%rsp), %rax
movq (%rax), %rdi
callq 0x22d00
movsd %xmm0, 0x50(%rsp)
movq 0x78(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x78(%rsp)
movl 0x80(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x80(%rsp)
movq 0x78(%rsp), %rax
movq (%rax), %rdi
callq 0x22d00
movsd %xmm0, 0x48(%rsp)
movq 0x78(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x78(%rsp)
movl 0x80(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x80(%rsp)
movq 0x78(%rsp), %rax
movq (%rax), %rdi
callq 0x22d00
movsd %xmm0, 0x40(%rsp)
movq 0x78(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x78(%rsp)
movl 0x80(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x80(%rsp)
movq 0x78(%rsp), %rax
movq (%rax), %rdi
callq 0x22d00
movsd %xmm0, 0x38(%rsp)
movq 0x78(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x78(%rsp)
movl 0x80(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x80(%rsp)
movq 0x78(%rsp), %rax
movq (%rax), %rdi
callq 0x22d00
movsd %xmm0, 0x30(%rsp)
movsd 0x70(%rsp), %xmm0
movsd 0x68(%rsp), %xmm1
movsd 0x60(%rsp), %xmm2
leaq 0x18(%rsp), %rdi
callq 0xcc870
leaq 0x1d18ea(%rip), %rdi    # 0x1fbbc8
leaq 0x18(%rsp), %rsi
callq 0xccf00
movsd 0x58(%rsp), %xmm0
movsd 0x50(%rsp), %xmm1
movsd 0x48(%rsp), %xmm2
leaq 0x1d1897(%rip), %rdi    # 0x1fbb98
callq 0x2bfe0
movsd 0x40(%rsp), %xmm0
movsd 0x38(%rsp), %xmm1
movsd 0x30(%rsp), %xmm2
leaq 0x1d1891(%rip), %rdi    # 0x1fbbb0
callq 0x2bfe0
movl $0x1, 0x1d1a12(%rip)    # 0x1fbd40
jmp 0x2a350
movq 0x78(%rsp), %rax
movq (%rax), %rsi
leaq 0x16409c(%rip), %rdi    # 0x18e3db
movb $0x0, %al
callq 0xf3b00
movl $0x1, %edi
callq 0x22c60
jmp 0x2a352
jmp 0x2a354
jmp 0x2a356
jmp 0x2a358
jmp 0x2a35a
jmp 0x2a35c
jmp 0x2a35e
jmp 0x2a360
jmp 0x2a362
jmp 0x2a364
jmp 0x2a366
jmp 0x2a368
jmp 0x2a36a
jmp 0x2a36c
jmp 0x2a36e
jmp 0x2a370
jmp 0x2a372
jmp 0x2a374
jmp 0x2a376
jmp 0x2a378
jmp 0x2a37a
jmp 0x2a37c
jmp 0x2a37e
movq 0x78(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x78(%rsp)
movl 0x80(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x80(%rsp)
jmp 0x2a3f9
cmpq $0x0, 0x1d1961(%rip)    # 0x1fbd08
jne 0x2a3ba
movq 0x78(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x1d1950(%rip)    # 0x1fbd08
jmp 0x2a3da
movq 0x78(%rsp), %rax
movq (%rax), %rsi
leaq 0x164012(%rip), %rdi    # 0x18e3db
movb $0x0, %al
callq 0xf3b00
movl $0x1, %edi
callq 0x22c60
movq 0x78(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x78(%rsp)
movl 0x80(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x80(%rsp)
jmp 0x29b32
cmpq $0x0, 0x1d1902(%rip)    # 0x1fbd08
jne 0x2a423
leaq 0x163fe9(%rip), %rdi    # 0x18e3f8
movb $0x0, %al
callq 0xf3b00
movl $0x0, 0x84(%rsp)
jmp 0x2a42e
movl $0x1, 0x84(%rsp)
movl 0x84(%rsp), %eax
addq $0x88, %rsp
retq
nopl (%rax)