#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 getch();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ system(char *);
main() {
  system("clear");
  printf("Press any key to see return code.");
  int getch_out = 0;
  do {
    getch_out = getch();
    system("clear");
    printf("Pressed key return value: %d\n\n\n\n\nPress ESC key to terminate "
           "application (ESC returns integer value 27).\n\n",
           getch_out);
  } while (getch_out != 27);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <system@plt>
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1050 <getch@plt>
mov    %eax,-0x8(%rbp)
lea    0xe8f(%rip),%rdi
call   1030 <system@plt>
mov    -0x8(%rbp),%esi
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x1b,-0x8(%rbp)
jne    1160 <main+0x30>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
lea    0xec5(%rip),%r14
mov    %r14,%rdi
call   1030 <system@plt>
lea    0xebc(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed0(%rip),%rbx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <getch@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1030 <system@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x1b,%ebp
jne    1160 <main+0x30>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"clear\00"
@.str.1 = [34 x i8] c"Press any key to see return code.\00"
@.str.2 = [106 x i8] c"Pressed key return value: %d\0A\0A\0A\0A\0APress ESC key to terminate application (ESC returns integer value 27).\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %2
br label %5
5: ; preds = %10, %0
%6 = call i32 (...) @getch()
store i32 %6, i32* %2
%7 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* %2
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([106 x i8], [106 x i8]* @.str.2, i64 0, i64 0), i32 %8)
br label %10
10: ; preds = %5
%11 = load i32, i32* %2
%12 = icmp ne i32 %11, 27
br i1 %12, label %5, label %13
13: ; preds = %10
%14 = load i32, i32* %1
ret i32 %14
}

LLVM IR (-O2):
@.str = [6 x i8] c"clear\00"
@.str.1 = [34 x i8] c"Press any key to see return code.\00"
@.str.2 = [106 x i8] c"Pressed key return value: %d\0A\0A\0A\0A\0APress ESC key to terminate application (ESC returns integer value 27).\0A\0A\00"
define i32 @main() {
%1 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
br label %3
3: ; preds = %3, %0
%4 = tail call i32 (...) @getch()
%5 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([106 x i8], [106 x i8]* @.str.2, i64 0, i64 0), i32 %4)
%7 = icmp eq i32 %4, 27
br i1 %7, label %8, label %3
8: ; preds = %3
ret i32 0
}