#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 */
double DBL_MAX;
double bingham_F_lookup_3d(double *);
int /*<<< orphan*/ bingham_dF_lookup_3d(double *, double *);
scalar_t__ isnan(double);
double bingham_dY_params_3d_slow_eval(double *err, double *Z, double *dY) {
  double F = bingham_F_lookup_3d(Z);
  double dF[3];
  bingham_dF_lookup_3d(dF, Z);
  err[0] = dF[0] / F - dY[0];
  err[1] = dF[1] / F - dY[1];
  err[2] = dF[2] / F - dY[2];
  double g = err[0] * err[0] + err[1] * err[1] + err[2] * err[2];
  return isnan(g) ? DBL_MAX : g;
}


x86 assembly (clang, -O0):
<bingham_dY_params_3d_slow_eval>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <bingham_F_lookup_3d@plt>
movsd  %xmm0,-0x20(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <bingham_dF_lookup_3d@plt>
movsd  -0x40(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
mov    -0x18(%rbp),%rax
subsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x38(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
mov    -0x18(%rbp),%rax
subsd  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x30(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
mov    -0x18(%rbp),%rax
subsd  0x10(%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1040 <isnan@plt>
cmp    $0x0,%rax
je     1223 <bingham_dY_params_3d_slow_eval+0xf3>
mov    0x2dcb(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    122d <bingham_dY_params_3d_slow_eval+0xfd>
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bingham_dY_params_3d_slow_eval>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
mov    %rsi,%rdi
call   1030 <bingham_F_lookup_3d@plt>
movsd  %xmm0,0x8(%rsp)
lea    0x10(%rsp),%rdi
mov    %rbx,%rsi
call   1050 <bingham_dF_lookup_3d@plt>
movsd  0x10(%rsp),%xmm3
movsd  0x8(%rsp),%xmm2
divsd  %xmm2,%xmm3
subsd  (%r14),%xmm3
movsd  %xmm3,(%r15)
movsd  0x18(%rsp),%xmm1
divsd  %xmm2,%xmm1
subsd  0x8(%r14),%xmm1
movsd  %xmm1,0x8(%r15)
movsd  0x20(%rsp),%xmm0
divsd  %xmm2,%xmm0
subsd  0x10(%r14),%xmm0
movsd  %xmm0,0x10(%r15)
mulsd  %xmm1,%xmm1
mulsd  %xmm3,%xmm3
addsd  %xmm1,%xmm3
mulsd  %xmm0,%xmm0
addsd  %xmm3,%xmm0
movsd  %xmm0,0x8(%rsp)
call   1040 <isnan@plt>
movsd  0x8(%rsp),%xmm0
test   %rax,%rax
je     11d8 <bingham_dY_params_3d_slow_eval+0xa8>
mov    0x2e0c(%rip),%rax
movsd  (%rax),%xmm0
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@DBL_MAX = global double 0.000000e+00
define double @bingham_dY_params_3d_slow_eval(double* %0, double* %1, double* %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca double*
%7 = alloca double
%8 = alloca [3 x double]
%9 = alloca double
store double* %0, double** %4
store double* %1, double** %5
store double* %2, double** %6
%10 = load double*, double** %5
%11 = call double @bingham_F_lookup_3d(double* %10)
store double %11, double* %7
%12 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 0
%13 = load double*, double** %5
%14 = call i32 @bingham_dF_lookup_3d(double* %12, double* %13)
%15 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 0
%16 = load double, double* %15
%17 = load double, double* %7
%18 = fdiv double %16, %17
%19 = load double*, double** %6
%20 = getelementptr inbounds double, double* %19, i64 0
%21 = load double, double* %20
%22 = fsub double %18, %21
%23 = load double*, double** %4
%24 = getelementptr inbounds double, double* %23, i64 0
store double %22, double* %24
%25 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 1
%26 = load double, double* %25
%27 = load double, double* %7
%28 = fdiv double %26, %27
%29 = load double*, double** %6
%30 = getelementptr inbounds double, double* %29, i64 1
%31 = load double, double* %30
%32 = fsub double %28, %31
%33 = load double*, double** %4
%34 = getelementptr inbounds double, double* %33, i64 1
store double %32, double* %34
%35 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 2
%36 = load double, double* %35
%37 = load double, double* %7
%38 = fdiv double %36, %37
%39 = load double*, double** %6
%40 = getelementptr inbounds double, double* %39, i64 2
%41 = load double, double* %40
%42 = fsub double %38, %41
%43 = load double*, double** %4
%44 = getelementptr inbounds double, double* %43, i64 2
store double %42, double* %44
%45 = load double*, double** %4
%46 = getelementptr inbounds double, double* %45, i64 0
%47 = load double, double* %46
%48 = load double*, double** %4
%49 = getelementptr inbounds double, double* %48, i64 0
%50 = load double, double* %49
%51 = load double*, double** %4
%52 = getelementptr inbounds double, double* %51, i64 1
%53 = load double, double* %52
%54 = load double*, double** %4
%55 = getelementptr inbounds double, double* %54, i64 1
%56 = load double, double* %55
%57 = fmul double %53, %56
%58 = call double @llvm.fmuladd.f64(double %47, double %50, double %57)
%59 = load double*, double** %4
%60 = getelementptr inbounds double, double* %59, i64 2
%61 = load double, double* %60
%62 = load double*, double** %4
%63 = getelementptr inbounds double, double* %62, i64 2
%64 = load double, double* %63
%65 = call double @llvm.fmuladd.f64(double %61, double %64, double %58)
store double %65, double* %9
%66 = load double, double* %9
%67 = call i64 @isnan(double %66)
%68 = icmp ne i64 %67, 0
br i1 %68, label %69, label %71
69: ; preds = %3
%70 = load double, double* @DBL_MAX
br label %73
71: ; preds = %3
%72 = load double, double* %9
br label %73
73: ; preds = %71, %69
%74 = phi double [ %70, %69 ], [ %72, %71 ]
ret double %74
}

LLVM IR (-O2):
@DBL_MAX = global double 0.000000e+00
define double @bingham_dY_params_3d_slow_eval(double* nocapture %0, double* %1, double* nocapture %2) {
%4 = alloca [3 x double]
%5 = tail call double @bingham_F_lookup_3d(double* %1)
%6 = bitcast [3 x double]* %4 to i8*
%7 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 0
%8 = call i32 @bingham_dF_lookup_3d(double* %7, double* %1)
%9 = load double, double* %7
%10 = fdiv double %9, %5
%11 = load double, double* %2
%12 = fsub double %10, %11
store double %12, double* %0
%13 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 1
%14 = load double, double* %13
%15 = fdiv double %14, %5
%16 = getelementptr inbounds double, double* %2, i64 1
%17 = load double, double* %16
%18 = fsub double %15, %17
%19 = getelementptr inbounds double, double* %0, i64 1
store double %18, double* %19
%20 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 2
%21 = load double, double* %20
%22 = fdiv double %21, %5
%23 = getelementptr inbounds double, double* %2, i64 2
%24 = load double, double* %23
%25 = fsub double %22, %24
%26 = getelementptr inbounds double, double* %0, i64 2
store double %25, double* %26
%27 = fmul double %18, %18
%28 = call double @llvm.fmuladd.f64(double %12, double %12, double %27)
%29 = call double @llvm.fmuladd.f64(double %25, double %25, double %28)
%30 = call i64 @isnan(double %29)
%31 = icmp eq i64 %30, 0
%32 = load double, double* @DBL_MAX
%33 = select i1 %31, double %29, double %32
ret double %33
}