#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(long);
void pprint(void *ptr) {
  int i;
  long adress = (long)ptr;
  kprint("0x");
  for (i = 7; i >= 0; i--)
    puthexdig((adress >> 4 * i) & 0xf);
  return;
}


x86 assembly (clang, -O0):
<pprint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    0xec5(%rip),%rdi
call   1030 <kprint@plt>
movl   $0x7,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     1179 <pprint+0x59>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%eax
shl    $0x2,%eax
mov    %eax,%eax
mov    %eax,%ecx
sar    %cl,%rdi
and    $0xf,%rdi
call   1040 <puthexdig@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1147 <pprint+0x27>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pprint>:
push   %rbx
mov    %rdi,%rbx
lea    0xed5(%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    %rbx,%rdi
pop    %rbx
jmp    1040 <puthexdig@plt>

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

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