#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 strlen(char *);
int main(int argc, char **argv) {
  char S[50];
  char Resultado[50];
  int x;
  printf("Insira uma palavra: ");
  gets(S);
  x = (strlen(S) - 1);
  for (int i = 0; i <= x; i++) {
    Resultado[i] = S[x - i];
    printf("%c", Resultado[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x50(%rbp),%rdi
call   1050 <gets@plt>
lea    -0x50(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x94(%rbp)
movl   $0x0,-0x98(%rbp)
mov    -0x98(%rbp),%eax
cmp    -0x94(%rbp),%eax
jg     11df <main+0xaf>
mov    -0x94(%rbp),%eax
sub    -0x98(%rbp),%eax
cltq
mov    -0x50(%rbp,%rax,1),%cl
movslq -0x98(%rbp),%rax
mov    %cl,-0x90(%rbp,%rax,1)
movslq -0x98(%rbp),%rax
movsbl -0x90(%rbp,%rax,1),%esi
ff
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x98(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x98(%rbp)
jmp    117c <main+0x4c>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
lea    0xeb4(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1060 <gets@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    1185 <main+0x45>
mov    %eax,%ebx
nopl   0x0(%rax)
add    $0xffffffffffffffff,%rbx
movslq %ebx,%rax
movsbl (%rsp,%rax,1),%edi
call   1030 <putchar@plt>
test   %rbx,%rbx
jne    1170 <main+0x30>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

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

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