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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void dump_binary(FILE *out, const void *buffer, size_t length) {
  const uint8_t *dump = buffer;
  for (size_t a = 0; a < length; a += 16) {
    fprintf(out, "%08zx: ", a);
    for (unsigned int i = 0; i < 16; i++) {
      if (a + i < length)
        fprintf(out, " %02x", dump[a + i]);
      else
        fprintf(out, "   ");
      if (i % 16 == 7)
        fprintf(out, " ");
    }
    fprintf(out, "  ");
    for (unsigned int i = 0; i < 16; i++) {
      uint8_t c = dump[a + i];
      if (a + i < length)
        fprintf(out, "%c", 32 <= c && c < 127 ? c : '.');
      else
        fprintf(out, " ");
      if (i % 16 == 7)
        fprintf(out, " ");
    }
    fprintf(out, "\n");
  }
  if (length % 16 != 0)
    fprintf(out, "\n");
}


x86 assembly (clang, -O0):
<dump_binary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    12f1 <dump_binary+0x1e1>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xeaf(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x10,-0x2c(%rbp)
jae    11eb <dump_binary+0xdb>
mov    -0x28(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    %rcx,%rax
cmp    -0x18(%rbp),%rax
jae    11a5 <dump_binary+0x95>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    -0x2c(%rbp),%edx
add    %rdx,%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe6f(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11b7 <dump_binary+0xa7>
mov    -0x8(%rbp),%rdi
lea    0xe5e(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x2c(%rbp),%eax
and    $0xf,%eax
cmp    $0x7,%eax
jne    11d8 <dump_binary+0xc8>
mov    -0x8(%rbp),%rdi
lea    0xe3f(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11dd <dump_binary+0xcd>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    115f <dump_binary+0x4f>
mov    -0x8(%rbp),%rdi
lea    0xe19(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x30(%rbp)
cmpl   $0x10,-0x30(%rbp)
jae    12ce <dump_binary+0x1be>
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%edx
add    %rdx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%ecx
add    %rcx,%rax
cmp    -0x18(%rbp),%rax
jae    1288 <dump_binary+0x178>
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    $0x20,%eax
cmp    -0x34(%rbp),%eax
jg     1261 <dump_binary+0x151>
cmpl   $0x7f,-0x34(%rbp)
jge    1261 <dump_binary+0x151>
mov    -0x34(%rbp),%eax
mov    %eax,-0x44(%rbp)
jmp    126e <dump_binary+0x15e>
mov    $0x2e,%eax
mov    %eax,-0x44(%rbp)
jmp    126e <dump_binary+0x15e>
mov    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%edx
lea    0xd96(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    129a <dump_binary+0x18a>
mov    -0x8(%rbp),%rdi
lea    0xd7d(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x30(%rbp),%eax
and    $0xf,%eax
cmp    $0x7,%eax
jne    12bb <dump_binary+0x1ab>
mov    -0x8(%rbp),%rdi
lea    0xd5c(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    12c0 <dump_binary+0x1b0>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1204 <dump_binary+0xf4>
mov    -0x8(%rbp),%rdi
lea    0xd3c(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x28(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x28(%rbp)
jmp    1134 <dump_binary+0x24>
mov    -0x18(%rbp),%rax
and    $0xf,%rax
cmp    $0x0,%rax
je     1315 <dump_binary+0x205>
mov    -0x8(%rbp),%rdi
lea    0xd07(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_binary>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rdx,%rdx
je     128d <dump_binary+0x15d>
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xeb4(%rip),%rbp
xor    %r12d,%r12d
jmp    1181 <dump_binary+0x51>
nopl   0x0(%rax)
mov    $0xa,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
add    $0x10,%r12
add    $0x40,%r15
cmp    %r14,%r12
mov    %r13,%rbp
jae    126c <dump_binary+0x13c>
mov    %rbx,%rdi
lea    0xe75(%rip),%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %r13d,%r13d
jmp    11aa <dump_binary+0x7a>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r13
cmp    $0x10,%r13
je     1200 <dump_binary+0xd0>
lea    (%r12,%r13,1),%rax
cmp    %r14,%rax
jae    11d0 <dump_binary+0xa0>
mov    (%r15,%r13,4),%edx
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
cmp    $0x7,%r13
jne    11a0 <dump_binary+0x70>
jmp    11ef <dump_binary+0xbf>
nopl   0x0(%rax)
mov    $0x3,%esi
mov    $0x1,%edx
lea    0xe2d(%rip),%rdi
mov    %rbx,%rcx
call   1050 <fwrite@plt>
cmp    $0x7,%r13
jne    11a0 <dump_binary+0x70>
mov    $0x20,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
jmp    11a0 <dump_binary+0x70>
xchg   %ax,%ax
mov    %rbp,%r13
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xdfb(%rip),%rdi
mov    %rbx,%rcx
call   1050 <fwrite@plt>
xor    %ebp,%ebp
jmp    122e <dump_binary+0xfe>
add    $0x1,%rbp
cmp    $0x10,%rbp
je     1160 <dump_binary+0x30>
mov    (%r15,%rbp,4),%edi
lea    -0x20(%rdi),%eax
cmp    $0x5f,%eax
mov    $0x2e,%eax
cmovae %eax,%edi
lea    (%r12,%rbp,1),%rax
cmp    %r14,%rax
mov    $0x20,%eax
cmovae %eax,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
cmp    $0x7,%rbp
jne    1220 <dump_binary+0xf0>
mov    $0x20,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
jmp    1220 <dump_binary+0xf0>
test   $0xf,%r14b
je     128d <dump_binary+0x15d>
mov    $0xa,%edi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fputc@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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