#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*/ print(char *);
void print_hex(unsigned long number) {
  char buf[] = "0x00000000";
  char hex[] = "0123456789ABCDEF";
  unsigned int i, digit;
  for (i = 9; i > 1; i--) {
    digit = number % 0x10;
    buf[i] = hex[digit];
    number /= 0x10;
    if (number == 0)
      break;
  }
  print(buf);
}


x86 assembly (clang, -O0):
<print_hex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    0xedd(%rip),%rax
mov    %rax,-0x13(%rbp)
mov    0xeda(%rip),%ax
mov    %ax,-0xb(%rbp)
mov    0xed2(%rip),%al
mov    %al,-0x9(%rbp)
mov    0xece(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xecb(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xec9(%rip),%al
mov    %al,-0x20(%rbp)
movl   $0x9,-0x34(%rbp)
cmpl   $0x1,-0x34(%rbp)
jbe    11b3 <print_hex+0xa3>
mov    -0x8(%rbp),%rax
and    $0xf,%rax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    -0x30(%rbp,%rax,1),%cl
mov    -0x34(%rbp),%eax
mov    %cl,-0x13(%rbp,%rax,1)
mov    -0x8(%rbp),%rax
shr    $0x4,%rax
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    11a0 <print_hex+0x90>
jmp    11b3 <print_hex+0xa3>
jmp    11a5 <print_hex+0x95>
mov    -0x34(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x34(%rbp)
jmp    1161 <print_hex+0x51>
lea    -0x13(%rbp),%rdi
call   1030 <print@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_hex>:
sub    $0x18,%rsp
movabs $0x3030303030307830,%rax
30 30 30
mov    %rax,0x8(%rsp)
movl   $0x303030,0xf(%rsp)
mov    %edi,%ecx
and    $0xf,%ecx
lea    0xed9(%rip),%rax
mov    (%rcx,%rax,1),%cl
mov    %cl,0x11(%rsp)
cmp    $0x10,%rdi
jb     11e6 <print_hex+0xd6>
mov    %edi,%ecx
shr    $0x4,%ecx
and    $0xf,%ecx
mov    (%rcx,%rax,1),%cl
mov    %cl,0x10(%rsp)
cmp    $0x100,%rdi
jb     11e6 <print_hex+0xd6>
mov    %edi,%ecx
shr    $0x8,%ecx
and    $0xf,%ecx
mov    (%rcx,%rax,1),%cl
mov    %cl,0xf(%rsp)
cmp    $0x1000,%rdi
jb     11e6 <print_hex+0xd6>
mov    %edi,%ecx
shr    $0xc,%ecx
and    $0xf,%ecx
mov    (%rcx,%rax,1),%cl
mov    %cl,0xe(%rsp)
cmp    $0x10000,%rdi
jb     11e6 <print_hex+0xd6>
mov    %edi,%ecx
shr    $0x10,%ecx
and    $0xf,%ecx
mov    (%rcx,%rax,1),%cl
mov    %cl,0xd(%rsp)
cmp    $0x100000,%rdi
jb     11e6 <print_hex+0xd6>
mov    %edi,%ecx
shr    $0x14,%ecx
and    $0xf,%ecx
mov    (%rcx,%rax,1),%cl
mov    %cl,0xc(%rsp)
cmp    $0x1000000,%rdi
jb     11e6 <print_hex+0xd6>
mov    %edi,%ecx
shr    $0x18,%ecx
and    $0xf,%ecx
mov    (%rcx,%rax,1),%cl
mov    %cl,0xb(%rsp)
cmp    $0x10000000,%rdi
jb     11e6 <print_hex+0xd6>
shr    $0x1c,%edi
mov    (%rdi,%rax,1),%al
mov    %al,0xa(%rsp)
lea    0x8(%rsp),%rdi
call   1030 <print@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.print_hex.buf = [11 x i8] c"0x00000000\00"
@__const.print_hex.hex = [17 x i8] c"0123456789ABCDEF\00"
define void @print_hex(i64 %0) {
%2 = alloca i64
%3 = alloca [11 x i8]
%4 = alloca [17 x i8]
%5 = alloca i32
%6 = alloca i32
store i64 %0, i64* %2
%7 = bitcast [11 x i8]* %3 to i8*
%8 = bitcast [17 x i8]* %4 to i8*
store i32 9, i32* %5
br label %9
9: ; preds = %29, %1
%10 = load i32, i32* %5
%11 = icmp ugt i32 %10, 1
br i1 %11, label %12, label %32
12: ; preds = %9
%13 = load i64, i64* %2
%14 = urem i64 %13, 16
%15 = trunc i64 %14 to i32
store i32 %15, i32* %6
%16 = load i32, i32* %6
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = load i32, i32* %5
%21 = zext i32 %20 to i64
%22 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 %21
store i8 %19, i8* %22
%23 = load i64, i64* %2
%24 = udiv i64 %23, 16
store i64 %24, i64* %2
%25 = load i64, i64* %2
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %12
br label %32
28: ; preds = %12
br label %29
29: ; preds = %28
%30 = load i32, i32* %5
%31 = add i32 %30, -1
store i32 %31, i32* %5
br label %9
32: ; preds = %27, %9
%33 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
%34 = call i32 @print(i8* %33)
ret void
}

LLVM IR (-O2):
@__const.print_hex.buf = [11 x i8] c"0x00000000\00"
@__const.print_hex.hex = [17 x i8] c"0123456789ABCDEF\00"
define void @print_hex(i64 %0) {
%2 = alloca [11 x i8]
%3 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%4 = and i64 %0, 15
%5 = getelementptr inbounds [17 x i8], [17 x i8]* @__const.print_hex.hex, i64 0, i64 %4
%6 = load i8, i8* %5
%7 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 9
store i8 %6, i8* %7
%8 = icmp ult i64 %0, 16
br i1 %8, label %57, label %9
9: ; preds = %1
%10 = lshr i64 %0, 4
%11 = and i64 %10, 15
%12 = getelementptr inbounds [17 x i8], [17 x i8]* @__const.print_hex.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 = icmp ult i64 %0, 256
br i1 %15, label %57, label %16
16: ; preds = %9
%17 = lshr i64 %0, 8
%18 = and i64 %17, 15
%19 = getelementptr inbounds [17 x i8], [17 x i8]* @__const.print_hex.hex, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 7
store i8 %20, i8* %21
%22 = icmp ult i64 %0, 4096
br i1 %22, label %57, label %23
23: ; preds = %16
%24 = lshr i64 %0, 12
%25 = and i64 %24, 15
%26 = getelementptr inbounds [17 x i8], [17 x i8]* @__const.print_hex.hex, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 6
store i8 %27, i8* %28
%29 = icmp ult i64 %0, 65536
br i1 %29, label %57, label %30
30: ; preds = %23
%31 = lshr i64 %0, 16
%32 = and i64 %31, 15
%33 = getelementptr inbounds [17 x i8], [17 x i8]* @__const.print_hex.hex, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 5
store i8 %34, i8* %35
%36 = icmp ult i64 %0, 1048576
br i1 %36, label %57, label %37
37: ; preds = %30
%38 = lshr i64 %0, 20
%39 = and i64 %38, 15
%40 = getelementptr inbounds [17 x i8], [17 x i8]* @__const.print_hex.hex, i64 0, i64 %39
%41 = load i8, i8* %40
%42 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 4
store i8 %41, i8* %42
%43 = icmp ult i64 %0, 16777216
br i1 %43, label %57, label %44
44: ; preds = %37
%45 = lshr i64 %0, 24
%46 = and i64 %45, 15
%47 = getelementptr inbounds [17 x i8], [17 x i8]* @__const.print_hex.hex, i64 0, i64 %46
%48 = load i8, i8* %47
%49 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 3
store i8 %48, i8* %49
%50 = icmp ult i64 %0, 268435456
br i1 %50, label %57, label %51
51: ; preds = %44
%52 = lshr i64 %0, 28
%53 = and i64 %52, 15
%54 = getelementptr inbounds [17 x i8], [17 x i8]* @__const.print_hex.hex, i64 0, i64 %53
%55 = load i8, i8* %54
%56 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 2
store i8 %55, i8* %56
br label %57
57: ; preds = %51, %44, %37, %30, %23, %16, %9, %1
%58 = call i32 @print(i8* %3)
ret void
}