#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);
int /*<<< orphan*/ putchar(char);
void print_characters(int *output) {
  int count_length = 0;
  int c;
  while ((c = getchar()) != EOF) {
    if (isprint(c) != 0) {
      if (*output == 0) {
        printf("0%-3o ", c);
      } else {
        printf("0x%x ", c);
      }
    } else {
      putchar(c);
    }
    count_length += 4;
    if (count_length >= 70) {
      putchar('\n');
      count_length = 0;
    }
  }
}


x86 assembly (clang, -O0):
<print_characters>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x10(%rbp)
mov    0x2e84(%rip),%rcx
cmp    (%rcx),%eax
je     11e7 <print_characters+0xa7>
mov    -0x10(%rbp),%edi
call   1060 <isprint@plt>
cmp    $0x0,%rax
je     11b3 <print_characters+0x73>
mov    -0x8(%rbp),%rax
cmpl   $0x0,(%rax)
jne    119f <print_characters+0x5f>
mov    -0x10(%rbp),%esi
lea    0xe6b(%rip),%rdi
call   1040 <printf@plt>
jmp    11ae <print_characters+0x6e>
mov    -0x10(%rbp),%esi
lea    0xe5e(%rip),%rdi
call   1040 <printf@plt>
jmp    11be <print_characters+0x7e>
mov    -0x10(%rbp),%eax
movsbl %al,%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x46,-0xc(%rbp)
jl     11e2 <print_characters+0xa2>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x0,-0xc(%rbp)
jmp    1153 <print_characters+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_characters>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r13
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e8c(%rip),%r12
cmp    (%r12),%eax
jne    1171 <print_characters+0x31>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebp
lea    0xe86(%rip),%r14
lea    0xe86(%rip),%r15
xor    %ebx,%ebx
jmp    11ab <print_characters+0x6b>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebp
cmp    (%r12),%eax
je     1162 <print_characters+0x22>
mov    %ebp,%edi
call   1060 <isprint@plt>
test   %rax,%rax
je     11d0 <print_characters+0x90>
cmpl   $0x0,0x0(%r13)
je     11e0 <print_characters+0xa0>
mov    %r15,%rdi
jmp    11e3 <print_characters+0xa3>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl %bpl,%edi
call   1030 <putchar@plt>
cmp    $0x42,%ebx
jl     11ef <print_characters+0xaf>
jmp    1190 <print_characters+0x50>
mov    %r14,%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
cmp    $0x42,%ebx
jge    1190 <print_characters+0x50>
add    $0x4,%ebx
jmp    119c <print_characters+0x5c>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [7 x i8] c"0%-3o \00"
@.str.1 = [6 x i8] c"0x%x \00"
define void @print_characters(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %3
br label %5
5: ; preds = %35, %1
%6 = call i32 (...) @getchar()
store i32 %6, i32* %4
%7 = load i32, i32* @EOF
%8 = icmp ne i32 %6, %7
br i1 %8, label %9, label %36
9: ; preds = %5
%10 = load i32, i32* %4
%11 = call i64 @isprint(i32 %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %24
13: ; preds = %9
%14 = load i32*, i32** %2
%15 = load i32, i32* %14
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = load i32, i32* %4
%19 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %18)
br label %23
20: ; preds = %13
%21 = load i32, i32* %4
%22 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %20, %17
br label %28
24: ; preds = %9
%25 = load i32, i32* %4
%26 = trunc i32 %25 to i8
%27 = call i32 @putchar(i8 signext %26)
br label %28
28: ; preds = %24, %23
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 4
store i32 %30, i32* %3
%31 = load i32, i32* %3
%32 = icmp sge i32 %31, 70
br i1 %32, label %33, label %35
33: ; preds = %28
%34 = call i32 @putchar(i8 signext 10)
store i32 0, i32* %3
br label %35
35: ; preds = %33, %28
br label %5
36: ; preds = %5
ret void
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [7 x i8] c"0%-3o \00"
@.str.1 = [6 x i8] c"0x%x \00"
define void @print_characters(i32* nocapture %0) {
%2 = tail call i32 (...) @getchar()
%3 = load i32, i32* @EOF
%4 = icmp eq i32 %2, %3
br i1 %4, label %30, label %5
5: ; preds = %1, %25
%6 = phi i32 [ %27, %25 ], [ %2, %1 ]
%7 = phi i32 [ %26, %25 ], [ 0, %1 ]
%8 = tail call i64 @isprint(i32 %6)
%9 = icmp eq i64 %8, 0
br i1 %9, label %17, label %10
10: ; preds = %5
%11 = load i32, i32* %0
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %6)
br label %20
15: ; preds = %10
%16 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %6)
br label %20
17: ; preds = %5
%18 = trunc i32 %6 to i8
%19 = tail call i32 @putchar(i8 signext %18)
br label %20
20: ; preds = %13, %15, %17
%21 = add nsw i32 %7, 4
%22 = icmp sgt i32 %7, 65
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = tail call i32 @putchar(i8 signext 10)
br label %25
25: ; preds = %23, %20
%26 = phi i32 [ 0, %23 ], [ %21, %20 ]
%27 = tail call i32 (...) @getchar()
%28 = load i32, i32* @EOF
%29 = icmp eq i32 %27, %28
br i1 %29, label %30, label %5
30: ; preds = %25, %1
ret void
}