// File: /workspace/github_c_makefile_star2_O2/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 0x8cc53(%rip), %xmm0    # 0xe5260
movsd %xmm0, 0x8(%rsp)
callq 0x82e0
xorpd 0x8cc10(%rip), %xmm0    # 0xe5230
movq 0x448(%rbx), %rdi
movsd (%rdi), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x586b7
movsd 0x8cc23(%rip), %xmm0    # 0xe5260
divsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movapd %xmm1, %xmm0
callq 0x86a0
movapd %xmm0, %xmm1
leaq 0xa948b(%rip), %rsi     # 0x101ae8
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movsd 0x8(%rsp), %xmm0
movb $0x2, %al
callq 0x2e014
leaq 0x8ca09(%rip), %rsi     # 0xe5082
leaq 0xa94db(%rip), %rdx     # 0x101b5b
leaq 0x810(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
addq $0xd1c, %rbx            # imm = 0xD1C
leaq 0x8c991(%rip), %rsi     # 0xe5034
leaq 0xa94cb(%rip), %rdx     # 0x101b75
movq %rbx, %rdi
movl $0x9f, %ecx
jmp 0x5874f
movsd 0x8(%rsp), %xmm2
movslq 0x440(%rbx), %rsi
movsd -0x8(%rdi,%rsi,8), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x5876e
movsd 0x8cb84(%rip), %xmm0    # 0xe5260
divsd %xmm2, %xmm0
movsd %xmm0, 0x8(%rsp)
movapd %xmm1, %xmm0
callq 0x86a0
movapd %xmm0, %xmm1
leaq 0xa948b(%rip), %rsi     # 0x101b85
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movsd 0x8(%rsp), %xmm0
movb $0x2, %al
callq 0x2e014
leaq 0x8c96c(%rip), %rsi     # 0xe5082
leaq 0xa9493(%rip), %rdx     # 0x101bb0
leaq 0x810(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
addq $0xd1c, %rbx            # imm = 0xD1C
leaq 0x8c8f4(%rip), %rsi     # 0xe5034
leaq 0xa942e(%rip), %rdx     # 0x101b75
movq %rbx, %rdi
movl $0xa3, %ecx
movq %r15, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %rbp
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 0x58806
testl %r12d, %r12d
jne 0x5875c
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 0x1604b
addq $0x20, %rsp
cmpl $0x1, %eax
jne 0x5875c
leaq 0x8cc1b(%rip), %rsi     # 0xe53f0
leaq 0xa93fb(%rip), %rdx     # 0x101bd7
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x8c83f(%rip), %rsi     # 0xe5034
leaq 0xa9379(%rip), %rdx     # 0x101b75
movq %rbx, %rdi
movl $0xc5, %ecx
jmp 0x58875
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 0x177dd
addq $0x20, %rsp
cmpl $0x1, %eax
jne 0x5875c
leaq 0x8cbaa(%rip), %rsi     # 0xe53f0
leaq 0xa9447(%rip), %rdx     # 0x101c94
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x8c7ce(%rip), %rsi     # 0xe5034
leaq 0xa9308(%rip), %rdx     # 0x101b75
movq %rbx, %rdi
movl $0xd4, %ecx
movq %r14, %r8
jmp 0x58752