#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_o(int);
int /*<<< orphan*/ ft_putstr_prntf(char *);
int ft_printf_o(unsigned int nbr) {
  int ret;
  int copy;
  copy = nbr;
  ret = 0;
  if (nbr <= 0) {
    ft_putstr_prntf("0");
    return (1);
  }
  while (nbr >= 1) {
    nbr = nbr / 8;
    ret++;
  }
  ft_putnbr_o(copy);
  return (ret);
}


x86 assembly (clang, -O0):
<ft_printf_o>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
ja     115a <ft_printf_o+0x3a>
lea    0xeb7(%rip),%rdi
call   1040 <ft_putstr_prntf@plt>
movl   $0x1,-0x4(%rbp)
jmp    118e <ft_printf_o+0x6e>
jmp    115f <ft_printf_o+0x3f>
cmpl   $0x1,-0x8(%rbp)
jb     1180 <ft_printf_o+0x60>
mov    -0x8(%rbp),%eax
shr    $0x3,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115f <ft_printf_o+0x3f>
mov    -0x10(%rbp),%edi
call   1030 <ft_putnbr_o@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_printf_o>:
push   %rbx
test   %edi,%edi
je     1144 <ft_printf_o+0x24>
xor    %ebx,%ebx
mov    %edi,%ecx
mov    %edi,%eax
nopl   0x0(%rax,%rax,1)
shr    $0x3,%eax
add    $0x1,%ebx
cmp    $0x7,%ecx
mov    %eax,%ecx
ja     1130 <ft_printf_o+0x10>
call   1030 <ft_putnbr_o@plt>
jmp    1155 <ft_printf_o+0x35>
lea    0xeb5(%rip),%rdi
call   1040 <ft_putstr_prntf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
ret

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

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