// File: /workspace/github_c_makefile_star2_O2/PoulinV[P]AxiCLASS/build/../source/primordial.c
// Function: primordial_inflation_find_attractor
int primordial_inflation_find_attractor(
                                        struct primordial * ppm,
                                        struct precision * ppr,
                                        double phi_0,
                                        double precision,
                                        double * y,
                                        double * dy,
                                        double * H_0,
                                        double * dphidt_0
                                        ) {

  double V_0,dV_0,ddV_0;
  double V=0.,dV=0.,ddV=0.;
  double a;
  double dphidt,dphidt_0new,dphidt_0old,phi;
  int counter;

  /* we want a series of value of phi' in phi_0, obtained by
     integrating the system from earlier and earlier time. The first
     value iof the series is the slow-roll prediction phi' =
     -V'/3H. The following lines compute this value and initialize relevant quantities. */

  class_call(primordial_inflation_check_potential(ppm,phi_0,&V_0,&dV_0,&ddV_0),
             ppm->error_message,
             ppm->error_message);

  dphidt_0new = -dV_0/3./sqrt((8.*_PI_/3.)*V_0);
  phi = phi_0;
  counter = 0;

  dphidt_0old = dphidt_0new/(precision+2.); // this silly value just
                                            // ensures that the loop
                                            // below will be executed
                                            // at least once.

  /* loop over different values of phi, from which the background
     equations are integrated until phi_0 */

  while (fabs(dphidt_0new/dphidt_0old-1.) >= precision) {

    counter ++;
    class_test(counter >= ppr->primordial_inflation_attractor_maxit,
               ppm->error_message,
               "could not converge after %d iterations: there exists no attractor solution near phi=%g. Potential probably too steep in this region, or precision parameter primordial_inflation_attractor_precision=%g too small",
               counter,
               phi_0,
               precision);

    dphidt_0old = dphidt_0new;

    /* take one step in phi, corresponding roughly to adding one more
       e-fold of inflation */

    phi=phi+dV_0/V_0/16./_PI_;

    /* fix the initial phi' to the slow-roll prediction in that point,
       and initialize other relevant quantities */

    class_call(primordial_inflation_check_potential(ppm,phi,&V,&dV,&ddV),
               ppm->error_message,
               ppm->error_message);

    a = 1.;
    dphidt = -dV/3./sqrt((8.*_PI_/3.)*V);
    y[ppm->index_in_a]=a;
    y[ppm->index_in_phi]=phi;
    y[ppm->index_in_dphi]=a*dphidt;

    /* evolve the background equations until phi_0 is reached */

    class_call(primordial_inflation_evolve_background(ppm,
                                                      ppr,
                                                      y,
                                                      dy,
                                                      _phi_,
                                                      phi_0,
                                                      _TRUE_,
                                                      forward,
                                                      conformal),
               ppm->error_message,
               ppm->error_message);

    /* compute phi' in phi_0, this is the new point in the series
       which convergence we want to check */

    dphidt_0new = y[ppm->index_in_dphi]/y[ppm->index_in_a];

  }

  /* if we have converged and found the attractor, we take the last
     value of phi' in phi_0 to be the correct one for the attractor
     solution */

  *dphidt_0 = dphidt_0new;
  *H_0 = sqrt((8.*_PI_/3.)*(0.5*dphidt_0new*dphidt_0new+V_0));

  if (ppm->primordial_verbose > 1) {
    printf(" (attractor found in phi=%g with phi'=%g, H=%g)\n",phi_0,*dphidt_0,*H_0);
  }

  return _SUCCESS_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1088, %rsp           # imm = 0x1088
movq %r9, %r14
movq %r8, %r15
movq %rcx, %r12
movq %rdx, %r13
movsd %xmm1, 0x20(%rsp)
movq %rsi, %rbp
andq $0x0, 0x40(%rsp)
movq %rdi, %rbx
andq $0x0, 0x38(%rsp)
leaq 0x68(%rsp), %rsi
leaq 0x60(%rsp), %rdx
leaq 0x78(%rsp), %rcx
movsd %xmm0, 0x8(%rsp)
callq 0x96639
testl %eax, %eax
je 0x94f57
addq $0x32a, %rbx            # imm = 0x32A
leaq 0x504ec(%rip), %rsi     # 0xe53f0
leaq 0x7be0f(%rip), %rdx     # 0x110d1a
leaq 0x80(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x5010d(%rip), %rsi     # 0xe5034
leaq 0x7be2e(%rip), %rdx     # 0x110d5c
movq %rbx, %rdi
movl $0x7ab, %ecx            # imm = 0x7AB
movq %r14, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %rbp
movl %ebp, %eax
addq $0x1088, %rsp           # imm = 0x1088
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movsd 0x60(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movapd %xmm0, %xmm5
divsd 0x534d1(%rip), %xmm5    # 0xe8440
movsd 0x68(%rsp), %xmm1
movsd 0x7a3ab(%rip), %xmm0    # 0x10f328
movsd %xmm1, 0x30(%rsp)
mulsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
movq %r14, 0x48(%rsp)
movq %r15, 0x28(%rsp)
jb 0x94fa1
sqrtsd %xmm0, %xmm0
jmp 0x94fb2
movsd %xmm5, 0x10(%rsp)
callq 0x82d0
movsd 0x10(%rsp), %xmm5
movsd 0x8(%rsp), %xmm2
movsd 0x20(%rsp), %xmm1
divsd %xmm0, %xmm5
movsd 0x50d16(%rip), %xmm0    # 0xe5ce0
addsd %xmm1, %xmm0
movapd %xmm5, %xmm4
movsd 0x18(%rsp), %xmm3
divsd 0x30(%rsp), %xmm3
mulsd 0x7a332(%rip), %xmm3    # 0x10f318
divsd 0x52faa(%rip), %xmm3    # 0xe7f98
movsd %xmm3, 0x18(%rsp)
divsd %xmm0, %xmm4
pushq $0x1
popq %r14
movl %r14d, %r15d
movsd %xmm2, 0x10(%rsp)
movapd %xmm5, %xmm3
movapd %xmm5, %xmm2
divsd %xmm4, %xmm2
addsd 0x507cf(%rip), %xmm2    # 0xe57e8
andpd 0x5021f(%rip), %xmm2    # 0xe5240
ucomisd %xmm1, %xmm2
jb 0x95147
cmpl 0x6c8(%rbp), %r15d
jge 0x95186
movsd %xmm3, 0x58(%rsp)
movsd 0x10(%rsp), %xmm0
addsd 0x18(%rsp), %xmm0
movq %rbx, %rdi
movsd %xmm0, 0x10(%rsp)
leaq 0x40(%rsp), %rsi
leaq 0x38(%rsp), %rdx
leaq 0x70(%rsp), %rcx
callq 0x96639
testl %eax, %eax
jne 0x951f0
movsd 0x38(%rsp), %xmm2
divsd 0x533c3(%rip), %xmm2    # 0xe8440
movsd 0x40(%rsp), %xmm0
mulsd 0x7a29d(%rip), %xmm0    # 0x10f328
ucomisd 0x501c5(%rip), %xmm0    # 0xe5258
jb 0x9509b
sqrtsd %xmm0, %xmm0
jmp 0x950ac
movsd %xmm2, 0x50(%rsp)
callq 0x82d0
movsd 0x50(%rsp), %xmm2
movsd 0x8(%rsp), %xmm1
divsd %xmm0, %xmm2
movslq 0x2d0(%rbx), %rax
movabsq $0x3ff0000000000000, %rcx # imm = 0x3FF0000000000000
movq %rcx, (%r13,%rax,8)
movslq 0x2d4(%rbx), %rax
movsd 0x10(%rsp), %xmm0
movsd %xmm0, (%r13,%rax,8)
movslq 0x2d8(%rbx), %rax
movsd %xmm2, (%r13,%rax,8)
movq %rbx, %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %r12, %rcx
movl %r14d, %r8d
movapd %xmm1, %xmm0
movl %r14d, %r9d
pushq $0x0
pushq $0x1
callq 0x953b4
popq %rcx
popq %rdx
testl %eax, %eax
jne 0x95235
movslq 0x2d8(%rbx), %rax
movsd (%r13,%rax,8), %xmm5
movslq 0x2d0(%rbx), %rax
divsd (%r13,%rax,8), %xmm5
incl %r15d
movsd 0x20(%rsp), %xmm1
movsd 0x58(%rsp), %xmm4
jmp 0x95005
movsd 0x50b61(%rip), %xmm0    # 0xe5cb0
mulsd %xmm3, %xmm0
mulsd %xmm3, %xmm0
addsd 0x30(%rsp), %xmm0
mulsd 0x7a1c3(%rip), %xmm0    # 0x10f328
movq 0x48(%rsp), %r14
movsd %xmm3, (%r14)
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x9527a
sqrtsd %xmm0, %xmm2
jmp 0x95283
leaq 0x7bbf3(%rip), %rsi     # 0x110d80
leaq 0x80(%rsp), %r14
movq %r14, %rdi
movl %r15d, %edx
movsd 0x8(%rsp), %xmm0
movb $0x2, %al
callq 0x2e014
leaq 0x4fed3(%rip), %rsi     # 0xe5082
leaq 0x7bc9c(%rip), %rdx     # 0x110e52
leaq 0x880(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
addq $0x32a, %rbx            # imm = 0x32A
leaq 0x4fe5b(%rip), %rsi     # 0xe5034
leaq 0x7bb7c(%rip), %rdx     # 0x110d5c
movq %rbx, %rdi
movl $0x7c1, %ecx            # imm = 0x7C1
movq %r15, %r8
jmp 0x94f39
addq $0x32a, %rbx            # imm = 0x32A
leaq 0x501f2(%rip), %rsi     # 0xe53f0
leaq 0x7bc82(%rip), %rdx     # 0x110e87
leaq 0x80(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x4fe13(%rip), %rsi     # 0xe5034
leaq 0x7bb34(%rip), %rdx     # 0x110d5c
movq %rbx, %rdi
movl $0x7cf, %ecx            # imm = 0x7CF
jmp 0x94f36
addq $0x32a, %rbx            # imm = 0x32A
leaq 0x501ad(%rip), %rsi     # 0xe53f0
leaq 0x7bc77(%rip), %rdx     # 0x110ec1
leaq 0x80(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x4fdce(%rip), %rsi     # 0xe5034
leaq 0x7baef(%rip), %rdx     # 0x110d5c
movq %rbx, %rdi
movl $0x7e3, %ecx            # imm = 0x7E3
jmp 0x94f36
callq 0x82d0
movapd %xmm0, %xmm2
movq 0x28(%rsp), %rax
movsd %xmm2, (%rax)
xorl %ebp, %ebp
cmpw $0x2, 0x328(%rbx)
jl 0x94f43
movsd (%r14), %xmm1
leaq 0x7bc76(%rip), %rdi     # 0x110f1e
movsd 0x8(%rsp), %xmm0
movb $0x3, %al
callq 0x8030
jmp 0x94f43