// File: /workspace/github_c_makefile_star2_O0/PoulinV[P]AxiCLASS/build/../source/input.c
// Function: input_find_root
int input_find_root(double *xzero,
                    int *fevals,
                    double tol_x_rel,
                    struct fzerofun_workspace *pfzw,
                    ErrorMsg errmsg){

  /** Summary: */

  /** Define local variables */
  double x1, x2, f1, f2, dxdy, dx;
  int iter, iter2;
  int return_function;

  /** Fisrt we do our guess */
  class_call(input_get_guess(&x1, &dxdy, pfzw, errmsg),
             errmsg,
             errmsg);

  class_call(input_fzerofun_1d(x1, pfzw, &f1, errmsg),
             errmsg,
             errmsg);

  (*fevals)++;
  dx = 1.5*f1*dxdy;

  /** Then we do a linear hunt for the boundaries */
  /* Try fifteen times to go above and below the root (i.e. where shooting succeeds) */
  for (iter=1; iter<=150; iter++){ //vp:default iter max is 15. We increase it to a large number to make sure shooting does not fail for axion.
    x2 = x1 - dx;
    /* Try three times to get a 'reasonable' value, i.e. no CLASS error */
    for (iter2=1; iter2 <= 3; iter2++) {
      return_function = input_fzerofun_1d(x2, pfzw, &f2, errmsg);
      (*fevals)++;
      if (return_function ==_SUCCESS_) {
        break;
      }
      else if (iter2 < 3) {
        dx*=0.5;
        x2 = x1-dx;
      }
      else {
        class_stop(errmsg,errmsg);
      }
    }
    if (f1*f2<0.0){
      /* Root has been bracketed */
      break;
    }
    x1 = x2;
    f1 = f2;
  }
  // printf("here x1 %e x2 %e f1 %e f2 %e!!\n",x1,x2,f1,f2);
  /** Find root using Ridders method (Exchange for bisection if you are old-school) */
  class_call(input_fzero_ridder(input_fzerofun_1d,
                                x1,
                                x2,
                                tol_x_rel*MAX(fabs(x1),fabs(x2)),
                                pfzw,
                                &f1,
                                &f2,
                                xzero,
                                fevals,
                                errmsg),
             errmsg,errmsg);
   // printf("here xzero %e!!\n",xzero);

  return _SUCCESS_;

}

