#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*/ printf(char *, ...);
void print_raw_data(char *data, int len) {
  int i;
  int j;
  for (i = 0; i < len; i += 16) {
    for (j = 0; j < 16; j++) {
      if (i + j < len)
        printf("%02X ", data[i + j]);
      else
        printf("   ");
    }
    for (j = 0; j < 16; j++) {
      if (i + j < len) {
        if (data[i + j] == '\0')
          printf(".");
        else
          printf("%c", data[i + j]);
      }
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<print_raw_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1237 <print_raw_data+0x127>
movl   $0x0,-0x14(%rbp)
cmpl   $0x10,-0x14(%rbp)
jge    1197 <print_raw_data+0x87>
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1176 <print_raw_data+0x66>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
add    -0x14(%rbp),%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1184 <print_raw_data+0x74>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1189 <print_raw_data+0x79>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1139 <print_raw_data+0x29>
movl   $0x0,-0x14(%rbp)
cmpl   $0x10,-0x14(%rbp)
jge    121b <print_raw_data+0x10b>
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1208 <print_raw_data+0xf8>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
add    -0x14(%rbp),%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    11e4 <print_raw_data+0xd4>
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1203 <print_raw_data+0xf3>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
add    -0x14(%rbp),%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1208 <print_raw_data+0xf8>
jmp    120d <print_raw_data+0xfd>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    119e <print_raw_data+0x8e>
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <print_raw_data+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_raw_data>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,0x4(%rsp)
test   %esi,%esi
jle    11fc <print_raw_data+0xdc>
mov    %rdi,%r15
mov    0x4(%rsp),%ebp
lea    0xebb(%rip),%rbx
lea    0xeba(%rip),%r12
xor    %r14d,%r14d
jmp    1180 <print_raw_data+0x60>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x10,%r14
add    $0x10,%r15
cmp    0x4(%rsp),%r14d
mov    %r13,%rbx
jge    11fc <print_raw_data+0xdc>
xor    %r13d,%r13d
jmp    11a4 <print_raw_data+0x84>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r13
cmp    $0x10,%r13
je     11c0 <print_raw_data+0xa0>
lea    (%r14,%r13,1),%rax
cmp    %rbp,%rax
jge    1190 <print_raw_data+0x70>
movsbl (%r15,%r13,1),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    119a <print_raw_data+0x7a>
xchg   %ax,%ax
mov    %rbx,%r13
xor    %ebx,%ebx
jmp    11da <print_raw_data+0xba>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    $0x10,%rbx
je     1160 <print_raw_data+0x40>
lea    (%r14,%rbx,1),%rax
cmp    %rbp,%rax
jge    11d0 <print_raw_data+0xb0>
movzbl (%r15,%rbx,1),%eax
test   %al,%al
mov    $0x2e,%ecx
cmove  %ecx,%eax
movsbl %al,%edi
call   1030 <putchar@plt>
jmp    11d0 <print_raw_data+0xb0>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%02X \00"
@.str.1 = [4 x i8] c" \00"
@.str.2 = [2 x i8] c".\00"
@.str.3 = [3 x i8] c"%c\00"
@.str.4 = [2 x i8] c"\0A\00"
define void @print_raw_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
br label %7
7: ; preds = %76, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %79
11: ; preds = %7
store i32 0, i32* %6
br label %12
12: ; preds = %34, %11
%13 = load i32, i32* %6
%14 = icmp slt i32 %13, 16
br i1 %14, label %15, label %37
15: ; preds = %12
%16 = load i32, i32* %5
%17 = load i32, i32* %6
%18 = add nsw i32 %16, %17
%19 = load i32, i32* %4
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %31
21: ; preds = %15
%22 = load i8*, i8** %3
%23 = load i32, i32* %5
%24 = load i32, i32* %6
%25 = add nsw i32 %23, %24
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %22, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %29)
br label %33
31: ; preds = %15
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %33
33: ; preds = %31, %21
br label %34
34: ; preds = %33
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
store i32 %36, i32* %6
br label %12
37: ; preds = %12
store i32 0, i32* %6
br label %38
38: ; preds = %71, %37
%39 = load i32, i32* %6
%40 = icmp slt i32 %39, 16
br i1 %40, label %41, label %74
41: ; preds = %38
%42 = load i32, i32* %5
%43 = load i32, i32* %6
%44 = add nsw i32 %42, %43
%45 = load i32, i32* %4
%46 = icmp slt i32 %44, %45
br i1 %46, label %47, label %70
47: ; preds = %41
%48 = load i8*, i8** %3
%49 = load i32, i32* %5
%50 = load i32, i32* %6
%51 = add nsw i32 %49, %50
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %48, i64 %52
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = icmp eq i32 %55, 0
br i1 %56, label %57, label %59
57: ; preds = %47
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %69
59: ; preds = %47
%60 = load i8*, i8** %3
%61 = load i32, i32* %5
%62 = load i32, i32* %6
%63 = add nsw i32 %61, %62
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8, i8* %60, i64 %64
%66 = load i8, i8* %65
%67 = sext i8 %66 to i32
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %67)
br label %69
69: ; preds = %59, %57
br label %70
70: ; preds = %69, %41
br label %71
71: ; preds = %70
%72 = load i32, i32* %6
%73 = add nsw i32 %72, 1
store i32 %73, i32* %6
br label %38
74: ; preds = %38
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %76
76: ; preds = %74
%77 = load i32, i32* %5
%78 = add nsw i32 %77, 16
store i32 %78, i32* %5
br label %7
79: ; preds = %7
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%02X \00"
@.str.1 = [4 x i8] c" \00"
define void @print_raw_data(i8* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %41
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %36
%7 = phi i64 [ 0, %4 ], [ %38, %36 ]
br label %8
8: ; preds = %6, %19
%9 = phi i64 [ 0, %6 ], [ %20, %19 ]
%10 = add nuw nsw i64 %9, %7
%11 = icmp slt i64 %10, %5
br i1 %11, label %12, label %17
12: ; preds = %8
%13 = getelementptr inbounds i8, i8* %0, i64 %10
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %15)
br label %19
17: ; preds = %8
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %19
19: ; preds = %12, %17
%20 = add nuw nsw i64 %9, 1
%21 = icmp eq i64 %20, 16
br i1 %21, label %22, label %8
22: ; preds = %19, %33
%23 = phi i64 [ %34, %33 ], [ 0, %19 ]
%24 = add nuw nsw i64 %23, %7
%25 = icmp slt i64 %24, %5
br i1 %25, label %26, label %33
26: ; preds = %22
%27 = getelementptr inbounds i8, i8* %0, i64 %24
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 0
%30 = select i1 %29, i8 46, i8 %28
%31 = sext i8 %30 to i32
%32 = tail call i32 @putchar(i32 %31)
br label %33
33: ; preds = %26, %22
%34 = add nuw nsw i64 %23, 1
%35 = icmp eq i64 %34, 16
br i1 %35, label %36, label %22
36: ; preds = %33
%37 = tail call i32 @putchar(i32 10)
%38 = add nuw i64 %7, 16
%39 = trunc i64 %38 to i32
%40 = icmp slt i32 %39, %1
br i1 %40, label %6, label %41
41: ; preds = %36, %2
ret void
}