#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 */
double **getMat(int, int);
scalar_t__ malloc(int);
void getParamMats(double ****paramMats, int hiddenLayerNum, int inputSize,
                  int *layerSizes) {
  (*paramMats) = (double ***)malloc(sizeof(double **) * hiddenLayerNum);
  int ctr;
  (*paramMats)[0] = getMat(inputSize, layerSizes[0]);
  for (ctr = 1; ctr < hiddenLayerNum; ctr++) {
    (*paramMats)[ctr] = getMat(layerSizes[ctr - 1], layerSizes[ctr]);
  }
}


x86 assembly (clang, -O0):
<getParamMats>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%edi
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
call   1030 <getMat@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11bd <getParamMats+0x9d>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
call   1030 <getMat@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    1171 <getParamMats+0x51>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getParamMats>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rcx,%rbx
mov    %edx,%ebp
mov    %esi,%r15d
mov    %rdi,%r14
lea    0x0(,%r15,8),%edi
call   1040 <malloc@plt>
mov    %rax,(%r14)
mov    (%rbx),%esi
mov    %ebp,%edi
call   1030 <getMat@plt>
mov    (%r14),%rcx
mov    %rax,(%rcx)
cmp    $0x2,%r15d
jl     117c <getParamMats+0x5c>
mov    %r15d,%r15d
mov    $0x1,%ebp
nop
mov    -0x4(%rbx,%rbp,4),%edi
mov    (%rbx,%rbp,4),%esi
call   1030 <getMat@plt>
mov    (%r14),%rcx
mov    %rax,(%rcx,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1160 <getParamMats+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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