// File: /workspace/github_c_makefile_star2_O2/PoulinV[P]AxiCLASS/build/../tools/hyperspherical.c
// Function: fzero_ridder
int fzero_ridder(double (*func)(double, void *),
                  double x1,
                  double x2,
                  double xtol,
                  void *param,
                  double *Fx1,
                  double *Fx2,
                  double *xzero,
                  int *fevals){
   /**Using Ridders' method, return the root of a function func known to
      lie between x1 and x2. The root, returned as zriddr, will be found to
      an approximate accuracy xtol.
   */
   int j,MAXIT=1000;
    double ans,fh,fl,fm,fnew,s,xh,xl,xm,xnew;
    if ((Fx1!=NULL)&&(Fx2!=NULL)){
      fl = *Fx1;
      fh = *Fx2;
    }
    else{
      fl=(*func)(x1,param);
      fh=(*func)(x2,param);
      *fevals = (*fevals)+2;
    }
    if ((fl > 0.0 && fh < 0.0) || (fl < 0.0 && fh > 0.0)) {
      xl=x1;
      xh=x2;
      ans=-1.11e11;
      for (j=1;j<=MAXIT;j++) {
        xm=0.5*(xl+xh);
        fm=(*func)(xm,param);
        *fevals = (*fevals)+1;
        s=sqrt(fm*fm-fl*fh);
        if (s == 0.0){
          *xzero = ans;
          //printf("Success 1\n");
          return _SUCCESS_;
        }
        xnew=xm+(xm-xl)*((fl >= fh ? 1.0 : -1.0)*fm/s);
        if (fabs(xnew-ans) <= xtol) {
          *xzero = ans;
          return _SUCCESS_;
        }
        ans=xnew;
        fnew=(*func)(ans,param);
        *fevals = (*fevals)+1;
        if (fnew == 0.0){
          *xzero = ans;
          //printf("Success 2, ans=%g\n",ans);
          return _SUCCESS_;
        }
        if (NRSIGN(fm,fnew) != fm) {
          xl=xm;
          fl=fm;
          xh=ans;
          fh=fnew;
        } else if (NRSIGN(fl,fnew) != fl) {
          xh=ans;
          fh=fnew;
        } else if (NRSIGN(fh,fnew) != fh) {
          xl=ans;
          fl=fnew;
        } else return _FAILURE_;
        if (fabs(xh-xl) <= xtol) {
          *xzero = ans;
          //        printf("Success 3\n");
          return _SUCCESS_;
        }
      }
      fprintf(stderr,"zriddr exceed maximum iterations");
      return _FAILURE_;
    }
    else {
      if (fl == 0.0) return x1;
      if (fh == 0.0) return x2;
      fprintf(stderr,"root must be bracketed in zriddr.");
      return _FAILURE_;
    }
    fprintf(stderr,"Failure in Ridder\n");
    return _FAILURE_;
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %r9, %r14
movq %r8, %rbx
movq %rsi, %r15
movsd %xmm2, 0x48(%rsp)
movapd %xmm1, %xmm2
movapd %xmm0, %xmm1
movq %rdi, %r12
testq %rdx, %rdx
sete %al
testq %rcx, %rcx
sete %sil
orb %al, %sil
jne 0x23e1e
movsd (%rdx), %xmm4
movsd (%rcx), %xmm3
jmp 0x23e60
movapd %xmm1, %xmm0
movq %r15, %rdi
movsd %xmm2, 0x8(%rsp)
movsd %xmm1, 0x10(%rsp)
callq *%r12
movapd %xmm0, 0x20(%rsp)
movsd 0x8(%rsp), %xmm0
movq %r15, %rdi
callq *%r12
movapd 0x20(%rsp), %xmm4
movsd 0x10(%rsp), %xmm1
movsd 0x8(%rsp), %xmm2
movapd %xmm0, %xmm3
addl $0x2, (%r14)
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm4
jbe 0x23e70
ucomisd %xmm3, %xmm0
ja 0x23e84
ucomisd %xmm4, %xmm0
jbe 0x240e6
ucomisd %xmm0, %xmm3
jbe 0x240e6
movsd 0xc467c(%rip), %xmm7    # 0xe8508
movl $0x3e9, %r13d           # imm = 0x3E9
pushq $0x1
popq %rbp
decl %r13d
je 0x2411f
movsd %xmm7, 0x30(%rsp)
movsd %xmm2, 0x8(%rsp)
movsd %xmm1, 0x10(%rsp)
addsd %xmm1, %xmm2
mulsd 0xc1df4(%rip), %xmm2    # 0xe5cb0
movsd %xmm2, 0x18(%rsp)
movapd %xmm2, %xmm0
movq %r15, %rdi
movapd %xmm3, 0x50(%rsp)
movapd %xmm4, 0x20(%rsp)
callq *%r12
movapd 0x20(%rsp), %xmm6
movapd 0x50(%rsp), %xmm3
incl (%r14)
movapd %xmm0, %xmm8
movapd %xmm3, %xmm1
mulsd %xmm6, %xmm1
mulsd %xmm0, %xmm0
subsd %xmm1, %xmm0
ucomisd 0xc1354(%rip), %xmm0    # 0xe5258
movapd %xmm8, 0x60(%rsp)
jb 0x23f13
sqrtsd %xmm0, %xmm0
jmp 0x23f2b
callq 0x82d0
movapd 0x60(%rsp), %xmm8
movapd 0x20(%rsp), %xmm6
movapd 0x50(%rsp), %xmm3
movapd 0xc12fd(%rip), %xmm4    # 0xe5230
movapd 0xc1305(%rip), %xmm5    # 0xe5240
ucomisd 0xc1315(%rip), %xmm0    # 0xe5258
movsd 0x18(%rsp), %xmm7
movsd 0x30(%rsp), %xmm9
jne 0x23f58
jnp 0x240df
movapd %xmm7, %xmm1
subsd 0x10(%rsp), %xmm1
movapd %xmm8, %xmm2
xorpd %xmm4, %xmm2
movapd %xmm3, %xmm4
cmplesd %xmm6, %xmm4
movapd %xmm4, %xmm3
andpd %xmm8, %xmm3
andnpd %xmm2, %xmm4
orpd %xmm3, %xmm4
divsd %xmm0, %xmm4
mulsd %xmm1, %xmm4
addsd %xmm7, %xmm4
movapd %xmm4, %xmm0
subsd %xmm9, %xmm0
andpd %xmm5, %xmm0
movsd 0x48(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jae 0x240df
movapd %xmm4, 0x30(%rsp)
movapd %xmm4, %xmm0
movq %r15, %rdi
callq *%r12
incl (%r14)
ucomisd 0xc128f(%rip), %xmm0    # 0xe5258
jne 0x23fd1
jnp 0x240f4
movapd 0x60(%rsp), %xmm9
movapd %xmm9, %xmm1
movapd 0xc125b(%rip), %xmm5    # 0xe5240
andpd %xmm5, %xmm1
jae 0x24036
movapd 0xc123d(%rip), %xmm4    # 0xe5230
xorpd %xmm4, %xmm1
ucomisd %xmm1, %xmm9
movsd 0x8(%rsp), %xmm2
movapd 0x50(%rsp), %xmm3
movapd 0x20(%rsp), %xmm6
movapd 0x30(%rsp), %xmm7
movsd 0x18(%rsp), %xmm8
jne 0x2405e
jp 0x2405e
movapd %xmm6, %xmm1
orpd %xmm4, %xmm1
ucomisd %xmm1, %xmm6
jne 0x2402f
jnp 0x2408e
movapd %xmm6, %xmm9
jmp 0x2407d
ucomisd %xmm9, %xmm1
movsd 0x8(%rsp), %xmm2
movapd 0x50(%rsp), %xmm3
movapd 0x20(%rsp), %xmm4
movapd 0x30(%rsp), %xmm7
movsd 0x18(%rsp), %xmm8
jne 0x2405e
jnp 0x24068
movapd %xmm0, %xmm3
movapd %xmm7, %xmm2
jmp 0x240b2
movapd %xmm4, %xmm1
andpd %xmm5, %xmm1
ucomisd %xmm4, %xmm1
jne 0x24078
jnp 0x24098
movapd %xmm4, %xmm9
movapd %xmm0, %xmm3
movapd %xmm7, %xmm2
movsd 0x10(%rsp), %xmm8
jmp 0x240b2
movapd %xmm3, %xmm1
orpd %xmm4, %xmm1
jmp 0x240a0
movapd %xmm3, %xmm1
andpd %xmm5, %xmm1
ucomisd %xmm3, %xmm1
movapd %xmm0, %xmm9
movapd %xmm7, %xmm8
jne 0x240b2
jnp 0x24100
movapd %xmm2, %xmm0
subsd %xmm8, %xmm0
andpd %xmm5, %xmm0
movsd 0x48(%rsp), %xmm1
ucomisd %xmm0, %xmm1
movapd %xmm9, %xmm4
movapd %xmm8, %xmm1
jb 0x23e95
movsd %xmm7, (%rbx)
jmp 0x240fe
movsd %xmm9, (%rbx)
jmp 0x240fe
ucomisd %xmm0, %xmm4
jne 0x24111
jp 0x24111
cvttsd2si %xmm1, %ebp
jmp 0x24100
movapd 0x30(%rsp), %xmm0
movsd %xmm0, (%rbx)
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
ucomisd %xmm0, %xmm3
jne 0x2413d
jp 0x2413d
cvttsd2si %xmm2, %ebp
jmp 0x24100
movq 0x11ee8a(%rip), %rax    # 0x142fb0
movq (%rax), %rcx
leaq 0xc4fce(%rip), %rdi     # 0xe90fe
pushq $0x20
popq %rsi
pushq $0x1
popq %rdx
callq 0x8700
jmp 0x24100
movq 0x11ee6c(%rip), %rax    # 0x142fb0
movq (%rax), %rcx
leaq 0xc4fd1(%rip), %rdi     # 0xe911f
pushq $0x21
popq %rsi
pushq $0x1
popq %rdx
callq 0x8700
pushq $0x1
popq %rbp
jmp 0x24100