/*
  Generated from python/gga_exc/gga_x_ev93.py via
  python/libxc_codegen.py with Python 3.9.25, SymPy 1.14.0.
  Do not edit -- regenerate via
  scripts/sympy2c/compile.py gga_x_ev93
*/

#ifndef _GGA_X_EV93_KERNEL_BODY
#define maple2c_order 4
#define MAPLE2C_FLAGS (XC_FLAGS_I_HAVE_EXC | XC_FLAGS_I_HAVE_VXC | XC_FLAGS_I_HAVE_FXC | XC_FLAGS_I_HAVE_KXC | XC_FLAGS_I_HAVE_LXC)

/* ---- top-level dispatch ---- */

#define _GGA_X_EV93_KERNEL_BODY
#define _KMAX 0
#define _GGA_X_EV93_HELPER_BODIES
#include "gga_x_ev93.c"
#undef _GGA_X_EV93_HELPER_BODIES
#undef _KMAX
#if XC_MAXORDER >= 1
#define _KMAX 1
#define _GGA_X_EV93_HELPER_BODIES
#include "gga_x_ev93.c"
#undef _GGA_X_EV93_HELPER_BODIES
#undef _KMAX
#endif
#if XC_MAXORDER >= 2
#define _KMAX 2
#define _GGA_X_EV93_HELPER_BODIES
#include "gga_x_ev93.c"
#undef _GGA_X_EV93_HELPER_BODIES
#undef _KMAX
#endif
#if XC_MAXORDER >= 3
#define _KMAX 3
#define _GGA_X_EV93_HELPER_BODIES
#include "gga_x_ev93.c"
#undef _GGA_X_EV93_HELPER_BODIES
#undef _KMAX
#endif
#if XC_MAXORDER >= 4
#define _KMAX 4
#define _GGA_X_EV93_HELPER_BODIES
#include "gga_x_ev93.c"
#undef _GGA_X_EV93_HELPER_BODIES
#undef _KMAX
#endif
#define _KMAX 0
#define _SPIN_UNPOL 1
#define FUNC_NAME func_exc_unpol
#include "gga_x_ev93.c"
#undef _KMAX
#undef _SPIN_UNPOL
#undef FUNC_NAME
#define _KMAX 0
#define _SPIN_UNPOL 0
#define FUNC_NAME func_exc_pol
#include "gga_x_ev93.c"
#undef _KMAX
#undef _SPIN_UNPOL
#undef FUNC_NAME
#if XC_MAXORDER >= 1
#define _KMAX 1
#define _SPIN_UNPOL 1
#define FUNC_NAME func_vxc_unpol
#include "gga_x_ev93.c"
#undef _KMAX
#undef _SPIN_UNPOL
#undef FUNC_NAME
#endif
#if XC_MAXORDER >= 1
#define _KMAX 1
#define _SPIN_UNPOL 0
#define FUNC_NAME func_vxc_pol
#include "gga_x_ev93.c"
#undef _KMAX
#undef _SPIN_UNPOL
#undef FUNC_NAME
#endif
#if XC_MAXORDER >= 2
#define _KMAX 2
#define _SPIN_UNPOL 1
#define FUNC_NAME func_fxc_unpol
#include "gga_x_ev93.c"
#undef _KMAX
#undef _SPIN_UNPOL
#undef FUNC_NAME
#endif
#if XC_MAXORDER >= 2
#define _KMAX 2
#define _SPIN_UNPOL 0
#define FUNC_NAME func_fxc_pol
#include "gga_x_ev93.c"
#undef _KMAX
#undef _SPIN_UNPOL
#undef FUNC_NAME
#endif
#if XC_MAXORDER >= 3
#define _KMAX 3
#define _SPIN_UNPOL 1
#define FUNC_NAME func_kxc_unpol
#include "gga_x_ev93.c"
#undef _KMAX
#undef _SPIN_UNPOL
#undef FUNC_NAME
#endif
#if XC_MAXORDER >= 3
#define _KMAX 3
#define _SPIN_UNPOL 0
#define FUNC_NAME func_kxc_pol
#include "gga_x_ev93.c"
#undef _KMAX
#undef _SPIN_UNPOL
#undef FUNC_NAME
#endif
#if XC_MAXORDER >= 4
#define _KMAX 4
#define _SPIN_UNPOL 1
#define FUNC_NAME func_lxc_unpol
#include "gga_x_ev93.c"
#undef _KMAX
#undef _SPIN_UNPOL
#undef FUNC_NAME
#endif
#if XC_MAXORDER >= 4
#define _KMAX 4
#define _SPIN_UNPOL 0
#define FUNC_NAME func_lxc_pol
#include "gga_x_ev93.c"
#undef _KMAX
#undef _SPIN_UNPOL
#undef FUNC_NAME
#endif
#elif defined(_GGA_X_EV93_HELPER_BODIES)

/* ---- helpers (one graded body -> <name>_k<order>) ---- */

GPU_DEVICE_FUNCTION static inline void XC_CAT(opz_pow_n_4_3_k, _KMAX)(const xc_func_type *p, double z, double *out) {

  const double _t1 = z + 0.1e1;
  const double _t2 = _t1 <= p->zeta_threshold;

  const double f = my_piecewise3(_t2, xc_powr(p->zeta_threshold, 4, 3), xc_powr(_t1, 4, 3));
  out[0] = f;
#if _KMAX >= 1
  const double df_dz = my_piecewise3(_t2, 0, (0.4e1 / 0.3e1)*xc_powr(_t1, 1, 3));
  out[1] = df_dz;
#endif
#if _KMAX >= 2
  const double d2f_dz2 = my_piecewise3(_t2, 0, (0.4e1 / 0.9e1)/xc_powr(_t1, 2, 3));
  out[2] = d2f_dz2;
#endif
#if _KMAX >= 3
  const double d3f_dz3 = my_piecewise3(_t2, 0, -(0.8e1 / 0.27e2)/xc_powr(_t1, 5, 3));
  out[3] = d3f_dz3;
#endif
#if _KMAX >= 4
  const double d4f_dz4 = my_piecewise3(_t2, 0, (0.40e2 / 0.81e2)/xc_powr(_t1, 8, 3));
  out[4] = d4f_dz4;
#endif
}

