#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 */
unsigned char _buttons_pressed();
unsigned char buttons_pressed(void) {
  unsigned char b = _buttons_pressed();
  switch (b) {
  case 'u':
  case 'd':
  case '1':
  case '6':
  case '8':
  case '9':
  case '*':
  case '0': {
    if (b == _buttons_pressed())
      return b;
    return 0;
  }
  default:
    return b;
  }
}


x86 assembly (clang, -O0):
<buttons_pressed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xor    %eax,%eax
call   1030 <_buttons_pressed@plt>
mov    %al,-0x2(%rbp)
movzbl -0x2(%rbp),%eax
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x4b,%eax
ja     117e <buttons_pressed+0x6e>
mov    -0x10(%rbp),%rax
lea    0xebd(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movzbl -0x2(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1030 <_buttons_pressed@plt>
mov    %al,%cl
mov    -0x14(%rbp),%eax
movzbl %cl,%ecx
cmp    %ecx,%eax
jne    1175 <buttons_pressed+0x65>
mov    -0x2(%rbp),%al
mov    %al,-0x1(%rbp)
jmp    1184 <buttons_pressed+0x74>
movb   $0x0,-0x1(%rbp)
jmp    1184 <buttons_pressed+0x74>
mov    -0x2(%rbp),%al
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<buttons_pressed>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <_buttons_pressed@plt>
mov    %eax,%ebx
lea    -0x2a(%rbx),%eax
cmp    $0x4b,%al
ja     1147 <buttons_pressed+0x37>
movzbl %al,%eax
lea    0xed3(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <_buttons_pressed@plt>
cmp    %al,%bl
movzbl %bl,%ebx
cmovne %ebp,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define zeroext i8 @buttons_pressed() {
%1 = alloca i8
%2 = alloca i8
%3 = call zeroext i8 (...) @_buttons_pressed()
store i8 %3, i8* %2
%4 = load i8, i8* %2
%5 = zext i8 %4 to i32
switch i32 %5, label %15 [
i32 117, label %6
i32 100, label %6
i32 49, label %6
i32 54, label %6
i32 56, label %6
i32 57, label %6
i32 42, label %6
i32 48, label %6
]
6: ; preds = %0, %0, %0, %0, %0, %0, %0, %0
%7 = load i8, i8* %2
%8 = zext i8 %7 to i32
%9 = call zeroext i8 (...) @_buttons_pressed()
%10 = zext i8 %9 to i32
%11 = icmp eq i32 %8, %10
br i1 %11, label %12, label %14
12: ; preds = %6
%13 = load i8, i8* %2
store i8 %13, i8* %1
br label %17
14: ; preds = %6
store i8 0, i8* %1
br label %17
15: ; preds = %0
%16 = load i8, i8* %2
store i8 %16, i8* %1
br label %17
17: ; preds = %15, %14, %12
%18 = load i8, i8* %1
ret i8 %18
}

LLVM IR (-O2):
define zeroext i8 @buttons_pressed() {
%1 = tail call zeroext i8 (...) @_buttons_pressed()
switch i8 %1, label %6 [
i8 117, label %2
i8 100, label %2
i8 49, label %2
i8 54, label %2
i8 56, label %2
i8 57, label %2
i8 42, label %2
i8 48, label %2
]
2: ; preds = %0, %0, %0, %0, %0, %0, %0, %0
%3 = tail call zeroext i8 (...) @_buttons_pressed()
%4 = icmp eq i8 %1, %3
%5 = select i1 %4, i8 %1, i8 0
br label %6
6: ; preds = %0, %2
%7 = phi i8 [ %5, %2 ], [ %1, %0 ]
ret i8 %7
}