#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 */
scalar_t__ gets(char *);
int /*<<< orphan*/ putchar(int);
int strlen(char *);
int main() {
  int i;
  char a[1000001];
  while (gets(a) > 0) {
    for (i = strlen(a) - 1; i >= 0; i--)
      putchar(a[i]);
    putchar(10);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf4250,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xf4250(%rbp),%rdi
call   1050 <gets@plt>
cmp    $0x0,%rax
jle    11a2 <main+0x72>
lea    -0xf4250(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     1193 <main+0x63>
movslq -0x8(%rbp),%rax
movsbl -0xf4250(%rbp,%rax,1),%edi
ff
call   1030 <putchar@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    116a <main+0x3a>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1142 <main+0x12>
xor    %eax,%eax
add    $0xf4250,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xf4248,%rsp
mov    %rsp,%rdi
call   1050 <gets@plt>
test   %rax,%rax
jle    1198 <main+0x68>
mov    %rsp,%r14
jmp    1167 <main+0x37>
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
call   1050 <gets@plt>
test   %rax,%rax
jle    1198 <main+0x68>
mov    %r14,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    1150 <main+0x20>
mov    %eax,%ebx
add    $0x1,%rbx
nopl   0x0(%rax)
lea    -0x2(%rbx),%eax
movsbl (%rsp,%rax,1),%edi
call   1030 <putchar@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     1180 <main+0x50>
jmp    1150 <main+0x20>
xor    %eax,%eax
add    $0xf4248,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [1000001 x i8]
store i32 0, i32* %1
br label %4
4: ; preds = %25, %0
%5 = getelementptr inbounds [1000001 x i8], [1000001 x i8]* %3, i64 0, i64 0
%6 = call i64 @gets(i8* %5)
%7 = icmp sgt i64 %6, 0
br i1 %7, label %8, label %27
8: ; preds = %4
%9 = getelementptr inbounds [1000001 x i8], [1000001 x i8]* %3, i64 0, i64 0
%10 = call i32 @strlen(i8* %9)
%11 = sub nsw i32 %10, 1
store i32 %11, i32* %2
br label %12
12: ; preds = %22, %8
%13 = load i32, i32* %2
%14 = icmp sge i32 %13, 0
br i1 %14, label %15, label %25
15: ; preds = %12
%16 = load i32, i32* %2
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [1000001 x i8], [1000001 x i8]* %3, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = call i32 @putchar(i32 %20)
br label %22
22: ; preds = %15
%23 = load i32, i32* %2
%24 = add nsw i32 %23, -1
store i32 %24, i32* %2
br label %12
25: ; preds = %12
%26 = call i32 @putchar(i32 10)
br label %4
27: ; preds = %4
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca [1000001 x i8]
%2 = getelementptr inbounds [1000001 x i8], [1000001 x i8]* %1, i64 0, i64 0
%3 = call i64 @gets(i8* %2)
%4 = icmp sgt i64 %3, 0
br i1 %4, label %5, label %23
5: ; preds = %0, %19
%6 = call i32 @strlen(i8* %2)
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %19
8: ; preds = %5
%9 = zext i32 %6 to i64
br label %10
10: ; preds = %8, %10
%11 = phi i64 [ %9, %8 ], [ %12, %10 ]
%12 = add nsw i64 %11, -1
%13 = and i64 %12, 4294967295
%14 = getelementptr inbounds [1000001 x i8], [1000001 x i8]* %1, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = call i32 @putchar(i32 %16)
%18 = icmp ugt i64 %11, 1
br i1 %18, label %10, label %19
19: ; preds = %10, %5
%20 = call i32 @putchar(i32 10)
%21 = call i64 @gets(i8* %2)
%22 = icmp sgt i64 %21, 0
br i1 %22, label %5, label %23
23: ; preds = %19, %0
ret i32 0
}