GPU_DEVICE_FUNCTION static inline void XC_CAT(lda_x_spin_k, _KMAX)(const xc_func_type *p, double rs, double z, double *out) {

  double _hc0[(_KMAX) >= 4 ? 5 : (_KMAX) >= 3 ? 4 : (_KMAX) >= 2 ? 3 : (_KMAX) >= 1 ? 2 : 1];
  XC_CAT(opz_pow_n_4_3_k, _KMAX)(p, z, _hc0);
  const double _t1 = xc_powr(0.6e1, 1, 3)*M_CBRT3/(M_CBRTPI*M_CBRTPI);
  const double _t2 = (0.3e1 / 0.16e2)*_t1;
  const double _t3 = _t2/rs;
#if _KMAX >= 1
  const double _t4 = _t2/(rs * rs);
#endif
#if _KMAX >= 2
  const double _t5 = _hc0[0]*_t1;
  const double _t6 = (0.3e1 / 0.8e1)/(rs * rs * rs);
#endif
#if _KMAX >= 3
  const double _t7 = _t1*_t6;
  const double _t8 = (0.9e1 / 0.8e1)/(rs * rs * rs * rs);
#endif

  const double f = -_hc0[0]*_t3;
  out[0] = f;
#if _KMAX >= 1
  const double df_dz = -_hc0[1]*_t3;
  out[1] = df_dz;
  const double df_drs = _hc0[0]*_t4;
  out[2] = df_drs;
#endif
#if _KMAX >= 2
  const double d2f_dz2 = -_hc0[2]*_t3;
  out[3] = d2f_dz2;
  const double d2f_drs_dz = _hc0[1]*_t4;
  out[4] = d2f_drs_dz;
  const double d2f_drs2 = -_t5*_t6;
  out[5] = d2f_drs2;
#endif
#if _KMAX >= 3
  const double d3f_dz3 = -_hc0[3]*_t3;
  out[6] = d3f_dz3;
  const double d3f_drs_dz2 = _hc0[2]*_t4;
  out[7] = d3f_drs_dz2;
  const double d3f_drs2_dz = -_hc0[1]*_t7;
  out[8] = d3f_drs2_dz;
  const double d3f_drs3 = _t5*_t8;
  out[9] = d3f_drs3;
#endif
#if _KMAX >= 4
  const double d4f_dz4 = -_hc0[4]*_t3;
  out[10] = d4f_dz4;
  const double d4f_drs_dz3 = _hc0[3]*_t4;
  out[11] = d4f_drs_dz3;
  const double d4f_drs2_dz2 = -_hc0[2]*_t7;
  out[12] = d4f_drs2_dz2;
  const double d4f_drs3_dz = _hc0[1]*_t1*_t8;
  out[13] = d4f_drs3_dz;
  const double d4f_drs4 = -0.9e1 / 0.2e1*_t5/xc_powi(rs, 5);
  out[14] = d4f_drs4;
#endif
}

