#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*/ snprintf(char *, int, char *, unsigned char);
const char *key2text(unsigned char *key) {
  static char text[256] = "";
  size_t i = 0;
  for (i = 0; i < 8; i++)
    snprintf(&text[2 * i], 1, "%2X", key[i]);
  return text;
}


x86 assembly (clang, -O0):
<key2text>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x10(%rbp)
cmpq   $0x8,-0x10(%rbp)
jae    1177 <key2text+0x67>
mov    -0x10(%rbp),%rax
shl    $0x1,%rax
lea    0x2efa(%rip),%rdi
add    %rax,%rdi
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
lea    0xea3(%rip),%rdx
movzbl (%rax,%rcx,1),%ecx
call   1030 <snprintf@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    112c <key2text+0x1c>
lea    0x2ec2(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<key2text>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
movzbl (%rdi),%ecx
lea    0x2f1e(%rip),%r14
lea    0xed7(%rip),%r15
mov    %r14,%rdi
mov    $0x1,%esi
mov    %r15,%rdx
call   1030 <snprintf@plt>
movzbl 0x1(%rbx),%ecx
lea    0x2efe(%rip),%rdi
mov    $0x1,%esi
mov    %r15,%rdx
call   1030 <snprintf@plt>
movzbl 0x2(%rbx),%ecx
lea    0x2ee8(%rip),%rdi
mov    $0x1,%esi
mov    %r15,%rdx
call   1030 <snprintf@plt>
movzbl 0x3(%rbx),%ecx
lea    0x2ed2(%rip),%rdi
mov    $0x1,%esi
mov    %r15,%rdx
call   1030 <snprintf@plt>
movzbl 0x4(%rbx),%ecx
lea    0x2ebc(%rip),%rdi
mov    $0x1,%esi
mov    %r15,%rdx
call   1030 <snprintf@plt>
movzbl 0x5(%rbx),%ecx
lea    0x2ea6(%rip),%rdi
mov    $0x1,%esi
mov    %r15,%rdx
call   1030 <snprintf@plt>
movzbl 0x6(%rbx),%ecx
lea    0x2e90(%rip),%rdi
mov    $0x1,%esi
mov    %r15,%rdx
call   1030 <snprintf@plt>
movzbl 0x7(%rbx),%ecx
lea    0x2e7a(%rip),%rdi
mov    $0x1,%esi
mov    %r15,%rdx
call   1030 <snprintf@plt>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@key2text.text = internal global [256 x i8] zeroinitializer
@.str = [4 x i8] c"%2X\00"
define i8* @key2text(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
store i8* %0, i8** %2
store i64 0, i64* %3
store i64 0, i64* %3
br label %4
4: ; preds = %16, %1
%5 = load i64, i64* %3
%6 = icmp ult i64 %5, 8
br i1 %6, label %7, label %19
7: ; preds = %4
%8 = load i64, i64* %3
%9 = mul i64 2, %8
%10 = getelementptr inbounds [256 x i8], [256 x i8]* @key2text.text, i64 0, i64 %9
%11 = load i8*, i8** %2
%12 = load i64, i64* %3
%13 = getelementptr inbounds i8, i8* %11, i64 %12
%14 = load i8, i8* %13
%15 = call i32 @snprintf(i8* %10, i32 1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 zeroext %14)
br label %16
16: ; preds = %7
%17 = load i64, i64* %3
%18 = add i64 %17, 1
store i64 %18, i64* %3
br label %4
19: ; preds = %4
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @key2text.text, i64 0, i64 0)
}

LLVM IR (-O2):
@key2text.text = internal global [256 x i8] zeroinitializer
@.str = [4 x i8] c"%2X\00"
define i8* @key2text(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = tail call i32 @snprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @key2text.text, i64 0, i64 0), i32 1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 zeroext %2)
%4 = getelementptr inbounds i8, i8* %0, i64 1
%5 = load i8, i8* %4
%6 = tail call i32 @snprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @key2text.text, i64 0, i64 2), i32 1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 zeroext %5)
%7 = getelementptr inbounds i8, i8* %0, i64 2
%8 = load i8, i8* %7
%9 = tail call i32 @snprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @key2text.text, i64 0, i64 4), i32 1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 zeroext %8)
%10 = getelementptr inbounds i8, i8* %0, i64 3
%11 = load i8, i8* %10
%12 = tail call i32 @snprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @key2text.text, i64 0, i64 6), i32 1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 zeroext %11)
%13 = getelementptr inbounds i8, i8* %0, i64 4
%14 = load i8, i8* %13
%15 = tail call i32 @snprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @key2text.text, i64 0, i64 8), i32 1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 zeroext %14)
%16 = getelementptr inbounds i8, i8* %0, i64 5
%17 = load i8, i8* %16
%18 = tail call i32 @snprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @key2text.text, i64 0, i64 10), i32 1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 zeroext %17)
%19 = getelementptr inbounds i8, i8* %0, i64 6
%20 = load i8, i8* %19
%21 = tail call i32 @snprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @key2text.text, i64 0, i64 12), i32 1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 zeroext %20)
%22 = getelementptr inbounds i8, i8* %0, i64 7
%23 = load i8, i8* %22
%24 = tail call i32 @snprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @key2text.text, i64 0, i64 14), i32 1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 zeroext %23)
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @key2text.text, i64 0, i64 0)
}