#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*/ eigenvalsort(double *, double **);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ jacobi(double **, double *, double **, int *);
int /*<<< orphan*/ printmatrix(double **);
double sqrt(double);
int /*<<< orphan*/ stderr;
int calc_pppos_2ndorder(double q[3][3], double cmpos[3], double cmmass,
                        double pppos[3][3], int c0) {
  int i, j, k;
  int nrot;
  double val;
  double x[3][3];
  double eval[3];
  double p[3][3];
  if (0 > jacobi(q, eval, p, &nrot)) {
    fprintf(stderr, "c0: %d\n", c0);
    printmatrix(q);
    return (-1);
  }
  eigenvalsort(eval, p);
  x[0][0] = 0.0;
  val = (eval[0] + 2.0 * eval[1]) / 3.0 / cmmass;
  if (val < 0.0) {
    if (-val < (1e-16)) {
      x[1][0] = 0.0;
    } else {
      fprintf(stderr, "c0: %d x[1][0]^2 < 0.0: %e\n", c0, val);
      fprintf(stderr, "eigen val: %e %e %e\n", eval[0], eval[1], eval[2]);
      fprintf(stderr, "eigen vec:\n");
      printmatrix(p);
      return (-1);
    }
  } else {
    x[1][0] = 2.0 * sqrt(val);
  }
  x[2][0] = 0.0;
  val = (2.0 * eval[0] + eval[1]) / cmmass;
  if (val < 0.0) {
    if (-val < (1e-16)) {
      x[0][1] = 0.0;
    } else {
      fprintf(stderr, "c0: %d x[0][1]^2 < 0.0: %e\n", c0, val);
      return (-1);
    }
  } else {
    x[0][1] = sqrt(val);
  }
  x[1][1] = -x[1][0] / 2.0;
  x[2][1] = 0.0;
  x[0][2] = -x[0][1];
  x[1][2] = x[1][1];
  x[2][2] = 0.0;
  for (i = 0; i < 3; i++) {
    for (j = 0; j < 3; j++) {
      pppos[j][i] = 0.0;
      for (k = 0; k < 3; k++) {
        pppos[j][i] += p[i][k] * x[k][j];
      }
    }
  }
  for (k = 0; k < 3; k++) {
    for (i = 0; i < 3; i++) {
      pppos[i][k] += cmpos[k];
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<calc_pppos_2ndorder>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %ecx,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
lea    -0x100(%rbp),%rdx
lea    -0x3c(%rbp),%rcx
call   1030 <jacobi@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jle    11c7 <calc_pppos_2ndorder+0x77>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
mov    -0x2c(%rbp),%edx
lea    0xe6d(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <printmatrix@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1570 <calc_pppos_2ndorder+0x420>
lea    -0xb0(%rbp),%rdi
lea    -0x100(%rbp),%rsi
call   1070 <eigenvalsort@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0xb0(%rbp),%xmm1
ff
movsd  -0xa8(%rbp),%xmm0
ff
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xdfb(%rip),%xmm1
divsd  %xmm1,%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x48(%rbp),%xmm0
jbe    12de <calc_pppos_2ndorder+0x18e>
movsd  -0x48(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xdcb(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    125c <calc_pppos_2ndorder+0x10c>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x78(%rbp)
jmp    12d9 <calc_pppos_2ndorder+0x189>
mov    0x2d7d(%rip),%rax
mov    (%rax),%edi
mov    -0x2c(%rbp),%edx
movsd  -0x48(%rbp),%xmm0
lea    0xdac(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    0x2d5e(%rip),%rax
mov    (%rax),%edi
movsd  -0xb0(%rbp),%xmm0
ff
movsd  -0xa8(%rbp),%xmm1
ff
movsd  -0xa0(%rbp),%xmm2
ff
lea    0xd99(%rip),%rsi
mov    $0x3,%al
call   1050 <fprintf@plt>
mov    0x2d2f(%rip),%rax
mov    (%rax),%edi
lea    0xd97(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
lea    -0x100(%rbp),%rdi
call   1040 <printmatrix@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1570 <calc_pppos_2ndorder+0x420>
jmp    12fc <calc_pppos_2ndorder+0x1ac>
movsd  -0x48(%rbp),%xmm0
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xd15(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0xb0(%rbp),%xmm0
ff
movsd  -0xa8(%rbp),%xmm1
ff
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x48(%rbp),%xmm0
jbe    13a2 <calc_pppos_2ndorder+0x252>
movsd  -0x48(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xcb8(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1372 <calc_pppos_2ndorder+0x222>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
jmp    139d <calc_pppos_2ndorder+0x24d>
mov    0x2c67(%rip),%rax
mov    (%rax),%edi
mov    -0x2c(%rbp),%edx
movsd  -0x48(%rbp),%xmm0
lea    0xcd3(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1570 <calc_pppos_2ndorder+0x420>
jmp    13b4 <calc_pppos_2ndorder+0x264>
movsd  -0x48(%rbp),%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x78(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xc30(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x88(%rbp),%xmm0
ff
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
movl   $0x0,-0x30(%rbp)
cmpl   $0x3,-0x30(%rbp)
jge    14fc <calc_pppos_2ndorder+0x3ac>
movl   $0x0,-0x34(%rbp)
cmpl   $0x3,-0x34(%rbp)
jge    14e9 <calc_pppos_2ndorder+0x399>
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x30(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x0,-0x38(%rbp)
cmpl   $0x3,-0x38(%rbp)
jge    14d6 <calc_pppos_2ndorder+0x386>
movslq -0x30(%rbp),%rcx
lea    -0x100(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x38(%rbp),%rcx
lea    -0x90(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1463 <calc_pppos_2ndorder+0x313>
jmp    14db <calc_pppos_2ndorder+0x38b>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1437 <calc_pppos_2ndorder+0x2e7>
jmp    14ee <calc_pppos_2ndorder+0x39e>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1426 <calc_pppos_2ndorder+0x2d6>
movl   $0x0,-0x38(%rbp)
cmpl   $0x3,-0x38(%rbp)
jge    1569 <calc_pppos_2ndorder+0x419>
movl   $0x0,-0x30(%rbp)
cmpl   $0x3,-0x30(%rbp)
jge    1556 <calc_pppos_2ndorder+0x406>
mov    -0x18(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x30(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x38(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1514 <calc_pppos_2ndorder+0x3c4>
jmp    155b <calc_pppos_2ndorder+0x40b>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1503 <calc_pppos_2ndorder+0x3b3>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_pppos_2ndorder>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x78,%rsp
mov    %ecx,%r15d
mov    %rdx,%rbx
movsd  %xmm0,0x8(%rsp)
mov    %rsi,%r14
mov    %rdi,%rbp
lea    0x10(%rsp),%rsi
lea    0x30(%rsp),%rdx
lea    0x2c(%rsp),%rcx
call   1030 <jacobi@plt>
test   %rax,%rax
js     1231 <calc_pppos_2ndorder+0xe1>
lea    0x10(%rsp),%rdi
lea    0x30(%rsp),%rsi
call   1070 <eigenvalsort@plt>
movsd  0x10(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
movapd %xmm2,%xmm0
addsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  0xe48(%rip),%xmm0
movsd  0x8(%rsp),%xmm3
divsd  %xmm3,%xmm0
xorpd  %xmm4,%xmm4
ucomisd %xmm0,%xmm4
jbe    125d <calc_pppos_2ndorder+0x10d>
ucomisd 0xe30(%rip),%xmm0
ja     128b <calc_pppos_2ndorder+0x13b>
mov    0x2dfb(%rip),%rbx
mov    (%rbx),%edi
lea    0xe32(%rip),%rsi
mov    %r15d,%edx
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    (%rbx),%edi
movsd  0x10(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
movsd  0x20(%rsp),%xmm2
lea    0xe29(%rip),%rsi
mov    $0x3,%al
call   1050 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe2e(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0x30(%rsp),%rdi
jmp    124e <calc_pppos_2ndorder+0xfe>
mov    0x2da8(%rip),%rax
mov    (%rax),%edi
lea    0xdd7(%rip),%rsi
mov    %r15d,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %rbp,%rdi
call   1040 <printmatrix@plt>
mov    $0xffffffff,%eax
jmp    14c2 <calc_pppos_2ndorder+0x372>
ucomisd %xmm4,%xmm0
jb     126c <calc_pppos_2ndorder+0x11c>
xorps  %xmm4,%xmm4
sqrtsd %xmm0,%xmm4
jmp    127b <calc_pppos_2ndorder+0x12b>
call   1060 <sqrt@plt>
movsd  0x8(%rsp),%xmm3
movapd %xmm0,%xmm4
addsd  %xmm4,%xmm4
movsd  0x10(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
addsd  %xmm1,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm3,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    12d3 <calc_pppos_2ndorder+0x183>
ucomisd 0xd5f(%rip),%xmm1
ja     12f7 <calc_pppos_2ndorder+0x1a7>
mov    0x2d2e(%rip),%rax
mov    (%rax),%edi
lea    0xda2(%rip),%rsi
mov    %r15d,%edx
movapd %xmm1,%xmm0
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    $0xffffffff,%eax
jmp    14c2 <calc_pppos_2ndorder+0x372>
ucomisd %xmm0,%xmm1
jb     12e2 <calc_pppos_2ndorder+0x192>
xorps  %xmm0,%xmm0
sqrtsd %xmm1,%xmm0
jmp    12f7 <calc_pppos_2ndorder+0x1a7>
movapd %xmm1,%xmm0
movsd  %xmm4,0x8(%rsp)
call   1060 <sqrt@plt>
movsd  0x8(%rsp),%xmm4
movsd  0xd10(%rip),%xmm8
mulsd  %xmm4,%xmm8
movsd  0x30(%rsp),%xmm1
movsd  0x38(%rsp),%xmm5
xorpd  %xmm3,%xmm3
movapd %xmm1,%xmm6
mulsd  %xmm3,%xmm6
addsd  %xmm3,%xmm6
movapd %xmm5,%xmm9
mulsd  %xmm4,%xmm9
addsd  %xmm6,%xmm9
movsd  0x40(%rsp),%xmm6
mulsd  %xmm3,%xmm6
addsd  %xmm6,%xmm9
movsd  %xmm9,(%rbx)
mulsd  %xmm0,%xmm1
xorpd  %xmm7,%xmm7
subsd  %xmm1,%xmm7
addsd  %xmm3,%xmm1
mulsd  %xmm8,%xmm5
addsd  %xmm5,%xmm1
addsd  %xmm6,%xmm1
movsd  %xmm1,0x18(%rbx)
addsd  %xmm7,%xmm5
addsd  %xmm6,%xmm5
movsd  %xmm5,0x30(%rbx)
movsd  0x48(%rsp),%xmm5
movsd  0x50(%rsp),%xmm2
movapd %xmm5,%xmm7
mulsd  %xmm3,%xmm7
addsd  %xmm3,%xmm7
movapd %xmm2,%xmm6
mulsd  %xmm4,%xmm6
addsd  %xmm7,%xmm6
movsd  0x58(%rsp),%xmm7
mulsd  %xmm3,%xmm7
addsd  %xmm7,%xmm6
movsd  %xmm6,0x8(%rbx)
mulsd  %xmm0,%xmm5
xorpd  %xmm6,%xmm6
subsd  %xmm5,%xmm6
addsd  %xmm3,%xmm5
mulsd  %xmm8,%xmm2
addsd  %xmm2,%xmm5
addsd  %xmm7,%xmm5
movsd  %xmm5,0x20(%rbx)
addsd  %xmm6,%xmm2
addsd  %xmm7,%xmm2
movsd  %xmm2,0x38(%rbx)
movsd  0x60(%rsp),%xmm2
movsd  0x68(%rsp),%xmm5
movapd %xmm2,%xmm6
mulsd  %xmm3,%xmm6
addsd  %xmm3,%xmm6
mulsd  %xmm5,%xmm4
addsd  %xmm6,%xmm4
movsd  0x70(%rsp),%xmm6
mulsd  %xmm3,%xmm6
addsd  %xmm6,%xmm4
movsd  %xmm4,0x10(%rbx)
mulsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
addsd  %xmm3,%xmm0
mulsd  %xmm5,%xmm8
addsd  %xmm8,%xmm0
addsd  %xmm6,%xmm0
movsd  %xmm0,0x28(%rbx)
subsd  %xmm2,%xmm3
addsd  %xmm8,%xmm3
addsd  %xmm6,%xmm3
movsd  %xmm3,0x40(%rbx)
addsd  (%r14),%xmm9
movsd  %xmm9,(%rbx)
addsd  (%r14),%xmm1
movsd  %xmm1,0x18(%rbx)
movsd  (%r14),%xmm0
addsd  0x30(%rbx),%xmm0
movsd  %xmm0,0x30(%rbx)
movsd  0x8(%r14),%xmm0
addsd  0x8(%rbx),%xmm0
movsd  %xmm0,0x8(%rbx)
movsd  0x8(%r14),%xmm0
addsd  0x20(%rbx),%xmm0
movsd  %xmm0,0x20(%rbx)
movsd  0x8(%r14),%xmm0
addsd  0x38(%rbx),%xmm0
movsd  %xmm0,0x38(%rbx)
movsd  0x10(%r14),%xmm0
addsd  0x10(%rbx),%xmm0
movsd  %xmm0,0x10(%rbx)
movsd  0x10(%r14),%xmm0
addsd  0x28(%rbx),%xmm0
movsd  %xmm0,0x28(%rbx)
movsd  0x10(%r14),%xmm0
addsd  0x40(%rbx),%xmm0
movsd  %xmm0,0x40(%rbx)
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [8 x i8] c"c0: %d\0A\00"
@.str.1 = [28 x i8] c"c0: %d x[1][0]^2 < 0.0: %e\0A\00"
@.str.2 = [21 x i8] c"eigen val: %e %e %e\0A\00"
@.str.3 = [12 x i8] c"eigen vec:\0A\00"
@.str.4 = [28 x i8] c"c0: %d x[0][1]^2 < 0.0: %e\0A\00"
define i32 @calc_pppos_2ndorder([3 x double]* %0, double* %1, double %2, [3 x double]* %3, i32 %4) {
%6 = alloca i32
%7 = alloca [3 x double]*
%8 = alloca double*
%9 = alloca double
%10 = alloca [3 x double]*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca double
%17 = alloca [3 x [3 x double]]
%18 = alloca [3 x double]
%19 = alloca [3 x [3 x double]]
store [3 x double]* %0, [3 x double]** %7
store double* %1, double** %8
store double %2, double* %9
store [3 x double]* %3, [3 x double]** %10
store i32 %4, i32* %11
%20 = load [3 x double]*, [3 x double]** %7
%21 = bitcast [3 x double]* %20 to double**
%22 = getelementptr inbounds [3 x double], [3 x double]* %18, i64 0, i64 0
%23 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %19, i64 0, i64 0
%24 = bitcast [3 x double]* %23 to double**
%25 = call i64 @jacobi(double** %21, double* %22, double** %24, i32* %15)
%26 = icmp sgt i64 0, %25
br i1 %26, label %27, label %34
27: ; preds = %5
%28 = load i32, i32* @stderr
%29 = load i32, i32* %11
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %29)
%31 = load [3 x double]*, [3 x double]** %7
%32 = bitcast [3 x double]* %31 to double**
%33 = call i32 @printmatrix(double** %32)
store i32 -1, i32* %6
br label %220
34: ; preds = %5
%35 = getelementptr inbounds [3 x double], [3 x double]* %18, i64 0, i64 0
%36 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %19, i64 0, i64 0
%37 = bitcast [3 x double]* %36 to double**
%38 = call i32 @eigenvalsort(double* %35, double** %37)
%39 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %17, i64 0, i64 0
%40 = getelementptr inbounds [3 x double], [3 x double]* %39, i64 0, i64 0
store double 0.000000e+00, double* %40
%41 = getelementptr inbounds [3 x double], [3 x double]* %18, i64 0, i64 0
%42 = load double, double* %41
%43 = getelementptr inbounds [3 x double], [3 x double]* %18, i64 0, i64 1
%44 = load double, double* %43
%45 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %44, double %42)
%46 = fdiv double %45, 3.000000e+00
%47 = load double, double* %9
%48 = fdiv double %46, %47
store double %48, double* %16
%49 = load double, double* %16
%50 = fcmp olt double %49, 0.000000e+00
br i1 %50, label %51, label %77
51: ; preds = %34
%52 = load double, double* %16
%53 = fneg double %52
%54 = fcmp olt double %53, 0x3C9CD2B297D889BC
br i1 %54, label %55, label %58
55: ; preds = %51
%56 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %17, i64 0, i64 1
%57 = getelementptr inbounds [3 x double], [3 x double]* %56, i64 0, i64 0
store double 0.000000e+00, double* %57
br label %76
58: ; preds = %51
%59 = load i32, i32* @stderr
%60 = load i32, i32* %11
%61 = load double, double* %16
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %60, double %61)
%63 = load i32, i32* @stderr
%64 = getelementptr inbounds [3 x double], [3 x double]* %18, i64 0, i64 0
%65 = load double, double* %64
%66 = getelementptr inbounds [3 x double], [3 x double]* %18, i64 0, i64 1
%67 = load double, double* %66
%68 = getelementptr inbounds [3 x double], [3 x double]* %18, i64 0, i64 2
%69 = load double, double* %68
%70 = call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), double %65, double %67, double %69)
%71 = load i32, i32* @stderr
%72 = call i32 (i32, i8*, ...) @fprintf(i32 %71, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%73 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %19, i64 0, i64 0
%74 = bitcast [3 x double]* %73 to double**
%75 = call i32 @printmatrix(double** %74)
store i32 -1, i32* %6
br label %220
76: ; preds = %55
br label %83
77: ; preds = %34
%78 = load double, double* %16
%79 = call double @sqrt(double %78)
%80 = fmul double 2.000000e+00, %79
%81 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %17, i64 0, i64 1
%82 = getelementptr inbounds [3 x double], [3 x double]* %81, i64 0, i64 0
store double %80, double* %82
br label %83
83: ; preds = %77, %76
%84 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %17, i64 0, i64 2
%85 = getelementptr inbounds [3 x double], [3 x double]* %84, i64 0, i64 0
store double 0.000000e+00, double* %85
%86 = getelementptr inbounds [3 x double], [3 x double]* %18, i64 0, i64 0
%87 = load double, double* %86
%88 = getelementptr inbounds [3 x double], [3 x double]* %18, i64 0, i64 1
%89 = load double, double* %88
%90 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %87, double %89)
%91 = load double, double* %9
%92 = fdiv double %90, %91
store double %92, double* %16
%93 = load double, double* %16
%94 = fcmp olt double %93, 0.000000e+00
br i1 %94, label %95, label %108
95: ; preds = %83
%96 = load double, double* %16
%97 = fneg double %96
%98 = fcmp olt double %97, 0x3C9CD2B297D889BC
br i1 %98, label %99, label %102
99: ; preds = %95
%100 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %17, i64 0, i64 0
%101 = getelementptr inbounds [3 x double], [3 x double]* %100, i64 0, i64 1
store double 0.000000e+00, double* %101
br label %107
102: ; preds = %95
%103 = load i32, i32* @stderr
%104 = load i32, i32* %11
%105 = load double, double* %16
%106 = call i32 (i32, i8*, ...) @fprintf(i32 %103, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i32 %104, double %105)
store i32 -1, i32* %6
br label %220
107: ; preds = %99
br label %113
108: ; preds = %83
%109 = load double, double* %16
%110 = call double @sqrt(double %109)
%111 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %17, i64 0, i64 0
%112 = getelementptr inbounds [3 x double], [3 x double]* %111, i64 0, i64 1
store double %110, double* %112
br label %113
113: ; preds = %108, %107
%114 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %17, i64 0, i64 1
%115 = getelementptr inbounds [3 x double], [3 x double]* %114, i64 0, i64 0
%116 = load double, double* %115
%117 = fneg double %116
%118 = fdiv double %117, 2.000000e+00
%119 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %17, i64 0, i64 1
%120 = getelementptr inbounds [3 x double], [3 x double]* %119, i64 0, i64 1
store double %118, double* %120
%121 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %17, i64 0, i64 2
%122 = getelementptr inbounds [3 x double], [3 x double]* %121, i64 0, i64 1
store double 0.000000e+00, double* %122
%123 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %17, i64 0, i64 0
%124 = getelementptr inbounds [3 x double], [3 x double]* %123, i64 0, i64 1
%125 = load double, double* %124
%126 = fneg double %125
%127 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %17, i64 0, i64 0
%128 = getelementptr inbounds [3 x double], [3 x double]* %127, i64 0, i64 2
store double %126, double* %128
%129 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %17, i64 0, i64 1
%130 = getelementptr inbounds [3 x double], [3 x double]* %129, i64 0, i64 1
%131 = load double, double* %130
%132 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %17, i64 0, i64 1
%133 = getelementptr inbounds [3 x double], [3 x double]* %132, i64 0, i64 2
store double %131, double* %133
%134 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %17, i64 0, i64 2
%135 = getelementptr inbounds [3 x double], [3 x double]* %134, i64 0, i64 2
store double 0.000000e+00, double* %135
store i32 0, i32* %12
br label %136
136: ; preds = %186, %113
%137 = load i32, i32* %12
%138 = icmp slt i32 %137, 3
br i1 %138, label %139, label %189
139: ; preds = %136
store i32 0, i32* %13
br label %140
140: ; preds = %182, %139
%141 = load i32, i32* %13
%142 = icmp slt i32 %141, 3
br i1 %142, label %143, label %185
143: ; preds = %140
%144 = load [3 x double]*, [3 x double]** %10
%145 = load i32, i32* %13
%146 = sext i32 %145 to i64
%147 = getelementptr inbounds [3 x double], [3 x double]* %144, i64 %146
%148 = load i32, i32* %12
%149 = sext i32 %148 to i64
%150 = getelementptr inbounds [3 x double], [3 x double]* %147, i64 0, i64 %149
store double 0.000000e+00, double* %150
store i32 0, i32* %14
br label %151
151: ; preds = %178, %143
%152 = load i32, i32* %14
%153 = icmp slt i32 %152, 3
br i1 %153, label %154, label %181
154: ; preds = %151
%155 = load i32, i32* %12
%156 = sext i32 %155 to i64
%157 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %19, i64 0, i64 %156
%158 = load i32, i32* %14
%159 = sext i32 %158 to i64
%160 = getelementptr inbounds [3 x double], [3 x double]* %157, i64 0, i64 %159
%161 = load double, double* %160
%162 = load i32, i32* %14
%163 = sext i32 %162 to i64
%164 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %17, i64 0, i64 %163
%165 = load i32, i32* %13
%166 = sext i32 %165 to i64
%167 = getelementptr inbounds [3 x double], [3 x double]* %164, i64 0, i64 %166
%168 = load double, double* %167
%169 = load [3 x double]*, [3 x double]** %10
%170 = load i32, i32* %13
%171 = sext i32 %170 to i64
%172 = getelementptr inbounds [3 x double], [3 x double]* %169, i64 %171
%173 = load i32, i32* %12
%174 = sext i32 %173 to i64
%175 = getelementptr inbounds [3 x double], [3 x double]* %172, i64 0, i64 %174
%176 = load double, double* %175
%177 = call double @llvm.fmuladd.f64(double %161, double %168, double %176)
store double %177, double* %175
br label %178
178: ; preds = %154
%179 = load i32, i32* %14
%180 = add nsw i32 %179, 1
store i32 %180, i32* %14
br label %151
181: ; preds = %151
br label %182
182: ; preds = %181
%183 = load i32, i32* %13
%184 = add nsw i32 %183, 1
store i32 %184, i32* %13
br label %140
185: ; preds = %140
br label %186
186: ; preds = %185
%187 = load i32, i32* %12
%188 = add nsw i32 %187, 1
store i32 %188, i32* %12
br label %136
189: ; preds = %136
store i32 0, i32* %14
br label %190
190: ; preds = %216, %189
%191 = load i32, i32* %14
%192 = icmp slt i32 %191, 3
br i1 %192, label %193, label %219
193: ; preds = %190
store i32 0, i32* %12
br label %194
194: ; preds = %212, %193
%195 = load i32, i32* %12
%196 = icmp slt i32 %195, 3
br i1 %196, label %197, label %215
197: ; preds = %194
%198 = load double*, double** %8
%199 = load i32, i32* %14
%200 = sext i32 %199 to i64
%201 = getelementptr inbounds double, double* %198, i64 %200
%202 = load double, double* %201
%203 = load [3 x double]*, [3 x double]** %10
%204 = load i32, i32* %12
%205 = sext i32 %204 to i64
%206 = getelementptr inbounds [3 x double], [3 x double]* %203, i64 %205
%207 = load i32, i32* %14
%208 = sext i32 %207 to i64
%209 = getelementptr inbounds [3 x double], [3 x double]* %206, i64 0, i64 %208
%210 = load double, double* %209
%211 = fadd double %210, %202
store double %211, double* %209
br label %212
212: ; preds = %197
%213 = load i32, i32* %12
%214 = add nsw i32 %213, 1
store i32 %214, i32* %12
br label %194
215: ; preds = %194
br label %216
216: ; preds = %215
%217 = load i32, i32* %14
%218 = add nsw i32 %217, 1
store i32 %218, i32* %14
br label %190
219: ; preds = %190
store i32 0, i32* %6
br label %220
220: ; preds = %219, %102, %58, %27
%221 = load i32, i32* %6
ret i32 %221
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [8 x i8] c"c0: %d\0A\00"
@.str.1 = [28 x i8] c"c0: %d x[1][0]^2 < 0.0: %e\0A\00"
@.str.2 = [21 x i8] c"eigen val: %e %e %e\0A\00"
@.str.3 = [12 x i8] c"eigen vec:\0A\00"
@.str.4 = [28 x i8] c"c0: %d x[0][1]^2 < 0.0: %e\0A\00"
define i32 @calc_pppos_2ndorder([3 x double]* %0, double* nocapture %1, double %2, [3 x double]* nocapture %3, i32 %4) {
%6 = alloca i32
%7 = alloca [3 x double]
%8 = alloca [3 x [3 x double]]
%9 = bitcast i32* %6 to i8*
%10 = bitcast [3 x double]* %7 to i8*
%11 = bitcast [3 x [3 x double]]* %8 to i8*
%12 = bitcast [3 x double]* %0 to double**
%13 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 0
%14 = bitcast [3 x [3 x double]]* %8 to double**
%15 = call i64 @jacobi(double** %12, double* %13, double** %14, i32* %6)
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %5
%18 = load i32, i32* @stderr
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %4)
%20 = call i32 @printmatrix(double** %12)
br label %159
21: ; preds = %5
%22 = call i32 @eigenvalsort(double* %13, double** %14)
%23 = load double, double* %13
%24 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 1
%25 = load double, double* %24
%26 = call double @llvm.fmuladd.f64(double %25, double 2.000000e+00, double %23)
%27 = fdiv double %26, 3.000000e+00
%28 = fdiv double %27, %2
%29 = fcmp olt double %28, 0.000000e+00
br i1 %29, label %30, label %44
30: ; preds = %21
%31 = fcmp ogt double %28, 0xBC9CD2B297D889BC
br i1 %31, label %49, label %32
32: ; preds = %30
%33 = load i32, i32* @stderr
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %4, double %28)
%35 = load i32, i32* @stderr
%36 = load double, double* %13
%37 = load double, double* %24
%38 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 2
%39 = load double, double* %38
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), double %36, double %37, double %39)
%41 = load i32, i32* @stderr
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%43 = call i32 @printmatrix(double** %14)
br label %159
44: ; preds = %21
%45 = call double @sqrt(double %28)
%46 = fmul double %45, 2.000000e+00
%47 = load double, double* %13
%48 = load double, double* %24
br label %49
49: ; preds = %30, %44
%50 = phi double [ %48, %44 ], [ %25, %30 ]
%51 = phi double [ %47, %44 ], [ %23, %30 ]
%52 = phi double [ %46, %44 ], [ 0.000000e+00, %30 ]
%53 = call double @llvm.fmuladd.f64(double %51, double 2.000000e+00, double %50)
%54 = fdiv double %53, %2
%55 = fcmp olt double %54, 0.000000e+00
br i1 %55, label %56, label %61
56: ; preds = %49
%57 = fcmp ogt double %54, 0xBC9CD2B297D889BC
br i1 %57, label %63, label %58
58: ; preds = %56
%59 = load i32, i32* @stderr
%60 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i32 %4, double %54)
br label %159
61: ; preds = %49
%62 = call double @sqrt(double %54)
br label %63
63: ; preds = %56, %61
%64 = phi double [ %62, %61 ], [ 0.000000e+00, %56 ]
%65 = fmul double %52, -5.000000e-01
%66 = fneg double %64
%67 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %8, i64 0, i64 0, i64 0
%68 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%69 = load double, double* %67
%70 = call double @llvm.fmuladd.f64(double %69, double 0.000000e+00, double 0.000000e+00)
%71 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %8, i64 0, i64 0, i64 1
%72 = load double, double* %71
%73 = call double @llvm.fmuladd.f64(double %72, double %52, double %70)
%74 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %8, i64 0, i64 0, i64 2
%75 = load double, double* %74
%76 = call double @llvm.fmuladd.f64(double %75, double 0.000000e+00, double %73)
store double %76, double* %68
%77 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 1, i64 0
%78 = call double @llvm.fmuladd.f64(double %69, double %64, double 0.000000e+00)
%79 = call double @llvm.fmuladd.f64(double %72, double %65, double %78)
%80 = call double @llvm.fmuladd.f64(double %75, double 0.000000e+00, double %79)
store double %80, double* %77
%81 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 2, i64 0
%82 = call double @llvm.fmuladd.f64(double %69, double %66, double 0.000000e+00)
%83 = call double @llvm.fmuladd.f64(double %72, double %65, double %82)
%84 = call double @llvm.fmuladd.f64(double %75, double 0.000000e+00, double %83)
store double %84, double* %81
%85 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %8, i64 0, i64 1, i64 0
%86 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 1
%87 = load double, double* %85
%88 = call double @llvm.fmuladd.f64(double %87, double 0.000000e+00, double 0.000000e+00)
%89 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %8, i64 0, i64 1, i64 1
%90 = load double, double* %89
%91 = call double @llvm.fmuladd.f64(double %90, double %52, double %88)
%92 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %8, i64 0, i64 1, i64 2
%93 = load double, double* %92
%94 = call double @llvm.fmuladd.f64(double %93, double 0.000000e+00, double %91)
store double %94, double* %86
%95 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 1, i64 1
%96 = call double @llvm.fmuladd.f64(double %87, double %64, double 0.000000e+00)
%97 = call double @llvm.fmuladd.f64(double %90, double %65, double %96)
%98 = call double @llvm.fmuladd.f64(double %93, double 0.000000e+00, double %97)
store double %98, double* %95
%99 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 2, i64 1
%100 = call double @llvm.fmuladd.f64(double %87, double %66, double 0.000000e+00)
%101 = call double @llvm.fmuladd.f64(double %90, double %65, double %100)
%102 = call double @llvm.fmuladd.f64(double %93, double 0.000000e+00, double %101)
store double %102, double* %99
%103 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %8, i64 0, i64 2, i64 0
%104 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 2
%105 = load double, double* %103
%106 = call double @llvm.fmuladd.f64(double %105, double 0.000000e+00, double 0.000000e+00)
%107 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %8, i64 0, i64 2, i64 1
%108 = load double, double* %107
%109 = call double @llvm.fmuladd.f64(double %108, double %52, double %106)
%110 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %8, i64 0, i64 2, i64 2
%111 = load double, double* %110
%112 = call double @llvm.fmuladd.f64(double %111, double 0.000000e+00, double %109)
store double %112, double* %104
%113 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 1, i64 2
%114 = call double @llvm.fmuladd.f64(double %105, double %64, double 0.000000e+00)
%115 = call double @llvm.fmuladd.f64(double %108, double %65, double %114)
%116 = call double @llvm.fmuladd.f64(double %111, double 0.000000e+00, double %115)
store double %116, double* %113
%117 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 2, i64 2
%118 = call double @llvm.fmuladd.f64(double %105, double %66, double 0.000000e+00)
%119 = call double @llvm.fmuladd.f64(double %108, double %65, double %118)
%120 = call double @llvm.fmuladd.f64(double %111, double 0.000000e+00, double %119)
store double %120, double* %117
%121 = load double, double* %1
%122 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%123 = load double, double* %122
%124 = fadd double %121, %123
store double %124, double* %122
%125 = load double, double* %1
%126 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 1, i64 0
%127 = load double, double* %126
%128 = fadd double %125, %127
store double %128, double* %126
%129 = load double, double* %1
%130 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 2, i64 0
%131 = load double, double* %130
%132 = fadd double %129, %131
store double %132, double* %130
%133 = getelementptr inbounds double, double* %1, i64 1
%134 = load double, double* %133
%135 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 1
%136 = load double, double* %135
%137 = fadd double %134, %136
store double %137, double* %135
%138 = load double, double* %133
%139 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 1, i64 1
%140 = load double, double* %139
%141 = fadd double %138, %140
store double %141, double* %139
%142 = load double, double* %133
%143 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 2, i64 1
%144 = load double, double* %143
%145 = fadd double %142, %144
store double %145, double* %143
%146 = getelementptr inbounds double, double* %1, i64 2
%147 = load double, double* %146
%148 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 2
%149 = load double, double* %148
%150 = fadd double %147, %149
store double %150, double* %148
%151 = load double, double* %146
%152 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 1, i64 2
%153 = load double, double* %152
%154 = fadd double %151, %153
store double %154, double* %152
%155 = load double, double* %146
%156 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 2, i64 2
%157 = load double, double* %156
%158 = fadd double %155, %157
store double %158, double* %156
br label %159
159: ; preds = %63, %58, %32, %17
%160 = phi i32 [ -1, %17 ], [ -1, %58 ], [ -1, %32 ], [ 0, %63 ]
ret i32 %160
}