#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 */
typedef int /*<<< orphan*/ s;

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ stdin;
int strlen(char *);
int main() {
  char s[32] = "";
  int i = 0;
  fgets(s, sizeof(s), stdin);
  for (i = strlen(s) - 1; i; i--) {
    putchar(s[i]);
  }
  printf("%c\n", s[0]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1060 <memset@plt>
movl   $0x0,-0x34(%rbp)
lea    -0x30(%rbp),%rdi
mov    0x2e67(%rip),%rax
mov    (%rax),%edx
mov    $0x20,%esi
call   1070 <fgets@plt>
lea    -0x30(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     11c2 <main+0x72>
movslq -0x34(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%edi
call   1030 <putchar@plt>
mov    -0x34(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x34(%rbp)
jmp    119c <main+0x4c>
lea    0xe37(%rip),%rdi
movsbl -0x30(%rbp),%esi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    0x2e8c(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x20,%esi
call   1060 <fgets@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
add    $0xffffffff,%ecx
je     11a3 <main+0x63>
movslq %ecx,%rcx
lea    (%rsp,%rcx,1),%r14
mov    $0x1,%r15d
sub    %eax,%r15d
xor    %ebx,%ebx
nop
movsbl (%r14,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0xffffffffffffffff,%rbx
cmp    %ebx,%r15d
jne    1190 <main+0x50>
movsbl (%rsp),%esi
lea    0xe52(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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