#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 u_int8_t;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
void hexdump(const char *prefix, const void *buf, int len) {
  int i, j;
  u_int8_t *p = (u_int8_t *)buf;
  for (i = 0; i < len; i += 16) {
    fprintf(stderr, "%s: 0x%04x:", prefix, i);
    for (j = 0; j < 16; j++)
      fprintf(stderr, j < len ? "%s%02X " : "%s   ", j % 4 ? "" : " ",
              p[i + j]);
    for (j = 0; j < 16 && j < len; j++)
      fprintf(stderr, "%c",
              p[i + j] > 0x1f && p[i + j] < 0x7f ? p[i + j] : '.');
    fputc('\n', stderr);
  }
  fputc('\n', stderr);
}


x86 assembly (clang, -O0):
<hexdump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12bb <hexdump+0x19b>
mov    0x2e8b(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x18(%rbp),%ecx
lea    0xe9b(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x10,-0x1c(%rbp)
jge    11e7 <hexdump+0xc7>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%ecx
mov    -0x14(%rbp),%edx
lea    0xe81(%rip),%rsi
lea    0xe72(%rip),%rax
cmp    %edx,%ecx
cmovl  %rax,%rsi
mov    -0x1c(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
lea    0xe64(%rip),%rdx
lea    0xe5e(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
mov    -0x28(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%ecx
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1173 <hexdump+0x53>
movl   $0x0,-0x1c(%rbp)
xor    %eax,%eax
cmpl   $0x10,-0x1c(%rbp)
mov    %al,-0x29(%rbp)
jge    1209 <hexdump+0xe9>
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
setl   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    1219 <hexdump+0xf9>
jmp    129a <hexdump+0x17a>
mov    0x2dc0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
cmpl   $0x1f,(%rax,%rcx,4)
jle    126b <hexdump+0x14b>
mov    -0x28(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
cmpl   $0x7f,(%rax,%rcx,4)
jge    126b <hexdump+0x14b>
mov    -0x28(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x34(%rbp)
jmp    1278 <hexdump+0x158>
mov    $0x2e,%eax
mov    %eax,-0x34(%rbp)
jmp    1278 <hexdump+0x158>
mov    -0x30(%rbp),%edi
mov    -0x34(%rbp),%edx
lea    0xd95(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ee <hexdump+0xce>
mov    0x2d3f(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1030 <fputc@plt>
mov    -0x18(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x18(%rbp)
jmp    1142 <hexdump+0x22>
mov    0x2d1e(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1030 <fputc@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hexdump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdi,0x18(%rsp)
mov    %rdx,(%rsp)
test   %edx,%edx
jle    1257 <hexdump+0x137>
mov    %rsi,%r13
mov    (%rsp),%rax
mov    %eax,%ecx
mov    %rcx,0x10(%rsp)
add    $0xffffffff,%eax
cmp    $0xf,%eax
mov    $0xf,%r15d
cmovb  %eax,%r15d
add    $0x1,%r15d
mov    0x2e78(%rip),%r14
xor    %ecx,%ecx
mov    %r15,0x8(%rsp)
nop
mov    (%r14),%edi
lea    0xe86(%rip),%rsi
mov    0x18(%rsp),%rdx
mov    %rcx,0x20(%rsp)
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %ebp,%ebp
mov    %r13,%rbx
mov    0x10(%rsp),%r15
mov    %r14,%r13
lea    0xe79(%rip),%r14
lea    0xe73(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
mov    0x0(%r13),%edi
cmp    %r15,%rbp
lea    0xe56(%rip),%rsi
lea    0xe47(%rip),%rax
cmovb  %rax,%rsi
test   $0x3,%bpl
mov    %r12,%rdx
cmove  %r14,%rdx
mov    (%rbx,%rbp,4),%ecx
xor    %eax,%eax
call   1040 <fprintf@plt>
add    $0x1,%rbp
cmp    $0x10,%rbp
jne    11b0 <hexdump+0x90>
xor    %ebp,%ebp
mov    0x8(%rsp),%r15
mov    %r13,%r14
lea    0xe21(%rip),%r12
mov    %rbx,%r13
mov    $0x2e,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r14),%edi
mov    0x0(%r13,%rbp,4),%edx
lea    -0x20(%rdx),%eax
cmp    $0x5f,%eax
cmovae %ebx,%edx
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1210 <hexdump+0xf0>
mov    (%r14),%esi
mov    $0xa,%edi
call   1030 <fputc@plt>
mov    0x20(%rsp),%rcx
add    $0x10,%rcx
add    $0x40,%r13
cmp    (%rsp),%ecx
jl     1170 <hexdump+0x50>
mov    0x2d82(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fputc@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [12 x i8] c"%s: 0x%04x:\00"
@.str.1 = [8 x i8] c"%s%02X \00"
@.str.2 = [6 x i8] c"%s \00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [2 x i8] c" \00"
@.str.5 = [3 x i8] c"%c\00"
define void @hexdump(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%10 = load i8*, i8** %5
%11 = bitcast i8* %10 to i32*
store i32* %11, i32** %9
store i32 0, i32* %7
br label %12
12: ; preds = %94, %3
%13 = load i32, i32* %7
%14 = load i32, i32* %6
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %97
16: ; preds = %12
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %4
%19 = load i32, i32* %7
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %18, i32 %19)
store i32 0, i32* %8
br label %21
21: ; preds = %44, %16
%22 = load i32, i32* %8
%23 = icmp slt i32 %22, 16
br i1 %23, label %24, label %47
24: ; preds = %21
%25 = load i32, i32* @stderr
%26 = load i32, i32* %8
%27 = load i32, i32* %6
%28 = icmp slt i32 %26, %27
%29 = zext i1 %28 to i64
%30 = select i1 %28, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0)
%31 = load i32, i32* %8
%32 = srem i32 %31, 4
%33 = icmp ne i32 %32, 0
%34 = zext i1 %33 to i64
%35 = select i1 %33, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0)
%36 = load i32*, i32** %9
%37 = load i32, i32* %7
%38 = load i32, i32* %8
%39 = add nsw i32 %37, %38
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i32, i32* %36, i64 %40
%42 = load i32, i32* %41
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* %30, i8* %35, i32 %42)
br label %44
44: ; preds = %24
%45 = load i32, i32* %8
%46 = add nsw i32 %45, 1
store i32 %46, i32* %8
br label %21
47: ; preds = %21
store i32 0, i32* %8
br label %48
48: ; preds = %88, %47
%49 = load i32, i32* %8
%50 = icmp slt i32 %49, 16
br i1 %50, label %51, label %55
51: ; preds = %48
%52 = load i32, i32* %8
%53 = load i32, i32* %6
%54 = icmp slt i32 %52, %53
br label %55
55: ; preds = %51, %48
%56 = phi i1 [ false, %48 ], [ %54, %51 ]
br i1 %56, label %57, label %91
57: ; preds = %55
%58 = load i32, i32* @stderr
%59 = load i32*, i32** %9
%60 = load i32, i32* %7
%61 = load i32, i32* %8
%62 = add nsw i32 %60, %61
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i32, i32* %59, i64 %63
%65 = load i32, i32* %64
%66 = icmp sgt i32 %65, 31
br i1 %66, label %67, label %84
67: ; preds = %57
%68 = load i32*, i32** %9
%69 = load i32, i32* %7
%70 = load i32, i32* %8
%71 = add nsw i32 %69, %70
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i32, i32* %68, i64 %72
%74 = load i32, i32* %73
%75 = icmp slt i32 %74, 127
br i1 %75, label %76, label %84
76: ; preds = %67
%77 = load i32*, i32** %9
%78 = load i32, i32* %7
%79 = load i32, i32* %8
%80 = add nsw i32 %78, %79
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds i32, i32* %77, i64 %81
%83 = load i32, i32* %82
br label %85
84: ; preds = %67, %57
br label %85
85: ; preds = %84, %76
%86 = phi i32 [ %83, %76 ], [ 46, %84 ]
%87 = call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %86)
br label %88
88: ; preds = %85
%89 = load i32, i32* %8
%90 = add nsw i32 %89, 1
store i32 %90, i32* %8
br label %48
91: ; preds = %55
%92 = load i32, i32* @stderr
%93 = call i32 @fputc(i8 signext 10, i32 %92)
br label %94
94: ; preds = %91
%95 = load i32, i32* %7
%96 = add nsw i32 %95, 16
store i32 %96, i32* %7
br label %12
97: ; preds = %12
%98 = load i32, i32* @stderr
%99 = call i32 @fputc(i8 signext 10, i32 %98)
ret void
}

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