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

  // Process keyboard button event 
  switch (key) {
  case GLUT_KEY_HOME:
  case GLUT_KEY_END:
  case GLUT_KEY_PAGE_DOWN:
  case GLUT_KEY_PAGE_UP: {
    int property_index = current_property_index;
    if (key == GLUT_KEY_PAGE_DOWN) property_index--;
    else if (key == GLUT_KEY_PAGE_UP) property_index++;
    else if (key == GLUT_KEY_HOME) property_index = 0;
    else if (key == GLUT_KEY_END) property_index = properties->NProperties() - 1;
    SelectProperty(property_index);
    break; }

  case GLUT_KEY_RIGHT:
  case GLUT_KEY_LEFT:
  case GLUT_KEY_DOWN:
  case GLUT_KEY_UP: {
    RNScalar mid = percentile_range.Mid();
    RNScalar radius = percentile_range.Radius();
    if (key == GLUT_KEY_LEFT) { if (radius >= 1) radius -= 1; }
    else if (key == GLUT_KEY_RIGHT) { if ((mid - radius >= 1) && (mid + radius <= 99)) radius += 1; }
    else if (key == GLUT_KEY_DOWN) { if (mid - radius >= 1) mid -= 1; }
    else if (key == GLUT_KEY_UP) { if (mid + radius <= 99) mid += 1; }
    percentile_range.Reset(mid - radius, mid + radius);
    RNScalar min_value = current_property->Percentile(percentile_range.Min());
    RNScalar max_value = current_property->Percentile(percentile_range.Max());
    value_range.Reset(min_value, max_value);
    break; }
  }

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

  // Remember modifiers 
  GLUTmodifiers = glutGetModifiers();

  // Redraw
  glutPostRedisplay();
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %edx, %ebp
movl %esi, %ebx
movl %edi, %eax
movl 0x11ffe7(%rip), %r14d   # 0x1469ac
leal -0x64(%rax), %ecx
cmpl $0x4, %ecx
jb 0x269fc
addl $-0x68, %eax
cmpl $0x3, %eax
ja 0x26b30
movl 0x124ff1(%rip), %edi    # 0x14b9d0
ja 0x26b2b
leaq 0xba6e4(%rip), %rcx     # 0xe10d0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
incl %edi
jmp 0x26b2b
movsd 0x124efc(%rip), %xmm0   # 0x14b900
movsd 0x124efc(%rip), %xmm2   # 0x14b908
movapd %xmm0, %xmm1
addsd %xmm2, %xmm1
movsd 0xba61c(%rip), %xmm3    # 0xe1038
mulsd %xmm3, %xmm1
subsd %xmm0, %xmm2
mulsd %xmm3, %xmm2
jae 0x26ac5
leaq 0xba68b(%rip), %rax     # 0xe10c0
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
ucomisd 0xba5da(%rip), %xmm2    # 0xe1020
jb 0x26ac5
addsd 0xba640(%rip), %xmm2    # 0xe1090
jmp 0x26ac5
movapd %xmm1, %xmm0
subsd %xmm2, %xmm0
ucomisd 0xba5be(%rip), %xmm0    # 0xe1020
jb 0x26ac5
movapd %xmm1, %xmm0
addsd %xmm2, %xmm0
movsd 0xba614(%rip), %xmm3    # 0xe1088
ucomisd %xmm0, %xmm3
jb 0x26ac5
addsd 0xba59e(%rip), %xmm2    # 0xe1020
jmp 0x26ac5
xorl %edi, %edi
jmp 0x26b2b
movapd %xmm1, %xmm0
subsd %xmm2, %xmm0
ucomisd 0xba585(%rip), %xmm0    # 0xe1020
jb 0x26ac5
addsd 0xba5eb(%rip), %xmm1    # 0xe1090
jmp 0x26ac5
movapd %xmm1, %xmm0
addsd %xmm2, %xmm0
movsd 0xba5d1(%rip), %xmm3    # 0xe1088
ucomisd %xmm0, %xmm3
jb 0x26ac5
addsd 0xba55b(%rip), %xmm1    # 0xe1020
movapd %xmm1, %xmm0
subsd %xmm2, %xmm0
addsd %xmm2, %xmm1
movsd %xmm0, 0x124e27(%rip)   # 0x14b900
movsd %xmm1, 0x124e27(%rip)   # 0x14b908
movq 0x124e98(%rip), %rdi    # 0x14b980
callq 0x49310
movsd %xmm0, 0x8(%rsp)
movq 0x124e86(%rip), %rdi    # 0x14b980
movsd 0x124e06(%rip), %xmm0   # 0x14b908
callq 0x49310
movsd 0x8(%rsp), %xmm1
movsd %xmm1, 0x124dfb(%rip)   # 0x14b910
movsd %xmm0, 0x124dfb(%rip)   # 0x14b918
jmp 0x26b30
movq 0x124e6a(%rip), %rax    # 0x14b990
movl 0x14(%rax), %edi
decl %edi
callq 0x26b52
subl %ebp, %r14d
movl %ebx, 0x124e67(%rip)    # 0x14b9a0
movl %r14d, 0x124e64(%rip)   # 0x14b9a4
callq 0xd8b9c
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0xd3c54