// File: /workspace/github_c_makefile_star2_O3/lesgourg[P]class_public/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<=15; iter++){
    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;
  }

  /** 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);

  return _SUCCESS_;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1078, %rsp           # imm = 0x1078
movq %rcx, %rbx
movq %rdx, %r12
movsd %xmm0, 0x48(%rsp)
movq %rsi, %r14
movq %rdi, %r15
leaq 0x58(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x3bc25
testl %eax, %eax
je 0x3b9cd
leaq 0xa3a54(%rip), %rsi     # 0xdf3f0
leaq 0xa8e72(%rip), %rdx     # 0xe4815
leaq 0x70(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0xa3678(%rip), %rsi     # 0xdf034
leaq 0xa8e7c(%rip), %rdx     # 0xe483f
movq %rbx, %rdi
movl $0x39e, %ecx            # imm = 0x39E
jmp 0x3ba23
movsd 0x58(%rsp), %xmm0
leaq 0x18(%rsp), %rsi
movapd %xmm0, 0x20(%rsp)
movq %r12, %rdi
movq %rbx, %rdx
callq 0x3cf92
testl %eax, %eax
je 0x3ba44
leaq 0xa39fc(%rip), %rsi     # 0xdf3f0
leaq 0xa8e54(%rip), %rdx     # 0xe484f
leaq 0x70(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0xa3620(%rip), %rsi     # 0xdf034
leaq 0xa8e24(%rip), %rdx     # 0xe483f
movq %rbx, %rdi
movl $0x3a2, %ecx            # imm = 0x3A2
movq %r14, %r8
xorl %eax, %eax
callq 0x30af0
movl $0x1, %eax
addq $0x1078, %rsp           # imm = 0x1078
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, 0x40(%rsp)
incl (%r14)
movsd 0x18(%rsp), %xmm0
movsd 0xa656e(%rip), %xmm1    # 0xe1fc8
movsd %xmm0, 0x30(%rsp)
mulsd %xmm0, %xmm1
mulsd 0x50(%rsp), %xmm1
movl $0x1, %ebp
leaq 0x38(%rsp), %r13
movapd 0x20(%rsp), %xmm0
movapd %xmm0, %xmm3
movapd %xmm0, 0x20(%rsp)
movsd %xmm1, 0x10(%rsp)
subsd %xmm1, %xmm3
movapd %xmm3, 0x60(%rsp)
movapd %xmm3, %xmm0
movq %r12, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x3cf92
incl (%r14)
testl %eax, %eax
je 0x3bafd
movl $0x3, %r15d
movsd 0x10(%rsp), %xmm1
decl %r15d
je 0x3bbd9
mulsd 0xa4206(%rip), %xmm1    # 0xdfcd0
movsd %xmm1, 0x10(%rsp)
movapd 0x20(%rsp), %xmm0
subsd %xmm1, %xmm0
movapd %xmm0, 0x60(%rsp)
movq %r12, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x3cf92
movsd 0x10(%rsp), %xmm1
incl (%r14)
testl %eax, %eax
jne 0x3bab9
jmp 0x3bb03
movsd 0x10(%rsp), %xmm1
movsd 0x38(%rsp), %xmm0
movsd 0x30(%rsp), %xmm3
mulsd %xmm0, %xmm3
xorpd %xmm2, %xmm2
ucomisd %xmm3, %xmm2
movapd 0x60(%rsp), %xmm3
ja 0x3bb44
movsd %xmm0, 0x18(%rsp)
incl %ebp
movsd %xmm0, 0x30(%rsp)
movapd %xmm3, %xmm0
cmpl $0x10, %ebp
jne 0x3ba7e
movapd %xmm3, 0x20(%rsp)
movapd 0xa36f4(%rip), %xmm2    # 0xdf240
movapd 0x20(%rsp), %xmm0
movapd %xmm0, %xmm1
andpd %xmm2, %xmm1
andpd %xmm3, %xmm2
maxsd %xmm1, %xmm2
mulsd 0x48(%rsp), %xmm2
movq %rbx, (%rsp)
leaq 0x141f(%rip), %rdi      # 0x3cf92
leaq 0x18(%rsp), %rdx
leaq 0x38(%rsp), %rcx
movapd %xmm3, %xmm1
movq %r12, %rsi
movq 0x40(%rsp), %r8
movq %r14, %r9
callq 0x3d019
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x1, %ecx
jne 0x3ba32
leaq 0xa384b(%rip), %rsi     # 0xdf3f0
leaq 0xa8ccc(%rip), %rdx     # 0xe4878
leaq 0x70(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0xa346f(%rip), %rsi     # 0xdf034
leaq 0xa8c73(%rip), %rdx     # 0xe483f
movq %rbx, %rdi
movl $0x3cd, %ecx            # imm = 0x3CD
jmp 0x3ba23
leaq 0x70(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x30af0
leaq 0xa3993(%rip), %rsi     # 0xdf585
leaq 0x870(%rsp), %r15
movq %r15, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x30af0
leaq 0xa3426(%rip), %rsi     # 0xdf034
leaq 0xa8c2a(%rip), %rdx     # 0xe483f
movq %rbx, %rdi
movl $0x3b7, %ecx            # imm = 0x3B7
movq %r15, %r8
jmp 0x3ba26