struct anon$34 *LoadMIPMap(const char *filename, signed int maxlevels) {
  struct anon$33 *img;
  struct anon$34 *mip;
  img = AllocateImageFile(filename);
  if (img == ((struct anon$33 *)((void *)0)))
    return (struct anon$34 *)((void *)0);
  LoadRawImage(img);
  mip = CreateMIPMap(img, maxlevels);
  if (mip == ((struct anon$34 *)((void *)0))) {
    DeallocateImage(img);
    free((void *)mip);
    return (struct anon$34 *)((void *)0);
  }
  return mip;
}


x86 assembly (clang, -O0):
<LoadMIPMap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1050 <AllocateImageFile@plt>
cltq
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1188 <LoadMIPMap+0x38>
movq   $0x0,-0x8(%rbp)
jmp    11db <LoadMIPMap+0x8b>
mov    -0x20(%rbp),%rdi
mov    $0x0,%al
call   1060 <LoadRawImage@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    $0x0,%al
call   1070 <CreateMIPMap@plt>
cltq
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11d3 <LoadMIPMap+0x83>
mov    -0x20(%rbp),%rdi
mov    $0x0,%al
call   1040 <DeallocateImage@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    11db <LoadMIPMap+0x8b>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LoadMIPMap>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <AllocateImageFile@plt>
test   %eax,%eax
je     1183 <LoadMIPMap+0x43>
movslq %eax,%rbp
mov    %rbp,%rdi
xor    %eax,%eax
call   1050 <LoadRawImage@plt>
mov    %rbp,%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1060 <CreateMIPMap@plt>
test   %eax,%eax
je     1177 <LoadMIPMap+0x37>
movslq %eax,%rbx
jmp    1183 <LoadMIPMap+0x43>
xor    %ebx,%ebx
mov    %rbp,%rdi
xor    %eax,%eax
call   1030 <DeallocateImage@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%"struct.anon$34" = type opaque
%"struct.anon$33" = type opaque
define %"struct.anon$34"* @LoadMIPMap(i8* %0, i32 %1) {
%3 = alloca %"struct.anon$34"*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca %"struct.anon$33"*
%7 = alloca %"struct.anon$34"*
store i8* %0, i8** %4
store i32 %1, i32* %5
%8 = load i8*, i8** %4
%9 = call i32 (i8*, ...) bitcast (i32 (...)* @AllocateImageFile to i32 (i8*, ...)*)(i8* %8)
%10 = sext i32 %9 to i64
%11 = inttoptr i64 %10 to %"struct.anon$33"*
store %"struct.anon$33"* %11, %"struct.anon$33"** %6
%12 = load %"struct.anon$33"*, %"struct.anon$33"** %6
%13 = icmp eq %"struct.anon$33"* %12, null
br i1 %13, label %14, label %15
14: ; preds = %2
store %"struct.anon$34"* null, %"struct.anon$34"** %3
br label %32
15: ; preds = %2
%16 = load %"struct.anon$33"*, %"struct.anon$33"** %6
%17 = call i32 (%"struct.anon$33"*, ...) bitcast (i32 (...)* @LoadRawImage to i32 (%"struct.anon$33"*, ...)*)(%"struct.anon$33"* %16)
%18 = load %"struct.anon$33"*, %"struct.anon$33"** %6
%19 = load i32, i32* %5
%20 = call i32 (%"struct.anon$33"*, i32, ...) bitcast (i32 (...)* @CreateMIPMap to i32 (%"struct.anon$33"*, i32, ...)*)(%"struct.anon$33"* %18, i32 %19)
%21 = sext i32 %20 to i64
%22 = inttoptr i64 %21 to %"struct.anon$34"*
store %"struct.anon$34"* %22, %"struct.anon$34"** %7
%23 = load %"struct.anon$34"*, %"struct.anon$34"** %7
%24 = icmp eq %"struct.anon$34"* %23, null
br i1 %24, label %25, label %30
25: ; preds = %15
%26 = load %"struct.anon$33"*, %"struct.anon$33"** %6
%27 = call i32 (%"struct.anon$33"*, ...) bitcast (i32 (...)* @DeallocateImage to i32 (%"struct.anon$33"*, ...)*)(%"struct.anon$33"* %26)
%28 = load %"struct.anon$34"*, %"struct.anon$34"** %7
%29 = bitcast %"struct.anon$34"* %28 to i8*
store %"struct.anon$34"* null, %"struct.anon$34"** %3
br label %32
30: ; preds = %15
%31 = load %"struct.anon$34"*, %"struct.anon$34"** %7
store %"struct.anon$34"* %31, %"struct.anon$34"** %3
br label %32
32: ; preds = %30, %25, %14
%33 = load %"struct.anon$34"*, %"struct.anon$34"** %3
ret %"struct.anon$34"* %33
}

LLVM IR (-O2):
%"struct.anon$34" = type opaque
%"struct.anon$33" = type opaque
define %"struct.anon$34"* @LoadMIPMap(i8* %0, i32 %1) {
%3 = tail call i32 (i8*, ...) bitcast (i32 (...)* @AllocateImageFile to i32 (i8*, ...)*)(i8* %0)
%4 = sext i32 %3 to i64
%5 = inttoptr i64 %4 to %"struct.anon$33"*
%6 = icmp eq i32 %3, 0
br i1 %6, label %16, label %7
7: ; preds = %2
%8 = tail call i32 (%"struct.anon$33"*, ...) bitcast (i32 (...)* @LoadRawImage to i32 (%"struct.anon$33"*, ...)*)(%"struct.anon$33"* %5)
%9 = tail call i32 (%"struct.anon$33"*, i32, ...) bitcast (i32 (...)* @CreateMIPMap to i32 (%"struct.anon$33"*, i32, ...)*)(%"struct.anon$33"* %5, i32 %1)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = tail call i32 (%"struct.anon$33"*, ...) bitcast (i32 (...)* @DeallocateImage to i32 (%"struct.anon$33"*, ...)*)(%"struct.anon$33"* %5)
br label %16
13: ; preds = %7
%14 = sext i32 %9 to i64
%15 = inttoptr i64 %14 to %"struct.anon$34"*
br label %16
16: ; preds = %2, %13, %11
%17 = phi %"struct.anon$34"* [ null, %11 ], [ %15, %13 ], [ null, %2 ]
ret %"struct.anon$34"* %17
}