// File: /workspace/github_c_makefile_star2_O1/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), %eax
cmpl $0x4, %eax
je 0x9ee29
cmpl $0x3, %eax
je 0x9ee9d
cmpl $0x2, %eax
jne 0x9ef17
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 0x9b20b
testl %eax, %eax
je 0x9ef6e
addq $0x32a, %rbx            # imm = 0x32A
leaq 0x5258a(%rip), %rsi     # 0xf13f0
leaq 0x7ee8f(%rip), %rdx     # 0x11dcfc
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x521ae(%rip), %rsi     # 0xf1034
leaq 0x7eed6(%rip), %rdx     # 0x11dd63
movq %rbx, %rdi
movl $0xc14, %ecx            # imm = 0xC14
movq %r14, %r8
jmp 0x9f18c
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 0x9b821
movl 0x74(%r12), %eax
cmpl $0x1, %eax
je 0x9efe8
testl %eax, %eax
jne 0x9f01b
movsd 0x10(%r12), %xmm0
mulsd 0x38(%r12), %xmm0
movslq 0x2d0(%rbx), %rax
movsd %xmm0, (%r14,%rax,8)
movsd (%r15,%rax,8), %xmm0
mulsd 0x7c57d(%rip), %xmm0    # 0x11b488
mulsd 0x40(%r12), %xmm0
jmp 0x9f00e
movl 0x18(%rbx), %edx
leaq 0x7d5fa(%rip), %rsi     # 0x11c51b
leaq 0x10(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30c2c
leaq 0x5264e(%rip), %rsi     # 0xf1585
leaq 0x810(%rsp), %r15
movq %r15, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x30c2c
addq $0x32a, %rbx            # imm = 0x32A
leaq 0x520da(%rip), %rsi     # 0xf1034
leaq 0x7ee02(%rip), %rdx     # 0x11dd63
movq %rbx, %rdi
movl $0xc92, %ecx            # imm = 0xC92
jmp 0x9f189
movl 0x70(%r12), %eax
testl %eax, %eax
je 0x9f2a7
cmpl $0x1, %eax
jne 0x9f115
movl 0x74(%r12), %eax
cmpl $0x1, %eax
je 0x9f2ea
testl %eax, %eax
jne 0x9f47c
movslq 0x2d8(%rbx), %rax
movsd (%r15,%rax,8), %xmm1
movsd 0x52d21(%rip), %xmm0    # 0xf1cd0
mulsd %xmm1, %xmm0
movsd 0x10(%r12), %xmm2
mulsd 0x18(%r12), %xmm2
mulsd %xmm1, %xmm0
addsd %xmm2, %xmm0
mulsd 0x7c477(%rip), %xmm0    # 0x11b448
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x9f36b
sqrtsd %xmm0, %xmm0
jmp 0x9f370
movslq 0x2d0(%rbx), %rax
movsd (%r15,%rax,8), %xmm0
mulsd (%rbp), %xmm0
movsd %xmm0, (%r14,%rax,8)
movsd (%r13), %xmm0
mulsd 0x7c47a(%rip), %xmm0    # 0x11b488
movslq 0x2d4(%rbx), %rax
movsd %xmm0, (%r14,%rax,8)
movsd 0x10(%r12), %xmm1
movsd 0x38(%r12), %xmm2
movapd %xmm1, %xmm0
addsd %xmm1, %xmm0
mulsd %xmm2, %xmm0
movsd 0x48(%r12), %xmm4
movsd 0x7c44c(%rip), %xmm3    # 0x11b490
mulsd %xmm1, %xmm3
mulsd %xmm2, %xmm3
mulsd %xmm4, %xmm3
mulsd %xmm2, %xmm0
addsd %xmm0, %xmm3
movsd 0x7c438(%rip), %xmm5    # 0x11b498
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 0x7c40e(%rip), %xmm6    # 0x11b4a0
mulsd %xmm1, %xmm6
mulsd %xmm3, %xmm6
mulsd %xmm3, %xmm6
mulsd %xmm4, %xmm6
divsd %xmm2, %xmm6
addsd %xmm5, %xmm6
movsd 0x7c3f6(%rip), %xmm4    # 0x11b4a8
mulsd %xmm1, %xmm4
mulsd %xmm3, %xmm4
mulsd %xmm3, %xmm4
mulsd 0x7c3ea(%rip), %xmm1    # 0x11b4b0
addsd %xmm6, %xmm4
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)
movslq 0x2d4(%rbx), %rax
movsd (%r14,%rax,8), %xmm1
movsd 0x7c3b6(%rip), %xmm2    # 0x11b4b8
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 0x9f198
cmpl $0x1, 0x74(%r12)
jne 0x9f1aa
leaq 0x7ec45(%rip), %rsi     # 0x11dd7f
leaq 0x10(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30c2c
leaq 0x51f32(%rip), %rsi     # 0xf1082
leaq 0x7ec62(%rip), %rdx     # 0x11ddb9
leaq 0x810(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30c2c
addq $0x32a, %rbx            # imm = 0x32A
leaq 0x51eba(%rip), %rsi     # 0xf1034
leaq 0x7ebe2(%rip), %rdx     # 0x11dd63
movq %rbx, %rdi
movl $0xc9e, %ecx            # imm = 0xC9E
movq %r15, %r8
xorl %eax, %eax
callq 0x30c2c
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 0x52038(%rip), %xmm0    # 0xf1230
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 0x9f198
movl 0x74(%r12), %eax
cmpl $0x1, %eax
je 0x9f339
testl %eax, %eax
jne 0x9f115
movsd 0x10(%r12), %xmm0
mulsd 0x7c17c(%rip), %xmm0    # 0x11b448
mulsd 0x18(%r12), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x9f3d0
sqrtsd %xmm0, %xmm0
jmp 0x9f3d5
movslq 0x2d8(%rbx), %rax
movsd (%r15,%rax,8), %xmm1
movslq 0x2d0(%rbx), %rax
movsd 0x529ca(%rip), %xmm0    # 0xf1cd0
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
addsd (%r13), %xmm0
mulsd 0x7c12c(%rip), %xmm0    # 0x11b448
movsd (%r15,%rax,8), %xmm2
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x9f411
sqrtsd %xmm0, %xmm0
jmp 0x9f422
movslq 0x2d0(%rbx), %rax
movsd (%r13), %xmm0
mulsd 0x7c0fa(%rip), %xmm0    # 0x11b448
movsd (%r15,%rax,8), %xmm2
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x9f552
sqrtsd %xmm0, %xmm0
jmp 0x9f563
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), %xmm0
mulsd 0x5339e(%rip), %xmm0    # 0xf2758
mulsd 0x10(%r12), %xmm1
mulsd (%r15,%rax,8), %xmm0
subsd %xmm1, %xmm0
jmp 0x9f476
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 0x5506b(%rip), %xmm0    # 0xf4470
divsd 0x30(%r12), %xmm0
jmp 0x9f597
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), %xmm0
mulsd 0x5500d(%rip), %xmm0    # 0xf4470
divsd (%r15,%rcx,8), %xmm0
mulsd (%r15,%rax,8), %xmm0
subsd 0x20(%r12), %xmm0
movsd %xmm0, (%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
movslq 0x2d8(%rbx), %rax
movsd (%r15,%rax,8), %xmm0
movsd 0x532a6(%rip), %xmm6    # 0xf2760
mulsd %xmm0, %xmm6
movsd 0x54f62(%rip), %xmm1    # 0xf4428
movapd %xmm0, %xmm5
mulsd %xmm1, %xmm5
divsd %xmm3, %xmm5
mulsd %xmm2, %xmm5
mulsd 0x20(%r12), %xmm5
mulsd %xmm0, %xmm6
addsd %xmm5, %xmm6
mulsd 0x7bfcb(%rip), %xmm6    # 0x11b4b8
addsd %xmm4, %xmm6
movsd %xmm6, 0x8(%rsp)
callq 0x8620
mulsd 0x7bfbc(%rip), %xmm0    # 0x11b4c0
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 0x7bf77(%rip), %xmm1    # 0x11b4b8
mulsd %xmm0, %xmm1
mulsd %xmm0, %xmm1
addsd %xmm1, %xmm2
jmp 0x9f10e
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 0x54ee6(%rip), %xmm0    # 0xf4470
divsd 0x30(%r12), %xmm0
mulsd (%r15,%rax,8), %xmm0
movslq 0x2d4(%rbx), %rax
movsd %xmm0, (%r14,%rax,8)
jmp 0x9f115