#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*/ ft_putnbr_p(unsigned long);
int /*<<< orphan*/ ft_putstr_prntf(char *);
int ft_printf_p(unsigned long nbr) {
  int ret;
  unsigned long copy;
  copy = nbr;
  ret = 0;
  if (nbr == 0)
    ret++;
  while (nbr >= 1) {
    nbr = nbr / 16;
    ret++;
  }
  ft_putstr_prntf("0x");
  ft_putnbr_p(copy);
  return (ret + 2);
}


x86 assembly (clang, -O0):
<ft_printf_p>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    114f <ft_printf_p+0x2f>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1154 <ft_printf_p+0x34>
cmpq   $0x1,-0x8(%rbp)
jb     1179 <ft_printf_p+0x59>
mov    -0x8(%rbp),%rax
shr    $0x4,%rax
mov    %rax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1154 <ft_printf_p+0x34>
lea    0xe80(%rip),%rdi
call   1030 <ft_putstr_prntf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <ft_putnbr_p@plt>
mov    -0xc(%rbp),%eax
add    $0x2,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_printf_p>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
test   %rdi,%rdi
je     1152 <ft_printf_p+0x32>
mov    $0x2,%ebp
mov    %rbx,%rcx
mov    %rbx,%rax
cs nopw 0x0(%rax,%rax,1)
shr    $0x4,%rax
add    $0x1,%ebp
cmp    $0xf,%rcx
mov    %rax,%rcx
ja     1140 <ft_printf_p+0x20>
jmp    1157 <ft_printf_p+0x37>
mov    $0x3,%ebp
lea    0xea2(%rip),%rdi
call   1030 <ft_putstr_prntf@plt>
mov    %rbx,%rdi
call   1040 <ft_putnbr_p@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"0x\00"
define i32 @ft_printf_p(i64 %0) {
%2 = alloca i64
%3 = alloca i32
%4 = alloca i64
store i64 %0, i64* %2
%5 = load i64, i64* %2
store i64 %5, i64* %4
store i32 0, i32* %3
%6 = load i64, i64* %2
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load i32, i32* %3
%10 = add nsw i32 %9, 1
store i32 %10, i32* %3
br label %11
11: ; preds = %8, %1
br label %12
12: ; preds = %15, %11
%13 = load i64, i64* %2
%14 = icmp uge i64 %13, 1
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = load i64, i64* %2
%17 = udiv i64 %16, 16
store i64 %17, i64* %2
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
br label %12
20: ; preds = %12
%21 = call i32 @ft_putstr_prntf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%22 = load i64, i64* %4
%23 = call i32 @ft_putnbr_p(i64 %22)
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 2
ret i32 %25
}

LLVM IR (-O2):
@.str = [3 x i8] c"0x\00"
define i32 @ft_printf_p(i64 %0) {
%2 = icmp eq i64 %0, 0
br i1 %2, label %11, label %3
3: ; preds = %1, %3
%4 = phi i64 [ %6, %3 ], [ %0, %1 ]
%5 = phi i32 [ %7, %3 ], [ 0, %1 ]
%6 = lshr i64 %4, 4
%7 = add nuw nsw i32 %5, 1
%8 = icmp ult i64 %4, 16
br i1 %8, label %9, label %3
9: ; preds = %3
%10 = add nuw i32 %5, 3
br label %11
11: ; preds = %9, %1
%12 = phi i32 [ 3, %1 ], [ %10, %9 ]
%13 = tail call i32 @ft_putstr_prntf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%14 = tail call i32 @ft_putnbr_p(i64 %0)
ret i32 %12
}