#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_putchar(int);
void ft_putnbr(int nb) {
  int neg;
  neg = 0;
  if (nb) {
    if (nb < 0) {
      ft_putchar('-');
      if (nb / 10)
        ft_putnbr(nb / -10);
      ft_putchar((-(nb + 1) % 10) + 49);
    } else {
      if (nb / 10)
        ft_putnbr(nb / 10);
      ft_putchar(nb % 10 + 48);
    }
    return;
  }
  ft_putchar('0');
}


x86 assembly (clang, -O0):
<ft_putnbr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     11d7 <ft_putnbr+0xb7>
cmpl   $0x0,-0x4(%rbp)
jge    1197 <ft_putnbr+0x77>
mov    $0x2d,%edi
call   1030 <ft_putchar@plt>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%eax
je     1176 <ft_putnbr+0x56>
mov    -0x4(%rbp),%eax
mov    $0xfffffff6,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1040 <ft_putnbr@plt>
mov    -0x4(%rbp),%ecx
add    $0x1,%ecx
xor    %eax,%eax
sub    %ecx,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
add    $0x31,%edi
call   1030 <ft_putchar@plt>
jmp    11d2 <ft_putnbr+0xb2>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%eax
je     11bd <ft_putnbr+0x9d>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1040 <ft_putnbr@plt>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
add    $0x30,%edi
call   1030 <ft_putchar@plt>
jmp    11e1 <ft_putnbr+0xc1>
mov    $0x30,%edi
call   1030 <ft_putchar@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_putnbr>:
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
je     115f <ft_putnbr+0x3f>
mov    %edi,%ebx
js     1166 <ft_putnbr+0x46>
mov    %ebx,%r14d
cmp    $0xa,%ebx
jb     1146 <ft_putnbr+0x26>
mov    $0xcccccccd,%edi
imul   %r14,%rdi
shr    $0x23,%rdi
call   1040 <ft_putnbr@plt>
mov    $0xcccccccd,%eax
imul   %r14,%rax
shr    $0x23,%rax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ebx
or     $0x30,%ebx
jmp    11b4 <ft_putnbr+0x94>
mov    $0x30,%ebx
jmp    11b4 <ft_putnbr+0x94>
mov    $0x2d,%edi
call   1030 <ft_putchar@plt>
lea    0x9(%rbx),%eax
cmp    $0x13,%eax
jb     118e <ft_putnbr+0x6e>
mov    %ebx,%eax
neg    %eax
mov    $0xcccccccd,%edi
imul   %rax,%rdi
shr    $0x23,%rdi
call   1040 <ft_putnbr@plt>
not    %ebx
movslq %ebx,%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
neg    %ecx
lea    (%rax,%rcx,1),%ebx
add    $0x31,%ebx
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <ft_putchar@plt>

LLVM IR (-O0):
define void @ft_putnbr(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
%4 = load i32, i32* %2
%5 = icmp ne i32 %4, 0
br i1 %5, label %6, label %37
6: ; preds = %1
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %24
9: ; preds = %6
%10 = call i32 @ft_putchar(i32 45)
%11 = load i32, i32* %2
%12 = sdiv i32 %11, 10
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %9
%15 = load i32, i32* %2
%16 = sdiv i32 %15, -10
br label %17
17: ; preds = %14, %9
%18 = load i32, i32* %2
%19 = add nsw i32 %18, 1
%20 = sub nsw i32 0, %19
%21 = srem i32 %20, 10
%22 = add nsw i32 %21, 49
%23 = call i32 @ft_putchar(i32 %22)
br label %36
24: ; preds = %6
%25 = load i32, i32* %2
%26 = sdiv i32 %25, 10
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %24
%29 = load i32, i32* %2
%30 = sdiv i32 %29, 10
br label %31
31: ; preds = %28, %24
%32 = load i32, i32* %2
%33 = srem i32 %32, 10
%34 = add nsw i32 %33, 48
%35 = call i32 @ft_putchar(i32 %34)
br label %36
36: ; preds = %31, %17
br label %39
37: ; preds = %1
%38 = call i32 @ft_putchar(i32 48)
br label %39
39: ; preds = %37, %36
ret void
}

LLVM IR (-O2):
define void @ft_putnbr(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %23, label %3
3: ; preds = %1
%4 = icmp slt i32 %0, 0
br i1 %4, label %5, label %16
5: ; preds = %3
%6 = tail call i32 @ft_putchar(i32 45)
%7 = add nsw i32 %0, 9
%8 = icmp ult i32 %7, 19
br i1 %8, label %12, label %9
9: ; preds = %5
%10 = sub i32 0, %0
%11 = udiv i32 %10, 10
tail call void @ft_putnbr(i32 %11)
br label %12
12: ; preds = %9, %5
%13 = xor i32 %0, -1
%14 = srem i32 %13, 10
%15 = add nsw i32 %14, 49
br label %23
16: ; preds = %3
%17 = icmp ult i32 %0, 10
br i1 %17, label %20, label %18
18: ; preds = %16
%19 = udiv i32 %0, 10
tail call void @ft_putnbr(i32 %19)
br label %20
20: ; preds = %18, %16
%21 = urem i32 %0, 10
%22 = or i32 %21, 48
br label %23
23: ; preds = %1, %12, %20
%24 = phi i32 [ %15, %12 ], [ %22, %20 ], [ 48, %1 ]
%25 = tail call i32 @ft_putchar(i32 %24)
ret void
}