#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*/ cpc_AnyKeyPressed();
int /*<<< orphan*/ cpc_PrintStr(char *);
int /*<<< orphan*/ cpc_RedefineKey(int);
int /*<<< orphan*/ cpc_SetBorder(int);
scalar_t__ cpc_TestKey(int);
int /*<<< orphan*/ wait();
void tecladoEjemplo() {
  cpc_PrintStr("Press a Key to redefine as #1");
  cpc_RedefineKey(0);
  cpc_PrintStr("Done!");
  cpc_PrintStr("Press any key");
  while (!(cpc_AnyKeyPressed())) {
  }
  cpc_PrintStr("fine! try again");
  cpc_PrintStr("Press any key to continue");
  while (!(cpc_AnyKeyPressed())) {
  }
  cpc_PrintStr("Press a Key to redefine as #2");
  cpc_RedefineKey(3);
  cpc_PrintStr("Done!");
  wait();
  cpc_SetBorder(3);
  cpc_PrintStr("Press a Key to test it..");
  while (1) {
    if (cpc_TestKey(0)) {
      cpc_PrintStr("OK Key #1");
    }
    if (cpc_TestKey(3)) {
      cpc_PrintStr("OK Key #2");
    }
  }
}


x86 assembly (clang, -O0):
<tecladoEjemplo>:
push   %rbp
mov    %rsp,%rbp
lea    0xe95(%rip),%rdi
call   1040 <cpc_PrintStr@plt>
xor    %edi,%edi
call   1030 <cpc_RedefineKey@plt>
lea    0xea0(%rip),%rdi
call   1040 <cpc_PrintStr@plt>
lea    0xe9a(%rip),%rdi
call   1040 <cpc_PrintStr@plt>
mov    $0x0,%al
call   1070 <cpc_AnyKeyPressed@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11ab <tecladoEjemplo+0x4b>
jmp    11b0 <tecladoEjemplo+0x50>
jmp    118f <tecladoEjemplo+0x2f>
lea    0xe7b(%rip),%rdi
call   1040 <cpc_PrintStr@plt>
lea    0xe7f(%rip),%rdi
call   1040 <cpc_PrintStr@plt>
mov    $0x0,%al
call   1070 <cpc_AnyKeyPressed@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11e4 <tecladoEjemplo+0x84>
jmp    11e9 <tecladoEjemplo+0x89>
jmp    11c8 <tecladoEjemplo+0x68>
lea    0xe6c(%rip),%rdi
call   1040 <cpc_PrintStr@plt>
mov    $0x3,%edi
call   1030 <cpc_RedefineKey@plt>
lea    0xe18(%rip),%rdi
call   1040 <cpc_PrintStr@plt>
mov    $0x0,%al
call   1080 <wait@plt>
mov    $0x3,%edi
call   1050 <cpc_SetBorder@plt>
lea    0xe57(%rip),%rdi
call   1040 <cpc_PrintStr@plt>
xor    %edi,%edi
call   1060 <cpc_TestKey@plt>
cmp    $0x0,%rax
je     1245 <tecladoEjemplo+0xe5>
lea    0xe53(%rip),%rdi
call   1040 <cpc_PrintStr@plt>
mov    $0x3,%edi
call   1060 <cpc_TestKey@plt>
cmp    $0x0,%rax
je     1265 <tecladoEjemplo+0x105>
lea    0xe3d(%rip),%rdi
call   1040 <cpc_PrintStr@plt>
jmp    1228 <tecladoEjemplo+0xc8>

x86 assembly (clang, -O2):
<tecladoEjemplo>:
push   %r14
push   %rbx
push   %rax
lea    0xe95(%rip),%rdi
call   1040 <cpc_PrintStr@plt>
xor    %edi,%edi
call   1030 <cpc_RedefineKey@plt>
lea    0xea0(%rip),%rdi
call   1040 <cpc_PrintStr@plt>
lea    0xe9a(%rip),%rdi
call   1040 <cpc_PrintStr@plt>
nop
xor    %eax,%eax
call   1070 <cpc_AnyKeyPressed@plt>
test   %eax,%eax
je     1190 <tecladoEjemplo+0x30>
lea    0xe90(%rip),%rdi
call   1040 <cpc_PrintStr@plt>
lea    0xe94(%rip),%rdi
call   1040 <cpc_PrintStr@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1070 <cpc_AnyKeyPressed@plt>
test   %eax,%eax
je     11c0 <tecladoEjemplo+0x60>
lea    0xe8a(%rip),%rdi
call   1040 <cpc_PrintStr@plt>
mov    $0x3,%edi
call   1030 <cpc_RedefineKey@plt>
lea    0xe36(%rip),%rdi
call   1040 <cpc_PrintStr@plt>
xor    %eax,%eax
call   1080 <wait@plt>
mov    $0x3,%edi
call   1050 <cpc_SetBorder@plt>
lea    0xe75(%rip),%rdi
lea    0xe91(%rip),%r14
lea    0xe80(%rip),%rbx
jmp    1223 <tecladoEjemplo+0xc3>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
call   1040 <cpc_PrintStr@plt>
jmp    123f <tecladoEjemplo+0xdf>
nopw   0x0(%rax,%rax,1)
mov    $0x3,%edi
call   1060 <cpc_TestKey@plt>
test   %rax,%rax
jne    1220 <tecladoEjemplo+0xc0>
xor    %edi,%edi
call   1060 <cpc_TestKey@plt>
test   %rax,%rax
je     1230 <tecladoEjemplo+0xd0>
mov    %rbx,%rdi
call   1040 <cpc_PrintStr@plt>
jmp    1230 <tecladoEjemplo+0xd0>

