#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_fd(char, int);
int /*<<< orphan*/ ft_putn_fd(int, int);
int /*<<< orphan*/ ft_putstr_fd(char *, int);
void ft_putnbr_fd(int n, int fd) {
  if (n == 2147483647) {
    ft_putstr_fd("2147483647", fd);
    return;
  }
  if (n == -2147483648) {
    ft_putstr_fd("-2147483648", fd);
    return;
  }
  if (n < 0) {
    n *= -1;
    ft_putchar_fd('-', fd);
  }
  ft_putn_fd(n, fd);
}


x86 assembly (clang, -O0):
<ft_putnbr_fd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x7fffffff,-0x4(%rbp)
jne    115f <ft_putnbr_fd+0x2f>
mov    -0x8(%rbp),%esi
lea    0xeab(%rip),%rdi
call   1040 <ft_putstr_fd@plt>
jmp    11ac <ft_putnbr_fd+0x7c>
movslq -0x4(%rbp),%rax
cmp    $0xffffffff80000000,%rax
jne    1183 <ft_putnbr_fd+0x53>
mov    -0x8(%rbp),%esi
lea    0xe92(%rip),%rdi
call   1040 <ft_putstr_fd@plt>
jmp    11ac <ft_putnbr_fd+0x7c>
cmpl   $0x0,-0x4(%rbp)
jge    11a1 <ft_putnbr_fd+0x71>
imul   $0xffffffff,-0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%esi
mov    $0x2d,%edi
call   1050 <ft_putchar_fd@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <ft_putn_fd@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_putnbr_fd>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
cmp    $0x80000000,%edi
je     1150 <ft_putnbr_fd+0x20>
mov    %edi,%ebp
cmp    $0x7fffffff,%edi
jne    1164 <ft_putnbr_fd+0x34>
lea    0xeb2(%rip),%rdi
jmp    1157 <ft_putnbr_fd+0x27>
lea    0xeb4(%rip),%rdi
mov    %ebx,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <ft_putstr_fd@plt>
test   %ebp,%ebp
jns    1176 <ft_putnbr_fd+0x46>
neg    %ebp
mov    $0x2d,%edi
mov    %ebx,%esi
call   1050 <ft_putchar_fd@plt>
mov    %ebp,%edi
mov    %ebx,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <ft_putn_fd@plt>

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

LLVM IR (-O2):
@.str = [11 x i8] c"2147483647\00"
@.str.1 = [12 x i8] c"-2147483648\00"
define void @ft_putnbr_fd(i32 %0, i32 %1) {
switch i32 %0, label %7 [
i32 2147483647, label %3
i32 -2147483648, label %5
]
3: ; preds = %2
%4 = tail call i32 @ft_putstr_fd(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %1)
br label %15
5: ; preds = %2
%6 = tail call i32 @ft_putstr_fd(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %1)
br label %15
7: ; preds = %2
%8 = icmp slt i32 %0, 0
br i1 %8, label %9, label %12
9: ; preds = %7
%10 = sub nsw i32 0, %0
%11 = tail call i32 @ft_putchar_fd(i8 signext 45, i32 %1)
br label %12
12: ; preds = %9, %7
%13 = phi i32 [ %10, %9 ], [ %0, %7 ]
%14 = tail call i32 @ft_putn_fd(i32 %13, i32 %1)
br label %15
15: ; preds = %12, %5, %3
ret void
}