#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);
void ft_putnbr(int n) {
  int i;
  int a[10];
  i = 0;
  if (n < 0) {
    ft_putchar('-');
    n = -n;
  }
  if (!n)
    ft_putchar('0');
  while (n) {
    *(a + i) = n % 10;
    n /= 10;
    i++;
  }
  while (i > 0) {
    i--;
    ft_putchar(*(a + i) + 48);
  }
}


x86 assembly (clang, -O0):
<ft_putnbr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    113e <ft_putnbr+0x2e>
mov    $0x2d,%edi
call   1030 <ft_putchar@plt>
xor    %eax,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1152 <ft_putnbr+0x42>
mov    $0x30,%edi
call   1030 <ft_putchar@plt>
jmp    1157 <ft_putnbr+0x47>
cmpl   $0x0,-0x4(%rbp)
je     1190 <ft_putnbr+0x80>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
movslq -0x8(%rbp),%rax
mov    %edx,-0x30(%rbp,%rax,4)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1157 <ft_putnbr+0x47>
jmp    1195 <ft_putnbr+0x85>
cmpl   $0x0,-0x8(%rbp)
jle    11bd <ft_putnbr+0xad>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
movslq -0x8(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edi
add    $0x30,%edi
call   1030 <ft_putchar@plt>
jmp    1195 <ft_putnbr+0x85>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_putnbr>:
push   %rbx
sub    $0x30,%rsp
mov    %edi,%ebx
test   %edi,%edi
js     112c <ft_putnbr+0x1c>
jne    1138 <ft_putnbr+0x28>
mov    $0x30,%edi
add    $0x30,%rsp
pop    %rbx
jmp    1030 <ft_putchar@plt>
mov    $0x2d,%edi
call   1030 <ft_putchar@plt>
neg    %ebx
xor    %eax,%eax
nopw   0x0(%rax,%rax,1)
movslq %ebx,%rcx
imul   $0x66666667,%rcx,%rbx
mov    %rbx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rbx
add    %edx,%ebx
lea    (%rbx,%rbx,1),%edx
lea    (%rdx,%rdx,4),%edx
mov    %ecx,%esi
sub    %edx,%esi
mov    %esi,(%rsp,%rax,4)
add    $0x1,%rax
add    $0x9,%ecx
cmp    $0x13,%ecx
jae    1140 <ft_putnbr+0x30>
test   %eax,%eax
jle    1198 <ft_putnbr+0x88>
mov    %eax,%ebx
add    $0x1,%rbx
nopw   0x0(%rax,%rax,1)
lea    -0x2(%rbx),%eax
mov    (%rsp,%rax,4),%edi
add    $0x30,%edi
call   1030 <ft_putchar@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     1180 <ft_putnbr+0x70>
add    $0x30,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define void @ft_putnbr(i32 %0) {
%2 = alloca [10 x i32]
%3 = bitcast [10 x i32]* %2 to i8*
%4 = icmp slt i32 %0, 0
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = tail call i32 @ft_putchar(i32 45)
%7 = sub nsw i32 0, %0
br label %10
8: ; preds = %1
%9 = icmp eq i32 %0, 0
br i1 %9, label %12, label %10
10: ; preds = %5, %8
%11 = phi i32 [ %0, %8 ], [ %7, %5 ]
br label %19
12: ; preds = %8
%13 = tail call i32 @ft_putchar(i32 48)
br label %37
14: ; preds = %19
%15 = trunc i64 %25 to i32
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %37
17: ; preds = %14
%18 = and i64 %25, 4294967295
br label %28
19: ; preds = %10, %19
%20 = phi i64 [ %25, %19 ], [ 0, %10 ]
%21 = phi i32 [ %24, %19 ], [ %11, %10 ]
%22 = srem i32 %21, 10
%23 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %20
store i32 %22, i32* %23
%24 = sdiv i32 %21, 10
%25 = add nuw i64 %20, 1
%26 = add i32 %21, 9
%27 = icmp ult i32 %26, 19
br i1 %27, label %14, label %19
28: ; preds = %17, %28
%29 = phi i64 [ %18, %17 ], [ %30, %28 ]
%30 = add nsw i64 %29, -1
%31 = and i64 %30, 4294967295
%32 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %31
%33 = load i32, i32* %32
%34 = add nsw i32 %33, 48
%35 = tail call i32 @ft_putchar(i32 %34)
%36 = icmp ugt i64 %29, 1
br i1 %36, label %28, label %37
37: ; preds = %28, %12, %14
ret void
}