#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 */
char hexdigit(unsigned int);
void Int2HexString(unsigned int Value, char *HexString) {
  int i;
  for (i = 7; i >= 0; i--) {
    HexString[i] = hexdigit(Value & 0xf);
    Value = Value >> 4;
  }
  HexString[8] = 0;
}


x86 assembly (clang, -O0):
<Int2HexString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x7,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     115f <Int2HexString+0x4f>
mov    -0x4(%rbp),%edi
and    $0xf,%edi
call   1030 <hexdigit@plt>
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x4(%rbp),%eax
shr    $0x4,%eax
mov    %eax,-0x4(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1126 <Int2HexString+0x16>
mov    -0x10(%rbp),%rax
movb   $0x0,0x8(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Int2HexString>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
and    $0xf,%edi
call   1030 <hexdigit@plt>
mov    %al,0x7(%rbx)
mov    %ebp,%edi
shr    $0x4,%edi
and    $0xf,%edi
call   1030 <hexdigit@plt>
mov    %al,0x6(%rbx)
mov    %ebp,%edi
shr    $0x8,%edi
and    $0xf,%edi
call   1030 <hexdigit@plt>
mov    %al,0x5(%rbx)
mov    %ebp,%edi
shr    $0xc,%edi
and    $0xf,%edi
call   1030 <hexdigit@plt>
mov    %al,0x4(%rbx)
mov    %ebp,%edi
shr    $0x10,%edi
and    $0xf,%edi
call   1030 <hexdigit@plt>
mov    %al,0x3(%rbx)
mov    %ebp,%edi
shr    $0x14,%edi
and    $0xf,%edi
call   1030 <hexdigit@plt>
mov    %al,0x2(%rbx)
mov    %ebp,%edi
shr    $0x18,%edi
and    $0xf,%edi
call   1030 <hexdigit@plt>
mov    %al,0x1(%rbx)
shr    $0x1c,%ebp
mov    %ebp,%edi
call   1030 <hexdigit@plt>
mov    %al,(%rbx)
movb   $0x0,0x8(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @Int2HexString(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 7, i32* %5
br label %6
6: ; preds = %19, %2
%7 = load i32, i32* %5
%8 = icmp sge i32 %7, 0
br i1 %8, label %9, label %22
9: ; preds = %6
%10 = load i32, i32* %3
%11 = and i32 %10, 15
%12 = call signext i8 @hexdigit(i32 %11)
%13 = load i8*, i8** %4
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
store i8 %12, i8* %16
%17 = load i32, i32* %3
%18 = lshr i32 %17, 4
store i32 %18, i32* %3
br label %19
19: ; preds = %9
%20 = load i32, i32* %5
%21 = add nsw i32 %20, -1
store i32 %21, i32* %5
br label %6
22: ; preds = %6
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i64 8
store i8 0, i8* %24
ret void
}

LLVM IR (-O2):
define void @Int2HexString(i32 %0, i8* nocapture writeonly %1) {
%3 = and i32 %0, 15
%4 = tail call signext i8 @hexdigit(i32 %3)
%5 = getelementptr inbounds i8, i8* %1, i64 7
store i8 %4, i8* %5
%6 = lshr i32 %0, 4
%7 = and i32 %6, 15
%8 = tail call signext i8 @hexdigit(i32 %7)
%9 = getelementptr inbounds i8, i8* %1, i64 6
store i8 %8, i8* %9
%10 = lshr i32 %0, 8
%11 = and i32 %10, 15
%12 = tail call signext i8 @hexdigit(i32 %11)
%13 = getelementptr inbounds i8, i8* %1, i64 5
store i8 %12, i8* %13
%14 = lshr i32 %0, 12
%15 = and i32 %14, 15
%16 = tail call signext i8 @hexdigit(i32 %15)
%17 = getelementptr inbounds i8, i8* %1, i64 4
store i8 %16, i8* %17
%18 = lshr i32 %0, 16
%19 = and i32 %18, 15
%20 = tail call signext i8 @hexdigit(i32 %19)
%21 = getelementptr inbounds i8, i8* %1, i64 3
store i8 %20, i8* %21
%22 = lshr i32 %0, 20
%23 = and i32 %22, 15
%24 = tail call signext i8 @hexdigit(i32 %23)
%25 = getelementptr inbounds i8, i8* %1, i64 2
store i8 %24, i8* %25
%26 = lshr i32 %0, 24
%27 = and i32 %26, 15
%28 = tail call signext i8 @hexdigit(i32 %27)
%29 = getelementptr inbounds i8, i8* %1, i64 1
store i8 %28, i8* %29
%30 = lshr i32 %0, 28
%31 = tail call signext i8 @hexdigit(i32 %30)
store i8 %31, i8* %1
%32 = getelementptr inbounds i8, i8* %1, i64 8
store i8 0, i8* %32
ret void
}