#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() {
  char line[1024];
  int i;
  int c;
  for (i = 0; i < 1024 - 1 ? ((c = getchar()) != EOF ? c != '\n' : 0) : 0;
       ++i) {
    line[i] = c;
  }
  if (c == '\n') {
    line[i] = c;
    ++i;
  }
  line[i] = '\0';
  printf("%s\n", line);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x414(%rbp)
cmpl   $0x3ff,-0x414(%rbp)
jge    11a0 <main+0x80>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x418(%rbp)
mov    0x2e88(%rip),%rcx
cmp    (%rcx),%eax
je     1182 <main+0x62>
cmpl   $0xa,-0x418(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x41c(%rbp)
jmp    118f <main+0x6f>
xor    %eax,%eax
mov    %eax,-0x41c(%rbp)
jmp    118f <main+0x6f>
mov    -0x41c(%rbp),%eax
mov    %eax,-0x420(%rbp)
jmp    11ad <main+0x8d>
xor    %eax,%eax
mov    %eax,-0x420(%rbp)
jmp    11ad <main+0x8d>
mov    -0x420(%rbp),%eax
cmp    $0x0,%eax
je     11e6 <main+0xc6>
mov    -0x418(%rbp),%eax
mov    %al,%cl
movslq -0x414(%rbp),%rax
mov    %cl,-0x410(%rbp,%rax,1)
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
jmp    113c <main+0x1c>
cmpl   $0xa,-0x418(%rbp)
jne    1218 <main+0xf8>
mov    -0x418(%rbp),%eax
mov    %al,%cl
movslq -0x414(%rbp),%rax
mov    %cl,-0x410(%rbp,%rax,1)
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
movslq -0x414(%rbp),%rax
movb   $0x0,-0x410(%rbp,%rax,1)
lea    -0x410(%rbp),%rsi
lea    0xdcb(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    0x2eb7(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%eax
je     1166 <main+0x46>
cmp    (%r14),%eax
je     1166 <main+0x46>
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    $0x3ff,%rbx
jne    1140 <main+0x20>
mov    $0x3ff,%ebx
cmp    $0xa,%eax
jne    1174 <main+0x54>
mov    %ebx,%eax
movb   $0xa,(%rsp,%rax,1)
add    $0x1,%ebx
movslq %ebx,%rax
movb   $0x0,(%rsp,%rax,1)
lea    0xe7e(%rip),%rdi
mov    %rsp,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

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

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