// File: /workspace/github_c_makefile_star2_O3/PoulinV[P]AxiCLASS/build/../source/primordial.c
// Function: primordial_inflation_derivs
int primordial_inflation_derivs(
                                double tau,
                                double * y,
                                double * dy,
                                void * parameters_and_workspace,
                                ErrorMsg error_message
                                ) {

  struct primordial_inflation_parameters_and_workspace * ppipaw;
  struct primordial * ppm;

  ppipaw = (struct primordial_inflation_parameters_and_workspace *)parameters_and_workspace;
  ppm = ppipaw->ppm;

  // a2
  ppipaw->a2=y[ppm->index_in_a]*y[ppm->index_in_a];

  // BACKGROUND

  switch (ppm->primordial_spec_type) {

  case inflation_V:
  case inflation_V_end:

    class_call(primordial_inflation_potential(ppm,
                                              y[ppm->index_in_phi],
                                              &(ppipaw->V),
                                              &(ppipaw->dV),
                                              &(ppipaw->ddV)),
               ppm->error_message,
               ppm->error_message);

    switch (ppipaw->integrate) {

    case forward:

      switch (ppipaw->time) {

      case conformal:

        // a H = a'/a
        ppipaw->aH = sqrt((8*_PI_/3.)*(0.5*y[ppm->index_in_dphi]*y[ppm->index_in_dphi]+ppipaw->a2*ppipaw->V));
        // 1: a
        dy[ppm->index_in_a]=y[ppm->index_in_a]*ppipaw->aH;
        // 2: phi
        dy[ppm->index_in_phi]=y[ppm->index_in_dphi];
        // 3: dphi/dtau
        dy[ppm->index_in_dphi]=-2.*ppipaw->aH*y[ppm->index_in_dphi]-ppipaw->a2*ppipaw->dV;
        break;

      case proper:

        // a H = adot
        ppipaw->aH = y[ppm->index_in_a]*sqrt((8*_PI_/3.)*(0.5*y[ppm->index_in_dphi]*y[ppm->index_in_dphi]+ppipaw->V));
        // 1: a
        dy[ppm->index_in_a]=ppipaw->aH;
        // 2: phi
        dy[ppm->index_in_phi]=y[ppm->index_in_dphi];
        // 3: dphi/dt
        dy[ppm->index_in_dphi]=-3.*ppipaw->aH/y[ppm->index_in_a]*y[ppm->index_in_dphi]-ppipaw->dV;
        break;
      }

      // z''/z (assumes that conformal time is requested)
      ppipaw->zpp_over_z=
        2*ppipaw->aH*ppipaw->aH
        - ppipaw->a2*ppipaw->ddV
        - 4.*_PI_*(7.*y[ppm->index_in_dphi]*y[ppm->index_in_dphi]
                   +4.*y[ppm->index_in_dphi]/ppipaw->aH*ppipaw->a2*ppipaw->dV)
        +32.*_PI_*_PI_*pow(y[ppm->index_in_dphi],4)/pow(ppipaw->aH,2);

      // a''/a (assumes that conformal time is requested)
      ppipaw->app_over_a=2.*ppipaw->aH*ppipaw->aH - 4.*_PI_*y[ppm->index_in_dphi]*y[ppm->index_in_dphi];

      break;

      // For backward integration of approximate slow-roll solution:
      // Neglect kinetic energy of the field phi'^2/(2a^2) w.r.t. potential energy V
      // Neglect phi'' w.r.t 2aHphi', reducing 2nd order Klein-Gordon to approximate 1st-order
    case backward:

      switch (ppipaw->time) {

      case conformal:

        // a H = a'/a
        ppipaw->aH = sqrt((8*_PI_/3.)*ppipaw->a2*ppipaw->V);
        // 1: a
        dy[ppm->index_in_a]=y[ppm->index_in_a]*ppipaw->aH;
        // 2: phi
        dy[ppm->index_in_phi]= -ppipaw->a2*ppipaw->dV/3./ppipaw->aH;
        break;

      case proper:

        // a H = da/dt
        ppipaw->aH = y[ppm->index_in_a]*sqrt((8*_PI_/3.)*ppipaw->V);
        // 1: a
        dy[ppm->index_in_a]=ppipaw->aH;
        // 2: phi
        dy[ppm->index_in_phi]= -ppipaw->dV/3./ppipaw->aH*y[ppm->index_in_a];
        break;
      }

      break;
    }

    break;

  case inflation_H:

    class_call(primordial_inflation_hubble(ppm,
                                           y[ppm->index_in_phi],
                                           &(ppipaw->H),
                                           &(ppipaw->dH),
                                           &(ppipaw->ddH),
                                           &(ppipaw->dddH)),
               ppm->error_message,
               ppm->error_message);

    switch (ppipaw->time) {

    case conformal:

      // 1: a
      dy[ppm->index_in_a]=ppipaw->a2*ppipaw->H;
      // 2: phi
      dy[ppm->index_in_phi]=-1./4./_PI_*y[ppm->index_in_a]*ppipaw->dH;
      break;

    case proper:

      // 1: a
      dy[ppm->index_in_a]=y[ppm->index_in_a]*ppipaw->H;
      // 2: phi
      dy[ppm->index_in_phi]=-1./4./_PI_*ppipaw->dH;
      break;
    }

    // z''/z (assumes that conformal time is requested)
    ppipaw->zpp_over_z =
      2.               *ppipaw->a2*ppipaw->H*ppipaw->H
      -3./4./_PI_      *ppipaw->a2*ppipaw->H*ppipaw->ddH
      +1./16./_PI_/_PI_*ppipaw->a2*ppipaw->ddH*ppipaw->ddH
      +1./16./_PI_/_PI_*ppipaw->a2*ppipaw->dH*ppipaw->dddH
      -1./4./_PI_/_PI_ *ppipaw->a2*ppipaw->dH*ppipaw->dH*ppipaw->ddH/ppipaw->H
      +1./2./_PI_      *ppipaw->a2*ppipaw->dH*ppipaw->dH
      +1./8./_PI_/_PI_ *ppipaw->a2*ppipaw->dH*ppipaw->dH*ppipaw->dH*ppipaw->dH/ppipaw->H/ppipaw->H;

    // a''/a (assumes that conformal time is requested)
    ppipaw->app_over_a = 2.*ppipaw->a2*ppipaw->H*ppipaw->H
      -4.*_PI_*dy[ppm->index_in_phi]*dy[ppm->index_in_phi];

    break;

  default:
    class_stop(ppm->error_message,"ppm->primordial_spec_type=%d different from possible relevant cases",ppm->primordial_spec_type);
    break;

  }

  if (ppipaw->N <= ppm->in_bg_size) // mind the <= instead of ==, necessary because for backward integration 1 equation is removed
    return _SUCCESS_;

  // PERTURBATIONS

  class_test(ppipaw->time == proper,
             ppm->error_message,
             "For inflaton perturbations, only conformal time is coded.");

  // SCALARS
  // 4: ksi_re
  dy[ppm->index_in_ksi_re]=y[ppm->index_in_dksi_re];
  // 5: ksi_im
  dy[ppm->index_in_ksi_im]=y[ppm->index_in_dksi_im];
  // 6: d ksi_re / dtau
  dy[ppm->index_in_dksi_re]=-(ppipaw->k*ppipaw->k-ppipaw->zpp_over_z)*y[ppm->index_in_ksi_re];
  // 7: d ksi_im / dtau
  dy[ppm->index_in_dksi_im]=-(ppipaw->k*ppipaw->k-ppipaw->zpp_over_z)*y[ppm->index_in_ksi_im];

  // TENSORS
  // 8: ah_re
  dy[ppm->index_in_ah_re]=y[ppm->index_in_dah_re];
  // 9: ah_im
  dy[ppm->index_in_ah_im]=y[ppm->index_in_dah_im];
  // 10: d ah_re / dtau
  dy[ppm->index_in_dah_re]=-(ppipaw->k*ppipaw->k-ppipaw->app_over_a)*y[ppm->index_in_ah_re];
  // 11: d ah_im / dtau
  dy[ppm->index_in_dah_im]=-(ppipaw->k*ppipaw->k-ppipaw->app_over_a)*y[ppm->index_in_ah_im];

  return _SUCCESS_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1018, %rsp           # imm = 0x1018
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %r15
movq (%rdx), %rbx
movslq 0x2d0(%rbx), %rax
movsd (%rdi,%rax,8), %xmm0
mulsd %xmm0, %xmm0
movsd %xmm0, 0x10(%rdx)
movl 0x18(%rbx), %edx
cmpl $0x4, %edx
je 0x9beff
cmpl $0x3, %edx
je 0x9bf73
cmpl $0x2, %edx
jne 0x9bfe3
movslq 0x2d4(%rbx), %rax
movsd (%r15,%rax,8), %xmm0
leaq 0x18(%r12), %r13
leaq 0x20(%r12), %rdx
leaq 0x28(%r12), %rcx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x9841a
testl %eax, %eax
je 0x9c037
addq $0x32a, %rbx            # imm = 0x32A
leaq 0x524b4(%rip), %rsi     # 0xee3f0
leaq 0x7edf9(%rip), %rdx     # 0x11ad3c
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0x520d8(%rip), %rsi     # 0xee034
leaq 0x7ee40(%rip), %rdx     # 0x11ada3
movq %rbx, %rdi
movl $0xc14, %ecx            # imm = 0xC14
movq %r14, %r8
jmp 0x9c262
movslq 0x2d4(%rbx), %rax
movsd (%r15,%rax,8), %xmm0
leaq 0x38(%r12), %rbp
leaq 0x40(%r12), %r13
leaq 0x48(%r12), %rcx
leaq 0x50(%r12), %r8
movq %rbx, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x98a30
movl 0x74(%r12), %eax
testl %eax, %eax
je 0x9c0b2
cmpl $0x1, %eax
jne 0x9c0f1
movslq 0x2d0(%rbx), %rax
movsd (%r15,%rax,8), %xmm0
mulsd (%rbp), %xmm0
movsd %xmm0, (%r14,%rax,8)
movsd (%r13), %xmm0
mulsd 0x7c4ea(%rip), %xmm0    # 0x1184c8
jmp 0x9c0e2
leaq 0x7d571(%rip), %rsi     # 0x11955b
leaq 0x10(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30af0
leaq 0x52585(%rip), %rsi     # 0xee585
leaq 0x810(%rsp), %r15
movq %r15, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x30af0
addq $0x32a, %rbx            # imm = 0x32A
leaq 0x52011(%rip), %rsi     # 0xee034
leaq 0x7ed79(%rip), %rdx     # 0x11ada3
movq %rbx, %rdi
movl $0xc92, %ecx            # imm = 0xC92
jmp 0x9c25f
movl 0x70(%r12), %eax
testl %eax, %eax
je 0x9c37d
cmpl $0x1, %eax
jne 0x9c1eb
movl 0x74(%r12), %eax
testl %eax, %eax
je 0x9c3c0
cmpl $0x1, %eax
jne 0x9c440
movslq 0x2d8(%rbx), %rax
movsd (%r15,%rax,8), %xmm1
movslq 0x2d0(%rbx), %rax
movsd 0x52c51(%rip), %xmm0    # 0xeecd0
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
addsd (%r13), %xmm0
mulsd 0x7c3f3(%rip), %xmm0    # 0x118488
movsd (%r15,%rax,8), %xmm2
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x9c44c
sqrtsd %xmm0, %xmm0
jmp 0x9c45d
movsd 0x10(%r12), %xmm0
mulsd 0x38(%r12), %xmm0
movslq 0x2d0(%rbx), %rax
movsd %xmm0, (%r14,%rax,8)
movsd (%r15,%rax,8), %xmm0
mulsd 0x7c3ed(%rip), %xmm0    # 0x1184c8
mulsd 0x40(%r12), %xmm0
movslq 0x2d4(%rbx), %rax
movsd %xmm0, (%r14,%rax,8)
jmp 0x9c0f8
movslq 0x2d4(%rbx), %rax
movsd 0x10(%r12), %xmm1
movsd 0x38(%r12), %xmm2
movapd %xmm1, %xmm0
addsd %xmm1, %xmm0
mulsd %xmm2, %xmm0
movsd 0x48(%r12), %xmm4
movsd 0x7c3af(%rip), %xmm3    # 0x1184d0
mulsd %xmm1, %xmm3
mulsd %xmm2, %xmm3
mulsd %xmm4, %xmm3
mulsd %xmm2, %xmm0
addsd %xmm0, %xmm3
movsd 0x7c39b(%rip), %xmm5    # 0x1184d8
mulsd %xmm1, %xmm5
movapd %xmm5, %xmm6
mulsd %xmm4, %xmm6
mulsd %xmm4, %xmm6
addsd %xmm3, %xmm6
movsd 0x40(%r12), %xmm3
mulsd %xmm3, %xmm5
mulsd 0x50(%r12), %xmm5
addsd %xmm6, %xmm5
movsd 0x7c371(%rip), %xmm6    # 0x1184e0
mulsd %xmm1, %xmm6
mulsd %xmm3, %xmm6
mulsd %xmm3, %xmm6
mulsd %xmm4, %xmm6
divsd %xmm2, %xmm6
addsd %xmm5, %xmm6
movsd 0x7c359(%rip), %xmm4    # 0x1184e8
mulsd %xmm1, %xmm4
mulsd %xmm3, %xmm4
mulsd %xmm3, %xmm4
addsd %xmm6, %xmm4
mulsd 0x7c349(%rip), %xmm1    # 0x1184f0
mulsd %xmm3, %xmm1
mulsd %xmm3, %xmm1
mulsd %xmm3, %xmm1
mulsd %xmm3, %xmm1
divsd %xmm2, %xmm1
divsd %xmm2, %xmm1
addsd %xmm4, %xmm1
movsd %xmm1, 0x58(%r12)
movsd (%r14,%rax,8), %xmm1
movsd 0x7c320(%rip), %xmm2    # 0x1184f8
mulsd %xmm1, %xmm2
mulsd %xmm1, %xmm2
addsd %xmm0, %xmm2
movsd %xmm2, 0x60(%r12)
xorps %xmm0, %xmm0
cvtsi2sdl 0x2fc(%rbx), %xmm0
xorl %eax, %eax
ucomisd 0x8(%r12), %xmm0
jae 0x9c26e
cmpl $0x1, 0x74(%r12)
jne 0x9c280
leaq 0x7ebaf(%rip), %rsi     # 0x11adbf
leaq 0x10(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30af0
leaq 0x51e5c(%rip), %rsi     # 0xee082
leaq 0x7ebcc(%rip), %rdx     # 0x11adf9
leaq 0x810(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30af0
addq $0x32a, %rbx            # imm = 0x32A
leaq 0x51de4(%rip), %rsi     # 0xee034
leaq 0x7eb4c(%rip), %rdx     # 0x11ada3
movq %rbx, %rdi
movl $0xc9e, %ecx            # imm = 0xC9E
movq %r15, %r8
xorl %eax, %eax
callq 0x30af0
movl $0x1, %eax
addq $0x1018, %rsp           # imm = 0x1018
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movslq 0x2e4(%rbx), %rcx
movsd (%r15,%rcx,8), %xmm0
movslq 0x2dc(%rbx), %rdx
movsd %xmm0, (%r14,%rdx,8)
movslq 0x2e8(%rbx), %rsi
movsd (%r15,%rsi,8), %xmm0
movslq 0x2e0(%rbx), %rdi
movsd %xmm0, (%r14,%rdi,8)
movsd 0x68(%r12), %xmm1
mulsd %xmm1, %xmm1
subsd 0x58(%r12), %xmm1
movapd 0x51f62(%rip), %xmm0    # 0xee230
xorpd %xmm0, %xmm1
mulsd (%r15,%rdx,8), %xmm1
movsd %xmm1, (%r14,%rcx,8)
movsd 0x68(%r12), %xmm1
mulsd %xmm1, %xmm1
subsd 0x58(%r12), %xmm1
xorpd %xmm0, %xmm1
mulsd (%r15,%rdi,8), %xmm1
movsd %xmm1, (%r14,%rsi,8)
movslq 0x2f4(%rbx), %rcx
movsd (%r15,%rcx,8), %xmm1
movslq 0x2ec(%rbx), %rdx
movsd %xmm1, (%r14,%rdx,8)
movslq 0x2f8(%rbx), %rsi
movsd (%r15,%rsi,8), %xmm1
movslq 0x2f0(%rbx), %rdi
movsd %xmm1, (%r14,%rdi,8)
movsd 0x68(%r12), %xmm1
mulsd %xmm1, %xmm1
subsd 0x60(%r12), %xmm1
xorpd %xmm0, %xmm1
mulsd (%r15,%rdx,8), %xmm1
movsd %xmm1, (%r14,%rcx,8)
movsd 0x68(%r12), %xmm1
mulsd %xmm1, %xmm1
subsd 0x60(%r12), %xmm1
xorpd %xmm0, %xmm1
mulsd (%r15,%rdi,8), %xmm1
movsd %xmm1, (%r14,%rsi,8)
jmp 0x9c26e
movl 0x74(%r12), %eax
cmpl $0x1, %eax
je 0x9c40e
testl %eax, %eax
jne 0x9c1eb
movsd 0x10(%r12), %xmm0
mulsd 0x7c0e6(%rip), %xmm0    # 0x118488
mulsd 0x18(%r12), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x9c4ba
sqrtsd %xmm0, %xmm0
jmp 0x9c4bf
movslq 0x2d8(%rbx), %rax
movsd (%r15,%rax,8), %xmm1
movsd 0x528fb(%rip), %xmm0    # 0xeecd0
mulsd %xmm1, %xmm0
movsd 0x10(%r12), %xmm2
mulsd 0x18(%r12), %xmm2
mulsd %xmm1, %xmm0
addsd %xmm2, %xmm0
mulsd 0x7c091(%rip), %xmm0    # 0x118488
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x9c4fb
sqrtsd %xmm0, %xmm0
jmp 0x9c500
movslq 0x2d0(%rbx), %rax
movsd (%r13), %xmm0
mulsd 0x7c065(%rip), %xmm0    # 0x118488
movsd (%r15,%rax,8), %xmm2
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x9c62e
sqrtsd %xmm0, %xmm0
jmp 0x9c63f
movslq 0x2d8(%rbx), %rax
jmp 0x9c55f
movsd %xmm2, 0x8(%rsp)
callq 0x82b0
movsd 0x8(%rsp), %xmm2
mulsd %xmm0, %xmm2
movsd %xmm2, 0x30(%r12)
movslq 0x2d0(%rbx), %rcx
movsd %xmm2, (%r14,%rcx,8)
movslq 0x2d8(%rbx), %rax
movsd (%r15,%rax,8), %xmm0
movslq 0x2d4(%rbx), %rdx
movsd %xmm0, (%r14,%rdx,8)
movsd 0x30(%r12), %xmm1
mulsd 0x54fe2(%rip), %xmm1    # 0xf1480
divsd (%r15,%rcx,8), %xmm1
mulsd %xmm0, %xmm1
subsd 0x20(%r12), %xmm1
movsd %xmm1, (%r14,%rax,8)
jmp 0x9c55f
callq 0x82b0
movsd %xmm0, 0x30(%r12)
movslq 0x2d0(%rbx), %rax
mulsd (%r15,%rax,8), %xmm0
movsd %xmm0, (%r14,%rax,8)
movsd 0x20(%r12), %xmm0
mulsd 0x10(%r12), %xmm0
divsd 0x54f91(%rip), %xmm0    # 0xf1480
divsd 0x30(%r12), %xmm0
jmp 0x9c673
callq 0x82b0
movsd %xmm0, 0x30(%r12)
movslq 0x2d0(%rbx), %rax
mulsd (%r15,%rax,8), %xmm0
movsd %xmm0, (%r14,%rax,8)
movslq 0x2d8(%rbx), %rax
movsd (%r15,%rax,8), %xmm0
movslq 0x2d4(%rbx), %rcx
movsd %xmm0, (%r14,%rcx,8)
movsd 0x20(%r12), %xmm1
movsd 0x30(%r12), %xmm2
mulsd 0x53216(%rip), %xmm2    # 0xef760
mulsd 0x10(%r12), %xmm1
mulsd %xmm0, %xmm2
subsd %xmm1, %xmm2
movsd %xmm2, (%r14,%rax,8)
movsd 0x10(%r12), %xmm2
movsd 0x30(%r12), %xmm3
movapd %xmm3, %xmm4
addsd %xmm3, %xmm4
movsd 0x28(%r12), %xmm0
mulsd %xmm2, %xmm0
mulsd %xmm3, %xmm4
subsd %xmm0, %xmm4
movsd (%r15,%rax,8), %xmm0
movsd 0x531d2(%rip), %xmm6    # 0xef768
mulsd %xmm0, %xmm6
movsd 0x54e96(%rip), %xmm1    # 0xf1438
movapd %xmm0, %xmm5
mulsd %xmm1, %xmm5
divsd %xmm3, %xmm5
mulsd %xmm2, %xmm5
mulsd 0x20(%r12), %xmm5
mulsd %xmm0, %xmm6
addsd %xmm5, %xmm6
mulsd 0x7bf2f(%rip), %xmm6    # 0x1184f8
addsd %xmm4, %xmm6
movsd %xmm6, 0x8(%rsp)
callq 0x8620
mulsd 0x7bf20(%rip), %xmm0    # 0x118500
movsd 0x30(%r12), %xmm1
movapd %xmm1, %xmm2
addsd %xmm1, %xmm2
mulsd %xmm1, %xmm2
mulsd %xmm1, %xmm1
divsd %xmm1, %xmm0
addsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x58(%r12)
movslq 0x2d8(%rbx), %rax
movsd (%r15,%rax,8), %xmm0
movsd 0x7bedb(%rip), %xmm1    # 0x1184f8
mulsd %xmm0, %xmm1
mulsd %xmm0, %xmm1
addsd %xmm1, %xmm2
jmp 0x9c1e4
movsd %xmm2, 0x8(%rsp)
callq 0x82b0
movsd 0x8(%rsp), %xmm2
mulsd %xmm0, %xmm2
movsd %xmm2, 0x30(%r12)
movslq 0x2d0(%rbx), %rax
movsd %xmm2, (%r14,%rax,8)
movsd 0x20(%r12), %xmm0
divsd 0x54e1a(%rip), %xmm0    # 0xf1480
divsd 0x30(%r12), %xmm0
mulsd (%r15,%rax,8), %xmm0
movslq 0x2d4(%rbx), %rax
movsd %xmm0, (%r14,%rax,8)
jmp 0x9c1eb