// File: /workspace/github_cpp_makefile_star2_O2/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 0x10f10e(%rip), %r14d   # 0x1349cc
leal -0x64(%rax), %ecx
cmpl $0x4, %ecx
jb 0x258ef
addl $-0x68, %eax
cmpl $0x3, %eax
ja 0x25a1d
movl 0x114118(%rip), %edi    # 0x1399f0
leaq 0xa37e9(%rip), %rcx     # 0xc90c8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
incl %edi
jmp 0x25a18
movsd 0x114029(%rip), %xmm0   # 0x139920
movsd 0x114029(%rip), %xmm2   # 0x139928
movapd %xmm0, %xmm1
addsd %xmm2, %xmm1
movsd 0xa3741(%rip), %xmm3    # 0xc9050
mulsd %xmm3, %xmm1
subsd %xmm0, %xmm2
mulsd %xmm3, %xmm2
leaq 0xa3796(%rip), %rax     # 0xc90b8
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
ucomisd 0xa36ed(%rip), %xmm2    # 0xc9020
jb 0x259b2
addsd 0xa374b(%rip), %xmm2    # 0xc9088
jmp 0x259b2
movapd %xmm1, %xmm0
subsd %xmm2, %xmm0
ucomisd 0xa36d1(%rip), %xmm0    # 0xc9020
jb 0x259b2
movapd %xmm1, %xmm0
addsd %xmm2, %xmm0
movsd 0xa371f(%rip), %xmm3    # 0xc9080
ucomisd %xmm0, %xmm3
jb 0x259b2
addsd 0xa36b1(%rip), %xmm2    # 0xc9020
jmp 0x259b2
xorl %edi, %edi
jmp 0x25a18
movapd %xmm1, %xmm0
subsd %xmm2, %xmm0
ucomisd 0xa3698(%rip), %xmm0    # 0xc9020
jb 0x259b2
addsd 0xa36f6(%rip), %xmm1    # 0xc9088
jmp 0x259b2
movapd %xmm1, %xmm0
addsd %xmm2, %xmm0
movsd 0xa36dc(%rip), %xmm3    # 0xc9080
ucomisd %xmm0, %xmm3
jb 0x259b2
addsd 0xa366e(%rip), %xmm1    # 0xc9020
movapd %xmm1, %xmm0
subsd %xmm2, %xmm0
addsd %xmm2, %xmm1
movsd %xmm0, 0x113f5a(%rip)   # 0x139920
movsd %xmm1, 0x113f5a(%rip)   # 0x139928
movq 0x113fcb(%rip), %rdi    # 0x1399a0
callq 0x43578
movsd %xmm0, 0x8(%rsp)
movq 0x113fb9(%rip), %rdi    # 0x1399a0
movsd 0x113f39(%rip), %xmm0   # 0x139928
callq 0x43578
movsd 0x8(%rsp), %xmm1
movsd %xmm1, 0x113f2e(%rip)   # 0x139930
movsd %xmm0, 0x113f2e(%rip)   # 0x139938
jmp 0x25a1d
movq 0x113f9d(%rip), %rax    # 0x1399b0
movl 0x14(%rax), %edi
decl %edi
callq 0x25a3f
subl %ebp, %r14d
movl %ebx, 0x113f9a(%rip)    # 0x1399c0
movl %r14d, 0x113f97(%rip)   # 0x1399c4
callq 0xc1082
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0xbc5e4