#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*/ EXIT_FAILURE;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ malloc(int const);
int **matAlloc(const int row, const int col) {
  assert(row >= 0);
  assert(col >= 0);
  int **matrix;
  if ((matrix = (int **)malloc(row * sizeof(int *))) == NULL) {
    exit(EXIT_FAILURE);
  }
  for (int i = 0; i < row; i++) {
    if ((matrix[i] = (int *)malloc(col * sizeof(int))) == NULL) {
      exit(EXIT_FAILURE);
    }
  }
  return matrix;
}


x86 assembly (clang, -O0):
<matAlloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x0,-0x8(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    118b <matAlloc+0x5b>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11e4 <matAlloc+0xb4>
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    -0x10(%rbp),%rcx
movslq -0x14(%rbp),%rdx
mov    %rax,(%rcx,%rdx,8)
cmp    $0x0,%rax
jne    11d1 <matAlloc+0xa1>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
jmp    11d6 <matAlloc+0xa6>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1192 <matAlloc+0x62>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matAlloc>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r15d
mov    %edi,%r14d
not    %edi
shr    $0x1f,%edi
call   1030 <assert@plt>
mov    %r15d,%edi
not    %edi
shr    $0x1f,%edi
call   1030 <assert@plt>
lea    0x0(,%r14,8),%edi
call   1040 <malloc@plt>
test   %rax,%rax
je     11a6 <matAlloc+0x76>
mov    %rax,%r12
test   %r14d,%r14d
jle    119a <matAlloc+0x6a>
shl    $0x2,%r15d
mov    %r14d,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %r15d,%edi
call   1040 <malloc@plt>
mov    %rax,(%r12,%rbx,8)
test   %rax,%rax
je     11a6 <matAlloc+0x76>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1180 <matAlloc+0x50>
mov    %r12,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e33(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
define i32** @matAlloc(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32**
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %3
%8 = icmp sge i32 %7, 0
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = load i32, i32* %4
%12 = icmp sge i32 %11, 0
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = mul i64 %16, 8
%18 = trunc i64 %17 to i32
%19 = call i64 @malloc(i32 %18)
%20 = inttoptr i64 %19 to i32**
store i32** %20, i32*** %5
%21 = icmp eq i32** %20, null
br i1 %21, label %22, label %25
22: ; preds = %2
%23 = load i32, i32* @EXIT_FAILURE
%24 = call i32 @exit(i32 %23)
unreachable
25: ; preds = %2
store i32 0, i32* %6
br label %26
26: ; preds = %46, %25
%27 = load i32, i32* %6
%28 = load i32, i32* %3
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %49
30: ; preds = %26
%31 = load i32, i32* %4
%32 = sext i32 %31 to i64
%33 = mul i64 %32, 4
%34 = trunc i64 %33 to i32
%35 = call i64 @malloc(i32 %34)
%36 = inttoptr i64 %35 to i32*
%37 = load i32**, i32*** %5
%38 = load i32, i32* %6
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i32*, i32** %37, i64 %39
store i32* %36, i32** %40
%41 = icmp eq i32* %36, null
br i1 %41, label %42, label %45
42: ; preds = %30
%43 = load i32, i32* @EXIT_FAILURE
%44 = call i32 @exit(i32 %43)
unreachable
45: ; preds = %30
br label %46
46: ; preds = %45
%47 = load i32, i32* %6
%48 = add nsw i32 %47, 1
store i32 %48, i32* %6
br label %26
49: ; preds = %26
%50 = load i32**, i32*** %5
ret i32** %50
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
define i32** @matAlloc(i32 %0, i32 %1) {
%3 = xor i32 %0, -1
%4 = lshr i32 %3, 31
%5 = tail call i32 @assert(i32 %4)
%6 = xor i32 %1, -1
%7 = lshr i32 %6, 31
%8 = tail call i32 @assert(i32 %7)
%9 = shl i32 %0, 3
%10 = tail call i64 @malloc(i32 %9)
%11 = inttoptr i64 %10 to i32**
%12 = icmp eq i64 %10, 0
br i1 %12, label %18, label %13
13: ; preds = %2
%14 = icmp sgt i32 %0, 0
br i1 %14, label %15, label %23
15: ; preds = %13
%16 = shl i32 %1, 2
%17 = zext i32 %0 to i64
br label %24
18: ; preds = %2
%19 = load i32, i32* @EXIT_FAILURE
%20 = tail call i32 @exit(i32 %19)
unreachable
21: ; preds = %24
%22 = icmp eq i64 %30, %17
br i1 %22, label %23, label %24
23: ; preds = %21, %13
ret i32** %11
24: ; preds = %15, %21
%25 = phi i64 [ 0, %15 ], [ %30, %21 ]
%26 = tail call i64 @malloc(i32 %16)
%27 = inttoptr i64 %26 to i32*
%28 = getelementptr inbounds i32*, i32** %11, i64 %25
store i32* %27, i32** %28
%29 = icmp eq i64 %26, 0
%30 = add nuw nsw i64 %25, 1
br i1 %29, label %31, label %21
31: ; preds = %24
%32 = load i32, i32* @EXIT_FAILURE
%33 = tail call i32 @exit(i32 %32)
unreachable
}