#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__ malloc(unsigned long);
double **make2DDoubleArray(unsigned long int x, unsigned long int y) {
  double **X;
  unsigned long int ix;
  X = (double **)malloc(x * sizeof(double *));
  for (ix = 0; ix < x; ix++) {
    X[ix] = (double *)malloc(y * sizeof(double));
  }
  return X;
}


x86 assembly (clang, -O0):
<make2DDoubleArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
shl    $0x3,%rdi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x8(%rbp),%rax
jae    1174 <make2DDoubleArray+0x64>
mov    -0x10(%rbp),%rdi
shl    $0x3,%rdi
call   1030 <malloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1139 <make2DDoubleArray+0x29>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make2DDoubleArray>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
lea    0x0(,%rdi,8),%rdi
call   1030 <malloc@plt>
mov    %rax,%r12
test   %r15,%r15
je     1155 <make2DDoubleArray+0x45>
shl    $0x3,%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <malloc@plt>
mov    %rax,(%r12,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1140 <make2DDoubleArray+0x30>
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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