// File: /workspace/github_cpp_makefile_star2_O3/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 0x234cb
leal -0x41(%rdi), %eax
cmpl $0x8, %eax
ja 0x2355b
leaq 0xa0c1d(%rip), %rcx     # 0xc40c8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
xorl %eax, %eax
cmpl $0x0, 0x103307(%rip)    # 0x1267c4
sete %al
movl %eax, 0x1032fe(%rip)    # 0x1267c4
jmp 0x23766
leal -0x50(%rdi), %eax
cmpl $0x12, %eax
jbe 0x23506
addl $-0x67, %edi
cmpl $0x13, %edi
ja 0x23766
leaq 0xa0c52(%rip), %rax     # 0xc4138
movslq (%rax,%rdi,4), %rcx
addq %rax, %rcx
jmpq *%rcx
xorl %eax, %eax
cmpl $0x0, 0x1032a0(%rip)    # 0x126798
sete %al
movl %eax, 0x103297(%rip)    # 0x126798
jmp 0x23766
leaq 0xa0bdf(%rip), %rcx     # 0xc40ec
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
xorl %eax, %eax
cmpl $0x0, 0x1032a9(%rip)    # 0x1267c8
sete %al
movl %eax, 0x1032a0(%rip)    # 0x1267c8
jmp 0x23766
xorl %eax, %eax
cmpl $0x0, 0xfe342(%rip)     # 0x121878
sete %al
movl %eax, 0xfe339(%rip)     # 0x121878
jmp 0x23766
xorl %eax, %eax
cmpl $0x0, 0xfe327(%rip)     # 0x121874
sete %al
movl %eax, 0xfe31e(%rip)     # 0x121874
jmp 0x23766
cmpl $0x20, %edi
jne 0x23676
movq 0x103225(%rip), %r12    # 0x126790
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 0x42a24
movsd (%r15), %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0x50(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x42a24
movsd 0x8(%r15), %xmm0
movsd %xmm0, 0x10(%rsp)
leaq 0x38(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x42a24
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 0xa0b7b(%rip), %rdi     # 0xc418d
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 0x23766
xorl %eax, %eax
cmpl $0x0, 0x103167(%rip)    # 0x1267ac
sete %al
movl %eax, 0x10315e(%rip)    # 0x1267ac
movl %eax, 0x10315c(%rip)    # 0x1267b0
movl %eax, 0x10315a(%rip)    # 0x1267b4
jmp 0x23766
xorl %eax, %eax
cmpl $0x0, 0x103140(%rip)    # 0x1267a8
sete %al
movl %eax, 0x103137(%rip)    # 0x1267a8
jmp 0x23766
cmpl $0x1b, %edi
jne 0x23766
movl 0x103103(%rip), %edi    # 0x126788
callq 0x8dcc2
xorl %edi, %edi
callq 0x1f930
movl 0x103125(%rip), %ecx    # 0x1267bc
incl %ecx
movl %ecx, 0x10311d(%rip)    # 0x1267bc
movq 0x1030fa(%rip), %rax    # 0x1267a0
movl 0x23c(%rax), %eax
cmpl %eax, %ecx
jl 0x23766
decl %eax
movl %eax, 0x103100(%rip)    # 0x1267bc
jmp 0x23766
movl 0x1030f1(%rip), %ecx    # 0x1267b8
incl %ecx
movl %ecx, 0x1030e9(%rip)    # 0x1267b8
movq 0x1030ca(%rip), %rax    # 0x1267a0
movl 0x238(%rax), %eax
cmpl %eax, %ecx
jl 0x23766
decl %eax
movl %eax, 0x1030cc(%rip)    # 0x1267b8
jmp 0x23766
movl 0x1030cc(%rip), %ecx    # 0x1267c0
incl %ecx
movl %ecx, 0x1030c4(%rip)    # 0x1267c0
movq 0x10309d(%rip), %rax    # 0x1267a0
movl 0x240(%rax), %eax
cmpl %eax, %ecx
jl 0x23766
decl %eax
movl %eax, 0x1030ab(%rip)    # 0x1267c0
jmp 0x23766
movl 0x10309f(%rip), %eax    # 0x1267bc
cmpl $0x2, %eax
movl $0x1, %ecx
cmovgel %eax, %ecx
decl %ecx
movl %ecx, 0x10308c(%rip)    # 0x1267bc
jmp 0x23766
movl 0x103080(%rip), %eax    # 0x1267b8
cmpl $0x2, %eax
movl $0x1, %ecx
cmovgel %eax, %ecx
decl %ecx
movl %ecx, 0x10306d(%rip)    # 0x1267b8
jmp 0x23766
movl 0x10306d(%rip), %eax    # 0x1267c0
cmpl $0x2, %eax
movl $0x1, %ecx
cmovgel %eax, %ecx
decl %ecx
movl %ecx, 0x10305a(%rip)    # 0x1267c0
movl %ebp, 0x1030cc(%rip)    # 0x126838
movl 0xfe10e(%rip), %eax     # 0x121880
subl %ebx, %eax
movl %eax, 0x1030c2(%rip)    # 0x12683c
callq 0x8c885
callq 0x879cc
addq $0x80, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq