#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*/ assert(int);
int /*<<< orphan*/ bytes_to_hex(void const *, size_t, char **);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, size_t const);
int /*<<< orphan*/ printf(char *, char const *, char *);
void hexdump(const char *prefix, const size_t column_len, const void *value,
             size_t len) {
  assert(prefix != NULL);
  assert(column_len > 0);
  int row_count = (len / column_len) + 1;
  int i;
  size_t slen = column_len * 3;
  char s[slen];
  for (i = 0; i < row_count; ++i) {
    memset(s, 0, column_len * 3);
    bytes_to_hex(value, len, (char **)&s);
    printf("%s %s\n", prefix, s);
  }
}


x86 assembly (clang, -O0):
<hexdump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
test   %rax,%rax
setne  %al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rax
test   %rax,%rax
setne  %al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
xor    %edx,%edx
div    %rcx
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
lea    (%rax,%rax,2),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rsp,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1218 <hexdump+0xd8>
mov    -0x48(%rbp),%rdi
imul   $0x3,-0x10(%rbp),%rdx
xor    %esi,%esi
call   1040 <memset@plt>
mov    -0x48(%rbp),%rdx
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <bytes_to_hex@plt>
mov    -0x48(%rbp),%rdx
mov    -0x8(%rbp),%rsi
lea    0xdfb(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11c9 <hexdump+0x89>
mov    -0x38(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hexdump>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%rbx
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%r15
xor    %edi,%edi
test   %r15,%r15
setne  %dil
call   1050 <assert@plt>
xor    %edi,%edi
test   %r12,%r12
setne  %dil
call   1050 <assert@plt>
mov    %rbx,%rax
or     %r12,%rax
mov    %rbx,%rcx
shr    $0x20,%rax
je     1192 <hexdump+0x52>
mov    %rbx,%rax
xor    %edx,%edx
div    %r12
jmp    1199 <hexdump+0x59>
mov    %ebx,%eax
xor    %edx,%edx
div    %r12d
mov    %r14,-0x30(%rbp)
mov    %rcx,-0x38(%rbp)
mov    %rsp,%rbx
lea    (%r12,%r12,2),%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%rbx
mov    %rbx,%rsp
cmp    $0x7ffffffe,%eax
ja     1218 <hexdump+0xd8>
mov    %r15,%r14
lea    (%r12,%r12,2),%r12
add    $0x1,%eax
cmp    $0x2,%eax
mov    $0x1,%r15d
cmovge %eax,%r15d
xor    %r13d,%r13d
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
xor    %esi,%esi
mov    %r12,%rdx
call   1040 <memset@plt>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    %rbx,%rdx
call   1060 <bytes_to_hex@plt>
lea    0xdfc(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1030 <printf@plt>
add    $0x1,%r13d
cmp    %r15d,%r13d
jne    11e0 <hexdump+0xa0>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%s %s\0A\00"
define void @hexdump(i8* %0, i64 %1, i8* %2, i64 %3) {
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
%11 = alloca i64
%12 = alloca i8*
%13 = alloca i64
store i8* %0, i8** %5
store i64 %1, i64* %6
store i8* %2, i8** %7
store i64 %3, i64* %8
%14 = load i8*, i8** %5
%15 = icmp ne i8* %14, null
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = load i64, i64* %6
%19 = icmp ugt i64 %18, 0
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = load i64, i64* %8
%23 = load i64, i64* %6
%24 = udiv i64 %22, %23
%25 = add i64 %24, 1
%26 = trunc i64 %25 to i32
store i32 %26, i32* %9
%27 = load i64, i64* %6
%28 = mul i64 %27, 3
store i64 %28, i64* %11
%29 = load i64, i64* %11
%30 = call i8* @llvm.stacksave()
store i8* %30, i8** %12
%31 = alloca i8, i64 %29
store i64 %29, i64* %13
store i32 0, i32* %10
br label %32
32: ; preds = %46, %4
%33 = load i32, i32* %10
%34 = load i32, i32* %9
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %49
36: ; preds = %32
%37 = load i64, i64* %6
%38 = mul i64 %37, 3
%39 = call i32 @memset(i8* %31, i32 0, i64 %38)
%40 = load i8*, i8** %7
%41 = load i64, i64* %8
%42 = bitcast i8* %31 to i8**
%43 = call i32 @bytes_to_hex(i8* %40, i64 %41, i8** %42)
%44 = load i8*, i8** %5
%45 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %44, i8* %31)
br label %46
46: ; preds = %36
%47 = load i32, i32* %10
%48 = add nsw i32 %47, 1
store i32 %48, i32* %10
br label %32
49: ; preds = %32
%50 = load i8*, i8** %12
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"%s %s\0A\00"
define void @hexdump(i8* %0, i64 %1, i8* %2, i64 %3) {
%5 = icmp ne i8* %0, null
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = icmp ne i64 %1, 0
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = udiv i64 %3, %1
%12 = trunc i64 %11 to i32
%13 = mul i64 %1, 3
%14 = alloca i8, i64 %13
%15 = icmp ult i32 %12, 2147483647
br i1 %15, label %16, label %27
16: ; preds = %4
%17 = add i32 %12, 1
%18 = bitcast i8* %14 to i8**
%19 = call i32 @llvm.smax.i32(i32 %17, i32 1)
br label %20
20: ; preds = %16, %20
%21 = phi i32 [ 0, %16 ], [ %25, %20 ]
%22 = call i32 @memset(i8* %14, i32 0, i64 %13)
%23 = call i32 @bytes_to_hex(i8* %2, i64 %3, i8** %18)
%24 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %14)
%25 = add nuw nsw i32 %21, 1
%26 = icmp eq i32 %25, %19
br i1 %26, label %27, label %20
27: ; preds = %20, %4
ret void
}