#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();
scalar_t__ isprint(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(int);
int main(void) {
  int c, n;
  n = 0;
  while ((c = getchar()) != EOF) {
    n++;
    if (isprint(c)) {
      putchar(c);
    } else {
      printf("0x%x", c);
    }
    if (n == 80) {
      printf("\n");
      n = 0;
    }
  }
  return 0;
}


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   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e81(%rip),%rcx
cmp    (%rcx),%eax
je     11cc <main+0x8c>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1060 <isprint@plt>
cmp    $0x0,%rax
je     1197 <main+0x57>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
jmp    11a8 <main+0x68>
mov    -0x8(%rbp),%esi
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x50,-0xc(%rbp)
jne    11c7 <main+0x87>
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
jmp    1156 <main+0x16>
xor    %eax,%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    0x2e93(%rip),%r15
cmp    (%r15),%eax
jne    1167 <main+0x27>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebp
lea    0xe90(%rip),%r14
xor    %ebx,%ebx
jmp    118e <main+0x4e>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebp
cmp    (%r15),%eax
je     115a <main+0x1a>
add    $0x1,%ebx
mov    %ebp,%edi
call   1060 <isprint@plt>
test   %rax,%rax
je     11b0 <main+0x70>
mov    %ebp,%edi
call   1030 <putchar@plt>
cmp    $0x50,%ebx
jne    1180 <main+0x40>
jmp    11c1 <main+0x81>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x50,%ebx
jne    1180 <main+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebx,%ebx
jmp    1180 <main+0x40>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [5 x i8] c"0x%x\00"
@.str.1 = [2 x i8] c"\0A\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 = %25, %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 %26
8: ; preds = %4
%9 = load i32, i32* %3
%10 = add nsw i32 %9, 1
store i32 %10, i32* %3
%11 = load i32, i32* %2
%12 = call i64 @isprint(i32 %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %8
%15 = load i32, i32* %2
%16 = call i32 @putchar(i32 %15)
br label %20
17: ; preds = %8
%18 = load i32, i32* %2
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %17, %14
%21 = load i32, i32* %3
%22 = icmp eq i32 %21, 80
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %25
25: ; preds = %23, %20
br label %4
26: ; preds = %4
ret i32 0
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [5 x i8] c"0x%x\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, %18
%5 = phi i32 [ %20, %18 ], [ %1, %0 ]
%6 = phi i32 [ %19, %18 ], [ 0, %0 ]
%7 = add nsw i32 %6, 1
%8 = tail call i64 @isprint(i32 %5)
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %4
%11 = tail call i32 @putchar(i32 %5)
br label %14
12: ; preds = %4
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %5)
br label %14
14: ; preds = %12, %10
%15 = icmp eq i32 %7, 80
br i1 %15, label %16, label %18
16: ; preds = %14
%17 = tail call i32 @putchar(i32 10)
br label %18
18: ; preds = %16, %14
%19 = phi i32 [ 0, %16 ], [ %7, %14 ]
%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 = %18, %0
ret i32 0
}