void *__allocate(size, filename, linenumber)
int size;
char *filename;
int linenumber;
{
  void *tmp;
  if (size < 0)
    __cause_ex1("rangefail", filename, linenumber);
  tmp = malloc(size);
  if (!tmp)
    __cause_ex1("allocatefail", filename, linenumber);
  return tmp;
}


x86 assembly (clang, -O0):
<__allocate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    1151 <__allocate+0x31>
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1040 <__cause_ex1@plt>
movslq -0x4(%rbp),%rdi
call   1030 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    117e <__allocate+0x5e>
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1040 <__cause_ex1@plt>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__allocate>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %edi,%ebp
test   %edi,%edi
jns    1144 <__allocate+0x24>
lea    0xec9(%rip),%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
xor    %eax,%eax
call   1040 <__cause_ex1@plt>
movslq %ebp,%rdi
call   1030 <malloc@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    1168 <__allocate+0x48>
lea    0xeaf(%rip),%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
xor    %eax,%eax
call   1040 <__cause_ex1@plt>
mov    %rbp,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"rangefail\00"
@.str.1 = [13 x i8] c"allocatefail\00"
define i8* @__allocate(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %3
%11 = load i8*, i8** %5
%12 = load i32, i32* %6
%13 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @__cause_ex1 to i32 (i8*, i8*, i32, ...)*)(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %11, i32 %12)
br label %14
14: ; preds = %10, %3
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = call i8* @malloc(i64 %16)
store i8* %17, i8** %7
%18 = load i8*, i8** %7
%19 = icmp ne i8* %18, null
br i1 %19, label %24, label %20
20: ; preds = %14
%21 = load i8*, i8** %5
%22 = load i32, i32* %6
%23 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @__cause_ex1 to i32 (i8*, i8*, i32, ...)*)(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %21, i32 %22)
br label %24
24: ; preds = %20, %14
%25 = load i8*, i8** %7
ret i8* %25
}

LLVM IR (-O2):
@.str = [10 x i8] c"rangefail\00"
@.str.1 = [13 x i8] c"allocatefail\00"
define i8* @__allocate(i32 %0, i8* %1, i32 %2) {
%4 = icmp slt i32 %0, 0
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @__cause_ex1 to i32 (i8*, i8*, i32, ...)*)(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %1, i32 %2)
br label %7
7: ; preds = %5, %3
%8 = sext i32 %0 to i64
%9 = tail call i8* @malloc(i64 %8)
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = tail call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @__cause_ex1 to i32 (i8*, i8*, i32, ...)*)(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %1, i32 %2)
br label %13
13: ; preds = %11, %7
ret i8* %9
}