#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 sqrt(double);
int initGauss4bit(double *prob, double *param) {
  double Vweight[] = {-7.5, -6.5, -5.5, -4.5, -3.5, -2.5, -1.5, -0.5,
                      0.5,  1.5,  2.5,  3.5,  4.5,  5.5,  6.5,  7.5};
  double Pweight[] = {56.25, 42.25, 30.25, 20.25, 12.25, 6.25,  2.25,  0.25,
                      0.25,  2.25,  6.25,  12.25, 20.25, 30.25, 42.25, 56.25};
  double Average = 0.0;
  double Variance = 0.0;
  int index;
  for (index = 0; index < 16; index++) {
    Average += Vweight[index] * prob[index];
    Variance += Pweight[index] * prob[index];
  }
  param[0] = 1.0 / sqrt(Variance);
  param[1] = Average * param[0];
  return (0);
}


x86 assembly (clang, -O0):
<initGauss4bit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x90(%rbp),%rdi
lea    0xecf(%rip),%rsi
mov    $0x80,%edx
call   1030 <memcpy@plt>
lea    -0x110(%rbp),%rdi
lea    0xf37(%rip),%rsi
mov    $0x80,%edx
call   1030 <memcpy@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x118(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x120(%rbp)
ff
movl   $0x0,-0x124(%rbp)
cmpl   $0x10,-0x124(%rbp)
jge    1214 <initGauss4bit+0xf4>
movslq -0x124(%rbp),%rax
movsd  -0x90(%rbp,%rax,8),%xmm0
ff ff
mov    -0x8(%rbp),%rax
movslq -0x124(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x118(%rbp),%xmm1
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x118(%rbp)
ff
movslq -0x124(%rbp),%rax
movsd  -0x110(%rbp,%rax,8),%xmm0
ff ff
mov    -0x8(%rbp),%rax
movslq -0x124(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x120(%rbp),%xmm1
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x120(%rbp)
ff
mov    -0x124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x124(%rbp)
jmp    1183 <initGauss4bit+0x63>
movsd  -0x120(%rbp),%xmm0
ff
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xdd4(%rip),%xmm0
divsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x118(%rbp),%xmm0
ff
mov    -0x10(%rbp),%rax
mulsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
xor    %eax,%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initGauss4bit>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
xorpd  %xmm3,%xmm3
xor    %eax,%eax
lea    0xeeb(%rip),%rcx
lea    0xf64(%rip),%rdx
nopl   0x0(%rax)
movsd  (%rdx,%rax,8),%xmm0
movsd  0x8(%rdx,%rax,8),%xmm1
movhpd (%rcx,%rax,8),%xmm0
movsd  (%rdi,%rax,8),%xmm2
unpcklpd %xmm2,%xmm2
mulpd  %xmm0,%xmm2
addpd  %xmm3,%xmm2
movsd  0x8(%rdi,%rax,8),%xmm3
movhpd 0x8(%rcx,%rax,8),%xmm1
unpcklpd %xmm3,%xmm3
mulpd  %xmm1,%xmm3
addpd  %xmm2,%xmm3
add    $0x2,%rax
cmp    $0x10,%rax
jne    1130 <initGauss4bit+0x20>
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm3
jb     1186 <initGauss4bit+0x76>
xorps  %xmm0,%xmm0
sqrtsd %xmm3,%xmm0
jmp    1199 <initGauss4bit+0x89>
movapd %xmm3,%xmm0
movapd %xmm3,(%rsp)
call   1030 <sqrt@plt>
movapd (%rsp),%xmm3
movsd  0xe5f(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%rbx)
unpckhpd %xmm3,%xmm3
mulsd  %xmm1,%xmm3
movsd  %xmm3,0x8(%rbx)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.initGauss4bit.Vweight = [16 x double] [double -7.500000e+00, double -6.500000e+00, double -5.500000e+00, double -4.500000e+00, double -3.500000e+00, double -2.500000e+00, double -1.500000e+00, double -5.000000e-01, double 5.000000e-01, double 1.500000e+00, double 2.500000e+00, double 3.500000e+00, double 4.500000e+00, double 5.500000e+00, double 6.500000e+00, double 7.500000e+00]
@__const.initGauss4bit.Pweight = [16 x double] [double 5.625000e+01, double 4.225000e+01, double 3.025000e+01, double 2.025000e+01, double 1.225000e+01, double 6.250000e+00, double 2.250000e+00, double 2.500000e-01, double 2.500000e-01, double 2.250000e+00, double 6.250000e+00, double 1.225000e+01, double 2.025000e+01, double 3.025000e+01, double 4.225000e+01, double 5.625000e+01]
define i32 @initGauss4bit(double* %0, double* %1) {
%3 = alloca double*
%4 = alloca double*
%5 = alloca [16 x double]
%6 = alloca [16 x double]
%7 = alloca double
%8 = alloca double
%9 = alloca i32
store double* %0, double** %3
store double* %1, double** %4
%10 = bitcast [16 x double]* %5 to i8*
%11 = bitcast [16 x double]* %6 to i8*
store double 0.000000e+00, double* %7
store double 0.000000e+00, double* %8
store i32 0, i32* %9
br label %12
12: ; preds = %38, %2
%13 = load i32, i32* %9
%14 = icmp slt i32 %13, 16
br i1 %14, label %15, label %41
15: ; preds = %12
%16 = load i32, i32* %9
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [16 x double], [16 x double]* %5, i64 0, i64 %17
%19 = load double, double* %18
%20 = load double*, double** %3
%21 = load i32, i32* %9
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds double, double* %20, i64 %22
%24 = load double, double* %23
%25 = load double, double* %7
%26 = call double @llvm.fmuladd.f64(double %19, double %24, double %25)
store double %26, double* %7
%27 = load i32, i32* %9
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [16 x double], [16 x double]* %6, i64 0, i64 %28
%30 = load double, double* %29
%31 = load double*, double** %3
%32 = load i32, i32* %9
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %31, i64 %33
%35 = load double, double* %34
%36 = load double, double* %8
%37 = call double @llvm.fmuladd.f64(double %30, double %35, double %36)
store double %37, double* %8
br label %38
38: ; preds = %15
%39 = load i32, i32* %9
%40 = add nsw i32 %39, 1
store i32 %40, i32* %9
br label %12
41: ; preds = %12
%42 = load double, double* %8
%43 = call double @sqrt(double %42)
%44 = fdiv double 1.000000e+00, %43
%45 = load double*, double** %4
%46 = getelementptr inbounds double, double* %45, i64 0
store double %44, double* %46
%47 = load double, double* %7
%48 = load double*, double** %4
%49 = getelementptr inbounds double, double* %48, i64 0
%50 = load double, double* %49
%51 = fmul double %47, %50
%52 = load double*, double** %4
%53 = getelementptr inbounds double, double* %52, i64 1
store double %51, double* %53
ret i32 0
}

LLVM IR (-O2):
@__const.initGauss4bit.Vweight = [16 x double] [double -7.500000e+00, double -6.500000e+00, double -5.500000e+00, double -4.500000e+00, double -3.500000e+00, double -2.500000e+00, double -1.500000e+00, double -5.000000e-01, double 5.000000e-01, double 1.500000e+00, double 2.500000e+00, double 3.500000e+00, double 4.500000e+00, double 5.500000e+00, double 6.500000e+00, double 7.500000e+00]
@__const.initGauss4bit.Pweight = [16 x double] [double 5.625000e+01, double 4.225000e+01, double 3.025000e+01, double 2.025000e+01, double 1.225000e+01, double 6.250000e+00, double 2.250000e+00, double 2.500000e-01, double 2.500000e-01, double 2.250000e+00, double 6.250000e+00, double 1.225000e+01, double 2.025000e+01, double 3.025000e+01, double 4.225000e+01, double 5.625000e+01]
define i32 @initGauss4bit(double* nocapture %0, double* nocapture writeonly %1) {
br label %3
3: ; preds = %3, %2
%4 = phi i64 [ 0, %2 ], [ %29, %3 ]
%5 = phi <2 x double> [ zeroinitializer, %2 ], [ %28, %3 ]
%6 = getelementptr inbounds [16 x double], [16 x double]* @__const.initGauss4bit.Vweight, i64 0, i64 %4
%7 = load double, double* %6
%8 = getelementptr inbounds double, double* %0, i64 %4
%9 = load double, double* %8
%10 = getelementptr inbounds [16 x double], [16 x double]* @__const.initGauss4bit.Pweight, i64 0, i64 %4
%11 = load double, double* %10
%12 = insertelement <2 x double> poison, double %11, i64 0
%13 = insertelement <2 x double> %12, double %7, i64 1
%14 = insertelement <2 x double> poison, double %9, i64 0
%15 = shufflevector <2 x double> %14, <2 x double> poison, <2 x i32> zeroinitializer
%16 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %13, <2 x double> %15, <2 x double> %5)
%17 = or i64 %4, 1
%18 = getelementptr inbounds [16 x double], [16 x double]* @__const.initGauss4bit.Vweight, i64 0, i64 %17
%19 = load double, double* %18
%20 = getelementptr inbounds double, double* %0, i64 %17
%21 = load double, double* %20
%22 = getelementptr inbounds [16 x double], [16 x double]* @__const.initGauss4bit.Pweight, i64 0, i64 %17
%23 = load double, double* %22
%24 = insertelement <2 x double> poison, double %23, i64 0
%25 = insertelement <2 x double> %24, double %19, i64 1
%26 = insertelement <2 x double> poison, double %21, i64 0
%27 = shufflevector <2 x double> %26, <2 x double> poison, <2 x i32> zeroinitializer
%28 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %25, <2 x double> %27, <2 x double> %16)
%29 = add nuw nsw i64 %4, 2
%30 = icmp eq i64 %29, 16
br i1 %30, label %31, label %3
31: ; preds = %3
%32 = extractelement <2 x double> %28, i64 0
%33 = tail call double @sqrt(double %32)
%34 = fdiv double 1.000000e+00, %33
store double %34, double* %1
%35 = extractelement <2 x double> %28, i64 1
%36 = fmul double %35, %34
%37 = getelementptr inbounds double, double* %1, i64 1
store double %36, double* %37
ret i32 0
}