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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ isprint(int const);
int /*<<< orphan*/ stderr;
void dump(const uint8_t *data, size_t len) {
  size_t i;
  size_t off = 0;
  while (off < len) {
    size_t n, pad = 0;
    if (len - off > 16)
      n = 16;
    else {
      n = len - off;
      pad = 16 - n;
    }
    fprintf(stderr, "%04X: ", (int)off);
    for (i = off; i < off + n; i++)
      fprintf(stderr, "%02X", data[i]);
    for (i = 0; i < pad; i++)
      fprintf(stderr, "  ");
    fprintf(stderr, "    ");
    for (i = off; i < off + n; i++)
      fprintf(stderr, "%c", isprint(data[i]) ? data[i] : '.');
    fprintf(stderr, "\r\n");
    off += n;
  }
}


x86 assembly (clang, -O0):
<dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    12f8 <dump+0x1d8>
movq   $0x0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
sub    -0x20(%rbp),%rax
cmp    $0x10,%rax
jbe    116d <dump+0x4d>
movq   $0x10,-0x28(%rbp)
jmp    1186 <dump+0x66>
mov    -0x10(%rbp),%rax
sub    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    $0x10,%eax
sub    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rax
mov    %eax,%edx
lea    0xe64(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
add    -0x28(%rbp),%rcx
cmp    %rcx,%rax
jae    11f3 <dump+0xd3>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe2c(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11ab <dump+0x8b>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x30(%rbp),%rax
jae    1231 <dump+0x111>
mov    0x2dd0(%rip),%rax
mov    (%rax),%edi
lea    0xdf5(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11fb <dump+0xdb>
mov    0x2da8(%rip),%rax
mov    (%rax),%edi
lea    0xdcb(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
add    -0x28(%rbp),%rcx
cmp    %rcx,%rax
jae    12d0 <dump+0x1b0>
mov    0x2d74(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1040 <isprint@plt>
cmp    $0x0,%rax
je     129e <dump+0x17e>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x38(%rbp)
jmp    12ab <dump+0x18b>
mov    $0x2e,%eax
mov    %eax,-0x38(%rbp)
jmp    12ab <dump+0x18b>
mov    -0x34(%rbp),%edi
mov    -0x38(%rbp),%edx
lea    0xd59(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1250 <dump+0x130>
mov    0x2d09(%rip),%rax
mov    (%rax),%edi
lea    0xd34(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x28(%rbp),%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    1138 <dump+0x18>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdi,(%rsp)
test   %rsi,%rsi
je     12ba <dump+0x19a>
mov    0x2e9e(%rip),%r12
lea    0xebe(%rip),%r13
xor    %ebp,%ebp
mov    %rsi,0x18(%rsp)
jmp    1188 <dump+0x68>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r12),%edi
lea    0xea9(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x10(%rsp),%rax
mov    %rax,%rbp
mov    0x18(%rsp),%rsi
cmp    %rsi,%rax
jae    12ba <dump+0x19a>
sub    %rbp,%rsi
cmp    $0x10,%rsi
mov    $0x10,%r14d
cmovb  %rsi,%r14
mov    $0x10,%eax
mov    %rsi,0x20(%rsp)
sub    %rsi,%rax
mov    $0x0,%ebx
cmovae %rax,%rbx
mov    (%r12),%edi
lea    0xe46(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    (%r14,%rbp,1),%rax
mov    %rax,0x10(%rsp)
mov    %rbp,0x8(%rsp)
cmp    %rax,%rbp
mov    %r13,%rbp
jae    120c <dump+0xec>
mov    (%rsp),%rax
mov    0x8(%rsp),%rcx
lea    (%rax,%rcx,4),%r13
xor    %r15d,%r15d
nopl   0x0(%rax)
mov    (%r12),%edi
mov    0x0(%r13,%r15,4),%edx
mov    %rbp,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0x1,%r15
cmp    %r15,%r14
jne    11f0 <dump+0xd0>
mov    %rbp,%r13
cmpq   $0xf,0x20(%rsp)
lea    0xdf2(%rip),%rbp
ja     1243 <dump+0x123>
cmp    $0x2,%rbx
mov    $0x1,%eax
cmovb  %rax,%rbx
neg    %rbx
xchg   %ax,%ax
mov    (%r12),%edi
mov    %rbp,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
inc    %rbx
jne    1230 <dump+0x110>
mov    (%r12),%edi
lea    0xdbe(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x8(%rsp),%rcx
cmp    0x10(%rsp),%rcx
jae    1160 <dump+0x40>
mov    (%rsp),%rax
lea    (%rax,%rcx,4),%r15
xor    %ebp,%ebp
jmp    12a1 <dump+0x181>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r15,%rbp,4),%edx
mov    %ebx,%edi
lea    0xd84(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0x1,%rbp
cmp    %rbp,%r14
je     1160 <dump+0x40>
mov    (%r12),%ebx
mov    (%r15,%rbp,4),%edi
call   1040 <isprint@plt>
test   %rax,%rax
jne    1280 <dump+0x160>
mov    $0x2e,%edx
jmp    1284 <dump+0x164>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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