#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 EOF;
int getchar();
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int c;
  int count = 0;
  while ((c = getchar()) != EOF) {
    if (count++ == 20) {
      printf("\n");
      count = 0;
    }
    if (0x21 <= c && c <= 0x7e)
      printf("%c", c);
    else
      printf("0x%02x", c);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2ea1(%rip),%rcx
cmp    (%rcx),%eax
je     11bc <main+0x9c>
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x14,%eax
jne    1178 <main+0x58>
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    $0x21,%eax
cmp    -0x8(%rbp),%eax
jg     11a6 <main+0x86>
cmpl   $0x7e,-0x8(%rbp)
jg     11a6 <main+0x86>
mov    -0x8(%rbp),%esi
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b7 <main+0x97>
mov    -0x8(%rbp),%esi
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1136 <main+0x16>
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2ea3(%rip),%r15
cmp    (%r15),%eax
jne    1161 <main+0x31>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebx
lea    0xe96(%rip),%r14
xor    %ebp,%ebp
jmp    118a <main+0x5a>
xchg   %ax,%ax
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebx
cmp    (%r15),%eax
je     114a <main+0x1a>
cmp    $0x14,%ebp
je     11a0 <main+0x70>
add    $0x1,%ebp
jmp    11ac <main+0x7c>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebp,%ebp
lea    -0x21(%rbx),%eax
cmp    $0x5d,%eax
ja     1170 <main+0x40>
mov    %ebx,%edi
call   1030 <putchar@plt>
jmp    117c <main+0x4c>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [2 x i8] c"\0A\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [7 x i8] c"0x%02x\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
br label %4
4: ; preds = %26, %0
%5 = call i32 (...) @getchar()
store i32 %5, i32* %2
%6 = load i32, i32* @EOF
%7 = icmp ne i32 %5, %6
br i1 %7, label %8, label %27
8: ; preds = %4
%9 = load i32, i32* %3
%10 = add nsw i32 %9, 1
store i32 %10, i32* %3
%11 = icmp eq i32 %9, 20
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %14
14: ; preds = %12, %8
%15 = load i32, i32* %2
%16 = icmp sle i32 33, %15
br i1 %16, label %17, label %23
17: ; preds = %14
%18 = load i32, i32* %2
%19 = icmp sle i32 %18, 126
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load i32, i32* %2
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %21)
br label %26
23: ; preds = %17, %14
%24 = load i32, i32* %2
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %23, %20
br label %4
27: ; preds = %4
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%29 = load i32, i32* %1
ret i32 %29
}

LLVM IR (-O2):
@EOF = global i32 0
@.str.2 = [7 x i8] c"0x%02x\00"
define i32 @main() {
%1 = tail call i32 (...) @getchar()
%2 = load i32, i32* @EOF
%3 = icmp eq i32 %1, %2
br i1 %3, label %23, label %4
4: ; preds = %0, %19
%5 = phi i32 [ %20, %19 ], [ %1, %0 ]
%6 = phi i32 [ %12, %19 ], [ 0, %0 ]
%7 = add nsw i32 %6, 1
%8 = icmp eq i32 %6, 20
br i1 %8, label %9, label %11
9: ; preds = %4
%10 = tail call i32 @putchar(i32 10)
br label %11
11: ; preds = %9, %4
%12 = phi i32 [ 0, %9 ], [ %7, %4 ]
%13 = add i32 %5, -33
%14 = icmp ult i32 %13, 94
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = tail call i32 @putchar(i32 %5)
br label %19
17: ; preds = %11
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %5)
br label %19
19: ; preds = %17, %15
%20 = tail call i32 (...) @getchar()
%21 = load i32, i32* @EOF
%22 = icmp eq i32 %20, %21
br i1 %22, label %23, label %4
23: ; preds = %19, %0
%24 = tail call i32 @putchar(i32 10)
ret i32 0
}