#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*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
char *removeAreaNaoUsada(char *);
int /*<<< orphan*/ scanf(char *, char *);
int main(int argc, char **argv) {
  char *s, *aux;
  s = (char *)malloc(sizeof(char) * 1000);
  printf("Insira uma frase (max 1000 caracteres): \n");
  scanf("%s", s);
  printf("Sua frase foi: '%s'\n", s);
  printf("Endereco do ponteiro s: %p\n", s);
  printf("Endereco do ponteiro aux: %p\n", aux);
  aux = s;
  s = removeAreaNaoUsada(s);
  printf("Endereco do ponteiro s: %p\n", s);
  printf("Endereco do ponteiro aux: %p\n", aux);
  free(aux);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x3e8,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xea4(%rip),%rdi
call   1060 <scanf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <removeAreaNaoUsada@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@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
mov    $0x3e8,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xed9(%rip),%rdi
call   1040 <puts@plt>
lea    0xe7b(%rip),%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
lea    0xe6f(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe73(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe7b(%rip),%r15
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1080 <removeAreaNaoUsada@plt>
mov    %r14,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [42 x i8] c"Insira uma frase (max 1000 caracteres): \0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [21 x i8] c"Sua frase foi: '%s'\0A\00"
@.str.3 = [28 x i8] c"Endereco do ponteiro s: %p\0A\00"
@.str.4 = [30 x i8] c"Endereco do ponteiro aux: %p\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i8*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%7 = call i64 @malloc(i32 1000)
%8 = inttoptr i64 %7 to i8*
store i8* %8, i8** %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%10 = load i8*, i8** %5
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = load i8*, i8** %5
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %12)
%14 = load i8*, i8** %5
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %14)
%16 = load i8*, i8** %6
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %16)
%18 = load i8*, i8** %5
store i8* %18, i8** %6
%19 = load i8*, i8** %5
%20 = call i8* @removeAreaNaoUsada(i8* %19)
store i8* %20, i8** %5
%21 = load i8*, i8** %5
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %21)
%23 = load i8*, i8** %6
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %23)
%25 = load i8*, i8** %6
%26 = call i32 @free(i8* %25)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [21 x i8] c"Sua frase foi: '%s'\0A\00"
@.str.3 = [28 x i8] c"Endereco do ponteiro s: %p\0A\00"
@.str.4 = [30 x i8] c"Endereco do ponteiro aux: %p\0A\00"
@str = [41 x i8] c"Insira uma frase (max 1000 caracteres): \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 @malloc(i32 1000)
%4 = inttoptr i64 %3 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* undef)
%10 = tail call i8* @removeAreaNaoUsada(i8* %4)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %10)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %4)
%13 = tail call i32 @free(i8* %4)
ret i32 0
}