#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*/ TextScreen_End();
int TextScreen_GetKey();
int /*<<< orphan*/ TextScreen_Init(int /*<<< orphan*/ *);
int /*<<< orphan*/ TextScreen_Wait(int);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  int key = 0;
  TextScreen_Init(NULL);
  printf("Show TextScreen's keycode. Press key. [q]quit\n");
  while (key != 'q') {
    key = TextScreen_GetKey();
    if (key) {
      printf("key = %x, %x         \n", key, key & 0x000FFFFF);
      if (key == 'q')
        break;
    }
    TextScreen_Wait(50);
  }
  TextScreen_End();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <TextScreen_Init@plt>
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x71,-0x8(%rbp)
je     11d8 <main+0x88>
mov    $0x0,%al
call   1070 <TextScreen_GetKey@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11c9 <main+0x79>
mov    -0x8(%rbp),%esi
mov    -0x8(%rbp),%edx
and    $0xfffff,%edx
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x71,-0x8(%rbp)
jne    11c4 <main+0x74>
jmp    11d8 <main+0x88>
jmp    11c9 <main+0x79>
mov    $0x32,%edi
call   1050 <TextScreen_Wait@plt>
jmp    117d <main+0x2d>
mov    $0x0,%al
call   1040 <TextScreen_End@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %edi,%edi
call   1070 <TextScreen_Init@plt>
lea    0xea6(%rip),%rdi
call   1030 <puts@plt>
lea    0xe83(%rip),%rbx
jmp    118f <main+0x2f>
nop
mov    $0x32,%edi
call   1060 <TextScreen_Wait@plt>
cmp    $0x71,%ebp
je     11b5 <main+0x55>
xor    %eax,%eax
call   1080 <TextScreen_GetKey@plt>
mov    %eax,%ebp
test   %eax,%eax
je     1180 <main+0x20>
mov    %ebp,%edx
and    $0xfffff,%edx
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x71,%ebp
jne    1180 <main+0x20>
xor    %eax,%eax
call   1050 <TextScreen_End@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [47 x i8] c"Show TextScreen's keycode. Press key. [q]quit\0A\00"
@.str.1 = [23 x i8] c"key = %x, %x \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%3 = call i32 @TextScreen_Init(i32* null)
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %21, %0
%6 = load i32, i32* %2
%7 = icmp ne i32 %6, 113
br i1 %7, label %8, label %23
8: ; preds = %5
%9 = call i32 (...) @TextScreen_GetKey()
store i32 %9, i32* %2
%10 = load i32, i32* %2
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %21
12: ; preds = %8
%13 = load i32, i32* %2
%14 = load i32, i32* %2
%15 = and i32 %14, 1048575
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %13, i32 %15)
%17 = load i32, i32* %2
%18 = icmp eq i32 %17, 113
br i1 %18, label %19, label %20
19: ; preds = %12
br label %23
20: ; preds = %12
br label %21
21: ; preds = %20, %8
%22 = call i32 @TextScreen_Wait(i32 50)
br label %5
23: ; preds = %19, %5
%24 = call i32 (...) @TextScreen_End()
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [23 x i8] c"key = %x, %x \0A\00"
@str = [46 x i8] c"Show TextScreen's keycode. Press key. [q]quit\00"
define i32 @main() {
%1 = tail call i32 @TextScreen_Init(i32* null)
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str, i64 0, i64 0))
br label %3
3: ; preds = %0, %10
%4 = tail call i32 (...) @TextScreen_GetKey()
%5 = icmp eq i32 %4, 0
br i1 %5, label %10, label %6
6: ; preds = %3
%7 = and i32 %4, 1048575
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %4, i32 %7)
%9 = icmp eq i32 %4, 113
br i1 %9, label %13, label %10
10: ; preds = %6, %3
%11 = tail call i32 @TextScreen_Wait(i32 50)
%12 = icmp eq i32 %4, 113
br i1 %12, label %13, label %3
13: ; preds = %6, %10
%14 = tail call i32 (...) @TextScreen_End()
ret i32 0
}