// File: /workspace/github_c_makefile_star2_O3/PoulinV[P]AxiCLASS/build/../source/background.c
// Function: background_find_equality
int background_find_equality(
                             struct precision *ppr,
                             struct background *pba
                             ) {

  double Omega_m_over_Omega_r=0.;
  int index_tau_minus = 0;
  int index_tau_plus = pba->bt_size-1;
  int index_tau_mid = 0;
  double tau_minus,tau_plus,tau_mid=0.;
  double * pvecback;

  /* first bracket the right tau value between two consecutive indices in the table */

  while ((index_tau_plus - index_tau_minus) > 1) {

    index_tau_mid = (int)(0.5*(index_tau_plus+index_tau_minus));

    Omega_m_over_Omega_r = pba->background_table[index_tau_mid*pba->bg_size+pba->index_bg_Omega_m]
      /pba->background_table[index_tau_mid*pba->bg_size+pba->index_bg_Omega_r];

    if (Omega_m_over_Omega_r > 1)
      index_tau_plus = index_tau_mid;
    else
      index_tau_minus = index_tau_mid;

  }

  /* then get a better estimate within this range */

  tau_minus = pba->tau_table[index_tau_minus];
  tau_plus =  pba->tau_table[index_tau_plus];

  class_alloc(pvecback,pba->bg_size*sizeof(double),pba->error_message);

  while ((tau_plus - tau_minus) > ppr->tol_tau_eq) {

    tau_mid = 0.5*(tau_plus+tau_minus);

    class_call(background_at_tau(pba,tau_mid,long_info,inter_closeby,&index_tau_minus,pvecback),
               pba->error_message,
               pba->error_message);

    Omega_m_over_Omega_r = pvecback[pba->index_bg_Omega_m]/pvecback[pba->index_bg_Omega_r];

    if (Omega_m_over_Omega_r > 1)
      tau_plus = tau_mid;
    else
      tau_minus = tau_mid;

  }

  pba->a_eq = pvecback[pba->index_bg_a];
  pba->H_eq = pvecback[pba->index_bg_H];
  pba->z_eq = 1./pba->a_eq -1.;
  pba->tau_eq = tau_mid;

  if (pba->background_verbose > 0) {
    printf(" -> radiation/matter equality at z = %f\n",pba->z_eq);
    printf("    corresponding to conformal time = %f Mpc\n",pba->tau_eq);
  }

  free(pvecback);

  return _SUCCESS_;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x830, %rsp            # imm = 0x830
movq %rsi, %rbx
movq %rdi, %r14
movl 0x440(%rsi), %ecx
leal -0x1(%rcx), %eax
cmpl $0x2, %ecx
jle 0x616c9
movq 0x460(%rbx), %rdx
movl 0x43c(%rbx), %ebp
movslq 0x40c(%rbx), %rsi
movslq 0x404(%rbx), %rdi
xorl %ecx, %ecx
movsd 0x8d65d(%rip), %xmm0    # 0xeecd0
movsd 0x8cbe5(%rip), %xmm1    # 0xee260
leal (%rcx,%rax), %r8d
xorps %xmm2, %xmm2
cvtsi2sd %r8d, %xmm2
mulsd %xmm0, %xmm2
cvttsd2si %xmm2, %r8d
movl %ebp, %r9d
imull %r8d, %r9d
movslq %r9d, %r9
leaq (%r9,%rsi), %r10
movsd (%rdx,%r10,8), %xmm2
addq %rdi, %r9
divsd (%rdx,%r9,8), %xmm2
ucomisd %xmm1, %xmm2
ja 0x616b8
movl %r8d, %ecx
jmp 0x616bb
movl %r8d, %eax
movl %eax, %r8d
subl %ecx, %r8d
cmpl $0x1, %r8d
jg 0x6167b
jmp 0x616d1
movl 0x43c(%rbx), %ebp
xorl %ecx, %ecx
movl %ecx, 0xc(%rsp)
movq 0x450(%rbx), %rdx
movslq %ecx, %rcx
movsd (%rdx,%rcx,8), %xmm0
movaps %xmm0, 0x10(%rsp)
cltq
movsd (%rdx,%rax,8), %xmm0
movsd %xmm0, (%rsp)
movslq %ebp, %rdi
shlq $0x3, %rdi
callq 0x8460
testq %rax, %rax
je 0x61867
movq %rax, %r15
movsd (%rsp), %xmm1
movapd %xmm1, %xmm0
movapd 0x10(%rsp), %xmm3
subsd %xmm3, %xmm0
xorpd %xmm4, %xmm4
ucomisd 0x58(%r14), %xmm0
jbe 0x617dc
movapd %xmm1, %xmm0
leaq 0xc(%rsp), %r12
movapd %xmm3, 0x10(%rsp)
movsd %xmm0, (%rsp)
addsd %xmm0, %xmm3
mulsd 0x8d580(%rip), %xmm3    # 0xeecd0
movq %rbx, %rdi
movapd %xmm3, 0x20(%rsp)
movapd %xmm3, %xmm0
movl $0x2, %esi
movl $0x1, %edx
movq %r12, %rcx
movq %r15, %r8
callq 0x5c63f
testl %eax, %eax
jne 0x618a8
movslq 0x40c(%rbx), %rax
movsd (%r15,%rax,8), %xmm1
movslq 0x404(%rbx), %rax
divsd (%r15,%rax,8), %xmm1
movsd 0x8cac4(%rip), %xmm2    # 0xee260
ucomisd %xmm2, %xmm1
movapd 0x20(%rsp), %xmm4
movapd %xmm4, %xmm0
ja 0x617b1
movsd (%rsp), %xmm0
cmpltsd %xmm1, %xmm2
movapd 0x10(%rsp), %xmm3
andpd %xmm2, %xmm3
andnpd %xmm4, %xmm2
orpd %xmm2, %xmm3
movapd %xmm0, %xmm1
subsd %xmm3, %xmm1
ucomisd 0x58(%r14), %xmm1
ja 0x61739
movslq 0x380(%rbx), %rax
movsd (%r15,%rax,8), %xmm1
movsd %xmm1, 0x360(%rbx)
movslq 0x384(%rbx), %rax
movsd (%r15,%rax,8), %xmm0
movsd %xmm0, 0x368(%rbx)
movsd 0x8ca52(%rip), %xmm0    # 0xee260
divsd %xmm1, %xmm0
addsd 0x8cfce(%rip), %xmm0    # 0xee7e8
movsd %xmm0, 0x370(%rbx)
movsd %xmm4, 0x378(%rbx)
cmpw $0x0, 0xd1a(%rbx)
jle 0x61858
leaq 0xab619(%rip), %rdi     # 0x10ce54
movb $0x1, %al
callq 0x8030
movsd 0x378(%rbx), %xmm0
leaq 0xab62c(%rip), %rdi     # 0x10ce7d
movb $0x1, %al
callq 0x8030
movq %r15, %rdi
callq 0x8410
xorl %eax, %eax
jmp 0x618f4
shll $0x3, %ebp
leaq 0x8c793(%rip), %rsi     # 0xee004
leaq 0xb3a1a(%rip), %rdx     # 0x115292
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0xd1c, %rbx            # imm = 0xD1C
leaq 0x8c79d(%rip), %rsi     # 0xee034
leaq 0xab54c(%rip), %rdx     # 0x10cdea
movq %rbx, %rdi
movl $0xb74, %ecx            # imm = 0xB74
jmp 0x618e5
addq $0xd1c, %rbx            # imm = 0xD1C
leaq 0x8cb3a(%rip), %rsi     # 0xee3f0
leaq 0xab546(%rip), %rdx     # 0x10ce03
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0x8c75e(%rip), %rsi     # 0xee034
leaq 0xab50d(%rip), %rdx     # 0x10cdea
movq %rbx, %rdi
movl $0xb7c, %ecx            # imm = 0xB7C
movq %r14, %r8
xorl %eax, %eax
callq 0x30af0
movl $0x1, %eax
addq $0x830, %rsp            # imm = 0x830
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq