// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/apps/mshview/mshview.cpp
// Function: GLUTKeyboard(unsigned char, int, int)
void GLUTKeyboard(unsigned char key, int x, int y)
{
  // Invert y coordinate
  y = GLUTwindow_height - y;

  // Process keyboard button event 
  switch (key) {
  case '0':
  case '1':
  case '2':
  case '3':
  case '4':
  case '5':
  case '6':
  case '7':
  case '8':
  case '9':
    if (key == '0') current_mesh = -1;
    else if (key - '1' < meshes.NEntries()) current_mesh = key - '1';
    else printf("Unable to select mesh %d\n", key - '1');
    break;

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

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

  case 'C': 
  case 'c':
    show_vertex_colors = !show_vertex_colors;
    break;
    
  case 'E':
    show_edge_names = !show_edge_names;
    break;

  case 'e':
    show_edges = !show_edges;
    break;

  case 'F':
    show_face_names = !show_face_names;
    break;

  case 'f':
    show_faces = !show_faces;
    break;

  case 'L':
    show_category_names = !show_category_names;
    break;

  case 'l':
    show_categories = !show_categories;
    break;

  case 'M':
    show_material_names = !show_material_names;
    break;

  case 'm':
    show_materials = !show_materials;
    break;

  case 'N':
    show_vertex_normals = !show_vertex_normals;
    break;

  case 'n':
    show_face_normals = !show_face_normals;
    break;

  case 'O':
  case 'o':
    show_world_origin = !show_world_origin;
    break;

  case 'S':
    show_segment_names = !show_segment_names;
    break;

  case 's':
    show_segments = !show_segments;
    break;

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

  case 'V':
    show_vertex_names = !show_vertex_names;
    break;

  case 'v':
    show_vertices = !show_vertices;
    break;

  case 'X':
  case 'x':
    show_boundaries = !show_boundaries;
    break;

  case ' ': {
    // Print camera
    const R3Camera& camera = viewer->Camera();
    RNFail("%g %g %g  %g %g %g  %g %g %g  %g %g  1\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.XFOV(), camera.YFOV());
    printf("%g %g %g  %g %g %g  %g %g %g  %g %g  1\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.XFOV(), camera.YFOV());
    break; }
      
  case 16:  // ctrl-P
    image_name = "mshview.png";
    break; 

  case 27: // ESCAPE
    GLUTStop();
    break;
  }

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

  // Remember modifiers 
  GLUTmodifiers = glutGetModifiers();

  // Redraw
  glutPostRedisplay();  
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl %edx, %ebp
movl %esi, %ebx
movl 0x116c55(%rip), %r13d   # 0x13d9bc
leal -0x1b(%rdi), %eax
cmpl $0x5d, %eax
ja 0x26e3a
leaq 0xb331e(%rip), %rcx     # 0xda098
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movzbl %dil, %esi
addl $-0x31, %esi
cmpl 0x11bb64(%rip), %esi    # 0x1428f4
jge 0x26d9d
movl %esi, 0x116c18(%rip)    # 0x13d9b0
jmp 0x27141
leaq 0xb346c(%rip), %rdi     # 0xda210
xorl %eax, %eax
callq 0x21080
jmp 0x27141
xorl %eax, %eax
cmpl $0x0, 0x11c23f(%rip)    # 0x142ff8
sete %al
movl %eax, 0x11c236(%rip)    # 0x142ff8
jmp 0x27141
xorl %eax, %eax
cmpl $0x0, 0x11c210(%rip)    # 0x142fe0
sete %al
movl %eax, 0x11c207(%rip)    # 0x142fe0
jmp 0x27141
xorl %eax, %eax
cmpl $0x0, 0x11c279(%rip)    # 0x143060
sete %al
movl %eax, 0x11c270(%rip)    # 0x143060
jmp 0x27141
xorl %eax, %eax
cmpl $0x0, 0x11c226(%rip)    # 0x143024
sete %al
movl %eax, 0x11c21d(%rip)    # 0x143024
jmp 0x27141
xorl %eax, %eax
cmpl $0x0, 0x11c20b(%rip)    # 0x143020
sete %al
movl %eax, 0x11c202(%rip)    # 0x143020
jmp 0x27141
xorl %eax, %eax
cmpl $0x0, 0x11c1c4(%rip)    # 0x142ff0
sete %al
movl %eax, 0x11c1bb(%rip)    # 0x142ff0
jmp 0x27141
cmpl $0x10, %edi
jne 0x27141
leaq 0xb3408(%rip), %rax     # 0xda252
movq %rax, 0x11c1d7(%rip)    # 0x143028
jmp 0x27141
xorl %eax, %eax
cmpl $0x0, 0x11c1a1(%rip)    # 0x143000
sete %al
movl %eax, 0x11c198(%rip)    # 0x143000
jmp 0x27141
xorl %eax, %eax
cmpl $0x0, 0x11c176(%rip)    # 0x142fec
sete %al
movl %eax, 0x11c16d(%rip)    # 0x142fec
jmp 0x27141
xorl %eax, %eax
cmpl $0x0, 0x11c15b(%rip)    # 0x142fe8
sete %al
movl %eax, 0x11c152(%rip)    # 0x142fe8
jmp 0x27141
xorl %eax, %eax
cmpl $0x0, 0x11c140(%rip)    # 0x142fe4
sete %al
movl %eax, 0x11c137(%rip)    # 0x142fe4
jmp 0x27141
xorl %eax, %eax
cmpl $0x0, 0x116af9(%rip)    # 0x13d9b4
sete %al
movl %eax, 0x116af0(%rip)    # 0x13d9b4
jmp 0x27141
xorl %eax, %eax
cmpl $0x0, 0x11c142(%rip)    # 0x143014
sete %al
movl %eax, 0x11c139(%rip)    # 0x143014
jmp 0x27141
xorl %eax, %eax
cmpl $0x0, 0x11c127(%rip)    # 0x143010
sete %al
movl %eax, 0x11c11e(%rip)    # 0x143010
jmp 0x27141
xorl %eax, %eax
cmpl $0x0, 0x11c11c(%rip)    # 0x14301c
sete %al
movl %eax, 0x11c113(%rip)    # 0x14301c
jmp 0x27141
xorl %eax, %eax
cmpl $0x0, 0x11c0e5(%rip)    # 0x142ffc
sete %al
movl %eax, 0x11c0dc(%rip)    # 0x142ffc
jmp 0x27141
movl $0xffffffff, 0x116a81(%rip) # imm = 0xFFFFFFFF
jmp 0x27141
movq 0x11c09d(%rip), %r15    # 0x142fd8
movsd 0x8(%r15), %xmm0
movsd %xmm0, 0x38(%rsp)
movsd 0x10(%r15), %xmm0
movsd %xmm0, 0x30(%rsp)
movsd 0x18(%r15), %xmm0
movsd %xmm0, 0x28(%rsp)
leaq 0x50(%r15), %r14
leaq 0x70(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x76360
movsd (%r12), %xmm0
movsd %xmm0, 0x20(%rsp)
leaq 0x58(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x76360
movsd 0x8(%r12), %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0x40(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x76360
movsd 0x10(%r12), %xmm5
movsd 0x38(%r15), %xmm6
movsd 0x40(%r15), %xmm7
movsd 0x48(%r15), %xmm0
movsd 0x68(%r15), %xmm1
movsd 0x70(%r15), %xmm2
movsd %xmm2, 0x10(%rsp)
movsd %xmm1, 0x8(%rsp)
movsd %xmm0, (%rsp)
leaq 0xb3241(%rip), %rdi     # 0xda22a
movsd 0x38(%rsp), %xmm0
movsd 0x30(%rsp), %xmm1
movsd 0x28(%rsp), %xmm2
movsd 0x20(%rsp), %xmm3
movsd 0x18(%rsp), %xmm4
movb $0x8, %al
callq 0x899c6
movsd 0x8(%r15), %xmm0
movsd %xmm0, 0x38(%rsp)
movsd 0x10(%r15), %xmm0
movsd %xmm0, 0x30(%rsp)
movsd 0x18(%r15), %xmm0
movsd %xmm0, 0x28(%rsp)
leaq 0x70(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x76360
movsd (%r12), %xmm0
movsd %xmm0, 0x20(%rsp)
leaq 0x58(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x76360
movsd 0x8(%r12), %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0x40(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x76360
movsd 0x10(%r12), %xmm5
movsd 0x38(%r15), %xmm6
movsd 0x40(%r15), %xmm7
movsd 0x48(%r15), %xmm0
movsd 0x68(%r15), %xmm1
movsd 0x70(%r15), %xmm2
movsd %xmm2, 0x10(%rsp)
movsd %xmm1, 0x8(%rsp)
movsd %xmm0, (%rsp)
leaq 0xb3172(%rip), %rdi     # 0xda22a
movsd 0x38(%rsp), %xmm0
movsd 0x30(%rsp), %xmm1
movsd 0x28(%rsp), %xmm2
movsd 0x20(%rsp), %xmm3
movsd 0x18(%rsp), %xmm4
movb $0x8, %al
callq 0x21080
jmp 0x27141
xorl %eax, %eax
cmpl $0x0, 0x11bf0c(%rip)    # 0x142ff4
sete %al
movl %eax, 0x11bf03(%rip)    # 0x142ff4
jmp 0x27141
xorl %eax, %eax
cmpl $0x0, 0x11bf0c(%rip)    # 0x143008
sete %al
movl %eax, 0x11bf03(%rip)    # 0x143008
jmp 0x27141
xorl %eax, %eax
cmpl $0x0, 0x11befc(%rip)    # 0x14300c
sete %al
movl %eax, 0x11bef3(%rip)    # 0x14300c
jmp 0x27141
xorl %eax, %eax
cmpl $0x0, 0x11bee0(%rip)    # 0x143004
sete %al
movl %eax, 0x11bed7(%rip)    # 0x143004
jmp 0x27141
xorl %eax, %eax
cmpl $0x0, 0x11bee0(%rip)    # 0x143018
sete %al
movl %eax, 0x11bed7(%rip)    # 0x143018
subl %ebp, %r13d
movl %ebx, 0x11bee6(%rip)    # 0x143030
movl %r13d, 0x11bee3(%rip)   # 0x143034
callq 0xd1d11
callq 0xcce58
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x11be5d(%rip), %edi    # 0x142fd0
callq 0xd314e
xorl %edi, %edi
callq 0x21ae0