#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 getkey();
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  int key;
  srand(time(NULL));
  for (;;) {
    key = getkey();
    if (key == 0x1B || key == 0x04) {
      break;
    } else {
      printf("%c", ((key < 0x20) ? (key + 0x20) : key));
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    $0x0,%al
call   1060 <getkey@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x1b,-0x8(%rbp)
je     117d <main+0x3d>
cmpl   $0x4,-0x8(%rbp)
jne    1182 <main+0x42>
jmp    11b4 <main+0x74>
cmpl   $0x20,-0x8(%rbp)
jge    119a <main+0x5a>
mov    -0x8(%rbp),%eax
add    $0x20,%eax
mov    %eax,-0xc(%rbp)
jmp    11a0 <main+0x60>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe56(%rip),%rdi
call   1030 <printf@plt>
jmp    115f <main+0x1f>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
lea    0xeaa(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <getkey@plt>
cmp    $0x4,%eax
je     1184 <main+0x44>
cmp    $0x1b,%eax
je     1184 <main+0x44>
lea    0x20(%rax),%esi
cmp    $0x20,%eax
cmovge %eax,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
jmp    1160 <main+0x20>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @time(i32* null)
%4 = call i32 @srand(i32 %3)
br label %5
5: ; preds = %24, %0
%6 = call i32 (...) @getkey()
store i32 %6, i32* %2
%7 = load i32, i32* %2
%8 = icmp eq i32 %7, 27
br i1 %8, label %12, label %9
9: ; preds = %5
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, 4
br i1 %11, label %12, label %13
12: ; preds = %9, %5
br label %25
13: ; preds = %9
%14 = load i32, i32* %2
%15 = icmp slt i32 %14, 32
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load i32, i32* %2
%18 = add nsw i32 %17, 32
br label %21
19: ; preds = %13
%20 = load i32, i32* %2
br label %21
21: ; preds = %19, %16
%22 = phi i32 [ %18, %16 ], [ %20, %19 ]
%23 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %22)
br label %24
24: ; preds = %21
br label %5
25: ; preds = %12
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
define i32 @main() {
%1 = tail call i32 @time(i32* null)
%2 = tail call i32 @srand(i32 %1)
br label %3
3: ; preds = %5, %0
%4 = tail call i32 (...) @getkey()
switch i32 %4, label %5 [
i32 27, label %10
i32 4, label %10
]
5: ; preds = %3
%6 = icmp slt i32 %4, 32
%7 = add nsw i32 %4, 32
%8 = select i1 %6, i32 %7, i32 %4
%9 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %8)
br label %3
10: ; preds = %3, %3
ret i32 0
}