#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 const *, ...);
void printData(const char *prefix, const unsigned char *const data, int len,
               const char *suffix) {
  printf(prefix);
  for (int l = 0; l < len; l++)
    printf("%02X", data[l]);
  printf(suffix);
}


x86 assembly (clang, -O0):
<printData>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    116d <printData+0x5d>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1139 <printData+0x29>
mov    -0x20(%rbp),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printData>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %edx,%ebp
mov    %rsi,%r12
xor    %eax,%eax
call   1030 <printf@plt>
test   %ebp,%ebp
jle    1158 <printData+0x48>
mov    %ebp,%ebp
lea    0xecc(%rip),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
movzbl (%r12,%rbx,1),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1140 <printData+0x30>
mov    %r14,%rdi
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"%02X\00"
define void @printData(i8* %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%10 = load i8*, i8** %5
%11 = call i32 (i8*, ...) @printf(i8* %10)
store i32 0, i32* %9
br label %12
12: ; preds = %24, %4
%13 = load i32, i32* %9
%14 = load i32, i32* %7
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %27
16: ; preds = %12
%17 = load i8*, i8** %6
%18 = load i32, i32* %9
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %22)
br label %24
24: ; preds = %16
%25 = load i32, i32* %9
%26 = add nsw i32 %25, 1
store i32 %26, i32* %9
br label %12
27: ; preds = %12
%28 = load i8*, i8** %8
%29 = call i32 (i8*, ...) @printf(i8* %28)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%02X\00"
define void @printData(i8* nocapture %0, i8* nocapture %1, i32 %2, i8* nocapture %3) {
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %0)
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = zext i32 %2 to i64
br label %11
9: ; preds = %11, %4
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %3)
ret void
11: ; preds = %7, %11
%12 = phi i64 [ 0, %7 ], [ %17, %11 ]
%13 = getelementptr inbounds i8, i8* %1, i64 %12
%14 = load i8, i8* %13
%15 = zext i8 %14 to i32
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = add nuw nsw i64 %12, 1
%18 = icmp eq i64 %17, %8
br i1 %18, label %9, label %11
}