#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*/ kprint(char *);
int /*<<< orphan*/ puthexdig(int);
void hexprint(int number) {
  int i;
  kprint("0x");
  for (i = 7; i >= 0; i--)
    puthexdig((number >> 4 * i) & 0xf);
  return;
}


x86 assembly (clang, -O0):
<hexprint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xece(%rip),%rdi
call   1030 <kprint@plt>
movl   $0x7,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     1169 <hexprint+0x49>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%ecx
shl    $0x2,%ecx
sar    %cl,%edi
and    $0xf,%edi
call   1040 <puthexdig@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    113e <hexprint+0x1e>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hexprint>:
push   %rbx
mov    %edi,%ebx
lea    0xed6(%rip),%rdi
call   1030 <kprint@plt>
mov    %ebx,%edi
shr    $0x1c,%edi
call   1040 <puthexdig@plt>
mov    %ebx,%edi
shr    $0x18,%edi
and    $0xf,%edi
call   1040 <puthexdig@plt>
mov    %ebx,%edi
shr    $0x14,%edi
and    $0xf,%edi
call   1040 <puthexdig@plt>
mov    %ebx,%edi
shr    $0x10,%edi
and    $0xf,%edi
call   1040 <puthexdig@plt>
mov    %ebx,%edi
shr    $0xc,%edi
and    $0xf,%edi
call   1040 <puthexdig@plt>
mov    %ebx,%edi
shr    $0x8,%edi
and    $0xf,%edi
call   1040 <puthexdig@plt>
mov    %ebx,%edi
shr    $0x4,%edi
and    $0xf,%edi
call   1040 <puthexdig@plt>
and    $0xf,%ebx
mov    %ebx,%edi
pop    %rbx
jmp    1040 <puthexdig@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"0x\00"
define void @hexprint(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = call i32 @kprint(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 7, i32* %3
br label %5
5: ; preds = %15, %1
%6 = load i32, i32* %3
%7 = icmp sge i32 %6, 0
br i1 %7, label %8, label %18
8: ; preds = %5
%9 = load i32, i32* %2
%10 = load i32, i32* %3
%11 = mul nsw i32 4, %10
%12 = ashr i32 %9, %11
%13 = and i32 %12, 15
%14 = call i32 @puthexdig(i32 %13)
br label %15
15: ; preds = %8
%16 = load i32, i32* %3
%17 = add nsw i32 %16, -1
store i32 %17, i32* %3
br label %5
18: ; preds = %5
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"0x\00"
define void @hexprint(i32 %0) {
%2 = tail call i32 @kprint(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = lshr i32 %0, 28
%4 = tail call i32 @puthexdig(i32 %3)
%5 = lshr i32 %0, 24
%6 = and i32 %5, 15
%7 = tail call i32 @puthexdig(i32 %6)
%8 = lshr i32 %0, 20
%9 = and i32 %8, 15
%10 = tail call i32 @puthexdig(i32 %9)
%11 = lshr i32 %0, 16
%12 = and i32 %11, 15
%13 = tail call i32 @puthexdig(i32 %12)
%14 = lshr i32 %0, 12
%15 = and i32 %14, 15
%16 = tail call i32 @puthexdig(i32 %15)
%17 = lshr i32 %0, 8
%18 = and i32 %17, 15
%19 = tail call i32 @puthexdig(i32 %18)
%20 = lshr i32 %0, 4
%21 = and i32 %20, 15
%22 = tail call i32 @puthexdig(i32 %21)
%23 = and i32 %0, 15
%24 = tail call i32 @puthexdig(i32 %23)
ret void
}