// File: /workspace/github_c_makefile_star2_O1/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 %r13
pushq %r12
pushq %rbx
subq $0x1028, %rsp           # imm = 0x1028
movq %r8, %r14
movq %rcx, %r15
movl %edx, %r12d
movl %esi, %ebp
movq %rdi, %rbx
addsd 0x927ad(%rip), %xmm0    # 0xf1260
movsd %xmm0, (%rsp)
callq 0x82c0
xorpd 0x9276b(%rip), %xmm0    # 0xf1230
movq 0x448(%rbx), %rdi
movsd (%rdi), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x5eb55
movsd 0x92782(%rip), %xmm0    # 0xf1260
divsd (%rsp), %xmm0
movsd %xmm0, (%rsp)
movsd (%rdi), %xmm0
callq 0x8670
movapd %xmm0, %xmm1
leaq 0xaf10c(%rip), %rsi     # 0x10dc08
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movsd (%rsp), %xmm0
movb $0x2, %al
callq 0x30c2c
leaq 0x9256b(%rip), %rsi     # 0xf1082
leaq 0xaf15d(%rip), %rdx     # 0x10dc7b
leaq 0x820(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30c2c
addq $0xd1c, %rbx            # imm = 0xD1C
leaq 0x924f3(%rip), %rsi     # 0xf1034
leaq 0xaf14d(%rip), %rdx     # 0x10dc95
movq %rbx, %rdi
movl $0x9f, %ecx
jmp 0x5ebe8
movsd (%rsp), %xmm1
movslq 0x440(%rbx), %rsi
ucomisd -0x8(%rdi,%rsi,8), %xmm0
jbe 0x5ec0b
movsd 0x926eb(%rip), %xmm0    # 0xf1260
divsd %xmm1, %xmm0
movsd %xmm0, (%rsp)
movsd -0x8(%rdi,%rsi,8), %xmm0
callq 0x8670
movapd %xmm0, %xmm1
leaq 0xaf111(%rip), %rsi     # 0x10dca5
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movsd (%rsp), %xmm0
movb $0x2, %al
callq 0x30c2c
leaq 0x924d3(%rip), %rsi     # 0xf1082
leaq 0xaf11a(%rip), %rdx     # 0x10dcd0
leaq 0x820(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30c2c
addq $0xd1c, %rbx            # imm = 0xD1C
leaq 0x9245b(%rip), %rsi     # 0xf1034
leaq 0xaf0b5(%rip), %rdx     # 0x10dc95
movq %rbx, %rdi
movl $0xa3, %ecx
movq %r15, %r8
xorl %eax, %eax
callq 0x30c2c
movl $0x1, %ebp
movl %ebp, %eax
addq $0x1028, %rsp           # imm = 0x1028
popq %rbx
popq %r12
popq %r13
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), %r13d
xorl %ebp, %ebp
cmpl $0x1, %r12d
je 0x5ecce
testl %r12d, %r12d
jne 0x5ebf7
movq 0x460(%rbx), %rdx
movq 0x478(%rbx), %rcx
movl 0x43c(%rbx), %r8d
leaq 0xd1c(%rbx), %rax
subq $0x8, %rsp
movapd %xmm0, 0x8(%rsp)
movq %r15, %r9
movq %rax, 0x20(%rsp)
pushq %rax
pushq %r13
pushq %r14
callq 0x17ee6
addq $0x20, %rsp
cmpl $0x1, %eax
jne 0x5ecbf
leaq 0x9276d(%rip), %rsi     # 0xf13f0
leaq 0xaf06d(%rip), %rdx     # 0x10dcf7
leaq 0x20(%rsp), %rbx
movq %rbx, %rdi
movq 0x18(%rsp), %r14
movq %r14, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x9238c(%rip), %rsi     # 0xf1034
leaq 0xaefe6(%rip), %rdx     # 0x10dc95
movq %r14, %rdi
movl $0xc5, %ecx
movq %rbx, %r8
jmp 0x5ebeb
cmpl $0x1, %r12d
movapd (%rsp), %xmm0
jne 0x5ebf7
movq 0x448(%rbx), %rdi
movl 0x43c(%rbx), %r8d
movl 0x440(%rbx), %esi
movq 0x460(%rbx), %rdx
movq 0x478(%rbx), %rcx
addq $0xd1c, %rbx            # imm = 0xD1C
subq $0x8, %rsp
movq %r15, %r9
pushq %rbx
pushq %r13
pushq %r14
callq 0x19770
addq $0x20, %rsp
cmpl $0x1, %eax
jne 0x5ebf7
leaq 0x926d4(%rip), %rsi     # 0xf13f0
leaq 0xaf091(%rip), %rdx     # 0x10ddb4
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x922f8(%rip), %rsi     # 0xf1034
leaq 0xaef52(%rip), %rdx     # 0x10dc95
movq %rbx, %rdi
movl $0xd4, %ecx
movq %r14, %r8
jmp 0x5ebeb