#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
unsigned char ureadchar();
int main(int argc, char *argv[]) {
  unsigned char c;
  printf("keys: press ctrl-c to quit\n");
  for (;;) {
    c = ureadchar();
    if (c == 0)
      continue;
    printf("char: %c, ord: %d = 0x%x\n", c, (unsigned int)c, (unsigned int)c);
    if (c == 3)
      exit(0);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <ureadchar@plt>
mov    %al,-0x11(%rbp)
movzbl -0x11(%rbp),%eax
cmp    $0x0,%eax
jne    1170 <main+0x40>
jmp    1154 <main+0x24>
movzbl -0x11(%rbp),%esi
movzbl -0x11(%rbp),%edx
movzbl -0x11(%rbp),%ecx
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movzbl -0x11(%rbp),%eax
cmp    $0x3,%eax
jne    119e <main+0x6e>
xor    %edi,%edi
call   1050 <exit@plt>
jmp    1154 <main+0x24>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xecf(%rip),%rdi
call   1030 <puts@plt>
lea    0xea9(%rip),%r14
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <ureadchar@plt>
test   %al,%al
je     1160 <main+0x20>
mov    %eax,%ebx
movzbl %al,%ecx
mov    %r14,%rdi
mov    %ecx,%esi
mov    %ecx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x3,%bl
jne    1160 <main+0x20>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [28 x i8] c"keys: press ctrl-c to quit\0A\00"
@.str.1 = [26 x i8] c"char: %c, ord: %d = 0x%x\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %27, %13, %2
%9 = call zeroext i8 (...) @ureadchar()
store i8 %9, i8* %6
%10 = load i8, i8* %6
%11 = zext i8 %10 to i32
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %8
br label %8
14: ; preds = %8
%15 = load i8, i8* %6
%16 = zext i8 %15 to i32
%17 = load i8, i8* %6
%18 = zext i8 %17 to i32
%19 = load i8, i8* %6
%20 = zext i8 %19 to i32
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %16, i32 %18, i32 %20)
%22 = load i8, i8* %6
%23 = zext i8 %22 to i32
%24 = icmp eq i32 %23, 3
br i1 %24, label %25, label %27
25: ; preds = %14
%26 = call i32 @exit(i32 0)
unreachable
27: ; preds = %14
br label %8
}

LLVM IR (-O2):
@.str.1 = [26 x i8] c"char: %c, ord: %d = 0x%x\0A\00"
@str = [27 x i8] c"keys: press ctrl-c to quit\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
br label %4
4: ; preds = %7, %2
%5 = tail call zeroext i8 (...) @ureadchar()
%6 = icmp eq i8 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %4, %8
br label %4
8: ; preds = %4
%9 = zext i8 %5 to i32
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %9, i32 %9, i32 %9)
%11 = icmp eq i8 %5, 3
br i1 %11, label %12, label %7
12: ; preds = %8
%13 = tail call i32 @exit(i32 0)
unreachable
}