int calcp1p2p3p4(int nlev, double *cf, double *ar_p1, double *ar_p2,
                 double *ar_p3, double *ar_p4) {
  double max_p1;
  double min_p3;
  double max_p2;
  double min_p4;
  const int nlyr = nlev - 1;
  ar_p1[0] = 1.0;
  ar_p3[0] = 1.0;
  for (int ilyr = 0; ilyr < nlyr; ilyr++) {
    if (cf[ilyr] > cf[ilyr - 1]) {
      max_p1 = cf[ilyr];
    } else {
      max_p1 = cf[ilyr - 1];
    }
    if (cf[ilyr] < cf[ilyr - 1]) {
      min_p3 = cf[ilyr];
    } else {
      min_p3 = cf[ilyr - 1];
    }
    if (cf[ilyr - 1] == 1.0)
      ar_p1[ilyr] = 1.0;
    else
      ar_p1[ilyr] = (1.0 - max_p1) / (1.0 - cf[ilyr - 1]);
    if (cf[ilyr - 1] == 0.0)
      ar_p3[ilyr] = 1.0;
    else
      ar_p3[ilyr] = min_p3 / cf[ilyr - 1];
  }
  for (int ilyr = 0; ilyr < nlyr - 1; ilyr++) {
    if (cf[ilyr] > cf[ilyr + 1]) {
      max_p2 = cf[ilyr];
    } else {
      max_p2 = cf[ilyr + 1];
    }
    if (cf[ilyr] < cf[ilyr + 1]) {
      min_p4 = cf[ilyr];
    } else {
      min_p4 = cf[ilyr + 1];
    }
    if (cf[ilyr + 1] == 1.0)
      ar_p2[ilyr] = 1.0;
    else
      ar_p2[ilyr] = (1.0 - max_p2) / (1.0 - cf[ilyr + 1]);
    if (cf[ilyr + 1] == 0.0)
      ar_p4[ilyr] = 1.0;
    else
      ar_p4[ilyr] = min_p4 / cf[ilyr + 1];
  }
  ar_p2[nlyr - 1] = 1.0;
  ar_p4[nlyr - 1] = 1.0;
  return 0;
}


