#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;

/* Variables and functions */
int /*<<< orphan*/ sprintf(char *, char *, int const);
void key_descriptor_to_hex(const uint8_t bytes[8], char hex[((2 * 8) + 1)]) {
  int i;
  for (i = 0; i < 8; ++i) {
    sprintf(hex + 2 * i, "%02x", bytes[i]);
  }
}


x86 assembly (clang, -O0):
<key_descriptor_to_hex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    1165 <key_descriptor_to_hex+0x55>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
cltq
add    %rax,%rdi
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xeae(%rip),%rsi
call   1030 <sprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1127 <key_descriptor_to_hex+0x17>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<key_descriptor_to_hex>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
mov    (%rdi),%edx
lea    0xedc(%rip),%r15
mov    %rsi,%rdi
mov    %r15,%rsi
call   1030 <sprintf@plt>
lea    0x2(%rbx),%rdi
mov    0x4(%r14),%edx
mov    %r15,%rsi
call   1030 <sprintf@plt>
lea    0x4(%rbx),%rdi
mov    0x8(%r14),%edx
mov    %r15,%rsi
call   1030 <sprintf@plt>
lea    0x6(%rbx),%rdi
mov    0xc(%r14),%edx
mov    %r15,%rsi
call   1030 <sprintf@plt>
lea    0x8(%rbx),%rdi
mov    0x10(%r14),%edx
mov    %r15,%rsi
call   1030 <sprintf@plt>
lea    0xa(%rbx),%rdi
mov    0x14(%r14),%edx
mov    %r15,%rsi
call   1030 <sprintf@plt>
lea    0xc(%rbx),%rdi
mov    0x18(%r14),%edx
mov    %r15,%rsi
call   1030 <sprintf@plt>
add    $0xe,%rbx
mov    0x1c(%r14),%edx
mov    %rbx,%rdi
mov    %r15,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <sprintf@plt>

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

LLVM IR (-O2):
@.str = [5 x i8] c"%02x\00"
define void @key_descriptor_to_hex(i32* nocapture %0, i8* nocapture writeonly %1) {
%3 = load i32, i32* %0
%4 = tail call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = getelementptr inbounds i8, i8* %1, i64 2
%6 = getelementptr inbounds i32, i32* %0, i64 1
%7 = load i32, i32* %6
%8 = tail call i32 @sprintf(i8* dereferenceable(1) %5, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = getelementptr inbounds i8, i8* %1, i64 4
%10 = getelementptr inbounds i32, i32* %0, i64 2
%11 = load i32, i32* %10
%12 = tail call i32 @sprintf(i8* dereferenceable(1) %9, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds i8, i8* %1, i64 6
%14 = getelementptr inbounds i32, i32* %0, i64 3
%15 = load i32, i32* %14
%16 = tail call i32 @sprintf(i8* dereferenceable(1) %13, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds i8, i8* %1, i64 8
%18 = getelementptr inbounds i32, i32* %0, i64 4
%19 = load i32, i32* %18
%20 = tail call i32 @sprintf(i8* dereferenceable(1) %17, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds i8, i8* %1, i64 10
%22 = getelementptr inbounds i32, i32* %0, i64 5
%23 = load i32, i32* %22
%24 = tail call i32 @sprintf(i8* dereferenceable(1) %21, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = getelementptr inbounds i8, i8* %1, i64 12
%26 = getelementptr inbounds i32, i32* %0, i64 6
%27 = load i32, i32* %26
%28 = tail call i32 @sprintf(i8* dereferenceable(1) %25, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %27)
%29 = getelementptr inbounds i8, i8* %1, i64 14
%30 = getelementptr inbounds i32, i32* %0, i64 7
%31 = load i32, i32* %30
%32 = tail call i32 @sprintf(i8* dereferenceable(1) %29, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %31)
ret void
}