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

/* Variables and functions */
void int2hex32(uint32_t n, char *s) {
  static const char *hex_digits = "0123456789abcdef";
  int index = 0;
  for (int i = 28; i >= 0; i -= 4)
    s[index++] = hex_digits[(n >> (32 - i)) & 0xf];
  s[index] = 0;
}


x86 assembly (clang, -O0):
<int2hex32>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x1c,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jl     1165 <int2hex32+0x65>
mov    0x2ef6(%rip),%rax
mov    -0x4(%rbp),%edx
mov    $0x20,%ecx
sub    -0x18(%rbp),%ecx
sar    %cl,%edx
mov    %edx,%ecx
and    $0xf,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x14(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
sub    $0x4,%eax
mov    %eax,-0x18(%rbp)
jmp    1119 <int2hex32+0x19>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
pop    %rbp
ret

x86 assembly (clang, -O2):
<int2hex32>:
mov    %edi,%ecx
shr    $0x4,%ecx
and    $0xf,%ecx
lea    0xef1(%rip),%rax
mov    (%rcx,%rax,1),%cl
mov    %cl,(%rsi)
mov    %edi,%ecx
shr    $0x8,%ecx
and    $0xf,%ecx
mov    (%rcx,%rax,1),%cl
mov    %cl,0x1(%rsi)
mov    %edi,%ecx
shr    $0xc,%ecx
and    $0xf,%ecx
mov    (%rcx,%rax,1),%cl
mov    %cl,0x2(%rsi)
mov    %edi,%ecx
shr    $0x10,%ecx
and    $0xf,%ecx
mov    (%rcx,%rax,1),%cl
mov    %cl,0x3(%rsi)
mov    %edi,%ecx
shr    $0x14,%ecx
and    $0xf,%ecx
mov    (%rcx,%rax,1),%cl
mov    %cl,0x4(%rsi)
mov    %edi,%ecx
shr    $0x18,%edi
and    $0xf,%edi
mov    (%rdi,%rax,1),%dl
mov    %dl,0x5(%rsi)
shr    $0x1c,%rcx
mov    (%rcx,%rax,1),%al
mov    %al,0x6(%rsi)
movb   $0x0,0x8(%rsi)
ret

LLVM IR (-O0):
@int2hex32.hex_digits = internal global i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i32 0, i32 0)
@.str = [17 x i8] c"0123456789abcdef\00"
define void @int2hex32(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
store i32 0, i32* %5
store i32 28, i32* %6
br label %7
7: ; preds = %25, %2
%8 = load i32, i32* %6
%9 = icmp sge i32 %8, 0
br i1 %9, label %10, label %28
10: ; preds = %7
%11 = load i8*, i8** @int2hex32.hex_digits
%12 = load i32, i32* %3
%13 = load i32, i32* %6
%14 = sub nsw i32 32, %13
%15 = ashr i32 %12, %14
%16 = and i32 %15, 15
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %11, i64 %17
%19 = load i8, i8* %18
%20 = load i8*, i8** %4
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
%23 = sext i32 %21 to i64
%24 = getelementptr inbounds i8, i8* %20, i64 %23
store i8 %19, i8* %24
br label %25
25: ; preds = %10
%26 = load i32, i32* %6
%27 = sub nsw i32 %26, 4
store i32 %27, i32* %6
br label %7
28: ; preds = %7
%29 = load i8*, i8** %4
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
store i8 0, i8* %32
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"0123456789abcdef\00"
define void @int2hex32(i32 %0, i8* nocapture writeonly %1) {
%3 = lshr i32 %0, 4
%4 = and i32 %3, 15
%5 = zext i32 %4 to i64
%6 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %5
%7 = load i8, i8* %6
store i8 %7, i8* %1
%8 = lshr i32 %0, 8
%9 = and i32 %8, 15
%10 = zext i32 %9 to i64
%11 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = getelementptr inbounds i8, i8* %1, i64 1
store i8 %12, i8* %13
%14 = lshr i32 %0, 12
%15 = and i32 %14, 15
%16 = zext i32 %15 to i64
%17 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = getelementptr inbounds i8, i8* %1, i64 2
store i8 %18, i8* %19
%20 = lshr i32 %0, 16
%21 = and i32 %20, 15
%22 = zext i32 %21 to i64
%23 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = getelementptr inbounds i8, i8* %1, i64 3
store i8 %24, i8* %25
%26 = lshr i32 %0, 20
%27 = and i32 %26, 15
%28 = zext i32 %27 to i64
%29 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = getelementptr inbounds i8, i8* %1, i64 4
store i8 %30, i8* %31
%32 = lshr i32 %0, 24
%33 = and i32 %32, 15
%34 = zext i32 %33 to i64
%35 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = getelementptr inbounds i8, i8* %1, i64 5
store i8 %36, i8* %37
%38 = lshr i32 %0, 28
%39 = zext i32 %38 to i64
%40 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %39
%41 = load i8, i8* %40
%42 = getelementptr inbounds i8, i8* %1, i64 6
store i8 %41, i8* %42
%43 = getelementptr inbounds i8, i8* %1, i64 8
store i8 0, i8* %43
ret void
}