#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
void hd(FILE *file, const char *label, void *data, size_t bytes) {
  size_t goffset, loffset;
  char c;
  fprintf(file, "%s\n", label);
  for (goffset = 0; goffset < bytes; goffset += 16) {
    fprintf(file, "%08X  ", (unsigned int)goffset);
    for (loffset = 0; loffset < 16; ++loffset) {
      if (goffset + loffset < bytes) {
        c = *(char *)((unsigned char *)data + goffset + loffset);
        fprintf(file, "%X%X", (c & 0xF0) >> 4, (c & 0x0F) >> 0);
        fputc(' ', file);
      } else {
        fprintf(file, "   ");
      }
      if (loffset % 8 == 7)
        fputc(' ', file);
    }
    fputc('|', file);
    for (loffset = 0; loffset < 16; ++loffset) {
      if (goffset + loffset < bytes) {
        c = *(char *)((unsigned char *)data + goffset + loffset);
        fputc((c < ' ' || c > '~') ? '.' : c, file);
      }
    }
    fputc('|', file);
    fputc('\n', file);
  }
}


x86 assembly (clang, -O0):
<hd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xeb9(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    12fc <hd+0x1dc>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    %eax,%edx
lea    0xe8f(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movq   $0x0,-0x30(%rbp)
cmpq   $0x10,-0x30(%rbp)
jae    1237 <hd+0x117>
mov    -0x28(%rbp),%rax
add    -0x30(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    11ef <hd+0xcf>
mov    -0x18(%rbp),%rax
add    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x31(%rbp)
mov    -0x8(%rbp),%rdi
movsbl -0x31(%rbp),%edx
and    $0xf0,%edx
sar    $0x4,%edx
movsbl -0x31(%rbp),%ecx
and    $0xf,%ecx
sar    $0x0,%ecx
lea    0xe36(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rsi
mov    $0x20,%edi
call   1030 <fputc@plt>
jmp    1201 <hd+0xe1>
mov    -0x8(%rbp),%rdi
lea    0xe16(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x30(%rbp),%rax
and    $0x7,%rax
cmp    $0x7,%rax
jne    1221 <hd+0x101>
mov    -0x8(%rbp),%rsi
mov    $0x20,%edi
call   1030 <fputc@plt>
jmp    1226 <hd+0x106>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1184 <hd+0x64>
mov    -0x8(%rbp),%rsi
mov    $0x7c,%edi
call   1030 <fputc@plt>
movq   $0x0,-0x30(%rbp)
cmpq   $0x10,-0x30(%rbp)
jae    12cf <hd+0x1af>
mov    -0x28(%rbp),%rax
add    -0x30(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    12b9 <hd+0x199>
mov    -0x18(%rbp),%rax
add    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x31(%rbp)
movsbl -0x31(%rbp),%eax
cmp    $0x20,%eax
jl     1296 <hd+0x176>
movsbl -0x31(%rbp),%eax
cmp    $0x7e,%eax
jle    12a3 <hd+0x183>
mov    $0x2e,%eax
mov    %eax,-0x38(%rbp)
jmp    12aa <hd+0x18a>
movsbl -0x31(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1030 <fputc@plt>
jmp    12be <hd+0x19e>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    124d <hd+0x12d>
mov    -0x8(%rbp),%rsi
mov    $0x7c,%edi
call   1030 <fputc@plt>
mov    -0x8(%rbp),%rsi
mov    $0xa,%edi
call   1030 <fputc@plt>
mov    -0x28(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x28(%rbp)
jmp    1156 <hd+0x36>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hd>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r15
mov    %rdx,%r14
mov    %rsi,%rdx
mov    %rdi,%rbx
lea    0xeb2(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
test   %r15,%r15
je     1297 <hd+0x167>
lea    0xea6(%rip),%rbp
xor    %r12d,%r12d
jmp    119e <hd+0x6e>
nopw   0x0(%rax,%rax,1)
mov    $0x7c,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
add    $0x10,%r12
add    $0x10,%r14
cmp    %r15,%r12
mov    %r13,%rbp
jae    1297 <hd+0x167>
mov    %rbx,%rdi
lea    0xe5c(%rip),%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %r13d,%r13d
jmp    11ca <hd+0x9a>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r13
cmp    $0x10,%r13
je     1240 <hd+0x110>
lea    (%r12,%r13,1),%rax
cmp    %r15,%rax
jae    1200 <hd+0xd0>
movzbl (%r14,%r13,1),%ecx
mov    %ecx,%edx
shr    $0x4,%edx
and    $0xf,%ecx
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x20,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
jmp    1219 <hd+0xe9>
nopl   0x0(%rax)
mov    $0x3,%esi
mov    $0x1,%edx
lea    0xdff(%rip),%rdi
mov    %rbx,%rcx
call   1050 <fwrite@plt>
mov    %r13d,%eax
not    %eax
test   $0x7,%al
jne    11c0 <hd+0x90>
mov    $0x20,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
jmp    11c0 <hd+0x90>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbp,%r13
mov    $0x7c,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
xor    %ebp,%ebp
jmp    126e <hd+0x13e>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbp
cmp    $0x10,%rbp
je     1170 <hd+0x40>
lea    (%r12,%rbp,1),%rax
cmp    %r15,%rax
jae    1260 <hd+0x130>
movzbl (%r14,%rbp,1),%eax
lea    -0x7f(%rax),%ecx
cmp    $0xa1,%cl
mov    $0x2e,%ecx
cmovb  %ecx,%eax
movsbl %al,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
jmp    1260 <hd+0x130>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [7 x i8] c"%08X \00"
@.str.2 = [5 x i8] c"%X%X\00"
@.str.3 = [4 x i8] c" \00"
define void @hd(i32* %0, i8* %1, i8* %2, i64 %3) {
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i8
store i32* %0, i32** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i64 %3, i64* %8
%12 = load i32*, i32** %5
%13 = load i8*, i8** %6
%14 = call i32 (i32*, i8*, ...) @fprintf(i32* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %13)
store i64 0, i64* %9
br label %15
15: ; preds = %110, %4
%16 = load i64, i64* %9
%17 = load i64, i64* %8
%18 = icmp ult i64 %16, %17
br i1 %18, label %19, label %113
19: ; preds = %15
%20 = load i32*, i32** %5
%21 = load i64, i64* %9
%22 = trunc i64 %21 to i32
%23 = call i32 (i32*, i8*, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %22)
store i64 0, i64* %10
br label %24
24: ; preds = %63, %19
%25 = load i64, i64* %10
%26 = icmp ult i64 %25, 16
br i1 %26, label %27, label %66
27: ; preds = %24
%28 = load i64, i64* %9
%29 = load i64, i64* %10
%30 = add i64 %28, %29
%31 = load i64, i64* %8
%32 = icmp ult i64 %30, %31
br i1 %32, label %33, label %52
33: ; preds = %27
%34 = load i8*, i8** %7
%35 = load i64, i64* %9
%36 = getelementptr inbounds i8, i8* %34, i64 %35
%37 = load i64, i64* %10
%38 = getelementptr inbounds i8, i8* %36, i64 %37
%39 = load i8, i8* %38
store i8 %39, i8* %11
%40 = load i32*, i32** %5
%41 = load i8, i8* %11
%42 = sext i8 %41 to i32
%43 = and i32 %42, 240
%44 = ashr i32 %43, 4
%45 = load i8, i8* %11
%46 = sext i8 %45 to i32
%47 = and i32 %46, 15
%48 = ashr i32 %47, 0
%49 = call i32 (i32*, i8*, ...) @fprintf(i32* %40, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %44, i32 %48)
%50 = load i32*, i32** %5
%51 = call i32 @fputc(i8 signext 32, i32* %50)
br label %55
52: ; preds = %27
%53 = load i32*, i32** %5
%54 = call i32 (i32*, i8*, ...) @fprintf(i32* %53, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %55
55: ; preds = %52, %33
%56 = load i64, i64* %10
%57 = urem i64 %56, 8
%58 = icmp eq i64 %57, 7
br i1 %58, label %59, label %62
59: ; preds = %55
%60 = load i32*, i32** %5
%61 = call i32 @fputc(i8 signext 32, i32* %60)
br label %62
62: ; preds = %59, %55
br label %63
63: ; preds = %62
%64 = load i64, i64* %10
%65 = add i64 %64, 1
store i64 %65, i64* %10
br label %24
66: ; preds = %24
%67 = load i32*, i32** %5
%68 = call i32 @fputc(i8 signext 124, i32* %67)
store i64 0, i64* %10
br label %69
69: ; preds = %102, %66
%70 = load i64, i64* %10
%71 = icmp ult i64 %70, 16
br i1 %71, label %72, label %105
72: ; preds = %69
%73 = load i64, i64* %9
%74 = load i64, i64* %10
%75 = add i64 %73, %74
%76 = load i64, i64* %8
%77 = icmp ult i64 %75, %76
br i1 %77, label %78, label %101
78: ; preds = %72
%79 = load i8*, i8** %7
%80 = load i64, i64* %9
%81 = getelementptr inbounds i8, i8* %79, i64 %80
%82 = load i64, i64* %10
%83 = getelementptr inbounds i8, i8* %81, i64 %82
%84 = load i8, i8* %83
store i8 %84, i8* %11
%85 = load i8, i8* %11
%86 = sext i8 %85 to i32
%87 = icmp slt i32 %86, 32
br i1 %87, label %92, label %88
88: ; preds = %78
%89 = load i8, i8* %11
%90 = sext i8 %89 to i32
%91 = icmp sgt i32 %90, 126
br i1 %91, label %92, label %93
92: ; preds = %88, %78
br label %96
93: ; preds = %88
%94 = load i8, i8* %11
%95 = sext i8 %94 to i32
br label %96
96: ; preds = %93, %92
%97 = phi i32 [ 46, %92 ], [ %95, %93 ]
%98 = trunc i32 %97 to i8
%99 = load i32*, i32** %5
%100 = call i32 @fputc(i8 signext %98, i32* %99)
br label %101
101: ; preds = %96, %72
br label %102
102: ; preds = %101
%103 = load i64, i64* %10
%104 = add i64 %103, 1
store i64 %104, i64* %10
br label %69
105: ; preds = %69
%106 = load i32*, i32** %5
%107 = call i32 @fputc(i8 signext 124, i32* %106)
%108 = load i32*, i32** %5
%109 = call i32 @fputc(i8 signext 10, i32* %108)
br label %110
110: ; preds = %105
%111 = load i64, i64* %9
%112 = add i64 %111, 16
store i64 %112, i64* %9
br label %15
113: ; preds = %15
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [7 x i8] c"%08X \00"
@.str.2 = [5 x i8] c"%X%X\00"
@.str.3 = [4 x i8] c" \00"
define void @hd(i32* nocapture %0, i8* %1, i8* nocapture %2, i64 %3) {
%5 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %1)
%6 = icmp eq i64 %3, 0
br i1 %6, label %55, label %7
7: ; preds = %4, %50
%8 = phi i64 [ %53, %50 ], [ 0, %4 ]
%9 = trunc i64 %8 to i32
%10 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = getelementptr inbounds i8, i8* %2, i64 %8
br label %12
12: ; preds = %7, %31
%13 = phi i64 [ 0, %7 ], [ %32, %31 ]
%14 = add nuw nsw i64 %13, %8
%15 = icmp ult i64 %14, %3
br i1 %15, label %16, label %24
16: ; preds = %12
%17 = getelementptr inbounds i8, i8* %11, i64 %13
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = lshr i32 %19, 4
%21 = and i32 %19, 15
%22 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %20, i32 %21)
%23 = tail call i32 @fputc(i8 signext 32, i32* %0)
br label %26
24: ; preds = %12
%25 = tail call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 3, i64 1, i32* %0)
br label %26
26: ; preds = %24, %16
%27 = and i64 %13, 7
%28 = icmp eq i64 %27, 7
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = tail call i32 @fputc(i8 signext 32, i32* %0)
br label %31
31: ; preds = %26, %29
%32 = add nuw nsw i64 %13, 1
%33 = icmp eq i64 %32, 16
br i1 %33, label %34, label %12
34: ; preds = %31
%35 = tail call i32 @fputc(i8 signext 124, i32* %0)
br label %36
36: ; preds = %34, %47
%37 = phi i64 [ 0, %34 ], [ %48, %47 ]
%38 = add nuw nsw i64 %37, %8
%39 = icmp ult i64 %38, %3
br i1 %39, label %40, label %47
40: ; preds = %36
%41 = getelementptr inbounds i8, i8* %11, i64 %37
%42 = load i8, i8* %41
%43 = add i8 %42, -127
%44 = icmp ult i8 %43, -95
%45 = select i1 %44, i8 46, i8 %42
%46 = tail call i32 @fputc(i8 signext %45, i32* %0)
br label %47
47: ; preds = %36, %40
%48 = add nuw nsw i64 %37, 1
%49 = icmp eq i64 %48, 16
br i1 %49, label %50, label %36
50: ; preds = %47
%51 = tail call i32 @fputc(i8 signext 124, i32* %0)
%52 = tail call i32 @fputc(i8 signext 10, i32* %0)
%53 = add i64 %8, 16
%54 = icmp ult i64 %53, %3
br i1 %54, label %7, label %55
55: ; preds = %50, %4
ret void
}