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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e9e(%rip),%rcx
cmp    (%rcx),%eax
je     1196 <main+0x76>
cmpl   $0x3e7,-0xc(%rbp)
jl     1164 <main+0x44>
jmp    1196 <main+0x76>
cmpl   $0xa,-0x8(%rbp)
jne    1173 <main+0x53>
jmp    1196 <main+0x76>
jmp    1178 <main+0x58>
mov    -0x8(%rbp),%eax
mov    %al,%cl
movslq -0xc(%rbp),%rax
mov    %cl,-0x400(%rbp,%rax,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1139 <main+0x19>
cmpl   $0xa,-0x8(%rbp)
jne    11b9 <main+0x99>
mov    -0x8(%rbp),%eax
mov    %al,%cl
mov    -0xc(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0xc(%rbp)
cltq
mov    %cl,-0x400(%rbp,%rax,1)
movslq -0xc(%rbp),%rax
movb   $0x0,-0x400(%rbp,%rax,1)
lea    -0x400(%rbp),%rsi
lea    0xe2d(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x3f0,%rsp
xor    %r15d,%r15d
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%eax
je     1174 <main+0x54>
mov    0x2ea6(%rip),%r14
cmp    (%r14),%eax
je     1174 <main+0x54>
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %al,(%rsp,%rbx,1)
lea    0x1(%rbx),%r15
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%eax
je     1174 <main+0x54>
cmp    (%r14),%eax
je     1174 <main+0x54>
cmp    $0x3e6,%rbx
mov    %r15,%rbx
jb     1150 <main+0x30>
cmp    $0xa,%eax
jne    1184 <main+0x64>
mov    %r15d,%eax
add    $0x1,%r15d
movb   $0xa,(%rsp,%rax,1)
mov    %r15d,%eax
movb   $0x0,(%rsp,%rax,1)
lea    0xe6e(%rip),%rdi
mov    %rsp,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x3f0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EOF = global i32 0
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [1000 x i8]
store i32 0, i32* %1
store i32 0, i32* %3
br label %5
5: ; preds = %18, %0
%6 = call i32 (...) @getchar()
store i32 %6, i32* %2
%7 = load i32, i32* @EOF
%8 = icmp ne i32 %6, %7
br i1 %8, label %9, label %26
9: ; preds = %5
%10 = load i32, i32* %3
%11 = icmp sge i32 %10, 999
br i1 %11, label %12, label %13
12: ; preds = %9
br label %26
13: ; preds = %9
%14 = load i32, i32* %2
%15 = icmp eq i32 %14, 10
br i1 %15, label %16, label %17
16: ; preds = %13
br label %26
17: ; preds = %13
br label %18
18: ; preds = %17
%19 = load i32, i32* %2
%20 = trunc i32 %19 to i8
%21 = load i32, i32* %3
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 %22
store i8 %20, i8* %23
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %5
26: ; preds = %16, %12, %5
%27 = load i32, i32* %2
%28 = icmp eq i32 %27, 10
br i1 %28, label %29, label %36
29: ; preds = %26
%30 = load i32, i32* %2
%31 = trunc i32 %30 to i8
%32 = load i32, i32* %3
%33 = add nsw i32 %32, 1
store i32 %33, i32* %3
%34 = sext i32 %32 to i64
%35 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 %34
store i8 %31, i8* %35
br label %36
36: ; preds = %29, %26
%37 = load i32, i32* %3
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 %38
store i8 0, i8* %39
%40 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%41 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %40)
ret i32 0
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (...) @getchar()
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
%6 = icmp eq i32 %3, 10
%7 = or i1 %6, %5
br i1 %7, label %23, label %8
8: ; preds = %0, %8
%9 = phi i64 [ %13, %8 ], [ 0, %0 ]
%10 = phi i32 [ %14, %8 ], [ %3, %0 ]
%11 = trunc i32 %10 to i8
%12 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %9
store i8 %11, i8* %12
%13 = add nuw nsw i64 %9, 1
%14 = tail call i32 (...) @getchar()
%15 = load i32, i32* @EOF
%16 = icmp eq i32 %14, %15
%17 = icmp ugt i64 %9, 997
%18 = select i1 %16, i1 true, i1 %17
%19 = icmp eq i32 %14, 10
%20 = or i1 %19, %18
br i1 %20, label %21, label %8
21: ; preds = %8
%22 = trunc i64 %13 to i32
br i1 %19, label %24, label %29
23: ; preds = %0
br i1 %6, label %24, label %29
24: ; preds = %21, %23
%25 = phi i32 [ %22, %21 ], [ 0, %23 ]
%26 = add nuw nsw i32 %25, 1
%27 = zext i32 %25 to i64
%28 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %27
store i8 10, i8* %28
br label %29
29: ; preds = %21, %24, %23
%30 = phi i32 [ %26, %24 ], [ 0, %23 ], [ %22, %21 ]
%31 = zext i32 %30 to i64
%32 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %31
store i8 0, i8* %32
%33 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
ret i32 0
}