#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
#define GLUT_KEY_DOWN 133
#define GLUT_KEY_F1 132
#define GLUT_KEY_F2 131
#define GLUT_KEY_LEFT 130
#define GLUT_KEY_RIGHT 129
#define GLUT_KEY_UP 128
int glutGetModifiers();
int /*<<< orphan*/ move_camera(double, double, double);
int /*<<< orphan*/ move_camera_focus(double, double);
int /*<<< orphan*/ printf(char *);
void specialkey(int key, int x, int y) {
  static int cameramode = 0;
  int mods;
  mods = glutGetModifiers();
  switch (key) {
  case GLUT_KEY_F1: {
    cameramode = 0;
    printf("Moving camera position mode\n");
    break;
  }
  case GLUT_KEY_F2: {
    cameramode = 1;
    printf("Moving camera focus point mode\n");
    break;
  }
  case GLUT_KEY_LEFT: {
    if (cameramode == 0) {
      move_camera(0.0, 0.1, 0.0);
    } else {
      move_camera_focus(0.0, 0.1);
    }
    break;
  }
  case GLUT_KEY_RIGHT: {
    if (cameramode == 0) {
      move_camera(0.0, -0.1, 0.0);
    } else {
      move_camera_focus(0.0, -0.1);
    }
    break;
  }
  case GLUT_KEY_UP: {
    if (cameramode == 0) {
      move_camera(0.0, 0.0, 0.1);
    } else if (cameramode == 1) {
      move_camera_focus(0.1, 0.0);
    }
    break;
  }
  case GLUT_KEY_DOWN: {
    if (cameramode == 0) {
      move_camera(0.0, 0.0, -0.1);
    } else if (cameramode == 1) {
      move_camera_focus(-0.1, 0.0);
    }
    break;
  }
  default:
    break;
  };
}