GPU_DEVICE_FUNCTION static inline void XC_CAT(xchan_k, _KMAX)(const xc_func_type *p, double n_s, double sigma_ss, double *out) {
  const gga_x_ev93_params *params = (const gga_x_ev93_params *)(p->params);

  const double _t1 = xc_powr(0.6e1, 1, 3);
  const double _t2 = _t1/M_CBRTPI;
  const double _t3 = (0.1e1 / 0.2e1)*_t2;
  const double _t4 = -p->dens_threshold + n_s <= 0;
  const double _t5 = (sigma_ss * sigma_ss * sigma_ss);
  const double _t6 = (0.1e1 / (M_PI * M_PI * M_PI * M_PI));
  const double _t7 = _t6/xc_powi(n_s, 8);
  const double _t8 = _t5*_t7;
  const double _t9 = (0.1e1 / 0.2304e4)*params->a3;
  const double _t10 = xc_powr(n_s, -8, 3);
  const double _t11 = _t1/(M_PI * M_CBRTPI);
  const double _t12 = _t10*_t11;
  const double _t13 = (0.1e1 / 0.24e2)*_t12;
  const double _t14 = _t13*params->a1;
  const double _t15 = xc_powr(n_s, -16, 3);
  const double _t16 = xc_powr(0.6e1, 2, 3);
  const double _t17 = _t16/(M_PI * M_PI * M_CBRTPI * M_CBRTPI);
  const double _t18 = _t15*_t17;
  const double _t19 = (sigma_ss * sigma_ss);
  const double _t20 = (0.1e1 / 0.576e3)*_t19;
  const double _t21 = _t14*sigma_ss + _t18*_t20*params->a2 + _t8*_t9 + 0.1e1;
  const double _t22 = (0.1e1 / 0.2304e4)*params->b3;
  const double _t23 = _t13*params->b1;
  const double _t24 = _t18*params->b2;
  const double _t25 = _t20*_t24 + _t22*_t8 + _t23*sigma_ss + 0.1e1;
  const double _t26 = (0.1e1 / _t25);
#if _KMAX >= 1
  const double _t29 = _t7*params->a3;
  const double _t30 = (0.1e1 / 0.768e3)*_t19;
  const double _t31 = (0.1e1 / 0.288e3)*_t18;
  const double _t32 = _t31*params->a2;
  const double _t33 = _t14 + _t29*_t30 + _t32*sigma_ss;
  const double _t34 = (0.1e1 / (_t25 * _t25));
  const double _t36 = _t7*params->b3;
  const double _t37 = _t31*params->b2;
  const double _t38 = -_t23 - _t30*_t36 - _t37*sigma_ss;
  const double _t39 = _t21*_t38;
  const double _t41 = _t6/xc_powi(n_s, 9);
  const double _t42 = _t41*params->a3;
  const double _t43 = (0.1e1 / 0.288e3)*_t5;
  const double _t44 = _t11*params->a1;
  const double _t45 = xc_powr(n_s, -11, 3);
  const double _t46 = (0.1e1 / 0.9e1)*_t45;
  const double _t47 = _t44*_t46;
  const double _t48 = xc_powr(n_s, -19, 3);
  const double _t49 = _t17*params->a2;
  const double _t50 = (0.1e1 / 0.108e3)*_t19;
  const double _t51 = -_t42*_t43 - _t47*sigma_ss - _t48*_t49*_t50;
  const double _t52 = _t21*_t26;
  const double _t53 = xc_powr(n_s, -4, 3);
  const double _t57 = _t41*params->b3;
  const double _t58 = _t11*params->b1;
  const double _t59 = _t46*_t58;
  const double _t60 = _t17*params->b2;
  const double _t61 = _t48*_t60;
  const double _t62 = _t43*_t57 + _t50*_t61 + _t59*sigma_ss;
#endif
#if _KMAX >= 2
  const double _t65 = (0.1e1 / 0.384e3)*sigma_ss;
  const double _t66 = _t29*_t65 + _t32;
  const double _t67 = -_t36*_t65 - _t37;
  const double _t70 = (0.1e1 / (_t25 * _t25 * _t25));
  const double _t72 = _t12*params->b1;
  const double _t73 = _t19*_t36;
  const double _t74 = (0.1e1 / 0.144e3)*_t24;
  const double _t75 = -0.1e1 / 0.12e2*_t72 - 0.1e1 / 0.384e3*_t73 - _t74*sigma_ss;
  const double _t76 = _t39*_t75;
  const double _t78 = (0.1e1 / 0.96e2)*_t19;
  const double _t79 = (0.1e1 / 0.54e2)*_t48;
  const double _t80 = _t49*_t79;
  const double _t81 = -_t42*_t78 - _t47 - _t80*sigma_ss;
  const double _t85 = _t60*_t79;
  const double _t86 = _t57*_t78 + _t59 + _t85*sigma_ss;
  const double _t89 = _t21*_t62;
  const double _t91 = _t6/xc_powi(n_s, 10);
  const double _t92 = _t91*params->a3;
  const double _t93 = (0.1e1 / 0.32e2)*_t5;
  const double _t94 = xc_powr(n_s, -14, 3);
  const double _t95 = (0.11e2 / 0.27e2)*_t94;
  const double _t96 = _t44*_t95;
  const double _t97 = _t19*_t49;
  const double _t98 = xc_powr(n_s, -22, 3);
  const double _t99 = (0.19e2 / 0.324e3)*_t98;
  const double _t100 = _t92*_t93 + _t96*sigma_ss + _t97*_t99;
  const double _t101 = _t26*_t51;
  const double _t103 = (0.2e1 / 0.9e1)*_t52;
  const double _t105 = (0.1e1 / 0.36e2)*_t52;
  const double _t108 = _t91*params->b3;
  const double _t109 = _t58*_t95;
  const double _t110 = _t19*_t60;
  const double _t111 = -_t108*_t93 - _t109*sigma_ss - _t110*_t99;
  const double _t114 = _t5*_t57;
  const double _t115 = _t45*_t58;
  const double _t116 = (0.2e1 / 0.9e1)*_t115;
  const double _t117 = (0.1e1 / 0.144e3)*_t114 + _t116*sigma_ss + _t19*_t85;
#endif
#if _KMAX >= 3
  const double _t120 = (0.1e1 / 0.384e3)*_t29;
  const double _t121 = (0.1e1 / 0.384e3)*_t36;
  const double _t124 = 0.3e1*_t67;
  const double _t125 = _t36*sigma_ss;
  const double _t126 = -0.1e1 / 0.192e3*_t125 - _t74;
  const double _t129 = 0.2e1*_t67;
  const double _t131 = (0.1e1 / 0.96e2)*_t24;
  const double _t132 = -_t131*sigma_ss - 0.1e1 / 0.8e1*_t72 - 0.1e1 / 0.256e3*_t73;
  const double _t133 = (0.1e1 / (_t25 * _t25 * _t25 * _t25));
  const double _t137 = (0.1e1 / 0.48e2)*sigma_ss;
  const double _t138 = -_t137*_t42 - _t80;
  const double _t139 = _t137*_t57 + _t85;
  const double _t140 = _t21*_t67;
  const double _t142 = _t33*_t38;
  const double _t143 = _t38*_t51;
  const double _t144 = _t33*_t62;
  const double _t146 = _t21*_t86;
  const double _t150 = (0.3e1 / 0.32e2)*_t19;
  const double _t151 = (0.19e2 / 0.162e3)*_t98;
  const double _t152 = _t151*_t49;
  const double _t153 = _t150*_t92 + _t152*sigma_ss + _t96;
  const double _t154 = _t26*_t33;
  const double _t157 = (0.1e1 / 0.36e2)*_t33;
  const double _t161 = _t151*_t60;
  const double _t162 = -_t108*_t150 - _t109 - _t161*sigma_ss;
  const double _t165 = (0.1e1 / 0.36e2)*_t39;
  const double _t169 = _t111*_t21;
  const double _t170 = _t51*_t62;
  const double _t171 = _t19*_t57;
  const double _t172 = (0.1e1 / 0.27e2)*_t61;
  const double _t173 = _t116 + (0.1e1 / 0.48e2)*_t171 + _t172*sigma_ss;
  const double _t174 = _t70*_t75;
  const double _t177 = _t6/xc_powi(n_s, 11);
  const double _t178 = _t177*params->a3;
  const double _t179 = (0.5e1 / 0.16e2)*_t5;
  const double _t180 = xc_powr(n_s, -17, 3);
  const double _t181 = (0.154e3 / 0.81e2)*_t180;
  const double _t182 = _t181*_t44;
  const double _t183 = xc_powr(n_s, -25, 3);
  const double _t184 = (0.209e3 / 0.486e3)*_t183;
  const double _t185 = -_t178*_t179 - _t182*sigma_ss - _t184*_t97;
  const double _t186 = (0.1e1 / M_PI);
  const double _t190 = _t3*_t53;
  const double _t196 = _t177*params->b3;
  const double _t197 = _t181*_t58;
  const double _t198 = _t110*_t184 + _t179*_t196 + _t197*sigma_ss;
  const double _t202 = _t34*_t89;
  const double _t205 = _t108*_t5;
  const double _t206 = _t58*_t94;
  const double _t207 = (0.22e2 / 0.27e2)*_t206;
  const double _t208 = -_t161*_t19 - 0.1e1 / 0.16e2*_t205 - _t207*sigma_ss;
  const double _t209 = 0.3e1*_t51;
  const double _t212 = _t70*_t89;
  const double _t213 = _t117*_t212;
  const double _t214 = (0.1e1 / 0.3e1)*_t115;
  const double _t215 = (0.1e1 / 0.96e2)*_t114 + (0.1e1 / 0.36e2)*_t19*_t61 + _t214*sigma_ss;
#endif
#if _KMAX >= 4
  const double _t220 = (0.1e1 / 0.192e3)*_t36;
  const double _t221 = _t124*_t21;
  const double _t222 = 0.4e1*_t142;
  const double _t224 = -0.1e1 / 0.128e3*_t125 - _t131;
  const double _t225 = 0.2e1*_t126;
  const double _t227 = _t132*_t76;
  const double _t230 = xc_powr(n_s, -28, 3);
  const double _t231 = _t1*_t230/(M_PI * M_PI * M_PI * M_PI * M_CBRTPI);
  const double _t232 = 0.3e1*_t139;
  const double _t233 = 0.3e1*_t86;
  const double _t240 = 0.3e1*_t81;
  const double _t245 = (0.3e1 / 0.16e2)*sigma_ss;
  const double _t246 = 0.4e1*_t86;
  const double _t249 = _t33*_t86;
  const double _t252 = 0.2e1*_t170;
  const double _t253 = _t111*_t33;
  const double _t256 = 0.2e1*_t162;
  const double _t257 = 0.2e1*_t146;
  const double _t260 = _t70*_t76;
  const double _t263 = _t132*_t133*_t89;
  const double _t264 = (0.15e2 / 0.16e2)*_t19;
  const double _t265 = (0.209e3 / 0.243e3)*_t183;
  const double _t266 = _t265*sigma_ss;
  const double _t272 = _t34*_t39;
  const double _t275 = 0.3e1*_t170;
  const double _t276 = _t117*_t70;
  const double _t278 = _t174*_t89;
  const double _t279 = _t117*_t215;
  const double _t282 = (0.55e2 / 0.16e2)*_t5*_t6/xc_powi(n_s, 12);
  const double _t283 = (0.2618e4 / 0.243e3)*sigma_ss/xc_powr(n_s, 20, 3);
  const double _t284 = (0.5225e4 / 0.1458e4)*_t230;
  const double _t288 = 0.4e1*_t170;
  const double _t289 = 0.3e1*_t169;
  const double _t291 = _t279*_t89;
#endif
  double _hc0[(_KMAX) >= 4 ? 15 : (_KMAX) >= 3 ? 10 : (_KMAX) >= 2 ? 6 : (_KMAX) >= 1 ? 3 : 1] = {0.};
  if(!(_t4)) XC_CAT(lda_x_spin_k, _KMAX)(p, _t3/xc_powr(n_s, 1, 3), 0.1e1 - p->zeta_threshold, _hc0);
  const double _t27 = _hc0[0]*_t26;
  const double _t28 = my_piecewise3(_t4, 0, _t21*_t27);
#if _KMAX >= 1
  const double _t35 = _hc0[0]*_t34;
  const double _t40 = my_piecewise3(_t4, 0, _t27*_t33 + _t35*_t39);
  const double _t54 = _hc0[2]*_t2;
  const double _t55 = _t53*_t54;
  const double _t56 = (0.1e1 / 0.6e1)*_t55;
  const double _t63 = _t21*_t35;
  const double _t64 = my_piecewise3(_t4, 0, _t27*_t51 - _t52*_t56 + _t62*_t63);
#endif
#if _KMAX >= 2
  const double _t68 = _t35*_t38;
  const double _t69 = 0.2e1*_t68;
  const double _t71 = _hc0[0]*_t70;
  const double _t77 = my_piecewise3(_t4, 0, _t27*_t66 + _t33*_t69 + _t63*_t67 + _t71*_t76);
  const double _t82 = _t26*_t56;
  const double _t83 = _t35*_t51;
  const double _t84 = _t35*_t62;
  const double _t87 = _t34*_t56;
  const double _t88 = _t71*_t75;
  const double _t90 = my_piecewise3(_t4, 0, _t27*_t81 - _t33*_t82 + _t33*_t84 + _t38*_t83 - _t39*_t87 + _t63*_t86 + _t88*_t89);
  const double _t102 = (0.1e1 / 0.3e1)*_t55;
  const double _t104 = _t54/xc_powr(n_s, 7, 3);
  const double _t106 = _hc0[5]*_t16/(M_CBRTPI * M_CBRTPI);
  const double _t107 = _t10*_t106;
  const double _t112 = 0.2e1*_t83;
  const double _t113 = _t102*_t34;
  const double _t118 = _t71*_t89;
  const double _t119 = my_piecewise3(_t4, 0, _t100*_t27 - _t101*_t102 + _t103*_t104 + _t105*_t107 + _t111*_t63 + _t112*_t62 - _t113*_t89 + _t117*_t118);
#endif
#if _KMAX >= 3
  const double _t122 = 0.3e1*_t68;
  const double _t123 = _t33*_t35;
  const double _t127 = _t126*_t71;
  const double _t128 = _t21*_t88;
  const double _t130 = _t38*_t88;
  const double _t134 = _hc0[0]*_t133;
  const double _t135 = _t132*_t134;
  const double _t136 = my_piecewise3(_t4, 0, _t120*_t27 - _t121*_t63 + _t122*_t66 + _t123*_t124 + _t127*_t39 + _t128*_t129 + 0.3e1*_t130*_t33 + _t135*_t76);
  const double _t141 = 0.2e1*_t123;
  const double _t145 = 0.2e1*_t88;
  const double _t147 = _t56*_t70;
  const double _t148 = _t135*_t89;
  const double _t149 = my_piecewise3(_t4, 0, -_t113*_t142 + _t118*_t126 + _t138*_t27 + _t139*_t63 - _t140*_t87 + _t141*_t86 + _t143*_t88 + _t144*_t145 + _t145*_t146 - _t147*_t76 + _t148*_t75 - _t66*_t82 + _t66*_t84 + _t67*_t83 + _t69*_t81);
  const double _t155 = (0.2e1 / 0.9e1)*_t104;
  const double _t156 = _t102*_t26;
  const double _t158 = _t107*_t26;
  const double _t159 = _t100*_t35;
  const double _t160 = _t111*_t35;
  const double _t163 = 0.2e1*_t84;
  const double _t164 = _t155*_t34;
  const double _t166 = _t107*_t34;
  const double _t167 = _t117*_t71;
  const double _t168 = _t167*_t62;
  const double _t175 = _t102*_t174;
  const double _t176 = my_piecewise3(_t4, 0, _t112*_t86 - _t113*_t143 - _t113*_t144 - _t113*_t146 + _t117*_t148 + _t118*_t173 + _t145*_t170 + _t146*_t167 + _t153*_t27 + _t154*_t155 - _t156*_t81 + _t157*_t158 + _t159*_t38 + _t160*_t33 + _t162*_t63 + _t163*_t81 + _t164*_t39 + _t165*_t166 + _t168*_t33 + _t169*_t88 - _t175*_t89);
  const double _t187 = _hc0[9]*_t186/(n_s * n_s * n_s * n_s);
  const double _t188 = (0.2e1 / 0.3e1)*_t104;
  const double _t189 = _hc0[2]*_t26;
  const double _t191 = _t189*_t190;
  const double _t192 = (0.1e1 / 0.12e2)*_t107;
  const double _t193 = _t54/xc_powr(n_s, 10, 3);
  const double _t194 = (0.14e2 / 0.27e2)*_t193;
  const double _t195 = _t106*_t46;
  const double _t199 = 0.3e1*_t84;
  const double _t200 = 0.3e1*_t83;
  const double _t201 = _t34*_t55;
  const double _t203 = _hc0[2]*_t34;
  const double _t204 = _t190*_t203;
  const double _t210 = 0.2e1*_t167;
  const double _t211 = _hc0[2]*_t190;
  const double _t216 = _t134*_t89;
  const double _t217 = _t117*_t216;
  const double _t218 = my_piecewise3(_t4, 0, -_t100*_t191 + _t100*_t199 + _t101*_t188 + _t101*_t192 - _t105*_t187 + _t111*_t200 + _t118*_t208 + _t168*_t209 - _t169*_t204 + _t169*_t210 - _t170*_t201 + _t185*_t27 + _t188*_t202 + _t192*_t202 - _t194*_t52 - _t195*_t52 + _t198*_t63 - _t211*_t213 + _t215*_t217);
#endif
#if _KMAX >= 4
  const double _t219 = _t35*_t66;
  const double _t223 = _t33*_t88;
  const double _t226 = _t135*_t75;
  const double _t228 = _hc0[0]/xc_powi(_t25, 5);
  const double _t229 = _t228*(-0.1e1 / 0.72e2*_t24*sigma_ss - 0.1e1 / 0.6e1*_t72 - 0.1e1 / 0.192e3*_t73);
  const double _t234 = _t35*_t81;
  const double _t235 = _t204*_t38;
  const double _t236 = _t62*_t88;
  const double _t237 = 0.3e1*_t236;
  const double _t238 = 0.3e1*_t127;
  const double _t239 = _t51*_t88;
  const double _t241 = _t174*_t211;
  const double _t242 = 0.3e1*_t226;
  const double _t243 = _t229*_t89;
  const double _t244 = _t132*_t243;
  const double _t247 = _t104*_t34;
  const double _t248 = _t201*_t81;
  const double _t250 = (0.2e1 / 0.3e1)*_t201;
  const double _t251 = _t167*_t21;
  const double _t254 = _t173*_t71;
  const double _t255 = 0.2e1*_t254;
  const double _t258 = (0.2e1 / 0.3e1)*_t55;
  const double _t259 = _t174*_t258;
  const double _t261 = _t117*_t135;
  const double _t262 = 0.2e1*_t261;
  const double _t267 = _t187*_t26;
  const double _t268 = _t187*_t34;
  const double _t269 = _t188*_t34;
  const double _t270 = _t201*_t51;
  const double _t271 = _t192*_t34;
  const double _t273 = _t208*_t71;
  const double _t274 = _t167*_t51;
  const double _t277 = _t211*_t276;
  const double _t280 = _t134*_t279;
  const double _t281 = _t215*_t216;
  const double _t285 = (0.56e2 / 0.27e2)*_t193;
  const double _t286 = (0.4e1 / 0.3e1)*_t104;
  const double _t287 = (0.4e1 / 0.9e1)*_t106*_t45;
  const double _t290 = _t276*_t55;
#endif

  const double f = my_piecewise3(_t4, 0, _t28*n_s);
  out[0] = f;
#if _KMAX >= 1
  const double df_dsigma_ss = my_piecewise3(_t4, 0, _t40*n_s);
  out[1] = df_dsigma_ss;
  const double df_dn_s = my_piecewise3(_t4, 0, _t28 + _t64*n_s);
  out[2] = df_dn_s;
#endif
#if _KMAX >= 2
  const double d2f_dsigma_ss2 = my_piecewise3(_t4, 0, _t77*n_s);
  out[3] = d2f_dsigma_ss2;
  const double d2f_dn_s_dsigma_ss = my_piecewise3(_t4, 0, _t40 + _t90*n_s);
  out[4] = d2f_dn_s_dsigma_ss;
  const double d2f_dn_s2 = my_piecewise3(_t4, 0, _t119*n_s + 0.2e1*_t64);
  out[5] = d2f_dn_s2;
#endif
#if _KMAX >= 3
  const double d3f_dsigma_ss3 = my_piecewise3(_t4, 0, _t136*n_s);
  out[6] = d3f_dsigma_ss3;
  const double d3f_dn_s_dsigma_ss2 = my_piecewise3(_t4, 0, _t149*n_s + _t77);
  out[7] = d3f_dn_s_dsigma_ss2;
  const double d3f_dn_s2_dsigma_ss = my_piecewise3(_t4, 0, _t176*n_s + 0.2e1*_t90);
  out[8] = d3f_dn_s2_dsigma_ss;
  const double d3f_dn_s3 = my_piecewise3(_t4, 0, 0.3e1*_t119 + _t218*n_s);
  out[9] = d3f_dn_s3;
#endif
#if _KMAX >= 4
  const double d4f_dsigma_ss4 = my_piecewise3(_t4, 0, n_s*my_piecewise3(_t4, 0, -0.1e1 / 0.96e2*_t123*_t36 + _t127*_t221 + _t127*_t222 - 0.1e1 / 0.128e3*_t128*_t36 + 0.6e1*_t130*_t66 + _t134*_t224*_t76 + _t135*_t225*_t39 + 0.6e1*_t219*_t67 - _t220*_t39*_t71 + _t221*_t226 + _t222*_t226 + 0.8e1*_t223*_t67 + _t227*_t229 + (0.1e1 / 0.96e2)*_t29*_t68));
  out[10] = d4f_dsigma_ss4;
  const double d4f_dn_s_dsigma_ss3 = my_piecewise3(_t4, 0, _t136 + n_s*my_piecewise3(_t4, 0, -_t118*_t220 + _t120*_t84 - _t121*_t83 + _t122*_t138 + _t123*_t232 + _t124*_t234 - _t126*_t147*_t39 + _t127*_t143 + _t128*_t232 + _t129*_t239 + _t130*_t240 - _t133*_t227*_t56 - _t140*_t175 - _t142*_t241 + _t143*_t226 + _t144*_t238 + _t144*_t242 + _t146*_t238 + _t146*_t242 + _t148*_t225 - _t189*_t231*_t9 + _t203*_t21*_t22*_t231 - _t204*_t33*_t67 + _t216*_t224*_t75 + _t219*_t233 + 0.6e1*_t223*_t86 - _t235*_t66 + _t237*_t66 + _t244*_t75 - 0.1e1 / 0.48e2*_t27*_t42 + (0.1e1 / 0.48e2)*_t57*_t63));
  out[11] = d4f_dn_s_dsigma_ss3;
  const double d4f_dn_s2_dsigma_ss2 = my_piecewise3(_t4, 0, 0.2e1*_t149 + n_s*my_piecewise3(_t4, 0, _t100*_t130 - _t102*_t126*_t212 - _t102*_t263*_t75 + (0.1e1 / 0.36e2)*_t107*_t260 + _t112*_t139 - _t113*_t139*_t21 - _t113*_t51*_t67 - _t113*_t62*_t66 + _t117*_t244 + _t118*(_t172 + (0.1e1 / 0.24e2)*_t57*sigma_ss) + _t127*_t169 + _t127*_t252 + _t128*_t256 - _t138*_t156 + _t138*_t163 + _t139*_t251 + _t140*_t164 + (0.1e1 / 0.36e2)*_t140*_t166 + _t141*_t162 + (0.1e1 / 0.18e2)*_t142*_t166 + (0.4e1 / 0.9e1)*_t142*_t247 - _t143*_t175 + _t144*_t255 - _t144*_t259 + _t144*_t262 + _t145*_t253 - _t146*_t259 + 0.2e1*_t148*_t173 + _t153*_t69 + _t155*_t26*_t66 + _t155*_t260 + (0.1e1 / 0.36e2)*_t158*_t66 + _t159*_t67 + _t160*_t66 + _t168*_t66 + _t169*_t226 + _t210*_t249 + _t217*_t224 + _t226*_t252 + _t234*_t246 + 0.4e1*_t236*_t81 + _t239*_t246 - 0.2e1 / 0.3e1*_t248*_t38 - _t249*_t250 + _t254*_t257 + _t257*_t261 + _t27*(_t152 + _t245*_t92) + _t63*(-_t108*_t245 - _t161)));
  out[12] = d4f_dn_s2_dsigma_ss2;
  const double d4f_dn_s3_dsigma_ss = my_piecewise3(_t4, 0, 0.3e1*_t176 + n_s*my_piecewise3(_t4, 0, -_t100*_t235 + _t100*_t237 + _t111*_t209*_t88 - _t117*_t211*_t263 + _t118*(-0.3e1 / 0.16e2*_t108*_t19 - _t207 - 0.19e2 / 0.81e2*_t60*_t98*sigma_ss) + _t123*_t198 + _t128*_t198 + _t143*_t269 + _t143*_t271 + _t144*_t269 + _t144*_t271 + _t144*_t273 - _t144*_t277 + _t144*_t280 + _t146*_t269 + _t146*_t271 + _t146*_t273 - _t146*_t277 + _t146*_t280 + _t148*_t208 - _t153*_t191 + _t153*_t199 - _t154*_t194 - _t154*_t195 - _t157*_t267 + (0.1e1 / 0.12e2)*_t158*_t81 + _t159*_t233 + _t160*_t240 + _t162*_t200 - _t162*_t204*_t21 - _t165*_t268 + _t168*_t240 - _t169*_t241 + _t169*_t255 + _t169*_t262 - _t170*_t174*_t55 - _t173*_t211*_t212 + _t173*_t281 + _t185*_t68 + _t188*_t26*_t81 + _t188*_t278 + _t192*_t278 - _t194*_t272 - _t195*_t272 - _t204*_t253 + _t210*_t253 + _t217*((0.1e1 / 0.32e2)*_t171 + _t214 + (0.1e1 / 0.18e2)*_t61*sigma_ss) + _t233*_t274 + _t243*_t279 - _t248*_t62 + _t251*_t256 + _t254*_t275 + _t261*_t275 + _t27*(-_t178*_t264 - _t182 - _t266*_t49) - _t270*_t86 + _t63*(_t196*_t264 + _t197 + _t266*_t60)));
  out[13] = d4f_dn_s3_dsigma_ss;
  const double d4f_dn_s4 = my_piecewise3(_t4, 0, 0.4e1*_t218 + n_s*my_piecewise3(_t4, 0, (0.1e1 / 0.216e3)*_hc0[14]*_t11*_t15*_t52 + _hc0[9]*_t103*_t186/xc_powi(n_s, 5) + (0.1e1 / 0.6e1)*_t100*_t158 + 0.6e1*_t100*_t168 - 0.2e1*_t100*_t201*_t62 + _t100*_t26*_t286 - _t101*_t285 - _t101*_t287 + (0.40e2 / 0.81e2)*_t106*_t52*_t94 + (0.1e1 / 0.6e1)*_t107*_t213 + 0.6e1*_t111*_t159 - 0.2e1*_t111*_t270 + 0.8e1*_t111*_t274 + _t118*(_t110*_t265 + (0.308e3 / 0.81e2)*_t180*_t58*sigma_ss + (0.5e1 / 0.8e1)*_t196*_t5) - _t133*_t258*_t291 + (0.1e1 / 0.6e1)*_t166*_t169 + (0.1e1 / 0.3e1)*_t166*_t170 + _t169*_t286*_t34 - 0.4e1 / 0.3e1*_t169*_t290 + (0.8e1 / 0.3e1)*_t170*_t247 - _t185*_t258*_t26 + 0.4e1*_t185*_t84 - _t198*_t21*_t250 + 0.3e1*_t198*_t251 + 0.4e1*_t198*_t83 - _t202*_t285 - _t202*_t287 - _t208*_t212*_t258 + 0.2e1*_t208*_t281 + _t213*_t286 + _t217*(-0.19e2 / 0.108e3*_t110*_t98 - 0.3e1 / 0.32e2*_t205 - 0.11e2 / 0.9e1*_t206*sigma_ss) + _t228*_t291*((0.1e1 / 0.72e2)*_t114 + (0.4e1 / 0.9e1)*_t115*sigma_ss + _t172*_t19) - _t252*_t290 - 0.1e1 / 0.9e1*_t267*_t51 - 0.1e1 / 0.9e1*_t268*_t89 + _t27*(_t282*params->a3 + _t283*_t44 + _t284*_t97) + _t273*_t288 + _t273*_t289 + _t280*_t288 + _t280*_t289 + (0.140e3 / 0.81e2)*_t52*_t54/xc_powr(n_s, 13, 3) + _t63*(-_t110*_t284 - _t282*params->b3 - _t283*_t58)));
  out[14] = d4f_dn_s4;
#endif
}

