#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);
int pow(double, double);
double sqrt(double);
double PopCSn0(int Z, double M, double E, int CSn) {
  int Q = 0;
  double Sum = 0, Q0 = 0, Width = 0, WP = 0;
  if (Z < CSn)
    return -1.0;
  Q0 = Z / pow(1 + pow(0.260 * pow(Z, 0.45) / sqrt(E / M), 1.66666667), 0.6);
  Width = 0.5 * sqrt(Q0 * (1 - pow(Q0 / Z, 1.66666667)));
  WP = 0.39894228 / Width;
  for (Q = 0; Q <= Z; Q++) {
    Sum += WP * exp(-0.5 * (Q0 - Q) * (Q0 - Q) / (Width * Width));
  };
  return WP * exp(-0.5 * (Q0 - CSn) * (Q0 - CSn) / (Width * Width)) / Sum;
}


x86 assembly (clang, -O0):
<PopCSn0>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
mov    %esi,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    118d <PopCSn0+0x5d>
movsd  0xeb5(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1350 <PopCSn0+0x220>
mov    -0xc(%rbp),%eax
mov    %eax,-0x54(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  0xe88(%rip),%xmm1
call   1040 <pow@plt>
cvtsi2sd %eax,%xmm1
movsd  0xe6f(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x20(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  0xe33(%rip),%xmm1
call   1040 <pow@plt>
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe27(%rip),%xmm1
call   1040 <pow@plt>
mov    %eax,%ecx
mov    -0x54(%rbp),%eax
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x38(%rbp),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  0xde9(%rip),%xmm1
call   1040 <pow@plt>
movsd  -0x50(%rbp),%xmm0
mov    %eax,%ecx
mov    $0x1,%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xdb6(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xd9d(%rip),%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     12f1 <PopCSn0+0x1c1>
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x38(%rbp),%xmm1
cvtsi2sdl -0x28(%rbp),%xmm0
subsd  %xmm0,%xmm1
movsd  0xd90(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  -0x38(%rbp),%xmm1
cvtsi2sdl -0x28(%rbp),%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  -0x40(%rbp),%xmm1
mulsd  -0x40(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm2
movsd  -0x68(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1274 <PopCSn0+0x144>
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x38(%rbp),%xmm1
cvtsi2sdl -0x24(%rbp),%xmm0
subsd  %xmm0,%xmm1
movsd  0xd1f(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  -0x38(%rbp),%xmm1
cvtsi2sdl -0x24(%rbp),%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  -0x40(%rbp),%xmm1
mulsd  -0x40(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
mulsd  %xmm1,%xmm0
divsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PopCSn0>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
cmp    %esi,%edi
jge    1149 <PopCSn0+0x19>
movsd  0xebc(%rip),%xmm0
jmp    1306 <PopCSn0+0x1d6>
mov    %esi,%r14d
movapd %xmm1,%xmm2
mov    %edi,%ebp
movsd  %xmm0,0x10(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %edi,%xmm0
movsd  0xea1(%rip),%xmm1
movsd  %xmm0,0x8(%rsp)
movsd  %xmm2,(%rsp)
call   1040 <pow@plt>
movsd  (%rsp),%xmm0
cvtsi2sd %eax,%xmm3
mulsd  0xe88(%rip),%xmm3
divsd  0x10(%rsp),%xmm0
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm0
jb     119e <PopCSn0+0x6e>
sqrtsd %xmm0,%xmm0
jmp    11ad <PopCSn0+0x7d>
movsd  %xmm3,(%rsp)
call   1050 <sqrt@plt>
movsd  (%rsp),%xmm3
divsd  %xmm0,%xmm3
movsd  0xe5f(%rip),%xmm1
movapd %xmm3,%xmm0
call   1040 <pow@plt>
add    $0x1,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0xe4c(%rip),%xmm1
call   1040 <pow@plt>
mov    %eax,%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,(%rsp)
divsd  0x8(%rsp),%xmm0
movsd  0xe1e(%rip),%xmm1
call   1040 <pow@plt>
movsd  (%rsp),%xmm1
mov    $0x1,%ecx
sub    %eax,%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
mulsd  %xmm1,%xmm0
ucomisd 0xe22(%rip),%xmm0
jb     1229 <PopCSn0+0xf9>
xorps  %xmm2,%xmm2
sqrtsd %xmm0,%xmm2
jmp    1237 <PopCSn0+0x107>
call   1050 <sqrt@plt>
movsd  (%rsp),%xmm1
movapd %xmm0,%xmm2
mulsd  0xde9(%rip),%xmm2
movsd  0xde9(%rip),%xmm0
divsd  %xmm2,%xmm0
mulsd  %xmm2,%xmm2
test   %ebp,%ebp
movsd  %xmm0,0x10(%rsp)
js     12c3 <PopCSn0+0x193>
add    $0x1,%ebp
xor    %ebx,%ebx
xorpd  %xmm3,%xmm3
movsd  %xmm3,0x8(%rsp)
movsd  %xmm2,0x18(%rsp)
xchg   %ax,%ax
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
mulsd  0xdac(%rip),%xmm0
mulsd  %xmm1,%xmm0
divsd  %xmm2,%xmm0
call   1030 <exp@plt>
movsd  0x18(%rsp),%xmm2
movsd  (%rsp),%xmm1
mulsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm3
addsd  %xmm0,%xmm3
movsd  %xmm3,0x8(%rsp)
add    $0x1,%ebx
cmp    %ebx,%ebp
jne    1270 <PopCSn0+0x140>
jmp    12cd <PopCSn0+0x19d>
xorpd  %xmm3,%xmm3
movsd  %xmm3,0x8(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
subsd  %xmm0,%xmm1
movsd  0xd57(%rip),%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
divsd  %xmm2,%xmm0
call   1030 <exp@plt>
movsd  0x10(%rsp),%xmm1
mulsd  %xmm0,%xmm1
divsd  0x8(%rsp),%xmm1
movapd %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define double @PopCSn0(i32 %0, double %1, double %2, i32 %3) {
%5 = alloca double
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca i32
%10 = alloca i32
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
store i32 %0, i32* %6
store double %1, double* %7
store double %2, double* %8
store i32 %3, i32* %9
store i32 0, i32* %10
store double 0.000000e+00, double* %11
store double 0.000000e+00, double* %12
store double 0.000000e+00, double* %13
store double 0.000000e+00, double* %14
%15 = load i32, i32* %6
%16 = load i32, i32* %9
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %19
18: ; preds = %4
store double -1.000000e+00, double* %5
br label %96
19: ; preds = %4
%20 = load i32, i32* %6
%21 = load i32, i32* %6
%22 = sitofp i32 %21 to double
%23 = call i32 @pow(double %22, double 4.500000e-01)
%24 = sitofp i32 %23 to double
%25 = fmul double 2.600000e-01, %24
%26 = load double, double* %8
%27 = load double, double* %7
%28 = fdiv double %26, %27
%29 = call double @sqrt(double %28)
%30 = fdiv double %25, %29
%31 = call i32 @pow(double %30, double 0x3FFAAAAAAB8FBB49)
%32 = add nsw i32 1, %31
%33 = sitofp i32 %32 to double
%34 = call i32 @pow(double %33, double 6.000000e-01)
%35 = sdiv i32 %20, %34
%36 = sitofp i32 %35 to double
store double %36, double* %12
%37 = load double, double* %12
%38 = load double, double* %12
%39 = load i32, i32* %6
%40 = sitofp i32 %39 to double
%41 = fdiv double %38, %40
%42 = call i32 @pow(double %41, double 0x3FFAAAAAAB8FBB49)
%43 = sub nsw i32 1, %42
%44 = sitofp i32 %43 to double
%45 = fmul double %37, %44
%46 = call double @sqrt(double %45)
%47 = fmul double 5.000000e-01, %46
store double %47, double* %13
%48 = load double, double* %13
%49 = fdiv double 0x3FD988453365DE00, %48
store double %49, double* %14
store i32 0, i32* %10
br label %50
50: ; preds = %73, %19
%51 = load i32, i32* %10
%52 = load i32, i32* %6
%53 = icmp sle i32 %51, %52
br i1 %53, label %54, label %76
54: ; preds = %50
%55 = load double, double* %14
%56 = load double, double* %12
%57 = load i32, i32* %10
%58 = sitofp i32 %57 to double
%59 = fsub double %56, %58
%60 = fmul double -5.000000e-01, %59
%61 = load double, double* %12
%62 = load i32, i32* %10
%63 = sitofp i32 %62 to double
%64 = fsub double %61, %63
%65 = fmul double %60, %64
%66 = load double, double* %13
%67 = load double, double* %13
%68 = fmul double %66, %67
%69 = fdiv double %65, %68
%70 = call double @exp(double %69)
%71 = load double, double* %11
%72 = call double @llvm.fmuladd.f64(double %55, double %70, double %71)
store double %72, double* %11
br label %73
73: ; preds = %54
%74 = load i32, i32* %10
%75 = add nsw i32 %74, 1
store i32 %75, i32* %10
br label %50
76: ; preds = %50
%77 = load double, double* %14
%78 = load double, double* %12
%79 = load i32, i32* %9
%80 = sitofp i32 %79 to double
%81 = fsub double %78, %80
%82 = fmul double -5.000000e-01, %81
%83 = load double, double* %12
%84 = load i32, i32* %9
%85 = sitofp i32 %84 to double
%86 = fsub double %83, %85
%87 = fmul double %82, %86
%88 = load double, double* %13
%89 = load double, double* %13
%90 = fmul double %88, %89
%91 = fdiv double %87, %90
%92 = call double @exp(double %91)
%93 = fmul double %77, %92
%94 = load double, double* %11
%95 = fdiv double %93, %94
store double %95, double* %5
br label %96
96: ; preds = %76, %18
%97 = load double, double* %5
ret double %97
}

LLVM IR (-O2):
define double @PopCSn0(i32 %0, double %1, double %2, i32 %3) {
%5 = icmp slt i32 %0, %3
br i1 %5, label %52, label %6
6: ; preds = %4
%7 = sitofp i32 %0 to double
%8 = tail call i32 @pow(double %7, double 4.500000e-01)
%9 = sitofp i32 %8 to double
%10 = fmul double %9, 2.600000e-01
%11 = fdiv double %2, %1
%12 = tail call double @sqrt(double %11)
%13 = fdiv double %10, %12
%14 = tail call i32 @pow(double %13, double 0x3FFAAAAAAB8FBB49)
%15 = add nsw i32 %14, 1
%16 = sitofp i32 %15 to double
%17 = tail call i32 @pow(double %16, double 6.000000e-01)
%18 = sdiv i32 %0, %17
%19 = sitofp i32 %18 to double
%20 = fdiv double %19, %7
%21 = tail call i32 @pow(double %20, double 0x3FFAAAAAAB8FBB49)
%22 = sub nsw i32 1, %21
%23 = sitofp i32 %22 to double
%24 = fmul double %19, %23
%25 = tail call double @sqrt(double %24)
%26 = fmul double %25, 5.000000e-01
%27 = fdiv double 0x3FD988453365DE00, %26
%28 = icmp slt i32 %0, 0
%29 = fmul double %26, %26
br i1 %28, label %42, label %30
30: ; preds = %6, %30
%31 = phi double [ %39, %30 ], [ 0.000000e+00, %6 ]
%32 = phi i32 [ %40, %30 ], [ 0, %6 ]
%33 = sitofp i32 %32 to double
%34 = fsub double %19, %33
%35 = fmul double %34, -5.000000e-01
%36 = fmul double %34, %35
%37 = fdiv double %36, %29
%38 = tail call double @exp(double %37)
%39 = tail call double @llvm.fmuladd.f64(double %27, double %38, double %31)
%40 = add nuw i32 %32, 1
%41 = icmp eq i32 %32, %0
br i1 %41, label %42, label %30
42: ; preds = %30, %6
%43 = phi double [ 0.000000e+00, %6 ], [ %39, %30 ]
%44 = sitofp i32 %3 to double
%45 = fsub double %19, %44
%46 = fmul double %45, -5.000000e-01
%47 = fmul double %45, %46
%48 = fdiv double %47, %29
%49 = tail call double @exp(double %48)
%50 = fmul double %27, %49
%51 = fdiv double %50, %43
br label %52
52: ; preds = %4, %42
%53 = phi double [ %51, %42 ], [ -1.000000e+00, %4 ]
ret double %53
}