#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*/ print_asc(unsigned char *, int);
int /*<<< orphan*/ printf(char *, ...);
void print_data(unsigned char *buf, int len) {
  int i = 0;
  if (len <= 0)
    return;
  printf("[%03X] ", i);
  for (i = 0; i < len;) {
    printf("%02X ", (int)buf[i]);
    i++;
    if (i % 8 == 0)
      printf(" ");
    if (i % 16 == 0) {
      print_asc(&buf[i - 16], 8);
      printf(" ");
      print_asc(&buf[i - 8], 8);
      printf("\n");
      if (i < len)
        printf("[%03X] ", i);
    }
  }
  if (i % 16) {
    int n;
    n = 16 - (i % 16);
    printf(" ");
    if (n > 8)
      printf(" ");
    while (n--)
      printf("   ");
    n = i % 16;
    if (n > 8)
      n = 8;
    print_asc(&buf[i - (i % 16)], n);
    printf(" ");
    n = (i % 16) - n;
    if (n > 0)
      print_asc(&buf[i - n], n);
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<print_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x0,-0xc(%rbp)
jg     1145 <print_data+0x25>
jmp    1346 <print_data+0x226>
mov    -0x10(%rbp),%esi
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1237 <print_data+0x117>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11ae <print_data+0x8e>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1232 <print_data+0x112>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%eax
sub    $0x10,%eax
cltq
add    %rax,%rdi
mov    $0x8,%esi
call   1030 <print_asc@plt>
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%eax
sub    $0x8,%eax
cltq
add    %rax,%rdi
mov    $0x8,%esi
call   1030 <print_asc@plt>
lea    0xe05(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    122d <print_data+0x10d>
mov    -0x10(%rbp),%esi
lea    0xdda(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1232 <print_data+0x112>
jmp    115d <print_data+0x3d>
mov    -0x10(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1346 <print_data+0x226>
mov    -0x10(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    $0x10,%eax
sub    %edx,%eax
mov    %eax,-0x14(%rbp)
lea    0xdab(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x8,-0x14(%rbp)
jle    1286 <print_data+0x166>
lea    0xd93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    128b <print_data+0x16b>
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
je     12b2 <print_data+0x192>
lea    0xd6a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    128b <print_data+0x16b>
mov    -0x10(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jle    12d1 <print_data+0x1b1>
movl   $0x8,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    -0x18(%rbp),%eax
sub    %edx,%eax
cltq
add    %rax,%rdi
mov    -0x14(%rbp),%esi
call   1030 <print_asc@plt>
lea    0xd13(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
sub    -0x14(%rbp),%edx
mov    %edx,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    1338 <print_data+0x218>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%eax
sub    -0x14(%rbp),%eax
cltq
add    %rax,%rdi
mov    -0x14(%rbp),%esi
call   1030 <print_asc@plt>
lea    0xccf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_data>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    12c9 <print_data+0x199>
mov    %esi,%r12d
mov    %rdi,%rbx
lea    0xeb0(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12d,%r15d
mov    %rbx,(%rsp)
add    $0xfffffffffffffff9,%rbx
mov    %r15,%r14
neg    %r14
mov    $0x1,%ebp
lea    0xe92(%rip),%r13
jmp    119a <print_data+0x6a>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
lea    (%r14,%rbp,1),%rax
add    $0x1,%rax
add    $0x1,%rbp
cmp    $0x1,%rax
je     121d <print_data+0xed>
movzbl 0x7(%rbx),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   $0x7,%bpl
je     11c0 <print_data+0x90>
test   $0xf,%bpl
jne    1180 <print_data+0x50>
jmp    11d0 <print_data+0xa0>
cs nopw 0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
test   $0xf,%bpl
jne    1180 <print_data+0x50>
lea    -0x8(%rbx),%rdi
mov    $0x8,%esi
call   1040 <print_asc@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
call   1040 <print_asc@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
cmp    %r15,%rbp
jae    1180 <print_data+0x50>
lea    0xdf1(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1180 <print_data+0x50>
mov    %r12d,%r14d
and    $0xf,%r14d
mov    (%rsp),%r15
je     12c9 <print_data+0x199>
mov    $0x20,%edi
call   1030 <putchar@plt>
cmp    $0x7,%r14d
ja     1248 <print_data+0x118>
mov    $0x20,%edi
call   1030 <putchar@plt>
lea    -0x10(%r14),%ebx
lea    0xdbb(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbp,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
inc    %ebx
jne    1260 <print_data+0x130>
cmp    $0x8,%r14d
mov    $0x8,%ebp
cmovb  %r14d,%ebp
mov    %r12d,%edi
and    $0x7ffffff0,%edi
add    %r15,%rdi
mov    %ebp,%esi
call   1040 <print_asc@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
sub    %ebp,%r14d
jle    12b1 <print_data+0x181>
sub    %r14d,%r12d
movslq %r12d,%rax
add    %rax,%r15
mov    %r15,%rdi
mov    %r14d,%esi
call   1040 <print_asc@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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