#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 /*<<< orphan*/ calc_Ba(double, double, double *, double *, double *,
                           double *, double *);
int /*<<< orphan*/ calc_Ka(double, double, double, double, double *, double *,
                           double, double *, int);
int /*<<< orphan*/ calc_entha(double, double, double *, double *, double *,
                              double *, double *);
int /*<<< orphan*/ calc_va(double, double, double, double *, double *,
                           double *);
int /*<<< orphan*/ cont_func(double, double *, double *, double *, double *,
                             double *, double *, double, double, double *,
                             double *, double *, double *, double *, double *,
                             double *, double, double, double *);
double fabs(double);
int /*<<< orphan*/ printf(char *, ...);
int calc_Ps(double *RL, double *RR, double Bx, double sL, double sR,
            double *Ps) {
  if (0)
    printf("    In calc_Ps\n");
  int i;
  double p0, p, p1, dp;
  double f, df;
  p0 = *Ps;
  p1 = p0;
  i = 0;
  do {
    p = p1;
    double vaL[3], vaR[3], dvaL[3], dvaR[3];
    double BaL[3], BaR[3], dBaL[3], dBaR[3];
    double enthL, enthR, denthL, denthR;
    double KaL[3], KaR[3], dKaL[3], dKaR[3];
    calc_va(p, sL, Bx, RL, vaL, dvaL);
    calc_va(p, sR, Bx, RR, vaR, dvaR);
    calc_Ba(sL, Bx, RL, vaL, BaL, dvaL, dBaL);
    calc_Ba(sR, Bx, RR, vaR, BaR, dvaR, dBaR);
    calc_entha(p, sL, RL, vaL, &enthL, dvaL, &denthL);
    calc_entha(p, sR, RR, vaR, &enthR, dvaR, &denthR);
    calc_Ka(p, sL, Bx, enthL, RL, KaL, denthL, dKaL, -1);
    calc_Ka(p, sR, Bx, enthR, RR, KaR, denthR, dKaR, +1);
    cont_func(Bx, BaL, BaR, vaL, vaR, KaL, KaR, enthL, enthR, &f, dBaL, dBaR,
              dvaL, dvaR, dKaL, dKaR, denthL, denthR, &df);
    dp = -f / df;
    p1 = p + dp;
    if (p1 < 0.0)
      p1 = 0.5 * p;
    if (enthL < 0.0 || enthR < 0.0)
      p1 = 0.8 * p;
    if (0) {
      printf("      %d: p=%.12lg dp=%.12lg f=%.12lg df=%.12lg\n", i, p, dp, f,
             df);
    }
    if (dp != dp && 0) {
      if (!0) {
        printf("      RL: %.16lg %.16lg %.16lg %.16lg\n", RL[0], RL[1], RL[2],
               RL[3]);
        printf("          %.16lg %.16lg %.16lg %.16lg\n", RL[4], RL[5], RL[6],
               RL[7]);
        printf("      RR: %.16lg %.16lg %.16lg %.16lg\n", RR[0], RR[1], RR[2],
               RR[3]);
        printf("          %.16lg %.16lg %.16lg %.16lg\n", RR[4], RR[5], RR[6],
               RR[7]);
        printf("      Bx = %.16lg, sL = %.16lg, sR = %.16lg\n", Bx, sL, sR);
      }
      printf("        va: (%.6lg %.6lg %.6lg) (%.6lg %.6lg %.6lg)\n", vaL[0],
             vaL[1], vaL[2], vaR[0], vaR[1], vaR[2]);
      printf("        Ba: (%.6lg %.6lg %.6lg) (%.6lg %.6lg %.6lg)\n", BaL[0],
             BaL[1], BaL[2], BaR[0], BaR[1], BaR[2]);
      printf("        entha: %.12lg %.12lg\n", enthL, enthR);
      printf("        Ka: (%.6lg %.6lg %.6lg) (%.6lg %.6lg %.6lg)\n", KaL[0],
             KaL[1], KaL[2], KaR[0], KaR[1], KaR[2]);
    }
    i++;
  } while (fabs(dp) / p > 1e-12 && i < 10);
  *Ps = p1;
  if (0)
    printf("    Done calc_Ps.\n");
  return 0;
}


