#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*/ format(char *, int);
int /*<<< orphan*/ putchar(char);
int main(int argc, char const *argv[]) {
  char formatted[1000];
  format(formatted, 1000);
  for (int i = 0; formatted[i] != '\0'; ++i)
    putchar(formatted[i]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x400(%rbp),%rdi
mov    $0x3e8,%esi
call   1040 <format@plt>
movl   $0x0,-0x404(%rbp)
movslq -0x404(%rbp),%rax
movsbl -0x400(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     1194 <main+0x74>
movslq -0x404(%rbp),%rax
movsbl -0x400(%rbp,%rax,1),%edi
ff
call   1030 <putchar@plt>
mov    -0x404(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x404(%rbp)
jmp    1154 <main+0x34>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x3f0,%rsp
mov    %rsp,%rdi
mov    $0x3e8,%esi
call   1040 <format@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>
xor    %eax,%eax
add    $0x3f0,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1000 x i8]
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%5 = call i32 @format(i8* %4, i32 1000)
%6 = load i8, i8* %4
%7 = icmp eq i8 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %9, %2
ret i32 0
9: ; preds = %2, %9
%10 = phi i64 [ %13, %9 ], [ 0, %2 ]
%11 = phi i8 [ %15, %9 ], [ %6, %2 ]
%12 = call i32 @putchar(i8 signext %11)
%13 = add nuw i64 %10, 1
%14 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %8, label %9
}