#else  /* re-inclusion: one graded body -> func_<order>_<spin> */
GPU_DEVICE_FUNCTION static inline void
FUNC_NAME(const xc_func_type *p, size_t ip, const double *rho, const double *sigma, xc_gga_out_params *out)
{
  assert(p->params != NULL);
  const gga_x_ev93_params *params = (const gga_x_ev93_params *)(p->params);
  (void)params;
#if _SPIN_UNPOL
  const double na = rho[0];
  const double gaa = sigma[0];

  double _hc0[(_KMAX) >= 4 ? 15 : (_KMAX) >= 3 ? 10 : (_KMAX) >= 2 ? 6 : (_KMAX) >= 1 ? 3 : 1];
  XC_CAT(xchan_k, _KMAX)(p, (0.1e1 / 0.2e1)*na, (0.1e1 / 0.4e1)*gaa, _hc0);
  const double zk = 0.2e1*_hc0[0]/na;
  if(out->zk != NULL) out->zk[ip*p->dim.zk + 0] += zk;
#if _KMAX >= 1
  const double dF_dna = _hc0[2];
  const double dF_dgaa = (0.1e1 / 0.2e1)*_hc0[1];
  if(out->vrho != NULL) out->vrho[ip*p->dim.vrho + 0] += dF_dna;
  if(out->vsigma != NULL) out->vsigma[ip*p->dim.vsigma + 0] += dF_dgaa;
#endif
#if _KMAX >= 2
  const double d2F_dna2 = (0.1e1 / 0.2e1)*_hc0[5];
  const double d2F_dna_dgaa = (0.1e1 / 0.4e1)*_hc0[4];
  const double d2F_dgaa2 = (0.1e1 / 0.8e1)*_hc0[3];
  if(out->v2rho2 != NULL) out->v2rho2[ip*p->dim.v2rho2 + 0] += d2F_dna2;
  if(out->v2rhosigma != NULL) out->v2rhosigma[ip*p->dim.v2rhosigma + 0] += d2F_dna_dgaa;
  if(out->v2sigma2 != NULL) out->v2sigma2[ip*p->dim.v2sigma2 + 0] += d2F_dgaa2;
#endif
#if _KMAX >= 3
  const double d3F_dna3 = (0.1e1 / 0.4e1)*_hc0[9];
  const double d3F_dna2_dgaa = (0.1e1 / 0.8e1)*_hc0[8];
  const double d3F_dna_dgaa2 = (0.1e1 / 0.16e2)*_hc0[7];
  const double d3F_dgaa3 = (0.1e1 / 0.32e2)*_hc0[6];
  if(out->v3rho3 != NULL) out->v3rho3[ip*p->dim.v3rho3 + 0] += d3F_dna3;
  if(out->v3rho2sigma != NULL) out->v3rho2sigma[ip*p->dim.v3rho2sigma + 0] += d3F_dna2_dgaa;
  if(out->v3rhosigma2 != NULL) out->v3rhosigma2[ip*p->dim.v3rhosigma2 + 0] += d3F_dna_dgaa2;
  if(out->v3sigma3 != NULL) out->v3sigma3[ip*p->dim.v3sigma3 + 0] += d3F_dgaa3;
#endif
#if _KMAX >= 4
  const double d4F_dna4 = (0.1e1 / 0.8e1)*_hc0[14];
  const double d4F_dna3_dgaa = (0.1e1 / 0.16e2)*_hc0[13];
  const double d4F_dna2_dgaa2 = (0.1e1 / 0.32e2)*_hc0[12];
  const double d4F_dna_dgaa3 = (0.1e1 / 0.64e2)*_hc0[11];
  const double d4F_dgaa4 = (0.1e1 / 0.128e3)*_hc0[10];
  if(out->v4rho4 != NULL) out->v4rho4[ip*p->dim.v4rho4 + 0] += d4F_dna4;
  if(out->v4rho3sigma != NULL) out->v4rho3sigma[ip*p->dim.v4rho3sigma + 0] += d4F_dna3_dgaa;
  if(out->v4rho2sigma2 != NULL) out->v4rho2sigma2[ip*p->dim.v4rho2sigma2 + 0] += d4F_dna2_dgaa2;
  if(out->v4rhosigma3 != NULL) out->v4rhosigma3[ip*p->dim.v4rhosigma3 + 0] += d4F_dna_dgaa3;
  if(out->v4sigma4 != NULL) out->v4sigma4[ip*p->dim.v4sigma4 + 0] += d4F_dgaa4;
#endif
#else
  const double na = rho[0];
  const double nb = rho[1];
  const double gaa = sigma[0];
  const double gbb = sigma[2];

  double _hc0[(_KMAX) >= 4 ? 15 : (_KMAX) >= 3 ? 10 : (_KMAX) >= 2 ? 6 : (_KMAX) >= 1 ? 3 : 1];
  XC_CAT(xchan_k, _KMAX)(p, na, gaa, _hc0);
  double _hc1[(_KMAX) >= 4 ? 15 : (_KMAX) >= 3 ? 10 : (_KMAX) >= 2 ? 6 : (_KMAX) >= 1 ? 3 : 1];
  XC_CAT(xchan_k, _KMAX)(p, nb, gbb, _hc1);
  const double zk = (_hc0[0] + _hc1[0])/(na + nb);
  if(out->zk != NULL) out->zk[ip*p->dim.zk + 0] += zk;
#if _KMAX >= 1
  const double dF_dna = _hc0[2];
  const double dF_dnb = _hc1[2];
  const double dF_dgaa = _hc0[1];
  const double dF_dgbb = _hc1[1];
  if(out->vrho != NULL) out->vrho[ip*p->dim.vrho + 0] += dF_dna;
  if(out->vrho != NULL) out->vrho[ip*p->dim.vrho + 1] += dF_dnb;
  if(out->vsigma != NULL) out->vsigma[ip*p->dim.vsigma + 0] += dF_dgaa;
  if(out->vsigma != NULL) out->vsigma[ip*p->dim.vsigma + 2] += dF_dgbb;
#endif
#if _KMAX >= 2
  const double d2F_dna2 = _hc0[5];
  const double d2F_dnb2 = _hc1[5];
  const double d2F_dna_dgaa = _hc0[4];
  const double d2F_dnb_dgbb = _hc1[4];
  const double d2F_dgaa2 = _hc0[3];
  const double d2F_dgbb2 = _hc1[3];
  if(out->v2rho2 != NULL) out->v2rho2[ip*p->dim.v2rho2 + 0] += d2F_dna2;
  if(out->v2rho2 != NULL) out->v2rho2[ip*p->dim.v2rho2 + 2] += d2F_dnb2;
  if(out->v2rhosigma != NULL) out->v2rhosigma[ip*p->dim.v2rhosigma + 0] += d2F_dna_dgaa;
  if(out->v2rhosigma != NULL) out->v2rhosigma[ip*p->dim.v2rhosigma + 5] += d2F_dnb_dgbb;
  if(out->v2sigma2 != NULL) out->v2sigma2[ip*p->dim.v2sigma2 + 0] += d2F_dgaa2;
  if(out->v2sigma2 != NULL) out->v2sigma2[ip*p->dim.v2sigma2 + 5] += d2F_dgbb2;
#endif
#if _KMAX >= 3
  const double d3F_dna3 = _hc0[9];
  const double d3F_dnb3 = _hc1[9];
  const double d3F_dna2_dgaa = _hc0[8];
  const double d3F_dnb2_dgbb = _hc1[8];
  const double d3F_dna_dgaa2 = _hc0[7];
  const double d3F_dnb_dgbb2 = _hc1[7];
  const double d3F_dgaa3 = _hc0[6];
  const double d3F_dgbb3 = _hc1[6];
  if(out->v3rho3 != NULL) out->v3rho3[ip*p->dim.v3rho3 + 0] += d3F_dna3;
  if(out->v3rho3 != NULL) out->v3rho3[ip*p->dim.v3rho3 + 3] += d3F_dnb3;
  if(out->v3rho2sigma != NULL) out->v3rho2sigma[ip*p->dim.v3rho2sigma + 0] += d3F_dna2_dgaa;
  if(out->v3rho2sigma != NULL) out->v3rho2sigma[ip*p->dim.v3rho2sigma + 8] += d3F_dnb2_dgbb;
  if(out->v3rhosigma2 != NULL) out->v3rhosigma2[ip*p->dim.v3rhosigma2 + 0] += d3F_dna_dgaa2;
  if(out->v3rhosigma2 != NULL) out->v3rhosigma2[ip*p->dim.v3rhosigma2 + 11] += d3F_dnb_dgbb2;
  if(out->v3sigma3 != NULL) out->v3sigma3[ip*p->dim.v3sigma3 + 0] += d3F_dgaa3;
  if(out->v3sigma3 != NULL) out->v3sigma3[ip*p->dim.v3sigma3 + 9] += d3F_dgbb3;
#endif
#if _KMAX >= 4
  const double d4F_dna4 = _hc0[14];
  const double d4F_dnb4 = _hc1[14];
  const double d4F_dna3_dgaa = _hc0[13];
  const double d4F_dnb3_dgbb = _hc1[13];
  const double d4F_dna2_dgaa2 = _hc0[12];
  const double d4F_dnb2_dgbb2 = _hc1[12];
  const double d4F_dna_dgaa3 = _hc0[11];
  const double d4F_dnb_dgbb3 = _hc1[11];
  const double d4F_dgaa4 = _hc0[10];
  const double d4F_dgbb4 = _hc1[10];
  if(out->v4rho4 != NULL) out->v4rho4[ip*p->dim.v4rho4 + 0] += d4F_dna4;
  if(out->v4rho4 != NULL) out->v4rho4[ip*p->dim.v4rho4 + 4] += d4F_dnb4;
  if(out->v4rho3sigma != NULL) out->v4rho3sigma[ip*p->dim.v4rho3sigma + 0] += d4F_dna3_dgaa;
  if(out->v4rho3sigma != NULL) out->v4rho3sigma[ip*p->dim.v4rho3sigma + 11] += d4F_dnb3_dgbb;
  if(out->v4rho2sigma2 != NULL) out->v4rho2sigma2[ip*p->dim.v4rho2sigma2 + 0] += d4F_dna2_dgaa2;
  if(out->v4rho2sigma2 != NULL) out->v4rho2sigma2[ip*p->dim.v4rho2sigma2 + 17] += d4F_dnb2_dgbb2;
  if(out->v4rhosigma3 != NULL) out->v4rhosigma3[ip*p->dim.v4rhosigma3 + 0] += d4F_dna_dgaa3;
  if(out->v4rhosigma3 != NULL) out->v4rhosigma3[ip*p->dim.v4rhosigma3 + 19] += d4F_dnb_dgbb3;
  if(out->v4sigma4 != NULL) out->v4sigma4[ip*p->dim.v4sigma4 + 0] += d4F_dgaa4;
  if(out->v4sigma4 != NULL) out->v4sigma4[ip*p->dim.v4sigma4 + 14] += d4F_dgbb4;
#endif
#endif
}
#endif