#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 /*<<< orphan*/ reverse(int, int, char *);
int main(void) {
  int c;
  int l = 0;
  int b = 0;
  char line[1000];
  while ((c = getchar()) != EOF) {
    line[l] = c;
    l++;
    if (c == '\n') {
      reverse(b, l - 2, line);
      b = l;
    }
  }
  printf("%s\n", line);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e87(%rip),%rcx
cmp    (%rcx),%eax
je     11ac <main+0x7c>
mov    -0x8(%rbp),%eax
mov    %al,%cl
movslq -0xc(%rbp),%rax
mov    %cl,-0x400(%rbp,%rax,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0xa,-0x8(%rbp)
jne    11a7 <main+0x77>
mov    -0x10(%rbp),%edi
mov    -0xc(%rbp),%esi
sub    $0x2,%esi
lea    -0x400(%rbp),%rdx
call   1030 <reverse@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    1150 <main+0x20>
lea    -0x400(%rbp),%rsi
lea    0xe46(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x3f0,%rsp
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e9b(%rip),%r15
cmp    (%r15),%eax
jne    1173 <main+0x43>
lea    0xea7(%rip),%rdi
mov    %rsp,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x3f0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0xffffffff,%ebx
mov    %rsp,%r14
mov    %r14,%rbp
xor    %r12d,%r12d
jmp    11a3 <main+0x73>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1050 <getchar@plt>
add    $0x1,%ebx
add    $0x1,%rbp
cmp    (%r15),%eax
je     1152 <main+0x22>
mov    %al,0x0(%rbp)
cmp    $0xa,%eax
jne    1190 <main+0x60>
mov    %r12d,%edi
mov    %ebx,%esi
mov    %r14,%rdx
call   1030 <reverse@plt>
lea    0x2(%rbx),%r12d
jmp    1190 <main+0x60>

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 i32
%4 = alloca i32
%5 = alloca [1000 x i8]
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %4
br label %6
6: ; preds = %27, %0
%7 = call i32 (...) @getchar()
store i32 %7, i32* %2
%8 = load i32, i32* @EOF
%9 = icmp ne i32 %7, %8
br i1 %9, label %10, label %28
10: ; preds = %6
%11 = load i32, i32* %2
%12 = trunc i32 %11 to i8
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 %14
store i8 %12, i8* %15
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
%18 = load i32, i32* %2
%19 = icmp eq i32 %18, 10
br i1 %19, label %20, label %27
20: ; preds = %10
%21 = load i32, i32* %4
%22 = load i32, i32* %3
%23 = sub nsw i32 %22, 2
%24 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%25 = call i32 @reverse(i32 %21, i32 %23, i8* %24)
%26 = load i32, i32* %3
store i32 %26, i32* %4
br label %27
27: ; preds = %20, %10
br label %6
28: ; preds = %6
%29 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%30 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %29)
%31 = load i32, i32* %1
ret i32 %31
}

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