#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 pow(double, int);
void stage_three(double *p_c, double *sigmas, double *mseR, double *fact,
                 double *ECik, double *tmseR, int p) {
  int i, j, k;
  double term1, term2;
  for (i = 1; i < p; ++i) {
    term1 = term2 = 0;
    for (j = i + 1; j < p; ++j) {
      term1 += p_c[j];
    }
    term1 *= p_c[i];
    for (k = p - 1 - i; k < p - 1; ++k) {
      term2 += (2. * sigmas[k] / pow(fact[k], 2)) / ECik[k];
    }
    tmseR[0] += mseR[i] + term1 * term2;
  }
}


x86 assembly (clang, -O0):
<stage_three>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    0x10(%rbp),%eax
jge    1260 <stage_three+0x150>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    0x10(%rbp),%eax
jge    1190 <stage_three+0x80>
mov    -0x8(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    115f <stage_three+0x4f>
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    0x10(%rbp),%eax
sub    $0x1,%eax
sub    -0x34(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    0x10(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1227 <stage_three+0x117>
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  0xe2c(%rip),%xmm0
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
movsd  -0x58(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movslq -0x3c(%rbp),%rcx
divsd  (%rax,%rcx,8),%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11b3 <stage_three+0xa3>
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x48(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    113a <stage_three+0x2a>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stage_three>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %r9,0x18(%rsp)
mov    %rcx,%r13
mov    %rdx,0x10(%rsp)
mov    %rdi,(%rsp)
mov    0x90(%rsp),%ecx
cmp    $0x2,%ecx
jl     1252 <stage_three+0x142>
mov    %r8,%r15
mov    %rsi,%rbx
lea    -0x1(%rcx),%ebp
mov    %ecx,%eax
add    $0xfffffffe,%ecx
mov    $0x1,%esi
mov    %rax,%rdx
mov    (%rsp),%r12
mov    %rax,0x8(%rsp)
xchg   %ax,%ax
lea    0x1(%rsi),%rdi
xorpd  %xmm1,%xmm1
xorpd  %xmm0,%xmm0
mov    %rdi,0x28(%rsp)
cmp    %rax,%rdi
jae    118f <stage_three+0x7f>
xorpd  %xmm0,%xmm0
mov    $0x2,%eax
nop
addsd  (%r12,%rax,8),%xmm0
add    $0x1,%rax
cmp    %rax,%rdx
jne    1180 <stage_three+0x70>
mov    %rdx,0x38(%rsp)
mov    %rcx,0x40(%rsp)
movslq %ecx,%r14
mov    (%rsp),%rax
mov    %rsi,0x30(%rsp)
mulsd  (%rax,%rsi,8),%xmm0
movsd  %xmm0,0x20(%rsp)
movsd  %xmm1,0x50(%rsp)
movsd  (%rbx,%r14,8),%xmm0
addsd  %xmm0,%xmm0
movsd  %xmm0,0x48(%rsp)
movsd  0x0(%r13,%r14,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
movsd  0x50(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x48(%rsp),%xmm2
divsd  %xmm0,%xmm2
divsd  (%r15,%r14,8),%xmm2
addsd  %xmm2,%xmm1
add    $0x1,%r14
cmp    %rbp,%r14
jl     11b0 <stage_three+0xa0>
movsd  0x20(%rsp),%xmm0
mulsd  %xmm1,%xmm0
mov    0x10(%rsp),%rax
mov    0x30(%rsp),%rcx
addsd  (%rax,%rcx,8),%xmm0
mov    0x18(%rsp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
mov    0x40(%rsp),%rcx
add    $0xffffffff,%ecx
add    $0x8,%r12
mov    0x38(%rsp),%rdx
add    $0xffffffffffffffff,%rdx
mov    0x28(%rsp),%rdi
mov    %rdi,%rsi
mov    0x8(%rsp),%rax
cmp    %rax,%rdi
jne    1160 <stage_three+0x50>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @stage_three(double* nocapture %0, double* nocapture %1, double* nocapture %2, double* nocapture %3, double* nocapture %4, double* nocapture %5, i32 %6) {
%8 = icmp sgt i32 %6, 1
br i1 %8, label %9, label %61
9: ; preds = %7
%10 = add nsw i32 %6, -1
%11 = add nsw i32 %6, -2
%12 = zext i32 %10 to i64
%13 = zext i32 %6 to i64
%14 = zext i32 %6 to i64
br label %15
15: ; preds = %9, %52
%16 = phi i64 [ 1, %9 ], [ %20, %52 ]
%17 = phi i32 [ %11, %9 ], [ %59, %52 ]
%18 = phi i64 [ 2, %9 ], [ %58, %52 ]
%19 = sext i32 %17 to i64
%20 = add nuw nsw i64 %16, 1
%21 = icmp ult i64 %20, %13
br i1 %21, label %22, label %30
22: ; preds = %15, %22
%23 = phi i64 [ %28, %22 ], [ %18, %15 ]
%24 = phi double [ %27, %22 ], [ 0.000000e+00, %15 ]
%25 = getelementptr inbounds double, double* %0, i64 %23
%26 = load double, double* %25
%27 = fadd double %24, %26
%28 = add nuw nsw i64 %23, 1
%29 = icmp eq i64 %28, %14
br i1 %29, label %30, label %22
30: ; preds = %22, %15
%31 = phi double [ 0.000000e+00, %15 ], [ %27, %22 ]
%32 = getelementptr inbounds double, double* %0, i64 %16
%33 = load double, double* %32
%34 = fmul double %31, %33
br label %35
35: ; preds = %30, %35
%36 = phi i64 [ %19, %30 ], [ %50, %35 ]
%37 = phi double [ 0.000000e+00, %30 ], [ %49, %35 ]
%38 = getelementptr inbounds double, double* %1, i64 %36
%39 = load double, double* %38
%40 = fmul double %39, 2.000000e+00
%41 = getelementptr inbounds double, double* %3, i64 %36
%42 = load double, double* %41
%43 = tail call i32 @pow(double %42, i32 2)
%44 = sitofp i32 %43 to double
%45 = fdiv double %40, %44
%46 = getelementptr inbounds double, double* %4, i64 %36
%47 = load double, double* %46
%48 = fdiv double %45, %47
%49 = fadd double %37, %48
%50 = add nsw i64 %36, 1
%51 = icmp slt i64 %50, %12
br i1 %51, label %35, label %52
52: ; preds = %35
%53 = getelementptr inbounds double, double* %2, i64 %16
%54 = load double, double* %53
%55 = tail call double @llvm.fmuladd.f64(double %34, double %49, double %54)
%56 = load double, double* %5
%57 = fadd double %56, %55
store double %57, double* %5
%58 = add nuw nsw i64 %18, 1
%59 = add i32 %17, -1
%60 = icmp eq i64 %20, %14
br i1 %60, label %61, label %15
61: ; preds = %52, %7
ret void
}