#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 *eliminaEspacios(char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strlen(char *);
int main() {
  char buffer[] = "       	hola guapo\n";
  char *cadena = &buffer[0];
  cadena = eliminaEspacios(cadena);
  printf("%s", cadena);
  printf("\n\n-----------------\n");
  printf("Tamanio cadena: %lu", strlen(cadena));
  if (NULL != cadena) {
    free(cadena);
    cadena = NULL;
    printf("\n*** Memoria Liberada ***\n");
  } else {
    printf("\n*** Memoria NO Liberada ***\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xea7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xea5(%rip),%eax
mov    %eax,-0x10(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <eliminaEspacios@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%esi
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
cmp    -0x28(%rbp),%rax
je     11ec <main+0xac>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x28(%rbp)
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11fa <main+0xba>
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
movaps 0xea4(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0xa6f70,0x10(%rsp)
mov    %rsp,%rdi
call   1070 <eliminaEspacios@plt>
mov    %rax,%rbx
lea    0xe9a(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xea0(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
lea    0xe78(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
test   %rbx,%rbx
je     11be <main+0x6e>
mov    %rbx,%rdi
call   1030 <free@plt>
lea    0xea0(%rip),%rdi
jmp    11c5 <main+0x75>
lea    0xe7a(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.buffer = [20 x i8] c" \09hola guapo\0A\00"
@.str = [3 x i8] c"%s\00"
@.str.1 = [21 x i8] c"\0A\0A-----------------\0A\00"
@.str.2 = [20 x i8] c"Tamanio cadena: %lu\00"
@.str.3 = [27 x i8] c"\0A*** Memoria Liberada ***\0A\00"
@.str.4 = [30 x i8] c"\0A*** Memoria NO Liberada ***\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i8]
%3 = alloca i8*
store i32 0, i32* %1
%4 = bitcast [20 x i8]* %2 to i8*
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
store i8* %5, i8** %3
%6 = load i8*, i8** %3
%7 = call i8* @eliminaEspacios(i8* %6)
store i8* %7, i8** %3
%8 = load i8*, i8** %3
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%11 = load i8*, i8** %3
%12 = call i32 @strlen(i8* %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = load i8*, i8** %3
%15 = icmp ne i8* null, %14
br i1 %15, label %16, label %20
16: ; preds = %0
%17 = load i8*, i8** %3
%18 = call i32 @free(i8* %17)
store i8* null, i8** %3
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
br label %22
20: ; preds = %0
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
br label %22
22: ; preds = %20, %16
ret i32 0
}

LLVM IR (-O2):
@__const.main.buffer = [20 x i8] c" \09hola guapo\0A\00"
@.str = [3 x i8] c"%s\00"
@.str.2 = [20 x i8] c"Tamanio cadena: %lu\00"
@str = [20 x i8] c"\0A\0A-----------------\00"
@str.5 = [29 x i8] c"\0A*** Memoria NO Liberada ***\00"
@str.6 = [26 x i8] c"\0A*** Memoria Liberada ***\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%3 = call i8* @eliminaEspacios(i8* %2)
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%6 = call i32 @strlen(i8* %3)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %6)
%8 = icmp eq i8* %3, null
br i1 %8, label %11, label %9
9: ; preds = %0
%10 = call i32 @free(i8* %3)
br label %11
11: ; preds = %0, %9
%12 = phi i8* [ getelementptr inbounds ([26 x i8], [26 x i8]* @str.6, i64 0, i64 0), %9 ], [ getelementptr inbounds ([29 x i8], [29 x i8]* @str.5, i64 0, i64 0), %0 ]
%13 = call i32 @puts(i8* dereferenceable(1) %12)
ret i32 0
}