#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 /*<<< orphan*/ itoa(int, char *);
int /*<<< orphan*/ printf(char *, char *, int);
int main() {
  char s[1024];
  int n = INT_MAX;
  itoa(n, s);
  printf("s: %s, n: %d\n", s, n);
  n = -2147483647;
  itoa(n, s);
  printf("s: %s, n: %d\n", s, n);
  n = -INT_MAX;
  itoa(n, s);
  printf("s: %s, n: %d\n", s, n);
  n = -0;
  itoa(n, s);
  printf("s: %s, n: %d\n", s, n);
  n = 0;
  itoa(n, s);
  printf("s: %s, n: %d\n", s, n);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2eaf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x414(%rbp)
mov    -0x414(%rbp),%edi
lea    -0x410(%rbp),%rsi
call   1040 <itoa@plt>
lea    -0x410(%rbp),%rsi
mov    -0x414(%rbp),%edx
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
movl   $0x80000001,-0x414(%rbp)
mov    -0x414(%rbp),%edi
lea    -0x410(%rbp),%rsi
call   1040 <itoa@plt>
lea    -0x410(%rbp),%rsi
mov    -0x414(%rbp),%edx
lea    0xe64(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
mov    0x2e3e(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x414(%rbp)
mov    -0x414(%rbp),%edi
lea    -0x410(%rbp),%rsi
call   1040 <itoa@plt>
lea    -0x410(%rbp),%rsi
mov    -0x414(%rbp),%edx
lea    0xe28(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x414(%rbp)
mov    -0x414(%rbp),%edi
lea    -0x410(%rbp),%rsi
call   1040 <itoa@plt>
lea    -0x410(%rbp),%rsi
mov    -0x414(%rbp),%edx
lea    0xdf3(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x414(%rbp)
mov    -0x414(%rbp),%edi
lea    -0x410(%rbp),%rsi
call   1040 <itoa@plt>
lea    -0x410(%rbp),%rsi
mov    -0x414(%rbp),%edx
lea    0xdbe(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    0x2eb4(%rip),%r15
mov    (%r15),%ebp
mov    %rsp,%rbx
mov    %ebp,%edi
mov    %rbx,%rsi
call   1040 <itoa@plt>
lea    0xeb5(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1030 <printf@plt>
mov    $0x80000001,%edi
mov    %rbx,%rsi
call   1040 <itoa@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x80000001,%edx
call   1030 <printf@plt>
xor    %ebp,%ebp
sub    (%r15),%ebp
mov    %ebp,%edi
mov    %rbx,%rsi
call   1040 <itoa@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1030 <printf@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1040 <itoa@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <printf@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1040 <itoa@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@INT_MAX = global i32 0
@.str = [14 x i8] c"s: %s, n: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1024 x i8]
%3 = alloca i32
store i32 0, i32* %1
%4 = load i32, i32* @INT_MAX
store i32 %4, i32* %3
%5 = load i32, i32* %3
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%7 = call i32 @itoa(i32 %5, i8* %6)
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%9 = load i32, i32* %3
%10 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %8, i32 %9)
store i32 -2147483647, i32* %3
%11 = load i32, i32* %3
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%13 = call i32 @itoa(i32 %11, i8* %12)
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%15 = load i32, i32* %3
%16 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %14, i32 %15)
%17 = load i32, i32* @INT_MAX
%18 = sub nsw i32 0, %17
store i32 %18, i32* %3
%19 = load i32, i32* %3
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%21 = call i32 @itoa(i32 %19, i8* %20)
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%23 = load i32, i32* %3
%24 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %22, i32 %23)
store i32 0, i32* %3
%25 = load i32, i32* %3
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%27 = call i32 @itoa(i32 %25, i8* %26)
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%29 = load i32, i32* %3
%30 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %28, i32 %29)
store i32 0, i32* %3
%31 = load i32, i32* %3
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%33 = call i32 @itoa(i32 %31, i8* %32)
%34 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%35 = load i32, i32* %3
%36 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %34, i32 %35)
ret i32 0
}

LLVM IR (-O2):
@INT_MAX = global i32 0
@.str = [14 x i8] c"s: %s, n: %d\0A\00"
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @INT_MAX
%4 = call i32 @itoa(i32 %3, i8* %2)
%5 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %2, i32 %3)
%6 = call i32 @itoa(i32 -2147483647, i8* %2)
%7 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %2, i32 -2147483647)
%8 = load i32, i32* @INT_MAX
%9 = sub nsw i32 0, %8
%10 = call i32 @itoa(i32 %9, i8* %2)
%11 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %2, i32 %9)
%12 = call i32 @itoa(i32 0, i8* %2)
%13 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %2, i32 0)
%14 = call i32 @itoa(i32 0, i8* %2)
%15 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %2, i32 0)
ret i32 0
}