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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void hex_out(FILE *fp, uint64_t data[], uint64_t size) {
  uint64_t i;
  for (i = 0; i < size; i++)
    fprintf(fp, "%016lx", data[size - i - 1]);
  fprintf(fp, "\n");
  return;
}


x86 assembly (clang, -O0):
<hex_out>:
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
jge    1171 <hex_out+0x61>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    -0x20(%rbp),%rcx
sub    $0x1,%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xea7(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    112c <hex_out+0x1c>
mov    -0x8(%rbp),%rdi
lea    0xe8b(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hex_out>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
test   %rdx,%rdx
jle    1158 <hex_out+0x38>
mov    %rdx,%rbx
mov    %rsi,%r15
lea    0xec3(%rip),%r12
nopl   (%rax)
mov    -0x8(%r15,%rbx,8),%rdx
mov    %r14,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
add    $0xffffffffffffffff,%rbx
jne    1140 <hex_out+0x20>
mov    $0xa,%edi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <fputc@plt>

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

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