#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(void) {
  int ret = 0;
  char line[10000];
  int c = 0, i = 0;
  while ((i < 10000) && ((c = getchar()) != EOF) && (c != '\n')) {
    line[i] = c;
    ++i;
  }
  line[i] = '\0';
  reverse(line);
  printf("%s", line);
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2730,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0x2724(%rbp)
movl   $0x0,-0x2728(%rbp)
xor    %eax,%eax
cmpl   $0x2710,-0x2728(%rbp)
mov    %al,-0x2729(%rbp)
jge    11ab <main+0x7b>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,%ecx
mov    %ecx,-0x2724(%rbp)
xor    %eax,%eax
mov    0x2e5b(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x2729(%rbp)
je     11ab <main+0x7b>
cmpl   $0xa,-0x2724(%rbp)
setne  %al
mov    %al,-0x2729(%rbp)
mov    -0x2729(%rbp),%al
test   $0x1,%al
jne    11be <main+0x8e>
jmp    11e8 <main+0xb8>
mov    -0x2724(%rbp),%eax
mov    %al,%cl
movslq -0x2728(%rbp),%rax
mov    %cl,-0x2720(%rbp,%rax,1)
mov    -0x2728(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2728(%rbp)
jmp    115d <main+0x2d>
movslq -0x2728(%rbp),%rax
movb   $0x0,-0x2720(%rbp,%rax,1)
lea    -0x2720(%rbp),%rdi
call   1030 <reverse@plt>
lea    -0x2720(%rbp),%rsi
lea    0xdef(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x2730,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x2718,%rsp
mov    0x2ea7(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%eax
je     1176 <main+0x46>
cmp    (%r14),%eax
je     1176 <main+0x46>
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    $0x2710,%rbx
jne    1150 <main+0x20>
mov    $0x2710,%ebx
mov    %ebx,%eax
movb   $0x0,(%rsp,%rax,1)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <reverse@plt>
lea    0xe72(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x2718,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@EOF = global i32 0
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [10000 x i8]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %18, %0
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 10000
br i1 %8, label %9, label %16
9: ; preds = %6
%10 = call i32 (...) @getchar()
store i32 %10, i32* %4
%11 = load i32, i32* @EOF
%12 = icmp ne i32 %10, %11
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 10
br label %16
16: ; preds = %13, %9, %6
%17 = phi i1 [ false, %9 ], [ false, %6 ], [ %15, %13 ]
br i1 %17, label %18, label %26
18: ; preds = %16
%19 = load i32, i32* %4
%20 = trunc i32 %19 to i8
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 %22
store i8 %20, i8* %23
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
br label %6
26: ; preds = %16
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 %28
store i8 0, i8* %29
%30 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%31 = call i32 @reverse(i8* %30)
%32 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%33 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %32)
%34 = load i32, i32* %2
ret i32 %34
}

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