#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*/ HDsi(double *, double *, double *, double *, int, int *,
                        int);
int /*<<< orphan*/ cov_mat(double *, double *, int, int);
int /*<<< orphan*/ denormH(double *, double *, double *);
int /*<<< orphan*/ lap_eig(double *, double *, int);
int /*<<< orphan*/ lin_hgN(double *, double *, int *, int, double *, double *);
int /*<<< orphan*/ memcpy(double *, double *, int);
int /*<<< orphan*/ normu(double *, int *, int, double *, double *);
int /*<<< orphan*/ scalmul(double *, int, int, int);
void hMCEs(double *Z, double *u, double *d, int *samidx, int len, double *errs,
           double thr) {
  int i, j;
  double C[9 * 9], V[9 * 9], *Cc = V;
  double A1[3], A2[3];
  double A[10 * 9];
  double h[3 * 3], e[4];
  normu(u, samidx, 4, A1, A2);
  lin_hgN(u, A, samidx, 4, A1, A2);
  for (i = 0; i < len; ++i) {
    if (errs[i] <= thr) {
      d[i] = errs[i];
      continue;
    }
    lin_hgN(u, A + 8 * 9, &i, 1, A1, A2);
    scalmul(A + 8 * 9, 100, 2 * 9, 1);
    cov_mat(C, A, 10, 9);
    lap_eig(C, Cc, 9);
    memcpy(h, C, 3 * 3 * sizeof(double));
    denormH(h, A1, A2);
    HDsi(Z, u, h, e, len, samidx, 4);
    d[i] = 0;
    for (j = 0; j < 4; ++j) {
      d[i] += e[j];
    }
    d[i] /= 4;
  }
}


