#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 *alloc(int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *);
void test_1(void) {
  char *p;
  printf("test_1 - start\n");
  p = alloc(1);
  free(p);
  p = alloc(2);
  free(p);
  p = alloc(256);
  free(p);
  p = alloc(1024);
  free(p);
  p = alloc(8096);
  free(p);
  p = alloc(-1);
  free(p);
  printf("test_1 - done\n");
}


x86 assembly (clang, -O0):
<test_1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <alloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    $0x2,%edi
call   1050 <alloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    $0x100,%edi
call   1050 <alloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    $0x400,%edi
call   1050 <alloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    $0x1fa0,%edi
call   1050 <alloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    $0xffffffff,%edi
call   1050 <alloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
lea    0xe3b(%rip),%rdi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_1>:
push   %rax
lea    0xec8(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1050 <alloc@plt>
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x2,%edi
call   1050 <alloc@plt>
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x100,%edi
call   1050 <alloc@plt>
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x400,%edi
call   1050 <alloc@plt>
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x1fa0,%edi
call   1050 <alloc@plt>
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0xffffffff,%edi
call   1050 <alloc@plt>
mov    %rax,%rdi
call   1030 <free@plt>
lea    0xe5f(%rip),%rdi
pop    %rax
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [16 x i8] c"test_1 - start\0A\00"
@.str.1 = [15 x i8] c"test_1 - done\0A\00"
define void @test_1() {
%1 = alloca i8*
%2 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%3 = call i8* @alloc(i32 1)
store i8* %3, i8** %1
%4 = load i8*, i8** %1
%5 = call i32 @free(i8* %4)
%6 = call i8* @alloc(i32 2)
store i8* %6, i8** %1
%7 = load i8*, i8** %1
%8 = call i32 @free(i8* %7)
%9 = call i8* @alloc(i32 256)
store i8* %9, i8** %1
%10 = load i8*, i8** %1
%11 = call i32 @free(i8* %10)
%12 = call i8* @alloc(i32 1024)
store i8* %12, i8** %1
%13 = load i8*, i8** %1
%14 = call i32 @free(i8* %13)
%15 = call i8* @alloc(i32 8096)
store i8* %15, i8** %1
%16 = load i8*, i8** %1
%17 = call i32 @free(i8* %16)
%18 = call i8* @alloc(i32 -1)
store i8* %18, i8** %1
%19 = load i8*, i8** %1
%20 = call i32 @free(i8* %19)
%21 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@str = [15 x i8] c"test_1 - start\00"
@str.2 = [14 x i8] c"test_1 - done\00"
define void @test_1() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%2 = tail call i8* @alloc(i32 1)
%3 = tail call i32 @free(i8* %2)
%4 = tail call i8* @alloc(i32 2)
%5 = tail call i32 @free(i8* %4)
%6 = tail call i8* @alloc(i32 256)
%7 = tail call i32 @free(i8* %6)
%8 = tail call i8* @alloc(i32 1024)
%9 = tail call i32 @free(i8* %8)
%10 = tail call i8* @alloc(i32 8096)
%11 = tail call i32 @free(i8* %10)
%12 = tail call i8* @alloc(i32 -1)
%13 = tail call i32 @free(i8* %12)
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.2, i64 0, i64 0))
ret void
}