LLVM IR (-O0):
@.str = [30 x i8] c"Press a Key to redefine as\00"
@.str.1 = [6 x i8] c"Done!\00"
@.str.2 = [14 x i8] c"Press any key\00"
@.str.3 = [16 x i8] c"fine! try again\00"
@.str.4 = [26 x i8] c"Press any key to continue\00"
@.str.5 = [30 x i8] c"Press a Key to redefine as\00"
@.str.6 = [25 x i8] c"Press a Key to test it..\00"
@.str.7 = [10 x i8] c"OK Key\00"
@.str.8 = [10 x i8] c"OK Key\00"
define void @tecladoEjemplo() {
%1 = call i32 @cpc_PrintStr(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%2 = call i32 @cpc_RedefineKey(i32 0)
%3 = call i32 @cpc_PrintStr(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @cpc_PrintStr(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %5
5: ; preds = %9, %0
%6 = call i32 (...) @cpc_AnyKeyPressed()
%7 = icmp ne i32 %6, 0
%8 = xor i1 %7, true
br i1 %8, label %9, label %10
9: ; preds = %5
br label %5
10: ; preds = %5
%11 = call i32 @cpc_PrintStr(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @cpc_PrintStr(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
br label %13
13: ; preds = %17, %10
%14 = call i32 (...) @cpc_AnyKeyPressed()
%15 = icmp ne i32 %14, 0
%16 = xor i1 %15, true
br i1 %16, label %17, label %18
17: ; preds = %13
br label %13
18: ; preds = %13
%19 = call i32 @cpc_PrintStr(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
%20 = call i32 @cpc_RedefineKey(i32 3)
%21 = call i32 @cpc_PrintStr(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 (...) @wait()
%23 = call i32 @cpc_SetBorder(i32 3)
%24 = call i32 @cpc_PrintStr(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
br label %25
25: ; preds = %18, %35
%26 = call i64 @cpc_TestKey(i32 0)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = call i32 @cpc_PrintStr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0))
br label %30
30: ; preds = %28, %25
%31 = call i64 @cpc_TestKey(i32 3)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = call i32 @cpc_PrintStr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
br label %35
35: ; preds = %33, %30
br label %25
}

LLVM IR (-O2):
@.str = [30 x i8] c"Press a Key to redefine as\00"
@.str.1 = [6 x i8] c"Done!\00"
@.str.2 = [14 x i8] c"Press any key\00"
@.str.3 = [16 x i8] c"fine! try again\00"
@.str.4 = [26 x i8] c"Press any key to continue\00"
@.str.5 = [30 x i8] c"Press a Key to redefine as\00"
@.str.6 = [25 x i8] c"Press a Key to test it..\00"
@.str.7 = [10 x i8] c"OK Key\00"
@.str.8 = [10 x i8] c"OK Key\00"
define void @tecladoEjemplo() {
%1 = tail call i32 @cpc_PrintStr(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @cpc_RedefineKey(i32 0)
%3 = tail call i32 @cpc_PrintStr(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @cpc_PrintStr(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %5
5: ; preds = %5, %0
%6 = tail call i32 (...) @cpc_AnyKeyPressed()
%7 = icmp eq i32 %6, 0
br i1 %7, label %5, label %8
8: ; preds = %5
%9 = tail call i32 @cpc_PrintStr(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%10 = tail call i32 @cpc_PrintStr(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
br label %11
11: ; preds = %11, %8
%12 = tail call i32 (...) @cpc_AnyKeyPressed()
%13 = icmp eq i32 %12, 0
br i1 %13, label %11, label %14
14: ; preds = %11
%15 = tail call i32 @cpc_PrintStr(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
%16 = tail call i32 @cpc_RedefineKey(i32 3)
%17 = tail call i32 @cpc_PrintStr(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%18 = tail call i32 (...) @wait()
%19 = tail call i32 @cpc_SetBorder(i32 3)
br label %20
20: ; preds = %28, %14
%21 = phi i8* [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), %14 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), %28 ]
%22 = tail call i32 @cpc_PrintStr(i8* %21)
br label %23
23: ; preds = %20, %28
%24 = tail call i64 @cpc_TestKey(i32 0)
%25 = icmp eq i64 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %23
%27 = tail call i32 @cpc_PrintStr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0))
br label %28
28: ; preds = %26, %23
%29 = tail call i64 @cpc_TestKey(i32 3)
%30 = icmp eq i64 %29, 0
br i1 %30, label %23, label %20
}