#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void dumpdata(FILE *stream, const char *leader, unsigned int depth,
              const unsigned char *data, size_t len) {
  const unsigned char *dataend = data + len;
  const unsigned char *p;
  const size_t rowsize = 16;
  for (p = data; p < dataend; p += rowsize) {
    size_t amt = rowsize;
    size_t i;
    if (amt > (dataend - p))
      amt = (dataend - p);
    fprintf(stream, "%s%*s  ", leader, 2 * depth, "");
    for (i = 0; i < amt; ++i) {
      fprintf(stream, "%02x", p[i]);
    }
    for (; i < rowsize; ++i) {
      fprintf(stream, "  ");
    }
    fprintf(stream, "  ");
    for (i = 0; i < amt; ++i) {
      if (p[i] >= ' ' && p[i] <= '~') {
        fprintf(stream, "%c", p[i]);
      } else {
        fprintf(stream, ".");
      }
    }
    fprintf(stream, "\n");
  }
  fflush(stream);
}


x86 assembly (clang, -O0):
<dumpdata>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x20(%rbp),%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
movq   $0x10,-0x40(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x30(%rbp),%rax
jae    12ef <dumpdata+0x1cf>
movq   $0x10,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%rdx
sub    %rdx,%rcx
cmp    %rcx,%rax
jbe    1194 <dumpdata+0x74>
mov    -0x30(%rbp),%rax
mov    -0x38(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
shl    $0x1,%ecx
lea    0xe57(%rip),%rsi
lea    0xe63(%rip),%r8
mov    $0x0,%al
call   1030 <fprintf@plt>
movq   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%rax
cmp    -0x48(%rbp),%rax
jae    11fc <dumpdata+0xdc>
mov    -0x8(%rbp),%rdi
mov    -0x38(%rbp),%rax
mov    -0x50(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
lea    0xe24(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
jmp    11bf <dumpdata+0x9f>
jmp    1201 <dumpdata+0xe1>
cmpq   $0x10,-0x50(%rbp)
jae    122f <dumpdata+0x10f>
mov    -0x8(%rbp),%rdi
lea    0xdee(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
jmp    1201 <dumpdata+0xe1>
mov    -0x8(%rbp),%rdi
lea    0xdcb(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movq   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%rax
cmp    -0x48(%rbp),%rax
jae    12cc <dumpdata+0x1ac>
mov    -0x38(%rbp),%rax
mov    -0x50(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jl     12a4 <dumpdata+0x184>
mov    -0x38(%rbp),%rax
mov    -0x50(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x7e,%eax
jg     12a4 <dumpdata+0x184>
mov    -0x8(%rbp),%rdi
mov    -0x38(%rbp),%rax
mov    -0x50(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
lea    0xd75(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    12b6 <dumpdata+0x196>
mov    -0x8(%rbp),%rdi
lea    0xd61(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    12bb <dumpdata+0x19b>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
jmp    1249 <dumpdata+0x129>
mov    -0x8(%rbp),%rdi
lea    0xd3b(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x38(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x38(%rbp)
jmp    1157 <dumpdata+0x37>
mov    -0x8(%rbp),%rdi
call   1040 <fflush@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dumpdata>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %edx,0xc(%rsp)
mov    %rsi,0x20(%rsp)
mov    %rdi,%rbp
test   %r8,%r8
jle    12b8 <dumpdata+0x178>
mov    %r8,%rbx
mov    %rcx,%r12
lea    (%rcx,%r8,1),%r14
mov    0xc(%rsp),%eax
add    %eax,%eax
mov    %eax,0xc(%rsp)
lea    0xe8a(%rip),%r13
mov    %r14,0x18(%rsp)
jmp    11bd <dumpdata+0x7d>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0xa,%edi
mov    %rbp,%rsi
call   1030 <fputc@plt>
add    $0x10,%r12
mov    0x10(%rsp),%rbx
add    $0xfffffffffffffff0,%rbx
mov    %r13,%r14
cmp    %r13,%r12
lea    0xe51(%rip),%r13
jae    12b8 <dumpdata+0x178>
cmp    $0x10,%rbx
mov    $0x10,%r15d
cmovb  %rbx,%r15
mov    %rbp,%rdi
lea    0xe2b(%rip),%rsi
mov    0x20(%rsp),%rdx
mov    0xc(%rsp),%ecx
lea    0xe22(%rip),%r8
xor    %eax,%eax
call   1040 <fprintf@plt>
cmp    %r12,%r14
mov    %rbx,0x10(%rsp)
je     1230 <dumpdata+0xf0>
mov    %r15,%r14
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movzbl (%r12,%rbx,1),%edx
mov    %rbp,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1200 <dumpdata+0xc0>
cmpq   $0xf,0x10(%rsp)
lea    0xddd(%rip),%rbx
jbe    123a <dumpdata+0xfa>
jmp    125a <dumpdata+0x11a>
nopl   0x0(%rax)
xor    %r14d,%r14d
lea    0xdcb(%rip),%rbx
add    $0xfffffffffffffff0,%r14
xchg   %ax,%ax
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rbx,%rdi
mov    %rbp,%rcx
call   1060 <fwrite@plt>
inc    %r14
jne    1240 <dumpdata+0x100>
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rbx,%rdi
mov    %rbp,%rcx
call   1060 <fwrite@plt>
mov    0x18(%rsp),%rax
mov    %rax,%r13
cmp    %r12,%rax
mov    $0x2e,%r14d
je     1190 <dumpdata+0x50>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movzbl (%r12,%rbx,1),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%cl
cmovae %r14d,%eax
movzbl %al,%edi
mov    %rbp,%rsi
call   1030 <fputc@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1290 <dumpdata+0x150>
jmp    1190 <dumpdata+0x50>
mov    %rbp,%rdi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fflush@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"%s%*s \00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [5 x i8] c"%02x\00"
@.str.3 = [3 x i8] c" \00"
@.str.4 = [3 x i8] c"%c\00"
@.str.5 = [2 x i8] c".\00"
@.str.6 = [2 x i8] c"\0A\00"
define void @dumpdata(i32* %0, i8* %1, i32 %2, i8* %3, i64 %4) {
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i64
%14 = alloca i64
%15 = alloca i64
store i32* %0, i32** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i8* %3, i8** %9
store i64 %4, i64* %10
%16 = load i8*, i8** %9
%17 = load i64, i64* %10
%18 = getelementptr inbounds i8, i8* %16, i64 %17
store i8* %18, i8** %11
store i64 16, i64* %13
%19 = load i8*, i8** %9
store i8* %19, i8** %12
br label %20
20: ; preds = %108, %5
%21 = load i8*, i8** %12
%22 = load i8*, i8** %11
%23 = icmp ult i8* %21, %22
br i1 %23, label %24, label %111
24: ; preds = %20
store i64 16, i64* %14
%25 = load i64, i64* %14
%26 = load i8*, i8** %11
%27 = load i8*, i8** %12
%28 = ptrtoint i8* %26 to i64
%29 = ptrtoint i8* %27 to i64
%30 = sub i64 %28, %29
%31 = icmp ugt i64 %25, %30
br i1 %31, label %32, label %38
32: ; preds = %24
%33 = load i8*, i8** %11
%34 = load i8*, i8** %12
%35 = ptrtoint i8* %33 to i64
%36 = ptrtoint i8* %34 to i64
%37 = sub i64 %35, %36
store i64 %37, i64* %14
br label %38
38: ; preds = %32, %24
%39 = load i32*, i32** %6
%40 = load i8*, i8** %7
%41 = load i32, i32* %8
%42 = mul i32 2, %41
%43 = call i32 (i32*, i8*, ...) @fprintf(i32* %39, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %40, i32 %42, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
store i64 0, i64* %15
br label %44
44: ; preds = %56, %38
%45 = load i64, i64* %15
%46 = load i64, i64* %14
%47 = icmp ult i64 %45, %46
br i1 %47, label %48, label %59
48: ; preds = %44
%49 = load i32*, i32** %6
%50 = load i8*, i8** %12
%51 = load i64, i64* %15
%52 = getelementptr inbounds i8, i8* %50, i64 %51
%53 = load i8, i8* %52
%54 = zext i8 %53 to i32
%55 = call i32 (i32*, i8*, ...) @fprintf(i32* %49, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %54)
br label %56
56: ; preds = %48
%57 = load i64, i64* %15
%58 = add i64 %57, 1
store i64 %58, i64* %15
br label %44
59: ; preds = %44
br label %60
60: ; preds = %66, %59
%61 = load i64, i64* %15
%62 = icmp ult i64 %61, 16
br i1 %62, label %63, label %69
63: ; preds = %60
%64 = load i32*, i32** %6
%65 = call i32 (i32*, i8*, ...) @fprintf(i32* %64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %66
66: ; preds = %63
%67 = load i64, i64* %15
%68 = add i64 %67, 1
store i64 %68, i64* %15
br label %60
69: ; preds = %60
%70 = load i32*, i32** %6
%71 = call i32 (i32*, i8*, ...) @fprintf(i32* %70, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i64 0, i64* %15
br label %72
72: ; preds = %102, %69
%73 = load i64, i64* %15
%74 = load i64, i64* %14
%75 = icmp ult i64 %73, %74
br i1 %75, label %76, label %105
76: ; preds = %72
%77 = load i8*, i8** %12
%78 = load i64, i64* %15
%79 = getelementptr inbounds i8, i8* %77, i64 %78
%80 = load i8, i8* %79
%81 = zext i8 %80 to i32
%82 = icmp sge i32 %81, 32
br i1 %82, label %83, label %98
83: ; preds = %76
%84 = load i8*, i8** %12
%85 = load i64, i64* %15
%86 = getelementptr inbounds i8, i8* %84, i64 %85
%87 = load i8, i8* %86
%88 = zext i8 %87 to i32
%89 = icmp sle i32 %88, 126
br i1 %89, label %90, label %98
90: ; preds = %83
%91 = load i32*, i32** %6
%92 = load i8*, i8** %12
%93 = load i64, i64* %15
%94 = getelementptr inbounds i8, i8* %92, i64 %93
%95 = load i8, i8* %94
%96 = zext i8 %95 to i32
%97 = call i32 (i32*, i8*, ...) @fprintf(i32* %91, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %96)
br label %101
98: ; preds = %83, %76
%99 = load i32*, i32** %6
%100 = call i32 (i32*, i8*, ...) @fprintf(i32* %99, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %101
101: ; preds = %98, %90
br label %102
102: ; preds = %101
%103 = load i64, i64* %15
%104 = add i64 %103, 1
store i64 %104, i64* %15
br label %72
105: ; preds = %72
%106 = load i32*, i32** %6
%107 = call i32 (i32*, i8*, ...) @fprintf(i32* %106, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %108
108: ; preds = %105
%109 = load i8*, i8** %12
%110 = getelementptr inbounds i8, i8* %109, i64 16
store i8* %110, i8** %12
br label %20
111: ; preds = %20
%112 = load i32*, i32** %6
%113 = call i32 @fflush(i32* %112)
ret void
}

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