#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 /*<<< orphan*/ add(double *, double *, double *, int);
int /*<<< orphan*/ memcpy(double *, double *, int);
int /*<<< orphan*/ mult(double *, double *, double, int);
double normrand(int /*<<< orphan*/, double);
void mvnrand_pcs(double *x, double *mu, double *z, double **V, int d) {
  int i;
  double s, v[d];
  memcpy(x, mu, d * sizeof(double));
  for (i = 0; i < d; i++) {
    s = normrand(0, z[i]);
    mult(v, V[i], s, d);
    add(x, x, v, d);
  }
}


x86 assembly (clang, -O0):
<mvnrand_pcs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x38(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
call   1040 <memcpy@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1205 <mvnrand_pcs+0xc5>
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xor    %edi,%edi
call   1050 <normrand@plt>
mov    -0x48(%rbp),%rdi
movsd  %xmm0,-0x30(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
movsd  -0x30(%rbp),%xmm0
mov    -0x24(%rbp),%edx
call   1060 <mult@plt>
mov    -0x48(%rbp),%rdx
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x24(%rbp),%ecx
call   1030 <add@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11a1 <mvnrand_pcs+0x61>
mov    -0x38(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mvnrand_pcs>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8d,%r12d
mov    %rcx,-0x38(%rbp)
mov    %rdx,-0x30(%rbp)
mov    %rdi,%r13
mov    %r8d,%r14d
mov    %rsp,%rbx
lea    0xf(,%r14,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0x0(,%r12,8),%edx
call   1040 <memcpy@plt>
test   %r12d,%r12d
jle    11ce <mvnrand_pcs+0x8e>
xor    %r15d,%r15d
nopl   0x0(%rax)
mov    -0x30(%rbp),%rax
movsd  (%rax,%r15,8),%xmm0
xor    %edi,%edi
call   1050 <normrand@plt>
mov    -0x38(%rbp),%rax
mov    (%rax,%r15,8),%rsi
mov    %rbx,%rdi
mov    %r12d,%edx
call   1060 <mult@plt>
mov    %r13,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
mov    %r12d,%ecx
call   1030 <add@plt>
add    $0x1,%r15
cmp    %r15,%r14
jne    1190 <mvnrand_pcs+0x50>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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