#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 /*<<< orphan*/ cat_button(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *locator_button(unsigned b) {
  static char result[80];
  if (b) {
    result[0] = 0;
    if (b & 1)
      cat_button(result, "right");
    if (b & 2)
      cat_button(result, "middle");
    if (b & 4)
      cat_button(result, "left");
    if (b & 8)
      cat_button(result, "M4");
  } else {
    strcpy(result, "no buttons down");
  }
  return result;
}


x86 assembly (clang, -O0):
<locator_button>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     11c9 <locator_button+0xa9>
movb   $0x0,0x2f04(%rip)
mov    -0x4(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     115e <locator_button+0x3e>
lea    0x2eee(%rip),%rdi
lea    0xea7(%rip),%rsi
call   1040 <cat_button@plt>
mov    -0x4(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     1180 <locator_button+0x60>
lea    0x2ecc(%rip),%rdi
lea    0xe8b(%rip),%rsi
call   1040 <cat_button@plt>
mov    -0x4(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     11a2 <locator_button+0x82>
lea    0x2eaa(%rip),%rdi
lea    0xe70(%rip),%rsi
call   1040 <cat_button@plt>
mov    -0x4(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     11c4 <locator_button+0xa4>
lea    0x2e88(%rip),%rdi
lea    0xe53(%rip),%rsi
call   1040 <cat_button@plt>
jmp    11dc <locator_button+0xbc>
lea    0x2e70(%rip),%rdi
lea    0xe3e(%rip),%rsi
call   1030 <strcpy@plt>
lea    0x2e5d(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<locator_button>:
push   %rbx
test   %edi,%edi
je     1144 <locator_button+0x24>
mov    %edi,%ebx
movb   $0x0,0x2f12(%rip)
test   $0x1,%bl
jne    1159 <locator_button+0x39>
test   $0x2,%bl
jne    1171 <locator_button+0x51>
test   $0x4,%bl
jne    1189 <locator_button+0x69>
test   $0x8,%bl
jne    11a1 <locator_button+0x81>
jmp    11b4 <locator_button+0x94>
lea    0x2ef5(%rip),%rdi
lea    0xec3(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11b4 <locator_button+0x94>
lea    0x2ee0(%rip),%rdi
lea    0xe99(%rip),%rsi
call   1040 <cat_button@plt>
test   $0x2,%bl
je     1138 <locator_button+0x18>
lea    0x2ec8(%rip),%rdi
lea    0xe87(%rip),%rsi
call   1040 <cat_button@plt>
test   $0x4,%bl
je     113d <locator_button+0x1d>
lea    0x2eb0(%rip),%rdi
lea    0xe76(%rip),%rsi
call   1040 <cat_button@plt>
test   $0x8,%bl
je     11b4 <locator_button+0x94>
lea    0x2e98(%rip),%rdi
lea    0xe63(%rip),%rsi
call   1040 <cat_button@plt>
lea    0x2e85(%rip),%rax
pop    %rbx
ret

LLVM IR (-O0):
@locator_button.result = internal global [80 x i8] zeroinitializer
@.str = [6 x i8] c"right\00"
@.str.1 = [7 x i8] c"middle\00"
@.str.2 = [5 x i8] c"left\00"
@.str.3 = [3 x i8] c"M4\00"
@.str.4 = [16 x i8] c"no buttons down\00"
define i8* @locator_button(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp ne i32 %3, 0
br i1 %4, label %5, label %30
5: ; preds = %1
store i8 0, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @locator_button.result, i64 0, i64 0)
%6 = load i32, i32* %2
%7 = and i32 %6, 1
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = call i32 @cat_button(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @locator_button.result, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %5
%12 = load i32, i32* %2
%13 = and i32 %12, 2
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = call i32 @cat_button(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @locator_button.result, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %15, %11
%18 = load i32, i32* %2
%19 = and i32 %18, 4
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = call i32 @cat_button(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @locator_button.result, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %23
23: ; preds = %21, %17
%24 = load i32, i32* %2
%25 = and i32 %24, 8
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %23
%28 = call i32 @cat_button(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @locator_button.result, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %29
29: ; preds = %27, %23
br label %32
30: ; preds = %1
%31 = call i32 @strcpy(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @locator_button.result, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
br label %32
32: ; preds = %30, %29
ret i8* getelementptr inbounds ([80 x i8], [80 x i8]* @locator_button.result, i64 0, i64 0)
}

LLVM IR (-O2):
@locator_button.result = internal global [80 x i8] zeroinitializer
@.str = [6 x i8] c"right\00"
@.str.1 = [7 x i8] c"middle\00"
@.str.2 = [5 x i8] c"left\00"
@.str.3 = [3 x i8] c"M4\00"
@.str.4 = [16 x i8] c"no buttons down\00"
define i8* @locator_button(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %23, label %3
3: ; preds = %1
store i8 0, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @locator_button.result, i64 0, i64 0)
%4 = and i32 %0, 1
%5 = icmp eq i32 %4, 0
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = tail call i32 @cat_button(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @locator_button.result, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %6, %3
%9 = and i32 %0, 2
%10 = icmp eq i32 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = tail call i32 @cat_button(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @locator_button.result, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %11, %8
%14 = and i32 %0, 4
%15 = icmp eq i32 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %13
%17 = tail call i32 @cat_button(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @locator_button.result, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %18
18: ; preds = %16, %13
%19 = and i32 %0, 8
%20 = icmp eq i32 %19, 0
br i1 %20, label %25, label %21
21: ; preds = %18
%22 = tail call i32 @cat_button(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @locator_button.result, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %25
23: ; preds = %1
%24 = tail call i32 @strcpy(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @locator_button.result, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
br label %25
25: ; preds = %18, %21, %23
ret i8* getelementptr inbounds ([80 x i8], [80 x i8]* @locator_button.result, i64 0, i64 0)
}