#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 *custom_alloc(int);
int /*<<< orphan*/ custom_free(int *);
int /*<<< orphan*/ make_leak();
int *malloc(int);
int main(void) {
  int *array;
  int *array3;
  array = custom_alloc(sizeof(int) * 10);
  array[8] = 8;
  array[9] = 8;
  array[10] = 10;
  custom_free(array);
  custom_free(NULL);
  array3 = malloc(sizeof(int) * 10);
  custom_free(array3);
  make_leak();
  return array[0];
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x28,%edi
call   1050 <custom_alloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x8,0x20(%rax)
mov    -0x10(%rbp),%rax
movl   $0x8,0x24(%rax)
mov    -0x10(%rbp),%rax
movl   $0xa,0x28(%rax)
mov    -0x10(%rbp),%rdi
call   1060 <custom_free@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <custom_free@plt>
mov    $0x28,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <custom_free@plt>
mov    $0x0,%al
call   1030 <make_leak@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x28,%edi
call   1050 <custom_alloc@plt>
mov    %rax,%rbx
movabs $0x800000008,%rax
mov    %rax,0x20(%rbx)
movl   $0xa,0x28(%rbx)
mov    %rbx,%rdi
call   1060 <custom_free@plt>
xor    %edi,%edi
call   1060 <custom_free@plt>
mov    $0x28,%edi
call   1040 <malloc@plt>
mov    %rax,%rdi
call   1060 <custom_free@plt>
xor    %eax,%eax
call   1030 <make_leak@plt>
mov    (%rbx),%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
store i32 0, i32* %1
%4 = call i32* @custom_alloc(i32 40)
store i32* %4, i32** %2
%5 = load i32*, i32** %2
%6 = getelementptr inbounds i32, i32* %5, i64 8
store i32 8, i32* %6
%7 = load i32*, i32** %2
%8 = getelementptr inbounds i32, i32* %7, i64 9
store i32 8, i32* %8
%9 = load i32*, i32** %2
%10 = getelementptr inbounds i32, i32* %9, i64 10
store i32 10, i32* %10
%11 = load i32*, i32** %2
%12 = call i32 @custom_free(i32* %11)
%13 = call i32 @custom_free(i32* null)
%14 = call i32* @malloc(i32 40)
store i32* %14, i32** %3
%15 = load i32*, i32** %3
%16 = call i32 @custom_free(i32* %15)
%17 = call i32 (...) @make_leak()
%18 = load i32*, i32** %2
%19 = getelementptr inbounds i32, i32* %18, i64 0
%20 = load i32, i32* %19
ret i32 %20
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32* @custom_alloc(i32 40)
%2 = getelementptr inbounds i32, i32* %1, i64 8
store i32 8, i32* %2
%3 = getelementptr inbounds i32, i32* %1, i64 9
store i32 8, i32* %3
%4 = getelementptr inbounds i32, i32* %1, i64 10
store i32 10, i32* %4
%5 = tail call i32 @custom_free(i32* %1)
%6 = tail call i32 @custom_free(i32* null)
%7 = tail call i32* @malloc(i32 40)
%8 = tail call i32 @custom_free(i32* %7)
%9 = tail call i32 (...) @make_leak()
%10 = load i32, i32* %1
ret i32 %10
}