#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 */
void *allocator_alloc(int, int /*<<< orphan*/);
int /*<<< orphan*/ allocator_default();
int /*<<< orphan*/ allocator_free(void *, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, char *, int, char *);
void _ensure_allocator_default_can_allocate_and_release_memory(void) {
  void *mem = allocator_alloc(1024, allocator_default());
  if (!(mem != 0)) {
    printf("%s:%d - test '%s' failed\n",
           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/jbrd/libmem/refs/heads/master/src/tests/"
           "allocator_tests.c",
           110, "mem != 0");
    exit(1);
  };
  allocator_free(mem, allocator_default());
}


x86 assembly (clang, -O0):
<_ensure_allocator_default_can_allocate_and_release_memory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1050 <allocator_default@plt>
mov    %eax,%esi
mov    $0x400,%edi
call   1060 <allocator_alloc@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    11a3 <_ensure_allocator_default_can_allocate_and_release_memory+0x53>
lea    0xe7f(%rip),%rdi
lea    0xe92(%rip),%rsi
mov    $0x6e,%edx
lea    0xf1a(%rip),%rcx
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1050 <allocator_default@plt>
mov    -0x10(%rbp),%rdi
mov    %eax,%esi
call   1030 <allocator_free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_ensure_allocator_default_can_allocate_and_release_memory>:
push   %rbx
xor    %eax,%eax
call   1050 <allocator_default@plt>
mov    $0x400,%edi
mov    %eax,%esi
call   1060 <allocator_alloc@plt>
test   %rax,%rax
je     117e <_ensure_allocator_default_can_allocate_and_release_memory+0x2e>
mov    %rax,%rbx
xor    %eax,%eax
call   1050 <allocator_default@plt>
mov    %rbx,%rdi
mov    %eax,%esi
pop    %rbx
jmp    1030 <allocator_free@plt>
lea    0xe7b(%rip),%rdi
lea    0xe8e(%rip),%rsi
lea    0xf1b(%rip),%rcx
mov    $0x6e,%edx
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"%s:%d - test '%s' failed\0A\00"
@.str.1 = [148 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/jbrd/libmem/refs/heads/master/src/tests/allocator_tests.c\00"
@.str.2 = [9 x i8] c"mem != 0\00"
define void @_ensure_allocator_default_can_allocate_and_release_memory() {
%1 = alloca i8*
%2 = call i32 (...) @allocator_default()
%3 = call i8* @allocator_alloc(i32 1024, i32 %2)
store i8* %3, i8** %1
%4 = load i8*, i8** %1
%5 = icmp ne i8* %4, null
br i1 %5, label %9, label %6
6: ; preds = %0
%7 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str.1, i64 0, i64 0), i32 110, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @exit(i32 1)
unreachable
9: ; preds = %0
%10 = load i8*, i8** %1
%11 = call i32 (...) @allocator_default()
%12 = call i32 @allocator_free(i8* %10, i32 %11)
ret void
}

LLVM IR (-O2):
@.str = [26 x i8] c"%s:%d - test '%s' failed\0A\00"
@.str.1 = [148 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/jbrd/libmem/refs/heads/master/src/tests/allocator_tests.c\00"
@.str.2 = [9 x i8] c"mem != 0\00"
define void @_ensure_allocator_default_can_allocate_and_release_memory() {
%1 = tail call i32 (...) @allocator_default()
%2 = tail call i8* @allocator_alloc(i32 1024, i32 %1)
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %7
4: ; preds = %0
%5 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str.1, i64 0, i64 0), i32 110, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %0
%8 = tail call i32 (...) @allocator_default()
%9 = tail call i32 @allocator_free(i8* %2, i32 %8)
ret void
}