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

/* Variables and functions */
int /*<<< orphan*/ hexlify(int /*<<< orphan*/ const *, size_t const, char *,
                           int);
int /*<<< orphan*/ printf(char *, ...);
void display_binary_data(const uint8_t *blob, const size_t length,
                         const bool show_all, const char *indent) {
  if ((blob) && (length > 0)) {
    const size_t max_on_line = 32;
    size_t start;
    char linebuf[256];
    if (!indent) {
      indent = "";
    }
    if (show_all || (length <= (3 * max_on_line))) {
      for (start = 0; start < length; start += max_on_line) {
        size_t num_bytes =
            (((length - start) < (max_on_line)) ? (length - start)
                                                : (max_on_line));
        printf("%s%s\n", indent,
               hexlify(&blob[start], num_bytes, linebuf, sizeof(linebuf)));
      }
    } else {
      printf("%s%s\n", indent,
             hexlify(blob, max_on_line, linebuf, sizeof(linebuf)));
      printf("%s  :\n", indent);
      start = length - max_on_line;
      printf("%s%s\n", indent,
             hexlify(&blob[start], max_on_line, linebuf, sizeof(linebuf)));
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<display_binary_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     12ec <display_binary_data+0x1cc>
cmpq   $0x0,-0x10(%rbp)
jbe    12ec <display_binary_data+0x1cc>
movq   $0x20,-0x28(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    116e <display_binary_data+0x4e>
lea    0xea2(%rip),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1183 <display_binary_data+0x63>
cmpq   $0x60,-0x10(%rbp)
ja     123d <display_binary_data+0x11d>
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1238 <display_binary_data+0x118>
mov    -0x10(%rbp),%rax
sub    -0x30(%rbp),%rax
cmp    $0x20,%rax
jae    11bf <display_binary_data+0x9f>
mov    -0x10(%rbp),%rax
sub    -0x30(%rbp),%rax
mov    %rax,-0x140(%rbp)
jmp    11d0 <display_binary_data+0xb0>
mov    $0x20,%eax
mov    %rax,-0x140(%rbp)
jmp    11d0 <display_binary_data+0xb0>
mov    -0x140(%rbp),%rax
mov    %rax,-0x138(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x148(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x138(%rbp),%rsi
lea    -0x130(%rbp),%rdx
mov    $0x100,%ecx
call   1040 <hexlify@plt>
mov    -0x148(%rbp),%rsi
mov    %eax,%edx
lea    0xde0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%rax
add    $0x20,%rax
mov    %rax,-0x30(%rbp)
jmp    118b <display_binary_data+0x6b>
jmp    12de <display_binary_data+0x1be>
mov    -0x20(%rbp),%rax
mov    %rax,-0x158(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x130(%rbp),%rdx
mov    $0x20,%esi
mov    $0x100,%ecx
call   1040 <hexlify@plt>
mov    -0x158(%rbp),%rsi
mov    %eax,%edx
lea    0xd8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xd82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
sub    $0x20,%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x150(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
lea    -0x130(%rbp),%rdx
mov    $0x20,%esi
mov    $0x100,%ecx
call   1040 <hexlify@plt>
mov    -0x150(%rbp),%rsi
mov    %eax,%edx
lea    0xd29(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd26(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_binary_data>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
test   %rdi,%rdi
je     1236 <display_binary_data+0x106>
mov    %rsi,%r15
test   %rsi,%rsi
je     1236 <display_binary_data+0x106>
mov    %rdi,%rbx
test   %rcx,%rcx
lea    0xea9(%rip),%r14
cmovne %rcx,%r14
cmp    $0x61,%r15
jb     11db <display_binary_data+0xab>
test   %edx,%edx
jne    11db <display_binary_data+0xab>
mov    %rsp,%r12
mov    $0x20,%esi
mov    %rbx,%rdi
mov    %r12,%rdx
mov    $0x100,%ecx
call   1050 <hexlify@plt>
lea    0xe70(%rip),%r13
mov    %r13,%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe60(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    (%rbx,%r15,4),%rdi
add    $0xffffffffffffff80,%rdi
mov    $0x20,%esi
mov    %r12,%rdx
mov    $0x100,%ecx
call   1050 <hexlify@plt>
mov    %r13,%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    122c <display_binary_data+0xfc>
lea    0xe1e(%rip),%r13
mov    %r15,%rsi
xor    %ebp,%ebp
mov    %r15,%r12
nopw   0x0(%rax,%rax,1)
sub    $0x20,%r12
mov    $0x20,%eax
cmovae %rax,%rsi
mov    %rbx,%rdi
mov    %rsp,%rdx
mov    $0x100,%ecx
call   1050 <hexlify@plt>
mov    %r13,%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x20,%rbp
sub    $0xffffffffffffff80,%rbx
mov    %r12,%rsi
cmp    %r15,%rbp
jb     11f0 <display_binary_data+0xc0>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [6 x i8] c"%s%s\0A\00"
@.str.2 = [7 x i8] c"%s :\0A\00"
@.str.3 = [2 x i8] c"\0A\00"
define void @display_binary_data(i32* %0, i64 %1, i32 %2, i8* %3) {
%5 = alloca i32*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i64
%11 = alloca [256 x i8]
%12 = alloca i64
store i32* %0, i32** %5
store i64 %1, i64* %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%13 = load i32*, i32** %5
%14 = icmp ne i32* %13, null
br i1 %14, label %15, label %76
15: ; preds = %4
%16 = load i64, i64* %6
%17 = icmp ugt i64 %16, 0
br i1 %17, label %18, label %76
18: ; preds = %15
store i64 32, i64* %9
%19 = load i8*, i8** %8
%20 = icmp ne i8* %19, null
br i1 %20, label %22, label %21
21: ; preds = %18
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %8
br label %22
22: ; preds = %21, %18
%23 = load i32, i32* %7
%24 = icmp ne i32 %23, 0
br i1 %24, label %28, label %25
25: ; preds = %22
%26 = load i64, i64* %6
%27 = icmp ule i64 %26, 96
br i1 %27, label %28, label %57
28: ; preds = %25, %22
store i64 0, i64* %10
br label %29
29: ; preds = %53, %28
%30 = load i64, i64* %10
%31 = load i64, i64* %6
%32 = icmp ult i64 %30, %31
br i1 %32, label %33, label %56
33: ; preds = %29
%34 = load i64, i64* %6
%35 = load i64, i64* %10
%36 = sub i64 %34, %35
%37 = icmp ult i64 %36, 32
br i1 %37, label %38, label %42
38: ; preds = %33
%39 = load i64, i64* %6
%40 = load i64, i64* %10
%41 = sub i64 %39, %40
br label %43
42: ; preds = %33
br label %43
43: ; preds = %42, %38
%44 = phi i64 [ %41, %38 ], [ 32, %42 ]
store i64 %44, i64* %12
%45 = load i8*, i8** %8
%46 = load i32*, i32** %5
%47 = load i64, i64* %10
%48 = getelementptr inbounds i32, i32* %46, i64 %47
%49 = load i64, i64* %12
%50 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%51 = call i32 @hexlify(i32* %48, i64 %49, i8* %50, i32 256)
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %45, i32 %51)
br label %53
53: ; preds = %43
%54 = load i64, i64* %10
%55 = add i64 %54, 32
store i64 %55, i64* %10
br label %29
56: ; preds = %29
br label %74
57: ; preds = %25
%58 = load i8*, i8** %8
%59 = load i32*, i32** %5
%60 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%61 = call i32 @hexlify(i32* %59, i64 32, i8* %60, i32 256)
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %58, i32 %61)
%63 = load i8*, i8** %8
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %63)
%65 = load i64, i64* %6
%66 = sub i64 %65, 32
store i64 %66, i64* %10
%67 = load i8*, i8** %8
%68 = load i32*, i32** %5
%69 = load i64, i64* %10
%70 = getelementptr inbounds i32, i32* %68, i64 %69
%71 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%72 = call i32 @hexlify(i32* %70, i64 32, i8* %71, i32 256)
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %67, i32 %72)
br label %74
74: ; preds = %57, %56
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %76
76: ; preds = %74, %15, %4
ret void
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [6 x i8] c"%s%s\0A\00"
@.str.2 = [7 x i8] c"%s :\0A\00"
define void @display_binary_data(i32* %0, i64 %1, i32 %2, i8* %3) {
%5 = alloca [256 x i8]
%6 = icmp ne i32* %0, null
%7 = icmp ne i64 %1, 0
%8 = and i1 %6, %7
br i1 %8, label %9, label %36
9: ; preds = %4
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%11 = icmp eq i8* %3, null
%12 = select i1 %11, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* %3
%13 = icmp ne i32 %2, 0
%14 = icmp ult i64 %1, 97
%15 = or i1 %14, %13
br i1 %15, label %16, label %26
16: ; preds = %9, %16
%17 = phi i64 [ %24, %16 ], [ 0, %9 ]
%18 = sub i64 %1, %17
%19 = icmp ult i64 %18, 32
%20 = select i1 %19, i64 %18, i64 32
%21 = getelementptr inbounds i32, i32* %0, i64 %17
%22 = call i32 @hexlify(i32* %21, i64 %20, i8* %10, i32 256)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %12, i32 %22)
%24 = add i64 %17, 32
%25 = icmp ult i64 %24, %1
br i1 %25, label %16, label %34
26: ; preds = %9
%27 = call i32 @hexlify(i32* %0, i64 32, i8* %10, i32 256)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %12, i32 %27)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %12)
%30 = add i64 %1, -32
%31 = getelementptr inbounds i32, i32* %0, i64 %30
%32 = call i32 @hexlify(i32* %31, i64 32, i8* %10, i32 256)
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %12, i32 %32)
br label %34
34: ; preds = %16, %26
%35 = call i32 @putchar(i32 10)
br label %36
36: ; preds = %34, %4
ret void
}