#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 129
#define GLUT_MIDDLE_BUTTON 128
int /*<<< orphan*/ left_down(int, int);
int /*<<< orphan*/ middle_down(int, int);
void mouse_clicked(int button, int state, int x, int y) {
  x += 5;
  y += 5;
  x -= x % (2 * 5);
  y -= y % (2 * 5);
  switch (button) {
  case GLUT_LEFT_BUTTON:
    if (state == GLUT_DOWN)
      left_down(x, y);
    break;
  case GLUT_MIDDLE_BUTTON:
    if (state == GLUT_DOWN)
      middle_down(x, y);
    break;
  }
}


x86 assembly (clang, -O0):
<mouse_clicked>:
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    -0xc(%rbp),%eax
add    $0x5,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x5,%eax
mov    %eax,-0x10(%rbp)
movslq -0xc(%rbp),%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rax
shr    $0x3f,%rax
sar    $0x22,%rcx
add    %eax,%ecx
add    %ecx,%ecx
mov    %ecx,%eax
lea    (%rax,%rax,4),%eax
mov    %eax,-0xc(%rbp)
movslq -0x10(%rbp),%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rax
shr    $0x3f,%rax
sar    $0x22,%rcx
add    %eax,%ecx
add    %ecx,%ecx
mov    %ecx,%eax
lea    (%rax,%rax,4),%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0x80,%eax
je     11d5 <mouse_clicked+0xb5>
jmp    11a0 <mouse_clicked+0x80>
mov    -0x14(%rbp),%eax
sub    $0x81,%eax
jne    11f7 <mouse_clicked+0xd7>
jmp    11b3 <mouse_clicked+0x93>
mov    -0x8(%rbp),%eax
mov    0x2e2b(%rip),%rcx
cmp    (%rcx),%eax
jne    11d0 <mouse_clicked+0xb0>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1040 <left_down@plt>
jmp    11f7 <mouse_clicked+0xd7>
mov    -0x8(%rbp),%eax
mov    0x2e09(%rip),%rcx
cmp    (%rcx),%eax
jne    11f2 <mouse_clicked+0xd2>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1030 <middle_down@plt>
jmp    11f7 <mouse_clicked+0xd7>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mouse_clicked>:
add    $0x5,%edx
add    $0x5,%ecx
movslq %edx,%rax
imul   $0x66666667,%rax,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rax
add    %edx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
movslq %ecx,%rcx
imul   $0x66666667,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
cmp    $0x80,%edi
je     1182 <mouse_clicked+0x62>
cmp    $0x81,%edi
jne    1196 <mouse_clicked+0x76>
mov    0x2e73(%rip),%rdx
cmp    %esi,(%rdx)
jne    1196 <mouse_clicked+0x76>
mov    %eax,%edi
mov    %ecx,%esi
jmp    1040 <left_down@plt>
mov    0x2e5f(%rip),%rdx
cmp    %esi,(%rdx)
jne    1196 <mouse_clicked+0x76>
mov    %eax,%edi
mov    %ecx,%esi
jmp    1030 <middle_down@plt>
ret

LLVM IR (-O0):
@GLUT_DOWN = global i32 0
define void @mouse_clicked(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* %7
%10 = add nsw i32 %9, 5
store i32 %10, i32* %7
%11 = load i32, i32* %8
%12 = add nsw i32 %11, 5
store i32 %12, i32* %8
%13 = load i32, i32* %7
%14 = srem i32 %13, 10
%15 = load i32, i32* %7
%16 = sub nsw i32 %15, %14
store i32 %16, i32* %7
%17 = load i32, i32* %8
%18 = srem i32 %17, 10
%19 = load i32, i32* %8
%20 = sub nsw i32 %19, %18
store i32 %20, i32* %8
%21 = load i32, i32* %5
switch i32 %21, label %40 [
i32 129, label %22
i32 128, label %31
]
22: ; preds = %4
%23 = load i32, i32* %6
%24 = load i32, i32* @GLUT_DOWN
%25 = icmp eq i32 %23, %24
br i1 %25, label %26, label %30
26: ; preds = %22
%27 = load i32, i32* %7
%28 = load i32, i32* %8
%29 = call i32 @left_down(i32 %27, i32 %28)
br label %30
30: ; preds = %26, %22
br label %40
31: ; preds = %4
%32 = load i32, i32* %6
%33 = load i32, i32* @GLUT_DOWN
%34 = icmp eq i32 %32, %33
br i1 %34, label %35, label %39
35: ; preds = %31
%36 = load i32, i32* %7
%37 = load i32, i32* %8
%38 = call i32 @middle_down(i32 %36, i32 %37)
br label %39
39: ; preds = %35, %31
br label %40
40: ; preds = %4, %39, %30
ret void
}

LLVM IR (-O2):
@GLUT_DOWN = global i32 0
define void @mouse_clicked(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = add nsw i32 %2, 5
%6 = add nsw i32 %3, 5
%7 = srem i32 %5, 10
%8 = sub nsw i32 %5, %7
%9 = srem i32 %6, 10
%10 = sub nsw i32 %6, %9
switch i32 %0, label %21 [
i32 129, label %11
i32 128, label %16
]
11: ; preds = %4
%12 = load i32, i32* @GLUT_DOWN
%13 = icmp eq i32 %12, %1
br i1 %13, label %14, label %21
14: ; preds = %11
%15 = tail call i32 @left_down(i32 %8, i32 %10)
br label %21
16: ; preds = %4
%17 = load i32, i32* @GLUT_DOWN
%18 = icmp eq i32 %17, %1
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = tail call i32 @middle_down(i32 %8, i32 %10)
br label %21
21: ; preds = %16, %19, %11, %14, %4
ret void
}