#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 */
int RAND_MAX;
scalar_t__ malloc(int);
int random();
double **getMat(int inputLayerSize, int outputLayerSize) {
  double **mat = (double **)malloc(sizeof(double *) * inputLayerSize);
  int rowIndex, colIndex;
  for (rowIndex = 0; rowIndex < inputLayerSize; rowIndex++) {
    mat[rowIndex] = (double *)malloc(sizeof(double) * outputLayerSize);
    for (colIndex = 0; colIndex < outputLayerSize; colIndex++) {
      mat[rowIndex][colIndex] =
          ((random() - RAND_MAX / 2) * 0.01) / (6 * RAND_MAX);
    }
  }
  return mat;
}


x86 assembly (clang, -O0):
<getMat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11ff <getMat+0xdf>
movslq -0x8(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ec <getMat+0xcc>
mov    $0x0,%al
call   1030 <random@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2e52(%rip),%rax
mov    (%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe4d(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    0x2e2a(%rip),%rax
imul   $0x6,(%rax),%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1179 <getMat+0x59>
jmp    11f1 <getMat+0xd1>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1148 <getMat+0x28>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getMat>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,0x10(%rsp)
mov    %edi,%r15d
lea    0x0(,%r15,8),%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
test   %r15d,%r15d
jle    11de <getMat+0xbe>
mov    0x10(%rsp),%rax
lea    0x0(,%rax,8),%ecx
mov    %ecx,0xc(%rsp)
mov    %r15d,%r15d
mov    %eax,%ebp
mov    0x2e7d(%rip),%r13
xor    %r14d,%r14d
jmp    1179 <getMat+0x59>
add    $0x1,%r14
cmp    %r15,%r14
je     11de <getMat+0xbe>
mov    0xc(%rsp),%edi
call   1040 <malloc@plt>
mov    %rax,(%rbx,%r14,8)
cmpl   $0x0,0x10(%rsp)
jle    1170 <getMat+0x50>
xor    %r12d,%r12d
xor    %eax,%eax
call   1030 <random@plt>
movsd  0xe61(%rip),%xmm1
mov    0x0(%r13),%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
add    %ecx,%edx
sar    %edx
sub    %edx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  %xmm1,%xmm0
add    %ecx,%ecx
lea    (%rcx,%rcx,2),%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
mov    (%rbx,%r14,8),%rax
movsd  %xmm0,(%rax,%r12,8)
add    $0x1,%r12
cmp    %r12,%rbp
jne    1190 <getMat+0x70>
jmp    1170 <getMat+0x50>
mov    %rbx,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@RAND_MAX = global i32 0
define double** @getMat(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca double**
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%8 = load i32, i32* %3
%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**
store double** %13, double*** %5
store i32 0, i32* %6
br label %14
14: ; preds = %56, %2
%15 = load i32, i32* %6
%16 = load i32, i32* %3
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %59
18: ; preds = %14
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = mul i64 8, %20
%22 = trunc i64 %21 to i32
%23 = call i64 @malloc(i32 %22)
%24 = inttoptr i64 %23 to double*
%25 = load double**, double*** %5
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double*, double** %25, i64 %27
store double* %24, double** %28
store i32 0, i32* %7
br label %29
29: ; preds = %52, %18
%30 = load i32, i32* %7
%31 = load i32, i32* %4
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %55
33: ; preds = %29
%34 = call i32 (...) @random()
%35 = load i32, i32* @RAND_MAX
%36 = sdiv i32 %35, 2
%37 = sub nsw i32 %34, %36
%38 = sitofp i32 %37 to double
%39 = fmul double %38, 1.000000e-02
%40 = load i32, i32* @RAND_MAX
%41 = mul nsw i32 6, %40
%42 = sitofp i32 %41 to double
%43 = fdiv double %39, %42
%44 = load double**, double*** %5
%45 = load i32, i32* %6
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds double*, double** %44, i64 %46
%48 = load double*, double** %47
%49 = load i32, i32* %7
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds double, double* %48, i64 %50
store double %43, double* %51
br label %52
52: ; preds = %33
%53 = load i32, i32* %7
%54 = add nsw i32 %53, 1
store i32 %54, i32* %7
br label %29
55: ; preds = %29
br label %56
56: ; preds = %55
%57 = load i32, i32* %6
%58 = add nsw i32 %57, 1
store i32 %58, i32* %6
br label %14
59: ; preds = %14
%60 = load double**, double*** %5
ret double** %60
}

LLVM IR (-O2):
@RAND_MAX = global i32 0
define double** @getMat(i32 %0, i32 %1) {
%3 = shl i32 %0, 3
%4 = tail call i64 @malloc(i32 %3)
%5 = inttoptr i64 %4 to double**
%6 = icmp sgt i32 %0, 0
br i1 %6, label %7, label %35
7: ; preds = %2
%8 = shl i32 %1, 3
%9 = icmp sgt i32 %1, 0
%10 = zext i32 %0 to i64
%11 = zext i32 %1 to i64
br label %12
12: ; preds = %7, %32
%13 = phi i64 [ 0, %7 ], [ %33, %32 ]
%14 = tail call i64 @malloc(i32 %8)
%15 = inttoptr i64 %14 to double*
%16 = getelementptr inbounds double*, double** %5, i64 %13
store double* %15, double** %16
br i1 %9, label %17, label %32
17: ; preds = %12, %17
%18 = phi i64 [ %30, %17 ], [ 0, %12 ]
%19 = tail call i32 (...) @random()
%20 = load i32, i32* @RAND_MAX
%21 = sdiv i32 %20, -2
%22 = add i32 %21, %19
%23 = sitofp i32 %22 to double
%24 = fmul double %23, 1.000000e-02
%25 = mul nsw i32 %20, 6
%26 = sitofp i32 %25 to double
%27 = fdiv double %24, %26
%28 = load double*, double** %16
%29 = getelementptr inbounds double, double* %28, i64 %18
store double %27, double* %29
%30 = add nuw nsw i64 %18, 1
%31 = icmp eq i64 %30, %11
br i1 %31, label %32, label %17
32: ; preds = %17, %12
%33 = add nuw nsw i64 %13, 1
%34 = icmp eq i64 %33, %10
br i1 %34, label %35, label %12
35: ; preds = %32, %2
ret double** %5
}