#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*/ gets(char *);
int /*<<< orphan*/ printf(char *, char);
int main(int argc, const char *argv[]) {
  char i, str[101];
  gets(str);
  for (i = 0; str[i] != '\0'; i++) {
  }
  i--;
  while (i >= 0) {
    printf("%c", str[i--]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x80(%rbp),%rdi
call   1040 <gets@plt>
movb   $0x0,-0x11(%rbp)
movsbq -0x11(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     116b <main+0x4b>
jmp    115e <main+0x3e>
mov    -0x11(%rbp),%al
add    $0x1,%al
mov    %al,-0x11(%rbp)
jmp    1146 <main+0x26>
mov    -0x11(%rbp),%al
add    $0xff,%al
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
cmp    $0x0,%eax
jl     11a5 <main+0x85>
mov    -0x11(%rbp),%al
mov    %al,%cl
add    $0xff,%cl
mov    %cl,-0x11(%rbp)
movsbq %al,%rax
lea    0xe6a(%rip),%rdi
movsbl -0x80(%rbp,%rax,1),%esi
call   1030 <printf@plt>
jmp    1173 <main+0x53>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x70,%rsp
mov    %rsp,%rdi
call   1040 <gets@plt>
mov    $0xfe,%bl
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0x2(%rbx),%eax
movsbq %al,%rax
add    $0x1,%bl
cmpb   $0x0,(%rsp,%rax,1)
jne    1140 <main+0x20>
test   %bl,%bl
js     1187 <main+0x67>
movzbl %bl,%eax
add    $0x1,%bl
lea    (%rsp,%rax,1),%r15
lea    0xe9b(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
movsbl (%r15),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0xff,%bl
add    $0xffffffffffffffff,%r15
test   %bl,%bl
jg     1170 <main+0x50>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [101 x i8]
%4 = getelementptr inbounds [101 x i8], [101 x i8]* %3, i64 0, i64 0
%5 = call i32 @gets(i8* %4)
br label %6
6: ; preds = %6, %2
%7 = phi i8 [ 0, %2 ], [ %12, %6 ]
%8 = sext i8 %7 to i64
%9 = getelementptr inbounds [101 x i8], [101 x i8]* %3, i64 0, i64 %8
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 0
%12 = add i8 %7, 1
br i1 %11, label %13, label %6
13: ; preds = %6
%14 = add i8 %7, -1
%15 = icmp sgt i8 %14, -1
br i1 %15, label %16, label %24
16: ; preds = %13, %16
%17 = phi i8 [ %22, %16 ], [ %14, %13 ]
%18 = zext i8 %17 to i64
%19 = getelementptr inbounds [101 x i8], [101 x i8]* %3, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %20)
%22 = add nsw i8 %17, -1
%23 = icmp sgt i8 %17, 0
br i1 %23, label %16, label %24
24: ; preds = %16, %13
ret i32 0
}