#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int, int, char);
int read(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ stdout;
void main() {
  int endOfInput = 0;
  char ch;
  while (!endOfInput) {
    fflush(stdout);
    if (read(0, &ch, 1) != 1) {
      return;
    }
    printf("%d %x '%c'\n", (int)ch, (int)ch, ch);
  }
  return;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1155 <main+0x25>
jmp    119e <main+0x6e>
mov    0x2e84(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
xor    %edi,%edi
lea    -0x5(%rbp),%rsi
mov    $0x1,%edx
call   1040 <read@plt>
cmp    $0x1,%eax
je     1181 <main+0x51>
jmp    11a3 <main+0x73>
movsbl -0x5(%rbp),%esi
movsbl -0x5(%rbp),%edx
lea    0xe70(%rip),%rdi
movsbl -0x5(%rbp),%ecx
call   1030 <printf@plt>
jmp    113f <main+0xf>
jmp    11a3 <main+0x73>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    0x2ea0(%rip),%r15
mov    (%r15),%edi
call   1050 <fflush@plt>
lea    0xf(%rsp),%rsi
xor    %edi,%edi
mov    $0x1,%edx
call   1040 <read@plt>
cmp    $0x1,%eax
jne    119d <main+0x6d>
lea    0xe9b(%rip),%r14
lea    0xf(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
movsbl 0xf(%rsp),%ecx
mov    %r14,%rdi
mov    %ecx,%esi
mov    %ecx,%edx
call   1030 <printf@plt>
mov    (%r15),%edi
call   1050 <fflush@plt>
xor    %edi,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1040 <read@plt>
cmp    $0x1,%eax
je     1170 <main+0x40>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [12 x i8] c"%d %x '%c'\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
br label %3
3: ; preds = %13, %0
%4 = load i32, i32* %1
%5 = icmp ne i32 %4, 0
%6 = xor i1 %5, true
br i1 %6, label %7, label %20
7: ; preds = %3
%8 = load i32, i32* @stdout
%9 = call i32 @fflush(i32 %8)
%10 = call i32 @read(i32 0, i8* %2, i32 1)
%11 = icmp ne i32 %10, 1
br i1 %11, label %12, label %13
12: ; preds = %7
br label %21
13: ; preds = %7
%14 = load i8, i8* %2
%15 = sext i8 %14 to i32
%16 = load i8, i8* %2
%17 = sext i8 %16 to i32
%18 = load i8, i8* %2
%19 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %17, i8 signext %18)
br label %3
20: ; preds = %3
br label %21
21: ; preds = %20, %12
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [12 x i8] c"%d %x '%c'\0A\00"
define void @main() {
%1 = alloca i8
%2 = load i32, i32* @stdout
%3 = tail call i32 @fflush(i32 %2)
%4 = call i32 @read(i32 0, i8* %1, i32 1)
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %14
6: ; preds = %0, %6
%7 = load i8, i8* %1
%8 = sext i8 %7 to i32
%9 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %8, i8 signext %7)
%10 = load i32, i32* @stdout
%11 = tail call i32 @fflush(i32 %10)
%12 = call i32 @read(i32 0, i8* %1, i32 1)
%13 = icmp eq i32 %12, 1
br i1 %13, label %6, label %14
14: ; preds = %6, %0
ret void
}