#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 */
typedef int GLint;

/* Variables and functions */
int /*<<< orphan*/ DeleteTri(int);
int DoSelect(int, int);
int GLUT_DOWN;
int GLUT_LEFT_BUTTON;
int GLUT_MIDDLE_BUTTON;
int GLUT_RIGHT_BUTTON;
int /*<<< orphan*/ GrowTri(int);
int /*<<< orphan*/ RecolorTri(int);
int /*<<< orphan*/ glutPostRedisplay();
void Mouse(int button, int state, int mouseX, int mouseY) {
  GLint hit;
  if (state == GLUT_DOWN) {
    hit = DoSelect((GLint)mouseX, (GLint)mouseY);
    if (hit != -1) {
      if (button == GLUT_LEFT_BUTTON) {
        RecolorTri(hit);
      } else if (button == GLUT_MIDDLE_BUTTON) {
        GrowTri(hit);
      } else if (button == GLUT_RIGHT_BUTTON) {
        DeleteTri(hit);
      }
      glutPostRedisplay();
    }
  }
}


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    -0x8(%rbp),%eax
mov    0x2e72(%rip),%rcx
cmp    (%rcx),%eax
jne    11fc <Mouse+0xac>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1060 <DoSelect@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
je     11f7 <Mouse+0xa7>
mov    -0x4(%rbp),%eax
mov    0x2e30(%rip),%rcx
cmp    (%rcx),%eax
jne    11ad <Mouse+0x5d>
mov    -0x14(%rbp),%edi
call   1050 <RecolorTri@plt>
jmp    11f0 <Mouse+0xa0>
mov    -0x4(%rbp),%eax
mov    0x2e19(%rip),%rcx
cmp    (%rcx),%eax
jne    11cc <Mouse+0x7c>
mov    -0x14(%rbp),%edi
call   1040 <GrowTri@plt>
jmp    11eb <Mouse+0x9b>
mov    -0x4(%rbp),%eax
mov    0x2e12(%rip),%rcx
cmp    (%rcx),%eax
jne    11e6 <Mouse+0x96>
mov    -0x14(%rbp),%edi
call   1070 <DeleteTri@plt>
jmp    11eb <Mouse+0x9b>
jmp    11f0 <Mouse+0xa0>
mov    $0x0,%al
call   1030 <glutPostRedisplay@plt>
jmp    11fc <Mouse+0xac>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Mouse>:
push   %rbx
mov    0x2e88(%rip),%rax
cmp    %esi,(%rax)
jne    1180 <Mouse+0x30>
mov    %edi,%ebx
mov    %edx,%edi
mov    %ecx,%esi
call   1060 <DoSelect@plt>
cmp    $0xffffffff,%eax
je     1180 <Mouse+0x30>
mov    0x2e55(%rip),%rcx
cmp    %ebx,(%rcx)
jne    1182 <Mouse+0x32>
mov    %eax,%edi
call   1050 <RecolorTri@plt>
jmp    11a8 <Mouse+0x58>
pop    %rbx
ret
mov    0x2e47(%rip),%rcx
cmp    %ebx,(%rcx)
jne    1196 <Mouse+0x46>
mov    %eax,%edi
call   1040 <GrowTri@plt>
jmp    11a8 <Mouse+0x58>
mov    0x2e4b(%rip),%rcx
cmp    %ebx,(%rcx)
jne    11a8 <Mouse+0x58>
mov    %eax,%edi
call   1070 <DeleteTri@plt>
xor    %eax,%eax
pop    %rbx
jmp    1030 <glutPostRedisplay@plt>

LLVM IR (-O0):
@GLUT_DOWN = global i32 0
@GLUT_LEFT_BUTTON = global i32 0
@GLUT_MIDDLE_BUTTON = global i32 0
@GLUT_RIGHT_BUTTON = global i32 0
define void @Mouse(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32, i32* %6
%11 = load i32, i32* @GLUT_DOWN
%12 = icmp eq i32 %10, %11
br i1 %12, label %13, label %45
13: ; preds = %4
%14 = load i32, i32* %7
%15 = load i32, i32* %8
%16 = call i32 @DoSelect(i32 %14, i32 %15)
store i32 %16, i32* %9
%17 = load i32, i32* %9
%18 = icmp ne i32 %17, -1
br i1 %18, label %19, label %44
19: ; preds = %13
%20 = load i32, i32* %5
%21 = load i32, i32* @GLUT_LEFT_BUTTON
%22 = icmp eq i32 %20, %21
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = load i32, i32* %9
%25 = call i32 @RecolorTri(i32 %24)
br label %42
26: ; preds = %19
%27 = load i32, i32* %5
%28 = load i32, i32* @GLUT_MIDDLE_BUTTON
%29 = icmp eq i32 %27, %28
br i1 %29, label %30, label %33
30: ; preds = %26
%31 = load i32, i32* %9
%32 = call i32 @GrowTri(i32 %31)
br label %41
33: ; preds = %26
%34 = load i32, i32* %5
%35 = load i32, i32* @GLUT_RIGHT_BUTTON
%36 = icmp eq i32 %34, %35
br i1 %36, label %37, label %40
37: ; preds = %33
%38 = load i32, i32* %9
%39 = call i32 @DeleteTri(i32 %38)
br label %40
40: ; preds = %37, %33
br label %41
41: ; preds = %40, %30
br label %42
42: ; preds = %41, %23
%43 = call i32 (...) @glutPostRedisplay()
br label %44
44: ; preds = %42, %13
br label %45
45: ; preds = %44, %4
ret void
}

LLVM IR (-O2):
@GLUT_DOWN = global i32 0
@GLUT_LEFT_BUTTON = global i32 0
@GLUT_MIDDLE_BUTTON = global i32 0
@GLUT_RIGHT_BUTTON = global i32 0
define void @Mouse(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = load i32, i32* @GLUT_DOWN
%6 = icmp eq i32 %5, %1
br i1 %6, label %7, label %27
7: ; preds = %4
%8 = tail call i32 @DoSelect(i32 %2, i32 %3)
%9 = icmp eq i32 %8, -1
br i1 %9, label %27, label %10
10: ; preds = %7
%11 = load i32, i32* @GLUT_LEFT_BUTTON
%12 = icmp eq i32 %11, %0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 @RecolorTri(i32 %8)
br label %25
15: ; preds = %10
%16 = load i32, i32* @GLUT_MIDDLE_BUTTON
%17 = icmp eq i32 %16, %0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = tail call i32 @GrowTri(i32 %8)
br label %25
20: ; preds = %15
%21 = load i32, i32* @GLUT_RIGHT_BUTTON
%22 = icmp eq i32 %21, %0
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = tail call i32 @DeleteTri(i32 %8)
br label %25
25: ; preds = %18, %23, %20, %13
%26 = tail call i32 (...) @glutPostRedisplay()
br label %27
27: ; preds = %7, %25, %4
ret void
}