#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*/ clrscr();
int /*<<< orphan*/ gotoxy(int, int);
int kbhit2();
int /*<<< orphan*/ printf(char *, ...);
int screenheight();
int screenwidth();
int /*<<< orphan*/ term_defaults();
int /*<<< orphan*/ term_init();
int /*<<< orphan*/ textbackground(int);
int /*<<< orphan*/ update_time();
int main() {
  int x, y;
  int ancho, alto;
  int tecla;
  term_init();
  ancho = screenwidth();
  alto = screenheight();
  textbackground(2);
  clrscr();
  textbackground(1);
  for (x = 0; x < ancho; x++)
    printf(" ");
  gotoxy(1, alto);
  for (x = 0; x < ancho; x++)
    printf(" ");
  gotoxy(2, 2);
  while ((tecla = kbhit2()) == 0)
    update_time();
  printf("You have pressed: %d\n", tecla);
  term_defaults();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   10c0 <term_init@plt>
mov    $0x0,%al
call   10b0 <screenwidth@plt>
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1090 <screenheight@plt>
mov    %eax,-0x14(%rbp)
mov    $0x2,%edi
call   10a0 <textbackground@plt>
mov    $0x0,%al
call   1030 <clrscr@plt>
mov    $0x1,%edi
call   10a0 <textbackground@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1214 <main+0x74>
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11ec <main+0x4c>
mov    -0x14(%rbp),%esi
mov    $0x1,%edi
call   1080 <gotoxy@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1250 <main+0xb0>
lea    0xdc5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1228 <main+0x88>
mov    $0x2,%esi
mov    %esi,%edi
call   1080 <gotoxy@plt>
mov    $0x0,%al
call   1070 <kbhit2@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jne    127b <main+0xdb>
mov    $0x0,%al
call   1060 <update_time@plt>
jmp    125c <main+0xbc>
mov    -0x18(%rbp),%esi
lea    0xd7d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <term_defaults@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   10d0 <term_init@plt>
xor    %eax,%eax
call   10c0 <screenwidth@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   10a0 <screenheight@plt>
mov    %eax,%r14d
mov    $0x2,%edi
call   10b0 <textbackground@plt>
xor    %eax,%eax
call   1040 <clrscr@plt>
mov    $0x1,%edi
call   10b0 <textbackground@plt>
test   %ebp,%ebp
jle    1221 <main+0x71>
mov    %ebp,%ebx
nop
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    11f0 <main+0x40>
mov    $0x1,%edi
mov    %r14d,%esi
call   1090 <gotoxy@plt>
test   %ebp,%ebp
jle    122e <main+0x7e>
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1210 <main+0x60>
jmp    122e <main+0x7e>
mov    $0x1,%edi
mov    %r14d,%esi
call   1090 <gotoxy@plt>
mov    $0x2,%edi
mov    $0x2,%esi
call   1090 <gotoxy@plt>
nopl   (%rax)
xor    %eax,%eax
call   1080 <kbhit2@plt>
test   %eax,%eax
jne    1254 <main+0xa4>
xor    %eax,%eax
call   1070 <update_time@plt>
jmp    1240 <main+0x90>
lea    0xda5(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1060 <term_defaults@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [22 x i8] c"You have pressed: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (...) @term_init()
%8 = call i32 (...) @screenwidth()
store i32 %8, i32* %4
%9 = call i32 (...) @screenheight()
store i32 %9, i32* %5
%10 = call i32 @textbackground(i32 2)
%11 = call i32 (...) @clrscr()
%12 = call i32 @textbackground(i32 1)
store i32 0, i32* %2
br label %13
13: ; preds = %19, %0
%14 = load i32, i32* %2
%15 = load i32, i32* %4
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %22
17: ; preds = %13
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %17
%20 = load i32, i32* %2
%21 = add nsw i32 %20, 1
store i32 %21, i32* %2
br label %13
22: ; preds = %13
%23 = load i32, i32* %5
%24 = call i32 @gotoxy(i32 1, i32 %23)
store i32 0, i32* %2
br label %25
25: ; preds = %31, %22
%26 = load i32, i32* %2
%27 = load i32, i32* %4
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %34
29: ; preds = %25
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %31
31: ; preds = %29
%32 = load i32, i32* %2
%33 = add nsw i32 %32, 1
store i32 %33, i32* %2
br label %25
34: ; preds = %25
%35 = call i32 @gotoxy(i32 2, i32 2)
br label %36
36: ; preds = %39, %34
%37 = call i32 (...) @kbhit2()
store i32 %37, i32* %6
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %36
%40 = call i32 (...) @update_time()
br label %36
41: ; preds = %36
%42 = load i32, i32* %6
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %42)
%44 = call i32 (...) @term_defaults()
%45 = load i32, i32* %1
ret i32 %45
}

LLVM IR (-O2):
@.str.1 = [22 x i8] c"You have pressed: %d\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @term_init()
%2 = tail call i32 (...) @screenwidth()
%3 = tail call i32 (...) @screenheight()
%4 = tail call i32 @textbackground(i32 2)
%5 = tail call i32 (...) @clrscr()
%6 = tail call i32 @textbackground(i32 1)
%7 = icmp sgt i32 %2, 0
br i1 %7, label %10, label %8
8: ; preds = %0
%9 = tail call i32 @gotoxy(i32 1, i32 %3)
br label %22
10: ; preds = %0, %10
%11 = phi i32 [ %13, %10 ], [ 0, %0 ]
%12 = tail call i32 @putchar(i32 32)
%13 = add nuw nsw i32 %11, 1
%14 = icmp eq i32 %13, %2
br i1 %14, label %15, label %10
15: ; preds = %10
%16 = tail call i32 @gotoxy(i32 1, i32 %3)
br i1 %7, label %17, label %22
17: ; preds = %15, %17
%18 = phi i32 [ %20, %17 ], [ 0, %15 ]
%19 = tail call i32 @putchar(i32 32)
%20 = add nuw nsw i32 %18, 1
%21 = icmp eq i32 %20, %2
br i1 %21, label %22, label %17
22: ; preds = %17, %8, %15
%23 = tail call i32 @gotoxy(i32 2, i32 2)
%24 = tail call i32 (...) @kbhit2()
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %22, %26
%27 = tail call i32 (...) @update_time()
%28 = tail call i32 (...) @kbhit2()
%29 = icmp eq i32 %28, 0
br i1 %29, label %26, label %30
30: ; preds = %26, %22
%31 = phi i32 [ %24, %22 ], [ %28, %26 ]
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %31)
%33 = tail call i32 (...) @term_defaults()
ret i32 0
}