#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);
void ft_putint(int i) {
  int tab2[10];
  int cprim;
  int c = 0;
  if (i < 0) {
    i = -i;
  }
  int tab[] = {1,      10,      100,      1000,      10000,
               100000, 1000000, 10000000, 100000000, 1000000000};
  int *ptr = tab;
  while (*(ptr + c) < i) {
    c++;
  }
  cprim = c;
  while (c >= 1) {
    tab2[c - 1] = (i / tab[c - 1]) % 10;
    c--;
  }
  while (cprim >= 1) {
    ft_putchar((char)tab2[cprim - 1] + 48);
    cprim--;
  }
}


x86 assembly (clang, -O0):
<ft_putint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x38(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    1144 <ft_putint+0x24>
xor    %eax,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xeb1(%rip),%rsi
mov    $0x28,%edx
call   1030 <memcpy@plt>
lea    -0x60(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x4(%rbp),%eax
jge    1183 <ft_putint+0x63>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1161 <ft_putint+0x41>
mov    -0x38(%rbp),%eax
mov    %eax,-0x34(%rbp)
cmpl   $0x1,-0x38(%rbp)
jl     11c6 <ft_putint+0xa6>
mov    -0x4(%rbp),%eax
mov    -0x38(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
cltd
idivl  -0x60(%rbp,%rcx,4)
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x38(%rbp),%eax
sub    $0x1,%eax
cltq
mov    %edx,-0x30(%rbp,%rax,4)
mov    -0x38(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x38(%rbp)
jmp    1189 <ft_putint+0x69>
jmp    11cb <ft_putint+0xab>
cmpl   $0x1,-0x34(%rbp)
jl     11fd <ft_putint+0xdd>
mov    -0x34(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x30(%rbp,%rax,4),%eax
movsbl %al,%eax
add    $0x30,%eax
movsbl %al,%edi
call   1040 <ft_putchar@plt>
mov    -0x34(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x34(%rbp)
jmp    11cb <ft_putint+0xab>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_putint>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %edi,%r9d
neg    %r9d
cmovs  %edi,%r9d
xor    %esi,%esi
lea    0xed3(%rip),%rax
nopl   (%rax)
add    $0xffffffff,%esi
lea    0x4(%rax),%rdx
cmp    %r9d,(%rax)
mov    %rdx,%rax
jl     1130 <ft_putint+0x20>
cmp    $0xffffffff,%esi
je     11df <ft_putint+0xcf>
mov    %esi,%r14d
neg    %r14d
mov    %esi,%r15d
not    %r15d
lea    -0x1(%r15),%rdi
lea    0xea1(%rip),%r8
mov    %r14d,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %edi,%ecx
shl    $0x2,%rcx
mov    %r9d,%eax
cltd
idivl  (%rcx,%r8,1)
cltq
imul   $0x66666667,%rax,%rdx
mov    %rdx,%rbx
shr    $0x3f,%rbx
sar    $0x22,%rdx
add    %ebx,%edx
add    %edx,%edx
lea    (%rdx,%rdx,4),%edx
sub    %edx,%eax
mov    %eax,(%rsp,%rcx,1)
add    $0xffffffff,%ebp
add    $0xffffffffffffffff,%rdi
cmp    $0x1,%ebp
jg     1170 <ft_putint+0x60>
cmp    $0xffffffff,%esi
je     11df <ft_putint+0xcf>
add    $0xffffffffffffffff,%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15d,%eax
movzbl (%rsp,%rax,4),%eax
add    $0x30,%al
movsbl %al,%edi
call   1030 <ft_putchar@plt>
add    $0xffffffff,%r14d
add    $0xffffffffffffffff,%r15
cmp    $0x1,%r14d
jg     11c0 <ft_putint+0xb0>
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.ft_putint.tab = [10 x i32] [i32 1, i32 10, i32 100, i32 1000, i32 10000, i32 100000, i32 1000000, i32 10000000, i32 100000000, i32 1000000000]
define void @ft_putint(i32 %0) {
%2 = alloca i32
%3 = alloca [10 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca [10 x i32]
%7 = alloca i32*
store i32 %0, i32* %2
store i32 0, i32* %5
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = load i32, i32* %2
%12 = sub nsw i32 0, %11
store i32 %12, i32* %2
br label %13
13: ; preds = %10, %1
%14 = bitcast [10 x i32]* %6 to i8*
%15 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 0
store i32* %15, i32** %7
br label %16
16: ; preds = %24, %13
%17 = load i32*, i32** %7
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
%21 = load i32, i32* %20
%22 = load i32, i32* %2
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %27
24: ; preds = %16
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
store i32 %26, i32* %5
br label %16
27: ; preds = %16
%28 = load i32, i32* %5
store i32 %28, i32* %4
br label %29
29: ; preds = %32, %27
%30 = load i32, i32* %5
%31 = icmp sge i32 %30, 1
br i1 %31, label %32, label %47
32: ; preds = %29
%33 = load i32, i32* %2
%34 = load i32, i32* %5
%35 = sub nsw i32 %34, 1
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 %36
%38 = load i32, i32* %37
%39 = sdiv i32 %33, %38
%40 = srem i32 %39, 10
%41 = load i32, i32* %5
%42 = sub nsw i32 %41, 1
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 %43
store i32 %40, i32* %44
%45 = load i32, i32* %5
%46 = add nsw i32 %45, -1
store i32 %46, i32* %5
br label %29
47: ; preds = %29
br label %48
48: ; preds = %51, %47
%49 = load i32, i32* %4
%50 = icmp sge i32 %49, 1
br i1 %50, label %51, label %64
51: ; preds = %48
%52 = load i32, i32* %4
%53 = sub nsw i32 %52, 1
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 %54
%56 = load i32, i32* %55
%57 = trunc i32 %56 to i8
%58 = sext i8 %57 to i32
%59 = add nsw i32 %58, 48
%60 = trunc i32 %59 to i8
%61 = call i32 @ft_putchar(i8 signext %60)
%62 = load i32, i32* %4
%63 = add nsw i32 %62, -1
store i32 %63, i32* %4
br label %48
64: ; preds = %48
ret void
}

LLVM IR (-O2):
@__const.ft_putint.tab = [10 x i32] [i32 1, i32 10, i32 100, i32 1000, i32 10000, i32 100000, i32 1000000, i32 10000000, i32 100000000, i32 1000000000]
define void @ft_putint(i32 %0) {
%2 = alloca [10 x i32]
%3 = bitcast [10 x i32]* %2 to i8*
%4 = tail call i32 @llvm.abs.i32(i32 %0, i1 true)
br label %5
5: ; preds = %5, %1
%6 = phi i64 [ %10, %5 ], [ 0, %1 ]
%7 = getelementptr inbounds [10 x i32], [10 x i32]* @__const.ft_putint.tab, i64 0, i64 %6
%8 = load i32, i32* %7
%9 = icmp slt i32 %8, %4
%10 = add nuw i64 %6, 1
br i1 %9, label %5, label %11
11: ; preds = %5
%12 = trunc i64 %6 to i32
%13 = icmp eq i32 %12, 0
br i1 %13, label %41, label %14
14: ; preds = %11
%15 = and i64 %6, 4294967295
br label %19
16: ; preds = %19
br i1 %13, label %41, label %17
17: ; preds = %16
%18 = and i64 %6, 4294967295
br label %30
19: ; preds = %14, %19
%20 = phi i64 [ %15, %14 ], [ %21, %19 ]
%21 = add nsw i64 %20, -1
%22 = and i64 %21, 4294967295
%23 = getelementptr inbounds [10 x i32], [10 x i32]* @__const.ft_putint.tab, i64 0, i64 %22
%24 = load i32, i32* %23
%25 = sdiv i32 %4, %24
%26 = srem i32 %25, 10
%27 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %22
store i32 %26, i32* %27
%28 = trunc i64 %20 to i32
%29 = icmp sgt i32 %28, 1
br i1 %29, label %19, label %16
30: ; preds = %17, %30
%31 = phi i64 [ %18, %17 ], [ %32, %30 ]
%32 = add nsw i64 %31, -1
%33 = and i64 %32, 4294967295
%34 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %33
%35 = load i32, i32* %34
%36 = trunc i32 %35 to i8
%37 = add i8 %36, 48
%38 = tail call i32 @ft_putchar(i8 signext %37)
%39 = trunc i64 %31 to i32
%40 = icmp sgt i32 %39, 1
br i1 %40, label %30, label %41
41: ; preds = %30, %11, %16
ret void
}