#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 **myalloc_data_(size_t);
int /*<<< orphan*/ myfree_data_(char **, size_t);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sleep(int);
int main() {
  char **buffer;
  size_t size1 = 3 * 1024 * 1024, size2 = 1 * 1024 * 1024;
  printf("First ... ");
  buffer = myalloc_data_(size1);
  printf("done\n");
  sleep(10);
  myfree_data_(buffer, size1);
  printf("Second ... ");
  buffer = myalloc_data_(size2);
  printf("done\n");
  sleep(10);
  myfree_data_(buffer, size2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x300000,-0x18(%rbp)
movq   $0x100000,-0x20(%rbp)
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <myalloc_data_@plt>
mov    %rax,-0x10(%rbp)
lea    0xe8c(%rip),%rdi
call   1030 <printf@plt>
mov    $0xa,%edi
call   1060 <sleep@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <myfree_data_@plt>
lea    0xe6f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1040 <myalloc_data_@plt>
mov    %rax,-0x10(%rbp)
lea    0xe50(%rip),%rdi
call   1030 <printf@plt>
mov    $0xa,%edi
call   1060 <sleep@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <myfree_data_@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xea5(%rip),%rdi
call   1040 <printf@plt>
mov    $0x300000,%edi
call   1050 <myalloc_data_@plt>
mov    %rax,%rbx
lea    0xea3(%rip),%r14
mov    %r14,%rdi
call   1030 <puts@plt>
mov    $0xa,%edi
call   1070 <sleep@plt>
mov    $0x300000,%esi
mov    %rbx,%rdi
call   1060 <myfree_data_@plt>
lea    0xe71(%rip),%rdi
call   1040 <printf@plt>
mov    $0x100000,%edi
call   1050 <myalloc_data_@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <puts@plt>
mov    $0xa,%edi
call   1070 <sleep@plt>
mov    $0x100000,%esi
mov    %rbx,%rdi
call   1060 <myfree_data_@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [11 x i8] c"First ... \00"
@.str.1 = [6 x i8] c"done\0A\00"
@.str.2 = [12 x i8] c"Second ... \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8**
%3 = alloca i64
%4 = alloca i64
store i32 0, i32* %1
store i64 3145728, i64* %3
store i64 1048576, i64* %4
%5 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%6 = load i64, i64* %3
%7 = call i8** @myalloc_data_(i64 %6)
store i8** %7, i8*** %2
%8 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @sleep(i32 10)
%10 = load i8**, i8*** %2
%11 = load i64, i64* %3
%12 = call i32 @myfree_data_(i8** %10, i64 %11)
%13 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%14 = load i64, i64* %4
%15 = call i8** @myalloc_data_(i64 %14)
store i8** %15, i8*** %2
%16 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @sleep(i32 10)
%18 = load i8**, i8*** %2
%19 = load i64, i64* %4
%20 = call i32 @myfree_data_(i8** %18, i64 %19)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"First ... \00"
@.str.2 = [12 x i8] c"Second ... \00"
@str.3 = [5 x i8] c"done\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%2 = tail call i8** @myalloc_data_(i64 3145728)
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.3, i64 0, i64 0))
%4 = tail call i32 @sleep(i32 10)
%5 = tail call i32 @myfree_data_(i8** %2, i64 3145728)
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%7 = tail call i8** @myalloc_data_(i64 1048576)
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.3, i64 0, i64 0))
%9 = tail call i32 @sleep(i32 10)
%10 = tail call i32 @myfree_data_(i8** %7, i64 1048576)
ret i32 0
}