#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*/ nanotest_putchar(char const);
int /*<<< orphan*/ nanotest_putstr(char *);
void nanotest_putuint_hex(unsigned int n) {
  static char const hexes[] = "0123456789ABCDEF";
  nanotest_putstr("0x");
  for (int i = 8; i != 0; i--) {
    nanotest_putchar(hexes[n >> 28 & 0x0f]);
    n <<= 4;
  }
}


x86 assembly (clang, -O0):
<nanotest_putuint_hex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xedf(%rip),%rdi
call   1030 <nanotest_putstr@plt>
movl   $0x8,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     117c <nanotest_putuint_hex+0x5c>
mov    -0x4(%rbp),%eax
shr    $0x1c,%eax
and    $0xf,%eax
mov    %eax,%eax
mov    %eax,%ecx
lea    0xea4(%rip),%rax
movsbl (%rax,%rcx,1),%edi
call   1040 <nanotest_putchar@plt>
mov    -0x4(%rbp),%eax
shl    $0x4,%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    113e <nanotest_putuint_hex+0x1e>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nanotest_putuint_hex>:
push   %r15
push   %r14
push   %rbx
mov    %edi,%ebx
lea    0xee3(%rip),%rdi
call   1030 <nanotest_putstr@plt>
mov    %ebx,%r14d
mov    %r14,%rax
shr    $0x1c,%rax
lea    0xebc(%rip),%r15
movsbl (%rax,%r15,1),%edi
call   1040 <nanotest_putchar@plt>
mov    %ebx,%eax
shr    $0x18,%eax
and    $0xf,%eax
movsbl (%rax,%r15,1),%edi
call   1040 <nanotest_putchar@plt>
mov    %ebx,%eax
shr    $0x14,%eax
and    $0xf,%eax
movsbl (%rax,%r15,1),%edi
call   1040 <nanotest_putchar@plt>
mov    %ebx,%eax
shr    $0x10,%eax
and    $0xf,%eax
movsbl (%rax,%r15,1),%edi
call   1040 <nanotest_putchar@plt>
mov    %ebx,%eax
shr    $0xc,%eax
and    $0xf,%eax
movsbl (%rax,%r15,1),%edi
call   1040 <nanotest_putchar@plt>
mov    %ebx,%eax
shr    $0x8,%eax
and    $0xf,%eax
movsbl (%rax,%r15,1),%edi
call   1040 <nanotest_putchar@plt>
shr    $0x4,%ebx
and    $0xf,%ebx
movsbl (%rbx,%r15,1),%edi
call   1040 <nanotest_putchar@plt>
and    $0xf,%r14d
movsbl (%r14,%r15,1),%edi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <nanotest_putchar@plt>

LLVM IR (-O0):
@nanotest_putuint_hex.hexes = internal constant [17 x i8] c"0123456789ABCDEF\00"
@.str = [3 x i8] c"0x\00"
define void @nanotest_putuint_hex(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = call i32 @nanotest_putstr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 8, i32* %3
br label %5
5: ; preds = %18, %1
%6 = load i32, i32* %3
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %21
8: ; preds = %5
%9 = load i32, i32* %2
%10 = lshr i32 %9, 28
%11 = and i32 %10, 15
%12 = zext i32 %11 to i64
%13 = getelementptr inbounds [17 x i8], [17 x i8]* @nanotest_putuint_hex.hexes, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = call i32 @nanotest_putchar(i8 signext %14)
%16 = load i32, i32* %2
%17 = shl i32 %16, 4
store i32 %17, i32* %2
br label %18
18: ; preds = %8
%19 = load i32, i32* %3
%20 = add nsw i32 %19, -1
store i32 %20, i32* %3
br label %5
21: ; preds = %5
ret void
}

LLVM IR (-O2):
@nanotest_putuint_hex.hexes = internal unnamed_addr constant [17 x i8] c"0123456789ABCDEF\00"
@.str = [3 x i8] c"0x\00"
define void @nanotest_putuint_hex(i32 %0) {
%2 = tail call i32 @nanotest_putstr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = lshr i32 %0, 28
%4 = zext i32 %3 to i64
%5 = getelementptr inbounds [17 x i8], [17 x i8]* @nanotest_putuint_hex.hexes, i64 0, i64 %4
%6 = load i8, i8* %5
%7 = tail call i32 @nanotest_putchar(i8 signext %6)
%8 = lshr i32 %0, 24
%9 = and i32 %8, 15
%10 = zext i32 %9 to i64
%11 = getelementptr inbounds [17 x i8], [17 x i8]* @nanotest_putuint_hex.hexes, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = tail call i32 @nanotest_putchar(i8 signext %12)
%14 = lshr i32 %0, 20
%15 = and i32 %14, 15
%16 = zext i32 %15 to i64
%17 = getelementptr inbounds [17 x i8], [17 x i8]* @nanotest_putuint_hex.hexes, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = tail call i32 @nanotest_putchar(i8 signext %18)
%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]* @nanotest_putuint_hex.hexes, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = tail call i32 @nanotest_putchar(i8 signext %24)
%26 = lshr i32 %0, 12
%27 = and i32 %26, 15
%28 = zext i32 %27 to i64
%29 = getelementptr inbounds [17 x i8], [17 x i8]* @nanotest_putuint_hex.hexes, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = tail call i32 @nanotest_putchar(i8 signext %30)
%32 = lshr i32 %0, 8
%33 = and i32 %32, 15
%34 = zext i32 %33 to i64
%35 = getelementptr inbounds [17 x i8], [17 x i8]* @nanotest_putuint_hex.hexes, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = tail call i32 @nanotest_putchar(i8 signext %36)
%38 = lshr i32 %0, 4
%39 = and i32 %38, 15
%40 = zext i32 %39 to i64
%41 = getelementptr inbounds [17 x i8], [17 x i8]* @nanotest_putuint_hex.hexes, i64 0, i64 %40
%42 = load i8, i8* %41
%43 = tail call i32 @nanotest_putchar(i8 signext %42)
%44 = and i32 %0, 15
%45 = zext i32 %44 to i64
%46 = getelementptr inbounds [17 x i8], [17 x i8]* @nanotest_putuint_hex.hexes, i64 0, i64 %45
%47 = load i8, i8* %46
%48 = tail call i32 @nanotest_putchar(i8 signext %47)
ret void
}