#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);
int /*<<< orphan*/ ft_putstr(char *);
void ft_putnbr(int nbr) {
  if (nbr < 0) {
    if (nbr == -2147483648) {
      ft_putstr("-2147483648");
      return;
    }
    ft_putchar('-');
    nbr = -1 * nbr;
  }
  if (nbr / 10 > 0)
    ft_putnbr(nbr / 10);
  else {
    ft_putchar(nbr + '0');
    return;
  }
  ft_putchar(nbr % 10 + '0');
}


x86 assembly (clang, -O0):
<ft_putnbr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    117a <ft_putnbr+0x4a>
movslq -0x4(%rbp),%rax
cmp    $0xffffffff80000000,%rax
jne    1166 <ft_putnbr+0x36>
lea    0xea4(%rip),%rdi
call   1050 <ft_putstr@plt>
jmp    11ca <ft_putnbr+0x9a>
mov    $0x2d,%edi
call   1030 <ft_putchar@plt>
imul   $0xffffffff,-0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%eax
jle    11a5 <ft_putnbr+0x75>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1040 <ft_putnbr@plt>
jmp    11b5 <ft_putnbr+0x85>
mov    -0x4(%rbp),%edi
add    $0x30,%edi
call   1030 <ft_putchar@plt>
jmp    11ca <ft_putnbr+0x9a>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
add    $0x30,%edi
call   1030 <ft_putchar@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_putnbr>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
test   %edi,%edi
js     1160 <ft_putnbr+0x30>
cmp    $0xa,%ebp
jb     118b <ft_putnbr+0x5b>
mov    %ebp,%eax
mov    $0xcccccccd,%ebx
imul   %rax,%rbx
shr    $0x23,%rbx
mov    %ebx,%edi
call   1040 <ft_putnbr@plt>
add    %ebx,%ebx
lea    (%rbx,%rbx,4),%eax
sub    %eax,%ebp
or     $0x30,%ebp
jmp    118e <ft_putnbr+0x5e>
cmp    $0x80000000,%ebp
jne    117a <ft_putnbr+0x4a>
lea    0xe91(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <ft_putstr@plt>
mov    $0x2d,%edi
call   1030 <ft_putchar@plt>
neg    %ebp
cmp    $0xa,%ebp
jae    113e <ft_putnbr+0xe>
add    $0x30,%ebp
mov    %ebp,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <ft_putchar@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"-2147483648\00"
define void @ft_putnbr(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp slt i32 %3, 0
br i1 %4, label %5, label %15
5: ; preds = %1
%6 = load i32, i32* %2
%7 = sext i32 %6 to i64
%8 = icmp eq i64 %7, -2147483648
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = call i32 @ft_putstr(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %31
11: ; preds = %5
%12 = call i32 @ft_putchar(i32 45)
%13 = load i32, i32* %2
%14 = mul nsw i32 -1, %13
store i32 %14, i32* %2
br label %15
15: ; preds = %11, %1
%16 = load i32, i32* %2
%17 = sdiv i32 %16, 10
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = load i32, i32* %2
%21 = sdiv i32 %20, 10
br label %26
22: ; preds = %15
%23 = load i32, i32* %2
%24 = add nsw i32 %23, 48
%25 = call i32 @ft_putchar(i32 %24)
br label %31
26: ; preds = %19
%27 = load i32, i32* %2
%28 = srem i32 %27, 10
%29 = add nsw i32 %28, 48
%30 = call i32 @ft_putchar(i32 %29)
br label %31
31: ; preds = %26, %22, %9
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"-2147483648\00"
define void @ft_putnbr(i32 %0) {
%2 = icmp slt i32 %0, 0
br i1 %2, label %3, label %10
3: ; preds = %1
%4 = icmp eq i32 %0, -2147483648
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 @ft_putstr(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %13
7: ; preds = %3
%8 = tail call i32 @ft_putchar(i32 45)
%9 = sub nsw i32 0, %0
br label %10
10: ; preds = %7, %1
%11 = phi i32 [ %9, %7 ], [ %0, %1 ]
%12 = icmp ugt i32 %11, 9
br i1 %12, label %14, label %19
13: ; preds = %5, %19, %14
ret void
14: ; preds = %10
%15 = udiv i32 %11, 10
tail call void @ft_putnbr(i32 %15)
%16 = urem i32 %11, 10
%17 = or i32 %16, 48
%18 = tail call i32 @ft_putchar(i32 %17)
br label %13
19: ; preds = %10
%20 = add nuw nsw i32 %11, 48
%21 = tail call i32 @ft_putchar(i32 %20)
br label %13
}