#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 write(int, unsigned char *, int);
int dump_init(int fd, long *id, long *extra) {
  unsigned char c, o = 0;
  c = 0x80;
  if (write(fd, &c, 1) != 1)
    return -1;
  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    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movb   $0x0,-0x1a(%rbp)
movb   $0x80,-0x19(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x19(%rbp),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
cmp    $0x1,%eax
je     1170 <dump_init+0x40>
mov    $0xffffffff,%eax
add    $0x30,%rsp
pop    %rbp
ret
jmp    1175 <dump_init+0x45>
mov    -0x4(%rbp),%edi
lea    -0x19(%rbp),%rsi
mov    $0x1,%edx
call   1030 <readchar@plt>
cmp    $0x0,%eax
jne    11e6 <dump_init+0xb6>
movzbl -0x19(%rbp),%eax
mov    %eax,-0x20(%rbp)
movzbl -0x19(%rbp),%eax
cmp    $0x20,%eax
jle    11bc <dump_init+0x8c>
movzbl -0x19(%rbp),%eax
cmp    $0x7f,%eax
jge    11bc <dump_init+0x8c>
movzbl -0x19(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    11c9 <dump_init+0x99>
mov    $0x78,%eax
mov    %eax,-0x24(%rbp)
jmp    11c9 <dump_init+0x99>
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movb   $0x1,-0x1a(%rbp)
jmp    1207 <dump_init+0xd7>
cmpb   $0x0,-0x1a(%rbp)
je     1202 <dump_init+0xd2>
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movb   $0x0,-0x1a(%rbp)
jmp    1207 <dump_init+0xd7>
jmp    1175 <dump_init+0x45>

x86 assembly (clang, -O2):
<dump_init>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
movb   $0x80,0x7(%rsp)
lea    0x7(%rsp),%rsi
mov    $0x1,%edx
call   1050 <write@plt>
cmp    $0x1,%eax
jne    11c9 <dump_init+0x89>
mov    $0x1,%bpl
lea    0x7(%rsp),%r14
lea    0xe8f(%rip),%r15
jmp    119e <dump_init+0x5e>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
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   1060 <printf@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1040 <readchar@plt>
test   %eax,%eax
je     1180 <dump_init+0x40>
test   $0x1,%bpl
mov    $0x1,%bpl
jne    119e <dump_init+0x5e>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x1,%bpl
jmp    119e <dump_init+0x5e>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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, i64* %1, i64* %2) {
%4 = alloca i32
%5 = alloca i64*
%6 = alloca i64*
%7 = alloca i8
%8 = alloca i8
store i32 %0, i32* %4
store i64* %1, i64** %5
store i64* %2, i64** %6
store i8 0, i8* %8
store i8 -128, i8* %7
%9 = load i32, i32* %4
%10 = call i32 @write(i32 %9, i8* %7, i32 1)
%11 = icmp ne i32 %10, 1
br i1 %11, label %12, label %13
12: ; preds = %3
ret i32 -1
13: ; preds = %3
br label %14
14: ; preds = %13, %41
%15 = load i32, i32* %4
%16 = call i32 @readchar(i32 %15, i8* %7, i32 1)
%17 = icmp ne i32 %16, 0
br i1 %17, label %35, label %18
18: ; preds = %14
%19 = load i8, i8* %7
%20 = zext i8 %19 to i32
%21 = load i8, i8* %7
%22 = zext i8 %21 to i32
%23 = icmp sgt i32 %22, 32
br i1 %23, label %24, label %31
24: ; preds = %18
%25 = load i8, i8* %7
%26 = zext i8 %25 to i32
%27 = icmp slt i32 %26, 127
br i1 %27, label %28, label %31
28: ; preds = %24
%29 = load i8, i8* %7
%30 = zext i8 %29 to i32
br label %32
31: ; preds = %24, %18
br label %32
32: ; preds = %31, %28
%33 = phi i32 [ %30, %28 ], [ 120, %31 ]
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %20, i32 %33)
store i8 1, i8* %8
br label %41
35: ; preds = %14
%36 = load i8, i8* %8
%37 = icmp ne i8 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8 0, i8* %8
br label %40
40: ; preds = %38, %35
br label %41
41: ; preds = %40, %32
br label %14
}

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