// File: /workspace/github_c_makefile_star2_O2/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 0x9714d
cmpl $0x3, %edx
je 0x971c1
cmpl $0x2, %edx
jne 0x97231
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 0x93719
testl %eax, %eax
je 0x97285
addq $0x32a, %rbx            # imm = 0x32A
leaq 0x4e266(%rip), %rsi     # 0xe53f0
leaq 0x7aa4b(%rip), %rdx     # 0x111bdc
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x4de8a(%rip), %rsi     # 0xe5034
leaq 0x7aa92(%rip), %rdx     # 0x111c43
movq %rbx, %rdi
movl $0xc14, %ecx            # imm = 0xC14
movq %r14, %r8
jmp 0x974ad
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 0x93d2d
movl 0x74(%r12), %eax
testl %eax, %eax
je 0x97300
cmpl $0x1, %eax
jne 0x9733f
movslq 0x2d0(%rbx), %rax
movsd (%r15,%rax,8), %xmm0
mulsd (%rbp), %xmm0
movsd %xmm0, (%r14,%rax,8)
movsd (%r13), %xmm0
mulsd 0x7813c(%rip), %xmm0    # 0x10f368
jmp 0x97330
leaq 0x791c3(%rip), %rsi     # 0x1103fb
leaq 0x10(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x2e014
leaq 0x4e337(%rip), %rsi     # 0xe5585
leaq 0x810(%rsp), %r15
movq %r15, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x2e014
addq $0x32a, %rbx            # imm = 0x32A
leaq 0x4ddc3(%rip), %rsi     # 0xe5034
leaq 0x7a9cb(%rip), %rdx     # 0x111c43
movq %rbx, %rdi
movl $0xc92, %ecx            # imm = 0xC92
jmp 0x974aa
movl 0x70(%r12), %eax
testl %eax, %eax
je 0x975c6
cmpl $0x1, %eax
jne 0x97439
movl 0x74(%r12), %eax
testl %eax, %eax
je 0x97609
cmpl $0x1, %eax
jne 0x97689
movslq 0x2d8(%rbx), %rax
movsd (%r15,%rax,8), %xmm1
movslq 0x2d0(%rbx), %rax
movsd 0x4e9e3(%rip), %xmm0    # 0xe5cb0
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
addsd (%r13), %xmm0
mulsd 0x78045(%rip), %xmm0    # 0x10f328
movsd (%r15,%rax,8), %xmm2
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x97695
sqrtsd %xmm0, %xmm0
jmp 0x976a6
movsd 0x10(%r12), %xmm0
mulsd 0x38(%r12), %xmm0
movslq 0x2d0(%rbx), %rax
movsd %xmm0, (%r14,%rax,8)
movsd (%r15,%rax,8), %xmm0
mulsd 0x7803f(%rip), %xmm0    # 0x10f368
mulsd 0x40(%r12), %xmm0
movslq 0x2d4(%rbx), %rax
movsd %xmm0, (%r14,%rax,8)
jmp 0x97346
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 0x78001(%rip), %xmm3    # 0x10f370
mulsd %xmm1, %xmm3
mulsd %xmm2, %xmm3
mulsd %xmm4, %xmm3
mulsd %xmm2, %xmm0
addsd %xmm0, %xmm3
movsd 0x77fed(%rip), %xmm5    # 0x10f378
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 0x77fc3(%rip), %xmm6    # 0x10f380
mulsd %xmm1, %xmm6
mulsd %xmm3, %xmm6
mulsd %xmm3, %xmm6
mulsd %xmm4, %xmm6
divsd %xmm2, %xmm6
addsd %xmm5, %xmm6
movsd 0x77fab(%rip), %xmm4    # 0x10f388
mulsd %xmm1, %xmm4
mulsd %xmm3, %xmm4
mulsd %xmm3, %xmm4
addsd %xmm6, %xmm4
mulsd 0x77f9b(%rip), %xmm1    # 0x10f390
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 0x77f72(%rip), %xmm2    # 0x10f398
mulsd %xmm1, %xmm2
mulsd %xmm1, %xmm2
addsd %xmm0, %xmm2
movsd %xmm2, 0x60(%r12)
cvtsi2sdl 0x2fc(%rbx), %xmm0
xorl %eax, %eax
ucomisd 0x8(%r12), %xmm0
jae 0x974b7
cmpl $0x1, 0x74(%r12)
jne 0x974c9
leaq 0x7a804(%rip), %rsi     # 0x111c5f
leaq 0x10(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x2e014
leaq 0x4dc11(%rip), %rsi     # 0xe5082
leaq 0x7a821(%rip), %rdx     # 0x111c99
leaq 0x810(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
addq $0x32a, %rbx            # imm = 0x32A
leaq 0x4db99(%rip), %rsi     # 0xe5034
leaq 0x7a7a1(%rip), %rdx     # 0x111c43
movq %rbx, %rdi
movl $0xc9e, %ecx            # imm = 0xC9E
movq %r15, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %rax
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 0x4dd19(%rip), %xmm0    # 0xe5230
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 0x974b7
movl 0x74(%r12), %eax
cmpl $0x1, %eax
je 0x97657
testl %eax, %eax
jne 0x97439
movsd 0x10(%r12), %xmm0
mulsd 0x77d3d(%rip), %xmm0    # 0x10f328
mulsd 0x18(%r12), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x97703
sqrtsd %xmm0, %xmm0
jmp 0x97708
movslq 0x2d8(%rbx), %rax
movsd (%r15,%rax,8), %xmm1
movsd 0x4e692(%rip), %xmm0    # 0xe5cb0
mulsd %xmm1, %xmm0
movsd 0x10(%r12), %xmm2
mulsd 0x18(%r12), %xmm2
mulsd %xmm1, %xmm0
addsd %xmm2, %xmm0
mulsd 0x77ce8(%rip), %xmm0    # 0x10f328
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x97744
sqrtsd %xmm0, %xmm0
jmp 0x97749
movslq 0x2d0(%rbx), %rax
movsd (%r13), %xmm0
mulsd 0x77cbc(%rip), %xmm0    # 0x10f328
movsd (%r15,%rax,8), %xmm2
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x97877
sqrtsd %xmm0, %xmm0
jmp 0x97888
movslq 0x2d8(%rbx), %rax
jmp 0x977a8
movsd %xmm2, 0x8(%rsp)
callq 0x82d0
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 0x50d59(%rip), %xmm1    # 0xe8440
divsd (%r15,%rcx,8), %xmm1
mulsd %xmm0, %xmm1
subsd 0x20(%r12), %xmm1
movsd %xmm1, (%r14,%rax,8)
jmp 0x977a8
callq 0x82d0
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 0x50d08(%rip), %xmm0    # 0xe8440
divsd 0x30(%r12), %xmm0
jmp 0x978bc
callq 0x82d0
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 0x4efa5(%rip), %xmm2    # 0xe6738
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 0x4ef61(%rip), %xmm6    # 0xe6740
mulsd %xmm0, %xmm6
movsd 0x50c0d(%rip), %xmm1    # 0xe83f8
movapd %xmm0, %xmm5
mulsd %xmm1, %xmm5
divsd %xmm3, %xmm5
mulsd %xmm2, %xmm5
mulsd 0x20(%r12), %xmm5
mulsd %xmm0, %xmm6
addsd %xmm5, %xmm6
mulsd 0x77b86(%rip), %xmm6    # 0x10f398
addsd %xmm4, %xmm6
movsd %xmm6, 0x8(%rsp)
callq 0x8650
mulsd 0x77b77(%rip), %xmm0    # 0x10f3a0
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 0x77b32(%rip), %xmm1    # 0x10f398
mulsd %xmm0, %xmm1
mulsd %xmm0, %xmm1
addsd %xmm1, %xmm2
jmp 0x97432
movsd %xmm2, 0x8(%rsp)
callq 0x82d0
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 0x50b91(%rip), %xmm0    # 0xe8440
divsd 0x30(%r12), %xmm0
mulsd (%r15,%rax,8), %xmm0
movslq 0x2d4(%rbx), %rax
movsd %xmm0, (%r14,%rax,8)
jmp 0x97439