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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movl   $0x0,-0x3f4(%rbp)
movl   $0x8,-0x3f8(%rbp)
mov    -0x3f4(%rbp),%edi
lea    -0x3f0(%rbp),%rsi
mov    -0x3f8(%rbp),%edx
call   1050 <itoa@plt>
mov    -0x3f4(%rbp),%esi
mov    -0x3f8(%rbp),%edx
lea    -0x3f0(%rbp),%rcx
lea    0xe7f(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffff80,-0x3f4(%rbp)
ff ff ff
movl   $0x8,-0x3f8(%rbp)
mov    -0x3f4(%rbp),%edi
lea    -0x3f0(%rbp),%rsi
mov    -0x3f8(%rbp),%edx
call   1050 <itoa@plt>
mov    -0x3f4(%rbp),%esi
mov    -0x3f8(%rbp),%edx
lea    -0x3f0(%rbp),%rcx
lea    0xe34(%rip),%rdi
call   1030 <printf@plt>
movl   $0x100,-0x3f4(%rbp)
movl   $0x10,-0x3f8(%rbp)
mov    -0x3f4(%rbp),%edi
lea    -0x3f0(%rbp),%rsi
mov    -0x3f8(%rbp),%edx
call   1050 <itoa@plt>
mov    -0x3f4(%rbp),%esi
mov    -0x3f8(%rbp),%edx
lea    -0x3f0(%rbp),%rcx
lea    0xde9(%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)
movl   $0x10,-0x3f8(%rbp)
mov    -0x3f4(%rbp),%edi
lea    -0x3f0(%rbp),%rsi
mov    -0x3f8(%rbp),%edx
call   1050 <itoa@plt>
mov    -0x3f4(%rbp),%esi
mov    -0x3f8(%rbp),%edx
lea    -0x3f0(%rbp),%rcx
lea    0xd8f(%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
mov    $0x8,%edx
call   1050 <itoa@plt>
lea    0xeac(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x8,%edx
mov    %rbx,%rcx
call   1030 <printf@plt>
mov    $0xffffff80,%edi
mov    %rbx,%rsi
mov    $0x8,%edx
call   1050 <itoa@plt>
mov    %r14,%rdi
mov    $0xffffff80,%esi
mov    $0x8,%edx
mov    %rbx,%rcx
call   1030 <printf@plt>
mov    $0x100,%edi
mov    %rbx,%rsi
mov    $0x10,%edx
call   1050 <itoa@plt>
mov    %r14,%rdi
mov    $0x100,%esi
mov    $0x10,%edx
mov    %rbx,%rcx
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
mov    $0x10,%edx
call   1050 <itoa@plt>
mov    %r14,%rdi
mov    %ebp,%esi
mov    $0x10,%edx
mov    %rbx,%rcx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x3f0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [30 x i8] c"%d to string width %d 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, i32 8)
%4 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 0, i32 8, i8* %2)
%5 = call i32 @itoa(i32 -128, i8* %2, i32 8)
%6 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 -128, i32 8, i8* %2)
%7 = call i32 @itoa(i32 256, i8* %2, i32 16)
%8 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 256, i32 16, 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, i32 16)
%13 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %11, i32 16, i8* %2)
ret i32 0
}