#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 *);
int main() {
  int c, i;
  char s[1024];
  for (i = 0; (c = getchar()) != EOF; i++) {
    if (i >= 1024 - 1) {
      break;
    }
    if (c == '\n') {
      break;
    }
    s[i] = c;
  }
  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    $0x410,%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     1191 <main+0x71>
cmpl   $0x3ff,-0xc(%rbp)
jl     1164 <main+0x44>
jmp    1191 <main+0x71>
cmpl   $0xa,-0x8(%rbp)
jne    1173 <main+0x53>
jmp    1191 <main+0x71>
mov    -0x8(%rbp),%eax
mov    %al,%cl
movslq -0xc(%rbp),%rax
mov    %cl,-0x410(%rbp,%rax,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1139 <main+0x19>
cmpl   $0xa,-0x8(%rbp)
jne    11b4 <main+0x94>
mov    -0x8(%rbp),%eax
mov    %al,%cl
mov    -0xc(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0xc(%rbp)
cltq
mov    %cl,-0x410(%rbp,%rax,1)
movslq -0xc(%rbp),%rax
movb   $0x0,-0x410(%rbp,%rax,1)
lea    -0x410(%rbp),%rsi
lea    0xe32(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x400,%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    $0x3fe,%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    $0x400,%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 [1024 x i8]
store i32 0, i32* %1
store i32 0, i32* %3
br label %5
5: ; preds = %23, %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, 1023
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
%18 = load i32, i32* %2
%19 = trunc i32 %18 to i8
%20 = load i32, i32* %3
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %21
store i8 %19, i8* %22
br label %23
23: ; preds = %17
%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 [1024 x i8], [1024 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 [1024 x i8], [1024 x i8]* %4, i64 0, i64 %38
store i8 0, i8* %39
%40 = getelementptr inbounds [1024 x i8], [1024 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 [1024 x i8]
%2 = getelementptr inbounds [1024 x i8], [1024 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 [1024 x i8], [1024 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, 1021
%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 [1024 x i8], [1024 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 [1024 x i8], [1024 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
}