#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(char *);
int main() {
  int c;
  char str[0x1000];
  int i = 0;
  while ((c = getchar()) != EOF) {
    if (c == '\n') {
      str[i] = 0;
      i = 0;
      reverse(str);
      printf("%s\n", str);
    } else
      str[i++] = c;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1014(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e8b(%rip),%rcx
cmp    (%rcx),%eax
je     11d0 <main+0xa0>
cmpl   $0xa,-0x8(%rbp)
jne    11ac <main+0x7c>
movslq -0x1014(%rbp),%rax
movb   $0x0,-0x1010(%rbp,%rax,1)
movl   $0x0,-0x1014(%rbp)
lea    -0x1010(%rbp),%rdi
call   1030 <reverse@plt>
lea    -0x1010(%rbp),%rsi
lea    0xe5e(%rip),%rdi
call   1040 <printf@plt>
jmp    11cb <main+0x9b>
mov    -0x8(%rbp),%eax
mov    %al,%cl
mov    -0x1014(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x1014(%rbp)
cltq
mov    %cl,-0x1010(%rbp,%rax,1)
jmp    114c <main+0x1c>
mov    -0x4(%rbp),%eax
add    $0x1020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x1008,%rsp
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e9d(%rip),%r15
cmp    (%r15),%eax
jne    1160 <main+0x30>
xor    %eax,%eax
add    $0x1008,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsp,%rbx
lea    0xe96(%rip),%r14
xor    %ebp,%ebp
jmp    1185 <main+0x55>
xchg   %ax,%ax
movslq %ebp,%rcx
add    $0x1,%ebp
mov    %al,(%rsp,%rcx,1)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    (%r15),%eax
je     1150 <main+0x20>
cmp    $0xa,%eax
jne    1170 <main+0x40>
movslq %ebp,%rax
movb   $0x0,(%rsp,%rax,1)
mov    %rbx,%rdi
call   1030 <reverse@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
xor    %ebp,%ebp
jmp    1179 <main+0x49>

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