#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 *);
int /*<<< orphan*/ ft_puts(char *);
char *ft_strnew(int);
int /*<<< orphan*/ printf(char *, ...);
int main(int ac, char **av) {
  char *str = NULL;
  ft_puts("-----------------------");
  ft_puts("        strnew         ");
  ft_puts("-----------------------");
  ft_puts("AVANT :");
  printf("%p\n", str);
  str = ft_strnew(100);
  ft_puts("APRES :");
  printf("%p\n", str);
  str = ft_strnew(100);
  ft_puts("APRES :");
  printf("%p\n", str);
  printf("\n\n");
  free(str);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    0xe9b(%rip),%rdi
call   1040 <ft_puts@plt>
lea    0xea7(%rip),%rdi
call   1040 <ft_puts@plt>
lea    0xe83(%rip),%rdi
call   1040 <ft_puts@plt>
lea    0xea7(%rip),%rdi
call   1040 <ft_puts@plt>
mov    -0x18(%rbp),%rsi
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x64,%edi
call   1060 <ft_strnew@plt>
mov    %rax,-0x18(%rbp)
lea    0xe87(%rip),%rdi
call   1040 <ft_puts@plt>
mov    -0x18(%rbp),%rsi
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x64,%edi
call   1060 <ft_strnew@plt>
mov    %rax,-0x18(%rbp)
lea    0xe5b(%rip),%rdi
call   1040 <ft_puts@plt>
mov    -0x18(%rbp),%rsi
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%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    0xea4(%rip),%rbx
mov    %rbx,%rdi
call   1050 <ft_puts@plt>
lea    0xead(%rip),%rdi
call   1050 <ft_puts@plt>
mov    %rbx,%rdi
call   1050 <ft_puts@plt>
lea    0xeb1(%rip),%rdi
call   1050 <ft_puts@plt>
lea    0xead(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x64,%edi
call   1070 <ft_strnew@plt>
mov    %rax,%rbx
lea    0xe91(%rip),%r15
mov    %r15,%rdi
call   1050 <ft_puts@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x64,%edi
call   1070 <ft_strnew@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   1050 <ft_puts@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe51(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [24 x i8] c"-----------------------\00"
@.str.1 = [24 x i8] c" strnew \00"
@.str.2 = [8 x i8] c"AVANT :\00"
@.str.3 = [4 x i8] c"%p\0A\00"
@.str.4 = [8 x i8] c"APRES :\00"
@.str.5 = [3 x i8] c"\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
%7 = call i32 @ft_puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @ft_puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @ft_puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @ft_puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%11 = load i8*, i8** %6
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %11)
%13 = call i8* @ft_strnew(i32 100)
store i8* %13, i8** %6
%14 = call i32 @ft_puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%15 = load i8*, i8** %6
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %15)
%17 = call i8* @ft_strnew(i32 100)
store i8* %17, i8** %6
%18 = call i32 @ft_puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%19 = load i8*, i8** %6
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%22 = load i8*, i8** %6
%23 = call i32 @free(i8* %22)
ret i32 0
}

LLVM IR (-O2):
@.str = [24 x i8] c"-----------------------\00"
@.str.1 = [24 x i8] c" strnew \00"
@.str.2 = [8 x i8] c"AVANT :\00"
@.str.3 = [4 x i8] c"%p\0A\00"
@.str.4 = [8 x i8] c"APRES :\00"
@str = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @ft_puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @ft_puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @ft_puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @ft_puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* null)
%8 = tail call i8* @ft_strnew(i32 100)
%9 = tail call i32 @ft_puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %8)
%11 = tail call i8* @ft_strnew(i32 100)
%12 = tail call i32 @ft_puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %11)
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%15 = tail call i32 @free(i8* %11)
ret i32 0
}