#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 *);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ puts(char *);
int strlen(char *);
int main() {
  char input[64];
  int size, c;
  printf("Enter a common earthly phrase please: -> ");
  gets(input);
  puts("Here is how we say that on Backward Planet:");
  size = strlen(input);
  for (c = size - 1; c >= 0; c--)
    putchar(input[c]);
  putchar('\n');
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
call   1060 <printf@plt>
lea    -0x50(%rbp),%rdi
call   1070 <gets@plt>
lea    0xeaf(%rip),%rdi
call   1040 <puts@plt>
lea    -0x50(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x54(%rbp)
mov    -0x54(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x58(%rbp)
cmpl   $0x0,-0x58(%rbp)
jl     11bb <main+0x6b>
movslq -0x58(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%edi
call   1030 <putchar@plt>
mov    -0x58(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x58(%rbp)
jmp    1195 <main+0x45>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
lea    0xea4(%rip),%rdi
call   1060 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1070 <gets@plt>
lea    0xeb7(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    11a6 <main+0x56>
mov    %eax,%ebx
add    $0x1,%rbx
nopw   0x0(%rax,%rax,1)
lea    -0x2(%rbx),%eax
movsbl (%rsp,%rax,1),%edi
call   1030 <putchar@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     1190 <main+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [42 x i8] c"Enter a common earthly phrase please: -> \00"
@.str.1 = [44 x i8] c"Here is how we say that on Backward Planet:\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [64 x i8]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%7 = call i32 @gets(i8* %6)
%8 = call i32 @puts(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0))
%9 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%10 = call i32 @strlen(i8* %9)
store i32 %10, i32* %3
%11 = load i32, i32* %3
%12 = sub nsw i32 %11, 1
store i32 %12, i32* %4
br label %13
13: ; preds = %22, %0
%14 = load i32, i32* %4
%15 = icmp sge i32 %14, 0
br i1 %15, label %16, label %25
16: ; preds = %13
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = call i32 @putchar(i8 signext %20)
br label %22
22: ; preds = %16
%23 = load i32, i32* %4
%24 = add nsw i32 %23, -1
store i32 %24, i32* %4
br label %13
25: ; preds = %13
%26 = call i32 @putchar(i8 signext 10)
ret i32 0
}

LLVM IR (-O2):
@.str = [42 x i8] c"Enter a common earthly phrase please: -> \00"
@.str.1 = [44 x i8] c"Here is how we say that on Backward Planet:\00"
define i32 @main() {
%1 = alloca [64 x i8]
%2 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @gets(i8* %2)
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @strlen(i8* %2)
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %18
8: ; preds = %0
%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 [64 x i8], [64 x i8]* %1, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = call i32 @putchar(i8 signext %15)
%17 = icmp ugt i64 %11, 1
br i1 %17, label %10, label %18
18: ; preds = %10, %0
%19 = call i32 @putchar(i8 signext 10)
ret i32 0
}