#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*/ fprintf(int /*<<< orphan*/ *, char *, ...);
scalar_t__ isprint(unsigned char);
int /*<<< orphan*/ memcpy(unsigned char *, void *, int);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
void dump_data(FILE *out, void *data, size_t offset, size_t size) {
  unsigned char buf[16];
  int i, j;
  for (i = 0; i < size; i += 16) {
    memset(buf, 0, sizeof buf);
    memcpy(buf, data + offset + i, (size - i >= 16) ? 16 : (size - i));
    fprintf(out, "0x%04x:", offset + i);
    for (j = 0; j < 16; j++) {
      if (j == 8)
        fprintf(out, " ");
      if (i + j >= size)
        fprintf(out, "   ");
      else
        fprintf(out, " %02x", buf[j]);
    }
    fprintf(out, " ");
    for (j = 0; j < 16; j++) {
      if (i + j >= size)
        break;
      if (j == 8)
        fprintf(out, " ");
      if (isprint(buf[j]))
        fprintf(out, "%c", buf[j]);
      else
        fprintf(out, ".");
    }
    fprintf(out, "\n");
  }
  return;
}


x86 assembly (clang, -O0):
<dump_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x34(%rbp)
movslq -0x34(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    1351 <dump_data+0x211>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1030 <memset@plt>
lea    -0x30(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
add    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
sub    %rcx,%rax
cmp    $0x10,%rax
jb     11bb <dump_data+0x7b>
mov    $0x10,%eax
mov    %rax,-0x50(%rbp)
jmp    11ca <dump_data+0x8a>
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x50(%rbp)
mov    -0x40(%rbp),%rsi
mov    -0x48(%rbp),%rdi
mov    -0x50(%rbp),%rax
mov    %eax,%edx
call   1050 <memcpy@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
movslq -0x34(%rbp),%rax
add    %rax,%rdx
lea    0xe0d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x38(%rbp)
cmpl   $0x10,-0x38(%rbp)
jge    127e <dump_data+0x13e>
cmpl   $0x8,-0x38(%rbp)
jne    1227 <dump_data+0xe7>
mov    -0x8(%rbp),%rdi
lea    0xdea(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x34(%rbp),%eax
add    -0x38(%rbp),%eax
cltq
cmp    -0x20(%rbp),%rax
jb     1250 <dump_data+0x110>
mov    -0x8(%rbp),%rdi
lea    0xdc4(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    126b <dump_data+0x12b>
mov    -0x8(%rbp),%rdi
movslq -0x38(%rbp),%rax
movzbl -0x30(%rbp,%rax,1),%edx
lea    0xda8(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1270 <dump_data+0x130>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1201 <dump_data+0xc1>
mov    -0x8(%rbp),%rdi
lea    0xd81(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x38(%rbp)
cmpl   $0x10,-0x38(%rbp)
jge    1331 <dump_data+0x1f1>
mov    -0x34(%rbp),%eax
add    -0x38(%rbp),%eax
cltq
cmp    -0x20(%rbp),%rax
jb     12b8 <dump_data+0x178>
jmp    1331 <dump_data+0x1f1>
cmpl   $0x8,-0x38(%rbp)
jne    12d4 <dump_data+0x194>
mov    -0x8(%rbp),%rdi
lea    0xd3d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movslq -0x38(%rbp),%rax
movzbl -0x30(%rbp,%rax,1),%edi
call   1060 <isprint@plt>
cmp    $0x0,%rax
je     130c <dump_data+0x1cc>
mov    -0x8(%rbp),%rdi
movslq -0x38(%rbp),%rax
movzbl -0x30(%rbp,%rax,1),%edx
lea    0xd12(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    131e <dump_data+0x1de>
mov    -0x8(%rbp),%rdi
lea    0xcfe(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1323 <dump_data+0x1e3>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1297 <dump_data+0x157>
mov    -0x8(%rbp),%rdi
lea    0xcdb(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x34(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x34(%rbp)
jmp    115f <dump_data+0x1f>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_data>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,0x8(%rsp)
mov    %rsi,(%rsp)
test   %rcx,%rcx
je     12fb <dump_data+0x19b>
mov    %rcx,%r12
mov    %rdi,%rbx
mov    (%rsp),%rax
add    0x8(%rsp),%rax
mov    %rax,(%rsp)
mov    $0x1,%r13d
lea    0xe68(%rip),%r14
xor    %r15d,%r15d
jmp    11ce <dump_data+0x6e>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0xa,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
add    $0x10,%r15
add    $0x10,%r13
cmp    %r12,%r15
jae    12fb <dump_data+0x19b>
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1030 <memset@plt>
mov    (%rsp),%rax
lea    (%rax,%r15,1),%rsi
mov    %r12,%rdx
sub    %r15,%rdx
cmp    $0x10,%rdx
mov    $0x10,%eax
cmovae %eax,%edx
mov    %rbp,%rdi
call   1060 <memcpy@plt>
mov    0x8(%rsp),%rax
lea    (%r15,%rax,1),%rdx
mov    %rbx,%rdi
lea    0xde9(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
xor    %ebp,%ebp
jmp    1250 <dump_data+0xf0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl 0x10(%rsp,%rbp,1),%edx
mov    %rbx,%rdi
lea    0xdcd(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
add    $0x1,%rbp
cmp    $0x10,%rbp
je     1290 <dump_data+0x130>
cmp    $0x8,%rbp
jne    1263 <dump_data+0x103>
mov    $0x20,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
lea    (%r15,%rbp,1),%rax
cmp    %r12,%rax
jb     1230 <dump_data+0xd0>
mov    $0x3,%esi
mov    $0x1,%edx
mov    %r14,%rdi
mov    %rbx,%rcx
call   1080 <fwrite@plt>
jmp    1246 <dump_data+0xe6>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x20,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
xor    %ebp,%ebp
nop
cmp    $0x8,%rbp
jne    12b3 <dump_data+0x153>
mov    $0x20,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
movzbl 0x10(%rsp,%rbp,1),%edi
call   1070 <isprint@plt>
test   %rax,%rax
je     12d0 <dump_data+0x170>
movzbl 0x10(%rsp,%rbp,1),%edi
jmp    12d5 <dump_data+0x175>
nopl   0x0(%rax)
mov    $0x2e,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
cmp    $0xe,%rbp
ja     11b0 <dump_data+0x50>
mov    %r13,%rax
add    %rbp,%rax
add    $0x1,%rbp
cmp    %r12,%rax
jb     12a0 <dump_data+0x140>
jmp    11b0 <dump_data+0x50>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"0x%04x:\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [4 x i8] c" \00"
@.str.3 = [6 x i8] c" %02x\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 @dump_data(i32* %0, i8* %1, i64 %2, i64 %3) {
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
%9 = alloca [16 x i8]
%10 = alloca i32
%11 = alloca i32
store i32* %0, i32** %5
store i8* %1, i8** %6
store i64 %2, i64* %7
store i64 %3, i64* %8
store i32 0, i32* %10
br label %12
12: ; preds = %124, %4
%13 = load i32, i32* %10
%14 = sext i32 %13 to i64
%15 = load i64, i64* %8
%16 = icmp ult i64 %14, %15
br i1 %16, label %17, label %127
17: ; preds = %12
%18 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%19 = call i32 @memset(i8* %18, i32 0, i32 16)
%20 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%21 = load i8*, i8** %6
%22 = load i64, i64* %7
%23 = getelementptr i8, i8* %21, i64 %22
%24 = load i32, i32* %10
%25 = sext i32 %24 to i64
%26 = getelementptr i8, i8* %23, i64 %25
%27 = load i64, i64* %8
%28 = load i32, i32* %10
%29 = sext i32 %28 to i64
%30 = sub i64 %27, %29
%31 = icmp uge i64 %30, 16
br i1 %31, label %32, label %33
32: ; preds = %17
br label %38
33: ; preds = %17
%34 = load i64, i64* %8
%35 = load i32, i32* %10
%36 = sext i32 %35 to i64
%37 = sub i64 %34, %36
br label %38
38: ; preds = %33, %32
%39 = phi i64 [ 16, %32 ], [ %37, %33 ]
%40 = trunc i64 %39 to i32
%41 = call i32 @memcpy(i8* %20, i8* %26, i32 %40)
%42 = load i32*, i32** %5
%43 = load i64, i64* %7
%44 = load i32, i32* %10
%45 = sext i32 %44 to i64
%46 = add i64 %43, %45
%47 = call i32 (i32*, i8*, ...) @fprintf(i32* %42, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 %46)
store i32 0, i32* %11
br label %48
48: ; preds = %76, %38
%49 = load i32, i32* %11
%50 = icmp slt i32 %49, 16
br i1 %50, label %51, label %79
51: ; preds = %48
%52 = load i32, i32* %11
%53 = icmp eq i32 %52, 8
br i1 %53, label %54, label %57
54: ; preds = %51
%55 = load i32*, i32** %5
%56 = call i32 (i32*, i8*, ...) @fprintf(i32* %55, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %57
57: ; preds = %54, %51
%58 = load i32, i32* %10
%59 = load i32, i32* %11
%60 = add nsw i32 %58, %59
%61 = sext i32 %60 to i64
%62 = load i64, i64* %8
%63 = icmp uge i64 %61, %62
br i1 %63, label %64, label %67
64: ; preds = %57
%65 = load i32*, i32** %5
%66 = call i32 (i32*, i8*, ...) @fprintf(i32* %65, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %75
67: ; preds = %57
%68 = load i32*, i32** %5
%69 = load i32, i32* %11
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 %70
%72 = load i8, i8* %71
%73 = zext i8 %72 to i32
%74 = call i32 (i32*, i8*, ...) @fprintf(i32* %68, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %73)
br label %75
75: ; preds = %67, %64
br label %76
76: ; preds = %75
%77 = load i32, i32* %11
%78 = add nsw i32 %77, 1
store i32 %78, i32* %11
br label %48
79: ; preds = %48
%80 = load i32*, i32** %5
%81 = call i32 (i32*, i8*, ...) @fprintf(i32* %80, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %11
br label %82
82: ; preds = %118, %79
%83 = load i32, i32* %11
%84 = icmp slt i32 %83, 16
br i1 %84, label %85, label %121
85: ; preds = %82
%86 = load i32, i32* %10
%87 = load i32, i32* %11
%88 = add nsw i32 %86, %87
%89 = sext i32 %88 to i64
%90 = load i64, i64* %8
%91 = icmp uge i64 %89, %90
br i1 %91, label %92, label %93
92: ; preds = %85
br label %121
93: ; preds = %85
%94 = load i32, i32* %11
%95 = icmp eq i32 %94, 8
br i1 %95, label %96, label %99
96: ; preds = %93
%97 = load i32*, i32** %5
%98 = call i32 (i32*, i8*, ...) @fprintf(i32* %97, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %99
99: ; preds = %96, %93
%100 = load i32, i32* %11
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 %101
%103 = load i8, i8* %102
%104 = call i64 @isprint(i8 zeroext %103)
%105 = icmp ne i64 %104, 0
br i1 %105, label %106, label %114
106: ; preds = %99
%107 = load i32*, i32** %5
%108 = load i32, i32* %11
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 %109
%111 = load i8, i8* %110
%112 = zext i8 %111 to i32
%113 = call i32 (i32*, i8*, ...) @fprintf(i32* %107, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %112)
br label %117
114: ; preds = %99
%115 = load i32*, i32** %5
%116 = call i32 (i32*, i8*, ...) @fprintf(i32* %115, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %117
117: ; preds = %114, %106
br label %118
118: ; preds = %117
%119 = load i32, i32* %11
%120 = add nsw i32 %119, 1
store i32 %120, i32* %11
br label %82
121: ; preds = %92, %82
%122 = load i32*, i32** %5
%123 = call i32 (i32*, i8*, ...) @fprintf(i32* %122, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %124
124: ; preds = %121
%125 = load i32, i32* %10
%126 = add nsw i32 %125, 16
store i32 %126, i32* %10
br label %12
127: ; preds = %12
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"0x%04x:\00"
@.str.2 = [4 x i8] c" \00"
@.str.3 = [6 x i8] c" %02x\00"
define void @dump_data(i32* nocapture %0, i8* %1, i64 %2, i64 %3) {
%5 = alloca [16 x i8]
%6 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%7 = icmp eq i64 %3, 0
br i1 %7, label %66, label %8
8: ; preds = %4
%9 = getelementptr i8, i8* %1, i64 %2
br label %10
10: ; preds = %8, %62
%11 = phi i64 [ 0, %8 ], [ %64, %62 ]
%12 = call i32 @memset(i8* %6, i32 0, i32 16)
%13 = getelementptr i8, i8* %9, i64 %11
%14 = sub i64 %3, %11
%15 = icmp ult i64 %14, 16
%16 = select i1 %15, i64 %14, i64 16
%17 = trunc i64 %16 to i32
%18 = call i32 @memcpy(i8* %6, i8* %13, i32 %17)
%19 = add i64 %11, %2
%20 = call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 %19)
br label %21
21: ; preds = %10, %36
%22 = phi i64 [ 0, %10 ], [ %37, %36 ]
%23 = icmp eq i64 %22, 8
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 @fputc(i32 32, i32* %0)
br label %26
26: ; preds = %24, %21
%27 = add nuw nsw i64 %22, %11
%28 = icmp ult i64 %27, %3
br i1 %28, label %31, label %29
29: ; preds = %26
%30 = call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64 3, i64 1, i32* %0)
br label %36
31: ; preds = %26
%32 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 %22
%33 = load i8, i8* %32
%34 = zext i8 %33 to i32
%35 = call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %29, %31
%37 = add nuw nsw i64 %22, 1
%38 = icmp eq i64 %37, 16
br i1 %38, label %39, label %21
39: ; preds = %36
%40 = call i32 @fputc(i32 32, i32* %0)
br label %41
41: ; preds = %39, %54
%42 = phi i64 [ 0, %39 ], [ %57, %54 ]
%43 = icmp eq i64 %42, 8
br i1 %43, label %44, label %46
44: ; preds = %41
%45 = call i32 @fputc(i32 32, i32* %0)
br label %46
46: ; preds = %44, %41
%47 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 %42
%48 = load i8, i8* %47
%49 = call i64 @isprint(i8 zeroext %48)
%50 = icmp eq i64 %49, 0
br i1 %50, label %54, label %51
51: ; preds = %46
%52 = load i8, i8* %47
%53 = zext i8 %52 to i32
br label %54
54: ; preds = %46, %51
%55 = phi i32 [ %53, %51 ], [ 46, %46 ]
%56 = call i32 @fputc(i32 %55, i32* %0)
%57 = add nuw nsw i64 %42, 1
%58 = icmp ult i64 %42, 15
%59 = add nuw nsw i64 %57, %11
%60 = icmp ult i64 %59, %3
%61 = select i1 %58, i1 %60, i1 false
br i1 %61, label %41, label %62
62: ; preds = %54
%63 = call i32 @fputc(i32 10, i32* %0)
%64 = add nuw i64 %11, 16
%65 = icmp ult i64 %64, %3
br i1 %65, label %10, label %66
66: ; preds = %62, %4
ret void
}