// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/apps/sflview/sflview.cpp
// Function: GLUTSpecial(int, int, int)
void GLUTSpecial(int key, int x, int y)
{
  // Invert y coordinate
  y = GLUTwindow_height - y;

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

  // Translate key
  int translated_key = key;
  switch (key) {
    case GLUT_KEY_PAGE_DOWN: translated_key = R3_SURFEL_VIEWER_PAGE_DOWN_KEY; break;
    case GLUT_KEY_PAGE_UP: translated_key = R3_SURFEL_VIEWER_PAGE_UP_KEY; break;
    case GLUT_KEY_DOWN: translated_key = R3_SURFEL_VIEWER_DOWN_KEY; break;
    case GLUT_KEY_UP: translated_key = R3_SURFEL_VIEWER_UP_KEY; break;
    case GLUT_KEY_LEFT: translated_key = R3_SURFEL_VIEWER_LEFT_KEY; break;
    case GLUT_KEY_RIGHT: translated_key = R3_SURFEL_VIEWER_RIGHT_KEY; break;
    case GLUT_KEY_HOME: translated_key = R3_SURFEL_VIEWER_HOME_KEY; break;
    case GLUT_KEY_END: translated_key = R3_SURFEL_VIEWER_END_KEY; break;
    case GLUT_KEY_INSERT: translated_key = R3_SURFEL_VIEWER_INSERT_KEY; break;
    case GLUT_KEY_F1: translated_key = R3_SURFEL_VIEWER_F1_KEY; break;
    case GLUT_KEY_F2: translated_key = R3_SURFEL_VIEWER_F2_KEY; break;
    case GLUT_KEY_F3: translated_key = R3_SURFEL_VIEWER_F3_KEY; break;
    case GLUT_KEY_F4: translated_key = R3_SURFEL_VIEWER_F4_KEY; break;
    case GLUT_KEY_F5: translated_key = R3_SURFEL_VIEWER_F5_KEY; break;
    case GLUT_KEY_F6: translated_key = R3_SURFEL_VIEWER_F6_KEY; break;
    case GLUT_KEY_F7: translated_key = R3_SURFEL_VIEWER_F7_KEY; break;
    case GLUT_KEY_F8: translated_key = R3_SURFEL_VIEWER_F8_KEY; break;
    case GLUT_KEY_F9: translated_key = R3_SURFEL_VIEWER_F9_KEY; break;
    case GLUT_KEY_F10: translated_key = R3_SURFEL_VIEWER_F10_KEY; break;
    case GLUT_KEY_F11: translated_key = R3_SURFEL_VIEWER_F11_KEY; break;
    case GLUT_KEY_F12: translated_key = R3_SURFEL_VIEWER_F12_KEY; break;
  }

  // Send keyboard event to viewer
  if (viewer->Keyboard(x, y, translated_key, shift, ctrl, alt)) {
    glutPostRedisplay();
  }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %esi, %ebx
movl %edi, %r14d
movl 0x17cc5e(%rip), %ebp    # 0x1a7a04
subl %edx, %ebp
callq 0x111bae
movl %eax, %r8d
andl $0x1, %r8d
movl %eax, %r9d
andl $0x2, %r9d
andl $0x4, %eax
leal -0x1(%r14), %ecx
cmpl $0xb, %ecx
ja 0x2ade2
leaq 0xef276(%rip), %rdx     # 0x11a044
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movl $0x428, %r14d           # imm = 0x428
jmp 0x2aea6
leal -0x64(%r14), %ecx
cmpl $0x8, %ecx
ja 0x2aea6
leaq 0xef27e(%rip), %rdx     # 0x11a074
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movl $0x400, %r14d           # imm = 0x400
jmp 0x2aea6
movl $0x433, %r14d           # imm = 0x433
jmp 0x2aea6
movl $0x408, %r14d           # imm = 0x408
jmp 0x2aea6
movl $0x42c, %r14d           # imm = 0x42C
jmp 0x2aea6
movl $0x431, %r14d           # imm = 0x431
jmp 0x2aea6
movl $0x401, %r14d           # imm = 0x401
jmp 0x2aea6
movl $0x42a, %r14d           # imm = 0x42A
jmp 0x2aea6
movl $0x402, %r14d           # imm = 0x402
jmp 0x2aea6
movl $0x405, %r14d           # imm = 0x405
jmp 0x2aea6
movl $0x403, %r14d           # imm = 0x403
jmp 0x2aea6
movl $0x42b, %r14d           # imm = 0x42B
jmp 0x2aea6
movl $0x42f, %r14d           # imm = 0x42F
jmp 0x2aea6
movl $0x429, %r14d           # imm = 0x429
jmp 0x2aea6
movl $0x407, %r14d           # imm = 0x407
jmp 0x2aea6
movl $0x404, %r14d           # imm = 0x404
jmp 0x2aea6
movl $0x42d, %r14d           # imm = 0x42D
jmp 0x2aea6
movl $0x406, %r14d           # imm = 0x406
jmp 0x2aea6
movl $0x42e, %r14d           # imm = 0x42E
jmp 0x2aea6
movl $0x432, %r14d           # imm = 0x432
jmp 0x2aea6
movl $0x430, %r14d           # imm = 0x430
movq 0x181af3(%rip), %rdi    # 0x1ac9a0
movq (%rdi), %r10
movl %eax, (%rsp)
movl %ebx, %esi
movl %ebp, %edx
movl %r14d, %ecx
callq *0x40(%r10)
addq $0x10, %rsp
testl %eax, %eax
je 0x2aecf
popq %rbx
popq %r14
popq %rbp
jmp 0x10d110
popq %rbx
popq %r14
popq %rbp
retq