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


x86 assembly (clang, -O0):
<ft_putnbr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jle    119b <ft_putnbr+0x6b>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%eax
je     1188 <ft_putnbr+0x58>
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
movsbl %al,%edi
call   1030 <ft_putchar@plt>
jmp    1196 <ft_putnbr+0x66>
mov    -0x4(%rbp),%eax
add    $0x30,%eax
movsbl %al,%edi
call   1030 <ft_putchar@plt>
jmp    11ee <ft_putnbr+0xbe>
movslq -0x4(%rbp),%rax
cmp    $0xffffffff80000000,%rax
jne    11c6 <ft_putnbr+0x96>
lea    0xe4e(%rip),%rdi
call   1050 <ft_putstr@plt>
mov    $0x8ca6c00,%edi
call   1040 <ft_putnbr@plt>
jmp    11e9 <ft_putnbr+0xb9>
cmpl   $0x0,-0x4(%rbp)
jge    11e4 <ft_putnbr+0xb4>
mov    $0x2d,%edi
call   1030 <ft_putchar@plt>
xor    %edi,%edi
sub    -0x4(%rbp),%edi
call   1040 <ft_putnbr@plt>
jmp    11e9 <ft_putnbr+0xb9>
jmp    11ee <ft_putnbr+0xbe>
cmpl   $0x0,-0x4(%rbp)
jne    1202 <ft_putnbr+0xd2>
mov    $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
jle    1144 <ft_putnbr+0x14>
cmp    $0xa,%ebp
jae    115d <ft_putnbr+0x2d>
add    $0x30,%bpl
jmp    117e <ft_putnbr+0x4e>
cmp    $0x80000000,%ebp
jne    118e <ft_putnbr+0x5e>
lea    0xead(%rip),%rdi
call   1050 <ft_putstr@plt>
mov    $0x8ca6c00,%ebp
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,%bpl
mov    %ebp,%eax
movsbl %al,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <ft_putchar@plt>
mov    $0x30,%al
test   %ebp,%ebp
jns    1180 <ft_putnbr+0x50>
mov    $0x2d,%edi
call   1030 <ft_putchar@plt>
neg    %ebp
cmp    $0xa,%ebp
jb     113e <ft_putnbr+0xe>
jmp    115d <ft_putnbr+0x2d>

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

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