// File: /workspace/github_c_makefile_star2_O2/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 %r13
pushq %r12
pushq %rbx
subq $0x838, %rsp            # imm = 0x838
movq %rsi, %rbx
movq %rdi, %r14
movl 0x440(%rsi), %eax
decl %eax
xorl %ecx, %ecx
movl %eax, %edx
subl %ecx, %edx
cmpl $0x2, %edx
jl 0x5d68b
leal (%rcx,%rax), %edx
cvtsi2sd %edx, %xmm0
mulsd 0x88672(%rip), %xmm0    # 0xe5cb0
cvttsd2si %xmm0, %edx
movq 0x460(%rbx), %rsi
movslq 0x43c(%rbx), %rdi
movslq %edx, %r8
imulq %rdi, %r8
movslq 0x40c(%rbx), %rdi
addq %r8, %rdi
movsd (%rsi,%rdi,8), %xmm0
movslq 0x404(%rbx), %rdi
movslq %r8d, %r8
addq %rdi, %r8
divsd (%rsi,%r8,8), %xmm0
ucomisd 0x87bdf(%rip), %xmm0    # 0xe5260
ja 0x5d687
movl %edx, %ecx
jmp 0x5d626
movl %edx, %eax
jmp 0x5d626
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 0x43c(%rbx), %r12
leaq (,%r12,8), %rdi
callq 0x8490
testq %rax, %rax
je 0x5d794
movq %rax, %r15
xorps %xmm3, %xmm3
pushq $0x2
popq %r12
pushq $0x1
popq %rbp
leaq 0xc(%rsp), %r13
movapd 0x10(%rsp), %xmm1
movsd (%rsp), %xmm2
movapd %xmm2, %xmm0
subsd %xmm1, %xmm0
ucomisd 0x58(%r14), %xmm0
movsd 0x885b1(%rip), %xmm0    # 0xe5cb0
jbe 0x5d7e7
movapd %xmm1, 0x10(%rsp)
movsd %xmm2, (%rsp)
addsd %xmm2, %xmm1
mulsd %xmm0, %xmm1
movq %rbx, %rdi
movapd %xmm1, 0x20(%rsp)
movapd %xmm1, %xmm0
movl %r12d, %esi
movl %ebp, %edx
movq %r13, %rcx
movq %r15, %r8
callq 0x5887d
testl %eax, %eax
jne 0x5d86f
movslq 0x40c(%rbx), %rax
movsd (%r15,%rax,8), %xmm1
movslq 0x404(%rbx), %rax
divsd (%r15,%rax,8), %xmm1
movsd 0x87b01(%rip), %xmm2    # 0xe5260
ucomisd %xmm2, %xmm1
movapd 0x20(%rsp), %xmm3
movapd %xmm3, %xmm0
ja 0x5d774
movsd (%rsp), %xmm0
cmpltsd %xmm1, %xmm2
movapd 0x10(%rsp), %xmm1
andpd %xmm2, %xmm1
andnpd %xmm3, %xmm2
orpd %xmm2, %xmm1
movapd %xmm0, %xmm2
jmp 0x5d6e9
shll $0x3, %r12d
leaq 0x87865(%rip), %rsi     # 0xe5004
leaq 0xae98c(%rip), %rdx     # 0x10c132
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %r12d, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0xd1c, %rbx            # imm = 0xD1C
leaq 0x8786e(%rip), %rsi     # 0xe5034
leaq 0xa64dd(%rip), %rdx     # 0x103caa
movq %rbx, %rdi
movl $0xb74, %ecx            # imm = 0xB74
movq %r14, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %rbp
jmp 0x5d8b6
movslq 0x380(%rbx), %rax
movsd (%r15,%rax,8), %xmm2
movsd %xmm2, 0x360(%rbx)
movslq 0x384(%rbx), %rax
movsd (%r15,%rax,8), %xmm1
movsd %xmm1, 0x368(%rbx)
movsd 0x87a47(%rip), %xmm0    # 0xe5260
divsd %xmm2, %xmm0
addsd 0x87fc3(%rip), %xmm0    # 0xe57e8
movsd %xmm0, 0x370(%rbx)
movsd %xmm3, 0x378(%rbx)
cmpw $0x0, 0xd1a(%rbx)
jle 0x5d863
leaq 0xa64ce(%rip), %rdi     # 0x103d14
movb $0x1, %al
callq 0x8030
movsd 0x378(%rbx), %xmm0
leaq 0xa64e1(%rip), %rdi     # 0x103d3d
movb $0x1, %al
callq 0x8030
movq %r15, %rdi
callq 0x8430
xorl %ebp, %ebp
jmp 0x5d8b6
addq $0xd1c, %rbx            # imm = 0xD1C
leaq 0x87b73(%rip), %rsi     # 0xe53f0
leaq 0xa643f(%rip), %rdx     # 0x103cc3
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x87797(%rip), %rsi     # 0xe5034
leaq 0xa6406(%rip), %rdx     # 0x103caa
movq %rbx, %rdi
movl $0xb7c, %ecx            # imm = 0xB7C
movq %r14, %r8
xorl %eax, %eax
callq 0x2e014
movl %ebp, %eax
addq $0x838, %rsp            # imm = 0x838
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq