// File: /workspace/github_c_makefile_star2_O1/PoulinV[P]AxiCLASS/build/../source/primordial.c
// Function: primordial_inflation_potential
int primordial_inflation_potential(
                                   struct primordial * ppm,
                                   double phi,
                                   double * V,
                                   double * dV,
                                   double * ddV
                                   ) {

  double e,de,dde,mu,dmu,ddmu,l,dl,ddl,p,dp,ddp;

  switch (ppm->potential) {

    /* V(phi)=polynomial in phi */
  case polynomial:

    *V   = ppm->V0+phi*ppm->V1+pow(phi,2)/2.*ppm->V2+pow(phi,3)/6.*ppm->V3+pow(phi,4)/24.*ppm->V4;
    *dV  = ppm->V1+phi*ppm->V2+pow(phi,2)/2.*ppm->V3+pow(phi,3)/6.*ppm->V4;
    *ddV = ppm->V2+phi*ppm->V3+pow(phi,2)/2.*ppm->V4;
    break;

    /* V(phi) = Lambda^4(1+cos(phi/f)) = V0 (1+cos(phi/V1)) */
  case natural:

    *V   = ppm->V0*(1.+cos(phi/ppm->V1));
    *dV  = -ppm->V0/ppm->V1*sin(phi/ppm->V1);
    *ddV = -ppm->V0/ppm->V1/ppm->V1*cos(phi/ppm->V1);
    break;

    /* Higgs inflation from arXiv:1403.6078 */
  case higgs_inflation:

    // correspondence with 1403.6078:
    // V0 = b
    // V1 = ksi
    // V2 = kappa
    // V3 = delta_lambda
    // mu = bar(mu)/M_P
    // phi = -chi/M_P

    e = exp(2./sqrt(6.)*sqrt(8.*_PI_)*phi);
    de = 2./sqrt(6.)*sqrt(8.*_PI_)*e;
    dde = 2./3. * 8.*_PI_ * e;

    mu = pow(1.-e,0.5);
    dmu = -0.5*de*pow(1.-e,-0.5);
    ddmu = -0.5*dde*pow(1.-e,-0.5)-0.25*de*de*pow(1.-e,-1.5);

    l = log(mu/ppm->V2);
    dl = dmu/mu;
    ddl = ddmu/mu - dl*dl;

    p = 1./16. + ppm->V3/ppm->V0 + l*l;
    dp = 2.*dl*l;
    ddp = 2.*ddl*l+2.*dl*dl;

    *V = ppm->V0/4./pow(8.*_PI_,2)/ppm->V1/ppm->V1*p*pow(mu,4);
    *dV = ppm->V0/4./pow(8.*_PI_,2)/ppm->V1/ppm->V1*(dp*pow(mu,4)+4.*p*dmu*pow(mu,3));
    *ddV = ppm->V0/4./pow(8.*_PI_,2)/ppm->V1/ppm->V1*(ddp*pow(mu,4)+8.*dp*dmu*pow(mu,3)+4.*p*ddmu*pow(mu,3)+12.*p*pow(dmu*mu,2));

    //fprintf(stderr,"%e  %e  %e\n",*V,p,mu);

    break;

    /* code here other shapes */

  default:
    class_stop(ppm->error_message,"ppm->potential=%d different from all known cases",ppm->potential);
    break;
  }

  return _SUCCESS_;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x1068, %rsp           # imm = 0x1068
movq %rcx, %rbx
movq %rdx, %r15
movq %rsi, %r12
movapd %xmm0, %xmm3
movq %rdi, %r14
movl 0x1a8(%rdi), %edx
cmpl $0x2, %edx
je 0x9b441
cmpl $0x1, %edx
je 0x9b382
testl %edx, %edx
jne 0x9b7b4
movsd 0x1b8(%r14), %xmm0
mulsd %xmm3, %xmm0
addsd 0x1b0(%r14), %xmm0
movapd %xmm3, %xmm2
mulsd %xmm3, %xmm2
mulsd 0x56a61(%rip), %xmm2    # 0xf1cd0
movsd %xmm2, 0x30(%rsp)
movsd 0x1c0(%r14), %xmm1
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
movsd 0x573ec(%rip), %xmm1    # 0xf2680
movapd %xmm3, %xmm0
movsd %xmm3, 0x8(%rsp)
callq 0x8620
divsd 0x573c5(%rip), %xmm0    # 0xf2670
mulsd 0x1c8(%r14), %xmm0
addsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x59160(%rip), %xmm1    # 0xf4428
movsd 0x8(%rsp), %xmm0
callq 0x8620
divsd 0x57415(%rip), %xmm0    # 0xf26f0
mulsd 0x1d0(%r14), %xmm0
addsd 0x10(%rsp), %xmm0
movsd %xmm0, (%r12)
movsd 0x1c0(%r14), %xmm1
movsd 0x8(%rsp), %xmm0
mulsd %xmm0, %xmm1
addsd 0x1b8(%r14), %xmm1
movsd 0x1c8(%r14), %xmm2
mulsd 0x30(%rsp), %xmm2
addsd %xmm1, %xmm2
movsd %xmm2, 0x10(%rsp)
movsd 0x57353(%rip), %xmm1    # 0xf2680
callq 0x8620
divsd 0x57336(%rip), %xmm0    # 0xf2670
mulsd 0x1d0(%r14), %xmm0
addsd 0x10(%rsp), %xmm0
movsd %xmm0, (%r15)
movsd 0x8(%rsp), %xmm0
mulsd 0x1c8(%r14), %xmm0
addsd 0x1c0(%r14), %xmm0
movapd %xmm0, %xmm1
movsd 0x30(%rsp), %xmm0
mulsd 0x1d0(%r14), %xmm0
addsd %xmm1, %xmm0
jmp 0x9b438
movsd 0x1b0(%r14), %xmm0
movsd %xmm0, 0x30(%rsp)
movapd %xmm3, %xmm0
divsd 0x1b8(%r14), %xmm0
movsd %xmm3, 0x8(%rsp)
callq 0x86a0
addsd 0x55eaf(%rip), %xmm0    # 0xf1260
mulsd 0x30(%rsp), %xmm0
movsd %xmm0, (%r12)
movsd 0x1b0(%r14), %xmm0
xorpd 0x55e62(%rip), %xmm0    # 0xf1230
movsd 0x1b8(%r14), %xmm1
divsd %xmm1, %xmm0
movapd %xmm0, 0x30(%rsp)
movsd 0x8(%rsp), %xmm0
divsd %xmm1, %xmm0
callq 0x80a0
mulsd 0x30(%rsp), %xmm0
movsd %xmm0, (%r15)
movsd 0x1b0(%r14), %xmm0
xorpd 0x55e24(%rip), %xmm0    # 0xf1230
movsd 0x1b8(%r14), %xmm1
divsd %xmm1, %xmm0
divsd %xmm1, %xmm0
movapd %xmm0, 0x30(%rsp)
movsd 0x8(%rsp), %xmm0
divsd %xmm1, %xmm0
callq 0x86a0
mulsd 0x30(%rsp), %xmm0
movsd %xmm0, (%rbx)
jmp 0x9b7b0
movsd 0x7ffdf(%rip), %xmm0    # 0x11b428
movsd %xmm0, 0x28(%rsp)
mulsd %xmm0, %xmm3
movapd %xmm3, %xmm0
callq 0x8670
movsd 0x28(%rsp), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, 0x28(%rsp)
movsd 0x7ffbc(%rip), %xmm1    # 0x11b430
mulsd %xmm0, %xmm1
movsd %xmm1, 0x20(%rsp)
movsd 0x55dda(%rip), %xmm2    # 0xf1260
subsd %xmm0, %xmm2
movsd %xmm2, 0x18(%rsp)
movsd 0x56838(%rip), %xmm1    # 0xf1cd0
movapd %xmm2, %xmm0
callq 0x8620
movsd %xmm0, 0x8(%rsp)
movsd 0x58fb9(%rip), %xmm1    # 0xf4468
movsd 0x28(%rsp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x30(%rsp)
movsd 0x18(%rsp), %xmm0
callq 0x8620
mulsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
movsd 0x20(%rsp), %xmm0
movsd 0x58f84(%rip), %xmm1    # 0xf4468
mulsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x18(%rsp), %xmm0
callq 0x8620
movsd %xmm0, 0x10(%rsp)
movsd 0x59339(%rip), %xmm1    # 0xf4840
movsd 0x18(%rsp), %xmm0
callq 0x8620
movsd 0x55d6e(%rip), %xmm1    # 0xf1288
movsd 0x28(%rsp), %xmm2
mulsd %xmm2, %xmm1
mulsd %xmm2, %xmm1
mulsd %xmm0, %xmm1
movsd 0x10(%rsp), %xmm0
mulsd 0x20(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x8(%rsp), %xmm0
divsd 0x1c0(%r14), %xmm0
callq 0x82c0
movsd 0x30(%rsp), %xmm2
movsd 0x8(%rsp), %xmm4
divsd %xmm4, %xmm2
movsd 0x10(%rsp), %xmm3
divsd %xmm4, %xmm3
movapd %xmm2, %xmm1
mulsd %xmm2, %xmm1
subsd %xmm1, %xmm3
movapd %xmm3, %xmm5
movsd 0x1c8(%r14), %xmm3
movsd 0x1b0(%r14), %xmm7
movsd 0x1b8(%r14), %xmm1
divsd %xmm7, %xmm3
addsd 0x7fe91(%rip), %xmm3    # 0x11b438
movapd %xmm2, %xmm6
addsd %xmm2, %xmm6
addsd %xmm5, %xmm5
mulsd %xmm6, %xmm2
mulsd %xmm0, %xmm6
movsd %xmm6, 0x28(%rsp)
mulsd %xmm0, %xmm5
mulsd %xmm0, %xmm0
addsd %xmm3, %xmm0
movsd %xmm0, 0x48(%rsp)
addsd %xmm2, %xmm5
movsd %xmm5, 0x58(%rsp)
mulsd 0x58f8b(%rip), %xmm7    # 0xf4570
divsd 0x5a69b(%rip), %xmm7    # 0xf5c88
divsd %xmm1, %xmm7
divsd %xmm1, %xmm7
mulsd %xmm0, %xmm7
movsd %xmm7, 0x20(%rsp)
movsd 0x58e21(%rip), %xmm1    # 0xf4428
movapd %xmm4, %xmm0
callq 0x8620
mulsd 0x20(%rsp), %xmm0
movsd %xmm0, (%r12)
movsd 0x1b0(%r14), %xmm1
mulsd 0x58f43(%rip), %xmm1    # 0xf4570
divsd 0x5a653(%rip), %xmm1    # 0xf5c88
movsd 0x1b8(%r14), %xmm0
divsd %xmm0, %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x18(%rsp)
movsd 0x8(%rsp), %xmm0
movsd 0x58dce(%rip), %xmm1    # 0xf4428
callq 0x8620
movsd %xmm0, 0x40(%rsp)
movsd 0x48(%rsp), %xmm0
mulsd 0x58db5(%rip), %xmm0    # 0xf4428
movsd %xmm0, 0x20(%rsp)
movsd 0x30(%rsp), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, 0x50(%rsp)
movsd 0x56fef(%rip), %xmm1    # 0xf2680
movsd 0x8(%rsp), %xmm0
callq 0x8620
mulsd 0x50(%rsp), %xmm0
movsd 0x40(%rsp), %xmm1
mulsd 0x28(%rsp), %xmm1
addsd %xmm0, %xmm1
mulsd 0x18(%rsp), %xmm1
movsd %xmm1, (%r15)
movsd 0x58eab(%rip), %xmm1    # 0xf4570
mulsd 0x1b0(%r14), %xmm1
divsd 0x5a5b2(%rip), %xmm1    # 0xf5c88
movsd 0x1b8(%r14), %xmm0
divsd %xmm0, %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x40(%rsp)
movsd 0x8(%rsp), %xmm0
movsd 0x58d2d(%rip), %xmm1    # 0xf4428
callq 0x8620
movsd %xmm0, 0x18(%rsp)
movsd 0x28(%rsp), %xmm0
mulsd 0x58d4c(%rip), %xmm0    # 0xf4460
mulsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x8(%rsp), %xmm0
movsd 0x56f52(%rip), %xmm1    # 0xf2680
callq 0x8620
mulsd 0x28(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
mulsd 0x58(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x18(%rsp)
movsd 0x20(%rsp), %xmm0
mulsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x8(%rsp), %xmm0
movsd 0x56f11(%rip), %xmm1    # 0xf2680
callq 0x8620
mulsd 0x20(%rsp), %xmm0
movsd 0x48(%rsp), %xmm2
mulsd 0x72348(%rip), %xmm2    # 0x10dad0
addsd 0x18(%rsp), %xmm0
movsd 0x30(%rsp), %xmm1
mulsd 0x8(%rsp), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
mulsd 0x40(%rsp), %xmm1
movsd %xmm1, (%rbx)
xorl %eax, %eax
jmp 0x9b812
leaq 0x80bd3(%rip), %rsi     # 0x11c38e
leaq 0x860(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x30c2c
leaq 0x55db1(%rip), %rsi     # 0xf1585
leaq 0x60(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x30c2c
addq $0x32a, %r14            # imm = 0x32A
leaq 0x55840(%rip), %rsi     # 0xf1034
leaq 0x80bc4(%rip), %rdx     # 0x11c3bf
movq %r14, %rdi
movl $0x43c, %ecx            # imm = 0x43C
movq %r15, %r8
xorl %eax, %eax
callq 0x30c2c
movl $0x1, %eax
addq $0x1068, %rsp           # imm = 0x1068
popq %rbx
popq %r12
popq %r14
popq %r15
retq