#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 /*<<< orphan*/ pm_error(char *, int const, int const);
int /*<<< orphan*/ pm_mallocarray2(void **, int const, int const, int const);
char **pm_allocarray(int const cols, int const rows, int const elementSize) {
  char **retval;
  void *result;
  pm_mallocarray2(&result, rows, cols, elementSize);
  if (result == NULL)
    pm_error("Failed to allocate a raster array of %u columns x %u rows", cols,
             rows);
  retval = result;
  return retval;
}


x86 assembly (clang, -O0):
<pm_allocarray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%esi
mov    -0x4(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    -0x20(%rbp),%rdi
call   1030 <pm_mallocarray2@plt>
cmpq   $0x0,-0x20(%rbp)
jne    1160 <pm_allocarray+0x40>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xea5(%rip),%rdi
call   1040 <pm_error@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pm_allocarray>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ecx
mov    %esi,%ebx
mov    %edi,%ebp
mov    %rsp,%rdi
mov    %ebp,%edx
call   1030 <pm_mallocarray2@plt>
mov    (%rsp),%rax
test   %rax,%rax
jne    1150 <pm_allocarray+0x30>
lea    0xebd(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
call   1040 <pm_error@plt>
mov    (%rsp),%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [58 x i8] c"Failed to allocate a raster array of %u columns x %u rows\00"
define i8** @pm_allocarray(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i8*
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = load i32, i32* %5
%10 = load i32, i32* %4
%11 = load i32, i32* %6
%12 = call i32 @pm_mallocarray2(i8** %8, i32 %9, i32 %10, i32 %11)
%13 = load i8*, i8** %8
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %19
15: ; preds = %3
%16 = load i32, i32* %4
%17 = load i32, i32* %5
%18 = call i32 @pm_error(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %17)
br label %19
19: ; preds = %15, %3
%20 = load i8*, i8** %8
%21 = bitcast i8* %20 to i8**
store i8** %21, i8*** %7
%22 = load i8**, i8*** %7
ret i8** %22
}

LLVM IR (-O2):
@.str = [58 x i8] c"Failed to allocate a raster array of %u columns x %u rows\00"
define i8** @pm_allocarray(i32 %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
%6 = call i32 @pm_mallocarray2(i8** %4, i32 %1, i32 %0, i32 %2)
%7 = load i8*, i8** %4
%8 = icmp eq i8* %7, null
br i1 %8, label %11, label %9
9: ; preds = %3
%10 = bitcast i8* %7 to i8**
br label %15
11: ; preds = %3
%12 = call i32 @pm_error(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1)
%13 = bitcast i8** %4 to i8***
%14 = load i8**, i8*** %13
br label %15
15: ; preds = %9, %11
%16 = phi i8** [ %14, %11 ], [ %10, %9 ]
ret i8** %16
}