#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);
int /*<<< orphan*/ eputs(char *);
void printHex(unsigned int Number) {
  char TxString[9];
  int Index = 8;
  TxString[Index] = 0;
  Index--;
  while (Index >= 0) {
    TxString[Index] = HexDigit(Number & 0x0f);
    Number = Number >> 4;
    Index--;
  }
  eputs(TxString);
}


x86 assembly (clang, -O0):
<printHex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x8,-0x14(%rbp)
movslq -0x14(%rbp),%rax
movb   $0x0,-0xd(%rbp,%rax,1)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     117a <printHex+0x5a>
mov    -0x4(%rbp),%edi
and    $0xf,%edi
call   1030 <HexDigit@plt>
mov    %al,%cl
movslq -0x14(%rbp),%rax
mov    %cl,-0xd(%rbp,%rax,1)
mov    -0x4(%rbp),%eax
shr    $0x4,%eax
mov    %eax,-0x4(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1144 <printHex+0x24>
lea    -0xd(%rbp),%rdi
call   1040 <eputs@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printHex>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
movb   $0x0,0xf(%rsp)
and    $0xf,%edi
call   1030 <HexDigit@plt>
mov    %al,0xe(%rsp)
mov    %ebx,%edi
shr    $0x4,%edi
and    $0xf,%edi
call   1030 <HexDigit@plt>
mov    %al,0xd(%rsp)
mov    %ebx,%edi
shr    $0x8,%edi
and    $0xf,%edi
call   1030 <HexDigit@plt>
mov    %al,0xc(%rsp)
mov    %ebx,%edi
shr    $0xc,%edi
and    $0xf,%edi
call   1030 <HexDigit@plt>
mov    %al,0xb(%rsp)
mov    %ebx,%edi
shr    $0x10,%edi
and    $0xf,%edi
call   1030 <HexDigit@plt>
mov    %al,0xa(%rsp)
mov    %ebx,%edi
shr    $0x14,%edi
and    $0xf,%edi
call   1030 <HexDigit@plt>
mov    %al,0x9(%rsp)
mov    %ebx,%edi
shr    $0x18,%edi
and    $0xf,%edi
call   1030 <HexDigit@plt>
mov    %al,0x8(%rsp)
shr    $0x1c,%ebx
mov    %ebx,%edi
call   1030 <HexDigit@plt>
mov    %al,0x7(%rsp)
lea    0x7(%rsp),%rdi
call   1040 <eputs@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @printHex(i32 %0) {
%2 = alloca i32
%3 = alloca [9 x i8]
%4 = alloca i32
store i32 %0, i32* %2
store i32 8, i32* %4
%5 = load i32, i32* %4
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 %6
store i8 0, i8* %7
%8 = load i32, i32* %4
%9 = add nsw i32 %8, -1
store i32 %9, i32* %4
br label %10
10: ; preds = %13, %1
%11 = load i32, i32* %4
%12 = icmp sge i32 %11, 0
br i1 %12, label %13, label %24
13: ; preds = %10
%14 = load i32, i32* %2
%15 = and i32 %14, 15
%16 = call signext i8 @HexDigit(i32 %15)
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 %18
store i8 %16, i8* %19
%20 = load i32, i32* %2
%21 = lshr i32 %20, 4
store i32 %21, i32* %2
%22 = load i32, i32* %4
%23 = add nsw i32 %22, -1
store i32 %23, i32* %4
br label %10
24: ; preds = %10
%25 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 0
%26 = call i32 @eputs(i8* %25)
ret void
}

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