#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 /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char);
int /*<<< orphan*/ stdin;
char strlen(char *);
int main() {
  char a[99], i, c;
  fgets(a, 99, stdin);
  c = strlen(a);
  for (i = c - 1; i >= 0; i--) {
    printf("%c", a[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x70(%rbp),%rdi
mov    0x2e9b(%rip),%rax
mov    (%rax),%edx
mov    $0x63,%esi
call   1050 <fgets@plt>
lea    -0x70(%rbp),%rdi
call   1030 <strlen@plt>
mov    %al,-0x72(%rbp)
movsbl -0x72(%rbp),%eax
sub    $0x1,%eax
mov    %al,-0x71(%rbp)
movsbl -0x71(%rbp),%eax
cmp    $0x0,%eax
jl     119f <main+0x6f>
movsbq -0x71(%rbp),%rax
lea    0xe78(%rip),%rdi
movsbl -0x70(%rbp,%rax,1),%esi
call   1040 <printf@plt>
mov    -0x71(%rbp),%al
add    $0xff,%al
mov    %al,-0x71(%rbp)
jmp    116f <main+0x3f>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x70,%rsp
mov    0x2ea9(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x63,%esi
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
add    $0xff,%al
js     1188 <main+0x58>
movzbl %al,%eax
lea    (%rsp,%rax,1),%rbx
lea    0xe93(%rip),%r14
nopl   (%rax)
movsbl (%rbx),%esi
mov    %r14,%rdi
call   1040 <printf@plt>
add    $0xff,%bpl
add    $0xffffffffffffffff,%rbx
test   %bpl,%bpl
jg     1170 <main+0x40>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@stdin = global i32 0
@.str = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca [99 x i8]
%2 = getelementptr inbounds [99 x i8], [99 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @stdin
%4 = call i32 @fgets(i8* %2, i32 99, i32 %3)
%5 = call signext i8 @strlen(i8* %2)
%6 = add i8 %5, -1
%7 = icmp sgt i8 %6, -1
br i1 %7, label %8, label %16
8: ; preds = %0, %8
%9 = phi i8 [ %14, %8 ], [ %6, %0 ]
%10 = zext i8 %9 to i64
%11 = getelementptr inbounds [99 x i8], [99 x i8]* %1, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %12)
%14 = add nsw i8 %9, -1
%15 = icmp sgt i8 %9, 0
br i1 %15, label %8, label %16
16: ; preds = %8, %0
ret i32 0
}