#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*/ uputs(int, char *);
void phint(int x) {
  static const char hex[] = "0123456789ABCDEF";
  char res[] = "0x........";
  int i;
  for (i = 0; i < 8; i++)
    res[2 + 7 - i] = hex[(x >> (i << 2)) & 0xF];
  uputs(0x00400000, res);
}


x86 assembly (clang, -O0):
<phint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    0xeef(%rip),%rax
mov    %rax,-0xf(%rbp)
mov    0xeec(%rip),%ax
mov    %ax,-0x7(%rbp)
mov    0xee4(%rip),%al
mov    %al,-0x5(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    1182 <phint+0x72>
mov    -0x4(%rbp),%eax
mov    -0x14(%rbp),%ecx
shl    $0x2,%ecx
sar    %cl,%eax
and    $0xf,%eax
movslq %eax,%rcx
lea    0xe9d(%rip),%rax
mov    (%rax,%rcx,1),%cl
mov    $0x9,%eax
sub    -0x14(%rbp),%eax
cltq
mov    %cl,-0xf(%rbp,%rax,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1141 <phint+0x31>
lea    -0xf(%rbp),%rsi
mov    $0x400000,%edi
call   1030 <uputs@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<phint>:
sub    $0x18,%rsp
movabs $0x2e2e2e2e2e2e7830,%rax
2e 2e 2e
mov    %rax,0x8(%rsp)
movl   $0x2e2e2e,0xf(%rsp)
mov    %edi,%eax
mov    %eax,%edx
and    $0xf,%edx
lea    0xec7(%rip),%rcx
mov    (%rdx,%rcx,1),%dl
mov    %dl,0x11(%rsp)
mov    %edi,%edx
shr    $0x4,%edx
and    $0xf,%edx
mov    (%rdx,%rcx,1),%dl
mov    %dl,0x10(%rsp)
mov    %edi,%edx
shr    $0x8,%edx
and    $0xf,%edx
mov    (%rdx,%rcx,1),%dl
mov    %dl,0xf(%rsp)
mov    %edi,%edx
shr    $0xc,%edx
and    $0xf,%edx
mov    (%rdx,%rcx,1),%dl
mov    %dl,0xe(%rsp)
mov    %edi,%edx
shr    $0x10,%edx
and    $0xf,%edx
mov    (%rdx,%rcx,1),%dl
mov    %dl,0xd(%rsp)
mov    %edi,%edx
shr    $0x14,%edx
and    $0xf,%edx
mov    (%rdx,%rcx,1),%dl
mov    %dl,0xc(%rsp)
shr    $0x18,%edi
and    $0xf,%edi
mov    (%rdi,%rcx,1),%dl
mov    %dl,0xb(%rsp)
shr    $0x1c,%rax
mov    (%rax,%rcx,1),%al
mov    %al,0xa(%rsp)
lea    0x8(%rsp),%rsi
mov    $0x400000,%edi
call   1030 <uputs@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
@phint.hex = internal constant [17 x i8] c"0123456789ABCDEF\00"
@__const.phint.res = [11 x i8] c"0x........\00"
define void @phint(i32 %0) {
%2 = alloca i32
%3 = alloca [11 x i8]
%4 = alloca i32
store i32 %0, i32* %2
%5 = bitcast [11 x i8]* %3 to i8*
store i32 0, i32* %4
br label %6
6: ; preds = %22, %1
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 8
br i1 %8, label %9, label %25
9: ; preds = %6
%10 = load i32, i32* %2
%11 = load i32, i32* %4
%12 = shl i32 %11, 2
%13 = ashr i32 %10, %12
%14 = and i32 %13, 15
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [17 x i8], [17 x i8]* @phint.hex, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = load i32, i32* %4
%19 = sub nsw i32 9, %18
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 %20
store i8 %17, i8* %21
br label %22
22: ; preds = %9
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %6
25: ; preds = %6
%26 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
%27 = call i32 @uputs(i32 4194304, i8* %26)
ret void
}

LLVM IR (-O2):
@phint.hex = internal unnamed_addr constant [17 x i8] c"0123456789ABCDEF\00"
@__const.phint.res = [11 x i8] c"0x........\00"
define void @phint(i32 %0) {
%2 = alloca [11 x i8]
%3 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%4 = and i32 %0, 15
%5 = zext i32 %4 to i64
%6 = getelementptr inbounds [17 x i8], [17 x i8]* @phint.hex, i64 0, i64 %5
%7 = load i8, i8* %6
%8 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 9
store i8 %7, i8* %8
%9 = lshr i32 %0, 4
%10 = and i32 %9, 15
%11 = zext i32 %10 to i64
%12 = getelementptr inbounds [17 x i8], [17 x i8]* @phint.hex, i64 0, i64 %11
%13 = load i8, i8* %12
%14 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 8
store i8 %13, i8* %14
%15 = lshr i32 %0, 8
%16 = and i32 %15, 15
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds [17 x i8], [17 x i8]* @phint.hex, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 7
store i8 %19, i8* %20
%21 = lshr i32 %0, 12
%22 = and i32 %21, 15
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds [17 x i8], [17 x i8]* @phint.hex, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 6
store i8 %25, i8* %26
%27 = lshr i32 %0, 16
%28 = and i32 %27, 15
%29 = zext i32 %28 to i64
%30 = getelementptr inbounds [17 x i8], [17 x i8]* @phint.hex, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 5
store i8 %31, i8* %32
%33 = lshr i32 %0, 20
%34 = and i32 %33, 15
%35 = zext i32 %34 to i64
%36 = getelementptr inbounds [17 x i8], [17 x i8]* @phint.hex, i64 0, i64 %35
%37 = load i8, i8* %36
%38 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 4
store i8 %37, i8* %38
%39 = lshr i32 %0, 24
%40 = and i32 %39, 15
%41 = zext i32 %40 to i64
%42 = getelementptr inbounds [17 x i8], [17 x i8]* @phint.hex, i64 0, i64 %41
%43 = load i8, i8* %42
%44 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 3
store i8 %43, i8* %44
%45 = lshr i32 %0, 28
%46 = zext i32 %45 to i64
%47 = getelementptr inbounds [17 x i8], [17 x i8]* @phint.hex, i64 0, i64 %46
%48 = load i8, i8* %47
%49 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 2
store i8 %48, i8* %49
%50 = call i32 @uputs(i32 4194304, i8* %3)
ret void
}