#include "simint/boys/boys.h"
#include "simint/ostei/gen/ostei_generated.h"
#include "simint/vectorization/vectorization.h"
#include <math.h>
#include <string.h>


int ostei_f_f_k_k(struct simint_multi_shellpair const P,
                  struct simint_multi_shellpair const Q,
                  double screen_tol,
                  double * const restrict work,
                  double * const restrict INT__f_f_k_k)
{

    SIMINT_ASSUME_ALIGN_DBL(work);
    SIMINT_ASSUME_ALIGN_DBL(INT__f_f_k_k);
    int ab, cd, abcd;
    int istart, jstart;
    int iprimcd, nprim_icd, icd;
    const int check_screen = (screen_tol > 0.0);
    int i, j;
    int n;
    int not_screened;
    int real_abcd;
    int iket;
    int ibra;

    // partition workspace
    double * const INT__f_s_k_s = work + (SIMINT_NSHELL_SIMD * 0);
    double * const INT__f_s_l_s = work + (SIMINT_NSHELL_SIMD * 360);
    double * const INT__f_s_m_s = work + (SIMINT_NSHELL_SIMD * 810);
    double * const INT__f_s_n_s = work + (SIMINT_NSHELL_SIMD * 1360);
    double * const INT__f_s_o_s = work + (SIMINT_NSHELL_SIMD * 2020);
    double * const INT__f_s_q_s = work + (SIMINT_NSHELL_SIMD * 2800);
    double * const INT__f_s_r_s = work + (SIMINT_NSHELL_SIMD * 3710);
    double * const INT__f_s_t_s = work + (SIMINT_NSHELL_SIMD * 4760);
    double * const INT__g_s_k_s = work + (SIMINT_NSHELL_SIMD * 5960);
    double * const INT__g_s_l_s = work + (SIMINT_NSHELL_SIMD * 6500);
    double * const INT__g_s_m_s = work + (SIMINT_NSHELL_SIMD * 7175);
    double * const INT__g_s_n_s = work + (SIMINT_NSHELL_SIMD * 8000);
    double * const INT__g_s_o_s = work + (SIMINT_NSHELL_SIMD * 8990);
    double * const INT__g_s_q_s = work + (SIMINT_NSHELL_SIMD * 10160);
    double * const INT__g_s_r_s = work + (SIMINT_NSHELL_SIMD * 11525);
    double * const INT__g_s_t_s = work + (SIMINT_NSHELL_SIMD * 13100);
    double * const INT__h_s_k_s = work + (SIMINT_NSHELL_SIMD * 14900);
    double * const INT__h_s_l_s = work + (SIMINT_NSHELL_SIMD * 15656);
    double * const INT__h_s_m_s = work + (SIMINT_NSHELL_SIMD * 16601);
    double * const INT__h_s_n_s = work + (SIMINT_NSHELL_SIMD * 17756);
    double * const INT__h_s_o_s = work + (SIMINT_NSHELL_SIMD * 19142);
    double * const INT__h_s_q_s = work + (SIMINT_NSHELL_SIMD * 20780);
    double * const INT__h_s_r_s = work + (SIMINT_NSHELL_SIMD * 22691);
    double * const INT__h_s_t_s = work + (SIMINT_NSHELL_SIMD * 24896);
    double * const INT__i_s_k_s = work + (SIMINT_NSHELL_SIMD * 27416);
    double * const INT__i_s_l_s = work + (SIMINT_NSHELL_SIMD * 28424);
    double * const INT__i_s_m_s = work + (SIMINT_NSHELL_SIMD * 29684);
    double * const INT__i_s_n_s = work + (SIMINT_NSHELL_SIMD * 31224);
    double * const INT__i_s_o_s = work + (SIMINT_NSHELL_SIMD * 33072);
    double * const INT__i_s_q_s = work + (SIMINT_NSHELL_SIMD * 35256);
    double * const INT__i_s_r_s = work + (SIMINT_NSHELL_SIMD * 37804);
    double * const INT__i_s_t_s = work + (SIMINT_NSHELL_SIMD * 40744);
    SIMINT_DBLTYPE * const primwork = (SIMINT_DBLTYPE *)(work + SIMINT_NSHELL_SIMD*44104);
    SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_s_s = primwork + 0;
    SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_p_s = primwork + 21;
    SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_d_s = primwork + 81;
    SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_f_s = primwork + 195;
    SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_g_s = primwork + 375;
    SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_h_s = primwork + 630;
    SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_i_s = primwork + 966;
    SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_k_s = primwork + 1386;
    SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_l_s = primwork + 1890;
    SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_m_s = primwork + 2475;
    SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_n_s = primwork + 3135;
    SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_o_s = primwork + 3861;
    SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_q_s = primwork + 4641;
    SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_r_s = primwork + 5460;
    SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_t_s = primwork + 6300;
    SIMINT_DBLTYPE * const restrict PRIM_INT__p_s_d_s = primwork + 7140;
    SIMINT_DBLTYPE * const restrict PRIM_INT__p_s_f_s = primwork + 7248;
    SIMINT_DBLTYPE * const restrict PRIM_INT__p_s_g_s = primwork + 7428;
    SIMINT_DBLTYPE * const restrict PRIM_INT__p_s_h_s = primwork + 7698;
    SIMINT_DBLTYPE * const restrict PRIM_INT__p_s_i_s = primwork + 8076;
    SIMINT_DBLTYPE * const restrict PRIM_INT__p_s_k_s = primwork + 8580;
    SIMINT_DBLTYPE * const restrict PRIM_INT__p_s_l_s = primwork + 9228;
    SIMINT_DBLTYPE * const restrict PRIM_INT__p_s_m_s = primwork + 10038;
    SIMINT_DBLTYPE * const restrict PRIM_INT__p_s_n_s = primwork + 11028;
    SIMINT_DBLTYPE * const restrict PRIM_INT__p_s_o_s = primwork + 12216;
    SIMINT_DBLTYPE * const restrict PRIM_INT__p_s_q_s = primwork + 13620;
    SIMINT_DBLTYPE * const restrict PRIM_INT__p_s_r_s = primwork + 15258;
    SIMINT_DBLTYPE * const restrict PRIM_INT__p_s_t_s = primwork + 17148;
    SIMINT_DBLTYPE * const restrict PRIM_INT__d_s_f_s = primwork + 19308;
    SIMINT_DBLTYPE * const restrict PRIM_INT__d_s_g_s = primwork + 19608;
    SIMINT_DBLTYPE * const restrict PRIM_INT__d_s_h_s = primwork + 20058;
    SIMINT_DBLTYPE * const restrict PRIM_INT__d_s_i_s = primwork + 20688;
    SIMINT_DBLTYPE * const restrict PRIM_INT__d_s_k_s = primwork + 21528;
    SIMINT_DBLTYPE * const restrict PRIM_INT__d_s_l_s = primwork + 22608;
    SIMINT_DBLTYPE * const restrict PRIM_INT__d_s_m_s = primwork + 23958;
    SIMINT_DBLTYPE * const restrict PRIM_INT__d_s_n_s = primwork + 25608;
    SIMINT_DBLTYPE * const restrict PRIM_INT__d_s_o_s = primwork + 27588;
    SIMINT_DBLTYPE * const restrict PRIM_INT__d_s_q_s = primwork + 29928;
    SIMINT_DBLTYPE * const restrict PRIM_INT__d_s_r_s = primwork + 32658;
    SIMINT_DBLTYPE * const restrict PRIM_INT__d_s_t_s = primwork + 35808;
    SIMINT_DBLTYPE * const restrict PRIM_INT__f_s_g_s = primwork + 39408;
    SIMINT_DBLTYPE * const restrict PRIM_INT__f_s_h_s = primwork + 40008;
    SIMINT_DBLTYPE * const restrict PRIM_INT__f_s_i_s = primwork + 40848;
    SIMINT_DBLTYPE * const restrict PRIM_INT__f_s_k_s = primwork + 41968;
    SIMINT_DBLTYPE * const restrict PRIM_INT__f_s_l_s = primwork + 43408;
    SIMINT_DBLTYPE * const restrict PRIM_INT__f_s_m_s = primwork + 45208;
    SIMINT_DBLTYPE * const restrict PRIM_INT__f_s_n_s = primwork + 47408;
    SIMINT_DBLTYPE * const restrict PRIM_INT__f_s_o_s = primwork + 50048;
    SIMINT_DBLTYPE * const restrict PRIM_INT__f_s_q_s = primwork + 53168;
    SIMINT_DBLTYPE * const restrict PRIM_INT__f_s_r_s = primwork + 56808;
    SIMINT_DBLTYPE * const restrict PRIM_INT__f_s_t_s = primwork + 61008;
    SIMINT_DBLTYPE * const restrict PRIM_INT__g_s_h_s = primwork + 65808;
    SIMINT_DBLTYPE * const restrict PRIM_INT__g_s_i_s = primwork + 66753;
    SIMINT_DBLTYPE * const restrict PRIM_INT__g_s_k_s = primwork + 68013;
    SIMINT_DBLTYPE * const restrict PRIM_INT__g_s_l_s = primwork + 69633;
    SIMINT_DBLTYPE * const restrict PRIM_INT__g_s_m_s = primwork + 71658;
    SIMINT_DBLTYPE * const restrict PRIM_INT__g_s_n_s = primwork + 74133;
    SIMINT_DBLTYPE * const restrict PRIM_INT__g_s_o_s = primwork + 77103;
    SIMINT_DBLTYPE * const restrict PRIM_INT__g_s_q_s = primwork + 80613;
    SIMINT_DBLTYPE * const restrict PRIM_INT__g_s_r_s = primwork + 84708;
    SIMINT_DBLTYPE * const restrict PRIM_INT__g_s_t_s = primwork + 89433;
    SIMINT_DBLTYPE * const restrict PRIM_INT__h_s_i_s = primwork + 94833;
    SIMINT_DBLTYPE * const restrict PRIM_INT__h_s_k_s = primwork + 96009;
    SIMINT_DBLTYPE * const restrict PRIM_INT__h_s_l_s = primwork + 97521;
    SIMINT_DBLTYPE * const restrict PRIM_INT__h_s_m_s = primwork + 99411;
    SIMINT_DBLTYPE * const restrict PRIM_INT__h_s_n_s = primwork + 101721;
    SIMINT_DBLTYPE * const restrict PRIM_INT__h_s_o_s = primwork + 104493;
    SIMINT_DBLTYPE * const restrict PRIM_INT__h_s_q_s = primwork + 107769;
    SIMINT_DBLTYPE * const restrict PRIM_INT__h_s_r_s = primwork + 111591;
    SIMINT_DBLTYPE * const restrict PRIM_INT__h_s_t_s = primwork + 116001;
    SIMINT_DBLTYPE * const restrict PRIM_INT__i_s_k_s = primwork + 121041;
    SIMINT_DBLTYPE * const restrict PRIM_INT__i_s_l_s = primwork + 122049;
    SIMINT_DBLTYPE * const restrict PRIM_INT__i_s_m_s = primwork + 123309;
    SIMINT_DBLTYPE * const restrict PRIM_INT__i_s_n_s = primwork + 124849;
    SIMINT_DBLTYPE * const restrict PRIM_INT__i_s_o_s = primwork + 126697;
    SIMINT_DBLTYPE * const restrict PRIM_INT__i_s_q_s = primwork + 128881;
    SIMINT_DBLTYPE * const restrict PRIM_INT__i_s_r_s = primwork + 131429;
    SIMINT_DBLTYPE * const restrict PRIM_INT__i_s_t_s = primwork + 134369;
    double * const hrrwork = (double *)(primwork + 137729);
    double * const HRR_INT__f_p_k_s = hrrwork + 0;
    double * const HRR_INT__f_p_l_s = hrrwork + 1080;
    double * const HRR_INT__f_p_m_s = hrrwork + 2430;
    double * const HRR_INT__f_p_n_s = hrrwork + 4080;
    double * const HRR_INT__f_p_o_s = hrrwork + 6060;
    double * const HRR_INT__f_p_q_s = hrrwork + 8400;
    double * const HRR_INT__f_p_r_s = hrrwork + 11130;
    double * const HRR_INT__f_p_t_s = hrrwork + 14280;
    double * const HRR_INT__f_d_k_s = hrrwork + 17880;
    double * const HRR_INT__f_d_l_s = hrrwork + 20040;
    double * const HRR_INT__f_d_m_s = hrrwork + 22740;
    double * const HRR_INT__f_d_n_s = hrrwork + 26040;
    double * const HRR_INT__f_d_o_s = hrrwork + 30000;
    double * const HRR_INT__f_d_q_s = hrrwork + 34680;
    double * const HRR_INT__f_d_r_s = hrrwork + 40140;
    double * const HRR_INT__f_d_t_s = hrrwork + 46440;
    double * const HRR_INT__f_f_k_s = hrrwork + 53640;
    double * const HRR_INT__f_f_k_p = hrrwork + 57240;
    double * const HRR_INT__f_f_k_d = hrrwork + 68040;
    double * const HRR_INT__f_f_k_f = hrrwork + 89640;
    double * const HRR_INT__f_f_k_g = hrrwork + 125640;
    double * const HRR_INT__f_f_k_h = hrrwork + 179640;
    double * const HRR_INT__f_f_k_i = hrrwork + 255240;
    double * const HRR_INT__f_f_l_s = hrrwork + 356040;
    double * const HRR_INT__f_f_l_p = hrrwork + 360540;
    double * const HRR_INT__f_f_l_d = hrrwork + 374040;
    double * const HRR_INT__f_f_l_f = hrrwork + 401040;
    double * const HRR_INT__f_f_l_g = hrrwork + 446040;
    double * const HRR_INT__f_f_l_h = hrrwork + 513540;
    double * const HRR_INT__f_f_l_i = hrrwork + 608040;
    double * const HRR_INT__f_f_m_s = hrrwork + 734040;
    double * const HRR_INT__f_f_m_p = hrrwork + 739540;
    double * const HRR_INT__f_f_m_d = hrrwork + 756040;
    double * const HRR_INT__f_f_m_f = hrrwork + 789040;
    double * const HRR_INT__f_f_m_g = hrrwork + 844040;
    double * const HRR_INT__f_f_m_h = hrrwork + 926540;
    double * const HRR_INT__f_f_n_s = hrrwork + 1042040;
    double * const HRR_INT__f_f_n_p = hrrwork + 1048640;
    double * const HRR_INT__f_f_n_d = hrrwork + 1068440;
    double * const HRR_INT__f_f_n_f = hrrwork + 1108040;
    double * const HRR_INT__f_f_n_g = hrrwork + 1174040;
    double * const HRR_INT__f_f_o_s = hrrwork + 1273040;
    double * const HRR_INT__f_f_o_p = hrrwork + 1280840;
    double * const HRR_INT__f_f_o_d = hrrwork + 1304240;
    double * const HRR_INT__f_f_o_f = hrrwork + 1351040;
    double * const HRR_INT__f_f_q_s = hrrwork + 1429040;
    double * const HRR_INT__f_f_q_p = hrrwork + 1438140;
    double * const HRR_INT__f_f_q_d = hrrwork + 1465440;
    double * const HRR_INT__f_f_r_s = hrrwork + 1520040;
    double * const HRR_INT__f_f_r_p = hrrwork + 1530540;
    double * const HRR_INT__f_f_t_s = hrrwork + 1562040;
    double * const HRR_INT__g_p_k_s = hrrwork + 1574040;
    double * const HRR_INT__g_p_l_s = hrrwork + 1575660;
    double * const HRR_INT__g_p_m_s = hrrwork + 1577685;
    double * const HRR_INT__g_p_n_s = hrrwork + 1580160;
    double * const HRR_INT__g_p_o_s = hrrwork + 1583130;
    double * const HRR_INT__g_p_q_s = hrrwork + 1586640;
    double * const HRR_INT__g_p_r_s = hrrwork + 1590735;
    double * const HRR_INT__g_p_t_s = hrrwork + 1595460;
    double * const HRR_INT__g_d_k_s = hrrwork + 1600860;
    double * const HRR_INT__g_d_l_s = hrrwork + 1604100;
    double * const HRR_INT__g_d_m_s = hrrwork + 1608150;
    double * const HRR_INT__g_d_n_s = hrrwork + 1613100;
    double * const HRR_INT__g_d_o_s = hrrwork + 1619040;
    double * const HRR_INT__g_d_q_s = hrrwork + 1626060;
    double * const HRR_INT__g_d_r_s = hrrwork + 1634250;
    double * const HRR_INT__g_d_t_s = hrrwork + 1643700;
    double * const HRR_INT__h_p_k_s = hrrwork + 1654500;
    double * const HRR_INT__h_p_l_s = hrrwork + 1656768;
    double * const HRR_INT__h_p_m_s = hrrwork + 1659603;
    double * const HRR_INT__h_p_n_s = hrrwork + 1663068;
    double * const HRR_INT__h_p_o_s = hrrwork + 1667226;
    double * const HRR_INT__h_p_q_s = hrrwork + 1672140;
    double * const HRR_INT__h_p_r_s = hrrwork + 1677873;
    double * const HRR_INT__h_p_t_s = hrrwork + 1684488;


    // Create constants
    const SIMINT_DBLTYPE const_1 = SIMINT_DBLSET1(1);
    const SIMINT_DBLTYPE const_10 = SIMINT_DBLSET1(10);
    const SIMINT_DBLTYPE const_11 = SIMINT_DBLSET1(11);
    const SIMINT_DBLTYPE const_12 = SIMINT_DBLSET1(12);
    const SIMINT_DBLTYPE const_13 = SIMINT_DBLSET1(13);
    const SIMINT_DBLTYPE const_14 = SIMINT_DBLSET1(14);
    const SIMINT_DBLTYPE const_2 = SIMINT_DBLSET1(2);
    const SIMINT_DBLTYPE const_3 = SIMINT_DBLSET1(3);
    const SIMINT_DBLTYPE const_4 = SIMINT_DBLSET1(4);
    const SIMINT_DBLTYPE const_5 = SIMINT_DBLSET1(5);
    const SIMINT_DBLTYPE const_6 = SIMINT_DBLSET1(6);
    const SIMINT_DBLTYPE const_7 = SIMINT_DBLSET1(7);
    const SIMINT_DBLTYPE const_8 = SIMINT_DBLSET1(8);
    const SIMINT_DBLTYPE const_9 = SIMINT_DBLSET1(9);
    const SIMINT_DBLTYPE one_half = SIMINT_DBLSET1(0.5);


    ////////////////////////////////////////
    // Loop over shells and primitives
    ////////////////////////////////////////

    real_abcd = 0;
    istart = 0;
    for(ab = 0; ab < P.nshell12_clip; ++ab)
    {
        const int iend = istart + P.nprim12[ab];

        cd = 0;
        jstart = 0;

        for(cd = 0; cd < Q.nshell12_clip; cd += SIMINT_NSHELL_SIMD)
        {
            const int nshellbatch = ((cd + SIMINT_NSHELL_SIMD) > Q.nshell12_clip) ? Q.nshell12_clip - cd : SIMINT_NSHELL_SIMD;
            int jend = jstart;
            for(i = 0; i < nshellbatch; i++)
                jend += Q.nprim12[cd+i];

            // Clear the beginning of the workspace (where we are accumulating integrals)
            memset(work, 0, SIMINT_NSHELL_SIMD * 44104 * sizeof(double));
            abcd = 0;


            for(i = istart; i < iend; ++i)
            {
                SIMINT_DBLTYPE bra_screen_max;  // only used if check_screen

                if(check_screen)
                {
                    // Skip this whole thing if always insignificant
                    if((P.screen[i] * Q.screen_max) < screen_tol)
                        continue;
                    bra_screen_max = SIMINT_DBLSET1(P.screen[i]);
                }

                icd = 0;
                iprimcd = 0;
                nprim_icd = Q.nprim12[cd];
                double * restrict PRIM_PTR_INT__f_s_k_s = INT__f_s_k_s + abcd * 360;
                double * restrict PRIM_PTR_INT__f_s_l_s = INT__f_s_l_s + abcd * 450;
                double * restrict PRIM_PTR_INT__f_s_m_s = INT__f_s_m_s + abcd * 550;
                double * restrict PRIM_PTR_INT__f_s_n_s = INT__f_s_n_s + abcd * 660;
                double * restrict PRIM_PTR_INT__f_s_o_s = INT__f_s_o_s + abcd * 780;
                double * restrict PRIM_PTR_INT__f_s_q_s = INT__f_s_q_s + abcd * 910;
                double * restrict PRIM_PTR_INT__f_s_r_s = INT__f_s_r_s + abcd * 1050;
                double * restrict PRIM_PTR_INT__f_s_t_s = INT__f_s_t_s + abcd * 1200;
                double * restrict PRIM_PTR_INT__g_s_k_s = INT__g_s_k_s + abcd * 540;
                double * restrict PRIM_PTR_INT__g_s_l_s = INT__g_s_l_s + abcd * 675;
                double * restrict PRIM_PTR_INT__g_s_m_s = INT__g_s_m_s + abcd * 825;
                double * restrict PRIM_PTR_INT__g_s_n_s = INT__g_s_n_s + abcd * 990;
                double * restrict PRIM_PTR_INT__g_s_o_s = INT__g_s_o_s + abcd * 1170;
                double * restrict PRIM_PTR_INT__g_s_q_s = INT__g_s_q_s + abcd * 1365;
                double * restrict PRIM_PTR_INT__g_s_r_s = INT__g_s_r_s + abcd * 1575;
                double * restrict PRIM_PTR_INT__g_s_t_s = INT__g_s_t_s + abcd * 1800;
                double * restrict PRIM_PTR_INT__h_s_k_s = INT__h_s_k_s + abcd * 756;
                double * restrict PRIM_PTR_INT__h_s_l_s = INT__h_s_l_s + abcd * 945;
                double * restrict PRIM_PTR_INT__h_s_m_s = INT__h_s_m_s + abcd * 1155;
                double * restrict PRIM_PTR_INT__h_s_n_s = INT__h_s_n_s + abcd * 1386;
                double * restrict PRIM_PTR_INT__h_s_o_s = INT__h_s_o_s + abcd * 1638;
                double * restrict PRIM_PTR_INT__h_s_q_s = INT__h_s_q_s + abcd * 1911;
                double * restrict PRIM_PTR_INT__h_s_r_s = INT__h_s_r_s + abcd * 2205;
                double * restrict PRIM_PTR_INT__h_s_t_s = INT__h_s_t_s + abcd * 2520;
                double * restrict PRIM_PTR_INT__i_s_k_s = INT__i_s_k_s + abcd * 1008;
                double * restrict PRIM_PTR_INT__i_s_l_s = INT__i_s_l_s + abcd * 1260;
                double * restrict PRIM_PTR_INT__i_s_m_s = INT__i_s_m_s + abcd * 1540;
                double * restrict PRIM_PTR_INT__i_s_n_s = INT__i_s_n_s + abcd * 1848;
                double * restrict PRIM_PTR_INT__i_s_o_s = INT__i_s_o_s + abcd * 2184;
                double * restrict PRIM_PTR_INT__i_s_q_s = INT__i_s_q_s + abcd * 2548;
                double * restrict PRIM_PTR_INT__i_s_r_s = INT__i_s_r_s + abcd * 2940;
                double * restrict PRIM_PTR_INT__i_s_t_s = INT__i_s_t_s + abcd * 3360;



                // Load these one per loop over i
                const SIMINT_DBLTYPE P_alpha = SIMINT_DBLSET1(P.alpha[i]);
                const SIMINT_DBLTYPE P_prefac = SIMINT_DBLSET1(P.prefac[i]);
                const SIMINT_DBLTYPE Pxyz[3] = { SIMINT_DBLSET1(P.x[i]), SIMINT_DBLSET1(P.y[i]), SIMINT_DBLSET1(P.z[i]) };

                const SIMINT_DBLTYPE P_PA[3] = { SIMINT_DBLSET1(P.PA_x[i]), SIMINT_DBLSET1(P.PA_y[i]), SIMINT_DBLSET1(P.PA_z[i]) };

                for(j = jstart; j < jend; j += SIMINT_SIMD_LEN)
                {
                    // calculate the shell offsets
                    // these are the offset from the shell pointed to by cd
                    // for each element
                    int shelloffsets[SIMINT_SIMD_LEN] = {0};
                    int lastoffset = 0;
                    const int nlane = ( ((j + SIMINT_SIMD_LEN) < jend) ? SIMINT_SIMD_LEN : (jend - j));

                    if((iprimcd + SIMINT_SIMD_LEN) >= nprim_icd)
                    {
                        // Handle if the first element of the vector is a new shell
                        if(iprimcd >= nprim_icd && ((icd+1) < nshellbatch))
                        {
                            nprim_icd += Q.nprim12[cd + (++icd)];
                            PRIM_PTR_INT__f_s_k_s += 360;
                            PRIM_PTR_INT__f_s_l_s += 450;
                            PRIM_PTR_INT__f_s_m_s += 550;
                            PRIM_PTR_INT__f_s_n_s += 660;
                            PRIM_PTR_INT__f_s_o_s += 780;
                            PRIM_PTR_INT__f_s_q_s += 910;
                            PRIM_PTR_INT__f_s_r_s += 1050;
                            PRIM_PTR_INT__f_s_t_s += 1200;
                            PRIM_PTR_INT__g_s_k_s += 540;
                            PRIM_PTR_INT__g_s_l_s += 675;
                            PRIM_PTR_INT__g_s_m_s += 825;
                            PRIM_PTR_INT__g_s_n_s += 990;
                            PRIM_PTR_INT__g_s_o_s += 1170;
                            PRIM_PTR_INT__g_s_q_s += 1365;
                            PRIM_PTR_INT__g_s_r_s += 1575;
                            PRIM_PTR_INT__g_s_t_s += 1800;
                            PRIM_PTR_INT__h_s_k_s += 756;
                            PRIM_PTR_INT__h_s_l_s += 945;
                            PRIM_PTR_INT__h_s_m_s += 1155;
                            PRIM_PTR_INT__h_s_n_s += 1386;
                            PRIM_PTR_INT__h_s_o_s += 1638;
                            PRIM_PTR_INT__h_s_q_s += 1911;
                            PRIM_PTR_INT__h_s_r_s += 2205;
                            PRIM_PTR_INT__h_s_t_s += 2520;
                            PRIM_PTR_INT__i_s_k_s += 1008;
                            PRIM_PTR_INT__i_s_l_s += 1260;
                            PRIM_PTR_INT__i_s_m_s += 1540;
                            PRIM_PTR_INT__i_s_n_s += 1848;
                            PRIM_PTR_INT__i_s_o_s += 2184;
                            PRIM_PTR_INT__i_s_q_s += 2548;
                            PRIM_PTR_INT__i_s_r_s += 2940;
                            PRIM_PTR_INT__i_s_t_s += 3360;
                        }
                        iprimcd++;
                        for(n = 1; n < SIMINT_SIMD_LEN; ++n)
                        {
                            if(iprimcd >= nprim_icd && ((icd+1) < nshellbatch))
                            {
                                shelloffsets[n] = shelloffsets[n-1] + 1;
                                lastoffset++;
                                nprim_icd += Q.nprim12[cd + (++icd)];
                            }
                            else
                                shelloffsets[n] = shelloffsets[n-1];
                            iprimcd++;
                        }
                    }
                    else
                        iprimcd += SIMINT_SIMD_LEN;

                    // Do we have to compute this vector (or has it been screened out)?
                    // (not_screened != 0 means we have to do this vector)
                    if(check_screen)
                    {
                        const double vmax = vector_max(SIMINT_MUL(bra_screen_max, SIMINT_DBLLOAD(Q.screen, j)));
                        if(vmax < screen_tol)
                        {
                            PRIM_PTR_INT__f_s_k_s += lastoffset*360;
                            PRIM_PTR_INT__f_s_l_s += lastoffset*450;
                            PRIM_PTR_INT__f_s_m_s += lastoffset*550;
                            PRIM_PTR_INT__f_s_n_s += lastoffset*660;
                            PRIM_PTR_INT__f_s_o_s += lastoffset*780;
                            PRIM_PTR_INT__f_s_q_s += lastoffset*910;
                            PRIM_PTR_INT__f_s_r_s += lastoffset*1050;
                            PRIM_PTR_INT__f_s_t_s += lastoffset*1200;
                            PRIM_PTR_INT__g_s_k_s += lastoffset*540;
                            PRIM_PTR_INT__g_s_l_s += lastoffset*675;
                            PRIM_PTR_INT__g_s_m_s += lastoffset*825;
                            PRIM_PTR_INT__g_s_n_s += lastoffset*990;
                            PRIM_PTR_INT__g_s_o_s += lastoffset*1170;
                            PRIM_PTR_INT__g_s_q_s += lastoffset*1365;
                            PRIM_PTR_INT__g_s_r_s += lastoffset*1575;
                            PRIM_PTR_INT__g_s_t_s += lastoffset*1800;
                            PRIM_PTR_INT__h_s_k_s += lastoffset*756;
                            PRIM_PTR_INT__h_s_l_s += lastoffset*945;
                            PRIM_PTR_INT__h_s_m_s += lastoffset*1155;
                            PRIM_PTR_INT__h_s_n_s += lastoffset*1386;
                            PRIM_PTR_INT__h_s_o_s += lastoffset*1638;
                            PRIM_PTR_INT__h_s_q_s += lastoffset*1911;
                            PRIM_PTR_INT__h_s_r_s += lastoffset*2205;
                            PRIM_PTR_INT__h_s_t_s += lastoffset*2520;
                            PRIM_PTR_INT__i_s_k_s += lastoffset*1008;
                            PRIM_PTR_INT__i_s_l_s += lastoffset*1260;
                            PRIM_PTR_INT__i_s_m_s += lastoffset*1540;
                            PRIM_PTR_INT__i_s_n_s += lastoffset*1848;
                            PRIM_PTR_INT__i_s_o_s += lastoffset*2184;
                            PRIM_PTR_INT__i_s_q_s += lastoffset*2548;
                            PRIM_PTR_INT__i_s_r_s += lastoffset*2940;
                            PRIM_PTR_INT__i_s_t_s += lastoffset*3360;
                            continue;
                        }
                    }

                    const SIMINT_DBLTYPE Q_alpha = SIMINT_DBLLOAD(Q.alpha, j);
                    const SIMINT_DBLTYPE PQalpha_mul = SIMINT_MUL(P_alpha, Q_alpha);
                    const SIMINT_DBLTYPE PQalpha_sum = SIMINT_ADD(P_alpha, Q_alpha);
                    const SIMINT_DBLTYPE one_over_PQalpha_sum = SIMINT_DIV(const_1, PQalpha_sum);


                    /* construct R2 = (Px - Qx)**2 + (Py - Qy)**2 + (Pz -Qz)**2 */
                    SIMINT_DBLTYPE PQ[3];
                    PQ[0] = SIMINT_SUB(Pxyz[0], SIMINT_DBLLOAD(Q.x, j));
                    PQ[1] = SIMINT_SUB(Pxyz[1], SIMINT_DBLLOAD(Q.y, j));
                    PQ[2] = SIMINT_SUB(Pxyz[2], SIMINT_DBLLOAD(Q.z, j));
                    SIMINT_DBLTYPE R2 = SIMINT_MUL(PQ[0], PQ[0]);
                    R2 = SIMINT_FMADD(PQ[1], PQ[1], R2);
                    R2 = SIMINT_FMADD(PQ[2], PQ[2], R2);

                    const SIMINT_DBLTYPE alpha = SIMINT_MUL(PQalpha_mul, one_over_PQalpha_sum); // alpha from MEST
                    const SIMINT_DBLTYPE one_over_p = SIMINT_DIV(const_1, P_alpha);
                    const SIMINT_DBLTYPE one_over_q = SIMINT_DIV(const_1, Q_alpha);
                    const SIMINT_DBLTYPE one_over_2p = SIMINT_MUL(one_half, one_over_p);
                    const SIMINT_DBLTYPE one_over_2q = SIMINT_MUL(one_half, one_over_q);
                    const SIMINT_DBLTYPE one_over_2pq = SIMINT_MUL(one_half, one_over_PQalpha_sum);
                    const SIMINT_DBLTYPE Q_PA[3] = { SIMINT_DBLLOAD(Q.PA_x, j), SIMINT_DBLLOAD(Q.PA_y, j), SIMINT_DBLLOAD(Q.PA_z, j) };

                    // NOTE: Minus sign!
                    const SIMINT_DBLTYPE a_over_p = SIMINT_MUL(SIMINT_NEG(alpha), one_over_p);
                    SIMINT_DBLTYPE aop_PQ[3];
                    aop_PQ[0] = SIMINT_MUL(a_over_p, PQ[0]);
                    aop_PQ[1] = SIMINT_MUL(a_over_p, PQ[1]);
                    aop_PQ[2] = SIMINT_MUL(a_over_p, PQ[2]);

                    SIMINT_DBLTYPE a_over_q = SIMINT_MUL(alpha, one_over_q);
                    SIMINT_DBLTYPE aoq_PQ[3];
                    aoq_PQ[0] = SIMINT_MUL(a_over_q, PQ[0]);
                    aoq_PQ[1] = SIMINT_MUL(a_over_q, PQ[1]);
                    aoq_PQ[2] = SIMINT_MUL(a_over_q, PQ[2]);
                    // Put a minus sign here so we don't have to in RR routines
                    a_over_q = SIMINT_NEG(a_over_q);


                    //////////////////////////////////////////////
                    // Fjt function section
                    // Maximum v value: 20
                    //////////////////////////////////////////////
                    // The parameter to the Fjt function
                    const SIMINT_DBLTYPE F_x = SIMINT_MUL(R2, alpha);


                    const SIMINT_DBLTYPE Q_prefac = mask_load(nlane, Q.prefac + j);


                    boys_F_split(PRIM_INT__s_s_s_s, F_x, 20);
                    SIMINT_DBLTYPE prefac = SIMINT_SQRT(one_over_PQalpha_sum);
                    prefac = SIMINT_MUL(SIMINT_MUL(P_prefac, Q_prefac), prefac);
                    for(n = 0; n <= 20; n++)
                        PRIM_INT__s_s_s_s[n] = SIMINT_MUL(PRIM_INT__s_s_s_s[n], prefac);

                    //////////////////////////////////////////////
                    // Primitive integrals: Vertical recurrance
                    //////////////////////////////////////////////

                    const SIMINT_DBLTYPE vrr_const_1_over_2p = one_over_2p;
                    const SIMINT_DBLTYPE vrr_const_2_over_2p = SIMINT_MUL(const_2, one_over_2p);
                    const SIMINT_DBLTYPE vrr_const_3_over_2p = SIMINT_MUL(const_3, one_over_2p);
                    const SIMINT_DBLTYPE vrr_const_4_over_2p = SIMINT_MUL(const_4, one_over_2p);
                    const SIMINT_DBLTYPE vrr_const_5_over_2p = SIMINT_MUL(const_5, one_over_2p);
                    const SIMINT_DBLTYPE vrr_const_1_over_2q = one_over_2q;
                    const SIMINT_DBLTYPE vrr_const_2_over_2q = SIMINT_MUL(const_2, one_over_2q);
                    const SIMINT_DBLTYPE vrr_const_3_over_2q = SIMINT_MUL(const_3, one_over_2q);
                    const SIMINT_DBLTYPE vrr_const_4_over_2q = SIMINT_MUL(const_4, one_over_2q);
                    const SIMINT_DBLTYPE vrr_const_5_over_2q = SIMINT_MUL(const_5, one_over_2q);
                    const SIMINT_DBLTYPE vrr_const_6_over_2q = SIMINT_MUL(const_6, one_over_2q);
                    const SIMINT_DBLTYPE vrr_const_7_over_2q = SIMINT_MUL(const_7, one_over_2q);
                    const SIMINT_DBLTYPE vrr_const_8_over_2q = SIMINT_MUL(const_8, one_over_2q);
                    const SIMINT_DBLTYPE vrr_const_9_over_2q = SIMINT_MUL(const_9, one_over_2q);
                    const SIMINT_DBLTYPE vrr_const_10_over_2q = SIMINT_MUL(const_10, one_over_2q);
                    const SIMINT_DBLTYPE vrr_const_11_over_2q = SIMINT_MUL(const_11, one_over_2q);
                    const SIMINT_DBLTYPE vrr_const_12_over_2q = SIMINT_MUL(const_12, one_over_2q);
                    const SIMINT_DBLTYPE vrr_const_13_over_2q = SIMINT_MUL(const_13, one_over_2q);
                    const SIMINT_DBLTYPE vrr_const_1_over_2pq = one_over_2pq;
                    const SIMINT_DBLTYPE vrr_const_2_over_2pq = SIMINT_MUL(const_2, one_over_2pq);
                    const SIMINT_DBLTYPE vrr_const_3_over_2pq = SIMINT_MUL(const_3, one_over_2pq);
                    const SIMINT_DBLTYPE vrr_const_4_over_2pq = SIMINT_MUL(const_4, one_over_2pq);
                    const SIMINT_DBLTYPE vrr_const_5_over_2pq = SIMINT_MUL(const_5, one_over_2pq);
                    const SIMINT_DBLTYPE vrr_const_6_over_2pq = SIMINT_MUL(const_6, one_over_2pq);
                    const SIMINT_DBLTYPE vrr_const_7_over_2pq = SIMINT_MUL(const_7, one_over_2pq);
                    const SIMINT_DBLTYPE vrr_const_8_over_2pq = SIMINT_MUL(const_8, one_over_2pq);
                    const SIMINT_DBLTYPE vrr_const_9_over_2pq = SIMINT_MUL(const_9, one_over_2pq);
                    const SIMINT_DBLTYPE vrr_const_10_over_2pq = SIMINT_MUL(const_10, one_over_2pq);
                    const SIMINT_DBLTYPE vrr_const_11_over_2pq = SIMINT_MUL(const_11, one_over_2pq);
                    const SIMINT_DBLTYPE vrr_const_12_over_2pq = SIMINT_MUL(const_12, one_over_2pq);
                    const SIMINT_DBLTYPE vrr_const_13_over_2pq = SIMINT_MUL(const_13, one_over_2pq);
                    const SIMINT_DBLTYPE vrr_const_14_over_2pq = SIMINT_MUL(const_14, one_over_2pq);



                    // Forming PRIM_INT__s_s_p_s[20 * 3];
                    for(n = 0; n < 20; ++n)  // loop over orders of auxiliary function
                    {

                        PRIM_INT__s_s_p_s[n * 3 + 0] = SIMINT_MUL(Q_PA[0], PRIM_INT__s_s_s_s[n * 1 + 0]);
                        PRIM_INT__s_s_p_s[n * 3 + 0] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_s_p_s[n * 3 + 0]);

                        PRIM_INT__s_s_p_s[n * 3 + 1] = SIMINT_MUL(Q_PA[1], PRIM_INT__s_s_s_s[n * 1 + 0]);
                        PRIM_INT__s_s_p_s[n * 3 + 1] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_s_p_s[n * 3 + 1]);

                        PRIM_INT__s_s_p_s[n * 3 + 2] = SIMINT_MUL(Q_PA[2], PRIM_INT__s_s_s_s[n * 1 + 0]);
                        PRIM_INT__s_s_p_s[n * 3 + 2] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_s_p_s[n * 3 + 2]);

                    }



                    // Forming PRIM_INT__s_s_d_s[19 * 6];
                    for(n = 0; n < 19; ++n)  // loop over orders of auxiliary function
                    {

                        PRIM_INT__s_s_d_s[n * 6 + 0] = SIMINT_MUL(Q_PA[0], PRIM_INT__s_s_p_s[n * 3 + 0]);
                        PRIM_INT__s_s_d_s[n * 6 + 0] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__s_s_p_s[(n+1) * 3 + 0], PRIM_INT__s_s_d_s[n * 6 + 0]);
                        PRIM_INT__s_s_d_s[n * 6 + 0] = SIMINT_FMADD( vrr_const_1_over_2q, SIMINT_FMADD(a_over_q, PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_s_s_s[n * 1 + 0]), PRIM_INT__s_s_d_s[n * 6 + 0]);

                        PRIM_INT__s_s_d_s[n * 6 + 1] = SIMINT_MUL(Q_PA[1], PRIM_INT__s_s_p_s[n * 3 + 0]);
                        PRIM_INT__s_s_d_s[n * 6 + 1] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_s_p_s[(n+1) * 3 + 0], PRIM_INT__s_s_d_s[n * 6 + 1]);

                        PRIM_INT__s_s_d_s[n * 6 + 2] = SIMINT_MUL(Q_PA[2], PRIM_INT__s_s_p_s[n * 3 + 0]);
                        PRIM_INT__s_s_d_s[n * 6 + 2] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_s_p_s[(n+1) * 3 + 0], PRIM_INT__s_s_d_s[n * 6 + 2]);

                        PRIM_INT__s_s_d_s[n * 6 + 3] = SIMINT_MUL(Q_PA[1], PRIM_INT__s_s_p_s[n * 3 + 1]);
                        PRIM_INT__s_s_d_s[n * 6 + 3] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_s_p_s[(n+1) * 3 + 1], PRIM_INT__s_s_d_s[n * 6 + 3]);
                        PRIM_INT__s_s_d_s[n * 6 + 3] = SIMINT_FMADD( vrr_const_1_over_2q, SIMINT_FMADD(a_over_q, PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_s_s_s[n * 1 + 0]), PRIM_INT__s_s_d_s[n * 6 + 3]);

                        PRIM_INT__s_s_d_s[n * 6 + 4] = SIMINT_MUL(Q_PA[2], PRIM_INT__s_s_p_s[n * 3 + 1]);
                        PRIM_INT__s_s_d_s[n * 6 + 4] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_s_p_s[(n+1) * 3 + 1], PRIM_INT__s_s_d_s[n * 6 + 4]);

                        PRIM_INT__s_s_d_s[n * 6 + 5] = SIMINT_MUL(Q_PA[2], PRIM_INT__s_s_p_s[n * 3 + 2]);
                        PRIM_INT__s_s_d_s[n * 6 + 5] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_s_p_s[(n+1) * 3 + 2], PRIM_INT__s_s_d_s[n * 6 + 5]);
                        PRIM_INT__s_s_d_s[n * 6 + 5] = SIMINT_FMADD( vrr_const_1_over_2q, SIMINT_FMADD(a_over_q, PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_s_s_s[n * 1 + 0]), PRIM_INT__s_s_d_s[n * 6 + 5]);

                    }



                    // Forming PRIM_INT__s_s_f_s[18 * 10];
                    for(n = 0; n < 18; ++n)  // loop over orders of auxiliary function
                    {

                        PRIM_INT__s_s_f_s[n * 10 + 0] = SIMINT_MUL(Q_PA[0], PRIM_INT__s_s_d_s[n * 6 + 0]);
                        PRIM_INT__s_s_f_s[n * 10 + 0] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__s_s_d_s[(n+1) * 6 + 0], PRIM_INT__s_s_f_s[n * 10 + 0]);
                        PRIM_INT__s_s_f_s[n * 10 + 0] = SIMINT_FMADD( vrr_const_2_over_2q, SIMINT_FMADD(a_over_q, PRIM_INT__s_s_p_s[(n+1) * 3 + 0], PRIM_INT__s_s_p_s[n * 3 + 0]), PRIM_INT__s_s_f_s[n * 10 + 0]);

                        PRIM_INT__s_s_f_s[n * 10 + 1] = SIMINT_MUL(Q_PA[1], PRIM_INT__s_s_d_s[n * 6 + 0]);
                        PRIM_INT__s_s_f_s[n * 10 + 1] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_s_d_s[(n+1) * 6 + 0], PRIM_INT__s_s_f_s[n * 10 + 1]);

                        PRIM_INT__s_s_f_s[n * 10 + 2] = SIMINT_MUL(Q_PA[2], PRIM_INT__s_s_d_s[n * 6 + 0]);
                        PRIM_INT__s_s_f_s[n * 10 + 2] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_s_d_s[(n+1) * 6 + 0], PRIM_INT__s_s_f_s[n * 10 + 2]);

                        PRIM_INT__s_s_f_s[n * 10 + 3] = SIMINT_MUL(Q_PA[0], PRIM_INT__s_s_d_s[n * 6 + 3]);
                        PRIM_INT__s_s_f_s[n * 10 + 3] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__s_s_d_s[(n+1) * 6 + 3], PRIM_INT__s_s_f_s[n * 10 + 3]);

                        PRIM_INT__s_s_f_s[n * 10 + 4] = SIMINT_MUL(Q_PA[2], PRIM_INT__s_s_d_s[n * 6 + 1]);
                        PRIM_INT__s_s_f_s[n * 10 + 4] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_s_d_s[(n+1) * 6 + 1], PRIM_INT__s_s_f_s[n * 10 + 4]);

                        PRIM_INT__s_s_f_s[n * 10 + 5] = SIMINT_MUL(Q_PA[0], PRIM_INT__s_s_d_s[n * 6 + 5]);
                        PRIM_INT__s_s_f_s[n * 10 + 5] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__s_s_d_s[(n+1) * 6 + 5], PRIM_INT__s_s_f_s[n * 10 + 5]);

                        PRIM_INT__s_s_f_s[n * 10 + 6] = SIMINT_MUL(Q_PA[1], PRIM_INT__s_s_d_s[n * 6 + 3]);
                        PRIM_INT__s_s_f_s[n * 10 + 6] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_s_d_s[(n+1) * 6 + 3], PRIM_INT__s_s_f_s[n * 10 + 6]);
                        PRIM_INT__s_s_f_s[n * 10 + 6] = SIMINT_FMADD( vrr_const_2_over_2q, SIMINT_FMADD(a_over_q, PRIM_INT__s_s_p_s[(n+1) * 3 + 1], PRIM_INT__s_s_p_s[n * 3 + 1]), PRIM_INT__s_s_f_s[n * 10 + 6]);

                        PRIM_INT__s_s_f_s[n * 10 + 7] = SIMINT_MUL(Q_PA[2], PRIM_INT__s_s_d_s[n * 6 + 3]);
                        PRIM_INT__s_s_f_s[n * 10 + 7] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_s_d_s[(n+1) * 6 + 3], PRIM_INT__s_s_f_s[n * 10 + 7]);

                        PRIM_INT__s_s_f_s[n * 10 + 8] = SIMINT_MUL(Q_PA[1], PRIM_INT__s_s_d_s[n * 6 + 5]);
                        PRIM_INT__s_s_f_s[n * 10 + 8] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_s_d_s[(n+1) * 6 + 5], PRIM_INT__s_s_f_s[n * 10 + 8]);

                        PRIM_INT__s_s_f_s[n * 10 + 9] = SIMINT_MUL(Q_PA[2], PRIM_INT__s_s_d_s[n * 6 + 5]);
                        PRIM_INT__s_s_f_s[n * 10 + 9] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_s_d_s[(n+1) * 6 + 5], PRIM_INT__s_s_f_s[n * 10 + 9]);
                        PRIM_INT__s_s_f_s[n * 10 + 9] = SIMINT_FMADD( vrr_const_2_over_2q, SIMINT_FMADD(a_over_q, PRIM_INT__s_s_p_s[(n+1) * 3 + 2], PRIM_INT__s_s_p_s[n * 3 + 2]), PRIM_INT__s_s_f_s[n * 10 + 9]);

                    }


                    VRR_K_s_s_g_s(
                            PRIM_INT__s_s_g_s,
                            PRIM_INT__s_s_f_s,
                            PRIM_INT__s_s_d_s,
                            Q_PA,
                            a_over_q,
                            aoq_PQ,
                            one_over_2q,
                            17);


                    VRR_K_s_s_h_s(
                            PRIM_INT__s_s_h_s,
                            PRIM_INT__s_s_g_s,
                            PRIM_INT__s_s_f_s,
                            Q_PA,
                            a_over_q,
                            aoq_PQ,
                            one_over_2q,
                            16);


                    ostei_general_vrr1_K(6, 15,
                            one_over_2q, a_over_q, aoq_PQ, Q_PA,
                            PRIM_INT__s_s_h_s, PRIM_INT__s_s_g_s, PRIM_INT__s_s_i_s);


                    ostei_general_vrr1_K(7, 14,
                            one_over_2q, a_over_q, aoq_PQ, Q_PA,
                            PRIM_INT__s_s_i_s, PRIM_INT__s_s_h_s, PRIM_INT__s_s_k_s);


                    ostei_general_vrr_I(1, 0, 7, 0, 6,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__s_s_k_s, NULL, NULL, PRIM_INT__s_s_i_s, NULL, PRIM_INT__p_s_k_s);


                    ostei_general_vrr_I(1, 0, 6, 0, 6,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__s_s_i_s, NULL, NULL, PRIM_INT__s_s_h_s, NULL, PRIM_INT__p_s_i_s);


                    ostei_general_vrr_I(2, 0, 7, 0, 5,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__p_s_k_s, PRIM_INT__s_s_k_s, NULL, PRIM_INT__p_s_i_s, NULL, PRIM_INT__d_s_k_s);


                    ostei_general_vrr_I(1, 0, 5, 0, 6,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__s_s_h_s, NULL, NULL, PRIM_INT__s_s_g_s, NULL, PRIM_INT__p_s_h_s);


                    ostei_general_vrr_I(2, 0, 6, 0, 5,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__p_s_i_s, PRIM_INT__s_s_i_s, NULL, PRIM_INT__p_s_h_s, NULL, PRIM_INT__d_s_i_s);


                    ostei_general_vrr_I(3, 0, 7, 0, 4,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__d_s_k_s, PRIM_INT__p_s_k_s, NULL, PRIM_INT__d_s_i_s, NULL, PRIM_INT__f_s_k_s);


                    ostei_general_vrr1_K(8, 13,
                            one_over_2q, a_over_q, aoq_PQ, Q_PA,
                            PRIM_INT__s_s_k_s, PRIM_INT__s_s_i_s, PRIM_INT__s_s_l_s);


                    ostei_general_vrr_I(1, 0, 8, 0, 6,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__s_s_l_s, NULL, NULL, PRIM_INT__s_s_k_s, NULL, PRIM_INT__p_s_l_s);


                    ostei_general_vrr_I(2, 0, 8, 0, 5,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__p_s_l_s, PRIM_INT__s_s_l_s, NULL, PRIM_INT__p_s_k_s, NULL, PRIM_INT__d_s_l_s);


                    ostei_general_vrr_I(3, 0, 8, 0, 4,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__d_s_l_s, PRIM_INT__p_s_l_s, NULL, PRIM_INT__d_s_k_s, NULL, PRIM_INT__f_s_l_s);


                    VRR_I_p_s_g_s(
                            PRIM_INT__p_s_g_s,
                            PRIM_INT__s_s_g_s,
                            PRIM_INT__s_s_f_s,
                            P_PA,
                            aop_PQ,
                            one_over_2pq,
                            6);


                    ostei_general_vrr_I(2, 0, 5, 0, 5,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__p_s_h_s, PRIM_INT__s_s_h_s, NULL, PRIM_INT__p_s_g_s, NULL, PRIM_INT__d_s_h_s);


                    ostei_general_vrr_I(3, 0, 6, 0, 4,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__d_s_i_s, PRIM_INT__p_s_i_s, NULL, PRIM_INT__d_s_h_s, NULL, PRIM_INT__f_s_i_s);


                    ostei_general_vrr_I(4, 0, 7, 0, 3,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__f_s_k_s, PRIM_INT__d_s_k_s, NULL, PRIM_INT__f_s_i_s, NULL, PRIM_INT__g_s_k_s);


                    ostei_general_vrr1_K(9, 12,
                            one_over_2q, a_over_q, aoq_PQ, Q_PA,
                            PRIM_INT__s_s_l_s, PRIM_INT__s_s_k_s, PRIM_INT__s_s_m_s);


                    ostei_general_vrr_I(1, 0, 9, 0, 6,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__s_s_m_s, NULL, NULL, PRIM_INT__s_s_l_s, NULL, PRIM_INT__p_s_m_s);


                    ostei_general_vrr_I(2, 0, 9, 0, 5,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__p_s_m_s, PRIM_INT__s_s_m_s, NULL, PRIM_INT__p_s_l_s, NULL, PRIM_INT__d_s_m_s);


                    ostei_general_vrr_I(3, 0, 9, 0, 4,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__d_s_m_s, PRIM_INT__p_s_m_s, NULL, PRIM_INT__d_s_l_s, NULL, PRIM_INT__f_s_m_s);


                    ostei_general_vrr_I(4, 0, 8, 0, 3,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__f_s_l_s, PRIM_INT__d_s_l_s, NULL, PRIM_INT__f_s_k_s, NULL, PRIM_INT__g_s_l_s);


                    VRR_I_p_s_f_s(
                            PRIM_INT__p_s_f_s,
                            PRIM_INT__s_s_f_s,
                            PRIM_INT__s_s_d_s,
                            P_PA,
                            aop_PQ,
                            one_over_2pq,
                            6);


                    ostei_general_vrr_I(2, 0, 4, 0, 5,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__p_s_g_s, PRIM_INT__s_s_g_s, NULL, PRIM_INT__p_s_f_s, NULL, PRIM_INT__d_s_g_s);


                    ostei_general_vrr_I(3, 0, 5, 0, 4,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__d_s_h_s, PRIM_INT__p_s_h_s, NULL, PRIM_INT__d_s_g_s, NULL, PRIM_INT__f_s_h_s);


                    ostei_general_vrr_I(4, 0, 6, 0, 3,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__f_s_i_s, PRIM_INT__d_s_i_s, NULL, PRIM_INT__f_s_h_s, NULL, PRIM_INT__g_s_i_s);


                    ostei_general_vrr_I(5, 0, 7, 0, 2,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__g_s_k_s, PRIM_INT__f_s_k_s, NULL, PRIM_INT__g_s_i_s, NULL, PRIM_INT__h_s_k_s);


                    ostei_general_vrr1_K(10, 11,
                            one_over_2q, a_over_q, aoq_PQ, Q_PA,
                            PRIM_INT__s_s_m_s, PRIM_INT__s_s_l_s, PRIM_INT__s_s_n_s);


                    ostei_general_vrr_I(1, 0, 10, 0, 6,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__s_s_n_s, NULL, NULL, PRIM_INT__s_s_m_s, NULL, PRIM_INT__p_s_n_s);


                    ostei_general_vrr_I(2, 0, 10, 0, 5,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__p_s_n_s, PRIM_INT__s_s_n_s, NULL, PRIM_INT__p_s_m_s, NULL, PRIM_INT__d_s_n_s);


                    ostei_general_vrr_I(3, 0, 10, 0, 4,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__d_s_n_s, PRIM_INT__p_s_n_s, NULL, PRIM_INT__d_s_m_s, NULL, PRIM_INT__f_s_n_s);


                    ostei_general_vrr_I(4, 0, 9, 0, 3,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__f_s_m_s, PRIM_INT__d_s_m_s, NULL, PRIM_INT__f_s_l_s, NULL, PRIM_INT__g_s_m_s);


                    ostei_general_vrr_I(5, 0, 8, 0, 2,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__g_s_l_s, PRIM_INT__f_s_l_s, NULL, PRIM_INT__g_s_k_s, NULL, PRIM_INT__h_s_l_s);



                    // Forming PRIM_INT__p_s_d_s[6 * 18];
                    for(n = 0; n < 6; ++n)  // loop over orders of auxiliary function
                    {

                        PRIM_INT__p_s_d_s[n * 18 + 0] = SIMINT_MUL(P_PA[0], PRIM_INT__s_s_d_s[n * 6 + 0]);
                        PRIM_INT__p_s_d_s[n * 18 + 0] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__s_s_d_s[(n+1) * 6 + 0], PRIM_INT__p_s_d_s[n * 18 + 0]);
                        PRIM_INT__p_s_d_s[n * 18 + 0] = SIMINT_FMADD( vrr_const_2_over_2pq, PRIM_INT__s_s_p_s[(n+1) * 3 + 0], PRIM_INT__p_s_d_s[n * 18 + 0]);

                        PRIM_INT__p_s_d_s[n * 18 + 1] = SIMINT_MUL(P_PA[0], PRIM_INT__s_s_d_s[n * 6 + 1]);
                        PRIM_INT__p_s_d_s[n * 18 + 1] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__s_s_d_s[(n+1) * 6 + 1], PRIM_INT__p_s_d_s[n * 18 + 1]);
                        PRIM_INT__p_s_d_s[n * 18 + 1] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_s_p_s[(n+1) * 3 + 1], PRIM_INT__p_s_d_s[n * 18 + 1]);

                        PRIM_INT__p_s_d_s[n * 18 + 2] = SIMINT_MUL(P_PA[0], PRIM_INT__s_s_d_s[n * 6 + 2]);
                        PRIM_INT__p_s_d_s[n * 18 + 2] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__s_s_d_s[(n+1) * 6 + 2], PRIM_INT__p_s_d_s[n * 18 + 2]);
                        PRIM_INT__p_s_d_s[n * 18 + 2] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_s_p_s[(n+1) * 3 + 2], PRIM_INT__p_s_d_s[n * 18 + 2]);

                        PRIM_INT__p_s_d_s[n * 18 + 3] = SIMINT_MUL(P_PA[0], PRIM_INT__s_s_d_s[n * 6 + 3]);
                        PRIM_INT__p_s_d_s[n * 18 + 3] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__s_s_d_s[(n+1) * 6 + 3], PRIM_INT__p_s_d_s[n * 18 + 3]);

                        PRIM_INT__p_s_d_s[n * 18 + 4] = SIMINT_MUL(P_PA[0], PRIM_INT__s_s_d_s[n * 6 + 4]);
                        PRIM_INT__p_s_d_s[n * 18 + 4] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__s_s_d_s[(n+1) * 6 + 4], PRIM_INT__p_s_d_s[n * 18 + 4]);

                        PRIM_INT__p_s_d_s[n * 18 + 5] = SIMINT_MUL(P_PA[0], PRIM_INT__s_s_d_s[n * 6 + 5]);
                        PRIM_INT__p_s_d_s[n * 18 + 5] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__s_s_d_s[(n+1) * 6 + 5], PRIM_INT__p_s_d_s[n * 18 + 5]);

                        PRIM_INT__p_s_d_s[n * 18 + 6] = SIMINT_MUL(P_PA[1], PRIM_INT__s_s_d_s[n * 6 + 0]);
                        PRIM_INT__p_s_d_s[n * 18 + 6] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__s_s_d_s[(n+1) * 6 + 0], PRIM_INT__p_s_d_s[n * 18 + 6]);

                        PRIM_INT__p_s_d_s[n * 18 + 7] = SIMINT_MUL(P_PA[1], PRIM_INT__s_s_d_s[n * 6 + 1]);
                        PRIM_INT__p_s_d_s[n * 18 + 7] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__s_s_d_s[(n+1) * 6 + 1], PRIM_INT__p_s_d_s[n * 18 + 7]);
                        PRIM_INT__p_s_d_s[n * 18 + 7] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_s_p_s[(n+1) * 3 + 0], PRIM_INT__p_s_d_s[n * 18 + 7]);

                        PRIM_INT__p_s_d_s[n * 18 + 8] = SIMINT_MUL(P_PA[1], PRIM_INT__s_s_d_s[n * 6 + 2]);
                        PRIM_INT__p_s_d_s[n * 18 + 8] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__s_s_d_s[(n+1) * 6 + 2], PRIM_INT__p_s_d_s[n * 18 + 8]);

                        PRIM_INT__p_s_d_s[n * 18 + 9] = SIMINT_MUL(P_PA[1], PRIM_INT__s_s_d_s[n * 6 + 3]);
                        PRIM_INT__p_s_d_s[n * 18 + 9] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__s_s_d_s[(n+1) * 6 + 3], PRIM_INT__p_s_d_s[n * 18 + 9]);
                        PRIM_INT__p_s_d_s[n * 18 + 9] = SIMINT_FMADD( vrr_const_2_over_2pq, PRIM_INT__s_s_p_s[(n+1) * 3 + 1], PRIM_INT__p_s_d_s[n * 18 + 9]);

                        PRIM_INT__p_s_d_s[n * 18 + 10] = SIMINT_MUL(P_PA[1], PRIM_INT__s_s_d_s[n * 6 + 4]);
                        PRIM_INT__p_s_d_s[n * 18 + 10] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__s_s_d_s[(n+1) * 6 + 4], PRIM_INT__p_s_d_s[n * 18 + 10]);
                        PRIM_INT__p_s_d_s[n * 18 + 10] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_s_p_s[(n+1) * 3 + 2], PRIM_INT__p_s_d_s[n * 18 + 10]);

                        PRIM_INT__p_s_d_s[n * 18 + 11] = SIMINT_MUL(P_PA[1], PRIM_INT__s_s_d_s[n * 6 + 5]);
                        PRIM_INT__p_s_d_s[n * 18 + 11] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__s_s_d_s[(n+1) * 6 + 5], PRIM_INT__p_s_d_s[n * 18 + 11]);

                        PRIM_INT__p_s_d_s[n * 18 + 12] = SIMINT_MUL(P_PA[2], PRIM_INT__s_s_d_s[n * 6 + 0]);
                        PRIM_INT__p_s_d_s[n * 18 + 12] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_s_d_s[(n+1) * 6 + 0], PRIM_INT__p_s_d_s[n * 18 + 12]);

                        PRIM_INT__p_s_d_s[n * 18 + 13] = SIMINT_MUL(P_PA[2], PRIM_INT__s_s_d_s[n * 6 + 1]);
                        PRIM_INT__p_s_d_s[n * 18 + 13] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_s_d_s[(n+1) * 6 + 1], PRIM_INT__p_s_d_s[n * 18 + 13]);

                        PRIM_INT__p_s_d_s[n * 18 + 14] = SIMINT_MUL(P_PA[2], PRIM_INT__s_s_d_s[n * 6 + 2]);
                        PRIM_INT__p_s_d_s[n * 18 + 14] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_s_d_s[(n+1) * 6 + 2], PRIM_INT__p_s_d_s[n * 18 + 14]);
                        PRIM_INT__p_s_d_s[n * 18 + 14] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_s_p_s[(n+1) * 3 + 0], PRIM_INT__p_s_d_s[n * 18 + 14]);

                        PRIM_INT__p_s_d_s[n * 18 + 15] = SIMINT_MUL(P_PA[2], PRIM_INT__s_s_d_s[n * 6 + 3]);
                        PRIM_INT__p_s_d_s[n * 18 + 15] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_s_d_s[(n+1) * 6 + 3], PRIM_INT__p_s_d_s[n * 18 + 15]);

                        PRIM_INT__p_s_d_s[n * 18 + 16] = SIMINT_MUL(P_PA[2], PRIM_INT__s_s_d_s[n * 6 + 4]);
                        PRIM_INT__p_s_d_s[n * 18 + 16] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_s_d_s[(n+1) * 6 + 4], PRIM_INT__p_s_d_s[n * 18 + 16]);
                        PRIM_INT__p_s_d_s[n * 18 + 16] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_s_p_s[(n+1) * 3 + 1], PRIM_INT__p_s_d_s[n * 18 + 16]);

                        PRIM_INT__p_s_d_s[n * 18 + 17] = SIMINT_MUL(P_PA[2], PRIM_INT__s_s_d_s[n * 6 + 5]);
                        PRIM_INT__p_s_d_s[n * 18 + 17] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_s_d_s[(n+1) * 6 + 5], PRIM_INT__p_s_d_s[n * 18 + 17]);
                        PRIM_INT__p_s_d_s[n * 18 + 17] = SIMINT_FMADD( vrr_const_2_over_2pq, PRIM_INT__s_s_p_s[(n+1) * 3 + 2], PRIM_INT__p_s_d_s[n * 18 + 17]);

                    }


                    VRR_I_d_s_f_s(
                            PRIM_INT__d_s_f_s,
                            PRIM_INT__p_s_f_s,
                            PRIM_INT__s_s_f_s,
                            PRIM_INT__p_s_d_s,
                            P_PA,
                            a_over_p,
                            aop_PQ,
                            one_over_2p,
                            one_over_2pq,
                            5);


                    ostei_general_vrr_I(3, 0, 4, 0, 4,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__d_s_g_s, PRIM_INT__p_s_g_s, NULL, PRIM_INT__d_s_f_s, NULL, PRIM_INT__f_s_g_s);


                    ostei_general_vrr_I(4, 0, 5, 0, 3,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__f_s_h_s, PRIM_INT__d_s_h_s, NULL, PRIM_INT__f_s_g_s, NULL, PRIM_INT__g_s_h_s);


                    ostei_general_vrr_I(5, 0, 6, 0, 2,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__g_s_i_s, PRIM_INT__f_s_i_s, NULL, PRIM_INT__g_s_h_s, NULL, PRIM_INT__h_s_i_s);


                    ostei_general_vrr_I(6, 0, 7, 0, 1,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__h_s_k_s, PRIM_INT__g_s_k_s, NULL, PRIM_INT__h_s_i_s, NULL, PRIM_INT__i_s_k_s);


                    ostei_general_vrr1_K(11, 10,
                            one_over_2q, a_over_q, aoq_PQ, Q_PA,
                            PRIM_INT__s_s_n_s, PRIM_INT__s_s_m_s, PRIM_INT__s_s_o_s);


                    ostei_general_vrr_I(1, 0, 11, 0, 6,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__s_s_o_s, NULL, NULL, PRIM_INT__s_s_n_s, NULL, PRIM_INT__p_s_o_s);


                    ostei_general_vrr_I(2, 0, 11, 0, 5,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__p_s_o_s, PRIM_INT__s_s_o_s, NULL, PRIM_INT__p_s_n_s, NULL, PRIM_INT__d_s_o_s);


                    ostei_general_vrr_I(3, 0, 11, 0, 4,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__d_s_o_s, PRIM_INT__p_s_o_s, NULL, PRIM_INT__d_s_n_s, NULL, PRIM_INT__f_s_o_s);


                    ostei_general_vrr_I(4, 0, 10, 0, 3,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__f_s_n_s, PRIM_INT__d_s_n_s, NULL, PRIM_INT__f_s_m_s, NULL, PRIM_INT__g_s_n_s);


                    ostei_general_vrr_I(5, 0, 9, 0, 2,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__g_s_m_s, PRIM_INT__f_s_m_s, NULL, PRIM_INT__g_s_l_s, NULL, PRIM_INT__h_s_m_s);


                    ostei_general_vrr_I(6, 0, 8, 0, 1,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__h_s_l_s, PRIM_INT__g_s_l_s, NULL, PRIM_INT__h_s_k_s, NULL, PRIM_INT__i_s_l_s);


                    ostei_general_vrr1_K(12, 9,
                            one_over_2q, a_over_q, aoq_PQ, Q_PA,
                            PRIM_INT__s_s_o_s, PRIM_INT__s_s_n_s, PRIM_INT__s_s_q_s);


                    ostei_general_vrr_I(1, 0, 12, 0, 6,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__s_s_q_s, NULL, NULL, PRIM_INT__s_s_o_s, NULL, PRIM_INT__p_s_q_s);


                    ostei_general_vrr_I(2, 0, 12, 0, 5,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__p_s_q_s, PRIM_INT__s_s_q_s, NULL, PRIM_INT__p_s_o_s, NULL, PRIM_INT__d_s_q_s);


                    ostei_general_vrr_I(3, 0, 12, 0, 4,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__d_s_q_s, PRIM_INT__p_s_q_s, NULL, PRIM_INT__d_s_o_s, NULL, PRIM_INT__f_s_q_s);


                    ostei_general_vrr_I(4, 0, 11, 0, 3,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__f_s_o_s, PRIM_INT__d_s_o_s, NULL, PRIM_INT__f_s_n_s, NULL, PRIM_INT__g_s_o_s);


                    ostei_general_vrr_I(5, 0, 10, 0, 2,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__g_s_n_s, PRIM_INT__f_s_n_s, NULL, PRIM_INT__g_s_m_s, NULL, PRIM_INT__h_s_n_s);


                    ostei_general_vrr_I(6, 0, 9, 0, 1,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__h_s_m_s, PRIM_INT__g_s_m_s, NULL, PRIM_INT__h_s_l_s, NULL, PRIM_INT__i_s_m_s);


                    ostei_general_vrr1_K(13, 8,
                            one_over_2q, a_over_q, aoq_PQ, Q_PA,
                            PRIM_INT__s_s_q_s, PRIM_INT__s_s_o_s, PRIM_INT__s_s_r_s);


                    ostei_general_vrr_I(1, 0, 13, 0, 6,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__s_s_r_s, NULL, NULL, PRIM_INT__s_s_q_s, NULL, PRIM_INT__p_s_r_s);


                    ostei_general_vrr_I(2, 0, 13, 0, 5,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__p_s_r_s, PRIM_INT__s_s_r_s, NULL, PRIM_INT__p_s_q_s, NULL, PRIM_INT__d_s_r_s);


                    ostei_general_vrr_I(3, 0, 13, 0, 4,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__d_s_r_s, PRIM_INT__p_s_r_s, NULL, PRIM_INT__d_s_q_s, NULL, PRIM_INT__f_s_r_s);


                    ostei_general_vrr_I(4, 0, 12, 0, 3,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__f_s_q_s, PRIM_INT__d_s_q_s, NULL, PRIM_INT__f_s_o_s, NULL, PRIM_INT__g_s_q_s);


                    ostei_general_vrr_I(5, 0, 11, 0, 2,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__g_s_o_s, PRIM_INT__f_s_o_s, NULL, PRIM_INT__g_s_n_s, NULL, PRIM_INT__h_s_o_s);


                    ostei_general_vrr_I(6, 0, 10, 0, 1,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__h_s_n_s, PRIM_INT__g_s_n_s, NULL, PRIM_INT__h_s_m_s, NULL, PRIM_INT__i_s_n_s);


                    ostei_general_vrr1_K(14, 7,
                            one_over_2q, a_over_q, aoq_PQ, Q_PA,
                            PRIM_INT__s_s_r_s, PRIM_INT__s_s_q_s, PRIM_INT__s_s_t_s);


                    ostei_general_vrr_I(1, 0, 14, 0, 6,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__s_s_t_s, NULL, NULL, PRIM_INT__s_s_r_s, NULL, PRIM_INT__p_s_t_s);


                    ostei_general_vrr_I(2, 0, 14, 0, 5,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__p_s_t_s, PRIM_INT__s_s_t_s, NULL, PRIM_INT__p_s_r_s, NULL, PRIM_INT__d_s_t_s);


                    ostei_general_vrr_I(3, 0, 14, 0, 4,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__d_s_t_s, PRIM_INT__p_s_t_s, NULL, PRIM_INT__d_s_r_s, NULL, PRIM_INT__f_s_t_s);


                    ostei_general_vrr_I(4, 0, 13, 0, 3,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__f_s_r_s, PRIM_INT__d_s_r_s, NULL, PRIM_INT__f_s_q_s, NULL, PRIM_INT__g_s_r_s);


                    ostei_general_vrr_I(5, 0, 12, 0, 2,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__g_s_q_s, PRIM_INT__f_s_q_s, NULL, PRIM_INT__g_s_o_s, NULL, PRIM_INT__h_s_q_s);


                    ostei_general_vrr_I(6, 0, 11, 0, 1,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__h_s_o_s, PRIM_INT__g_s_o_s, NULL, PRIM_INT__h_s_n_s, NULL, PRIM_INT__i_s_o_s);


                    ostei_general_vrr_I(4, 0, 14, 0, 3,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__f_s_t_s, PRIM_INT__d_s_t_s, NULL, PRIM_INT__f_s_r_s, NULL, PRIM_INT__g_s_t_s);


                    ostei_general_vrr_I(5, 0, 13, 0, 2,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__g_s_r_s, PRIM_INT__f_s_r_s, NULL, PRIM_INT__g_s_q_s, NULL, PRIM_INT__h_s_r_s);


                    ostei_general_vrr_I(6, 0, 12, 0, 1,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__h_s_q_s, PRIM_INT__g_s_q_s, NULL, PRIM_INT__h_s_o_s, NULL, PRIM_INT__i_s_q_s);


                    ostei_general_vrr_I(5, 0, 14, 0, 2,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__g_s_t_s, PRIM_INT__f_s_t_s, NULL, PRIM_INT__g_s_r_s, NULL, PRIM_INT__h_s_t_s);


                    ostei_general_vrr_I(6, 0, 13, 0, 1,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__h_s_r_s, PRIM_INT__g_s_r_s, NULL, PRIM_INT__h_s_q_s, NULL, PRIM_INT__i_s_r_s);


                    ostei_general_vrr_I(6, 0, 14, 0, 1,
                            one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
                            PRIM_INT__h_s_t_s, PRIM_INT__g_s_t_s, NULL, PRIM_INT__h_s_r_s, NULL, PRIM_INT__i_s_t_s);




                    ////////////////////////////////////
                    // Accumulate contracted integrals
                    ////////////////////////////////////
                    if(lastoffset == 0)
                    {
                        contract_all(360, PRIM_INT__f_s_k_s, PRIM_PTR_INT__f_s_k_s);
                        contract_all(450, PRIM_INT__f_s_l_s, PRIM_PTR_INT__f_s_l_s);
                        contract_all(550, PRIM_INT__f_s_m_s, PRIM_PTR_INT__f_s_m_s);
                        contract_all(660, PRIM_INT__f_s_n_s, PRIM_PTR_INT__f_s_n_s);
                        contract_all(780, PRIM_INT__f_s_o_s, PRIM_PTR_INT__f_s_o_s);
                        contract_all(910, PRIM_INT__f_s_q_s, PRIM_PTR_INT__f_s_q_s);
                        contract_all(1050, PRIM_INT__f_s_r_s, PRIM_PTR_INT__f_s_r_s);
                        contract_all(1200, PRIM_INT__f_s_t_s, PRIM_PTR_INT__f_s_t_s);
                        contract_all(540, PRIM_INT__g_s_k_s, PRIM_PTR_INT__g_s_k_s);
                        contract_all(675, PRIM_INT__g_s_l_s, PRIM_PTR_INT__g_s_l_s);
                        contract_all(825, PRIM_INT__g_s_m_s, PRIM_PTR_INT__g_s_m_s);
                        contract_all(990, PRIM_INT__g_s_n_s, PRIM_PTR_INT__g_s_n_s);
                        contract_all(1170, PRIM_INT__g_s_o_s, PRIM_PTR_INT__g_s_o_s);
                        contract_all(1365, PRIM_INT__g_s_q_s, PRIM_PTR_INT__g_s_q_s);
                        contract_all(1575, PRIM_INT__g_s_r_s, PRIM_PTR_INT__g_s_r_s);
                        contract_all(1800, PRIM_INT__g_s_t_s, PRIM_PTR_INT__g_s_t_s);
                        contract_all(756, PRIM_INT__h_s_k_s, PRIM_PTR_INT__h_s_k_s);
                        contract_all(945, PRIM_INT__h_s_l_s, PRIM_PTR_INT__h_s_l_s);
                        contract_all(1155, PRIM_INT__h_s_m_s, PRIM_PTR_INT__h_s_m_s);
                        contract_all(1386, PRIM_INT__h_s_n_s, PRIM_PTR_INT__h_s_n_s);
                        contract_all(1638, PRIM_INT__h_s_o_s, PRIM_PTR_INT__h_s_o_s);
                        contract_all(1911, PRIM_INT__h_s_q_s, PRIM_PTR_INT__h_s_q_s);
                        contract_all(2205, PRIM_INT__h_s_r_s, PRIM_PTR_INT__h_s_r_s);
                        contract_all(2520, PRIM_INT__h_s_t_s, PRIM_PTR_INT__h_s_t_s);
                        contract_all(1008, PRIM_INT__i_s_k_s, PRIM_PTR_INT__i_s_k_s);
                        contract_all(1260, PRIM_INT__i_s_l_s, PRIM_PTR_INT__i_s_l_s);
                        contract_all(1540, PRIM_INT__i_s_m_s, PRIM_PTR_INT__i_s_m_s);
                        contract_all(1848, PRIM_INT__i_s_n_s, PRIM_PTR_INT__i_s_n_s);
                        contract_all(2184, PRIM_INT__i_s_o_s, PRIM_PTR_INT__i_s_o_s);
                        contract_all(2548, PRIM_INT__i_s_q_s, PRIM_PTR_INT__i_s_q_s);
                        contract_all(2940, PRIM_INT__i_s_r_s, PRIM_PTR_INT__i_s_r_s);
                        contract_all(3360, PRIM_INT__i_s_t_s, PRIM_PTR_INT__i_s_t_s);
                    }
                    else
                    {
                        contract(360, shelloffsets, PRIM_INT__f_s_k_s, PRIM_PTR_INT__f_s_k_s);
                        contract(450, shelloffsets, PRIM_INT__f_s_l_s, PRIM_PTR_INT__f_s_l_s);
                        contract(550, shelloffsets, PRIM_INT__f_s_m_s, PRIM_PTR_INT__f_s_m_s);
                        contract(660, shelloffsets, PRIM_INT__f_s_n_s, PRIM_PTR_INT__f_s_n_s);
                        contract(780, shelloffsets, PRIM_INT__f_s_o_s, PRIM_PTR_INT__f_s_o_s);
                        contract(910, shelloffsets, PRIM_INT__f_s_q_s, PRIM_PTR_INT__f_s_q_s);
                        contract(1050, shelloffsets, PRIM_INT__f_s_r_s, PRIM_PTR_INT__f_s_r_s);
                        contract(1200, shelloffsets, PRIM_INT__f_s_t_s, PRIM_PTR_INT__f_s_t_s);
                        contract(540, shelloffsets, PRIM_INT__g_s_k_s, PRIM_PTR_INT__g_s_k_s);
                        contract(675, shelloffsets, PRIM_INT__g_s_l_s, PRIM_PTR_INT__g_s_l_s);
                        contract(825, shelloffsets, PRIM_INT__g_s_m_s, PRIM_PTR_INT__g_s_m_s);
                        contract(990, shelloffsets, PRIM_INT__g_s_n_s, PRIM_PTR_INT__g_s_n_s);
                        contract(1170, shelloffsets, PRIM_INT__g_s_o_s, PRIM_PTR_INT__g_s_o_s);
                        contract(1365, shelloffsets, PRIM_INT__g_s_q_s, PRIM_PTR_INT__g_s_q_s);
                        contract(1575, shelloffsets, PRIM_INT__g_s_r_s, PRIM_PTR_INT__g_s_r_s);
                        contract(1800, shelloffsets, PRIM_INT__g_s_t_s, PRIM_PTR_INT__g_s_t_s);
                        contract(756, shelloffsets, PRIM_INT__h_s_k_s, PRIM_PTR_INT__h_s_k_s);
                        contract(945, shelloffsets, PRIM_INT__h_s_l_s, PRIM_PTR_INT__h_s_l_s);
                        contract(1155, shelloffsets, PRIM_INT__h_s_m_s, PRIM_PTR_INT__h_s_m_s);
                        contract(1386, shelloffsets, PRIM_INT__h_s_n_s, PRIM_PTR_INT__h_s_n_s);
                        contract(1638, shelloffsets, PRIM_INT__h_s_o_s, PRIM_PTR_INT__h_s_o_s);
                        contract(1911, shelloffsets, PRIM_INT__h_s_q_s, PRIM_PTR_INT__h_s_q_s);
                        contract(2205, shelloffsets, PRIM_INT__h_s_r_s, PRIM_PTR_INT__h_s_r_s);
                        contract(2520, shelloffsets, PRIM_INT__h_s_t_s, PRIM_PTR_INT__h_s_t_s);
                        contract(1008, shelloffsets, PRIM_INT__i_s_k_s, PRIM_PTR_INT__i_s_k_s);
                        contract(1260, shelloffsets, PRIM_INT__i_s_l_s, PRIM_PTR_INT__i_s_l_s);
                        contract(1540, shelloffsets, PRIM_INT__i_s_m_s, PRIM_PTR_INT__i_s_m_s);
                        contract(1848, shelloffsets, PRIM_INT__i_s_n_s, PRIM_PTR_INT__i_s_n_s);
                        contract(2184, shelloffsets, PRIM_INT__i_s_o_s, PRIM_PTR_INT__i_s_o_s);
                        contract(2548, shelloffsets, PRIM_INT__i_s_q_s, PRIM_PTR_INT__i_s_q_s);
                        contract(2940, shelloffsets, PRIM_INT__i_s_r_s, PRIM_PTR_INT__i_s_r_s);
                        contract(3360, shelloffsets, PRIM_INT__i_s_t_s, PRIM_PTR_INT__i_s_t_s);
                        PRIM_PTR_INT__f_s_k_s += lastoffset*360;
                        PRIM_PTR_INT__f_s_l_s += lastoffset*450;
                        PRIM_PTR_INT__f_s_m_s += lastoffset*550;
                        PRIM_PTR_INT__f_s_n_s += lastoffset*660;
                        PRIM_PTR_INT__f_s_o_s += lastoffset*780;
                        PRIM_PTR_INT__f_s_q_s += lastoffset*910;
                        PRIM_PTR_INT__f_s_r_s += lastoffset*1050;
                        PRIM_PTR_INT__f_s_t_s += lastoffset*1200;
                        PRIM_PTR_INT__g_s_k_s += lastoffset*540;
                        PRIM_PTR_INT__g_s_l_s += lastoffset*675;
                        PRIM_PTR_INT__g_s_m_s += lastoffset*825;
                        PRIM_PTR_INT__g_s_n_s += lastoffset*990;
                        PRIM_PTR_INT__g_s_o_s += lastoffset*1170;
                        PRIM_PTR_INT__g_s_q_s += lastoffset*1365;
                        PRIM_PTR_INT__g_s_r_s += lastoffset*1575;
                        PRIM_PTR_INT__g_s_t_s += lastoffset*1800;
                        PRIM_PTR_INT__h_s_k_s += lastoffset*756;
                        PRIM_PTR_INT__h_s_l_s += lastoffset*945;
                        PRIM_PTR_INT__h_s_m_s += lastoffset*1155;
                        PRIM_PTR_INT__h_s_n_s += lastoffset*1386;
                        PRIM_PTR_INT__h_s_o_s += lastoffset*1638;
                        PRIM_PTR_INT__h_s_q_s += lastoffset*1911;
                        PRIM_PTR_INT__h_s_r_s += lastoffset*2205;
                        PRIM_PTR_INT__h_s_t_s += lastoffset*2520;
                        PRIM_PTR_INT__i_s_k_s += lastoffset*1008;
                        PRIM_PTR_INT__i_s_l_s += lastoffset*1260;
                        PRIM_PTR_INT__i_s_m_s += lastoffset*1540;
                        PRIM_PTR_INT__i_s_n_s += lastoffset*1848;
                        PRIM_PTR_INT__i_s_o_s += lastoffset*2184;
                        PRIM_PTR_INT__i_s_q_s += lastoffset*2548;
                        PRIM_PTR_INT__i_s_r_s += lastoffset*2940;
                        PRIM_PTR_INT__i_s_t_s += lastoffset*3360;
                    }

                }  // close loop over j
            }  // close loop over i
            
            //Advance to the next batch
            jstart = SIMINT_SIMD_ROUND(jend);
            
            //////////////////////////////////////////////
            // Contracted integrals: Horizontal recurrance
            //////////////////////////////////////////////


            const double hAB[3] = { P.AB_x[ab], P.AB_y[ab], P.AB_z[ab] };


            for(abcd = 0; abcd < nshellbatch; ++abcd, ++real_abcd)
            {
                const double hCD[3] = { Q.AB_x[cd+abcd], Q.AB_y[cd+abcd], Q.AB_z[cd+abcd] };

                // set up HRR pointers
                double const * restrict HRR_INT__f_s_k_s = INT__f_s_k_s + abcd * 360;
                double const * restrict HRR_INT__f_s_l_s = INT__f_s_l_s + abcd * 450;
                double const * restrict HRR_INT__f_s_m_s = INT__f_s_m_s + abcd * 550;
                double const * restrict HRR_INT__f_s_n_s = INT__f_s_n_s + abcd * 660;
                double const * restrict HRR_INT__f_s_o_s = INT__f_s_o_s + abcd * 780;
                double const * restrict HRR_INT__f_s_q_s = INT__f_s_q_s + abcd * 910;
                double const * restrict HRR_INT__f_s_r_s = INT__f_s_r_s + abcd * 1050;
                double const * restrict HRR_INT__f_s_t_s = INT__f_s_t_s + abcd * 1200;
                double const * restrict HRR_INT__g_s_k_s = INT__g_s_k_s + abcd * 540;
                double const * restrict HRR_INT__g_s_l_s = INT__g_s_l_s + abcd * 675;
                double const * restrict HRR_INT__g_s_m_s = INT__g_s_m_s + abcd * 825;
                double const * restrict HRR_INT__g_s_n_s = INT__g_s_n_s + abcd * 990;
                double const * restrict HRR_INT__g_s_o_s = INT__g_s_o_s + abcd * 1170;
                double const * restrict HRR_INT__g_s_q_s = INT__g_s_q_s + abcd * 1365;
                double const * restrict HRR_INT__g_s_r_s = INT__g_s_r_s + abcd * 1575;
                double const * restrict HRR_INT__g_s_t_s = INT__g_s_t_s + abcd * 1800;
                double const * restrict HRR_INT__h_s_k_s = INT__h_s_k_s + abcd * 756;
                double const * restrict HRR_INT__h_s_l_s = INT__h_s_l_s + abcd * 945;
                double const * restrict HRR_INT__h_s_m_s = INT__h_s_m_s + abcd * 1155;
                double const * restrict HRR_INT__h_s_n_s = INT__h_s_n_s + abcd * 1386;
                double const * restrict HRR_INT__h_s_o_s = INT__h_s_o_s + abcd * 1638;
                double const * restrict HRR_INT__h_s_q_s = INT__h_s_q_s + abcd * 1911;
                double const * restrict HRR_INT__h_s_r_s = INT__h_s_r_s + abcd * 2205;
                double const * restrict HRR_INT__h_s_t_s = INT__h_s_t_s + abcd * 2520;
                double const * restrict HRR_INT__i_s_k_s = INT__i_s_k_s + abcd * 1008;
                double const * restrict HRR_INT__i_s_l_s = INT__i_s_l_s + abcd * 1260;
                double const * restrict HRR_INT__i_s_m_s = INT__i_s_m_s + abcd * 1540;
                double const * restrict HRR_INT__i_s_n_s = INT__i_s_n_s + abcd * 1848;
                double const * restrict HRR_INT__i_s_o_s = INT__i_s_o_s + abcd * 2184;
                double const * restrict HRR_INT__i_s_q_s = INT__i_s_q_s + abcd * 2548;
                double const * restrict HRR_INT__i_s_r_s = INT__i_s_r_s + abcd * 2940;
                double const * restrict HRR_INT__i_s_t_s = INT__i_s_t_s + abcd * 3360;
                double * restrict HRR_INT__f_f_k_k = INT__f_f_k_k + real_abcd * 129600;

                // form INT__f_p_k_s
                HRR_J_f_p(
                    HRR_INT__f_p_k_s,
                    HRR_INT__f_s_k_s,
                    HRR_INT__g_s_k_s,
                    hAB, 36);

                // form INT__f_p_l_s
                HRR_J_f_p(
                    HRR_INT__f_p_l_s,
                    HRR_INT__f_s_l_s,
                    HRR_INT__g_s_l_s,
                    hAB, 45);

                // form INT__f_p_m_s
                HRR_J_f_p(
                    HRR_INT__f_p_m_s,
                    HRR_INT__f_s_m_s,
                    HRR_INT__g_s_m_s,
                    hAB, 55);

                // form INT__f_p_n_s
                HRR_J_f_p(
                    HRR_INT__f_p_n_s,
                    HRR_INT__f_s_n_s,
                    HRR_INT__g_s_n_s,
                    hAB, 66);

                // form INT__f_p_o_s
                HRR_J_f_p(
                    HRR_INT__f_p_o_s,
                    HRR_INT__f_s_o_s,
                    HRR_INT__g_s_o_s,
                    hAB, 78);

                // form INT__f_p_q_s
                HRR_J_f_p(
                    HRR_INT__f_p_q_s,
                    HRR_INT__f_s_q_s,
                    HRR_INT__g_s_q_s,
                    hAB, 91);

                // form INT__f_p_r_s
                HRR_J_f_p(
                    HRR_INT__f_p_r_s,
                    HRR_INT__f_s_r_s,
                    HRR_INT__g_s_r_s,
                    hAB, 105);

                // form INT__f_p_t_s
                HRR_J_f_p(
                    HRR_INT__f_p_t_s,
                    HRR_INT__f_s_t_s,
                    HRR_INT__g_s_t_s,
                    hAB, 120);

                // form INT__g_p_k_s
                HRR_J_g_p(
                    HRR_INT__g_p_k_s,
                    HRR_INT__g_s_k_s,
                    HRR_INT__h_s_k_s,
                    hAB, 36);

                // form INT__g_p_l_s
                HRR_J_g_p(
                    HRR_INT__g_p_l_s,
                    HRR_INT__g_s_l_s,
                    HRR_INT__h_s_l_s,
                    hAB, 45);

                // form INT__g_p_m_s
                HRR_J_g_p(
                    HRR_INT__g_p_m_s,
                    HRR_INT__g_s_m_s,
                    HRR_INT__h_s_m_s,
                    hAB, 55);

                // form INT__g_p_n_s
                HRR_J_g_p(
                    HRR_INT__g_p_n_s,
                    HRR_INT__g_s_n_s,
                    HRR_INT__h_s_n_s,
                    hAB, 66);

                // form INT__g_p_o_s
                HRR_J_g_p(
                    HRR_INT__g_p_o_s,
                    HRR_INT__g_s_o_s,
                    HRR_INT__h_s_o_s,
                    hAB, 78);

                // form INT__g_p_q_s
                HRR_J_g_p(
                    HRR_INT__g_p_q_s,
                    HRR_INT__g_s_q_s,
                    HRR_INT__h_s_q_s,
                    hAB, 91);

                // form INT__g_p_r_s
                HRR_J_g_p(
                    HRR_INT__g_p_r_s,
                    HRR_INT__g_s_r_s,
                    HRR_INT__h_s_r_s,
                    hAB, 105);

                // form INT__g_p_t_s
                HRR_J_g_p(
                    HRR_INT__g_p_t_s,
                    HRR_INT__g_s_t_s,
                    HRR_INT__h_s_t_s,
                    hAB, 120);

                // form INT__h_p_k_s
                ostei_general_hrr_J(5, 1, 7, 0, hAB, HRR_INT__i_s_k_s, HRR_INT__h_s_k_s, HRR_INT__h_p_k_s);

                // form INT__h_p_l_s
                ostei_general_hrr_J(5, 1, 8, 0, hAB, HRR_INT__i_s_l_s, HRR_INT__h_s_l_s, HRR_INT__h_p_l_s);

                // form INT__h_p_m_s
                ostei_general_hrr_J(5, 1, 9, 0, hAB, HRR_INT__i_s_m_s, HRR_INT__h_s_m_s, HRR_INT__h_p_m_s);

                // form INT__h_p_n_s
                ostei_general_hrr_J(5, 1, 10, 0, hAB, HRR_INT__i_s_n_s, HRR_INT__h_s_n_s, HRR_INT__h_p_n_s);

                // form INT__h_p_o_s
                ostei_general_hrr_J(5, 1, 11, 0, hAB, HRR_INT__i_s_o_s, HRR_INT__h_s_o_s, HRR_INT__h_p_o_s);

                // form INT__h_p_q_s
                ostei_general_hrr_J(5, 1, 12, 0, hAB, HRR_INT__i_s_q_s, HRR_INT__h_s_q_s, HRR_INT__h_p_q_s);

                // form INT__h_p_r_s
                ostei_general_hrr_J(5, 1, 13, 0, hAB, HRR_INT__i_s_r_s, HRR_INT__h_s_r_s, HRR_INT__h_p_r_s);

                // form INT__h_p_t_s
                ostei_general_hrr_J(5, 1, 14, 0, hAB, HRR_INT__i_s_t_s, HRR_INT__h_s_t_s, HRR_INT__h_p_t_s);

                // form INT__f_d_k_s
                HRR_J_f_d(
                    HRR_INT__f_d_k_s,
                    HRR_INT__f_p_k_s,
                    HRR_INT__g_p_k_s,
                    hAB, 36);

                // form INT__f_d_l_s
                HRR_J_f_d(
                    HRR_INT__f_d_l_s,
                    HRR_INT__f_p_l_s,
                    HRR_INT__g_p_l_s,
                    hAB, 45);

                // form INT__f_d_m_s
                HRR_J_f_d(
                    HRR_INT__f_d_m_s,
                    HRR_INT__f_p_m_s,
                    HRR_INT__g_p_m_s,
                    hAB, 55);

                // form INT__f_d_n_s
                HRR_J_f_d(
                    HRR_INT__f_d_n_s,
                    HRR_INT__f_p_n_s,
                    HRR_INT__g_p_n_s,
                    hAB, 66);

                // form INT__f_d_o_s
                HRR_J_f_d(
                    HRR_INT__f_d_o_s,
                    HRR_INT__f_p_o_s,
                    HRR_INT__g_p_o_s,
                    hAB, 78);

                // form INT__f_d_q_s
                HRR_J_f_d(
                    HRR_INT__f_d_q_s,
                    HRR_INT__f_p_q_s,
                    HRR_INT__g_p_q_s,
                    hAB, 91);

                // form INT__f_d_r_s
                HRR_J_f_d(
                    HRR_INT__f_d_r_s,
                    HRR_INT__f_p_r_s,
                    HRR_INT__g_p_r_s,
                    hAB, 105);

                // form INT__f_d_t_s
                HRR_J_f_d(
                    HRR_INT__f_d_t_s,
                    HRR_INT__f_p_t_s,
                    HRR_INT__g_p_t_s,
                    hAB, 120);

                // form INT__g_d_k_s
                ostei_general_hrr_J(4, 2, 7, 0, hAB, HRR_INT__h_p_k_s, HRR_INT__g_p_k_s, HRR_INT__g_d_k_s);

                // form INT__g_d_l_s
                ostei_general_hrr_J(4, 2, 8, 0, hAB, HRR_INT__h_p_l_s, HRR_INT__g_p_l_s, HRR_INT__g_d_l_s);

                // form INT__g_d_m_s
                ostei_general_hrr_J(4, 2, 9, 0, hAB, HRR_INT__h_p_m_s, HRR_INT__g_p_m_s, HRR_INT__g_d_m_s);

                // form INT__g_d_n_s
                ostei_general_hrr_J(4, 2, 10, 0, hAB, HRR_INT__h_p_n_s, HRR_INT__g_p_n_s, HRR_INT__g_d_n_s);

                // form INT__g_d_o_s
                ostei_general_hrr_J(4, 2, 11, 0, hAB, HRR_INT__h_p_o_s, HRR_INT__g_p_o_s, HRR_INT__g_d_o_s);

                // form INT__g_d_q_s
                ostei_general_hrr_J(4, 2, 12, 0, hAB, HRR_INT__h_p_q_s, HRR_INT__g_p_q_s, HRR_INT__g_d_q_s);

                // form INT__g_d_r_s
                ostei_general_hrr_J(4, 2, 13, 0, hAB, HRR_INT__h_p_r_s, HRR_INT__g_p_r_s, HRR_INT__g_d_r_s);

                // form INT__g_d_t_s
                ostei_general_hrr_J(4, 2, 14, 0, hAB, HRR_INT__h_p_t_s, HRR_INT__g_p_t_s, HRR_INT__g_d_t_s);

                // form INT__f_f_k_s
                ostei_general_hrr_J(3, 3, 7, 0, hAB, HRR_INT__g_d_k_s, HRR_INT__f_d_k_s, HRR_INT__f_f_k_s);

                // form INT__f_f_l_s
                ostei_general_hrr_J(3, 3, 8, 0, hAB, HRR_INT__g_d_l_s, HRR_INT__f_d_l_s, HRR_INT__f_f_l_s);

                // form INT__f_f_m_s
                ostei_general_hrr_J(3, 3, 9, 0, hAB, HRR_INT__g_d_m_s, HRR_INT__f_d_m_s, HRR_INT__f_f_m_s);

                // form INT__f_f_n_s
                ostei_general_hrr_J(3, 3, 10, 0, hAB, HRR_INT__g_d_n_s, HRR_INT__f_d_n_s, HRR_INT__f_f_n_s);

                // form INT__f_f_o_s
                ostei_general_hrr_J(3, 3, 11, 0, hAB, HRR_INT__g_d_o_s, HRR_INT__f_d_o_s, HRR_INT__f_f_o_s);

                // form INT__f_f_q_s
                ostei_general_hrr_J(3, 3, 12, 0, hAB, HRR_INT__g_d_q_s, HRR_INT__f_d_q_s, HRR_INT__f_f_q_s);

                // form INT__f_f_r_s
                ostei_general_hrr_J(3, 3, 13, 0, hAB, HRR_INT__g_d_r_s, HRR_INT__f_d_r_s, HRR_INT__f_f_r_s);

                // form INT__f_f_t_s
                ostei_general_hrr_J(3, 3, 14, 0, hAB, HRR_INT__g_d_t_s, HRR_INT__f_d_t_s, HRR_INT__f_f_t_s);

                // form INT__f_f_k_p
                ostei_general_hrr_L(3, 3, 7, 1, hCD, HRR_INT__f_f_l_s, HRR_INT__f_f_k_s, HRR_INT__f_f_k_p);

                // form INT__f_f_l_p
                ostei_general_hrr_L(3, 3, 8, 1, hCD, HRR_INT__f_f_m_s, HRR_INT__f_f_l_s, HRR_INT__f_f_l_p);

                // form INT__f_f_m_p
                ostei_general_hrr_L(3, 3, 9, 1, hCD, HRR_INT__f_f_n_s, HRR_INT__f_f_m_s, HRR_INT__f_f_m_p);

                // form INT__f_f_n_p
                ostei_general_hrr_L(3, 3, 10, 1, hCD, HRR_INT__f_f_o_s, HRR_INT__f_f_n_s, HRR_INT__f_f_n_p);

                // form INT__f_f_o_p
                ostei_general_hrr_L(3, 3, 11, 1, hCD, HRR_INT__f_f_q_s, HRR_INT__f_f_o_s, HRR_INT__f_f_o_p);

                // form INT__f_f_q_p
                ostei_general_hrr_L(3, 3, 12, 1, hCD, HRR_INT__f_f_r_s, HRR_INT__f_f_q_s, HRR_INT__f_f_q_p);

                // form INT__f_f_r_p
                ostei_general_hrr_L(3, 3, 13, 1, hCD, HRR_INT__f_f_t_s, HRR_INT__f_f_r_s, HRR_INT__f_f_r_p);

                // form INT__f_f_k_d
                ostei_general_hrr_L(3, 3, 7, 2, hCD, HRR_INT__f_f_l_p, HRR_INT__f_f_k_p, HRR_INT__f_f_k_d);

                // form INT__f_f_l_d
                ostei_general_hrr_L(3, 3, 8, 2, hCD, HRR_INT__f_f_m_p, HRR_INT__f_f_l_p, HRR_INT__f_f_l_d);

                // form INT__f_f_m_d
                ostei_general_hrr_L(3, 3, 9, 2, hCD, HRR_INT__f_f_n_p, HRR_INT__f_f_m_p, HRR_INT__f_f_m_d);

                // form INT__f_f_n_d
                ostei_general_hrr_L(3, 3, 10, 2, hCD, HRR_INT__f_f_o_p, HRR_INT__f_f_n_p, HRR_INT__f_f_n_d);

                // form INT__f_f_o_d
                ostei_general_hrr_L(3, 3, 11, 2, hCD, HRR_INT__f_f_q_p, HRR_INT__f_f_o_p, HRR_INT__f_f_o_d);

                // form INT__f_f_q_d
                ostei_general_hrr_L(3, 3, 12, 2, hCD, HRR_INT__f_f_r_p, HRR_INT__f_f_q_p, HRR_INT__f_f_q_d);

                // form INT__f_f_k_f
                ostei_general_hrr_L(3, 3, 7, 3, hCD, HRR_INT__f_f_l_d, HRR_INT__f_f_k_d, HRR_INT__f_f_k_f);

                // form INT__f_f_l_f
                ostei_general_hrr_L(3, 3, 8, 3, hCD, HRR_INT__f_f_m_d, HRR_INT__f_f_l_d, HRR_INT__f_f_l_f);

                // form INT__f_f_m_f
                ostei_general_hrr_L(3, 3, 9, 3, hCD, HRR_INT__f_f_n_d, HRR_INT__f_f_m_d, HRR_INT__f_f_m_f);

                // form INT__f_f_n_f
                ostei_general_hrr_L(3, 3, 10, 3, hCD, HRR_INT__f_f_o_d, HRR_INT__f_f_n_d, HRR_INT__f_f_n_f);

                // form INT__f_f_o_f
                ostei_general_hrr_L(3, 3, 11, 3, hCD, HRR_INT__f_f_q_d, HRR_INT__f_f_o_d, HRR_INT__f_f_o_f);

                // form INT__f_f_k_g
                ostei_general_hrr_L(3, 3, 7, 4, hCD, HRR_INT__f_f_l_f, HRR_INT__f_f_k_f, HRR_INT__f_f_k_g);

                // form INT__f_f_l_g
                ostei_general_hrr_L(3, 3, 8, 4, hCD, HRR_INT__f_f_m_f, HRR_INT__f_f_l_f, HRR_INT__f_f_l_g);

                // form INT__f_f_m_g
                ostei_general_hrr_L(3, 3, 9, 4, hCD, HRR_INT__f_f_n_f, HRR_INT__f_f_m_f, HRR_INT__f_f_m_g);

                // form INT__f_f_n_g
                ostei_general_hrr_L(3, 3, 10, 4, hCD, HRR_INT__f_f_o_f, HRR_INT__f_f_n_f, HRR_INT__f_f_n_g);

                // form INT__f_f_k_h
                ostei_general_hrr_L(3, 3, 7, 5, hCD, HRR_INT__f_f_l_g, HRR_INT__f_f_k_g, HRR_INT__f_f_k_h);

                // form INT__f_f_l_h
                ostei_general_hrr_L(3, 3, 8, 5, hCD, HRR_INT__f_f_m_g, HRR_INT__f_f_l_g, HRR_INT__f_f_l_h);

                // form INT__f_f_m_h
                ostei_general_hrr_L(3, 3, 9, 5, hCD, HRR_INT__f_f_n_g, HRR_INT__f_f_m_g, HRR_INT__f_f_m_h);

                // form INT__f_f_k_i
                ostei_general_hrr_L(3, 3, 7, 6, hCD, HRR_INT__f_f_l_h, HRR_INT__f_f_k_h, HRR_INT__f_f_k_i);

                // form INT__f_f_l_i
                ostei_general_hrr_L(3, 3, 8, 6, hCD, HRR_INT__f_f_m_h, HRR_INT__f_f_l_h, HRR_INT__f_f_l_i);

                // form INT__f_f_k_k
                ostei_general_hrr_L(3, 3, 7, 7, hCD, HRR_INT__f_f_l_i, HRR_INT__f_f_k_i, HRR_INT__f_f_k_k);


            }  // close HRR loop


        }   // close loop cdbatch

        istart = iend;
    }  // close loop over ab

    return P.nshell12_clip * Q.nshell12_clip;
}