// Assembly:
subq $0x28a8, %rsp           # imm = 0x28A8
movq %rdi, 0x2898(%rsp)
movq %rsi, 0x2890(%rsp)
movsd %xmm0, 0x2888(%rsp)
movq %rdx, 0x2880(%rsp)
movq %rcx, 0x2878(%rsp)
movq 0x2880(%rsp), %rdx
movq 0x2878(%rsp), %rcx
leaq 0x2870(%rsp), %rdi
leaq 0x2850(%rsp), %rsi
callq 0x6e920
cmpl $0x1, %eax
jne 0x6e539
leaq 0x2030(%rsp), %rdi
movq 0x2878(%rsp), %rcx
leaq 0x163ee7(%rip), %rsi    # 0x1d23d8
leaq 0x169ac9(%rip), %rdx    # 0x1d7fc1
movb $0x0, %al
callq 0x5b9c0
movq 0x2878(%rsp), %rdi
leaq 0x2030(%rsp), %r8
leaq 0x163b1e(%rip), %rsi    # 0x1d2034
leaq 0x169ace(%rip), %rdx    # 0x1d7feb
movl $0x4c4, %ecx            # imm = 0x4C4
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x28a4(%rsp)
jmp 0x6e904
movsd 0x2870(%rsp), %xmm0
movq 0x2880(%rsp), %rdi
movq 0x2878(%rsp), %rdx
leaq 0x2860(%rsp), %rsi
callq 0x72620
cmpl $0x1, %eax
jne 0x6e5c3
leaq 0x1830(%rsp), %rdi
movq 0x2878(%rsp), %rcx
leaq 0x163e5d(%rip), %rsi    # 0x1d23d8
leaq 0x169a79(%rip), %rdx    # 0x1d7ffb
movb $0x0, %al
callq 0x5b9c0
movq 0x2878(%rsp), %rdi
leaq 0x1830(%rsp), %r8
leaq 0x163a94(%rip), %rsi    # 0x1d2034
leaq 0x169a44(%rip), %rdx    # 0x1d7feb
movl $0x4c8, %ecx            # imm = 0x4C8
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x28a4(%rsp)
jmp 0x6e904
movq 0x2890(%rsp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movsd 0x164676(%rip), %xmm0   # 0x1d2c50
mulsd 0x2860(%rsp), %xmm0
mulsd 0x2850(%rsp), %xmm0
movsd %xmm0, 0x2848(%rsp)
movl $0x1, 0x2844(%rsp)
cmpl $0x96, 0x2844(%rsp)
jg 0x6e7b1
movsd 0x2870(%rsp), %xmm0
subsd 0x2848(%rsp), %xmm0
movsd %xmm0, 0x2868(%rsp)
movl $0x1, 0x2840(%rsp)
cmpl $0x3, 0x2840(%rsp)
jg 0x6e75a
movsd 0x2868(%rsp), %xmm0
movq 0x2880(%rsp), %rdi
movq 0x2878(%rsp), %rdx
leaq 0x2858(%rsp), %rsi
callq 0x72620
movl %eax, 0x283c(%rsp)
movq 0x2890(%rsp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
cmpl $0x0, 0x283c(%rsp)
jne 0x6e690
jmp 0x6e75a
cmpl $0x3, 0x2840(%rsp)
jge 0x6e6d1
movsd 0x1645e6(%rip), %xmm0   # 0x1d2c88
mulsd 0x2848(%rsp), %xmm0
movsd %xmm0, 0x2848(%rsp)
movsd 0x2870(%rsp), %xmm0
subsd 0x2848(%rsp), %xmm0
movsd %xmm0, 0x2868(%rsp)
jmp 0x6e740
leaq 0x1030(%rsp), %rdi
movq 0x2878(%rsp), %rsi
movb $0x0, %al
callq 0x5b9c0
leaq 0x830(%rsp), %rdi
leaq 0x1030(%rsp), %rdx
leaq 0x163e6e(%rip), %rsi    # 0x1d256d
movb $0x0, %al
callq 0x5b9c0
movq 0x2878(%rsp), %rdi
leaq 0x830(%rsp), %r8
leaq 0x163917(%rip), %rsi    # 0x1d2034
leaq 0x1698c7(%rip), %rdx    # 0x1d7feb
movl $0x4dd, %ecx            # imm = 0x4DD
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x28a4(%rsp)
jmp 0x6e904
jmp 0x6e742
jmp 0x6e744
movl 0x2840(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2840(%rsp)
jmp 0x6e637
movsd 0x2860(%rsp), %xmm1
mulsd 0x2858(%rsp), %xmm1
xorps %xmm0, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x6e777
jmp 0x6e7b1
movsd 0x2868(%rsp), %xmm0
movsd %xmm0, 0x2870(%rsp)
movsd 0x2858(%rsp), %xmm0
movsd %xmm0, 0x2860(%rsp)
movl 0x2844(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2844(%rsp)
jmp 0x6e600
movsd 0x2870(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x2868(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x2888(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x2870(%rsp), %xmm1
movaps 0x163a42(%rip), %xmm0   # 0x1d2230
pand %xmm0, %xmm1
movsd 0x2868(%rsp), %xmm0
movaps 0x163a2e(%rip), %xmm2   # 0x1d2230
pand %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x6e828
movsd 0x2868(%rsp), %xmm0
movaps 0x163a14(%rip), %xmm1   # 0x1d2230
pand %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
jmp 0x6e842
movsd 0x2870(%rsp), %xmm0
movaps 0x1639f8(%rip), %xmm1   # 0x1d2230
pand %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x20(%rsp), %xmm1
movsd 0x18(%rsp), %xmm0
movsd 0x28(%rsp), %xmm2
movsd 0x10(%rsp), %xmm3
mulsd %xmm3, %xmm2
movq 0x2880(%rsp), %rsi
movq 0x2898(%rsp), %r8
movq 0x2890(%rsp), %r9
movq 0x2878(%rsp), %rax
leaq 0x3d9b(%rip), %rdi      # 0x72620
leaq 0x2860(%rsp), %rdx
leaq 0x2858(%rsp), %rcx
movq %rax, (%rsp)
callq 0x726f0
cmpl $0x1, %eax
jne 0x6e8f9
leaq 0x30(%rsp), %rdi
movq 0x2878(%rsp), %rcx
leaq 0x163b21(%rip), %rsi    # 0x1d23d8
leaq 0x169766(%rip), %rdx    # 0x1d8024
movb $0x0, %al
callq 0x5b9c0
movq 0x2878(%rsp), %rdi
leaq 0x30(%rsp), %r8
leaq 0x16375b(%rip), %rsi    # 0x1d2034
leaq 0x16970b(%rip), %rdx    # 0x1d7feb
movl $0x4f3, %ecx            # imm = 0x4F3
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x28a4(%rsp)
jmp 0x6e904
movl $0x0, 0x28a4(%rsp)
movl 0x28a4(%rsp), %eax
addq $0x28a8, %rsp           # imm = 0x28A8
retq
nopw %cs:(%rax,%rax)