#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_itoa_recursive(char **, int, int /*<<< orphan*/, int);
char *ft_itoa(int n) {
  char *str;
  if (n >= 0)
    ft_itoa_recursive(&str, n, 0, 0);
  else if (n == -2147483648) {
    ft_itoa_recursive(&str, 147483648, 0, 2);
    str[0] = '-';
    str[1] = '2';
  } else {
    ft_itoa_recursive(&str, n * (-1), 0, 1);
    str[0] = '-';
  }
  return (str);
}


x86 assembly (clang, -O0):
<ft_itoa>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     113a <ft_itoa+0x2a>
mov    -0x4(%rbp),%esi
lea    -0x10(%rbp),%rdi
xor    %ecx,%ecx
mov    %ecx,%edx
call   1030 <ft_itoa_recursive@plt>
jmp    1193 <ft_itoa+0x83>
movslq -0x4(%rbp),%rax
cmp    $0xffffffff80000000,%rax
jne    1173 <ft_itoa+0x63>
lea    -0x10(%rbp),%rdi
mov    $0x8ca6c00,%esi
xor    %edx,%edx
mov    $0x2,%ecx
call   1030 <ft_itoa_recursive@plt>
mov    -0x10(%rbp),%rax
movb   $0x2d,(%rax)
mov    -0x10(%rbp),%rax
movb   $0x32,0x1(%rax)
jmp    118e <ft_itoa+0x7e>
imul   $0xffffffff,-0x4(%rbp),%esi
lea    -0x10(%rbp),%rdi
xor    %edx,%edx
mov    $0x1,%ecx
call   1030 <ft_itoa_recursive@plt>
mov    -0x10(%rbp),%rax
movb   $0x2d,(%rax)
jmp    1193 <ft_itoa+0x83>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_itoa>:
push   %rax
mov    %edi,%esi
test   %edi,%edi
js     1125 <ft_itoa+0x15>
mov    %rsp,%rdi
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <ft_itoa_recursive@plt>
jmp    116a <ft_itoa+0x5a>
cmp    $0x80000000,%esi
jne    1152 <ft_itoa+0x42>
mov    %rsp,%rdi
mov    $0x8ca6c00,%esi
xor    %edx,%edx
mov    $0x2,%ecx
call   1030 <ft_itoa_recursive@plt>
mov    (%rsp),%rax
movb   $0x2d,(%rax)
mov    (%rsp),%rax
movb   $0x32,0x1(%rax)
jmp    116a <ft_itoa+0x5a>
neg    %esi
mov    %rsp,%rdi
xor    %edx,%edx
mov    $0x1,%ecx
call   1030 <ft_itoa_recursive@plt>
mov    (%rsp),%rax
movb   $0x2d,(%rax)
mov    (%rsp),%rax
pop    %rcx
ret

LLVM IR (-O0):
define i8* @ft_itoa(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = icmp sge i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = load i32, i32* %2
%8 = call i32 @ft_itoa_recursive(i8** %3, i32 %7, i32 0, i32 0)
br label %26
9: ; preds = %1
%10 = load i32, i32* %2
%11 = sext i32 %10 to i64
%12 = icmp eq i64 %11, -2147483648
br i1 %12, label %13, label %19
13: ; preds = %9
%14 = call i32 @ft_itoa_recursive(i8** %3, i32 147483648, i32 0, i32 2)
%15 = load i8*, i8** %3
%16 = getelementptr inbounds i8, i8* %15, i64 0
store i8 45, i8* %16
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i64 1
store i8 50, i8* %18
br label %25
19: ; preds = %9
%20 = load i32, i32* %2
%21 = mul nsw i32 %20, -1
%22 = call i32 @ft_itoa_recursive(i8** %3, i32 %21, i32 0, i32 1)
%23 = load i8*, i8** %3
%24 = getelementptr inbounds i8, i8* %23, i64 0
store i8 45, i8* %24
br label %25
25: ; preds = %19, %13
br label %26
26: ; preds = %25, %6
%27 = load i8*, i8** %3
ret i8* %27
}

LLVM IR (-O2):
define i8* @ft_itoa(i32 %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = icmp sgt i32 %0, -1
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = call i32 @ft_itoa_recursive(i8** %2, i32 %0, i32 0, i32 0)
br label %18
7: ; preds = %1
%8 = icmp eq i32 %0, -2147483648
br i1 %8, label %9, label %14
9: ; preds = %7
%10 = call i32 @ft_itoa_recursive(i8** %2, i32 147483648, i32 0, i32 2)
%11 = load i8*, i8** %2
store i8 45, i8* %11
%12 = load i8*, i8** %2
%13 = getelementptr inbounds i8, i8* %12, i64 1
store i8 50, i8* %13
br label %18
14: ; preds = %7
%15 = sub nsw i32 0, %0
%16 = call i32 @ft_itoa_recursive(i8** %2, i32 %15, i32 0, i32 1)
%17 = load i8*, i8** %2
store i8 45, i8* %17
br label %18
18: ; preds = %9, %14, %5
%19 = load i8*, i8** %2
ret i8* %19
}