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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void fprintBstr(FILE *fp, char *S, unsigned char *A, unsigned long long L) {
  unsigned long long i;
  fprintf(fp, "%s", S);
  for (i = 0; i < L; i++)
    fprintf(fp, "%02X", A[i]);
  if (L == 0)
    fprintf(fp, "00");
  fprintf(fp, "\n");
}


x86 assembly (clang, -O0):
<fprintBstr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xec9(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    1183 <fprintBstr+0x73>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
lea    0xe98(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1146 <fprintBstr+0x36>
cmpq   $0x0,-0x20(%rbp)
jne    11a0 <fprintBstr+0x90>
mov    -0x8(%rbp),%rdi
lea    0xe6f(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xe60(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fprintBstr>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rcx,%r13
mov    %rdx,%r15
mov    %rdi,%r14
mov    %rsi,%rdi
mov    %r14,%rsi
call   1030 <fputs@plt>
test   %r13,%r13
je     1190 <fprintBstr+0x50>
lea    0xe97(%rip),%r12
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movzbl (%r15,%rbx,1),%edx
mov    %r14,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1170 <fprintBstr+0x30>
test   %r13,%r13
jne    11a9 <fprintBstr+0x69>
lea    0xe6e(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1060 <fwrite@plt>
mov    $0xa,%edi
mov    %r14,%rsi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1040 <fputc@plt>

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

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