x86 assembly (clang, -O0):
<calcp1p2p3p4>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x54(%rbp)
mov    -0x18(%rbp),%rax
movsd  0xed0(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movsd  0xec0(%rip),%xmm0
movsd  %xmm0,(%rax)
movl   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%eax
cmp    -0x54(%rbp),%eax
jge    12f3 <calcp1p2p3p4+0x1f3>
mov    -0x10(%rbp),%rax
movslq -0x58(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x58(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
ucomisd (%rax,%rcx,8),%xmm0
jbe    1193 <calcp1p2p3p4+0x93>
mov    -0x10(%rbp),%rax
movslq -0x58(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    11aa <calcp1p2p3p4+0xaa>
mov    -0x10(%rbp),%rax
mov    -0x58(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x58(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x10(%rbp),%rax
mov    -0x58(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd %xmm1,%xmm0
jbe    11ea <calcp1p2p3p4+0xea>
mov    -0x10(%rbp),%rax
movslq -0x58(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    1201 <calcp1p2p3p4+0x101>
mov    -0x10(%rbp),%rax
mov    -0x58(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x58(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  0xde5(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1245 <calcp1p2p3p4+0x145>
jp     1245 <calcp1p2p3p4+0x145>
mov    -0x18(%rbp),%rax
movslq -0x58(%rbp),%rcx
movsd  0xdc5(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    127d <calcp1p2p3p4+0x17d>
movsd  0xdb3(%rip),%xmm0
subsd  -0x38(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x58(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  0xd99(%rip),%xmm1
subsd  (%rax,%rcx,8),%xmm1
divsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x58(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
mov    -0x58(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    12bc <calcp1p2p3p4+0x1bc>
jp     12bc <calcp1p2p3p4+0x1bc>
mov    -0x28(%rbp),%rax
movslq -0x58(%rbp),%rcx
movsd  0xd4e(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    12e0 <calcp1p2p3p4+0x1e0>
movsd  -0x40(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x58(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
divsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x58(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    12e5 <calcp1p2p3p4+0x1e5>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    114b <calcp1p2p3p4+0x4b>
movl   $0x0,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
mov    -0x54(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    14a7 <calcp1p2p3p4+0x3a7>
mov    -0x10(%rbp),%rax
movslq -0x5c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x5c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
ucomisd (%rax,%rcx,8),%xmm0
jbe    1347 <calcp1p2p3p4+0x247>
mov    -0x10(%rbp),%rax
movslq -0x5c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    135e <calcp1p2p3p4+0x25e>
mov    -0x10(%rbp),%rax
mov    -0x5c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x5c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x10(%rbp),%rax
mov    -0x5c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd %xmm1,%xmm0
jbe    139e <calcp1p2p3p4+0x29e>
mov    -0x10(%rbp),%rax
movslq -0x5c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    13b5 <calcp1p2p3p4+0x2b5>
mov    -0x10(%rbp),%rax
mov    -0x5c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x5c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  0xc31(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    13f9 <calcp1p2p3p4+0x2f9>
jp     13f9 <calcp1p2p3p4+0x2f9>
mov    -0x20(%rbp),%rax
movslq -0x5c(%rbp),%rcx
movsd  0xc11(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    1431 <calcp1p2p3p4+0x331>
movsd  0xbff(%rip),%xmm0
subsd  -0x48(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x5c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  0xbe5(%rip),%xmm1
subsd  (%rax,%rcx,8),%xmm1
divsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movslq -0x5c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
mov    -0x5c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1470 <calcp1p2p3p4+0x370>
jp     1470 <calcp1p2p3p4+0x370>
mov    -0x30(%rbp),%rax
movslq -0x5c(%rbp),%rcx
movsd  0xb9a(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    1494 <calcp1p2p3p4+0x394>
movsd  -0x50(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x5c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
divsd  (%rax,%rcx,8),%xmm0
mov    -0x30(%rbp),%rax
movslq -0x5c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    1499 <calcp1p2p3p4+0x399>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    12fa <calcp1p2p3p4+0x1fa>
mov    -0x20(%rbp),%rax
mov    -0x54(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  0xb44(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
mov    -0x54(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  0xb2a(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<calcp1p2p3p4>:
movabs $0x3ff0000000000000,%r10
mov    %r10,(%rdx)
mov    %r10,(%r8)
cmp    $0x1,%edi
jle    1197 <calcp1p2p3p4+0x97>
lea    -0x1(%rdi),%r11d
xor    %eax,%eax
movsd  0xed9(%rip),%xmm0
xorpd  %xmm1,%xmm1
jmp    113f <calcp1p2p3p4+0x3f>
nopl   (%rax)
movsd  %xmm5,(%r8,%rax,8)
add    $0x1,%rax
cmp    %rax,%r11
je     11a2 <calcp1p2p3p4+0xa2>
movsd  -0x8(%rsi,%rax,8),%xmm3
movsd  (%rsi,%rax,8),%xmm2
ucomisd %xmm0,%xmm3
movapd %xmm0,%xmm4
jne    1156 <calcp1p2p3p4+0x56>
jnp    1172 <calcp1p2p3p4+0x72>
movapd %xmm2,%xmm5
maxsd  %xmm3,%xmm5
movapd %xmm0,%xmm4
subsd  %xmm5,%xmm4
movapd %xmm0,%xmm5
subsd  %xmm3,%xmm5
divsd  %xmm5,%xmm4
movsd  %xmm4,(%rdx,%rax,8)
movsd  -0x8(%rsi,%rax,8),%xmm4
ucomisd %xmm1,%xmm4
movapd %xmm0,%xmm5
jne    1189 <calcp1p2p3p4+0x89>
jnp    1130 <calcp1p2p3p4+0x30>
minsd  %xmm3,%xmm2
divsd  %xmm4,%xmm2
movapd %xmm2,%xmm5
jmp    1130 <calcp1p2p3p4+0x30>
add    $0xfffffffe,%edi
mov    %edi,%r8d
jmp    123a <calcp1p2p3p4+0x13a>
lea    -0x2(%rdi),%r8d
cmp    $0x3,%edi
jl     123a <calcp1p2p3p4+0x13a>
mov    %r8d,%eax
xor    %edi,%edi
movsd  0xe44(%rip),%xmm0
xorpd  %xmm1,%xmm1
jmp    11de <calcp1p2p3p4+0xde>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  %xmm5,(%r9,%rdi,8)
mov    %rdx,%rdi
cmp    %rdx,%rax
je     123a <calcp1p2p3p4+0x13a>
movsd  (%rsi,%rdi,8),%xmm2
movsd  0x8(%rsi,%rdi,8),%xmm3
ucomisd %xmm0,%xmm3
movapd %xmm0,%xmm4
jne    11f5 <calcp1p2p3p4+0xf5>
jnp    1211 <calcp1p2p3p4+0x111>
movapd %xmm2,%xmm5
maxsd  %xmm3,%xmm5
movapd %xmm0,%xmm4
subsd  %xmm5,%xmm4
movapd %xmm0,%xmm5
subsd  %xmm3,%xmm5
divsd  %xmm5,%xmm4
lea    0x1(%rdi),%rdx
movsd  %xmm4,(%rcx,%rdi,8)
movsd  0x8(%rsi,%rdi,8),%xmm4
ucomisd %xmm1,%xmm4
movapd %xmm0,%xmm5
jne    122c <calcp1p2p3p4+0x12c>
jnp    11d0 <calcp1p2p3p4+0xd0>
minsd  %xmm3,%xmm2
divsd  %xmm4,%xmm2
movapd %xmm2,%xmm5
jmp    11d0 <calcp1p2p3p4+0xd0>
movslq %r8d,%rax
mov    %r10,(%rcx,%rax,8)
mov    %r10,(%r9,%rax,8)
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @calcp1p2p3p4(i32 %0, double* %1, double* %2, double* %3, double* %4, double* %5) {
%7 = alloca i32
%8 = alloca double*
%9 = alloca double*
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
store i32 %0, i32* %7
store double* %1, double** %8
store double* %2, double** %9
store double* %3, double** %10
store double* %4, double** %11
store double* %5, double** %12
%20 = load i32, i32* %7
%21 = sub nsw i32 %20, 1
store i32 %21, i32* %17
%22 = load double*, double** %9
%23 = getelementptr inbounds double, double* %22, i64 0
store double 1.000000e+00, double* %23
%24 = load double*, double** %11
%25 = getelementptr inbounds double, double* %24, i64 0
store double 1.000000e+00, double* %25
store i32 0, i32* %18
br label %26
26: ; preds = %137, %6
%27 = load i32, i32* %18
%28 = load i32, i32* %17
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %140
30: ; preds = %26
%31 = load double*, double** %8
%32 = load i32, i32* %18
%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 = load i32, i32* %18
%38 = sub nsw i32 %37, 1
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %36, i64 %39
%41 = load double, double* %40
%42 = fcmp ogt double %35, %41
br i1 %42, label %43, label %49
43: ; preds = %30
%44 = load double*, double** %8
%45 = load i32, i32* %18
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds double, double* %44, i64 %46
%48 = load double, double* %47
store double %48, double* %13
br label %56
49: ; preds = %30
%50 = load double*, double** %8
%51 = load i32, i32* %18
%52 = sub nsw i32 %51, 1
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds double, double* %50, i64 %53
%55 = load double, double* %54
store double %55, double* %13
br label %56
56: ; preds = %49, %43
%57 = load double*, double** %8
%58 = load i32, i32* %18
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds double, double* %57, i64 %59
%61 = load double, double* %60
%62 = load double*, double** %8
%63 = load i32, i32* %18
%64 = sub nsw i32 %63, 1
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds double, double* %62, i64 %65
%67 = load double, double* %66
%68 = fcmp olt double %61, %67
br i1 %68, label %69, label %75
69: ; preds = %56
%70 = load double*, double** %8
%71 = load i32, i32* %18
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds double, double* %70, i64 %72
%74 = load double, double* %73
store double %74, double* %14
br label %82
75: ; preds = %56
%76 = load double*, double** %8
%77 = load i32, i32* %18
%78 = sub nsw i32 %77, 1
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds double, double* %76, i64 %79
%81 = load double, double* %80
store double %81, double* %14
br label %82
82: ; preds = %75, %69
%83 = load double*, double** %8
%84 = load i32, i32* %18
%85 = sub nsw i32 %84, 1
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds double, double* %83, i64 %86
%88 = load double, double* %87
%89 = fcmp oeq double %88, 1.000000e+00
br i1 %89, label %90, label %95
90: ; preds = %82
%91 = load double*, double** %9
%92 = load i32, i32* %18
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds double, double* %91, i64 %93
store double 1.000000e+00, double* %94
br label %110
95: ; preds = %82
%96 = load double, double* %13
%97 = fsub double 1.000000e+00, %96
%98 = load double*, double** %8
%99 = load i32, i32* %18
%100 = sub nsw i32 %99, 1
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds double, double* %98, i64 %101
%103 = load double, double* %102
%104 = fsub double 1.000000e+00, %103
%105 = fdiv double %97, %104
%106 = load double*, double** %9
%107 = load i32, i32* %18
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds double, double* %106, i64 %108
store double %105, double* %109
br label %110
110: ; preds = %95, %90
%111 = load double*, double** %8
%112 = load i32, i32* %18
%113 = sub nsw i32 %112, 1
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds double, double* %111, i64 %114
%116 = load double, double* %115
%117 = fcmp oeq double %116, 0.000000e+00
br i1 %117, label %118, label %123
118: ; preds = %110
%119 = load double*, double** %11
%120 = load i32, i32* %18
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds double, double* %119, i64 %121
store double 1.000000e+00, double* %122
br label %136
123: ; preds = %110
%124 = load double, double* %14
%125 = load double*, double** %8
%126 = load i32, i32* %18
%127 = sub nsw i32 %126, 1
%128 = sext i32 %127 to i64
%129 = getelementptr inbounds double, double* %125, i64 %128
%130 = load double, double* %129
%131 = fdiv double %124, %130
%132 = load double*, double** %11
%133 = load i32, i32* %18
%134 = sext i32 %133 to i64
%135 = getelementptr inbounds double, double* %132, i64 %134
store double %131, double* %135
br label %136
136: ; preds = %123, %118
br label %137
137: ; preds = %136
%138 = load i32, i32* %18
%139 = add nsw i32 %138, 1
store i32 %139, i32* %18
br label %26
140: ; preds = %26
store i32 0, i32* %19
br label %141
141: ; preds = %253, %140
%142 = load i32, i32* %19
%143 = load i32, i32* %17
%144 = sub nsw i32 %143, 1
%145 = icmp slt i32 %142, %144
br i1 %145, label %146, label %256
146: ; preds = %141
%147 = load double*, double** %8
%148 = load i32, i32* %19
%149 = sext i32 %148 to i64
%150 = getelementptr inbounds double, double* %147, i64 %149
%151 = load double, double* %150
%152 = load double*, double** %8
%153 = load i32, i32* %19
%154 = add nsw i32 %153, 1
%155 = sext i32 %154 to i64
%156 = getelementptr inbounds double, double* %152, i64 %155
%157 = load double, double* %156
%158 = fcmp ogt double %151, %157
br i1 %158, label %159, label %165
159: ; preds = %146
%160 = load double*, double** %8
%161 = load i32, i32* %19
%162 = sext i32 %161 to i64
%163 = getelementptr inbounds double, double* %160, i64 %162
%164 = load double, double* %163
store double %164, double* %15
br label %172
165: ; preds = %146
%166 = load double*, double** %8
%167 = load i32, i32* %19
%168 = add nsw i32 %167, 1
%169 = sext i32 %168 to i64
%170 = getelementptr inbounds double, double* %166, i64 %169
%171 = load double, double* %170
store double %171, double* %15
br label %172
172: ; preds = %165, %159
%173 = load double*, double** %8
%174 = load i32, i32* %19
%175 = sext i32 %174 to i64
%176 = getelementptr inbounds double, double* %173, i64 %175
%177 = load double, double* %176
%178 = load double*, double** %8
%179 = load i32, i32* %19
%180 = add nsw i32 %179, 1
%181 = sext i32 %180 to i64
%182 = getelementptr inbounds double, double* %178, i64 %181
%183 = load double, double* %182
%184 = fcmp olt double %177, %183
br i1 %184, label %185, label %191
185: ; preds = %172
%186 = load double*, double** %8
%187 = load i32, i32* %19
%188 = sext i32 %187 to i64
%189 = getelementptr inbounds double, double* %186, i64 %188
%190 = load double, double* %189
store double %190, double* %16
br label %198
191: ; preds = %172
%192 = load double*, double** %8
%193 = load i32, i32* %19
%194 = add nsw i32 %193, 1
%195 = sext i32 %194 to i64
%196 = getelementptr inbounds double, double* %192, i64 %195
%197 = load double, double* %196
store double %197, double* %16
br label %198
198: ; preds = %191, %185
%199 = load double*, double** %8
%200 = load i32, i32* %19
%201 = add nsw i32 %200, 1
%202 = sext i32 %201 to i64
%203 = getelementptr inbounds double, double* %199, i64 %202
%204 = load double, double* %203
%205 = fcmp oeq double %204, 1.000000e+00
br i1 %205, label %206, label %211
206: ; preds = %198
%207 = load double*, double** %10
%208 = load i32, i32* %19
%209 = sext i32 %208 to i64
%210 = getelementptr inbounds double, double* %207, i64 %209
store double 1.000000e+00, double* %210
br label %226
211: ; preds = %198
%212 = load double, double* %15
%213 = fsub double 1.000000e+00, %212
%214 = load double*, double** %8
%215 = load i32, i32* %19
%216 = add nsw i32 %215, 1
%217 = sext i32 %216 to i64
%218 = getelementptr inbounds double, double* %214, i64 %217
%219 = load double, double* %218
%220 = fsub double 1.000000e+00, %219
%221 = fdiv double %213, %220
%222 = load double*, double** %10
%223 = load i32, i32* %19
%224 = sext i32 %223 to i64
%225 = getelementptr inbounds double, double* %222, i64 %224
store double %221, double* %225
br label %226
226: ; preds = %211, %206
%227 = load double*, double** %8
%228 = load i32, i32* %19
%229 = add nsw i32 %228, 1
%230 = sext i32 %229 to i64
%231 = getelementptr inbounds double, double* %227, i64 %230
%232 = load double, double* %231
%233 = fcmp oeq double %232, 0.000000e+00
br i1 %233, label %234, label %239
234: ; preds = %226
%235 = load double*, double** %12
%236 = load i32, i32* %19
%237 = sext i32 %236 to i64
%238 = getelementptr inbounds double, double* %235, i64 %237
store double 1.000000e+00, double* %238
br label %252
239: ; preds = %226
%240 = load double, double* %16
%241 = load double*, double** %8
%242 = load i32, i32* %19
%243 = add nsw i32 %242, 1
%244 = sext i32 %243 to i64
%245 = getelementptr inbounds double, double* %241, i64 %244
%246 = load double, double* %245
%247 = fdiv double %240, %246
%248 = load double*, double** %12
%249 = load i32, i32* %19
%250 = sext i32 %249 to i64
%251 = getelementptr inbounds double, double* %248, i64 %250
store double %247, double* %251
br label %252
252: ; preds = %239, %234
br label %253
253: ; preds = %252
%254 = load i32, i32* %19
%255 = add nsw i32 %254, 1
store i32 %255, i32* %19
br label %141
256: ; preds = %141
%257 = load double*, double** %10
%258 = load i32, i32* %17
%259 = sub nsw i32 %258, 1
%260 = sext i32 %259 to i64
%261 = getelementptr inbounds double, double* %257, i64 %260
store double 1.000000e+00, double* %261
%262 = load double*, double** %12
%263 = load i32, i32* %17
%264 = sub nsw i32 %263, 1
%265 = sext i32 %264 to i64
%266 = getelementptr inbounds double, double* %262, i64 %265
store double 1.000000e+00, double* %266
ret i32 0
}

LLVM IR (-O2):
define i32 @calcp1p2p3p4(i32 %0, double* nocapture %1, double* nocapture writeonly %2, double* nocapture writeonly %3, double* nocapture writeonly %4, double* nocapture writeonly %5) {
store double 1.000000e+00, double* %2
store double 1.000000e+00, double* %4
%7 = icmp sgt i32 %0, 1
br i1 %7, label %10, label %8
8: ; preds = %6
%9 = add i32 %0, -2
br label %44
10: ; preds = %6
%11 = add nsw i32 %0, -1
%12 = zext i32 %11 to i64
br label %18
13: ; preds = %34
%14 = add i32 %0, -2
%15 = icmp sgt i32 %0, 2
br i1 %15, label %16, label %44
16: ; preds = %13
%17 = zext i32 %14 to i64
br label %49
18: ; preds = %10, %34
%19 = phi i64 [ 0, %10 ], [ %42, %34 ]
%20 = getelementptr inbounds double, double* %1, i64 %19
%21 = load double, double* %20
%22 = add nsw i64 %19, -1
%23 = getelementptr inbounds double, double* %1, i64 %22
%24 = load double, double* %23
%25 = fcmp olt double %21, %24
%26 = select i1 %25, double %21, double %24
%27 = fcmp oeq double %24, 1.000000e+00
br i1 %27, label %34, label %28
28: ; preds = %18
%29 = fcmp ogt double %21, %24
%30 = select i1 %29, double %21, double %24
%31 = fsub double 1.000000e+00, %30
%32 = fsub double 1.000000e+00, %24
%33 = fdiv double %31, %32
br label %34
34: ; preds = %18, %28
%35 = phi double [ %33, %28 ], [ 1.000000e+00, %18 ]
%36 = getelementptr inbounds double, double* %2, i64 %19
store double %35, double* %36
%37 = load double, double* %23
%38 = fcmp oeq double %37, 0.000000e+00
%39 = fdiv double %26, %37
%40 = select i1 %38, double 1.000000e+00, double %39
%41 = getelementptr inbounds double, double* %4, i64 %19
store double %40, double* %41
%42 = add nuw nsw i64 %19, 1
%43 = icmp eq i64 %42, %12
br i1 %43, label %13, label %18
44: ; preds = %65, %8, %13
%45 = phi i32 [ %9, %8 ], [ %14, %13 ], [ %14, %65 ]
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds double, double* %3, i64 %46
store double 1.000000e+00, double* %47
%48 = getelementptr inbounds double, double* %5, i64 %46
store double 1.000000e+00, double* %48
ret i32 0
49: ; preds = %16, %65
%50 = phi i64 [ 0, %16 ], [ %53, %65 ]
%51 = getelementptr inbounds double, double* %1, i64 %50
%52 = load double, double* %51
%53 = add nuw nsw i64 %50, 1
%54 = getelementptr inbounds double, double* %1, i64 %53
%55 = load double, double* %54
%56 = fcmp olt double %52, %55
%57 = select i1 %56, double %52, double %55
%58 = fcmp oeq double %55, 1.000000e+00
br i1 %58, label %65, label %59
59: ; preds = %49
%60 = fcmp ogt double %52, %55
%61 = select i1 %60, double %52, double %55
%62 = fsub double 1.000000e+00, %61
%63 = fsub double 1.000000e+00, %55
%64 = fdiv double %62, %63
br label %65
65: ; preds = %49, %59
%66 = phi double [ %64, %59 ], [ 1.000000e+00, %49 ]
%67 = getelementptr inbounds double, double* %3, i64 %50
store double %66, double* %67
%68 = load double, double* %54
%69 = fcmp oeq double %68, 0.000000e+00
%70 = fdiv double %57, %68
%71 = select i1 %69, double 1.000000e+00, double %70
%72 = getelementptr inbounds double, double* %5, i64 %50
store double %71, double* %72
%73 = icmp eq i64 %53, %17
br i1 %73, label %44, label %49
}