#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(int);
void getLayers(double ***hiddenLayers, int hiddenLayerNum,
               int *hiddenLayerSizes) {
  (*hiddenLayers) = (double **)malloc(sizeof(double *) * hiddenLayerNum);
  int layerCtr;
  for (layerCtr = 0; layerCtr < hiddenLayerNum; layerCtr++) {
    (*hiddenLayers)[layerCtr] =
        (double *)malloc(sizeof(double) * hiddenLayerSizes[layerCtr]);
  }
}


x86 assembly (clang, -O0):
<getLayers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1186 <getLayers+0x76>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movslq (%rax,%rcx,4),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,%rdx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1143 <getLayers+0x33>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getLayers>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %esi,%r15d
mov    %rdi,%r12
lea    0x0(,%r15,8),%edi
call   1030 <malloc@plt>
mov    %rax,(%r12)
test   %r15d,%r15d
jle    115d <getLayers+0x4d>
mov    %r15d,%r15d
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    (%r14,%rbx,4),%edi
shl    $0x3,%edi
call   1030 <malloc@plt>
mov    (%r12),%rcx
mov    %rax,(%rcx,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1140 <getLayers+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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