// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/apps/gapsview/gapsview.cpp
// Function: GLUTKeyboard(unsigned char, int, int)
static void
GLUTKeyboard(unsigned char key, int x, int y)
{
  // Initialize redraw
  RNBoolean redraw = TRUE;

  // Determine modifiers
  int modifiers = glutGetModifiers();
  int ctrl = (modifiers & GLUT_ACTIVE_CTRL);
  int alt = (modifiers & GLUT_ACTIVE_ALT);

  // Process keyboard button event
  if (ctrl) {
    // Control which data sources are drawn
    switch(key) {
    case 7: // ctrl-G
      show_grids = !show_grids;
      break;

    case 12: // ctrl-L
      show_gsvs = !show_gsvs;
      break;

    case 13: // ctrl-M
      show_meshes = !show_meshes;
      break;

    case 15: // ctrl-O
      show_scenes = !show_scenes;
      break;

    case 16: // ctrl-P
      show_pointsets = !show_pointsets;
      break;

    case 19: // ctrl-S
      show_sfls = !show_sfls;
      break;

    default:
      redraw = FALSE;
      break;
    }
  }
  else if (alt) {
    // Control how things are drawn
    switch (key) {
    case 'C':
    case 'c':
      color_scheme = RGB_COLOR_SCHEME;
      break;

    case 'E':
    case 'e':
      color_scheme = NULL_COLOR_SCHEME;
      break;

    case 'I':
    case 'i':
      color_scheme = INSTANCE_COLOR_SCHEME;
      break;

    case 'L':
    case 'l':
      color_scheme = CATEGORY_COLOR_SCHEME;
      break;

    case 'S':
    case 's':
      color_scheme = SHADING_COLOR_SCHEME;
      break;

    case 'X':
      if (selected_model_index < grids.NEntries()) {
        grid_slice_coords[RN_X]++;
        if (grid_slice_coords[RN_X] >= grids[selected_model_index]->XResolution()) 
          grid_slice_coords[RN_X] = grids[selected_model_index]->XResolution() - 1;
      }
      break;

    case 'x':
      if (selected_model_index < grids.NEntries()) {
        grid_slice_coords[RN_X]--;
        if (grid_slice_coords[RN_X] < 0)
          grid_slice_coords[RN_X] = 0;
      }
      break;

    case 'Y':
      if (selected_model_index < grids.NEntries()) {
        grid_slice_coords[RN_Y]++;
        if (grid_slice_coords[RN_Y] >= grids[selected_model_index]->YResolution()) 
          grid_slice_coords[RN_Y] = grids[selected_model_index]->YResolution() - 1;
      }
      break;

    case 'y':
      if (selected_model_index < grids.NEntries()) {
        grid_slice_coords[RN_Y]--;
        if (grid_slice_coords[RN_Y] < 0)
          grid_slice_coords[RN_Y] = 0;
      }
      break;

    case 'Z':
      if (selected_model_index < grids.NEntries()) {
        grid_slice_coords[RN_Z]++;
        if (grid_slice_coords[RN_Z] >= grids[selected_model_index]->ZResolution()) 
          grid_slice_coords[RN_Z] = grids[selected_model_index]->ZResolution() - 1;
      }
      break;

    case 'z':
      if (selected_model_index < grids.NEntries()) {
        grid_slice_coords[RN_Z]--;
        if (grid_slice_coords[RN_Z] < 0)
          grid_slice_coords[RN_Z] = 0;
      }
      break;

    default:
      redraw = FALSE;
      break;
    }
  }
  else {
    // Control which data elements are drawn
    switch (key) {
    case '1':
    case '2':
    case '3':
    case '4':
      selected_model_index = key - '1';
      if (selected_model_index > nmodels - 1) {
        selected_model_index = nmodels - 1;
      }
      break;

    case 'A':
    case 'a':
      show_axes = !show_axes;
      break;

    case 'B':
    case 'b':
      show_bbox = !show_bbox;
      break;

    case 'C':
    case 'c':
      show_cameras = !show_cameras;
      break;

    case 'D':
    case 'd':
      show_image_depths = !show_image_depths;
      break;
      
    case 'E':
    case 'e':
      show_edges = !show_edges;
      break;

    case 'F':
    case 'f':
      show_surfaces = !show_surfaces;
      break;

    case 'G':
    case 'g':
      show_slices = !show_slices;
      break;

    case 'I':
      show_image_billboards = !show_image_billboards;
      break;

    case 'i':
      show_image_insets = !show_image_insets;
      break;

    case 'L':
    case 'l':
      show_text_labels = !show_text_labels;
      break;

    case 'N':
    case 'n':
      show_normals = !show_normals;
      break;

    case 'P':
    case 'p':
      show_points = !show_points;
      break;

    case 'R':
    case 'r':
      show_image_rays = !show_image_rays;
      break;

    case 'T':
    case 't':
      show_grid_threshold = !show_grid_threshold;
      break;

    case ' ': {
      // Print camera
      const R3Camera& camera = viewer->Camera();
      printf("#camera  %g %g %g  %g %g %g  %g %g %g  %g \n",
             camera.Origin().X(), camera.Origin().Y(), camera.Origin().Z(),
             camera.Towards().X(), camera.Towards().Y(), camera.Towards().Z(),
             camera.Up().X(), camera.Up().Y(), camera.Up().Z(),
             camera.YFOV());
      break; }
      
    case 27: // ESCAPE
      GLUTStop();
      break;

    default:
      redraw = FALSE;
      break;
    }
  }
  
  // Remember mouse position 
  GLUTmouse[0] = x;
  GLUTmouse[1] = GLUTwindow_height - y;

  // Remember modifiers 
  GLUTmodifiers = modifiers;

  // Redraw
  if (redraw) glutPostRedisplay();  
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x80, %rsp
movl %edx, %ebx
movl %esi, %ebp
movl %edi, %r14d
callq 0x116ed4
testb $0x2, %al
jne 0x2dc7f
testb $0x4, %al
jne 0x2dcb6
movzbl %r14b, %ecx
leal -0x31(%rcx), %eax
cmpl $0x43, %eax
ja 0x2e066
leaq 0x1205b7(%rip), %rcx    # 0x14e20c
movslq (%rcx,%rax,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
movl %eax, 0x1af530(%rip)    # 0x1dd194
movl 0x1af76a(%rip), %ecx    # 0x1dd3d4
cmpl %ecx, %eax
jl 0x2e18e
decl %ecx
movl %ecx, 0x1af51a(%rip)    # 0x1dd194
jmp 0x2e18e
movzbl %r14b, %eax
addl $-0x7, %eax
cmpl $0xc, %eax
ja 0x2e074
leaq 0x1204b2(%rip), %rcx    # 0x14e148
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
xorl %eax, %eax
cmpl $0x0, 0x1a9dfc(%rip)    # 0x1d7aa4
sete %al
movl %eax, 0x1a9df3(%rip)    # 0x1d7aa4
jmp 0x2e18e
movzbl %r14b, %eax
cmpl $0x62, %eax
jg 0x2dd2e
leal -0x43(%rax), %ecx
cmpl $0x9, %ecx
jbe 0x2ddd8
addl $-0x53, %eax
cmpl $0x7, %eax
ja 0x2e074
leaq 0x1204c6(%rip), %rcx    # 0x14e1a4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movslq 0x1af4a6(%rip), %rax    # 0x1dd194
cmpl 0x1aeff0(%rip), %eax    # 0x1dcce4
jge 0x2e18e
movl 0x1af470(%rip), %ecx    # 0x1dd170
incl %ecx
movl %ecx, 0x1af468(%rip)    # 0x1dd170
movq 0x1aefc9(%rip), %rdx    # 0x1dccd8
movq (%rdx,%rax,8), %rax
movl 0x238(%rax), %eax
cmpl %eax, %ecx
jl 0x2e18e
decl %eax
movl %eax, 0x1af447(%rip)    # 0x1dd170
jmp 0x2e18e
leal -0x63(%rax), %ecx
cmpl $0x9, %ecx
jbe 0x2dde8
addl $-0x73, %eax
cmpl $0x7, %eax
ja 0x2e074
leaq 0x12049f(%rip), %rcx    # 0x14e1ec
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x2, 0x1a9d30(%rip)    # 0x1d7a90
jmp 0x2e18e
xorl %eax, %eax
cmpl $0x0, 0x1a9d32(%rip)    # 0x1d7aa0
sete %al
movl %eax, 0x1a9d29(%rip)    # 0x1d7aa0
jmp 0x2e18e
xorl %eax, %eax
cmpl $0x0, 0x1a9d23(%rip)    # 0x1d7aa8
sete %al
movl %eax, 0x1a9d1a(%rip)    # 0x1d7aa8
jmp 0x2e18e
xorl %eax, %eax
cmpl $0x0, 0x1a9d14(%rip)    # 0x1d7ab0
sete %al
movl %eax, 0x1a9d0b(%rip)    # 0x1d7ab0
jmp 0x2e18e
xorl %eax, %eax
cmpl $0x0, 0x1a9ce9(%rip)    # 0x1d7a9c
sete %al
movl %eax, 0x1a9ce0(%rip)    # 0x1d7a9c
jmp 0x2e18e
xorl %eax, %eax
cmpl $0x0, 0x1a9cca(%rip)    # 0x1d7a94
sete %al
movl %eax, 0x1a9cc1(%rip)    # 0x1d7a94
jmp 0x2e18e
leaq 0x12039d(%rip), %rax    # 0x14e17c
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
leaq 0x1203d5(%rip), %rax    # 0x14e1c4
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movl $0x1, 0x1a9c8e(%rip)    # 0x1d7a90
jmp 0x2e18e
movl $0x4, 0x1a9c7f(%rip)    # 0x1d7a90
jmp 0x2e18e
movl $0x0, 0x1a9c70(%rip)    # 0x1d7a90
jmp 0x2e18e
movl $0x3, 0x1a9c61(%rip)    # 0x1d7a90
jmp 0x2e18e
xorl %eax, %eax
cmpl $0x0, 0x1af58b(%rip)    # 0x1dd3c8
sete %al
movl %eax, 0x1af582(%rip)    # 0x1dd3c8
jmp 0x2e18e
xorl %eax, %eax
cmpl $0x0, 0x1af348(%rip)    # 0x1dd19c
sete %al
movl %eax, 0x1af33f(%rip)    # 0x1dd19c
jmp 0x2e18e
xorl %eax, %eax
cmpl $0x0, 0x1af32d(%rip)    # 0x1dd198
sete %al
movl %eax, 0x1af324(%rip)    # 0x1dd198
jmp 0x2e18e
xorl %eax, %eax
cmpl $0x0, 0x1af54e(%rip)    # 0x1dd3d0
sete %al
movl %eax, 0x1af545(%rip)    # 0x1dd3d0
jmp 0x2e18e
xorl %eax, %eax
cmpl $0x0, 0x1af52b(%rip)    # 0x1dd3c4
sete %al
movl %eax, 0x1af522(%rip)    # 0x1dd3c4
jmp 0x2e18e
xorl %eax, %eax
cmpl $0x0, 0x1af500(%rip)    # 0x1dd3b0
sete %al
movl %eax, 0x1af4f7(%rip)    # 0x1dd3b0
jmp 0x2e18e
xorl %eax, %eax
cmpl $0x0, 0x1a9be5(%rip)    # 0x1d7aac
sete %al
movl %eax, 0x1a9bdc(%rip)    # 0x1d7aac
jmp 0x2e18e
xorl %eax, %eax
cmpl $0x0, 0x1af4ee(%rip)    # 0x1dd3cc
sete %al
movl %eax, 0x1af4e5(%rip)    # 0x1dd3cc
jmp 0x2e18e
xorl %eax, %eax
cmpl $0x0, 0x1af2ab(%rip)    # 0x1dd1a0
sete %al
movl %eax, 0x1af2a2(%rip)    # 0x1dd1a0
jmp 0x2e18e
xorl %eax, %eax
cmpl $0x0, 0x1af4ac(%rip)    # 0x1dd3b8
sete %al
movl %eax, 0x1af4a3(%rip)    # 0x1dd3b8
jmp 0x2e18e
xorl %eax, %eax
cmpl $0x0, 0x1a9b75(%rip)    # 0x1d7a98
sete %al
movl %eax, 0x1a9b6c(%rip)    # 0x1d7a98
jmp 0x2e18e
xorl %eax, %eax
cmpl $0x0, 0x1af47a(%rip)    # 0x1dd3b4
sete %al
movl %eax, 0x1af471(%rip)    # 0x1dd3b4
jmp 0x2e18e
movslq 0x1af245(%rip), %rax    # 0x1dd194
cmpl 0x1aed8f(%rip), %eax    # 0x1dcce4
jge 0x2e18e
movl 0x1af213(%rip), %ecx    # 0x1dd174
incl %ecx
movl %ecx, 0x1af20b(%rip)    # 0x1dd174
movq 0x1aed68(%rip), %rdx    # 0x1dccd8
movq (%rdx,%rax,8), %rax
movl 0x23c(%rax), %eax
cmpl %eax, %ecx
jl 0x2e18e
decl %eax
movl %eax, 0x1af1ea(%rip)    # 0x1dd174
jmp 0x2e18e
movl 0x1af1ff(%rip), %eax    # 0x1dd194
cmpl 0x1aed49(%rip), %eax    # 0x1dcce4
jge 0x2e18e
movl 0x1af1cd(%rip), %eax    # 0x1dd174
cmpl $0x2, %eax
movl $0x1, %ecx
cmovgel %eax, %ecx
decl %ecx
movl %ecx, 0x1af1ba(%rip)    # 0x1dd174
jmp 0x2e18e
movl 0x1af1cf(%rip), %eax    # 0x1dd194
cmpl 0x1aed19(%rip), %eax    # 0x1dcce4
jge 0x2e18e
movl 0x1af199(%rip), %eax    # 0x1dd170
cmpl $0x2, %eax
movl $0x1, %ecx
cmovgel %eax, %ecx
decl %ecx
movl %ecx, 0x1af186(%rip)    # 0x1dd170
jmp 0x2e18e
movslq 0x1af19e(%rip), %rax    # 0x1dd194
cmpl 0x1aece8(%rip), %eax    # 0x1dcce4
jge 0x2e18e
movl 0x1af170(%rip), %ecx    # 0x1dd178
incl %ecx
movl %ecx, 0x1af168(%rip)    # 0x1dd178
movq 0x1aecc1(%rip), %rdx    # 0x1dccd8
movq (%rdx,%rax,8), %rax
movl 0x240(%rax), %eax
cmpl %eax, %ecx
jl 0x2e18e
decl %eax
movl %eax, 0x1af147(%rip)    # 0x1dd178
jmp 0x2e18e
movl 0x1af158(%rip), %eax    # 0x1dd194
cmpl 0x1aeca2(%rip), %eax    # 0x1dcce4
jge 0x2e18e
movl 0x1af12a(%rip), %eax    # 0x1dd178
cmpl $0x2, %eax
movl $0x1, %ecx
cmovgel %eax, %ecx
decl %ecx
movl %ecx, 0x1af117(%rip)    # 0x1dd178
jmp 0x2e18e
cmpl $0x20, %ecx
je 0x2e0bb
cmpl $0x1b, %ecx
je 0x2e1b7
movl %ebp, 0x1af35e(%rip)    # 0x1dd3d8
movl 0x1a9984(%rip), %eax    # 0x1d7a04
subl %ebx, %eax
movl %eax, 0x1af354(%rip)    # 0x1dd3dc
jmp 0x2e1a7
xorl %eax, %eax
cmpl $0x0, 0x1af32a(%rip)    # 0x1dd3c0
sete %al
movl %eax, 0x1af321(%rip)    # 0x1dd3c0
jmp 0x2e18e
xorl %eax, %eax
cmpl $0x0, 0x1af30f(%rip)    # 0x1dd3bc
sete %al
movl %eax, 0x1af306(%rip)    # 0x1dd3bc
jmp 0x2e18e
movq 0x1af0be(%rip), %r12    # 0x1dd180
movsd 0x8(%r12), %xmm0
movsd %xmm0, 0x30(%rsp)
movsd 0x10(%r12), %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x18(%r12), %xmm0
movsd %xmm0, 0x20(%rsp)
leaq 0x50(%r12), %r14
leaq 0x68(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0xd755c
movsd (%r15), %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0x50(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0xd755c
movsd 0x8(%r15), %xmm0
movsd %xmm0, 0x10(%rsp)
leaq 0x38(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0xd755c
movsd 0x10(%r15), %xmm5
movsd 0x38(%r12), %xmm6
movsd 0x40(%r12), %xmm7
movsd 0x48(%r12), %xmm0
movsd 0x70(%r12), %xmm1
movsd %xmm1, 0x8(%rsp)
movsd %xmm0, (%rsp)
leaq 0x1202a3(%rip), %rdi    # 0x14e40c
movsd 0x30(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
movsd 0x20(%rsp), %xmm2
movsd 0x18(%rsp), %xmm3
movsd 0x10(%rsp), %xmm4
movb $0x8, %al
callq 0x27080
movl %ebp, 0x1af244(%rip)    # 0x1dd3d8
movl 0x1a986a(%rip), %eax    # 0x1d7a04
subl %ebx, %eax
movl %eax, 0x1af23a(%rip)    # 0x1dd3dc
callq 0x111f8c
addq $0x80, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0x32457