#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 */
int GLUT_DOWN;
#define GLUT_LEFT_BUTTON 130
#define GLUT_MIDDLE_BUTTON 129
#define GLUT_RIGHT_BUTTON 128
int /*<<< orphan*/ printf(char *);
void mouse(int button, int state, int x, int y) {
  switch (button) {
  case GLUT_LEFT_BUTTON:
    if (state == GLUT_DOWN) {
      printf("Mouse Down, left.\n");
    }
    break;
  case GLUT_MIDDLE_BUTTON:
    if (state == GLUT_DOWN) {
      printf("Mouse Down, middle.\n");
    }
    break;
  case GLUT_RIGHT_BUTTON:
    if (state == GLUT_DOWN) {
      printf("Mouse Down, right.\n");
    }
    break;
  default:
    break;
  }
}


x86 assembly (clang, -O0):
<mouse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0x80,%eax
je     11a6 <mouse+0x96>
jmp    113a <mouse+0x2a>
mov    -0x14(%rbp),%eax
sub    $0x81,%eax
je     1183 <mouse+0x73>
jmp    114d <mouse+0x3d>
mov    -0x14(%rbp),%eax
sub    $0x82,%eax
jne    11c9 <mouse+0xb9>
jmp    1160 <mouse+0x50>
mov    -0x8(%rbp),%eax
mov    0x2e7e(%rip),%rcx
cmp    (%rcx),%eax
jne    117e <mouse+0x6e>
lea    0xe87(%rip),%rdi
call   1030 <printf@plt>
jmp    11ce <mouse+0xbe>
mov    -0x8(%rbp),%eax
mov    0x2e5b(%rip),%rcx
cmp    (%rcx),%eax
jne    11a1 <mouse+0x91>
lea    0xe77(%rip),%rdi
call   1030 <printf@plt>
jmp    11ce <mouse+0xbe>
mov    -0x8(%rbp),%eax
mov    0x2e38(%rip),%rcx
cmp    (%rcx),%eax
jne    11c4 <mouse+0xb4>
lea    0xe69(%rip),%rdi
call   1030 <printf@plt>
jmp    11ce <mouse+0xbe>
jmp    11ce <mouse+0xbe>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mouse>:
cmp    $0x80,%edi
je     113f <mouse+0x2f>
cmp    $0x81,%edi
je     1156 <mouse+0x46>
cmp    $0x82,%edi
jne    116d <mouse+0x5d>
mov    0x2eb9(%rip),%rax
cmp    %esi,(%rax)
jne    116d <mouse+0x5d>
lea    0xeed(%rip),%rdi
jmp    1030 <puts@plt>
mov    0x2ea2(%rip),%rax
cmp    %esi,(%rax)
jne    116d <mouse+0x5d>
lea    0xeaf(%rip),%rdi
jmp    1030 <puts@plt>
mov    0x2e8b(%rip),%rax
cmp    %esi,(%rax)
jne    116d <mouse+0x5d>
lea    0xeab(%rip),%rdi
jmp    1030 <puts@plt>
ret

LLVM IR (-O0):
@GLUT_DOWN = global i32 0
@.str = [19 x i8] c"Mouse Down, left.\0A\00"
@.str.1 = [21 x i8] c"Mouse Down, middle.\0A\00"
@.str.2 = [20 x i8] c"Mouse Down, right.\0A\00"
define void @mouse(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i32, i32* %5
switch i32 %9, label %31 [
i32 130, label %10
i32 129, label %17
i32 128, label %24
]
10: ; preds = %4
%11 = load i32, i32* %6
%12 = load i32, i32* @GLUT_DOWN
%13 = icmp eq i32 %11, %12
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %14, %10
br label %32
17: ; preds = %4
%18 = load i32, i32* %6
%19 = load i32, i32* @GLUT_DOWN
%20 = icmp eq i32 %18, %19
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %23
23: ; preds = %21, %17
br label %32
24: ; preds = %4
%25 = load i32, i32* %6
%26 = load i32, i32* @GLUT_DOWN
%27 = icmp eq i32 %25, %26
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %30
30: ; preds = %28, %24
br label %32
31: ; preds = %4
br label %32
32: ; preds = %31, %30, %23, %16
ret void
}

LLVM IR (-O2):
@GLUT_DOWN = global i32 0
@str = [19 x i8] c"Mouse Down, right.\00"
@str.3 = [20 x i8] c"Mouse Down, middle.\00"
@str.4 = [18 x i8] c"Mouse Down, left.\00"
define void @mouse(i32 %0, i32 %1, i32 %2, i32 %3) {
switch i32 %0, label %17 [
i32 130, label %5
i32 129, label %8
i32 128, label %11
]
5: ; preds = %4
%6 = load i32, i32* @GLUT_DOWN
%7 = icmp eq i32 %6, %1
br i1 %7, label %14, label %17
8: ; preds = %4
%9 = load i32, i32* @GLUT_DOWN
%10 = icmp eq i32 %9, %1
br i1 %10, label %14, label %17
11: ; preds = %4
%12 = load i32, i32* @GLUT_DOWN
%13 = icmp eq i32 %12, %1
br i1 %13, label %14, label %17
14: ; preds = %11, %8, %5
%15 = phi i8* [ getelementptr inbounds ([18 x i8], [18 x i8]* @str.4, i64 0, i64 0), %5 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @str.3, i64 0, i64 0), %8 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0), %11 ]
%16 = tail call i32 @puts(i8* dereferenceable(1) %15)
br label %17
17: ; preds = %14, %4, %11, %8, %5
ret void
}