#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__ calloc(int, int);
scalar_t__ malloc(int);
void allocate_all(double **m_beta, double **inv_cov_beta, double **m_U,
                  double **inv_cov_U, double **m_V, double **inv_cov_V,
                  double **mean, double **mean_U, double **mean_V,
                  double **sum2, double **sum, double **bb, double **CCt, int N,
                  int M, int K, int D) {
  *m_beta = (double *)malloc(D * M * sizeof(double));
  *inv_cov_beta = (double *)malloc(D * D * sizeof(double));
  *m_U = (double *)malloc(K * N * sizeof(double));
  *inv_cov_U = (double *)malloc(K * K * sizeof(double));
  *m_V = (double *)malloc(K * M * sizeof(double));
  *inv_cov_V = (double *)malloc(K * K * sizeof(double));
  *mean = (double *)calloc(D * M, sizeof(double));
  *mean_U = (double *)calloc(K * N, sizeof(double));
  *mean_V = (double *)calloc(K * M, sizeof(double));
  *sum = (double *)calloc(D * M, sizeof(double));
  *sum2 = (double *)calloc(D * M, sizeof(double));
  *bb = (double *)calloc(D, sizeof(double));
  *CCt = (double *)calloc(D * D, sizeof(double));
}


x86 assembly (clang, -O0):
<allocate_all>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x60(%rbp),%eax
mov    0x58(%rbp),%eax
mov    0x50(%rbp),%eax
mov    0x48(%rbp),%eax
mov    0x40(%rbp),%rax
mov    0x38(%rbp),%rax
mov    0x30(%rbp),%rax
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    0x60(%rbp),%eax
imul   0x50(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    0x60(%rbp),%eax
imul   0x60(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    0x58(%rbp),%eax
imul   0x48(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    0x58(%rbp),%eax
imul   0x58(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    0x58(%rbp),%eax
imul   0x50(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    0x58(%rbp),%eax
imul   0x58(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
mov    0x60(%rbp),%edi
imul   0x50(%rbp),%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,%rcx
mov    0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    0x58(%rbp),%edi
imul   0x48(%rbp),%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,%rcx
mov    0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    0x58(%rbp),%edi
imul   0x50(%rbp),%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,%rcx
mov    0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    0x60(%rbp),%edi
imul   0x50(%rbp),%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,%rcx
mov    0x30(%rbp),%rax
mov    %rcx,(%rax)
mov    0x60(%rbp),%edi
imul   0x50(%rbp),%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,%rcx
mov    0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    0x60(%rbp),%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,%rcx
mov    0x38(%rbp),%rax
mov    %rcx,(%rax)
mov    0x60(%rbp),%edi
imul   0x60(%rbp),%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,%rcx
mov    0x40(%rbp),%rax
mov    %rcx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<allocate_all>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,0x10(%rsp)
mov    %r8,0x8(%rsp)
mov    %rcx,(%rsp)
mov    %rdx,%r13
mov    %rsi,%r15
mov    %rdi,%r12
mov    0xa0(%rsp),%eax
mov    %eax,%r14d
mov    %eax,%ebp
imul   0x90(%rsp),%r14d
mov    0x98(%rsp),%ebx
lea    0x0(,%r14,8),%edi
call   1040 <malloc@plt>
mov    %rax,(%r12)
mov    %ebp,%r12d
imul   %r12d,%r12d
lea    0x0(,%r12,8),%edi
call   1040 <malloc@plt>
mov    %rax,(%r15)
mov    0x88(%rsp),%r15d
imul   %ebx,%r15d
lea    0x0(,%r15,8),%edi
call   1040 <malloc@plt>
mov    %rax,0x0(%r13)
mov    %ebx,%ebp
imul   %ebx,%ebp
shl    $0x3,%ebp
mov    %ebp,%edi
call   1040 <malloc@plt>
mov    (%rsp),%rcx
mov    %rax,(%rcx)
imul   0x90(%rsp),%ebx
lea    0x0(,%rbx,8),%edi
call   1040 <malloc@plt>
mov    0x8(%rsp),%rcx
mov    %rax,(%rcx)
mov    %ebp,%edi
call   1040 <malloc@plt>
mov    0x10(%rsp),%rcx
mov    %rax,(%rcx)
mov    %r14d,%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    0x50(%rsp),%rcx
mov    %rax,(%rcx)
mov    %r15d,%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    0x58(%rsp),%rcx
mov    %rax,(%rcx)
mov    %ebx,%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    0x60(%rsp),%rcx
mov    %rax,(%rcx)
mov    %r14d,%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    0x70(%rsp),%rcx
mov    %rax,(%rcx)
mov    %r14d,%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    0x68(%rsp),%rcx
mov    %rax,(%rcx)
mov    0xa0(%rsp),%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    0x78(%rsp),%rcx
mov    %rax,(%rcx)
mov    %r12d,%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    0x80(%rsp),%rcx
mov    %rax,(%rcx)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @allocate_all(double** %0, double** %1, double** %2, double** %3, double** %4, double** %5, double** %6, double** %7, double** %8, double** %9, double** %10, double** %11, double** %12, i32 %13, i32 %14, i32 %15, i32 %16) {
%18 = alloca double**
%19 = alloca double**
%20 = alloca double**
%21 = alloca double**
%22 = alloca double**
%23 = alloca double**
%24 = alloca double**
%25 = alloca double**
%26 = alloca double**
%27 = alloca double**
%28 = alloca double**
%29 = alloca double**
%30 = alloca double**
%31 = alloca i32
%32 = alloca i32
%33 = alloca i32
%34 = alloca i32
store double** %0, double*** %18
store double** %1, double*** %19
store double** %2, double*** %20
store double** %3, double*** %21
store double** %4, double*** %22
store double** %5, double*** %23
store double** %6, double*** %24
store double** %7, double*** %25
store double** %8, double*** %26
store double** %9, double*** %27
store double** %10, double*** %28
store double** %11, double*** %29
store double** %12, double*** %30
store i32 %13, i32* %31
store i32 %14, i32* %32
store i32 %15, i32* %33
store i32 %16, i32* %34
%35 = load i32, i32* %34
%36 = load i32, i32* %32
%37 = mul nsw i32 %35, %36
%38 = sext i32 %37 to i64
%39 = mul i64 %38, 8
%40 = trunc i64 %39 to i32
%41 = call i64 @malloc(i32 %40)
%42 = inttoptr i64 %41 to double*
%43 = load double**, double*** %18
store double* %42, double** %43
%44 = load i32, i32* %34
%45 = load i32, i32* %34
%46 = mul nsw i32 %44, %45
%47 = sext i32 %46 to i64
%48 = mul i64 %47, 8
%49 = trunc i64 %48 to i32
%50 = call i64 @malloc(i32 %49)
%51 = inttoptr i64 %50 to double*
%52 = load double**, double*** %19
store double* %51, double** %52
%53 = load i32, i32* %33
%54 = load i32, i32* %31
%55 = mul nsw i32 %53, %54
%56 = sext i32 %55 to i64
%57 = mul i64 %56, 8
%58 = trunc i64 %57 to i32
%59 = call i64 @malloc(i32 %58)
%60 = inttoptr i64 %59 to double*
%61 = load double**, double*** %20
store double* %60, double** %61
%62 = load i32, i32* %33
%63 = load i32, i32* %33
%64 = mul nsw i32 %62, %63
%65 = sext i32 %64 to i64
%66 = mul i64 %65, 8
%67 = trunc i64 %66 to i32
%68 = call i64 @malloc(i32 %67)
%69 = inttoptr i64 %68 to double*
%70 = load double**, double*** %21
store double* %69, double** %70
%71 = load i32, i32* %33
%72 = load i32, i32* %32
%73 = mul nsw i32 %71, %72
%74 = sext i32 %73 to i64
%75 = mul i64 %74, 8
%76 = trunc i64 %75 to i32
%77 = call i64 @malloc(i32 %76)
%78 = inttoptr i64 %77 to double*
%79 = load double**, double*** %22
store double* %78, double** %79
%80 = load i32, i32* %33
%81 = load i32, i32* %33
%82 = mul nsw i32 %80, %81
%83 = sext i32 %82 to i64
%84 = mul i64 %83, 8
%85 = trunc i64 %84 to i32
%86 = call i64 @malloc(i32 %85)
%87 = inttoptr i64 %86 to double*
%88 = load double**, double*** %23
store double* %87, double** %88
%89 = load i32, i32* %34
%90 = load i32, i32* %32
%91 = mul nsw i32 %89, %90
%92 = call i64 @calloc(i32 %91, i32 8)
%93 = inttoptr i64 %92 to double*
%94 = load double**, double*** %24
store double* %93, double** %94
%95 = load i32, i32* %33
%96 = load i32, i32* %31
%97 = mul nsw i32 %95, %96
%98 = call i64 @calloc(i32 %97, i32 8)
%99 = inttoptr i64 %98 to double*
%100 = load double**, double*** %25
store double* %99, double** %100
%101 = load i32, i32* %33
%102 = load i32, i32* %32
%103 = mul nsw i32 %101, %102
%104 = call i64 @calloc(i32 %103, i32 8)
%105 = inttoptr i64 %104 to double*
%106 = load double**, double*** %26
store double* %105, double** %106
%107 = load i32, i32* %34
%108 = load i32, i32* %32
%109 = mul nsw i32 %107, %108
%110 = call i64 @calloc(i32 %109, i32 8)
%111 = inttoptr i64 %110 to double*
%112 = load double**, double*** %28
store double* %111, double** %112
%113 = load i32, i32* %34
%114 = load i32, i32* %32
%115 = mul nsw i32 %113, %114
%116 = call i64 @calloc(i32 %115, i32 8)
%117 = inttoptr i64 %116 to double*
%118 = load double**, double*** %27
store double* %117, double** %118
%119 = load i32, i32* %34
%120 = call i64 @calloc(i32 %119, i32 8)
%121 = inttoptr i64 %120 to double*
%122 = load double**, double*** %29
store double* %121, double** %122
%123 = load i32, i32* %34
%124 = load i32, i32* %34
%125 = mul nsw i32 %123, %124
%126 = call i64 @calloc(i32 %125, i32 8)
%127 = inttoptr i64 %126 to double*
%128 = load double**, double*** %30
store double* %127, double** %128
ret void
}

LLVM IR (-O2):
define void @allocate_all(double** nocapture writeonly %0, double** nocapture writeonly %1, double** nocapture writeonly %2, double** nocapture writeonly %3, double** nocapture writeonly %4, double** nocapture writeonly %5, double** nocapture writeonly %6, double** nocapture writeonly %7, double** nocapture writeonly %8, double** nocapture writeonly %9, double** nocapture writeonly %10, double** nocapture writeonly %11, double** nocapture writeonly %12, i32 %13, i32 %14, i32 %15, i32 %16) {
%18 = mul nsw i32 %16, %14
%19 = shl i32 %18, 3
%20 = tail call i64 @malloc(i32 %19)
%21 = inttoptr i64 %20 to double*
store double* %21, double** %0
%22 = mul nsw i32 %16, %16
%23 = shl i32 %22, 3
%24 = tail call i64 @malloc(i32 %23)
%25 = inttoptr i64 %24 to double*
store double* %25, double** %1
%26 = mul nsw i32 %15, %13
%27 = shl i32 %26, 3
%28 = tail call i64 @malloc(i32 %27)
%29 = inttoptr i64 %28 to double*
store double* %29, double** %2
%30 = shl i32 %15, 3
%31 = mul i32 %30, %15
%32 = tail call i64 @malloc(i32 %31)
%33 = inttoptr i64 %32 to double*
store double* %33, double** %3
%34 = mul nsw i32 %15, %14
%35 = shl i32 %34, 3
%36 = tail call i64 @malloc(i32 %35)
%37 = inttoptr i64 %36 to double*
store double* %37, double** %4
%38 = tail call i64 @malloc(i32 %31)
%39 = inttoptr i64 %38 to double*
store double* %39, double** %5
%40 = tail call i64 @calloc(i32 %18, i32 8)
%41 = inttoptr i64 %40 to double*
store double* %41, double** %6
%42 = tail call i64 @calloc(i32 %26, i32 8)
%43 = inttoptr i64 %42 to double*
store double* %43, double** %7
%44 = tail call i64 @calloc(i32 %34, i32 8)
%45 = inttoptr i64 %44 to double*
store double* %45, double** %8
%46 = tail call i64 @calloc(i32 %18, i32 8)
%47 = inttoptr i64 %46 to double*
store double* %47, double** %10
%48 = tail call i64 @calloc(i32 %18, i32 8)
%49 = inttoptr i64 %48 to double*
store double* %49, double** %9
%50 = tail call i64 @calloc(i32 %16, i32 8)
%51 = inttoptr i64 %50 to double*
store double* %51, double** %11
%52 = tail call i64 @calloc(i32 %22, i32 8)
%53 = inttoptr i64 %52 to double*
store double* %53, double** %12
ret void
}