#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 /*<<< orphan*/ itoa(int, char *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  char str[1000];
  itoa(-1234, str);
  int i;
  for (i = 0; str[i] != '\0'; i++) {
    printf("%c", str[i]);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x3f0(%rbp),%rsi
mov    $0xfffffb2e,%edi
call   1040 <itoa@plt>
movl   $0x0,-0x3f4(%rbp)
movslq -0x3f4(%rbp),%rax
movsbl -0x3f0(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     1196 <main+0x76>
movslq -0x3f4(%rbp),%rax
movsbl -0x3f0(%rbp,%rax,1),%esi
ff
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x3f4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3f4(%rbp)
jmp    114d <main+0x2d>
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x3f0,%rsp
mov    %rsp,%rsi
mov    $0xfffffb2e,%edi
call   1040 <itoa@plt>
mov    (%rsp),%al
test   %al,%al
je     1163 <main+0x43>
lea    0x1(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <putchar@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1150 <main+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x3f0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1000 x i8]
%3 = alloca i32
store i32 0, i32* %1
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%5 = call i32 @itoa(i32 -1234, i8* %4)
store i32 0, i32* %3
br label %6
6: ; preds = %20, %0
%7 = load i32, i32* %3
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %8
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %23
13: ; preds = %6
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %13
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %6
23: ; preds = %6
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%25 = load i32, i32* %1
ret i32 %25
}

LLVM IR (-O2):
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 -1234, i8* %2)
%4 = load i8, i8* %2
%5 = icmp eq i8 %4, 0
br i1 %5, label %15, label %6
6: ; preds = %0, %6
%7 = phi i64 [ %11, %6 ], [ 0, %0 ]
%8 = phi i8 [ %13, %6 ], [ %4, %0 ]
%9 = sext i8 %8 to i32
%10 = call i32 @putchar(i32 %9)
%11 = add nuw i64 %7, 1
%12 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %11
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %15, label %6
15: ; preds = %6, %0
%16 = call i32 @putchar(i32 10)
ret i32 0
}