// File: /workspace/github_cpp_makefile_star2_O3/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 0x11e026(%rip), %r14d   # 0x1449ac
leal -0x64(%rax), %ecx
cmpl $0x4, %ecx
jb 0x269b7
addl $-0x68, %eax
cmpl $0x3, %eax
ja 0x26ae5
movl 0x123030(%rip), %edi    # 0x1499d0
leaq 0xb8729(%rip), %rcx     # 0xdf0d0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
incl %edi
jmp 0x26ae0
movsd 0x122f41(%rip), %xmm0   # 0x149900
movsd 0x122f41(%rip), %xmm2   # 0x149908
movapd %xmm0, %xmm1
addsd %xmm2, %xmm1
movsd 0xb8661(%rip), %xmm3    # 0xdf038
mulsd %xmm3, %xmm1
subsd %xmm0, %xmm2
mulsd %xmm3, %xmm2
leaq 0xb86d6(%rip), %rax     # 0xdf0c0
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
ucomisd 0xb8625(%rip), %xmm2    # 0xdf020
jb 0x26a7a
addsd 0xb868b(%rip), %xmm2    # 0xdf090
jmp 0x26a7a
movapd %xmm1, %xmm0
subsd %xmm2, %xmm0
ucomisd 0xb8609(%rip), %xmm0    # 0xdf020
jb 0x26a7a
movapd %xmm1, %xmm0
addsd %xmm2, %xmm0
movsd 0xb865f(%rip), %xmm3    # 0xdf088
ucomisd %xmm0, %xmm3
jb 0x26a7a
addsd 0xb85e9(%rip), %xmm2    # 0xdf020
jmp 0x26a7a
xorl %edi, %edi
jmp 0x26ae0
movapd %xmm1, %xmm0
subsd %xmm2, %xmm0
ucomisd 0xb85d0(%rip), %xmm0    # 0xdf020
jb 0x26a7a
addsd 0xb8636(%rip), %xmm1    # 0xdf090
jmp 0x26a7a
movapd %xmm1, %xmm0
addsd %xmm2, %xmm0
movsd 0xb861c(%rip), %xmm3    # 0xdf088
ucomisd %xmm0, %xmm3
jb 0x26a7a
addsd 0xb85a6(%rip), %xmm1    # 0xdf020
movapd %xmm1, %xmm0
subsd %xmm2, %xmm0
addsd %xmm2, %xmm1
movsd %xmm0, 0x122e72(%rip)   # 0x149900
movsd %xmm1, 0x122e72(%rip)   # 0x149908
movq 0x122ee3(%rip), %rdi    # 0x149980
callq 0x48c8a
movsd %xmm0, 0x8(%rsp)
movq 0x122ed1(%rip), %rdi    # 0x149980
movsd 0x122e51(%rip), %xmm0   # 0x149908
callq 0x48c8a
movsd 0x8(%rsp), %xmm1
movsd %xmm1, 0x122e46(%rip)   # 0x149910
movsd %xmm0, 0x122e46(%rip)   # 0x149918
jmp 0x26ae5
movq 0x122eb5(%rip), %rax    # 0x149990
movl 0x14(%rax), %edi
decl %edi
callq 0x26b07
subl %ebp, %r14d
movl %ebx, 0x122eb2(%rip)    # 0x1499a0
movl %r14d, 0x122eaf(%rip)   # 0x1499a4
callq 0xd6bd9
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0xd1d20