#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 *, ...);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
void hex_print(const char *name, const unsigned char *buf, size_t len) {
  size_t i;
  fprintf(stderr, "%s ", name);
  for (i = 0; i < len; i++)
    fprintf(stderr, "%02X", buf[i]);
  fputs("\n", stderr);
}


x86 assembly (clang, -O0):
<hex_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0x2ea5(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xeb8(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1199 <hex_print+0x79>
mov    0x2e74(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
lea    0xe83(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1157 <hex_print+0x37>
mov    0x2e40(%rip),%rax
mov    (%rax),%esi
lea    0xe60(%rip),%rdi
call   1030 <fputs@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hex_print>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r13
mov    %rsi,%r14
mov    %rdi,%rdx
mov    0x2ea7(%rip),%r12
mov    (%r12),%edi
lea    0xebc(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
test   %r13,%r13
je     117c <hex_print+0x5c>
lea    0xead(%rip),%r15
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    (%r12),%edi
movzbl (%r14,%rbx,1),%edx
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1160 <hex_print+0x40>
mov    (%r12),%esi
lea    0xe82(%rip),%rdi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <fputs@plt>

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

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