// File: /workspace/github_c_makefile_star2_O3/PoulinV[P]AxiCLASS/build/../source/background.c
// Function: background_at_z
int background_at_z(
                    struct background *pba,
                    double z,
                    enum vecback_format return_format,
                    enum interpolation_method inter_mode,
                    int * last_index,
                    double * pvecback /* vector with argument pvecback[index_bg] (must be already allocated with a size compatible with return_format) */
                    ) {

  /** Summary: */

  /** - define local variables */

  /* size of output vector, controlled by input parameter return_format */
  int pvecback_size;

  /* log(a) (in fact, given our normalisation conventions, this is log(a/a_0)) */
  double loga;

  /** - check that log(a) = log(1/(1+z)) = -log(1+z) is in the pre-computed range */
  loga = -log(1+z);

  class_test(loga < pba->loga_table[0],
             pba->error_message,
             "out of range: a/a_0 = %e < a_min/a_0 = %e, you should decrease the precision parameter a_ini_over_a_today_default\n",1./(1.+z),exp(pba->loga_table[0]));

  class_test(loga > pba->loga_table[pba->bt_size-1],
             pba->error_message,
             "out of range: a/a_0 = %e > a_max/a_0 = %e\n",1./(1.+z),exp(pba->loga_table[pba->bt_size-1]));

  /** - deduce length of returned vector from format mode */

  if (return_format == normal_info) {
    pvecback_size=pba->bg_size_normal;
  }
  else {
    if (return_format == short_info) {
      pvecback_size=pba->bg_size_short;
    }
    else {
      pvecback_size=pba->bg_size;
    }
  }


  /** - interpolate from pre-computed table with array_interpolate()
      or array_interpolate_growing_closeby() (depending on
      interpolation mode) */

  if (inter_mode == inter_normal) {
    class_call(array_interpolate_spline(
                                        pba->loga_table,
                                        pba->bt_size,
                                        pba->background_table,
                                        pba->d2background_dloga2_table,
                                        pba->bg_size,
                                        loga,
                                        last_index,
                                        pvecback,
                                        pvecback_size,
                                        pba->error_message),
               pba->error_message,
               pba->error_message);
  }
  if (inter_mode == inter_closeby) {
    class_call(array_interpolate_spline_growing_closeby(
                                                        pba->loga_table,
                                                        pba->bt_size,
                                                        pba->background_table,
                                                        pba->d2background_dloga2_table,
                                                        pba->bg_size,
                                                        loga,
                                                        last_index,
                                                        pvecback,
                                                        pvecback_size,
                                                        pba->error_message),
               pba->error_message,
               pba->error_message);
  }

  return _SUCCESS_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x1010, %rsp           # imm = 0x1010
movq %r8, %r14
movq %rcx, %r15
movl %edx, %r12d
movl %esi, %ebp
movq %rdi, %rbx
addsd 0x91e93(%rip), %xmm0    # 0xee260
movsd %xmm0, 0x8(%rsp)
callq 0x82c0
xorpd 0x91e50(%rip), %xmm0    # 0xee230
movq 0x448(%rbx), %rdi
movsd (%rdi), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x5c477
movsd 0x91e63(%rip), %xmm0    # 0xee260
divsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movapd %xmm1, %xmm0
callq 0x8670
movapd %xmm0, %xmm1
leaq 0xae80b(%rip), %rsi     # 0x10ac28
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movsd 0x8(%rsp), %xmm0
movb $0x2, %al
callq 0x30af0
leaq 0x91c49(%rip), %rsi     # 0xee082
leaq 0xae85b(%rip), %rdx     # 0x10ac9b
leaq 0x810(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30af0
addq $0xd1c, %rbx            # imm = 0xD1C
leaq 0x91bd1(%rip), %rsi     # 0xee034
leaq 0xae84b(%rip), %rdx     # 0x10acb5
movq %rbx, %rdi
movl $0x9f, %ecx
jmp 0x5c50f
movsd 0x8(%rsp), %xmm2
movslq 0x440(%rbx), %rsi
movsd -0x8(%rdi,%rsi,8), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x5c530
movsd 0x91dc4(%rip), %xmm0    # 0xee260
divsd %xmm2, %xmm0
movsd %xmm0, 0x8(%rsp)
movapd %xmm1, %xmm0
callq 0x8670
movapd %xmm0, %xmm1
leaq 0xae80b(%rip), %rsi     # 0x10acc5
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movsd 0x8(%rsp), %xmm0
movb $0x2, %al
callq 0x30af0
leaq 0x91bac(%rip), %rsi     # 0xee082
leaq 0xae813(%rip), %rdx     # 0x10acf0
leaq 0x810(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30af0
addq $0xd1c, %rbx            # imm = 0xD1C
leaq 0x91b34(%rip), %rsi     # 0xee034
leaq 0xae7ae(%rip), %rdx     # 0x10acb5
movq %rbx, %rdi
movl $0xa3, %ecx
movq %r15, %r8
xorl %eax, %eax
callq 0x30af0
movl $0x1, %ebp
movl %ebp, %eax
addq $0x1010, %rsp           # imm = 0x1010
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
testl %ebp, %ebp
setne %al
leaq 0x434(,%rax,8), %rax
cmpl $0x1, %ebp
movl $0x438, %ecx            # imm = 0x438
cmovneq %rax, %rcx
movl (%rbx,%rcx), %eax
xorl %ebp, %ebp
cmpl $0x1, %r12d
je 0x5c5c8
testl %r12d, %r12d
jne 0x5c51e
movq 0x460(%rbx), %rdx
movq 0x478(%rbx), %rcx
movl 0x43c(%rbx), %r8d
addq $0xd1c, %rbx            # imm = 0xD1C
subq $0x8, %rsp
movq %r15, %r9
pushq %rbx
pushq %rax
pushq %r14
callq 0x18071
addq $0x20, %rsp
cmpl $0x1, %eax
jne 0x5c51e
leaq 0x91e59(%rip), %rsi     # 0xee3f0
leaq 0xae779(%rip), %rdx     # 0x10ad17
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0x91a7d(%rip), %rsi     # 0xee034
leaq 0xae6f7(%rip), %rdx     # 0x10acb5
movq %rbx, %rdi
movl $0xc5, %ecx
jmp 0x5c637
movq 0x460(%rbx), %rdx
movq 0x478(%rbx), %rcx
movl 0x43c(%rbx), %r8d
addq $0xd1c, %rbx            # imm = 0xD1C
subq $0x8, %rsp
movq %r15, %r9
pushq %rbx
pushq %rax
pushq %r14
callq 0x198fb
addq $0x20, %rsp
cmpl $0x1, %eax
jne 0x5c51e
leaq 0x91de8(%rip), %rsi     # 0xee3f0
leaq 0xae7c5(%rip), %rdx     # 0x10add4
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0x91a0c(%rip), %rsi     # 0xee034
leaq 0xae686(%rip), %rdx     # 0x10acb5
movq %rbx, %rdi
movl $0xd4, %ecx
movq %r14, %r8
jmp 0x5c512