#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*/ hexdump_line(char const *, char const *, char const *);
int /*<<< orphan*/ printf(char *, ...);
void hexdump(const char *title, const void *data, size_t len) {
  const char *data_ptr = data;
  const char *data_start = data_ptr;
  const char *data_end = data_ptr + len;
  printf("%s = {\n", title);
  while (data_ptr < data_end) {
    data_ptr += hexdump_line(data_ptr, data_start, data_end);
  }
  printf("}\n");
}


x86 assembly (clang, -O0):
<hexdump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
add    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
cmp    -0x30(%rbp),%rax
jae    1196 <hexdump+0x76>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1030 <hexdump_line@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
jmp    1162 <hexdump+0x42>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hexdump>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rsi
lea    0xebb(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   %r15,%r15
jle    1178 <hexdump+0x48>
add    %r14,%r15
mov    %r14,%rbx
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1040 <hexdump_line@plt>
cltq
add    %rax,%rbx
cmp    %r15,%rbx
jb     1160 <hexdump+0x30>
lea    0xe89(%rip),%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"%s = {\0A\00"
@.str.1 = [3 x i8] c"}\0A\00"
define void @hexdump(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%10 = load i8*, i8** %5
store i8* %10, i8** %7
%11 = load i8*, i8** %7
store i8* %11, i8** %8
%12 = load i8*, i8** %7
%13 = load i64, i64* %6
%14 = getelementptr inbounds i8, i8* %12, i64 %13
store i8* %14, i8** %9
%15 = load i8*, i8** %4
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %15)
br label %17
17: ; preds = %21, %3
%18 = load i8*, i8** %7
%19 = load i8*, i8** %9
%20 = icmp ult i8* %18, %19
br i1 %20, label %21, label %29
21: ; preds = %17
%22 = load i8*, i8** %7
%23 = load i8*, i8** %8
%24 = load i8*, i8** %9
%25 = call i32 @hexdump_line(i8* %22, i8* %23, i8* %24)
%26 = load i8*, i8** %7
%27 = sext i32 %25 to i64
%28 = getelementptr inbounds i8, i8* %26, i64 %27
store i8* %28, i8** %7
br label %17
29: ; preds = %17
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"%s = {\0A\00"
@str = [2 x i8] c"}\00"
define void @hexdump(i8* %0, i8* %1, i64 %2) {
%4 = getelementptr inbounds i8, i8* %1, i64 %2
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = icmp sgt i64 %2, 0
br i1 %6, label %7, label %13
7: ; preds = %3, %7
%8 = phi i8* [ %11, %7 ], [ %1, %3 ]
%9 = tail call i32 @hexdump_line(i8* %8, i8* %1, i8* %4)
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %8, i64 %10
%12 = icmp ult i8* %11, %4
br i1 %12, label %7, label %13
13: ; preds = %7, %3
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret void
}