#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 */
scalar_t__ a_button();
scalar_t__ b_button();
int /*<<< orphan*/ msleep(int);
int /*<<< orphan*/ printf(char *, int);
int getabbutton() {
  ;
  while (!(!(a_button() || b_button()))) {
    msleep(1);
  };
  ;
  while (!(a_button() || b_button())) {
    msleep(1);
  };
  int x;
  if (a_button())
    x = 0;
  if (b_button())
    x = 1;
  printf("\n%d", x);
  ;
  while (!(!(a_button() || b_button()))) {
    msleep(1);
  };
  return x;
}


x86 assembly (clang, -O0):
<getabbutton>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <a_button@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x5(%rbp)
jne    1172 <getabbutton+0x32>
mov    $0x0,%al
call   1060 <b_button@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x5(%rbp)
mov    -0x5(%rbp),%al
xor    $0xff,%al
xor    $0xff,%al
test   $0x1,%al
jne    1186 <getabbutton+0x46>
jmp    1195 <getabbutton+0x55>
mov    $0x1,%edi
call   1040 <msleep@plt>
jmp    1148 <getabbutton+0x8>
jmp    119a <getabbutton+0x5a>
mov    $0x0,%al
call   1030 <a_button@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x6(%rbp)
jne    11c4 <getabbutton+0x84>
mov    $0x0,%al
call   1060 <b_button@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x6(%rbp)
mov    -0x6(%rbp),%al
xor    $0xff,%al
test   $0x1,%al
jne    11d6 <getabbutton+0x96>
jmp    11e5 <getabbutton+0xa5>
mov    $0x1,%edi
call   1040 <msleep@plt>
jmp    119a <getabbutton+0x5a>
mov    $0x0,%al
call   1030 <a_button@plt>
cmp    $0x0,%rax
je     11fd <getabbutton+0xbd>
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1060 <b_button@plt>
cmp    $0x0,%rax
je     1215 <getabbutton+0xd5>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xde1(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1030 <a_button@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x7(%rbp)
jne    124e <getabbutton+0x10e>
mov    $0x0,%al
call   1060 <b_button@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x7(%rbp)
mov    -0x7(%rbp),%al
xor    $0xff,%al
xor    $0xff,%al
test   $0x1,%al
jne    1262 <getabbutton+0x122>
jmp    1271 <getabbutton+0x131>
mov    $0x1,%edi
call   1040 <msleep@plt>
jmp    1224 <getabbutton+0xe4>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getabbutton>:
push   %rbx
jmp    115a <getabbutton+0x1a>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x1,%edi
call   1040 <msleep@plt>
xor    %eax,%eax
call   1030 <a_button@plt>
test   %rax,%rax
jne    1150 <getabbutton+0x10>
xor    %eax,%eax
call   1060 <b_button@plt>
test   %rax,%rax
jne    1150 <getabbutton+0x10>
jmp    1196 <getabbutton+0x56>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1060 <b_button@plt>
test   %rax,%rax
jne    11a2 <getabbutton+0x62>
mov    $0x1,%edi
call   1040 <msleep@plt>
xor    %eax,%eax
call   1030 <a_button@plt>
test   %rax,%rax
je     1180 <getabbutton+0x40>
xor    %eax,%eax
call   1030 <a_button@plt>
xor    %eax,%eax
call   1060 <b_button@plt>
xor    %ebx,%ebx
test   %rax,%rax
setne  %bl
lea    0xe41(%rip),%rdi
mov    %ebx,%esi
call   1050 <printf@plt>
jmp    11da <getabbutton+0x9a>
nopl   0x0(%rax,%rax,1)
mov    $0x1,%edi
call   1040 <msleep@plt>
xor    %eax,%eax
call   1030 <a_button@plt>
test   %rax,%rax
jne    11d0 <getabbutton+0x90>
xor    %eax,%eax
call   1060 <b_button@plt>
test   %rax,%rax
jne    11d0 <getabbutton+0x90>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"\0A%d\00"
define i32 @getabbutton() {
%1 = alloca i32
br label %2
2: ; preds = %12, %0
%3 = call i64 (...) @a_button()
%4 = icmp ne i64 %3, 0
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = call i64 (...) @b_button()
%7 = icmp ne i64 %6, 0
br label %8
8: ; preds = %5, %2
%9 = phi i1 [ true, %2 ], [ %7, %5 ]
%10 = xor i1 %9, true
%11 = xor i1 %10, true
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = call i32 @msleep(i32 1)
br label %2
14: ; preds = %8
br label %15
15: ; preds = %24, %14
%16 = call i64 (...) @a_button()
%17 = icmp ne i64 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = call i64 (...) @b_button()
%20 = icmp ne i64 %19, 0
br label %21
21: ; preds = %18, %15
%22 = phi i1 [ true, %15 ], [ %20, %18 ]
%23 = xor i1 %22, true
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 @msleep(i32 1)
br label %15
26: ; preds = %21
%27 = call i64 (...) @a_button()
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %26
store i32 0, i32* %1
br label %30
30: ; preds = %29, %26
%31 = call i64 (...) @b_button()
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %30
store i32 1, i32* %1
br label %34
34: ; preds = %33, %30
%35 = load i32, i32* %1
%36 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %47, %34
%38 = call i64 (...) @a_button()
%39 = icmp ne i64 %38, 0
br i1 %39, label %43, label %40
40: ; preds = %37
%41 = call i64 (...) @b_button()
%42 = icmp ne i64 %41, 0
br label %43
43: ; preds = %40, %37
%44 = phi i1 [ true, %37 ], [ %42, %40 ]
%45 = xor i1 %44, true
%46 = xor i1 %45, true
br i1 %46, label %47, label %49
47: ; preds = %43
%48 = call i32 @msleep(i32 1)
br label %37
49: ; preds = %43
%50 = load i32, i32* %1
ret i32 %50
}

LLVM IR (-O2):
@.str = [4 x i8] c"\0A%d\00"
define i32 @getabbutton() {
br label %1
1: ; preds = %10, %0
%2 = tail call i64 (...) @a_button()
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %10
4: ; preds = %1
%5 = tail call i64 (...) @b_button()
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %4
%8 = tail call i64 (...) @a_button()
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %19
10: ; preds = %1, %4
%11 = tail call i32 @msleep(i32 1)
br label %1
12: ; preds = %7, %15
%13 = tail call i64 (...) @b_button()
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = tail call i32 @msleep(i32 1)
%17 = tail call i64 (...) @a_button()
%18 = icmp eq i64 %17, 0
br i1 %18, label %12, label %19
19: ; preds = %12, %15, %7
%20 = tail call i64 (...) @a_button()
%21 = tail call i64 (...) @b_button()
%22 = icmp ne i64 %21, 0
%23 = zext i1 %22 to i32
%24 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %31, %19
%26 = tail call i64 (...) @a_button()
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = tail call i64 (...) @b_button()
%30 = icmp eq i64 %29, 0
br i1 %30, label %33, label %31
31: ; preds = %25, %28
%32 = tail call i32 @msleep(i32 1)
br label %25
33: ; preds = %28
ret i32 %23
}