#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 INT_MAX;
int INT_MIN;
char *ft_itoa(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
scalar_t__ strcmp(char *, char *);
int main(void) {
  char s1[100] = {0};
  char s2[100] = {0};
  sprintf(s1, "%d\n%d\n%d\n", INT_MIN, 0, INT_MAX);
  sprintf(s2, "%s\n%s\n%s\n", ft_itoa(INT_MIN), ft_itoa(0), ft_itoa(INT_MAX));
  printf("ft_itoa: %s\n", strcmp(s1, s2) ? "FAILURE" : "OK");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
lea    -0xe0(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
lea    -0x70(%rbp),%rdi
mov    0x2e50(%rip),%rax
mov    (%rax),%edx
mov    0x2e4f(%rip),%rax
mov    (%rax),%r8d
lea    0xe5d(%rip),%rsi
xor    %ecx,%ecx
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0xe0(%rbp),%rax
mov    %rax,-0xf8(%rbp)
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
call   1030 <ft_itoa@plt>
mov    %rax,-0xf0(%rbp)
xor    %edi,%edi
call   1030 <ft_itoa@plt>
mov    %rax,-0xe8(%rbp)
mov    0x2e04(%rip),%rax
mov    (%rax),%edi
call   1030 <ft_itoa@plt>
mov    -0xf8(%rbp),%rdi
mov    -0xf0(%rbp),%rdx
mov    -0xe8(%rbp),%rcx
mov    %rax,%r8
lea    0xe00(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x70(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
call   1060 <strcmp@plt>
mov    %rax,%rcx
lea    0xdfe(%rip),%rsi
lea    0xdef(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rsi
lea    0xdd3(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xd8,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movl   $0x0,0xd0(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movl   $0x0,0x60(%rsp)
mov    0x2e2b(%rip),%rbx
mov    (%rbx),%edx
mov    0x2e2a(%rip),%r12
mov    (%r12),%r8d
lea    0xe37(%rip),%rsi
lea    0x70(%rsp),%r14
mov    %r14,%rdi
xor    %ecx,%ecx
xor    %eax,%eax
call   1060 <sprintf@plt>
mov    (%rbx),%edi
call   1030 <ft_itoa@plt>
mov    %rax,%r15
xor    %edi,%edi
call   1030 <ft_itoa@plt>
mov    %rax,%rbx
mov    (%r12),%edi
call   1030 <ft_itoa@plt>
lea    0xe0c(%rip),%rsi
mov    %rsp,%r12
mov    %r12,%rdi
mov    %r15,%rdx
mov    %rbx,%rcx
mov    %rax,%r8
xor    %eax,%eax
call   1060 <sprintf@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
lea    0xe00(%rip),%rax
lea    0xdf1(%rip),%rsi
cmove  %rax,%rsi
lea    0xdd9(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [10 x i8] c"%d\0A%d\0A%d\0A\00"
@INT_MIN = global i32 0
@INT_MAX = global i32 0
@.str.1 = [10 x i8] c"%s\0A%s\0A%s\0A\00"
@.str.2 = [13 x i8] c"ft_itoa: %s\0A\00"
@.str.3 = [8 x i8] c"FAILURE\00"
@.str.4 = [3 x i8] c"OK\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
store i32 0, i32* %1
%4 = bitcast [100 x i8]* %2 to i8*
%5 = bitcast [100 x i8]* %3 to i8*
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%7 = load i32, i32* @INT_MIN
%8 = load i32, i32* @INT_MAX
%9 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %7, i32 0, i32 %8)
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%11 = load i32, i32* @INT_MIN
%12 = call i8* @ft_itoa(i32 %11)
%13 = call i8* @ft_itoa(i32 0)
%14 = load i32, i32* @INT_MAX
%15 = call i8* @ft_itoa(i32 %14)
%16 = call i32 (i8*, i8*, ...) @sprintf(i8* %10, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %12, i8* %13, i8* %15)
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%19 = call i64 @strcmp(i8* %17, i8* %18)
%20 = icmp ne i64 %19, 0
%21 = zext i1 %20 to i64
%22 = select i1 %20, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0)
%23 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %22)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"%d\0A%d\0A%d\0A\00"
@INT_MIN = global i32 0
@INT_MAX = global i32 0
@.str.1 = [10 x i8] c"%s\0A%s\0A%s\0A\00"
@.str.2 = [13 x i8] c"ft_itoa: %s\0A\00"
@.str.3 = [8 x i8] c"FAILURE\00"
@.str.4 = [3 x i8] c"OK\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = load i32, i32* @INT_MIN
%6 = load i32, i32* @INT_MAX
%7 = call i32 (i8*, i8*, ...) @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %5, i32 0, i32 %6)
%8 = load i32, i32* @INT_MIN
%9 = tail call i8* @ft_itoa(i32 %8)
%10 = tail call i8* @ft_itoa(i32 0)
%11 = load i32, i32* @INT_MAX
%12 = tail call i8* @ft_itoa(i32 %11)
%13 = call i32 (i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %9, i8* %10, i8* %12)
%14 = call i64 @strcmp(i8* %3, i8* %4)
%15 = icmp eq i64 %14, 0
%16 = select i1 %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0)
%17 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %16)
ret i32 0
}