#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);
void initMat(int rows, int cols, double ***matPtr) {
  int k = 0;
  *matPtr = (double **)calloc(rows, sizeof(double *));
  for (k = 0; k < rows; k++) {
    (*matPtr)[k] = (double *)calloc(cols, sizeof(double));
  }
}


x86 assembly (clang, -O0):
<initMat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1180 <initMat+0x70>
mov    -0x8(%rbp),%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1147 <initMat+0x37>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initMat>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r12
mov    %esi,%r15d
mov    %edi,%r14d
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,(%r12)
test   %r14d,%r14d
jle    115e <initMat+0x4e>
mov    %r14d,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %r15d,%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    (%r12),%rcx
mov    %rax,(%rcx,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1140 <initMat+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @initMat(i32 %0, i32 %1, double*** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca double***
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store double*** %2, double**** %6
store i32 0, i32* %7
%8 = load i32, i32* %4
%9 = call i64 @calloc(i32 %8, i32 8)
%10 = inttoptr i64 %9 to double**
%11 = load double***, double**** %6
store double** %10, double*** %11
store i32 0, i32* %7
br label %12
12: ; preds = %25, %3
%13 = load i32, i32* %7
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %28
16: ; preds = %12
%17 = load i32, i32* %5
%18 = call i64 @calloc(i32 %17, i32 8)
%19 = inttoptr i64 %18 to double*
%20 = load double***, double**** %6
%21 = load double**, double*** %20
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds double*, double** %21, i64 %23
store double* %19, double** %24
br label %25
25: ; preds = %16
%26 = load i32, i32* %7
%27 = add nsw i32 %26, 1
store i32 %27, i32* %7
br label %12
28: ; preds = %12
ret void
}

LLVM IR (-O2):
define void @initMat(i32 %0, i32 %1, double*** nocapture %2) {
%4 = tail call i64 @calloc(i32 %0, i32 8)
%5 = inttoptr i64 %4 to double**
store double** %5, double*** %2
%6 = icmp sgt i32 %0, 0
br i1 %6, label %7, label %17
7: ; preds = %3
%8 = zext i32 %0 to i64
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 0, %7 ], [ %15, %9 ]
%11 = tail call i64 @calloc(i32 %1, i32 8)
%12 = inttoptr i64 %11 to double*
%13 = load double**, double*** %2
%14 = getelementptr inbounds double*, double** %13, i64 %10
store double* %12, double** %14
%15 = add nuw nsw i64 %10, 1
%16 = icmp eq i64 %15, %8
br i1 %16, label %17, label %9
17: ; preds = %9, %3
ret void
}