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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x3e8,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11a7 <main+0x87>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x401(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
je     1199 <main+0x79>
movsbl -0x401(%rbp),%eax
mov    0x2e70(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1194 <main+0x74>
mov    -0x401(%rbp),%cl
movslq -0xc(%rbp),%rax
mov    %cl,-0x400(%rbp,%rax,1)
jmp    1199 <main+0x79>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1140 <main+0x20>
lea    -0x400(%rbp),%rsi
lea    0xe4b(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x410,%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     1162 <main+0x42>
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%al
je     1140 <main+0x20>
cmp    (%r14),%al
je     1140 <main+0x20>
mov    %al,(%rsp,%rbx,1)
jmp    1140 <main+0x20>
lea    0xe97(%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 i8 0
@.str = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [1000 x i8]
%5 = alloca i8
store i32 0, i32* %1
store i32 1000, i32* %2
store i32 0, i32* %3
br label %6
6: ; preds = %27, %0
%7 = load i32, i32* %3
%8 = load i32, i32* %2
%9 = sub nsw i32 %8, 1
%10 = icmp slt i32 %7, %9
br i1 %10, label %11, label %30
11: ; preds = %6
%12 = call signext i8 (...) @getchar()
store i8 %12, i8* %5
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 10
br i1 %14, label %15, label %27
15: ; preds = %11
%16 = load i8, i8* %5
%17 = sext i8 %16 to i32
%18 = load i8, i8* @EOF
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %17, %19
br i1 %20, label %21, label %26
21: ; preds = %15
%22 = load i8, i8* %5
%23 = load i32, i32* %3
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 %24
store i8 %22, i8* %25
br label %26
26: ; preds = %21, %15
br label %27
27: ; preds = %26, %11
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 1
store i32 %29, i32* %3
br label %6
30: ; preds = %6
%31 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%32 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %31)
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 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %0, %12
%4 = phi i64 [ 0, %0 ], [ %13, %12 ]
%5 = tail call signext i8 (...) @getchar()
%6 = icmp eq i8 %5, 10
%7 = load i8, i8* @EOF
%8 = icmp eq i8 %5, %7
%9 = select i1 %6, i1 true, i1 %8
br i1 %9, label %12, label %10
10: ; preds = %3
%11 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %4
store i8 %5, i8* %11
br label %12
12: ; preds = %10, %3
%13 = add nuw nsw i64 %4, 1
%14 = icmp eq i64 %13, 999
br i1 %14, label %15, label %3
15: ; preds = %12
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %2)
ret i32 0
}