#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 *, ...);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
main() {
  int n_car = 0, n_caracteres = 0;
  char car, frase[50], stemp[50];
  printf("Introduzca una frase:\n");
  gets(frase);
  strcpy(stemp, frase);
  n_caracteres = strlen(frase);
  printf("%s", frase);
  do {
    car = frase[n_caracteres - 1];
    for (n_car = n_caracteres - 2; n_car >= 0; n_car--) {
      frase[n_car + 1] = frase[n_car];
    }
    frase[0] = car;
    printf("-%s", frase);
  } while (strcmp(frase, stemp));
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x40(%rbp),%rdi
call   1070 <gets@plt>
lea    -0x80(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x40(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0xc(%rbp)
lea    -0x40(%rbp),%rsi
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x40(%rbp,%rax,1),%al
mov    %al,-0xd(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     11f6 <main+0xa6>
movslq -0x8(%rbp),%rax
mov    -0x40(%rbp,%rax,1),%cl
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cltq
mov    %cl,-0x40(%rbp,%rax,1)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    11ca <main+0x7a>
mov    -0xd(%rbp),%al
mov    %al,-0x40(%rbp)
lea    -0x40(%rbp),%rsi
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x40(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11b2 <main+0x62>
lea    0xde9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
lea    0xe7f(%rip),%rdi
call   1050 <puts@plt>
mov    %rsp,%r12
mov    %r12,%rdi
call   1090 <gets@plt>
lea    0x40(%rsp),%rbx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <strcpy@plt>
mov    %r12,%rdi
call   1060 <strlen@plt>
mov    %eax,%ebp
lea    0xe4b(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
movslq %ebp,%rbp
lea    -0x2(%rbp),%r14d
lea    -0x1(%rbp),%r13d
and    $0x3,%r13d
lea    0xe2a(%rip),%r15
jmp    1200 <main+0x90>
nopl   0x0(%rax,%rax,1)
mov    %al,(%rsp)
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1254 <main+0xe4>
mov    -0x1(%rsp,%rbp,1),%al
cmp    $0x2,%ebp
jl     11e0 <main+0x70>
mov    %rbx,%rsi
mov    %r14,%rcx
test   %r13,%r13
je     1232 <main+0xc2>
mov    %r13,%rdx
mov    %r14,%rcx
nopw   0x0(%rax,%rax,1)
movzbl (%rsp,%rcx,1),%ebx
mov    %bl,0x1(%rsp,%rcx,1)
add    $0xffffffffffffffff,%rcx
add    $0xffffffffffffffff,%rdx
jne    1220 <main+0xb0>
cmp    $0x3,%r14d
mov    %rsi,%rbx
jb     11e0 <main+0x70>
add    $0x4,%rcx
nop
mov    -0x7(%rsp,%rcx,1),%edx
mov    %edx,-0x6(%rsp,%rcx,1)
add    $0xfffffffffffffffc,%rcx
cmp    $0x3,%rcx
jg     1240 <main+0xd0>
jmp    11e0 <main+0x70>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Introduzca una frase:\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [4 x i8] c"-%s\00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
%5 = alloca [50 x i8]
%6 = alloca [50 x i8]
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%9 = call i32 @gets(i8* %8)
%10 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%11 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%12 = call i32 @strcpy(i8* %10, i8* %11)
%13 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%14 = call i32 @strlen(i8* %13)
store i32 %14, i32* %3
%15 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %15)
br label %17
17: ; preds = %45, %0
%18 = load i32, i32* %3
%19 = sub nsw i32 %18, 1
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 %20
%22 = load i8, i8* %21
store i8 %22, i8* %4
%23 = load i32, i32* %3
%24 = sub nsw i32 %23, 2
store i32 %24, i32* %2
br label %25
25: ; preds = %37, %17
%26 = load i32, i32* %2
%27 = icmp sge i32 %26, 0
br i1 %27, label %28, label %40
28: ; preds = %25
%29 = load i32, i32* %2
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = load i32, i32* %2
%34 = add nsw i32 %33, 1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 %35
store i8 %32, i8* %36
br label %37
37: ; preds = %28
%38 = load i32, i32* %2
%39 = add nsw i32 %38, -1
store i32 %39, i32* %2
br label %25
40: ; preds = %25
%41 = load i8, i8* %4
%42 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
store i8 %41, i8* %42
%43 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %43)
br label %45
45: ; preds = %40
%46 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%47 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%48 = call i64 @strcmp(i8* %46, i8* %47)
%49 = icmp ne i64 %48, 0
br i1 %49, label %17, label %50
50: ; preds = %45
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%52 = load i32, i32* %1
ret i32 %52
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [4 x i8] c"-%s\00"
@str = [22 x i8] c"Introduzca una frase:\00"
define i32 @main() {
%1 = alloca [50 x i8]
%2 = alloca [50 x i8]
%3 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%6 = call i32 @gets(i8* %3)
%7 = call i32 @strcpy(i8* %4, i8* %3)
%8 = call i32 @strlen(i8* %3)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%10 = add nsw i32 %8, -1
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %11
%13 = add i32 %8, -2
%14 = icmp sgt i32 %8, 1
%15 = zext i32 %13 to i64
%16 = add nuw nsw i64 %15, 1
%17 = and i64 %16, 3
%18 = icmp eq i64 %17, 0
%19 = icmp ult i32 %13, 3
br label %20
20: ; preds = %55, %0
%21 = load i8, i8* %12
br i1 %14, label %22, label %55
22: ; preds = %20
br i1 %18, label %33, label %23
23: ; preds = %22, %23
%24 = phi i64 [ %30, %23 ], [ %15, %22 ]
%25 = phi i64 [ %31, %23 ], [ 0, %22 ]
%26 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %24
%27 = load i8, i8* %26
%28 = add nuw nsw i64 %24, 1
%29 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %28
store i8 %27, i8* %29
%30 = add nsw i64 %24, -1
%31 = add i64 %25, 1
%32 = icmp eq i64 %31, %17
br i1 %32, label %33, label %23
33: ; preds = %23, %22
%34 = phi i64 [ %15, %22 ], [ %30, %23 ]
br i1 %19, label %55, label %35
35: ; preds = %33, %35
%36 = phi i64 [ %53, %35 ], [ %34, %33 ]
%37 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %36
%38 = load i8, i8* %37
%39 = add nuw nsw i64 %36, 1
%40 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %39
store i8 %38, i8* %40
%41 = add nsw i64 %36, -1
%42 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %41
%43 = load i8, i8* %42
%44 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %36
store i8 %43, i8* %44
%45 = add nsw i64 %36, -2
%46 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %45
%47 = load i8, i8* %46
%48 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %41
store i8 %47, i8* %48
%49 = add nsw i64 %36, -3
%50 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %49
%51 = load i8, i8* %50
%52 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %45
store i8 %51, i8* %52
%53 = add nsw i64 %36, -4
%54 = icmp sgt i64 %36, 3
br i1 %54, label %35, label %55
55: ; preds = %33, %35, %20
store i8 %21, i8* %3
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%57 = call i64 @strcmp(i8* %3, i8* %4)
%58 = icmp eq i64 %57, 0
br i1 %58, label %59, label %20
59: ; preds = %55
%60 = call i32 @putchar(i32 10)
ret i32 0
}