#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 i, h;
  char s[1000];
  fgets(s, 1000, stdin);
  h = strlen(s);
  for (i = h - 1; i >= 0; i--) {
    printf("%c", s[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3f0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x3f0(%rbp),%rdi
mov    0x2e98(%rip),%rax
mov    (%rax),%edx
mov    $0x3e8,%esi
call   1050 <fgets@plt>
lea    -0x3f0(%rbp),%rdi
call   1030 <strlen@plt>
mov    %al,-0x6(%rbp)
movsbl -0x6(%rbp),%eax
sub    $0x1,%eax
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x0,%eax
jl     11a8 <main+0x78>
movsbq -0x5(%rbp),%rax
lea    0xe72(%rip),%rdi
movsbl -0x3f0(%rbp,%rax,1),%esi
ff
call   1040 <printf@plt>
mov    -0x5(%rbp),%al
add    $0xff,%al
mov    %al,-0x5(%rbp)
jmp    1175 <main+0x45>
xor    %eax,%eax
add    $0x3f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x3f0,%rsp
mov    0x2ea6(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x3e8,%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    0xe90(%rip),%r14
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    $0x3f0,%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 i8
%3 = alloca i8
%4 = alloca [1000 x i8]
store i32 0, i32* %1
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%6 = load i32, i32* @stdin
%7 = call i32 @fgets(i8* %5, i32 1000, i32 %6)
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%9 = call signext i8 @strlen(i8* %8)
store i8 %9, i8* %3
%10 = load i8, i8* %3
%11 = sext i8 %10 to i32
%12 = sub nsw i32 %11, 1
%13 = trunc i32 %12 to i8
store i8 %13, i8* %2
br label %14
14: ; preds = %24, %0
%15 = load i8, i8* %2
%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* %2
%20 = sext i8 %19 to i64
%21 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, 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* %2
%26 = add i8 %25, -1
store i8 %26, i8* %2
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 [1000 x i8]
%2 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @stdin
%4 = call i32 @fgets(i8* %2, i32 1000, 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 [1000 x i8], [1000 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
}