#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 uint8_t;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
void print_data(const char *data, size_t len) {
  for (size_t i = 0; i < len; i++) {
    if ((i & 2) == 0) {
      fputc(' ', stderr);
    }
    fprintf(stderr, "%02X", ((uint8_t *)data)[i]);
  }
}


x86 assembly (clang, -O0):
<print_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    119c <print_data+0x7c>
mov    -0x18(%rbp),%rax
and    $0x2,%rax
cmp    $0x0,%rax
jne    116b <print_data+0x4b>
mov    0x2e81(%rip),%rax
mov    (%rax),%esi
mov    $0x20,%edi
call   1030 <fputc@plt>
mov    0x2e6e(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe7a(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1138 <print_data+0x18>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_data>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %rsi,%rsi
je     117e <print_data+0x5e>
mov    %rsi,%r12
mov    %rdi,%r14
xor    %ebx,%ebx
mov    0x2ea3(%rip),%r13
lea    0xebc(%rip),%r15
jmp    1169 <print_data+0x49>
cs nopw 0x0(%rax,%rax,1)
mov    0x0(%r13),%edi
mov    (%r14,%rbx,4),%edx
mov    %r15,%rsi
call   1040 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
je     117e <print_data+0x5e>
test   $0x2,%bl
jne    1150 <print_data+0x30>
mov    0x0(%r13),%esi
mov    $0x20,%edi
call   1030 <fputc@plt>
jmp    1150 <print_data+0x30>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [5 x i8] c"%02X\00"
define void @print_data(i8* nocapture %0, i64 %1) {
%3 = icmp eq i64 %1, 0
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = bitcast i8* %0 to i32*
br label %7
6: ; preds = %14, %2
ret void
7: ; preds = %4, %14
%8 = phi i64 [ 0, %4 ], [ %19, %14 ]
%9 = and i64 %8, 2
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = load i32, i32* @stderr
%13 = tail call i32 @fputc(i8 signext 32, i32 %12)
br label %14
14: ; preds = %11, %7
%15 = load i32, i32* @stderr
%16 = getelementptr inbounds i32, i32* %5, i64 %8
%17 = load i32, i32* %16
%18 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = add nuw i64 %8, 1
%20 = icmp eq i64 %19, %1
br i1 %20, label %6, label %7
}