#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 */
char in_byte(int);
char keyboard_get_scanduck_from_keyboard() {
  static char c, ex;
  c = in_byte(0x60);
  do {
    ex = in_byte(0x60);
    if (ex != c) {
      c = ex;
      if (c > 0)
        return c;
    }
  } while (1);
}


x86 assembly (clang, -O0):
<keyboard_get_scanduck_from_keyboard>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x60,%edi
call   1030 <in_byte@plt>
mov    %al,0x2f01(%rip)
mov    $0x60,%edi
call   1030 <in_byte@plt>
mov    %al,0x2ef2(%rip)
movsbl 0x2eeb(%rip),%eax
movsbl 0x2ee3(%rip),%ecx
cmp    %ecx,%eax
je     117d <keyboard_get_scanduck_from_keyboard+0x6d>
mov    0x2ed6(%rip),%al
mov    %al,0x2ecf(%rip)
movsbl 0x2ec8(%rip),%eax
cmp    $0x0,%eax
jle    1178 <keyboard_get_scanduck_from_keyboard+0x68>
mov    0x2eb9(%rip),%al
mov    %al,-0x1(%rbp)
jmp    1191 <keyboard_get_scanduck_from_keyboard+0x81>
jmp    117d <keyboard_get_scanduck_from_keyboard+0x6d>
jmp    1182 <keyboard_get_scanduck_from_keyboard+0x72>
mov    $0x1,%al
test   $0x1,%al
jne    1128 <keyboard_get_scanduck_from_keyboard+0x18>
jmp    1191 <keyboard_get_scanduck_from_keyboard+0x81>
movsbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<keyboard_get_scanduck_from_keyboard>:
push   %rax
mov    $0x60,%edi
call   1030 <in_byte@plt>
mov    %al,0x2f08(%rip)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x60,%edi
call   1030 <in_byte@plt>
cmp    0x2ee9(%rip),%al
je     1130 <keyboard_get_scanduck_from_keyboard+0x20>
mov    %al,0x2ee1(%rip)
test   %al,%al
jle    1130 <keyboard_get_scanduck_from_keyboard+0x20>
pop    %rcx
ret

LLVM IR (-O0):
@keyboard_get_scanduck_from_keyboard.c = internal global i8 0
@keyboard_get_scanduck_from_keyboard.ex = internal global i8 0
define signext i8 @keyboard_get_scanduck_from_keyboard() {
%1 = alloca i8
%2 = call signext i8 @in_byte(i32 96)
store i8 %2, i8* @keyboard_get_scanduck_from_keyboard.c
br label %3
3: ; preds = %19, %0
%4 = call signext i8 @in_byte(i32 96)
store i8 %4, i8* @keyboard_get_scanduck_from_keyboard.ex
%5 = load i8, i8* @keyboard_get_scanduck_from_keyboard.ex
%6 = sext i8 %5 to i32
%7 = load i8, i8* @keyboard_get_scanduck_from_keyboard.c
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %6, %8
br i1 %9, label %10, label %18
10: ; preds = %3
%11 = load i8, i8* @keyboard_get_scanduck_from_keyboard.ex
store i8 %11, i8* @keyboard_get_scanduck_from_keyboard.c
%12 = load i8, i8* @keyboard_get_scanduck_from_keyboard.c
%13 = sext i8 %12 to i32
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %10
%16 = load i8, i8* @keyboard_get_scanduck_from_keyboard.c
store i8 %16, i8* %1
br label %20
17: ; preds = %10
br label %18
18: ; preds = %17, %3
br label %19
19: ; preds = %18
br i1 true, label %3, label %20
20: ; preds = %15, %19
%21 = load i8, i8* %1
ret i8 %21
}

LLVM IR (-O2):
@keyboard_get_scanduck_from_keyboard.c = internal unnamed_addr global i8 0
define signext i8 @keyboard_get_scanduck_from_keyboard() {
%1 = tail call signext i8 @in_byte(i32 96)
store i8 %1, i8* @keyboard_get_scanduck_from_keyboard.c
br label %2
2: ; preds = %6, %0
%3 = tail call signext i8 @in_byte(i32 96)
%4 = load i8, i8* @keyboard_get_scanduck_from_keyboard.c
%5 = icmp eq i8 %3, %4
br i1 %5, label %6, label %7
6: ; preds = %2, %7
br label %2
7: ; preds = %2
store i8 %3, i8* @keyboard_get_scanduck_from_keyboard.c
%8 = icmp sgt i8 %3, 0
br i1 %8, label %9, label %6
9: ; preds = %7
ret i8 %3
}