#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(size_t, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
double **mtrx2(const int a, const int b) {
  int i;
  double **x;
  if (!(x = (double **)calloc((size_t)a, sizeof(*x)))) {
    fprintf(stderr, "mtrx2() in theq() : Cannot allocate memory!\n");
    exit(3);
  }
  for (i = 0; i < a; i++)
    if (!(x[i] = (double *)calloc((size_t)b, sizeof(**x)))) {
      fprintf(stderr, "mtrx2() in theq() : Cannot allocate memory!\n");
      exit(3);
    }
  return (x);
}


x86 assembly (clang, -O0):
<mtrx2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movslq -0x4(%rbp),%rdi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1179 <mtrx2+0x49>
mov    0x2e7f(%rip),%rax
mov    (%rax),%edi
lea    0xe96(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x3,%edi
call   1050 <exit@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11e2 <mtrx2+0xb2>
movslq -0x8(%rbp),%rdi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    -0x18(%rbp),%rcx
movslq -0xc(%rbp),%rdx
mov    %rax,(%rcx,%rdx,8)
cmp    $0x0,%rax
jne    11cf <mtrx2+0x9f>
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
lea    0xe40(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x3,%edi
call   1050 <exit@plt>
jmp    11d4 <mtrx2+0xa4>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1180 <mtrx2+0x50>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mtrx2>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
movslq %edi,%rdi
mov    $0x8,%esi
call   1030 <calloc@plt>
test   %rax,%rax
je     118d <mtrx2+0x5d>
mov    %rax,%r14
test   %ebp,%ebp
jle    117f <mtrx2+0x4f>
movslq %ebx,%r15
mov    %ebp,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,(%r14,%rbx,8)
test   %rax,%rax
je     118d <mtrx2+0x5d>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1160 <mtrx2+0x30>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
lea    0xe63(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x3,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [45 x i8] c"mtrx2() in theq() : Cannot allocate memory!\0A\00"
define double** @mtrx2(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca double**
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %3
%8 = sext i32 %7 to i64
%9 = call i64 @calloc(i64 %8, i32 8)
%10 = inttoptr i64 %9 to double**
store double** %10, double*** %6
%11 = icmp ne double** %10, null
br i1 %11, label %16, label %12
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @exit(i32 3)
unreachable
16: ; preds = %2
store i32 0, i32* %5
br label %17
17: ; preds = %36, %16
%18 = load i32, i32* %5
%19 = load i32, i32* %3
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %39
21: ; preds = %17
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = call i64 @calloc(i64 %23, i32 8)
%25 = inttoptr i64 %24 to double*
%26 = load double**, double*** %6
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds double*, double** %26, i64 %28
store double* %25, double** %29
%30 = icmp ne double* %25, null
br i1 %30, label %35, label %31
31: ; preds = %21
%32 = load i32, i32* @stderr
%33 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%34 = call i32 @exit(i32 3)
unreachable
35: ; preds = %21
br label %36
36: ; preds = %35
%37 = load i32, i32* %5
%38 = add nsw i32 %37, 1
store i32 %38, i32* %5
br label %17
39: ; preds = %17
%40 = load double**, double*** %6
ret double** %40
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [45 x i8] c"mtrx2() in theq() : Cannot allocate memory!\0A\00"
define double** @mtrx2(i32 %0, i32 %1) {
%3 = sext i32 %0 to i64
%4 = tail call i64 @calloc(i64 %3, i32 8)
%5 = inttoptr i64 %4 to double**
%6 = icmp eq i64 %4, 0
br i1 %6, label %12, label %7
7: ; preds = %2
%8 = icmp sgt i32 %0, 0
br i1 %8, label %9, label %29
9: ; preds = %7
%10 = sext i32 %1 to i64
%11 = zext i32 %0 to i64
br label %18
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%15 = tail call i32 @exit(i32 3)
unreachable
16: ; preds = %18
%17 = icmp eq i64 %24, %11
br i1 %17, label %29, label %18
18: ; preds = %9, %16
%19 = phi i64 [ 0, %9 ], [ %24, %16 ]
%20 = tail call i64 @calloc(i64 %10, i32 8)
%21 = inttoptr i64 %20 to double*
%22 = getelementptr inbounds double*, double** %5, i64 %19
store double* %21, double** %22
%23 = icmp eq i64 %20, 0
%24 = add nuw nsw i64 %19, 1
br i1 %23, label %25, label %16
25: ; preds = %18
%26 = load i32, i32* @stderr
%27 = tail call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%28 = tail call i32 @exit(i32 3)
unreachable
29: ; preds = %16, %7
ret double** %5
}