#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;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int const, char);
void fprint_u8a(FILE *stream, const uint8_t *a, size_t len) {
  for (size_t i = 0; i < len; ++i)
    fprintf(stream, "%02x%c", a[i], i + 1 < len ? ' ' : '\n');
}


x86 assembly (clang, -O0):
<fprint_u8a>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1185 <fprint_u8a+0x75>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x20(%rbp),%rsi
add    $0x1,%rsi
mov    -0x18(%rbp),%r8
mov    $0xa,%eax
mov    $0x20,%ecx
cmp    %r8,%rsi
cmovb  %ecx,%eax
lea    0xe94(%rip),%rsi
movsbl %al,%ecx
call   1030 <fprintf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    112c <fprint_u8a+0x1c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fprint_u8a>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rdx,%rdx
je     1172 <fprint_u8a+0x62>
mov    %rdx,%r13
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rdx,%rbx
neg    %rbx
mov    $0x1,%ebp
lea    0xec5(%rip),%r12
nopl   0x0(%rax,%rax,1)
mov    -0x4(%r14,%rbp,4),%edx
cmp    %r13,%rbp
mov    $0xa,%ecx
mov    $0x20,%eax
cmovb  %eax,%ecx
mov    %r15,%rdi
mov    %r12,%rsi
call   1030 <fprintf@plt>
lea    (%rbx,%rbp,1),%rax
add    $0x1,%rax
add    $0x1,%rbp
cmp    $0x1,%rax
jne    1140 <fprint_u8a+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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