#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 */
char EOF;
int /*<<< orphan*/ expand(char *, char *);
char getchar();
int /*<<< orphan*/ printf(char *, char *);
int main(void) {
  int i = 0;
  char s1[1000];
  char s2[1000];
  while ((s1[i] = getchar()) != EOF && i < 1000)
    i++;
  s1[i] = '\0';
  expand(s1, s2);
  printf("%s\n", s2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7f0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
movslq -0x8(%rbp),%rcx
mov    %al,-0x3f0(%rbp,%rcx,1)
movsbl %al,%ecx
mov    0x2e83(%rip),%rax
movsbl (%rax),%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x7e1(%rbp)
je     1188 <main+0x58>
cmpl   $0x3e8,-0x8(%rbp)
setl   %al
mov    %al,-0x7e1(%rbp)
mov    -0x7e1(%rbp),%al
test   $0x1,%al
jne    119b <main+0x6b>
jmp    11a9 <main+0x79>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1149 <main+0x19>
movslq -0x8(%rbp),%rax
movb   $0x0,-0x3f0(%rbp,%rax,1)
lea    -0x3f0(%rbp),%rdi
lea    -0x7e0(%rbp),%rsi
call   1050 <expand@plt>
lea    -0x7e0(%rbp),%rsi
lea    0xe2a(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x7f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x7d8,%rsp
mov    0x2ea7(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %al,(%rsp,%rbx,1)
lea    0x1(%rbx),%rcx
cmp    (%r14),%al
je     116f <main+0x3f>
cmp    $0x3e8,%rbx
mov    %rcx,%rbx
jb     1150 <main+0x20>
movb   $0x0,-0x1(%rsp,%rcx,1)
mov    %rsp,%rdi
lea    0x3f0(%rsp),%rbx
mov    %rbx,%rsi
call   1050 <expand@plt>
lea    0xe72(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x7d8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@EOF = global i8 0
@.str = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = alloca [1000 x i8]
%3 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
br label %5
5: ; preds = %5, %0
%6 = phi i64 [ %13, %5 ], [ 0, %0 ]
%7 = tail call signext i8 (...) @getchar()
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %6
store i8 %7, i8* %8
%9 = load i8, i8* @EOF
%10 = icmp ne i8 %7, %9
%11 = icmp ult i64 %6, 1000
%12 = select i1 %10, i1 %11, i1 false
%13 = add nuw nsw i64 %6, 1
br i1 %12, label %5, label %14
14: ; preds = %5
%15 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %6
store i8 0, i8* %15
%16 = call i32 @expand(i8* %3, i8* %4)
%17 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %4)
ret i32 0
}