// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/apps/grdview/grdview.cpp
// Function: GLUTKeyboard(unsigned char, int, int)
void GLUTKeyboard(unsigned char key, int x, int y)
{
  // Process keyboard button event 
  switch (key) {
  case 'A':
  case 'a':
    show_axes = !show_axes;
    break;

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

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

  case 'I':
  case 'i':
    show_isosurface = !show_isosurface;
    break;

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

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

  case 'W':
  case 'w':
    show_slices[0] = !show_slices[0];
    show_slices[1] = show_slices[0];
    show_slices[2] = show_slices[0];
    break;

  case 'X':
    grid_slice_coords[RN_X]++;
    if (grid_slice_coords[RN_X] >= grid->XResolution()) 
      grid_slice_coords[RN_X] = grid->XResolution() - 1;
    break;

  case 'x':
    grid_slice_coords[RN_X]--;
    if (grid_slice_coords[RN_X] < 0)
      grid_slice_coords[RN_X] = 0;
    break;

  case 'Y':
    grid_slice_coords[RN_Y]++;
    if (grid_slice_coords[RN_Y] >= grid->YResolution()) 
      grid_slice_coords[RN_Y] = grid->YResolution() - 1;
    break;

  case 'y':
    grid_slice_coords[RN_Y]--;
    if (grid_slice_coords[RN_Y] < 0)
      grid_slice_coords[RN_Y] = 0;
    break;

  case 'Z':
    grid_slice_coords[RN_Z]++;
    if (grid_slice_coords[RN_Z] >= grid->ZResolution()) 
      grid_slice_coords[RN_Z] = grid->ZResolution() - 1;
    break;

  case 'z':
    grid_slice_coords[RN_Z]--;
    if (grid_slice_coords[RN_Z] < 0)
      grid_slice_coords[RN_Z] = 0;
    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;
  }

  // Remember mouse position 
  GLUTmouse[0] = x;
  GLUTmouse[1] = GLUTwindow_height - y;

  // Remember modifiers 
  GLUTmodifiers = glutGetModifiers();

  // Redraw
  glutPostRedisplay();  
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x80, %rsp
movl %edx, %ebx
movl %esi, %ebp
leal -0x50(%rdi), %eax
cmpl $0x12, %eax
jbe 0x22a40
leal -0x67(%rdi), %eax
cmpl $0x13, %eax
ja 0x22a67
leaq 0x9271d(%rip), %rcx     # 0xb5138
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl 0xf8d9e(%rip), %eax     # 0x11b7c8
cmpl $0x2, %eax
pushq $0x1
popq %rcx
cmovgel %eax, %ecx
decl %ecx
movl %ecx, 0xf8d8d(%rip)     # 0x11b7c8
jmp 0x22ccb
leaq 0x926a5(%rip), %rcx     # 0xb50ec
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
xorl %eax, %eax
cmpl $0x0, 0xf8d7f(%rip)     # 0x11b7d8
sete %al
movl %eax, 0xf8d76(%rip)     # 0x11b7d8
jmp 0x22ccb
leal -0x41(%rdi), %eax
cmpl $0x8, %eax
ja 0x22b19
leaq 0x9264e(%rip), %rcx     # 0xb50c8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
xorl %eax, %eax
cmpl $0x0, 0xf8d48(%rip)     # 0x11b7d4
sete %al
movl %eax, 0xf8d3f(%rip)     # 0x11b7d4
jmp 0x22ccb
xorl %eax, %eax
cmpl $0x0, 0xf8d15(%rip)     # 0x11b7b8
sete %al
movl %eax, 0xf8d0c(%rip)     # 0x11b7b8
jmp 0x22ccb
xorl %eax, %eax
cmpl $0x0, 0xf8d02(%rip)     # 0x11b7bc
sete %al
movl %eax, 0xf8cf9(%rip)     # 0x11b7bc
movl %eax, 0xf8cf7(%rip)     # 0x11b7c0
movl %eax, 0xf8cf5(%rip)     # 0x11b7c4
jmp 0x22ccb
xorl %eax, %eax
cmpl $0x0, 0xf3dab(%rip)     # 0x116888
sete %al
movl %eax, 0xf3da2(%rip)     # 0x116888
jmp 0x22ccb
xorl %eax, %eax
cmpl $0x0, 0xf3d90(%rip)     # 0x116884
sete %al
movl %eax, 0xf3d87(%rip)     # 0x116884
jmp 0x22ccb
xorl %eax, %eax
cmpl $0x0, 0xf8c9d(%rip)     # 0x11b7a8
sete %al
movl %eax, 0xf8c94(%rip)     # 0x11b7a8
jmp 0x22ccb
cmpl $0x20, %edi
je 0x22bf8
cmpl $0x1b, %edi
jne 0x22ccb
callq 0x21c6c
movl 0xf8c96(%rip), %ecx     # 0x11b7cc
incl %ecx
movl %ecx, 0xf8c8e(%rip)     # 0x11b7cc
movq 0xf8c6b(%rip), %rax     # 0x11b7b0
movl 0x23c(%rax), %eax
cmpl %eax, %ecx
jl 0x22ccb
decl %eax
movl %eax, 0xf8c71(%rip)     # 0x11b7cc
jmp 0x22ccb
movl 0xf8c6a(%rip), %ecx     # 0x11b7d0
incl %ecx
movl %ecx, 0xf8c62(%rip)     # 0x11b7d0
movq 0xf8c3b(%rip), %rax     # 0x11b7b0
movl 0x240(%rax), %eax
cmpl %eax, %ecx
jl 0x22ccb
decl %eax
movl %eax, 0xf8c45(%rip)     # 0x11b7d0
jmp 0x22ccb
movl 0xf8c32(%rip), %ecx     # 0x11b7c8
incl %ecx
movl %ecx, 0xf8c2a(%rip)     # 0x11b7c8
movq 0xf8c0b(%rip), %rax     # 0x11b7b0
movl 0x238(%rax), %eax
cmpl %eax, %ecx
jl 0x22ccb
decl %eax
movl %eax, 0xf8c0d(%rip)     # 0x11b7c8
jmp 0x22ccb
movl 0xf8c06(%rip), %eax     # 0x11b7cc
cmpl $0x2, %eax
pushq $0x1
popq %rcx
cmovgel %eax, %ecx
decl %ecx
movl %ecx, 0xf8bf5(%rip)     # 0x11b7cc
jmp 0x22ccb
movl 0xf8bee(%rip), %eax     # 0x11b7d0
cmpl $0x2, %eax
pushq $0x1
popq %rcx
cmovgel %eax, %ecx
decl %ecx
movl %ecx, 0xf8bdd(%rip)     # 0x11b7d0
jmp 0x22ccb
movq 0xf8ba1(%rip), %r12     # 0x11b7a0
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 0x3eece
movsd (%r15), %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0x50(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x3eece
movsd 0x8(%r15), %xmm0
movsd %xmm0, 0x10(%rsp)
leaq 0x38(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x3eece
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 0x924e7(%rip), %rdi     # 0xb518d
movsd 0x30(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
movsd 0x20(%rsp), %xmm2
movsd 0x18(%rsp), %xmm3
movsd 0x10(%rsp), %xmm4
movb $0x8, %al
callq 0x1f070
movl %ebp, 0xf8b77(%rip)     # 0x11b848
movl 0xf3bb9(%rip), %eax     # 0x116890
subl %ebx, %eax
movl %eax, 0xf8b6d(%rip)     # 0x11b84c
callq 0x8271e
callq 0x7dc80
addq $0x80, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq