#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 EXIT_SUCCESS;
int INT_MIN;
int /*<<< orphan*/ itoa1(int, char *);
int /*<<< orphan*/ itoa2(int, char *);
int /*<<< orphan*/ printf(char *, char *);
int main() {
  int n = INT_MIN;
  char s[20];
  itoa1(n + 1, s);
  printf("result(version 1):%s\n", s);
  itoa2(n, s);
  printf("result(version 2):%s\n", s);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2ea2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
add    $0x1,%edi
lea    -0x20(%rbp),%rsi
call   1040 <itoa1@plt>
lea    -0x20(%rbp),%rsi
lea    0xe9b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
lea    -0x20(%rbp),%rsi
call   1050 <itoa2@plt>
lea    -0x20(%rbp),%rsi
lea    0xe95(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e4b(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    0x2eaa(%rip),%rax
mov    (%rax),%ebx
lea    0x1(%rbx),%edi
mov    %rsp,%r14
mov    %r14,%rsi
call   1040 <itoa1@plt>
lea    0xeab(%rip),%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
mov    %ebx,%edi
mov    %r14,%rsi
call   1050 <itoa2@plt>
lea    0xea8(%rip),%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
mov    0x2e5b(%rip),%rax
mov    (%rax),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@INT_MIN = global i32 0
@.str = [22 x i8] c"result(version 1):%s\0A\00"
@.str.1 = [22 x i8] c"result(version 2):%s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [20 x i8]
store i32 0, i32* %1
%4 = load i32, i32* @INT_MIN
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = add nsw i32 %5, 1
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%8 = call i32 @itoa1(i32 %6, i8* %7)
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%10 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load i32, i32* %2
%12 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%13 = call i32 @itoa2(i32 %11, i8* %12)
%14 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%15 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = load i32, i32* @EXIT_SUCCESS
ret i32 %16
}

LLVM IR (-O2):
@INT_MIN = global i32 0
@.str = [22 x i8] c"result(version 1):%s\0A\00"
@.str.1 = [22 x i8] c"result(version 2):%s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca [20 x i8]
%2 = load i32, i32* @INT_MIN
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%4 = add nsw i32 %2, 1
%5 = call i32 @itoa1(i32 %4, i8* %3)
%6 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %3)
%7 = call i32 @itoa2(i32 %2, i8* %3)
%8 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%9 = load i32, i32* @EXIT_SUCCESS
ret i32 %9
}