x86 assembly (clang, -O0):
<calc_Ps>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x258,%rsp
mov    %rdi,-0x30(%rbp)
mov    %rsi,-0x38(%rbp)
movsd  %xmm0,-0x40(%rbp)
movsd  %xmm1,-0x48(%rbp)
movsd  %xmm2,-0x50(%rbp)
mov    %rdx,-0x58(%rbp)
mov    -0x58(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movl   $0x0,-0x5c(%rbp)
movsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x70(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
mov    -0x30(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
lea    -0xf0(%rbp),%rdx
call   1040 <calc_va@plt>
movsd  -0x70(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
mov    -0x38(%rbp),%rdi
lea    -0xd0(%rbp),%rsi
lea    -0x110(%rbp),%rdx
call   1040 <calc_va@plt>
movsd  -0x48(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
mov    -0x30(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
lea    -0x130(%rbp),%rdx
lea    -0xf0(%rbp),%rcx
lea    -0x170(%rbp),%r8
call   1070 <calc_Ba@plt>
movsd  -0x50(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
mov    -0x38(%rbp),%rdi
lea    -0xd0(%rbp),%rsi
lea    -0x150(%rbp),%rdx
lea    -0x110(%rbp),%rcx
lea    -0x190(%rbp),%r8
call   1070 <calc_Ba@plt>
movsd  -0x70(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
mov    -0x30(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
lea    -0xf0(%rbp),%rcx
lea    -0x198(%rbp),%rdx
lea    -0x1a8(%rbp),%r8
call   1080 <calc_entha@plt>
movsd  -0x70(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
mov    -0x38(%rbp),%rdi
lea    -0xd0(%rbp),%rsi
lea    -0x110(%rbp),%rcx
lea    -0x1a0(%rbp),%rdx
lea    -0x1b0(%rbp),%r8
call   1080 <calc_entha@plt>
movsd  -0x70(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
movsd  -0x198(%rbp),%xmm3
ff
mov    -0x30(%rbp),%rdi
lea    -0x1d0(%rbp),%rsi
movsd  -0x1a8(%rbp),%xmm4
ff
lea    -0x210(%rbp),%rdx
mov    $0xffffffff,%ecx
call   1030 <calc_Ka@plt>
movsd  -0x70(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
movsd  -0x1a0(%rbp),%xmm3
ff
mov    -0x38(%rbp),%rdi
lea    -0x1f0(%rbp),%rsi
movsd  -0x1b0(%rbp),%xmm4
ff
lea    -0x230(%rbp),%rdx
mov    $0x1,%ecx
call   1030 <calc_Ka@plt>
movsd  -0x40(%rbp),%xmm0
lea    -0x130(%rbp),%rdi
lea    -0x150(%rbp),%rsi
lea    -0xb0(%rbp),%rdx
lea    -0xd0(%rbp),%rcx
lea    -0x1d0(%rbp),%r8
lea    -0x1f0(%rbp),%r9
movsd  -0x198(%rbp),%xmm1
ff
movsd  -0x1a0(%rbp),%xmm2
ff
lea    -0x170(%rbp),%r12
lea    -0x190(%rbp),%r15
lea    -0xf0(%rbp),%r14
lea    -0x110(%rbp),%rbx
lea    -0x210(%rbp),%r11
lea    -0x230(%rbp),%r10
movsd  -0x1a8(%rbp),%xmm3
ff
movsd  -0x1b0(%rbp),%xmm4
ff
lea    -0x88(%rbp),%r13
lea    -0x90(%rbp),%rax
mov    %r13,(%rsp)
mov    %r12,0x8(%rsp)
mov    %r15,0x10(%rsp)
mov    %r14,0x18(%rsp)
mov    %rbx,0x20(%rsp)
mov    %r11,0x28(%rsp)
mov    %r10,0x30(%rsp)
mov    %rax,0x38(%rsp)
call   1060 <cont_func@plt>
movsd  -0x88(%rbp),%xmm0
ff
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
divsd  -0x90(%rbp),%xmm0
ff
movsd  %xmm0,-0x80(%rbp)
movsd  -0x70(%rbp),%xmm0
addsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x78(%rbp),%xmm0
jbe    1443 <calc_Ps+0x2e3>
movsd  0xbc7(%rip),%xmm0
mulsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x198(%rbp),%xmm0
ff
ja     1465 <calc_Ps+0x305>
xorps  %xmm0,%xmm0
ucomisd -0x1a0(%rbp),%xmm0
ff
jbe    1477 <calc_Ps+0x317>
movsd  0xb9b(%rip),%xmm0
mulsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x80(%rbp),%xmm0
ucomisd -0x80(%rbp),%xmm0
jne    1492 <calc_Ps+0x332>
jp     1492 <calc_Ps+0x332>
jmp    165c <calc_Ps+0x4fc>
xor    %eax,%eax
test   $0x1,%al
jne    14a1 <calc_Ps+0x341>
jmp    165c <calc_Ps+0x4fc>
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x30(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x30(%rbp),%rax
movsd  0x10(%rax),%xmm2
mov    -0x30(%rbp),%rax
movsd  0x18(%rax),%xmm3
lea    0xb65(%rip),%rdi
mov    $0x4,%al
call   1050 <printf@plt>
mov    -0x30(%rbp),%rax
movsd  0x20(%rax),%xmm0
mov    -0x30(%rbp),%rax
movsd  0x28(%rax),%xmm1
mov    -0x30(%rbp),%rax
movsd  0x30(%rax),%xmm2
mov    -0x30(%rbp),%rax
movsd  0x38(%rax),%xmm3
lea    0xb5a(%rip),%rdi
mov    $0x4,%al
call   1050 <printf@plt>
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x38(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x38(%rbp),%rax
movsd  0x10(%rax),%xmm2
mov    -0x38(%rbp),%rax
movsd  0x18(%rax),%xmm3
lea    0xb50(%rip),%rdi
mov    $0x4,%al
call   1050 <printf@plt>
mov    -0x38(%rbp),%rax
movsd  0x20(%rax),%xmm0
mov    -0x38(%rbp),%rax
movsd  0x28(%rax),%xmm1
mov    -0x38(%rbp),%rax
movsd  0x30(%rax),%xmm2
mov    -0x38(%rbp),%rax
movsd  0x38(%rax),%xmm3
lea    0xaf7(%rip),%rdi
mov    $0x4,%al
call   1050 <printf@plt>
movsd  -0x40(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm2
lea    0xb28(%rip),%rdi
mov    $0x3,%al
call   1050 <printf@plt>
movsd  -0xb0(%rbp),%xmm0
ff
movsd  -0xa8(%rbp),%xmm1
ff
movsd  -0xa0(%rbp),%xmm2
ff
movsd  -0xd0(%rbp),%xmm3
ff
movsd  -0xc8(%rbp),%xmm4
ff
movsd  -0xc0(%rbp),%xmm5
ff
lea    0xb17(%rip),%rdi
mov    $0x6,%al
call   1050 <printf@plt>
movsd  -0x130(%rbp),%xmm0
ff
movsd  -0x128(%rbp),%xmm1
ff
movsd  -0x120(%rbp),%xmm2
ff
movsd  -0x150(%rbp),%xmm3
ff
movsd  -0x148(%rbp),%xmm4
ff
movsd  -0x140(%rbp),%xmm5
ff
lea    0xb0e(%rip),%rdi
mov    $0x6,%al
call   1050 <printf@plt>
movsd  -0x198(%rbp),%xmm0
ff
movsd  -0x1a0(%rbp),%xmm1
ff
lea    0xb25(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
movsd  -0x1d0(%rbp),%xmm0
ff
movsd  -0x1c8(%rbp),%xmm1
ff
movsd  -0x1c0(%rbp),%xmm2
ff
movsd  -0x1f0(%rbp),%xmm3
ff
movsd  -0x1e8(%rbp),%xmm4
ff
movsd  -0x1e0(%rbp),%xmm5
ff
lea    0xb05(%rip),%rdi
mov    $0x6,%al
call   1050 <printf@plt>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
movsd  -0x80(%rbp),%xmm0
movaps 0x9af(%rip),%xmm1
pand   %xmm1,%xmm0
divsd  -0x70(%rbp),%xmm0
xor    %eax,%eax
movsd  0x98c(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x231(%rbp)
jbe    16a1 <calc_Ps+0x541>
cmpl   $0xa,-0x5c(%rbp)
setl   %al
mov    %al,-0x231(%rbp)
mov    -0x231(%rbp),%al
test   $0x1,%al
jne    11ad <calc_Ps+0x4d>
movsd  -0x78(%rbp),%xmm0
mov    -0x58(%rbp),%rax
movsd  %xmm0,(%rax)
xor    %eax,%eax
add    $0x258,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_Ps>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1e8,%rsp
movsd  %xmm2,0x18(%rsp)
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,(%rsp)
mov    %rsi,0x58(%rsp)
mov    %rdi,0x50(%rsp)
mov    %rdx,0x48(%rsp)
movsd  (%rdx),%xmm0
xor    %eax,%eax
mov    %rax,0x30(%rsp)
nopl   0x0(%rax)
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm1
movsd  (%rsp),%xmm2
mov    0x50(%rsp),%r12
mov    %r12,%rdi
lea    0x1d0(%rsp),%r13
mov    %r13,%rsi
lea    0x110(%rsp),%rbp
mov    %rbp,%rdx
call   1040 <calc_va@plt>
movsd  0x8(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
movsd  (%rsp),%xmm2
mov    0x58(%rsp),%rbx
mov    %rbx,%rdi
lea    0x1b0(%rsp),%r14
mov    %r14,%rsi
lea    0xf0(%rsp),%r15
mov    %r15,%rdx
call   1040 <calc_va@plt>
movsd  0x10(%rsp),%xmm0
movsd  (%rsp),%xmm1
mov    %r12,%rdi
mov    %r13,%rsi
lea    0xd0(%rsp),%rdx
mov    %rbp,%rcx
lea    0x90(%rsp),%r8
call   1060 <calc_Ba@plt>
movsd  0x18(%rsp),%xmm0
movsd  (%rsp),%xmm1
mov    %rbx,%rdi
mov    %r14,%rsi
lea    0xb0(%rsp),%rdx
mov    %r15,%rcx
lea    0x70(%rsp),%r8
call   1060 <calc_Ba@plt>
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
mov    %r12,%rdi
mov    %r13,%rsi
lea    0x28(%rsp),%rdx
mov    %rbp,%rcx
lea    0x40(%rsp),%r8
call   1070 <calc_entha@plt>
movsd  0x8(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
mov    %rbx,%rdi
mov    %r14,%rsi
lea    0x20(%rsp),%rdx
mov    %r15,%rcx
lea    0x38(%rsp),%r8
call   1070 <calc_entha@plt>
movsd  0x28(%rsp),%xmm3
movsd  0x40(%rsp),%xmm4
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  (%rsp),%xmm2
mov    %r12,%rdi
lea    0x190(%rsp),%rbp
mov    %rbp,%rsi
lea    0x150(%rsp),%r12
mov    %r12,%rdx
mov    $0xffffffff,%ecx
call   1030 <calc_Ka@plt>
movsd  0x20(%rsp),%xmm3
movsd  0x38(%rsp),%xmm4
movsd  0x8(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
movsd  (%rsp),%xmm2
mov    %rbx,%rdi
lea    0x170(%rsp),%rbx
mov    %rbx,%rsi
lea    0x130(%rsp),%r15
mov    %r15,%rdx
mov    $0x1,%ecx
call   1030 <calc_Ka@plt>
movsd  0x28(%rsp),%xmm1
movsd  0x20(%rsp),%xmm2
movsd  0x40(%rsp),%xmm3
movsd  0x38(%rsp),%xmm4
movsd  (%rsp),%xmm0
lea    0xd0(%rsp),%rdi
lea    0xb0(%rsp),%rsi
mov    %r13,%rdx
mov    %r14,%rcx
mov    %rbp,%r8
mov    %rbx,%r9
lea    0x60(%rsp),%rax
push   %rax
push   %r15
push   %r12
lea    0x108(%rsp),%rax
push   %rax
lea    0x130(%rsp),%rax
push   %rax
lea    0x98(%rsp),%rax
push   %rax
lea    0xc0(%rsp),%rax
push   %rax
lea    0xa0(%rsp),%rax
push   %rax
call   1050 <cont_func@plt>
add    $0x40,%rsp
movsd  0x68(%rsp),%xmm1
xorpd  0xc6a(%rip),%xmm1
divsd  0x60(%rsp),%xmm1
movsd  0x8(%rsp),%xmm7
movapd %xmm7,%xmm0
addsd  %xmm1,%xmm0
movapd %xmm7,%xmm2
mulsd  0xc6a(%rip),%xmm2
movapd %xmm0,%xmm3
xorpd  %xmm6,%xmm6
cmpltsd %xmm6,%xmm3
movapd %xmm3,%xmm4
andnpd %xmm0,%xmm4
andpd  %xmm2,%xmm3
orpd   %xmm4,%xmm3
movsd  0x28(%rsp),%xmm0
movsd  0x20(%rsp),%xmm2
movapd %xmm7,%xmm4
mulsd  0xc3d(%rip),%xmm4
cmpltsd %xmm6,%xmm2
movapd %xmm2,%xmm5
andnpd %xmm3,%xmm5
andpd  %xmm4,%xmm2
orpd   %xmm5,%xmm2
cmpltsd %xmm6,%xmm0
movapd %xmm0,%xmm3
andnpd %xmm2,%xmm3
andpd  %xmm4,%xmm0
orpd   %xmm3,%xmm0
andpd  0xbf3(%rip),%xmm1
divsd  %xmm7,%xmm1
ucomisd 0xc07(%rip),%xmm1
jbe    1441 <calc_Ps+0x2f1>
mov    0x30(%rsp),%rcx
lea    0x1(%rcx),%eax
cmp    $0x9,%ecx
mov    %rax,0x30(%rsp)
jb     1190 <calc_Ps+0x40>
mov    0x48(%rsp),%rax
movsd  %xmm0,(%rax)
xor    %eax,%eax
add    $0x1e8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @calc_Ps(double* %0, double* %1, double %2, double %3, double %4, double* nocapture %5) {
%7 = alloca double
%8 = alloca double
%9 = alloca [3 x double]
%10 = alloca [3 x double]
%11 = alloca [3 x double]
%12 = alloca [3 x double]
%13 = alloca [3 x double]
%14 = alloca [3 x double]
%15 = alloca [3 x double]
%16 = alloca [3 x double]
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca [3 x double]
%22 = alloca [3 x double]
%23 = alloca [3 x double]
%24 = alloca [3 x double]
%25 = bitcast double* %7 to i8*
%26 = bitcast double* %8 to i8*
%27 = load double, double* %5
%28 = bitcast [3 x double]* %9 to i8*
%29 = bitcast [3 x double]* %10 to i8*
%30 = bitcast [3 x double]* %11 to i8*
%31 = bitcast [3 x double]* %12 to i8*
%32 = bitcast [3 x double]* %13 to i8*
%33 = bitcast [3 x double]* %14 to i8*
%34 = bitcast [3 x double]* %15 to i8*
%35 = bitcast [3 x double]* %16 to i8*
%36 = bitcast double* %17 to i8*
%37 = bitcast double* %18 to i8*
%38 = bitcast double* %19 to i8*
%39 = bitcast double* %20 to i8*
%40 = bitcast [3 x double]* %21 to i8*
%41 = bitcast [3 x double]* %22 to i8*
%42 = bitcast [3 x double]* %23 to i8*
%43 = bitcast [3 x double]* %24 to i8*
%44 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 0
%45 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%46 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 0
%47 = getelementptr inbounds [3 x double], [3 x double]* %12, i64 0, i64 0
%48 = getelementptr inbounds [3 x double], [3 x double]* %13, i64 0, i64 0
%49 = getelementptr inbounds [3 x double], [3 x double]* %15, i64 0, i64 0
%50 = getelementptr inbounds [3 x double], [3 x double]* %14, i64 0, i64 0
%51 = getelementptr inbounds [3 x double], [3 x double]* %16, i64 0, i64 0
%52 = getelementptr inbounds [3 x double], [3 x double]* %21, i64 0, i64 0
%53 = getelementptr inbounds [3 x double], [3 x double]* %23, i64 0, i64 0
%54 = getelementptr inbounds [3 x double], [3 x double]* %22, i64 0, i64 0
%55 = getelementptr inbounds [3 x double], [3 x double]* %24, i64 0, i64 0
br label %56
56: ; preds = %56, %6
%57 = phi double [ %27, %6 ], [ %90, %56 ]
%58 = phi i32 [ 0, %6 ], [ %91, %56 ]
%59 = call i32 @calc_va(double %57, double %3, double %2, double* %0, double* %44, double* %45)
%60 = call i32 @calc_va(double %57, double %4, double %2, double* %1, double* %46, double* %47)
%61 = call i32 @calc_Ba(double %3, double %2, double* %0, double* %44, double* %48, double* %45, double* %49)
%62 = call i32 @calc_Ba(double %4, double %2, double* %1, double* %46, double* %50, double* %47, double* %51)
%63 = call i32 @calc_entha(double %57, double %3, double* %0, double* %44, double* %17, double* %45, double* %19)
%64 = call i32 @calc_entha(double %57, double %4, double* %1, double* %46, double* %18, double* %47, double* %20)
%65 = load double, double* %17
%66 = load double, double* %19
%67 = call i32 @calc_Ka(double %57, double %3, double %2, double %65, double* %0, double* %52, double %66, double* %53, i32 -1)
%68 = load double, double* %18
%69 = load double, double* %20
%70 = call i32 @calc_Ka(double %57, double %4, double %2, double %68, double* %1, double* %54, double %69, double* %55, i32 1)
%71 = load double, double* %17
%72 = load double, double* %18
%73 = load double, double* %19
%74 = load double, double* %20
%75 = call i32 @cont_func(double %2, double* %48, double* %50, double* %44, double* %46, double* %52, double* %54, double %71, double %72, double* %7, double* %49, double* %51, double* %45, double* %47, double* %53, double* %55, double %73, double %74, double* %8)
%76 = load double, double* %7
%77 = fneg double %76
%78 = load double, double* %8
%79 = fdiv double %77, %78
%80 = fadd double %57, %79
%81 = fcmp olt double %80, 0.000000e+00
%82 = fmul double %57, 5.000000e-01
%83 = select i1 %81, double %82, double %80
%84 = load double, double* %17
%85 = fcmp olt double %84, 0.000000e+00
%86 = load double, double* %18
%87 = fcmp olt double %86, 0.000000e+00
%88 = select i1 %85, i1 true, i1 %87
%89 = fmul double %57, 8.000000e-01
%90 = select i1 %88, double %89, double %83
%91 = add nuw nsw i32 %58, 1
%92 = call double @llvm.fabs.f64(double %79)
%93 = fdiv double %92, %57
%94 = fcmp ogt double %93, 0x3D719799812DEA11
%95 = icmp ult i32 %58, 9
%96 = select i1 %94, i1 %95, i1 false
br i1 %96, label %56, label %97
97: ; preds = %56
store double %90, double* %5
ret i32 0
}