#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__ mCalloc(int, int);
double **initDoubleMatrix(int d) {
  int i, j;
  double **A;
  A = (double **)mCalloc(d, sizeof(double *));
  for (i = 0; i < d; i++) {
    A[i] = (double *)mCalloc(d, sizeof(double));
    for (j = 0; j < d; j++)
      A[i][j] = 0.0;
  }
  return (A);
}


x86 assembly (clang, -O0):
<initDoubleMatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x8,%esi
call   1030 <mCalloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11a7 <initDoubleMatrix+0x97>
mov    -0x4(%rbp),%edi
mov    $0x8,%esi
call   1030 <mCalloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1194 <initDoubleMatrix+0x84>
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0xc(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1162 <initDoubleMatrix+0x52>
jmp    1199 <initDoubleMatrix+0x89>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1133 <initDoubleMatrix+0x23>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initDoubleMatrix>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%r14d
mov    $0x8,%esi
call   1040 <mCalloc@plt>
mov    %rax,%r15
test   %r14d,%r14d
jle    1177 <initDoubleMatrix+0x57>
mov    %r14d,%r12d
lea    0x0(,%r12,8),%rbp
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %r14d,%edi
mov    $0x8,%esi
call   1040 <mCalloc@plt>
mov    %rax,(%r15,%rbx,8)
mov    %rax,%rdi
xor    %esi,%esi
mov    %rbp,%rdx
call   1030 <memset@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1150 <initDoubleMatrix+0x30>
mov    %r15,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double** @initDoubleMatrix(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca double**
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = call i64 @mCalloc(i32 %6, i32 8)
%8 = inttoptr i64 %7 to double**
store double** %8, double*** %5
store i32 0, i32* %3
br label %9
9: ; preds = %38, %1
%10 = load i32, i32* %3
%11 = load i32, i32* %2
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %41
13: ; preds = %9
%14 = load i32, i32* %2
%15 = call i64 @mCalloc(i32 %14, i32 8)
%16 = inttoptr i64 %15 to double*
%17 = load double**, double*** %5
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds double*, double** %17, i64 %19
store double* %16, double** %20
store i32 0, i32* %4
br label %21
21: ; preds = %34, %13
%22 = load i32, i32* %4
%23 = load i32, i32* %2
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %37
25: ; preds = %21
%26 = load double**, double*** %5
%27 = load i32, i32* %3
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds double*, double** %26, i64 %28
%30 = load double*, double** %29
%31 = load i32, i32* %4
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double, double* %30, i64 %32
store double 0.000000e+00, double* %33
br label %34
34: ; preds = %25
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
br label %21
37: ; preds = %21
br label %38
38: ; preds = %37
%39 = load i32, i32* %3
%40 = add nsw i32 %39, 1
store i32 %40, i32* %3
br label %9
41: ; preds = %9
%42 = load double**, double*** %5
ret double** %42
}

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