x86 assembly (clang, -O0):
<hMCEs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x8f0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9,-0x30(%rbp)
movsd  %xmm0,-0x38(%rbp)
lea    -0x560(%rbp),%rax
mov    %rax,-0x568(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    -0x580(%rbp),%rcx
lea    -0x5a0(%rbp),%r8
mov    $0x4,%edx
call   1090 <normu@plt>
mov    -0x10(%rbp),%rdi
lea    -0x870(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    -0x580(%rbp),%r8
lea    -0x5a0(%rbp),%r9
mov    $0x4,%ecx
call   1050 <lin_hgN@plt>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    13a6 <hMCEs+0x226>
mov    -0x30(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x38(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     124b <hMCEs+0xcb>
mov    -0x30(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    1398 <hMCEs+0x218>
mov    -0x10(%rbp),%rdi
lea    -0x870(%rbp),%rsi
add    $0x240,%rsi
lea    -0x580(%rbp),%r8
lea    -0x5a0(%rbp),%r9
lea    -0x3c(%rbp),%rdx
mov    $0x1,%ecx
call   1050 <lin_hgN@plt>
lea    -0x870(%rbp),%rdi
add    $0x240,%rdi
mov    $0x64,%esi
mov    $0x12,%edx
mov    $0x1,%ecx
call   1080 <scalmul@plt>
lea    -0x2d0(%rbp),%rdi
lea    -0x870(%rbp),%rsi
mov    $0xa,%edx
mov    $0x9,%ecx
call   10a0 <cov_mat@plt>
lea    -0x2d0(%rbp),%rdi
mov    -0x568(%rbp),%rsi
mov    $0x9,%edx
call   1060 <lap_eig@plt>
lea    -0x8c0(%rbp),%rdi
lea    -0x2d0(%rbp),%rsi
mov    $0x48,%edx
call   1070 <memcpy@plt>
lea    -0x8c0(%rbp),%rdi
lea    -0x580(%rbp),%rsi
lea    -0x5a0(%rbp),%rdx
call   1040 <denormH@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x8c0(%rbp),%rdx
lea    -0x8e0(%rbp),%rcx
mov    -0x24(%rbp),%r8d
mov    -0x20(%rbp),%r9
movl   $0x4,(%rsp)
call   1030 <HDsi@plt>
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x0,-0x40(%rbp)
cmpl   $0x4,-0x40(%rbp)
jge    137a <hMCEs+0x1fa>
movslq -0x40(%rbp),%rax
movsd  -0x8e0(%rbp,%rax,8),%xmm0
ff ff
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1343 <hMCEs+0x1c3>
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  0xc71(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1204 <hMCEs+0x84>
add    $0x8f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hMCEs>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x8d8,%rsp
movsd  %xmm0,0x38(%rsp)
mov    %r9,0x30(%rsp)
mov    %r8d,%r12d
mov    %rcx,%r15
mov    %rdx,%rbp
mov    %rsi,%r14
mov    %rdi,0x20(%rsp)
lea    0x60(%rsp),%rbx
lea    0x80(%rsp),%r13
mov    %rsi,%rdi
mov    %rcx,%rsi
mov    $0x4,%edx
mov    %rbx,%rcx
mov    %r13,%r8
call   1090 <normu@plt>
lea    0xf0(%rsp),%rsi
mov    %r14,0x18(%rsp)
mov    %r14,%rdi
mov    %r15,0x28(%rsp)
mov    %r15,%rdx
mov    $0x4,%ecx
mov    %rbx,%r8
mov    %r13,%r9
call   1050 <lin_hgN@plt>
movl   $0x0,0x14(%rsp)
test   %r12d,%r12d
jle    1351 <hMCEs+0x1d1>
xor    %eax,%eax
mov    0x18(%rsp),%r14
jmp    132c <hMCEs+0x1ac>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
lea    0x330(%rsp),%r13
mov    %r13,%rsi
lea    0x14(%rsp),%rdx
mov    $0x1,%ecx
lea    0x60(%rsp),%r8
mov    %r12d,%ebx
lea    0x80(%rsp),%r12
mov    %r12,%r9
call   1050 <lin_hgN@plt>
mov    %r13,%rdi
mov    $0x64,%esi
mov    $0x12,%edx
mov    $0x1,%ecx
call   1080 <scalmul@plt>
lea    0x650(%rsp),%r13
mov    %r13,%rdi
lea    0xf0(%rsp),%rsi
mov    $0xa,%edx
mov    $0x9,%ecx
call   10a0 <cov_mat@plt>
mov    %r13,%rdi
lea    0x3c0(%rsp),%rsi
mov    $0x9,%edx
call   1060 <lap_eig@plt>
lea    0xa0(%rsp),%r15
mov    %r15,%rdi
mov    %r13,%rsi
mov    $0x48,%edx
call   1070 <memcpy@plt>
mov    %r15,%rdi
lea    0x60(%rsp),%rsi
mov    %r12,%rdx
mov    %ebx,%r12d
call   1040 <denormH@plt>
movl   $0x4,(%rsp)
mov    0x20(%rsp),%rdi
mov    %r14,%rsi
mov    %r15,%rdx
lea    0x40(%rsp),%rcx
mov    %ebx,%r8d
mov    0x28(%rsp),%r9
call   1030 <HDsi@plt>
movslq 0x14(%rsp),%rax
movsd  0x40(%rsp),%xmm0
addsd  0xd08(%rip),%xmm0
addsd  0x48(%rsp),%xmm0
addsd  0x50(%rsp),%xmm0
addsd  0x58(%rsp),%xmm0
mulsd  0xce6(%rip),%xmm0
movsd  %xmm0,0x0(%rbp,%rax,8)
add    $0x1,%eax
mov    %eax,0x14(%rsp)
cmp    %r12d,%eax
jge    1351 <hMCEs+0x1d1>
movslq %eax,%rcx
mov    0x30(%rsp),%rdx
movsd  (%rdx,%rcx,8),%xmm0
movsd  0x38(%rsp),%xmm1
ucomisd %xmm0,%xmm1
jb     1220 <hMCEs+0xa0>
movsd  %xmm0,0x0(%rbp,%rcx,8)
jmp    1320 <hMCEs+0x1a0>
add    $0x8d8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @hMCEs(double* %0, double* %1, double* nocapture %2, i32* %3, i32 %4, double* nocapture %5, double %6) {
%8 = alloca i32
%9 = alloca [81 x double]
%10 = alloca [81 x double]
%11 = alloca [3 x double]
%12 = alloca [3 x double]
%13 = alloca [90 x double]
%14 = alloca [9 x double]
%15 = alloca [4 x double]
%16 = bitcast i32* %8 to i8*
%17 = bitcast [81 x double]* %9 to i8*
%18 = bitcast [81 x double]* %10 to i8*
%19 = getelementptr inbounds [81 x double], [81 x double]* %10, i64 0, i64 0
%20 = bitcast [3 x double]* %11 to i8*
%21 = bitcast [3 x double]* %12 to i8*
%22 = bitcast [90 x double]* %13 to i8*
%23 = bitcast [9 x double]* %14 to i8*
%24 = bitcast [4 x double]* %15 to i8*
%25 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%26 = getelementptr inbounds [3 x double], [3 x double]* %12, i64 0, i64 0
%27 = call i32 @normu(double* %1, i32* %3, i32 4, double* %25, double* %26)
%28 = getelementptr inbounds [90 x double], [90 x double]* %13, i64 0, i64 0
%29 = call i32 @lin_hgN(double* %1, double* %28, i32* %3, i32 4, double* %25, double* %26)
store i32 0, i32* %8
%30 = icmp sgt i32 %4, 0
br i1 %30, label %31, label %71
31: ; preds = %7
%32 = getelementptr inbounds [90 x double], [90 x double]* %13, i64 0, i64 72
%33 = getelementptr inbounds [81 x double], [81 x double]* %9, i64 0, i64 0
%34 = getelementptr inbounds [9 x double], [9 x double]* %14, i64 0, i64 0
%35 = getelementptr inbounds [4 x double], [4 x double]* %15, i64 0, i64 0
%36 = getelementptr inbounds [4 x double], [4 x double]* %15, i64 0, i64 1
%37 = getelementptr inbounds [4 x double], [4 x double]* %15, i64 0, i64 2
%38 = getelementptr inbounds [4 x double], [4 x double]* %15, i64 0, i64 3
br label %39
39: ; preds = %31, %67
%40 = phi i32 [ 0, %31 ], [ %69, %67 ]
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds double, double* %5, i64 %41
%43 = load double, double* %42
%44 = fcmp ugt double %43, %6
br i1 %44, label %47, label %45
45: ; preds = %39
%46 = getelementptr inbounds double, double* %2, i64 %41
store double %43, double* %46
br label %67
47: ; preds = %39
%48 = call i32 @lin_hgN(double* %1, double* %32, i32* %8, i32 1, double* %25, double* %26)
%49 = call i32 @scalmul(double* %32, i32 100, i32 18, i32 1)
%50 = call i32 @cov_mat(double* %33, double* %28, i32 10, i32 9)
%51 = call i32 @lap_eig(double* %33, double* %19, i32 9)
%52 = call i32 @memcpy(double* %34, double* %33, i32 72)
%53 = call i32 @denormH(double* %34, double* %25, double* %26)
%54 = call i32 @HDsi(double* %0, double* %1, double* %34, double* %35, i32 %4, i32* %3, i32 4)
%55 = load i32, i32* %8
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds double, double* %2, i64 %56
%58 = load double, double* %35
%59 = fadd double %58, 0.000000e+00
%60 = load double, double* %36
%61 = fadd double %60, %59
%62 = load double, double* %37
%63 = fadd double %62, %61
%64 = load double, double* %38
%65 = fadd double %64, %63
%66 = fmul double %65, 2.500000e-01
store double %66, double* %57
br label %67
67: ; preds = %47, %45
%68 = phi i32 [ %55, %47 ], [ %40, %45 ]
%69 = add nsw i32 %68, 1
store i32 %69, i32* %8
%70 = icmp slt i32 %69, %4
br i1 %70, label %39, label %71
71: ; preds = %67, %7
ret void
}