#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*/ CalcQuarticCoeffs(double const **, double const **,
                                     int const, double *);
double CoordsInnerProd(double const **, int const);
double QCProot(double *, double, int);
double QuatCharPoly(const double **coords1, const double **coords2,
                    const int len, double *coeff) {
  double innerprod;
  double lambdamax;
  innerprod = CoordsInnerProd(coords1, len) + CoordsInnerProd(coords2, len);
  CalcQuarticCoeffs(coords1, coords2, len, coeff);
  lambdamax = QCProot(coeff, 0.5 * innerprod, 1e-6);
  return (innerprod - (2.0 * lambdamax));
}


x86 assembly (clang, -O0):
<QuatCharPoly>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <CoordsInnerProd@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <CoordsInnerProd@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
call   1050 <CalcQuarticCoeffs@plt>
mov    -0x20(%rbp),%rdi
movsd  0xe6b(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
xor    %esi,%esi
call   1040 <QCProot@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
addsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<QuatCharPoly>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %edx,%ebp
mov    %rsi,%r15
mov    %rdi,%rbx
mov    %edx,%esi
call   1030 <CoordsInnerProd@plt>
movsd  %xmm0,(%rsp)
mov    %r15,%rdi
mov    %ebp,%esi
call   1030 <CoordsInnerProd@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
mov    %r14,%rcx
call   1050 <CalcQuarticCoeffs@plt>
movsd  0xe86(%rip),%xmm0
mulsd  (%rsp),%xmm0
mov    %r14,%rdi
xor    %esi,%esi
call   1040 <QCProot@plt>
addsd  %xmm0,%xmm0
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @QuatCharPoly(double** %0, double** %1, i32 %2, double* %3) {
%5 = alloca double**
%6 = alloca double**
%7 = alloca i32
%8 = alloca double*
%9 = alloca double
%10 = alloca double
store double** %0, double*** %5
store double** %1, double*** %6
store i32 %2, i32* %7
store double* %3, double** %8
%11 = load double**, double*** %5
%12 = load i32, i32* %7
%13 = call double @CoordsInnerProd(double** %11, i32 %12)
%14 = load double**, double*** %6
%15 = load i32, i32* %7
%16 = call double @CoordsInnerProd(double** %14, i32 %15)
%17 = fadd double %13, %16
store double %17, double* %9
%18 = load double**, double*** %5
%19 = load double**, double*** %6
%20 = load i32, i32* %7
%21 = load double*, double** %8
%22 = call i32 @CalcQuarticCoeffs(double** %18, double** %19, i32 %20, double* %21)
%23 = load double*, double** %8
%24 = load double, double* %9
%25 = fmul double 5.000000e-01, %24
%26 = call double @QCProot(double* %23, double %25, i32 0)
store double %26, double* %10
%27 = load double, double* %9
%28 = load double, double* %10
%29 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %28, double %27)
ret double %29
}

LLVM IR (-O2):
define double @QuatCharPoly(double** %0, double** %1, i32 %2, double* %3) {
%5 = tail call double @CoordsInnerProd(double** %0, i32 %2)
%6 = tail call double @CoordsInnerProd(double** %1, i32 %2)
%7 = fadd double %5, %6
%8 = tail call i32 @CalcQuarticCoeffs(double** %0, double** %1, i32 %2, double* %3)
%9 = fmul double %7, 5.000000e-01
%10 = tail call double @QCProot(double* %3, double %9, i32 0)
%11 = tail call double @llvm.fmuladd.f64(double %10, double -2.000000e+00, double %7)
ret double %11
}