x86 assembly (clang, -O0):
<specialkey>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
xor    %eax,%eax
call   1060 <glutGetModifiers@plt>
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x5,%eax
ja     12c6 <specialkey+0x186>
mov    -0x18(%rbp),%rax
lea    0xe95(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x0,0x2eb6(%rip)
lea    0xe93(%rip),%rdi
call   1030 <printf@plt>
jmp    12cb <specialkey+0x18b>
movl   $0x1,0x2e9b(%rip)
lea    0xe95(%rip),%rdi
call   1030 <printf@plt>
jmp    12cb <specialkey+0x18b>
cmpl   $0x0,0x2e83(%rip)
jne    11df <specialkey+0x9f>
xorps  %xmm2,%xmm2
movsd  0xe36(%rip),%xmm1
movaps %xmm2,%xmm0
call   1040 <move_camera@plt>
jmp    11ef <specialkey+0xaf>
xorps  %xmm0,%xmm0
movsd  0xe1e(%rip),%xmm1
call   1050 <move_camera_focus@plt>
jmp    12cb <specialkey+0x18b>
cmpl   $0x0,0x2e49(%rip)
jne    1219 <specialkey+0xd9>
xorps  %xmm2,%xmm2
movsd  0xdf4(%rip),%xmm1
movaps %xmm2,%xmm0
call   1040 <move_camera@plt>
jmp    1229 <specialkey+0xe9>
xorps  %xmm0,%xmm0
movsd  0xddc(%rip),%xmm1
call   1050 <move_camera_focus@plt>
jmp    12cb <specialkey+0x18b>
cmpl   $0x0,0x2e0f(%rip)
jne    1253 <specialkey+0x113>
xorps  %xmm1,%xmm1
movsd  0xdc2(%rip),%xmm2
movaps %xmm1,%xmm0
call   1040 <move_camera@plt>
jmp    1275 <specialkey+0x135>
cmpl   $0x1,0x2dea(%rip)
jne    1270 <specialkey+0x130>
movsd  0xda0(%rip),%xmm0
xorps  %xmm1,%xmm1
call   1050 <move_camera_focus@plt>
jmp    1275 <specialkey+0x135>
jmp    12cb <specialkey+0x18b>
cmpl   $0x0,0x2dc3(%rip)
jne    129f <specialkey+0x15f>
xorps  %xmm1,%xmm1
movsd  0xd6e(%rip),%xmm2
movaps %xmm1,%xmm0
call   1040 <move_camera@plt>
jmp    12c1 <specialkey+0x181>
cmpl   $0x1,0x2d9e(%rip)
jne    12bc <specialkey+0x17c>
movsd  0xd4c(%rip),%xmm0
xorps  %xmm1,%xmm1
call   1050 <move_camera_focus@plt>
jmp    12c1 <specialkey+0x181>
jmp    12cb <specialkey+0x18b>
jmp    12cb <specialkey+0x18b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<specialkey>:
push   %rbx
mov    %edi,%ebx
xor    %eax,%eax
call   1060 <glutGetModifiers@plt>
add    $0xffffff80,%ebx
cmp    $0x5,%ebx
ja     11e8 <specialkey+0xa8>
lea    0xeb3(%rip),%rax
movslq (%rax,%rbx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
cmpb   $0x0,0x2ed7(%rip)
je     11ea <specialkey+0xaa>
movsd  0xe91(%rip),%xmm0
jmp    11df <specialkey+0x9f>
cmpb   $0x0,0x2ec4(%rip)
je     11f4 <specialkey+0xb4>
movsd  0xe76(%rip),%xmm1
jmp    119d <specialkey+0x5d>
cmpb   $0x0,0x2eb1(%rip)
je     11fe <specialkey+0xbe>
movsd  0xe6b(%rip),%xmm1
xorps  %xmm0,%xmm0
pop    %rbx
jmp    1050 <move_camera_focus@plt>
movb   $0x1,0x2e97(%rip)
lea    0xe74(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>
movb   $0x0,0x2e83(%rip)
lea    0xe7f(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>
cmpb   $0x0,0x2e6f(%rip)
je     1212 <specialkey+0xd2>
movsd  0xe21(%rip),%xmm0
xorps  %xmm1,%xmm1
pop    %rbx
jmp    1050 <move_camera_focus@plt>
pop    %rbx
ret
movsd  0xe16(%rip),%xmm2
jmp    121a <specialkey+0xda>
movsd  0xe04(%rip),%xmm1
jmp    1206 <specialkey+0xc6>
movsd  0xe02(%rip),%xmm1
xorps  %xmm0,%xmm0
xorps  %xmm2,%xmm2
pop    %rbx
jmp    1040 <move_camera@plt>
movsd  0xde6(%rip),%xmm2
xorps  %xmm0,%xmm0
xorps  %xmm1,%xmm1
pop    %rbx
jmp    1040 <move_camera@plt>

LLVM IR (-O0):
@specialkey.cameramode = internal global i32 0
@.str = [29 x i8] c"Moving camera position mode\0A\00"
@.str.1 = [32 x i8] c"Moving camera focus point mode\0A\00"
define void @specialkey(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = call i32 (...) @glutGetModifiers()
store i32 %8, i32* %7
%9 = load i32, i32* %4
switch i32 %9, label %54 [
i32 132, label %10
i32 131, label %12
i32 130, label %14
i32 129, label %22
i32 128, label %30
i32 133, label %42
]
10: ; preds = %3
store i32 0, i32* @specialkey.cameramode
%11 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %55
12: ; preds = %3
store i32 1, i32* @specialkey.cameramode
%13 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
br label %55
14: ; preds = %3
%15 = load i32, i32* @specialkey.cameramode
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = call i32 @move_camera(double 0.000000e+00, double 1.000000e-01, double 0.000000e+00)
br label %21
19: ; preds = %14
%20 = call i32 @move_camera_focus(double 0.000000e+00, double 1.000000e-01)
br label %21
21: ; preds = %19, %17
br label %55
22: ; preds = %3
%23 = load i32, i32* @specialkey.cameramode
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = call i32 @move_camera(double 0.000000e+00, double -1.000000e-01, double 0.000000e+00)
br label %29
27: ; preds = %22
%28 = call i32 @move_camera_focus(double 0.000000e+00, double -1.000000e-01)
br label %29
29: ; preds = %27, %25
br label %55
30: ; preds = %3
%31 = load i32, i32* @specialkey.cameramode
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = call i32 @move_camera(double 0.000000e+00, double 0.000000e+00, double 1.000000e-01)
br label %41
35: ; preds = %30
%36 = load i32, i32* @specialkey.cameramode
%37 = icmp eq i32 %36, 1
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = call i32 @move_camera_focus(double 1.000000e-01, double 0.000000e+00)
br label %40
40: ; preds = %38, %35
br label %41
41: ; preds = %40, %33
br label %55
42: ; preds = %3
%43 = load i32, i32* @specialkey.cameramode
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %42
%46 = call i32 @move_camera(double 0.000000e+00, double 0.000000e+00, double -1.000000e-01)
br label %53
47: ; preds = %42
%48 = load i32, i32* @specialkey.cameramode
%49 = icmp eq i32 %48, 1
br i1 %49, label %50, label %52
50: ; preds = %47
%51 = call i32 @move_camera_focus(double -1.000000e-01, double 0.000000e+00)
br label %52
52: ; preds = %50, %47
br label %53
53: ; preds = %52, %45
br label %55
54: ; preds = %3
br label %55
55: ; preds = %54, %53, %41, %29, %21, %12, %10
ret void
}

LLVM IR (-O2):
@specialkey.cameramode = internal unnamed_addr global i1 false
@str = [31 x i8] c"Moving camera focus point mode\00"
@str.2 = [28 x i8] c"Moving camera position mode\00"
define void @specialkey(i32 %0, i32 %1, i32 %2) {
%4 = tail call i32 (...) @glutGetModifiers()
switch i32 %0, label %33 [
i32 132, label %5
i32 131, label %7
i32 130, label %9
i32 129, label %15
i32 128, label %21
i32 133, label %27
]
5: ; preds = %3
store i1 false, i1* @specialkey.cameramode
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.2, i64 0, i64 0))
br label %33
7: ; preds = %3
store i1 true, i1* @specialkey.cameramode
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
br label %33
9: ; preds = %3
%10 = load i1, i1* @specialkey.cameramode
br i1 %10, label %13, label %11
11: ; preds = %9
%12 = tail call i32 @move_camera(double 0.000000e+00, double 1.000000e-01, double 0.000000e+00)
br label %33
13: ; preds = %9
%14 = tail call i32 @move_camera_focus(double 0.000000e+00, double 1.000000e-01)
br label %33
15: ; preds = %3
%16 = load i1, i1* @specialkey.cameramode
br i1 %16, label %19, label %17
17: ; preds = %15
%18 = tail call i32 @move_camera(double 0.000000e+00, double -1.000000e-01, double 0.000000e+00)
br label %33
19: ; preds = %15
%20 = tail call i32 @move_camera_focus(double 0.000000e+00, double -1.000000e-01)
br label %33
21: ; preds = %3
%22 = load i1, i1* @specialkey.cameramode
br i1 %22, label %25, label %23
23: ; preds = %21
%24 = tail call i32 @move_camera(double 0.000000e+00, double 0.000000e+00, double 1.000000e-01)
br label %33
25: ; preds = %21
%26 = tail call i32 @move_camera_focus(double 1.000000e-01, double 0.000000e+00)
br label %33
27: ; preds = %3
%28 = load i1, i1* @specialkey.cameramode
br i1 %28, label %31, label %29
29: ; preds = %27
%30 = tail call i32 @move_camera(double 0.000000e+00, double 0.000000e+00, double -1.000000e-01)
br label %33
31: ; preds = %27
%32 = tail call i32 @move_camera_focus(double -1.000000e-01, double 0.000000e+00)
br label %33
33: ; preds = %3, %29, %31, %23, %25, %17, %19, %11, %13, %7, %5
ret void
}