#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 */
double exp(double);
double ndtr(double);
double min_prob(int k, int n, double mu[], double sigma[]) {
  const double gauss_hermite[10][2] = {
      {-3.4361591188, 1.0254516913}, {-2.5327316742, 0.8206661264},
      {-1.7566836492, 0.7414419319}, {-1.0366108297, 0.7032963231},
      {-0.3429013272, 0.6870818539}, {0.3429013272, 0.6870818539},
      {1.0366108297, 0.7032963231},  {1.7566836492, 0.7414419319},
      {2.5327316742, 0.8206661264},  {3.4361591188, 1.0254516913},
  };
  double x, p, srt, f, g;
  int i, j;
  srt = sigma[k] * 1.41421356237309504880;
  p = 0.0;
  for (i = 0; i < 10; i++) {
    x = gauss_hermite[i][0];
    f = exp(-x * x);
    g = f;
    for (j = 0; (j < n) && (g > 0.01); j++) {
      if (j == k)
        continue;
      g *= (1.0 - ndtr(((mu[k] + x * srt) - mu[j]) / sigma[j]));
    }
    p += gauss_hermite[i][1] * g;
  }
  return p * 1.12837916709551257390 / 2.0;
}


x86 assembly (clang, -O0):
<min_prob>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
lea    -0xc0(%rbp),%rdi
lea    0xed9(%rip),%rsi
mov    $0xa0,%edx
call   1030 <memcpy@plt>
mov    -0x18(%rbp),%rax
movslq -0x4(%rbp),%rcx
movsd  0xe8f(%rip),%xmm0
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0xd8(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
movl   $0x0,-0xec(%rbp)
cmpl   $0xa,-0xec(%rbp)
jge    1335 <min_prob+0x205>
movslq -0xec(%rbp),%rcx
lea    -0xc0(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
movsd  -0xc8(%rbp),%xmm0
ff
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0xc8(%rbp),%xmm0
ff
call   1040 <exp@plt>
movsd  %xmm0,-0xe0(%rbp)
ff
movsd  -0xe0(%rbp),%xmm0
ff
movsd  %xmm0,-0xe8(%rbp)
ff
movl   $0x0,-0xf0(%rbp)
mov    -0xf0(%rbp),%ecx
xor    %eax,%eax
cmp    -0x8(%rbp),%ecx
mov    %al,-0xf1(%rbp)
jge    1243 <min_prob+0x113>
movsd  -0xe8(%rbp),%xmm0
ff
movsd  0xde2(%rip),%xmm1
ucomisd %xmm1,%xmm0
seta   %al
mov    %al,-0xf1(%rbp)
mov    -0xf1(%rbp),%al
test   $0x1,%al
jne    1256 <min_prob+0x126>
jmp    12e7 <min_prob+0x1b7>
mov    -0xf0(%rbp),%eax
cmp    -0x4(%rbp),%eax
jne    126a <min_prob+0x13a>
jmp    12d3 <min_prob+0x1a3>
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0xc8(%rbp),%xmm0
ff
movsd  -0xd8(%rbp),%xmm2
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0xf0(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0xf0(%rbp),%rcx
divsd  (%rax,%rcx,8),%xmm0
call   1050 <ndtr@plt>
movaps %xmm0,%xmm1
movsd  0xd61(%rip),%xmm0
subsd  %xmm1,%xmm0
mulsd  -0xe8(%rbp),%xmm0
ff
movsd  %xmm0,-0xe8(%rbp)
ff
mov    -0xf0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf0(%rbp)
jmp    120f <min_prob+0xdf>
movslq -0xec(%rbp),%rcx
lea    -0xc0(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
movsd  0x8(%rax),%xmm0
movsd  -0xe8(%rbp),%xmm2
ff
movsd  -0xd0(%rbp),%xmm1
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
mov    -0xec(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xec(%rbp)
jmp    1193 <min_prob+0x63>
movsd  0xcd3(%rip),%xmm0
mulsd  -0xd0(%rbp),%xmm0
ff
movsd  0xcbb(%rip),%xmm1
divsd  %xmm1,%xmm0
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<min_prob>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rdx,%r13
movslq %edi,%rax
mov    %rcx,0x28(%rsp)
movsd  (%rcx,%rax,8),%xmm0
mulsd  0xeba(%rip),%xmm0
movsd  %xmm0,0x20(%rsp)
mov    %rax,%r12
mov    %eax,%ebp
mov    %esi,0x14(%rsp)
movslq %esi,%rbx
neg    %rbp
xorpd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
xor    %r15d,%r15d
lea    0xed2(%rip),%rax
jmp    119e <min_prob+0x7e>
lea    0xec9(%rip),%rax
mov    0x18(%rsp),%rcx
mulsd  0x8(%rcx,%rax,1),%xmm1
movsd  (%rsp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
add    $0x1,%r15
cmp    $0xa,%r15
je     1269 <min_prob+0x149>
mov    %r15,%r14
shl    $0x4,%r14
movsd  (%r14,%rax,1),%xmm1
movapd %xmm1,%xmm0
xorpd  0xe79(%rip),%xmm0
movapd %xmm1,0x30(%rsp)
mulsd  %xmm1,%xmm0
call   1030 <exp@plt>
movapd %xmm0,%xmm1
cmpl   $0x0,0x14(%rsp)
mov    %r14,0x18(%rsp)
jle    1170 <min_prob+0x50>
ucomisd 0xe2a(%rip),%xmm1
jbe    1170 <min_prob+0x50>
mov    $0x1,%r14d
cs nopw 0x0(%rax,%rax,1)
lea    (%r14,%rbp,1),%rax
cmp    $0x1,%rax
je     124d <min_prob+0x12d>
movapd 0x30(%rsp),%xmm0
mulsd  0x20(%rsp),%xmm0
addsd  0x0(%r13,%r12,8),%xmm0
subsd  -0x8(%r13,%r14,8),%xmm0
mov    0x28(%rsp),%rax
divsd  -0x8(%rax,%r14,8),%xmm0
movsd  %xmm1,0x8(%rsp)
call   1040 <ndtr@plt>
movsd  0xddd(%rip),%xmm1
subsd  %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rsp),%xmm1
cmp    %rbx,%r14
jge    1170 <min_prob+0x50>
add    $0x1,%r14
ucomisd 0xda6(%rip),%xmm1
ja     11f0 <min_prob+0xd0>
jmp    1170 <min_prob+0x50>
movsd  (%rsp),%xmm0
mulsd  0xda2(%rip),%xmm0
mulsd  0xda2(%rip),%xmm0
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.min_prob.gauss_hermite = [10 x [2 x double]] [[2 x double] [double 0xC00B7D40FDF8C912, double 0x3FF06840085C2EA5], [2 x double] [double 0xC0044308D2F1DBCE, double 0x3FEA42E59BBA5609], [2 x double] [double 0xBFFC1B60506BB603, double 0x3FE7B9E46E2C9809], [2 x double] [double 0xBFF095F53CC3DAD5, double 0x3FE681674A6391D0], [2 x double] [double 0xBFD5F21868850E42, double 0x3FE5FC9315859E1B], [2 x double] [double 0x3FD5F21868850E42, double 0x3FE5FC9315859E1B], [2 x double] [double 0x3FF095F53CC3DAD5, double 0x3FE681674A6391D0], [2 x double] [double 0x3FFC1B60506BB603, double 0x3FE7B9E46E2C9809], [2 x double] [double 0x40044308D2F1DBCE, double 0x3FEA42E59BBA5609], [2 x double] [double 0x400B7D40FDF8C912, double 0x3FF06840085C2EA5]]
define double @min_prob(i32 %0, i32 %1, double* %2, double* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca double*
%8 = alloca double*
%9 = alloca [10 x [2 x double]]
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca i32
%16 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store double* %2, double** %7
store double* %3, double** %8
%17 = bitcast [10 x [2 x double]]* %9 to i8*
%18 = load double*, double** %8
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds double, double* %18, i64 %20
%22 = load double, double* %21
%23 = fmul double %22, 0x3FF6A09E667F3BCD
store double %23, double* %12
store double 0.000000e+00, double* %11
store i32 0, i32* %15
br label %24
24: ; preds = %90, %4
%25 = load i32, i32* %15
%26 = icmp slt i32 %25, 10
br i1 %26, label %27, label %93
27: ; preds = %24
%28 = load i32, i32* %15
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [10 x [2 x double]], [10 x [2 x double]]* %9, i64 0, i64 %29
%31 = getelementptr inbounds [2 x double], [2 x double]* %30, i64 0, i64 0
%32 = load double, double* %31
store double %32, double* %10
%33 = load double, double* %10
%34 = fneg double %33
%35 = load double, double* %10
%36 = fmul double %34, %35
%37 = call double @exp(double %36)
store double %37, double* %13
%38 = load double, double* %13
store double %38, double* %14
store i32 0, i32* %16
br label %39
39: ; preds = %78, %27
%40 = load i32, i32* %16
%41 = load i32, i32* %6
%42 = icmp slt i32 %40, %41
br i1 %42, label %43, label %46
43: ; preds = %39
%44 = load double, double* %14
%45 = fcmp ogt double %44, 1.000000e-02
br label %46
46: ; preds = %43, %39
%47 = phi i1 [ false, %39 ], [ %45, %43 ]
br i1 %47, label %48, label %81
48: ; preds = %46
%49 = load i32, i32* %16
%50 = load i32, i32* %5
%51 = icmp eq i32 %49, %50
br i1 %51, label %52, label %53
52: ; preds = %48
br label %78
53: ; preds = %48
%54 = load double*, double** %7
%55 = load i32, i32* %5
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds double, double* %54, i64 %56
%58 = load double, double* %57
%59 = load double, double* %10
%60 = load double, double* %12
%61 = call double @llvm.fmuladd.f64(double %59, double %60, double %58)
%62 = load double*, double** %7
%63 = load i32, i32* %16
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds double, double* %62, i64 %64
%66 = load double, double* %65
%67 = fsub double %61, %66
%68 = load double*, double** %8
%69 = load i32, i32* %16
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds double, double* %68, i64 %70
%72 = load double, double* %71
%73 = fdiv double %67, %72
%74 = call double @ndtr(double %73)
%75 = fsub double 1.000000e+00, %74
%76 = load double, double* %14
%77 = fmul double %76, %75
store double %77, double* %14
br label %78
78: ; preds = %53, %52
%79 = load i32, i32* %16
%80 = add nsw i32 %79, 1
store i32 %80, i32* %16
br label %39
81: ; preds = %46
%82 = load i32, i32* %15
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds [10 x [2 x double]], [10 x [2 x double]]* %9, i64 0, i64 %83
%85 = getelementptr inbounds [2 x double], [2 x double]* %84, i64 0, i64 1
%86 = load double, double* %85
%87 = load double, double* %14
%88 = load double, double* %11
%89 = call double @llvm.fmuladd.f64(double %86, double %87, double %88)
store double %89, double* %11
br label %90
90: ; preds = %81
%91 = load i32, i32* %15
%92 = add nsw i32 %91, 1
store i32 %92, i32* %15
br label %24
93: ; preds = %24
%94 = load double, double* %11
%95 = fmul double %94, 0x3FF20DD750429B6D
%96 = fdiv double %95, 2.000000e+00
ret double %96
}

LLVM IR (-O2):
@__const.min_prob.gauss_hermite = [10 x [2 x double]] [[2 x double] [double 0xC00B7D40FDF8C912, double 0x3FF06840085C2EA5], [2 x double] [double 0xC0044308D2F1DBCE, double 0x3FEA42E59BBA5609], [2 x double] [double 0xBFFC1B60506BB603, double 0x3FE7B9E46E2C9809], [2 x double] [double 0xBFF095F53CC3DAD5, double 0x3FE681674A6391D0], [2 x double] [double 0xBFD5F21868850E42, double 0x3FE5FC9315859E1B], [2 x double] [double 0x3FD5F21868850E42, double 0x3FE5FC9315859E1B], [2 x double] [double 0x3FF095F53CC3DAD5, double 0x3FE681674A6391D0], [2 x double] [double 0x3FFC1B60506BB603, double 0x3FE7B9E46E2C9809], [2 x double] [double 0x40044308D2F1DBCE, double 0x3FEA42E59BBA5609], [2 x double] [double 0x400B7D40FDF8C912, double 0x3FF06840085C2EA5]]
define double @min_prob(i32 %0, i32 %1, double* nocapture %2, double* nocapture %3) {
%5 = sext i32 %0 to i64
%6 = getelementptr inbounds double, double* %3, i64 %5
%7 = load double, double* %6
%8 = fmul double %7, 0x3FF6A09E667F3BCD
%9 = icmp sgt i32 %1, 0
%10 = getelementptr inbounds double, double* %2, i64 %5
%11 = zext i32 %0 to i64
%12 = sext i32 %1 to i64
br label %13
13: ; preds = %4, %45
%14 = phi i64 [ 0, %4 ], [ %50, %45 ]
%15 = phi double [ 0.000000e+00, %4 ], [ %49, %45 ]
%16 = getelementptr inbounds [10 x [2 x double]], [10 x [2 x double]]* @__const.min_prob.gauss_hermite, i64 0, i64 %14, i64 0
%17 = load double, double* %16
%18 = fneg double %17
%19 = fmul double %17, %18
%20 = tail call double @exp(double %19)
%21 = fcmp ogt double %20, 1.000000e-02
%22 = select i1 %9, i1 %21, i1 false
br i1 %22, label %23, label %45
23: ; preds = %13, %39
%24 = phi i64 [ %41, %39 ], [ 0, %13 ]
%25 = phi double [ %40, %39 ], [ %20, %13 ]
%26 = icmp eq i64 %24, %11
br i1 %26, label %39, label %27
27: ; preds = %23
%28 = load double, double* %10
%29 = tail call double @llvm.fmuladd.f64(double %17, double %8, double %28)
%30 = getelementptr inbounds double, double* %2, i64 %24
%31 = load double, double* %30
%32 = fsub double %29, %31
%33 = getelementptr inbounds double, double* %3, i64 %24
%34 = load double, double* %33
%35 = fdiv double %32, %34
%36 = tail call double @ndtr(double %35)
%37 = fsub double 1.000000e+00, %36
%38 = fmul double %25, %37
br label %39
39: ; preds = %23, %27
%40 = phi double [ %25, %23 ], [ %38, %27 ]
%41 = add nuw nsw i64 %24, 1
%42 = icmp slt i64 %41, %12
%43 = fcmp ogt double %40, 1.000000e-02
%44 = select i1 %42, i1 %43, i1 false
br i1 %44, label %23, label %45
45: ; preds = %39, %13
%46 = phi double [ %20, %13 ], [ %40, %39 ]
%47 = getelementptr inbounds [10 x [2 x double]], [10 x [2 x double]]* @__const.min_prob.gauss_hermite, i64 0, i64 %14, i64 1
%48 = load double, double* %47
%49 = tail call double @llvm.fmuladd.f64(double %48, double %46, double %15)
%50 = add nuw nsw i64 %14, 1
%51 = icmp eq i64 %50, 10
br i1 %51, label %52, label %13
52: ; preds = %45
%53 = fmul double %49, 0x3FF20DD750429B6D
%54 = fmul double %53, 5.000000e-01
ret double %54
}