#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*/ printf(char *, ...);
int /*<<< orphan*/ readchar(int, unsigned char *, int);
int dump_init(int fd) {
  unsigned char c, o = 0;
  while (1)
    if (!readchar(fd, &c, 1)) {
      printf("%02x (%c) ", c, ((c > 32) && (c < 127)) ? c : 'x');
      o = 1;
    } else {
      if (o) {
        printf("\n");
        o = 0;
      }
    }
}


x86 assembly (clang, -O0):
<dump_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movb   $0x0,-0x6(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x5(%rbp),%rsi
mov    $0x1,%edx
call   1030 <readchar@plt>
cmp    $0x0,%eax
jne    11a0 <dump_init+0x80>
movzbl -0x5(%rbp),%eax
mov    %eax,-0xc(%rbp)
movzbl -0x5(%rbp),%eax
cmp    $0x20,%eax
jle    1176 <dump_init+0x56>
movzbl -0x5(%rbp),%eax
cmp    $0x7f,%eax
jge    1176 <dump_init+0x56>
movzbl -0x5(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    1183 <dump_init+0x63>
mov    $0x78,%eax
mov    %eax,-0x10(%rbp)
jmp    1183 <dump_init+0x63>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movb   $0x1,-0x6(%rbp)
jmp    11c1 <dump_init+0xa1>
cmpb   $0x0,-0x6(%rbp)
je     11bc <dump_init+0x9c>
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movb   $0x0,-0x6(%rbp)
jmp    11c1 <dump_init+0xa1>
jmp    112f <dump_init+0xf>

x86 assembly (clang, -O2):
<dump_init>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
mov    $0x1,%bpl
lea    0x7(%rsp),%r14
lea    0xeb8(%rip),%r15
jmp    116e <dump_init+0x3e>
nopw   0x0(%rax,%rax,1)
movzbl 0x7(%rsp),%esi
lea    -0x21(%rsi),%eax
cmp    $0x5e,%al
mov    $0x78,%edx
cmovb  %esi,%edx
xor    %ebp,%ebp
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1040 <readchar@plt>
test   %eax,%eax
je     1150 <dump_init+0x20>
test   $0x1,%bpl
mov    $0x1,%bpl
jne    116e <dump_init+0x3e>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x1,%bpl
jmp    116e <dump_init+0x3e>

LLVM IR (-O0):
@.str = [11 x i8] c"%02x (%c) \00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @dump_init(i32 %0) {
%2 = alloca i32
%3 = alloca i8
%4 = alloca i8
store i32 %0, i32* %2
store i8 0, i8* %4
br label %5
5: ; preds = %1, %32
%6 = load i32, i32* %2
%7 = call i32 @readchar(i32 %6, i8* %3, i32 1)
%8 = icmp ne i32 %7, 0
br i1 %8, label %26, label %9
9: ; preds = %5
%10 = load i8, i8* %3
%11 = zext i8 %10 to i32
%12 = load i8, i8* %3
%13 = zext i8 %12 to i32
%14 = icmp sgt i32 %13, 32
br i1 %14, label %15, label %22
15: ; preds = %9
%16 = load i8, i8* %3
%17 = zext i8 %16 to i32
%18 = icmp slt i32 %17, 127
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = load i8, i8* %3
%21 = zext i8 %20 to i32
br label %23
22: ; preds = %15, %9
br label %23
23: ; preds = %22, %19
%24 = phi i32 [ %21, %19 ], [ 120, %22 ]
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %24)
store i8 1, i8* %4
br label %32
26: ; preds = %5
%27 = load i8, i8* %4
%28 = icmp ne i8 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8 0, i8* %4
br label %31
31: ; preds = %29, %26
br label %32
32: ; preds = %31, %23
br label %5
}

LLVM IR (-O2):
@.str = [11 x i8] c"%02x (%c) \00"
define i32 @dump_init(i32 %0) {
%2 = alloca i8
br label %3
3: ; preds = %15, %1
%4 = phi i1 [ true, %1 ], [ %16, %15 ]
%5 = call i32 @readchar(i32 %0, i8* %2, i32 1)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %14
7: ; preds = %3
%8 = load i8, i8* %2
%9 = zext i8 %8 to i32
%10 = add i8 %8, -33
%11 = icmp ult i8 %10, 94
%12 = select i1 %11, i32 %9, i32 120
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %12)
br label %15
14: ; preds = %3
br i1 %4, label %15, label %17
15: ; preds = %14, %17, %7
%16 = phi i1 [ false, %7 ], [ true, %17 ], [ true, %14 ]
br label %3
17: ; preds = %14
%18 = call i32 @putchar(i32 10)
br label %15
}