#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 */
scalar_t__ calloc(int, int);
int /*<<< orphan*/ fatalx(char *, int);
int /*<<< orphan*/ lvclear(long *, int, int);
long **initarray_2Dlong(int numrows, int numcolumns, int initval) {
  int i, j;
  long **array;
  if ((array = (long **)calloc((numrows), sizeof(long *))) == NULL)
    fatalx("Unable to allocate %d unit(s) for item \n", numrows);
  for (i = 0; i < numrows; i++) {
    if ((array[i] = (long *)calloc((numcolumns), sizeof(long))) == NULL)
      fatalx("Unable to allocate %d unit(s) for item \n", numcolumns);
    if (initval != 0)
      lvclear(array[i], initval, numcolumns);
  }
  return array;
}


x86 assembly (clang, -O0):
<initarray_2Dlong>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    116b <initarray_2Dlong+0x3b>
mov    -0x4(%rbp),%esi
lea    0xe9a(%rip),%rdi
call   1030 <fatalx@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11e4 <initarray_2Dlong+0xb4>
mov    -0x8(%rbp),%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    -0x20(%rbp),%rcx
movslq -0x10(%rbp),%rdx
mov    %rax,(%rcx,%rdx,8)
cmp    $0x0,%rax
jne    11b0 <initarray_2Dlong+0x80>
mov    -0x8(%rbp),%esi
lea    0xe55(%rip),%rdi
call   1030 <fatalx@plt>
cmpl   $0x0,-0xc(%rbp)
je     11d1 <initarray_2Dlong+0xa1>
mov    -0x20(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
call   1050 <lvclear@plt>
jmp    11d6 <initarray_2Dlong+0xa6>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1172 <initarray_2Dlong+0x42>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initarray_2Dlong>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %esi,%ebp
mov    %edi,%r15d
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,%r13
test   %rax,%rax
je     115c <initarray_2Dlong+0x2c>
test   %r15d,%r15d
jg     1170 <initarray_2Dlong+0x40>
jmp    11d0 <initarray_2Dlong+0xa0>
lea    0xe9d(%rip),%rdi
mov    %r15d,%esi
call   1030 <fatalx@plt>
test   %r15d,%r15d
jle    11d0 <initarray_2Dlong+0xa0>
mov    %r15d,%r12d
xor    %ebx,%ebx
lea    0xe84(%rip),%r15
jmp    1189 <initarray_2Dlong+0x59>
xchg   %ax,%ax
add    $0x1,%rbx
cmp    %rbx,%r12
je     11d0 <initarray_2Dlong+0xa0>
mov    %ebp,%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,0x0(%r13,%rbx,8)
test   %rax,%rax
je     11b0 <initarray_2Dlong+0x80>
test   %r14d,%r14d
jne    11bf <initarray_2Dlong+0x8f>
jmp    1180 <initarray_2Dlong+0x50>
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %ebp,%esi
call   1030 <fatalx@plt>
test   %r14d,%r14d
je     1180 <initarray_2Dlong+0x50>
mov    0x0(%r13,%rbx,8),%rdi
mov    %r14d,%esi
mov    %ebp,%edx
call   1050 <lvclear@plt>
jmp    1180 <initarray_2Dlong+0x50>
mov    %r13,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [41 x i8] c"Unable to allocate %d unit(s) for item \0A\00"
define i64** @initarray_2Dlong(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i64**
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%10 = load i32, i32* %4
%11 = call i64 @calloc(i32 %10, i32 8)
%12 = inttoptr i64 %11 to i64**
store i64** %12, i64*** %9
%13 = icmp eq i64** %12, null
br i1 %13, label %14, label %17
14: ; preds = %3
%15 = load i32, i32* %4
%16 = call i32 @fatalx(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %14, %3
store i32 0, i32* %7
br label %18
18: ; preds = %47, %17
%19 = load i32, i32* %7
%20 = load i32, i32* %4
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %50
22: ; preds = %18
%23 = load i32, i32* %5
%24 = call i64 @calloc(i32 %23, i32 8)
%25 = inttoptr i64 %24 to i64*
%26 = load i64**, i64*** %9
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i64*, i64** %26, i64 %28
store i64* %25, i64** %29
%30 = icmp eq i64* %25, null
br i1 %30, label %31, label %34
31: ; preds = %22
%32 = load i32, i32* %5
%33 = call i32 @fatalx(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %31, %22
%35 = load i32, i32* %6
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %46
37: ; preds = %34
%38 = load i64**, i64*** %9
%39 = load i32, i32* %7
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i64*, i64** %38, i64 %40
%42 = load i64*, i64** %41
%43 = load i32, i32* %6
%44 = load i32, i32* %5
%45 = call i32 @lvclear(i64* %42, i32 %43, i32 %44)
br label %46
46: ; preds = %37, %34
br label %47
47: ; preds = %46
%48 = load i32, i32* %7
%49 = add nsw i32 %48, 1
store i32 %49, i32* %7
br label %18
50: ; preds = %18
%51 = load i64**, i64*** %9
ret i64** %51
}

LLVM IR (-O2):
@.str = [41 x i8] c"Unable to allocate %d unit(s) for item \0A\00"
define i64** @initarray_2Dlong(i32 %0, i32 %1, i32 %2) {
%4 = tail call i64 @calloc(i32 %0, i32 8)
%5 = inttoptr i64 %4 to i64**
%6 = icmp eq i64 %4, 0
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 @fatalx(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %9
9: ; preds = %7, %3
%10 = icmp sgt i32 %0, 0
br i1 %10, label %11, label %29
11: ; preds = %9
%12 = icmp eq i32 %2, 0
%13 = zext i32 %0 to i64
br label %14
14: ; preds = %11, %26
%15 = phi i64 [ 0, %11 ], [ %27, %26 ]
%16 = tail call i64 @calloc(i32 %1, i32 8)
%17 = inttoptr i64 %16 to i64*
%18 = getelementptr inbounds i64*, i64** %5, i64 %15
store i64* %17, i64** %18
%19 = icmp eq i64 %16, 0
br i1 %19, label %20, label %22
20: ; preds = %14
%21 = tail call i32 @fatalx(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %1)
br label %22
22: ; preds = %20, %14
br i1 %12, label %26, label %23
23: ; preds = %22
%24 = load i64*, i64** %18
%25 = tail call i32 @lvclear(i64* %24, i32 %2, i32 %1)
br label %26
26: ; preds = %22, %23
%27 = add nuw nsw i64 %15, 1
%28 = icmp eq i64 %27, %13
br i1 %28, label %29, label %14
29: ; preds = %26, %9
ret i64** %5
}