#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 */
void hexify(uint8_t *out, const uint8_t *in, size_t len) {
  static const char hex[] = "0123456789abcdef";
  for (int i = 0; i < len; i++) {
    out[2 * i] = hex[in[i] >> 4];
    out[2 * i + 1] = hex[in[i] & 15];
  }
  out[2 * len] = '\0';
}


x86 assembly (clang, -O0):
<hexify>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    118e <hexify+0x8e>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
sar    $0x4,%eax
movslq %eax,%rcx
lea    0xec3(%rip),%rax
movsbl (%rax,%rcx,1),%edx
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
and    $0xf,%eax
movslq %eax,%rcx
lea    0xe97(%rip),%rax
movsbl (%rax,%rcx,1),%edx
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1117 <hexify+0x17>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
shl    $0x1,%rcx
movl   $0x0,(%rax,%rcx,4)
pop    %rbp
ret

x86 assembly (clang, -O2):
<hexify>:
test   %rdx,%rdx
je     1139 <hexify+0x39>
xor    %eax,%eax
lea    0xef2(%rip),%r8
xchg   %ax,%ax
mov    (%rsi,%rax,4),%ecx
sar    $0x4,%ecx
movslq %ecx,%rcx
movsbl (%rcx,%r8,1),%ecx
mov    %ecx,(%rdi,%rax,8)
mov    (%rsi,%rax,4),%ecx
and    $0xf,%ecx
movsbl (%rcx,%r8,1),%ecx
mov    %ecx,0x4(%rdi,%rax,8)
add    $0x1,%rax
cmp    %rax,%rdx
jne    1110 <hexify+0x10>
movl   $0x0,(%rdi,%rdx,8)
ret

LLVM IR (-O0):
@hexify.hex = internal constant [17 x i8] c"0123456789abcdef\00"
define void @hexify(i32* %0, i32* %1, i64 %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i64
%7 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i64 %2, i64* %6
store i32 0, i32* %7
br label %8
8: ; preds = %45, %3
%9 = load i32, i32* %7
%10 = sext i32 %9 to i64
%11 = load i64, i64* %6
%12 = icmp ult i64 %10, %11
br i1 %12, label %13, label %48
13: ; preds = %8
%14 = load i32*, i32** %5
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i32, i32* %14, i64 %16
%18 = load i32, i32* %17
%19 = ashr i32 %18, 4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [17 x i8], [17 x i8]* @hexify.hex, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = load i32*, i32** %4
%25 = load i32, i32* %7
%26 = mul nsw i32 2, %25
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %24, i64 %27
store i32 %23, i32* %28
%29 = load i32*, i32** %5
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %29, i64 %31
%33 = load i32, i32* %32
%34 = and i32 %33, 15
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [17 x i8], [17 x i8]* @hexify.hex, i64 0, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = load i32*, i32** %4
%40 = load i32, i32* %7
%41 = mul nsw i32 2, %40
%42 = add nsw i32 %41, 1
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i32, i32* %39, i64 %43
store i32 %38, i32* %44
br label %45
45: ; preds = %13
%46 = load i32, i32* %7
%47 = add nsw i32 %46, 1
store i32 %47, i32* %7
br label %8
48: ; preds = %8
%49 = load i32*, i32** %4
%50 = load i64, i64* %6
%51 = mul i64 2, %50
%52 = getelementptr inbounds i32, i32* %49, i64 %51
store i32 0, i32* %52
ret void
}

LLVM IR (-O2):
@hexify.hex = internal unnamed_addr constant [17 x i8] c"0123456789abcdef\00"
define void @hexify(i32* nocapture writeonly %0, i32* nocapture %1, i64 %2) {
%4 = icmp eq i64 %2, 0
br i1 %4, label %5, label %8
5: ; preds = %8, %3
%6 = shl i64 %2, 1
%7 = getelementptr inbounds i32, i32* %0, i64 %6
store i32 0, i32* %7
ret void
8: ; preds = %3, %8
%9 = phi i64 [ %27, %8 ], [ 0, %3 ]
%10 = getelementptr inbounds i32, i32* %1, i64 %9
%11 = load i32, i32* %10
%12 = ashr i32 %11, 4
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [17 x i8], [17 x i8]* @hexify.hex, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = shl nuw nsw i64 %9, 1
%18 = getelementptr inbounds i32, i32* %0, i64 %17
store i32 %16, i32* %18
%19 = load i32, i32* %10
%20 = and i32 %19, 15
%21 = zext i32 %20 to i64
%22 = getelementptr inbounds [17 x i8], [17 x i8]* @hexify.hex, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = or i64 %17, 1
%26 = getelementptr inbounds i32, i32* %0, i64 %25
store i32 %24, i32* %26
%27 = add nuw nsw i64 %9, 1
%28 = icmp eq i64 %27, %2
br i1 %28, label %5, label %8
}