#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 */
char *duplica_string(char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, char *);
char *voltea_string(char *);
int main(void) {
  char *s = "Campos verdes";
  char *s_duplicado;
  char *s_invertido;
  s_duplicado = duplica_string(s);
  s_invertido = voltea_string(s);
  printf("Duplicado: %s\n", s_duplicado);
  printf("Invertido: %s\n", s_invertido);
  free(s_duplicado);
  free(s_invertido);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <duplica_string@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <voltea_string@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe8f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xe8e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
lea    0xeb4(%rip),%r14
mov    %r14,%rdi
call   1050 <duplica_string@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1060 <voltea_string@plt>
mov    %rax,%rbx
lea    0xea5(%rip),%rdi
mov    %r15,%rsi
call   1040 <printf@plt>
lea    0xea5(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Campos verdes\00"
@.str.1 = [15 x i8] c"Duplicado: %s\0A\00"
@.str.2 = [15 x i8] c"Invertido: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8** %2
%5 = load i8*, i8** %2
%6 = call i8* @duplica_string(i8* %5)
store i8* %6, i8** %3
%7 = load i8*, i8** %2
%8 = call i8* @voltea_string(i8* %7)
store i8* %8, i8** %4
%9 = load i8*, i8** %3
%10 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = load i8*, i8** %4
%12 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %11)
%13 = load i8*, i8** %3
%14 = call i32 @free(i8* %13)
%15 = load i8*, i8** %4
%16 = call i32 @free(i8* %15)
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"Campos verdes\00"
@.str.1 = [15 x i8] c"Duplicado: %s\0A\00"
@.str.2 = [15 x i8] c"Invertido: %s\0A\00"
define i32 @main() {
%1 = tail call i8* @duplica_string(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%2 = tail call i8* @voltea_string(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%5 = tail call i32 @free(i8* %1)
%6 = tail call i32 @free(i8* %2)
ret i32 0
}