#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 getwordsize();
int /*<<< orphan*/ itoa(int, char *);
int /*<<< orphan*/ printf(char *, int, char *);
int main() {
  char s[1000];
  int i = 0;
  itoa(i, s);
  printf("%d to string is: %s\n", i, s);
  i = -128;
  itoa(i, s);
  printf("%d to string is: %s\n", i, s);
  i = 256;
  itoa(i, s);
  printf("%d to string is: %s\n", i, s);
  i = 1 << (getwordsize() - 1);
  itoa(i, s);
  printf("%d to string is: %s\n", i, s);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movl   $0x0,-0x3f4(%rbp)
mov    -0x3f4(%rbp),%edi
lea    -0x3f0(%rbp),%rsi
call   1050 <itoa@plt>
mov    -0x3f4(%rbp),%esi
lea    -0x3f0(%rbp),%rdx
lea    0xe95(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffff80,-0x3f4(%rbp)
ff ff ff
mov    -0x3f4(%rbp),%edi
lea    -0x3f0(%rbp),%rsi
call   1050 <itoa@plt>
mov    -0x3f4(%rbp),%esi
lea    -0x3f0(%rbp),%rdx
lea    0xe60(%rip),%rdi
call   1030 <printf@plt>
movl   $0x100,-0x3f4(%rbp)
mov    -0x3f4(%rbp),%edi
lea    -0x3f0(%rbp),%rsi
call   1050 <itoa@plt>
mov    -0x3f4(%rbp),%esi
lea    -0x3f0(%rbp),%rdx
lea    0xe2b(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getwordsize@plt>
mov    %eax,%ecx
sub    $0x1,%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x3f4(%rbp)
mov    -0x3f4(%rbp),%edi
lea    -0x3f0(%rbp),%rsi
call   1050 <itoa@plt>
mov    -0x3f4(%rbp),%esi
lea    -0x3f0(%rbp),%rdx
lea    0xde7(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x3f0,%rsp
mov    %rsp,%rbx
xor    %edi,%edi
mov    %rbx,%rsi
call   1050 <itoa@plt>
lea    0xeb1(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    %rbx,%rdx
call   1030 <printf@plt>
mov    $0xffffff80,%edi
mov    %rbx,%rsi
call   1050 <itoa@plt>
mov    %r14,%rdi
mov    $0xffffff80,%esi
mov    %rbx,%rdx
call   1030 <printf@plt>
mov    $0x100,%edi
mov    %rbx,%rsi
call   1050 <itoa@plt>
mov    %r14,%rdi
mov    $0x100,%esi
mov    %rbx,%rdx
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <getwordsize@plt>
lea    -0x1(%rax),%ecx
mov    $0x1,%ebp
shl    %cl,%ebp
mov    %ebp,%edi
mov    %rbx,%rsi
call   1050 <itoa@plt>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x3f0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"%d to string is: %s\0A\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = alloca i32
store i32 0, i32* %2
%3 = load i32, i32* %2
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%5 = call i32 @itoa(i32 %3, i8* %4)
%6 = load i32, i32* %2
%7 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%8 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %6, i8* %7)
store i32 -128, i32* %2
%9 = load i32, i32* %2
%10 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%11 = call i32 @itoa(i32 %9, i8* %10)
%12 = load i32, i32* %2
%13 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%14 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %12, i8* %13)
store i32 256, i32* %2
%15 = load i32, i32* %2
%16 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%17 = call i32 @itoa(i32 %15, i8* %16)
%18 = load i32, i32* %2
%19 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%20 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %18, i8* %19)
%21 = call i32 (...) @getwordsize()
%22 = sub nsw i32 %21, 1
%23 = shl i32 1, %22
store i32 %23, i32* %2
%24 = load i32, i32* %2
%25 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%26 = call i32 @itoa(i32 %24, i8* %25)
%27 = load i32, i32* %2
%28 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%29 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %27, i8* %28)
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"%d to string is: %s\0A\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%3 = call i32 @itoa(i32 0, i8* %2)
%4 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 0, i8* %2)
%5 = call i32 @itoa(i32 -128, i8* %2)
%6 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 -128, i8* %2)
%7 = call i32 @itoa(i32 256, i8* %2)
%8 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 256, i8* %2)
%9 = call i32 (...) @getwordsize()
%10 = add nsw i32 %9, -1
%11 = shl nuw i32 1, %10
%12 = call i32 @itoa(i32 %11, i8* %2)
%13 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %11, i8* %2)
ret i32 0
}