#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__ RAND_MAX;
scalar_t__ malloc(int);
scalar_t__ rand();
double **getMatSpace(int inputLayerSize, int outputLayerSize) {
  int epsilon = 0.0012;
  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] =
          0.001 * (double)rand() / (double)RAND_MAX - epsilon;
    }
  }
  return mat;
}


x86 assembly (clang, -O0):
<getMatSpace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11f3 <getMatSpace+0xd3>
movslq -0x8(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11e0 <getMatSpace+0xc0>
mov    $0x0,%al
call   1040 <rand@plt>
cvtsi2sd %rax,%xmm1
movsd  0xe60(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    0x2e3d(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
subsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1180 <getMatSpace+0x60>
jmp    11e5 <getMatSpace+0xc5>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114f <getMatSpace+0x2f>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getMatSpace>:
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   1030 <malloc@plt>
mov    %rax,%rbx
test   %r15d,%r15d
jle    11cd <getMatSpace+0xad>
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 <getMatSpace+0x59>
add    $0x1,%r14
cmp    %r15,%r14
je     11cd <getMatSpace+0xad>
mov    0xc(%rsp),%edi
call   1030 <malloc@plt>
mov    %rax,(%rbx,%r14,8)
cmpl   $0x0,0x10(%rsp)
jle    1170 <getMatSpace+0x50>
xor    %r12d,%r12d
xor    %eax,%eax
call   1040 <rand@plt>
movsd  0xe61(%rip),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mulsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdq 0x0(%r13),%xmm1
divsd  %xmm1,%xmm0
mov    (%rbx,%r14,8),%rax
movsd  %xmm0,(%rax,%r12,8)
add    $0x1,%r12
cmp    %r12,%rbp
jne    1190 <getMatSpace+0x70>
jmp    1170 <getMatSpace+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 i64 0
define double** @getMatSpace(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca double**
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %5
%9 = load i32, i32* %3
%10 = sext i32 %9 to i64
%11 = mul i64 8, %10
%12 = trunc i64 %11 to i32
%13 = call i64 @malloc(i32 %12)
%14 = inttoptr i64 %13 to double**
store double** %14, double*** %6
store i32 0, i32* %7
br label %15
15: ; preds = %56, %2
%16 = load i32, i32* %7
%17 = load i32, i32* %3
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %59
19: ; preds = %15
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = mul i64 8, %21
%23 = trunc i64 %22 to i32
%24 = call i64 @malloc(i32 %23)
%25 = inttoptr i64 %24 to double*
%26 = load double**, double*** %6
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds double*, double** %26, i64 %28
store double* %25, double** %29
store i32 0, i32* %8
br label %30
30: ; preds = %52, %19
%31 = load i32, i32* %8
%32 = load i32, i32* %4
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %55
34: ; preds = %30
%35 = call i64 (...) @rand()
%36 = sitofp i64 %35 to double
%37 = fmul double 1.000000e-03, %36
%38 = load i64, i64* @RAND_MAX
%39 = sitofp i64 %38 to double
%40 = fdiv double %37, %39
%41 = load i32, i32* %5
%42 = sitofp i32 %41 to double
%43 = fsub double %40, %42
%44 = load double**, double*** %6
%45 = load i32, i32* %7
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds double*, double** %44, i64 %46
%48 = load double*, double** %47
%49 = load i32, i32* %8
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds double, double* %48, i64 %50
store double %43, double* %51
br label %52
52: ; preds = %34
%53 = load i32, i32* %8
%54 = add nsw i32 %53, 1
store i32 %54, i32* %8
br label %30
55: ; preds = %30
br label %56
56: ; preds = %55
%57 = load i32, i32* %7
%58 = add nsw i32 %57, 1
store i32 %58, i32* %7
br label %15
59: ; preds = %15
%60 = load double**, double*** %6
ret double** %60
}

LLVM IR (-O2):
@RAND_MAX = global i64 0
define double** @getMatSpace(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 %32
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, %29
%13 = phi i64 [ 0, %7 ], [ %30, %29 ]
%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 %29
17: ; preds = %12, %17
%18 = phi i64 [ %27, %17 ], [ 0, %12 ]
%19 = tail call i64 (...) @rand()
%20 = sitofp i64 %19 to double
%21 = fmul double %20, 1.000000e-03
%22 = load i64, i64* @RAND_MAX
%23 = sitofp i64 %22 to double
%24 = fdiv double %21, %23
%25 = load double*, double** %16
%26 = getelementptr inbounds double, double* %25, i64 %18
store double %24, double* %26
%27 = add nuw nsw i64 %18, 1
%28 = icmp eq i64 %27, %11
br i1 %28, label %29, label %17
29: ; preds = %17, %12
%30 = add nuw nsw i64 %13, 1
%31 = icmp eq i64 %30, %10
br i1 %31, label %32, label %12
32: ; preds = %29, %2
ret double** %5
}