#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*/ STDIN_FILENO;
int /*<<< orphan*/ enableRawMode();
scalar_t__ iscntrl(char);
int /*<<< orphan*/ printf(char *, char, ...);
int read(int /*<<< orphan*/, char *, int);
int main() {
  enableRawMode();
  char c;
  while (read(STDIN_FILENO, &c, 1) == 1) {
    if (iscntrl(c)) {
      printf("%#4o\n", c);
    } else {
      printf("%#4o ('%c')\n", c, c);
    }
    if (c == 'q')
      return 0;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <enableRawMode@plt>
mov    0x2e83(%rip),%rax
mov    (%rax),%edi
lea    -0x5(%rbp),%rsi
mov    $0x1,%edx
call   1060 <read@plt>
cmp    $0x1,%eax
jne    11d6 <main+0x96>
movsbl -0x5(%rbp),%edi
call   1040 <iscntrl@plt>
cmp    $0x0,%rax
je     11a0 <main+0x60>
lea    0xe70(%rip),%rdi
movsbl -0x5(%rbp),%esi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11b8 <main+0x78>
mov    -0x5(%rbp),%al
movsbl -0x5(%rbp),%edx
lea    0xe58(%rip),%rdi
movsbl %al,%esi
mov    $0x0,%al
call   1050 <printf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x71,%eax
jne    11d1 <main+0x91>
movl   $0x0,-0x4(%rbp)
jmp    11dd <main+0x9d>
jmp    1156 <main+0x16>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1030 <enableRawMode@plt>
mov    0x2e86(%rip),%r12
lea    0xf(%rsp),%rbx
lea    0xea0(%rip),%r14
lea    0xe93(%rip),%r15
jmp    1184 <main+0x44>
nop
mov    %r14,%rdi
mov    %ebp,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x71,%bpl
je     11bd <main+0x7d>
mov    (%r12),%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1060 <read@plt>
cmp    $0x1,%eax
jne    11bd <main+0x7d>
movsbl 0xf(%rsp),%ebp
mov    %ebp,%edi
call   1040 <iscntrl@plt>
test   %rax,%rax
je     1170 <main+0x30>
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x71,%bpl
jne    1184 <main+0x44>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@STDIN_FILENO = global i32 0
@.str = [6 x i8] c"%o\0A\00"
@.str.1 = [13 x i8] c"%o ('%c')\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
%3 = call i32 (...) @enableRawMode()
br label %4
4: ; preds = %25, %0
%5 = load i32, i32* @STDIN_FILENO
%6 = call i32 @read(i32 %5, i8* %2, i32 1)
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %26
8: ; preds = %4
%9 = load i8, i8* %2
%10 = call i64 @iscntrl(i8 signext %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = load i8, i8* %2
%14 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8 signext %13)
br label %20
15: ; preds = %8
%16 = load i8, i8* %2
%17 = load i8, i8* %2
%18 = sext i8 %17 to i32
%19 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8 signext %16, i32 %18)
br label %20
20: ; preds = %15, %12
%21 = load i8, i8* %2
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 113
br i1 %23, label %24, label %25
24: ; preds = %20
store i32 0, i32* %1
br label %27
25: ; preds = %20
br label %4
26: ; preds = %4
store i32 0, i32* %1
br label %27
27: ; preds = %26, %24
%28 = load i32, i32* %1
ret i32 %28
}

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