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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x3f4(%rbp)
cmpl   $0x3e7,-0x3f4(%rbp)
jge    11a2 <main+0x82>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
cmp    $0xa,%eax
je     1189 <main+0x69>
mov    -0x8(%rbp),%eax
mov    0x2e7f(%rip),%rcx
cmp    (%rcx),%eax
je     1184 <main+0x64>
mov    -0x8(%rbp),%eax
mov    %al,%cl
movslq -0x3f4(%rbp),%rax
mov    %cl,-0x3f0(%rbp,%rax,1)
jmp    1189 <main+0x69>
jmp    118e <main+0x6e>
mov    -0x3f4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3f4(%rbp)
jmp    113c <main+0x1c>
lea    -0x3f0(%rbp),%rsi
lea    0xe50(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x3e8,%rsp
mov    0x2eb7(%rip),%r14
xor    %ebx,%ebx
jmp    114d <main+0x2d>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rbx
cmp    $0x3e7,%rbx
je     1163 <main+0x43>
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%eax
je     1140 <main+0x20>
cmp    (%r14),%eax
je     1140 <main+0x20>
mov    %al,(%rsp,%rbx,1)
jmp    1140 <main+0x20>
lea    0xe96(%rip),%rdi
mov    %rsp,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x3e8,%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 i32
%3 = alloca [1000 x i8]
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
br label %5
5: ; preds = %23, %0
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 999
br i1 %7, label %8, label %26
8: ; preds = %5
%9 = call i32 (...) @getchar()
store i32 %9, i32* %2
%10 = icmp ne i32 %9, 10
br i1 %10, label %11, label %22
11: ; preds = %8
%12 = load i32, i32* %2
%13 = load i32, i32* @EOF
%14 = icmp ne i32 %12, %13
br i1 %14, label %15, label %21
15: ; preds = %11
%16 = load i32, i32* %2
%17 = trunc i32 %16 to i8
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 %19
store i8 %17, i8* %20
br label %21
21: ; preds = %15, %11
br label %22
22: ; preds = %21, %8
br label %23
23: ; preds = %22
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 1
store i32 %25, i32* %4
br label %5
26: ; preds = %5
%27 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%28 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %27)
%29 = load i32, i32* %1
ret i32 %29
}

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