#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*/ write(int, char *, int);
void ft_putnbr(int nb) {
  char c;
  if (nb == -2147483648) {
    write(1, "-2147483648", 11);
    return;
  }
  if (nb < 0) {
    write(1, "-", 1);
    nb = 0 - nb;
  }
  if (nb >= 10)
    ft_putnbr(nb / 10);
  c = '0' + nb % 10;
  write(1, &c, 1);
}


x86 assembly (clang, -O0):
<ft_putnbr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movslq -0x4(%rbp),%rax
cmp    $0xffffffff80000000,%rax
jne    1156 <ft_putnbr+0x36>
mov    $0x1,%edi
lea    0xeb9(%rip),%rsi
mov    $0xb,%edx
call   1030 <write@plt>
jmp    11ba <ft_putnbr+0x9a>
cmpl   $0x0,-0x4(%rbp)
jge    117b <ft_putnbr+0x5b>
mov    $0x1,%edx
lea    0xea0(%rip),%rsi
mov    %edx,%edi
call   1030 <write@plt>
xor    %eax,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
cmpl   $0xa,-0x4(%rbp)
jl     1197 <ft_putnbr+0x77>
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
add    $0x30,%edx
mov    %dl,%al
mov    %al,-0x5(%rbp)
mov    $0x1,%edx
lea    -0x5(%rbp),%rsi
mov    %edx,%edi
call   1030 <write@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_putnbr>:
cmp    $0x80000000,%edi
jne    113e <ft_putnbr+0x1e>
lea    0xed1(%rip),%rsi
mov    $0x1,%edi
mov    $0xb,%edx
jmp    1030 <write@plt>
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
test   %edi,%edi
jns    1160 <ft_putnbr+0x40>
lea    0xebd(%rip),%rsi
mov    $0x1,%edi
mov    $0x1,%edx
call   1030 <write@plt>
neg    %ebx
mov    %ebx,%r14d
cmp    $0xa,%ebx
jb     117a <ft_putnbr+0x5a>
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,%bl
mov    %bl,0x7(%rsp)
lea    0x7(%rsp),%rsi
mov    $0x1,%edi
mov    $0x1,%edx
call   1030 <write@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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