// File: /workspace/github_cpp_makefile_star2_O1/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
cmpl $0x4f, %edi
jg 0x23503
leal -0x41(%rdi), %eax
cmpl $0x8, %eax
ja 0x23593
leaq 0xa1be5(%rip), %rcx     # 0xc50c8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
xorl %eax, %eax
cmpl $0x0, 0x1042cf(%rip)    # 0x1277c4
sete %al
movl %eax, 0x1042c6(%rip)    # 0x1277c4
jmp 0x2379e
leal -0x50(%rdi), %eax
cmpl $0x12, %eax
jbe 0x2353e
addl $-0x67, %edi
cmpl $0x13, %edi
ja 0x2379e
leaq 0xa1c1a(%rip), %rax     # 0xc5138
movslq (%rax,%rdi,4), %rcx
addq %rax, %rcx
jmpq *%rcx
xorl %eax, %eax
cmpl $0x0, 0x104268(%rip)    # 0x127798
sete %al
movl %eax, 0x10425f(%rip)    # 0x127798
jmp 0x2379e
leaq 0xa1ba7(%rip), %rcx     # 0xc50ec
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
xorl %eax, %eax
cmpl $0x0, 0x104271(%rip)    # 0x1277c8
sete %al
movl %eax, 0x104268(%rip)    # 0x1277c8
jmp 0x2379e
xorl %eax, %eax
cmpl $0x0, 0xff30a(%rip)     # 0x122878
sete %al
movl %eax, 0xff301(%rip)     # 0x122878
jmp 0x2379e
xorl %eax, %eax
cmpl $0x0, 0xff2ef(%rip)     # 0x122874
sete %al
movl %eax, 0xff2e6(%rip)     # 0x122874
jmp 0x2379e
cmpl $0x20, %edi
jne 0x236ae
movq 0x1041ed(%rip), %r12    # 0x127790
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 0x42d74
movsd (%r15), %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0x50(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x42d74
movsd 0x8(%r15), %xmm0
movsd %xmm0, 0x10(%rsp)
leaq 0x38(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x42d74
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 0xa1b43(%rip), %rdi     # 0xc518d
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
jmp 0x2379e
xorl %eax, %eax
cmpl $0x0, 0x10412f(%rip)    # 0x1277ac
sete %al
movl %eax, 0x104126(%rip)    # 0x1277ac
movl %eax, 0x104124(%rip)    # 0x1277b0
movl %eax, 0x104122(%rip)    # 0x1277b4
jmp 0x2379e
xorl %eax, %eax
cmpl $0x0, 0x104108(%rip)    # 0x1277a8
sete %al
movl %eax, 0x1040ff(%rip)    # 0x1277a8
jmp 0x2379e
cmpl $0x1b, %edi
jne 0x2379e
movl 0x1040cb(%rip), %edi    # 0x127788
callq 0x8ed0c
xorl %edi, %edi
callq 0x1f930
movl 0x1040ed(%rip), %ecx    # 0x1277bc
incl %ecx
movl %ecx, 0x1040e5(%rip)    # 0x1277bc
movq 0x1040c2(%rip), %rax    # 0x1277a0
movl 0x23c(%rax), %eax
cmpl %eax, %ecx
jl 0x2379e
decl %eax
movl %eax, 0x1040c8(%rip)    # 0x1277bc
jmp 0x2379e
movl 0x1040b9(%rip), %ecx    # 0x1277b8
incl %ecx
movl %ecx, 0x1040b1(%rip)    # 0x1277b8
movq 0x104092(%rip), %rax    # 0x1277a0
movl 0x238(%rax), %eax
cmpl %eax, %ecx
jl 0x2379e
decl %eax
movl %eax, 0x104094(%rip)    # 0x1277b8
jmp 0x2379e
movl 0x104094(%rip), %ecx    # 0x1277c0
incl %ecx
movl %ecx, 0x10408c(%rip)    # 0x1277c0
movq 0x104065(%rip), %rax    # 0x1277a0
movl 0x240(%rax), %eax
cmpl %eax, %ecx
jl 0x2379e
decl %eax
movl %eax, 0x104073(%rip)    # 0x1277c0
jmp 0x2379e
movl 0x104067(%rip), %eax    # 0x1277bc
cmpl $0x2, %eax
movl $0x1, %ecx
cmovgel %eax, %ecx
decl %ecx
movl %ecx, 0x104054(%rip)    # 0x1277bc
jmp 0x2379e
movl 0x104048(%rip), %eax    # 0x1277b8
cmpl $0x2, %eax
movl $0x1, %ecx
cmovgel %eax, %ecx
decl %ecx
movl %ecx, 0x104035(%rip)    # 0x1277b8
jmp 0x2379e
movl 0x104035(%rip), %eax    # 0x1277c0
cmpl $0x2, %eax
movl $0x1, %ecx
cmovgel %eax, %ecx
decl %ecx
movl %ecx, 0x104022(%rip)    # 0x1277c0
movl %ebp, 0x104094(%rip)    # 0x127838
movl 0xff0d6(%rip), %eax     # 0x122880
subl %ebx, %eax
movl %eax, 0x10408a(%rip)    # 0x12783c
callq 0x8d914
callq 0x889cc
addq $0x80, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq