#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, ...);
void ft_putnbr(int n) {
  if (n == -2147483648)
    write(1, "-2147483648", 11);
  else {
    if (n < 0) {
      write(1, "-", 1);
      n = -n;
    }
    if (n < 10) {
      n = n + 48;
      write(1, &n, 1);
    } else {
      ft_putnbr(n / 10);
      ft_putnbr(n % 10);
    }
  }
}


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    1158 <ft_putnbr+0x38>
mov    $0x1,%edi
lea    0xeb9(%rip),%rsi
mov    $0xb,%edx
mov    $0x0,%al
call   1030 <write@plt>
jmp    11d2 <ft_putnbr+0xb2>
cmpl   $0x0,-0x4(%rbp)
jge    117f <ft_putnbr+0x5f>
mov    $0x1,%edx
lea    0xe9e(%rip),%rsi
mov    %edx,%edi
mov    $0x0,%al
call   1030 <write@plt>
xor    %eax,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
cmpl   $0xa,-0x4(%rbp)
jge    11a9 <ft_putnbr+0x89>
mov    -0x4(%rbp),%eax
add    $0x30,%eax
mov    %eax,-0x4(%rbp)
mov    $0x1,%edx
lea    -0x4(%rbp),%rsi
mov    %edx,%edi
mov    $0x0,%al
call   1030 <write@plt>
jmp    11cd <ft_putnbr+0xad>
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
call   1040 <ft_putnbr@plt>
jmp    11d2 <ft_putnbr+0xb2>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_putnbr>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x80000000,%edi
jne    1159 <ft_putnbr+0x39>
movl   $0x80000000,0x4(%rsp)
80
lea    0xec2(%rip),%rsi
mov    $0x1,%edi
mov    $0xb,%edx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <write@plt>
mov    %edi,%ebp
lea    0xeaa(%rip),%r14
mov    $0xcccccccd,%r15d
test   %ebp,%ebp
jns    1186 <ft_putnbr+0x66>
nopl   0x0(%rax)
mov    $0x1,%edi
mov    %r14,%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
neg    %ebp
cmp    $0x9,%ebp
jbe    11a9 <ft_putnbr+0x89>
mov    %ebp,%ebx
imul   %r15,%rbx
shr    $0x23,%rbx
mov    %ebx,%edi
call   1040 <ft_putnbr@plt>
add    %ebx,%ebx
lea    (%rbx,%rbx,4),%eax
sub    %eax,%ebp
test   %ebp,%ebp
jns    1186 <ft_putnbr+0x66>
jmp    1170 <ft_putnbr+0x50>
add    $0x30,%ebp
mov    %ebp,0x4(%rsp)
lea    0x4(%rsp),%rsi
mov    $0x1,%edi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
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
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = sext i32 %3 to i64
%5 = icmp eq i64 %4, -2147483648
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = call i32 (i32, ...) @write(i32 1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 11)
br label %28
8: ; preds = %1
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = call i32 (i32, ...) @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%13 = load i32, i32* %2
%14 = sub nsw i32 0, %13
store i32 %14, i32* %2
br label %15
15: ; preds = %11, %8
%16 = load i32, i32* %2
%17 = icmp slt i32 %16, 10
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = load i32, i32* %2
%20 = add nsw i32 %19, 48
store i32 %20, i32* %2
%21 = call i32 (i32, ...) @write(i32 1, i32* %2, i32 1)
br label %27
22: ; preds = %15
%23 = load i32, i32* %2
%24 = sdiv i32 %23, 10
%25 = load i32, i32* %2
%26 = srem i32 %25, 10
br label %27
27: ; preds = %22, %18
br label %28
28: ; preds = %27, %6
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 i32
%3 = icmp eq i32 %0, -2147483648
br i1 %3, label %4, label %6
4: ; preds = %1
store i32 -2147483648, i32* %2
%5 = tail call i32 (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, %18
%7 = phi i32 [ %20, %18 ], [ %0, %1 ]
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = tail call i32 (i32, ...) @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%11 = sub nsw i32 0, %7
br label %12
12: ; preds = %9, %6
%13 = phi i32 [ %11, %9 ], [ %7, %6 ]
%14 = icmp ult i32 %13, 10
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = add nuw nsw i32 %13, 48
store i32 %16, i32* %2
%17 = call i32 (i32, ...) @write(i32 1, i32* %2, i32 1)
br label %21
18: ; preds = %12
%19 = udiv i32 %13, 10
tail call void @ft_putnbr(i32 %19)
%20 = urem i32 %13, 10
br label %6
21: ; preds = %15, %4
ret void
}