// File: /workspace/github_c_makefile_star2_O0/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:
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 0x6ccc0
cmpl $0x1, %eax
jne 0x6c8e9
leaq 0x2030(%rsp), %rdi
movq 0x2878(%rsp), %rcx
leaq 0x14ab37(%rip), %rsi    # 0x1b73d8
leaq 0x14fc2f(%rip), %rdx    # 0x1bc4d7
movb $0x0, %al
callq 0x5b9c0
movq 0x2878(%rsp), %rdi
leaq 0x2030(%rsp), %r8
leaq 0x14a76e(%rip), %rsi    # 0x1b7034
leaq 0x14fc34(%rip), %rdx    # 0x1bc501
movl $0x39e, %ecx            # imm = 0x39E
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x28a4(%rsp)
jmp 0x6ccb1
movsd 0x2870(%rsp), %xmm0
movq 0x2880(%rsp), %rdi
movq 0x2878(%rsp), %rdx
leaq 0x2860(%rsp), %rsi
callq 0x6edb0
cmpl $0x1, %eax
jne 0x6c973
leaq 0x1830(%rsp), %rdi
movq 0x2878(%rsp), %rcx
leaq 0x14aaad(%rip), %rsi    # 0x1b73d8
leaq 0x14fbdf(%rip), %rdx    # 0x1bc511
movb $0x0, %al
callq 0x5b9c0
movq 0x2878(%rsp), %rdi
leaq 0x1830(%rsp), %r8
leaq 0x14a6e4(%rip), %rsi    # 0x1b7034
leaq 0x14fbaa(%rip), %rdx    # 0x1bc501
movl $0x3a2, %ecx            # imm = 0x3A2
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x28a4(%rsp)
jmp 0x6ccb1
movq 0x2890(%rsp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movsd 0x14b2c6(%rip), %xmm0   # 0x1b7c50
mulsd 0x2860(%rsp), %xmm0
mulsd 0x2850(%rsp), %xmm0
movsd %xmm0, 0x2848(%rsp)
movl $0x1, 0x2844(%rsp)
cmpl $0xf, 0x2844(%rsp)
jg 0x6cb5e
movsd 0x2870(%rsp), %xmm0
subsd 0x2848(%rsp), %xmm0
movsd %xmm0, 0x2868(%rsp)
movl $0x1, 0x2840(%rsp)
cmpl $0x3, 0x2840(%rsp)
jg 0x6cb07
movsd 0x2868(%rsp), %xmm0
movq 0x2880(%rsp), %rdi
movq 0x2878(%rsp), %rdx
leaq 0x2858(%rsp), %rsi
callq 0x6edb0
movl %eax, 0x283c(%rsp)
movq 0x2890(%rsp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
cmpl $0x0, 0x283c(%rsp)
jne 0x6ca3d
jmp 0x6cb07
cmpl $0x3, 0x2840(%rsp)
jge 0x6ca7e
movsd 0x14b239(%rip), %xmm0   # 0x1b7c88
mulsd 0x2848(%rsp), %xmm0
movsd %xmm0, 0x2848(%rsp)
movsd 0x2870(%rsp), %xmm0
subsd 0x2848(%rsp), %xmm0
movsd %xmm0, 0x2868(%rsp)
jmp 0x6caed
leaq 0x1030(%rsp), %rdi
movq 0x2878(%rsp), %rsi
movb $0x0, %al
callq 0x5b9c0
leaq 0x830(%rsp), %rdi
leaq 0x1030(%rsp), %rdx
leaq 0x14aac1(%rip), %rsi    # 0x1b756d
movb $0x0, %al
callq 0x5b9c0
movq 0x2878(%rsp), %rdi
leaq 0x830(%rsp), %r8
leaq 0x14a56a(%rip), %rsi    # 0x1b7034
leaq 0x14fa30(%rip), %rdx    # 0x1bc501
movl $0x3b7, %ecx            # imm = 0x3B7
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x28a4(%rsp)
jmp 0x6ccb1
jmp 0x6caef
jmp 0x6caf1
movl 0x2840(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2840(%rsp)
jmp 0x6c9e4
movsd 0x2860(%rsp), %xmm1
mulsd 0x2858(%rsp), %xmm1
xorps %xmm0, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x6cb24
jmp 0x6cb5e
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 0x6c9b0
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 0x14a695(%rip), %xmm0   # 0x1b7230
pand %xmm0, %xmm1
movsd 0x2868(%rsp), %xmm0
movaps 0x14a681(%rip), %xmm2   # 0x1b7230
pand %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x6cbd5
movsd 0x2868(%rsp), %xmm0
movaps 0x14a667(%rip), %xmm1   # 0x1b7230
pand %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
jmp 0x6cbef
movsd 0x2870(%rsp), %xmm0
movaps 0x14a64b(%rip), %xmm1   # 0x1b7230
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 0x217e(%rip), %rdi      # 0x6edb0
leaq 0x2860(%rsp), %rdx
leaq 0x2858(%rsp), %rcx
movq %rax, (%rsp)
callq 0x6ee80
cmpl $0x1, %eax
jne 0x6cca6
leaq 0x30(%rsp), %rdi
movq 0x2878(%rsp), %rcx
leaq 0x14a774(%rip), %rsi    # 0x1b73d8
leaq 0x14f8cf(%rip), %rdx    # 0x1bc53a
movb $0x0, %al
callq 0x5b9c0
movq 0x2878(%rsp), %rdi
leaq 0x30(%rsp), %r8
leaq 0x14a3ae(%rip), %rsi    # 0x1b7034
leaq 0x14f874(%rip), %rdx    # 0x1bc501
movl $0x3cd, %ecx            # imm = 0x3CD
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x28a4(%rsp)
jmp 0x6ccb1
movl $0x0, 0x28a4(%rsp)
movl 0x28a4(%rsp), %eax
addq $0x28a8, %rsp           # imm = 0x28A8
retq