#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*/ fprintf(int /*<<< orphan*/, char *, unsigned char);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
void print(unsigned char *in, const unsigned long len) {
  int i;
  for (i = 0; i < len; i++)
    fprintf(stdout, "%02X", in[i]);
  fputc('\n', stdout);
}


x86 assembly (clang, -O0):
<print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1174 <print+0x54>
mov    0x2e94(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
lea    0xea3(%rip),%rsi
movzbl (%rax,%rcx,1),%edx
call   1040 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1137 <print+0x17>
mov    0x2e65(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1030 <fputc@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %rsi,%rsi
je     116a <print+0x4a>
mov    %rsi,%r12
mov    %rdi,%r14
xor    %ebx,%ebx
mov    0x2ea3(%rip),%r13
lea    0xebc(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x0(%r13),%edi
movzbl (%r14,%rbx,1),%edx
mov    %r15,%rsi
call   1040 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1150 <print+0x30>
mov    0x2e6f(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <fputc@plt>

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

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