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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x0,-0x3f8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    11db <main+0xbb>
cmpl   $0x3e7,-0x3f8(%rbp)
jge    11bb <main+0x9b>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x3f4(%rbp)
cmp    $0xa,%eax
je     11af <main+0x8f>
mov    -0x3f4(%rbp),%eax
mov    0x2e68(%rip),%rcx
cmp    (%rcx),%eax
je     11a3 <main+0x83>
mov    -0x3f4(%rbp),%eax
mov    %al,%cl
movslq -0x3f8(%rbp),%rax
mov    %cl,-0x3f0(%rbp,%rax,1)
jmp    11aa <main+0x8a>
movl   $0x0,-0x8(%rbp)
jmp    11b6 <main+0x96>
movl   $0x0,-0x8(%rbp)
jmp    11c2 <main+0xa2>
movl   $0x0,-0x8(%rbp)
jmp    11c7 <main+0xa7>
mov    -0x3f8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3f8(%rbp)
jmp    1143 <main+0x23>
movl   $0x0,-0x3f8(%rbp)
movslq -0x3f8(%rbp),%rax
movsbl -0x3f0(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     122c <main+0x10c>
movslq -0x3f8(%rbp),%rax
lea    0xdf5(%rip),%rdi
movsbl -0x3f0(%rbp,%rax,1),%esi
ff
call   1030 <printf@plt>
mov    -0x3f8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3f8(%rbp)
jmp    11e5 <main+0xc5>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x3e8,%rsp
mov    $0xffffffffffffffff,%rbx
mov    0x2eb0(%rip),%r14
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%eax
je     1162 <main+0x42>
cmp    (%r14),%eax
je     1162 <main+0x42>
mov    %al,0x1(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    $0x3e6,%rbx
jb     1140 <main+0x20>
mov    (%rsp),%al
test   %al,%al
je     1196 <main+0x76>
lea    0x1(%rsp),%rbx
lea    0xe8b(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
movsbl %al,%esi
mov    %r14,%rdi
call   1030 <printf@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1180 <main+0x60>
xor    %eax,%eax
add    $0x3e8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@EOF = global i32 0
@.str = [3 x i8] c"%c\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 %6
3: ; preds = %13, %6
%4 = load i8, i8* %2
%5 = icmp eq i8 %4, 0
br i1 %5, label %26, label %18
6: ; preds = %0, %13
%7 = phi i64 [ 0, %0 ], [ %16, %13 ]
%8 = tail call i32 (...) @getchar()
%9 = icmp eq i32 %8, 10
%10 = load i32, i32* @EOF
%11 = icmp eq i32 %8, %10
%12 = select i1 %9, i1 true, i1 %11
br i1 %12, label %3, label %13
13: ; preds = %6
%14 = trunc i32 %8 to i8
%15 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %7
store i8 %14, i8* %15
%16 = add nuw nsw i64 %7, 1
%17 = icmp ult i64 %7, 998
br i1 %17, label %6, label %3
18: ; preds = %3, %18
%19 = phi i64 [ %22, %18 ], [ 0, %3 ]
%20 = phi i8 [ %24, %18 ], [ %4, %3 ]
%21 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %20)
%22 = add nuw i64 %19, 1
%23 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 0
br i1 %25, label %26, label %18
26: ; preds = %18, %3
ret i32 0
}