void mvnapp(int *type, int *m0, double w0[], double x0[], double corr[],
            int *nsim, double *eps, double *pr, double *sd, int *ifail) {
  double r[20][20];
  double w[20], x[20];
  double p, perr;
  int i, m, j, k, ierr;
  void mvn1(int, double[], double[], double[][20], int, double, double *,
            double *, int *);
  void mvn2(int, double[], double[], double[][20], int, double, double *,
            double *, int *);
  m = *m0;
  for (i = 1; i <= m; i++) {
    w[i] = w0[i - 1];
    x[i] = x0[i - 1];
  }
  for (i = 1, k = 0; i <= m; i++) {
    for (j = 1; j <= m; j++) {
      r[i][j] = corr[k];
      k++;
    }
  }
  if (*type == 1)
    mvn1(m, w, x, r, *nsim, *eps, &p, &perr, &ierr);
  else
    mvn2(m, w, x, r, *nsim, *eps, &p, &perr, &ierr);
  *pr = p;
  *sd = perr;
  *ifail = ierr;
}


x86 assembly (clang, -O0):
<mvnapp>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe30,%rsp
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    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0xe08(%rbp)
movl   $0x1,-0xe04(%rbp)
mov    -0xe04(%rbp),%eax
cmp    -0xe08(%rbp),%eax
jg     11d9 <mvnapp+0xb9>
mov    -0x18(%rbp),%rax
mov    -0xe04(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0xe04(%rbp),%rax
movsd  %xmm0,-0xd50(%rbp,%rax,8)
ff ff
mov    -0x20(%rbp),%rax
mov    -0xe04(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0xe04(%rbp),%rax
movsd  %xmm0,-0xdf0(%rbp,%rax,8)
ff ff
mov    -0xe04(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe04(%rbp)
jmp    1169 <mvnapp+0x49>
movl   $0x1,-0xe04(%rbp)
movl   $0x0,-0xe10(%rbp)
mov    -0xe04(%rbp),%eax
cmp    -0xe08(%rbp),%eax
jg     128b <mvnapp+0x16b>
movl   $0x1,-0xe0c(%rbp)
mov    -0xe0c(%rbp),%eax
cmp    -0xe08(%rbp),%eax
jg     1272 <mvnapp+0x152>
mov    -0x28(%rbp),%rax
movslq -0xe10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0xe04(%rbp),%rcx
lea    -0xcb0(%rbp),%rax
imul   $0xa0,%rcx,%rcx
add    %rcx,%rax
movslq -0xe0c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0xe10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe10(%rbp)
mov    -0xe0c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe0c(%rbp)
jmp    1209 <mvnapp+0xe9>
jmp    1277 <mvnapp+0x157>
mov    -0xe04(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe04(%rbp)
jmp    11ed <mvnapp+0xcd>
mov    -0x8(%rbp),%rax
cmpl   $0x1,(%rax)
jne    12ea <mvnapp+0x1ca>
mov    -0xe08(%rbp),%edi
lea    -0xd50(%rbp),%rsi
lea    -0xdf0(%rbp),%rdx
lea    -0xcb0(%rbp),%rcx
mov    -0x30(%rbp),%rax
mov    (%rax),%r8d
mov    0x10(%rbp),%rax
movsd  (%rax),%xmm0
lea    -0xdf8(%rbp),%r9
lea    -0xe00(%rbp),%r10
lea    -0xe14(%rbp),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1030 <mvn1@plt>
jmp    1337 <mvnapp+0x217>
mov    -0xe08(%rbp),%edi
lea    -0xd50(%rbp),%rsi
lea    -0xdf0(%rbp),%rdx
lea    -0xcb0(%rbp),%rcx
mov    -0x30(%rbp),%rax
mov    (%rax),%r8d
mov    0x10(%rbp),%rax
movsd  (%rax),%xmm0
lea    -0xdf8(%rbp),%r9
lea    -0xe00(%rbp),%r10
lea    -0xe14(%rbp),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1040 <mvn2@plt>
movsd  -0xdf8(%rbp),%xmm0
ff
mov    0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0xe00(%rbp),%xmm0
ff
mov    0x20(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0xe14(%rbp),%ecx
mov    0x28(%rbp),%rax
mov    %ecx,(%rax)
add    $0xe30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mvnapp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe28,%rsp
mov    %r9,%r13
mov    %rcx,%r14
mov    0xe60(%rsp),%rcx
mov    (%rsi),%ebx
test   %ebx,%ebx
jle    129a <mvnapp+0x16a>
mov    %r8,%r15
mov    %rdi,0x10(%rsp)
lea    0x108(%rsp),%rdi
lea    0x0(,%rbx,8),%rbp
mov    %rdx,%rsi
mov    %rbp,%rdx
call   1040 <memcpy@plt>
lea    0x68(%rsp),%rdi
mov    %r14,%rsi
mov    %rbp,%rdx
call   1040 <memcpy@plt>
cmp    $0x1,%ebx
jne    119d <mvnapp+0x6d>
mov    $0x1,%edx
xor    %eax,%eax
jmp    125c <mvnapp+0x12c>
mov    %r13,0x38(%rsp)
mov    %rbp,0x20(%rsp)
mov    %r15,0x18(%rsp)
lea    -0x1(%rbx),%eax
add    $0x1,%rax
mov    %rax,0x50(%rsp)
lea    0x2e8(%rsp),%rbp
mov    %rbx,0x40(%rsp)
and    $0xfffffffe,%ebx
neg    %rbx
mov    %rbx,0x48(%rsp)
mov    $0x1,%edx
xor    %r13d,%r13d
mov    0x18(%rsp),%r15
mov    0x20(%rsp),%r12
mov    0x50(%rsp),%r14
nopw   0x0(%rax,%rax,1)
mov    %rdx,0x58(%rsp)
lea    -0xa0(%rbp),%rdi
movslq %r13d,%rbx
lea    (%r15,%rbx,8),%rsi
mov    %r12,%rdx
call   1040 <memcpy@plt>
add    %r14d,%ebx
movslq %ebx,%r13
lea    (%r15,%r13,8),%rsi
mov    %rbp,%rdi
mov    %r12,%rdx
call   1040 <memcpy@plt>
mov    0x58(%rsp),%rdx
add    %r14,%r13
add    $0x140,%rbp
mov    0x48(%rsp),%rax
add    %rdx,%rax
add    $0x2,%rax
add    $0x2,%rdx
cmp    $0x1,%rax
jne    11f0 <mvnapp+0xc0>
movslq %r13d,%rax
mov    0x40(%rsp),%rbx
mov    0x38(%rsp),%r13
mov    0x18(%rsp),%r15
mov    0x20(%rsp),%rbp
test   $0x1,%bl
mov    0xe60(%rsp),%rcx
mov    0x10(%rsp),%rdi
je     129a <mvnapp+0x16a>
lea    (%rdx,%rdx,4),%rcx
shl    $0x5,%rcx
lea    (%rsp,%rcx,1),%rdi
add    $0x1a8,%rdi
lea    (%r15,%rax,8),%rsi
mov    %rbp,%rdx
call   1040 <memcpy@plt>
mov    0x10(%rsp),%rdi
mov    0xe60(%rsp),%rcx
mov    0xe78(%rsp),%r14
mov    0xe70(%rsp),%r15
mov    0xe68(%rsp),%rbp
cmpl   $0x1,(%rdi)
mov    0x0(%r13),%r8d
movsd  (%rcx),%xmm0
lea    0xc(%rsp),%rax
lea    0x28(%rsp),%r10
lea    0x100(%rsp),%rsi
lea    0x60(%rsp),%rdx
lea    0x1a0(%rsp),%rcx
lea    0x30(%rsp),%r9
mov    %ebx,%edi
jne    12ef <mvnapp+0x1bf>
push   %rax
push   %r10
call   1030 <mvn1@plt>
jmp    12f7 <mvnapp+0x1c7>
push   %rax
push   %r10
call   1050 <mvn2@plt>
add    $0x10,%rsp
movsd  0x30(%rsp),%xmm0
movsd  %xmm0,0x0(%rbp)
movsd  0x28(%rsp),%xmm0
movsd  %xmm0,(%r15)
mov    0xc(%rsp),%eax
mov    %eax,(%r14)
add    $0xe28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @mvnapp(i32* nocapture %0, i32* nocapture %1, double* nocapture %2, double* nocapture %3, double* nocapture %4, i32* nocapture %5, double* nocapture %6, double* nocapture writeonly %7, double* nocapture writeonly %8, i32* nocapture writeonly %9) {
%11 = alloca [20 x [20 x double]]
%12 = alloca [20 x double]
%13 = alloca [20 x double]
%14 = alloca double
%15 = alloca double
%16 = alloca i32
%17 = bitcast [20 x [20 x double]]* %11 to i8*
%18 = bitcast [20 x double]* %12 to i8*
%19 = bitcast [20 x double]* %13 to i8*
%20 = bitcast double* %14 to i8*
%21 = bitcast double* %15 to i8*
%22 = bitcast i32* %16 to i8*
%23 = load i32, i32* %1
%24 = icmp slt i32 %23, 1
br i1 %24, label %78, label %25
25: ; preds = %10
%26 = bitcast double* %3 to i8*
%27 = bitcast double* %2 to i8*
%28 = getelementptr inbounds [20 x double], [20 x double]* %12, i64 0, i64 1
%29 = bitcast double* %28 to i8*
%30 = zext i32 %23 to i64
%31 = shl nuw nsw i64 %30, 3
%32 = getelementptr inbounds [20 x double], [20 x double]* %13, i64 0, i64 1
%33 = bitcast double* %32 to i8*
%34 = zext i32 %23 to i64
%35 = shl nuw nsw i64 %34, 3
%36 = add nsw i32 %23, -1
%37 = zext i32 %36 to i64
%38 = add nuw nsw i64 %37, 1
%39 = and i64 %34, 1
%40 = icmp eq i32 %23, 1
br i1 %40, label %69, label %41
41: ; preds = %25
%42 = and i64 %34, 4294967294
br label %43
43: ; preds = %43, %41
%44 = phi i64 [ 0, %41 ], [ %55, %43 ]
%45 = phi i64 [ 0, %41 ], [ %62, %43 ]
%46 = phi i64 [ 0, %41 ], [ %63, %43 ]
%47 = or i64 %44, 1
%48 = getelementptr [20 x [20 x double]], [20 x [20 x double]]* %11, i64 0, i64 %47, i64 1
%49 = bitcast double* %48 to i8*
%50 = shl i64 %45, 32
%51 = ashr exact i64 %50, 32
%52 = getelementptr double, double* %4, i64 %51
%53 = bitcast double* %52 to i8*
%54 = add nsw i64 %38, %45
%55 = add nuw nsw i64 %44, 2
%56 = getelementptr [20 x [20 x double]], [20 x [20 x double]]* %11, i64 0, i64 %55, i64 1
%57 = bitcast double* %56 to i8*
%58 = shl i64 %54, 32
%59 = ashr exact i64 %58, 32
%60 = getelementptr double, double* %4, i64 %59
%61 = bitcast double* %60 to i8*
%62 = add nsw i64 %38, %59
%63 = add i64 %46, 2
%64 = icmp eq i64 %63, %42
br i1 %64, label %65, label %43
65: ; preds = %43
%66 = add nuw i64 %44, 3
%67 = shl i64 %62, 32
%68 = ashr exact i64 %67, 32
br label %69
69: ; preds = %65, %25
%70 = phi i64 [ 1, %25 ], [ %66, %65 ]
%71 = phi i64 [ 0, %25 ], [ %68, %65 ]
%72 = icmp eq i64 %39, 0
br i1 %72, label %78, label %73
73: ; preds = %69
%74 = getelementptr [20 x [20 x double]], [20 x [20 x double]]* %11, i64 0, i64 %70, i64 1
%75 = bitcast double* %74 to i8*
%76 = getelementptr double, double* %4, i64 %71
%77 = bitcast double* %76 to i8*
br label %78
78: ; preds = %73, %69, %10
%79 = load i32, i32* %0
%80 = icmp eq i32 %79, 1
%81 = getelementptr inbounds [20 x double], [20 x double]* %12, i64 0, i64 0
%82 = getelementptr inbounds [20 x double], [20 x double]* %13, i64 0, i64 0
%83 = getelementptr inbounds [20 x [20 x double]], [20 x [20 x double]]* %11, i64 0, i64 0
%84 = load i32, i32* %5
%85 = load double, double* %6
br i1 %80, label %86, label %87
86: ; preds = %78
br label %88
87: ; preds = %78
br label %88
88: ; preds = %87, %86
%89 = load double, double* %14
store double %89, double* %7
%90 = load double, double* %15
store double %90, double* %8
%91 = load i32, i32* %16
store i32 %91, i32* %9
ret void
}