#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_i_i_f_f(struct simint_multi_shellpair const P,
                  struct simint_multi_shellpair const Q,
                  double screen_tol,
                  double * const restrict work,
                  double * const restrict INT__i_i_f_f)
{

    SIMINT_ASSUME_ALIGN_DBL(work);
    SIMINT_ASSUME_ALIGN_DBL(INT__i_i_f_f);
    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__i_s_f_s = work + (SIMINT_NSHELL_SIMD * 0);
    double * const INT__i_s_g_s = work + (SIMINT_NSHELL_SIMD * 280);
    double * const INT__i_s_h_s = work + (SIMINT_NSHELL_SIMD * 700);
    double * const INT__i_s_i_s = work + (SIMINT_NSHELL_SIMD * 1288);
    double * const INT__k_s_f_s = work + (SIMINT_NSHELL_SIMD * 2072);
    double * const INT__k_s_g_s = work + (SIMINT_NSHELL_SIMD * 2432);
    double * const INT__k_s_h_s = work + (SIMINT_NSHELL_SIMD * 2972);
    double * const INT__k_s_i_s = work + (SIMINT_NSHELL_SIMD * 3728);
    double * const INT__l_s_f_s = work + (SIMINT_NSHELL_SIMD * 4736);
    double * const INT__l_s_g_s = work + (SIMINT_NSHELL_SIMD * 5186);
    double * const INT__l_s_h_s = work + (SIMINT_NSHELL_SIMD * 5861);
    double * const INT__l_s_i_s = work + (SIMINT_NSHELL_SIMD * 6806);
    double * const INT__m_s_f_s = work + (SIMINT_NSHELL_SIMD * 8066);
    double * const INT__m_s_g_s = work + (SIMINT_NSHELL_SIMD * 8616);
    double * const INT__m_s_h_s = work + (SIMINT_NSHELL_SIMD * 9441);
    double * const INT__m_s_i_s = work + (SIMINT_NSHELL_SIMD * 10596);
    double * const INT__n_s_f_s = work + (SIMINT_NSHELL_SIMD * 12136);
    double * const INT__n_s_g_s = work + (SIMINT_NSHELL_SIMD * 12796);
    double * const INT__n_s_h_s = work + (SIMINT_NSHELL_SIMD * 13786);
    double * const INT__n_s_i_s = work + (SIMINT_NSHELL_SIMD * 15172);
    double * const INT__o_s_f_s = work + (SIMINT_NSHELL_SIMD * 17020);
    double * const INT__o_s_g_s = work + (SIMINT_NSHELL_SIMD * 17800);
    double * const INT__o_s_h_s = work + (SIMINT_NSHELL_SIMD * 18970);
    double * const INT__o_s_i_s = work + (SIMINT_NSHELL_SIMD * 20608);
    double * const INT__q_s_f_s = work + (SIMINT_NSHELL_SIMD * 22792);
    double * const INT__q_s_g_s = work + (SIMINT_NSHELL_SIMD * 23702);
    double * const INT__q_s_h_s = work + (SIMINT_NSHELL_SIMD * 25067);
    double * const INT__q_s_i_s = work + (SIMINT_NSHELL_SIMD * 26978);
    SIMINT_DBLTYPE * const primwork = (SIMINT_DBLTYPE *)(work + SIMINT_NSHELL_SIMD*29526);
    SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_s_s = primwork + 0;
    SIMINT_DBLTYPE * const restrict PRIM_INT__p_s_s_s = primwork + 19;
    SIMINT_DBLTYPE * const restrict PRIM_INT__p_s_p_s = primwork + 73;
    SIMINT_DBLTYPE * const restrict PRIM_INT__d_s_s_s = primwork + 127;
    SIMINT_DBLTYPE * const restrict PRIM_INT__d_s_p_s = primwork + 229;
    SIMINT_DBLTYPE * const restrict PRIM_INT__d_s_d_s = primwork + 337;
    SIMINT_DBLTYPE * const restrict PRIM_INT__f_s_s_s = primwork + 517;
    SIMINT_DBLTYPE * const restrict PRIM_INT__f_s_p_s = primwork + 677;
    SIMINT_DBLTYPE * const restrict PRIM_INT__f_s_d_s = primwork + 857;
    SIMINT_DBLTYPE * const restrict PRIM_INT__f_s_f_s = primwork + 1157;
    SIMINT_DBLTYPE * const restrict PRIM_INT__g_s_s_s = primwork + 1557;
    SIMINT_DBLTYPE * const restrict PRIM_INT__g_s_p_s = primwork + 1782;
    SIMINT_DBLTYPE * const restrict PRIM_INT__g_s_d_s = primwork + 2052;
    SIMINT_DBLTYPE * const restrict PRIM_INT__g_s_f_s = primwork + 2502;
    SIMINT_DBLTYPE * const restrict PRIM_INT__g_s_g_s = primwork + 3102;
    SIMINT_DBLTYPE * const restrict PRIM_INT__h_s_s_s = primwork + 3777;
    SIMINT_DBLTYPE * const restrict PRIM_INT__h_s_p_s = primwork + 4071;
    SIMINT_DBLTYPE * const restrict PRIM_INT__h_s_d_s = primwork + 4449;
    SIMINT_DBLTYPE * const restrict PRIM_INT__h_s_f_s = primwork + 5079;
    SIMINT_DBLTYPE * const restrict PRIM_INT__h_s_g_s = primwork + 5919;
    SIMINT_DBLTYPE * const restrict PRIM_INT__h_s_h_s = primwork + 6864;
    SIMINT_DBLTYPE * const restrict PRIM_INT__i_s_s_s = primwork + 7746;
    SIMINT_DBLTYPE * const restrict PRIM_INT__i_s_p_s = primwork + 8110;
    SIMINT_DBLTYPE * const restrict PRIM_INT__i_s_d_s = primwork + 8614;
    SIMINT_DBLTYPE * const restrict PRIM_INT__i_s_f_s = primwork + 9454;
    SIMINT_DBLTYPE * const restrict PRIM_INT__i_s_g_s = primwork + 10574;
    SIMINT_DBLTYPE * const restrict PRIM_INT__i_s_h_s = primwork + 11834;
    SIMINT_DBLTYPE * const restrict PRIM_INT__i_s_i_s = primwork + 13010;
    SIMINT_DBLTYPE * const restrict PRIM_INT__k_s_s_s = primwork + 13794;
    SIMINT_DBLTYPE * const restrict PRIM_INT__k_s_p_s = primwork + 14226;
    SIMINT_DBLTYPE * const restrict PRIM_INT__k_s_d_s = primwork + 14874;
    SIMINT_DBLTYPE * const restrict PRIM_INT__k_s_f_s = primwork + 15954;
    SIMINT_DBLTYPE * const restrict PRIM_INT__k_s_g_s = primwork + 17394;
    SIMINT_DBLTYPE * const restrict PRIM_INT__k_s_h_s = primwork + 19014;
    SIMINT_DBLTYPE * const restrict PRIM_INT__k_s_i_s = primwork + 20526;
    SIMINT_DBLTYPE * const restrict PRIM_INT__l_s_s_s = primwork + 21534;
    SIMINT_DBLTYPE * const restrict PRIM_INT__l_s_p_s = primwork + 22029;
    SIMINT_DBLTYPE * const restrict PRIM_INT__l_s_d_s = primwork + 22839;
    SIMINT_DBLTYPE * const restrict PRIM_INT__l_s_f_s = primwork + 24189;
    SIMINT_DBLTYPE * const restrict PRIM_INT__l_s_g_s = primwork + 25989;
    SIMINT_DBLTYPE * const restrict PRIM_INT__l_s_h_s = primwork + 28014;
    SIMINT_DBLTYPE * const restrict PRIM_INT__l_s_i_s = primwork + 29904;
    SIMINT_DBLTYPE * const restrict PRIM_INT__m_s_s_s = primwork + 31164;
    SIMINT_DBLTYPE * const restrict PRIM_INT__m_s_p_s = primwork + 31714;
    SIMINT_DBLTYPE * const restrict PRIM_INT__m_s_d_s = primwork + 32704;
    SIMINT_DBLTYPE * const restrict PRIM_INT__m_s_f_s = primwork + 34354;
    SIMINT_DBLTYPE * const restrict PRIM_INT__m_s_g_s = primwork + 36554;
    SIMINT_DBLTYPE * const restrict PRIM_INT__m_s_h_s = primwork + 39029;
    SIMINT_DBLTYPE * const restrict PRIM_INT__m_s_i_s = primwork + 41339;
    SIMINT_DBLTYPE * const restrict PRIM_INT__n_s_s_s = primwork + 42879;
    SIMINT_DBLTYPE * const restrict PRIM_INT__n_s_p_s = primwork + 43473;
    SIMINT_DBLTYPE * const restrict PRIM_INT__n_s_d_s = primwork + 44661;
    SIMINT_DBLTYPE * const restrict PRIM_INT__n_s_f_s = primwork + 46641;
    SIMINT_DBLTYPE * const restrict PRIM_INT__n_s_g_s = primwork + 49281;
    SIMINT_DBLTYPE * const restrict PRIM_INT__n_s_h_s = primwork + 52251;
    SIMINT_DBLTYPE * const restrict PRIM_INT__n_s_i_s = primwork + 55023;
    SIMINT_DBLTYPE * const restrict PRIM_INT__o_s_s_s = primwork + 56871;
    SIMINT_DBLTYPE * const restrict PRIM_INT__o_s_p_s = primwork + 57495;
    SIMINT_DBLTYPE * const restrict PRIM_INT__o_s_d_s = primwork + 58899;
    SIMINT_DBLTYPE * const restrict PRIM_INT__o_s_f_s = primwork + 61239;
    SIMINT_DBLTYPE * const restrict PRIM_INT__o_s_g_s = primwork + 64359;
    SIMINT_DBLTYPE * const restrict PRIM_INT__o_s_h_s = primwork + 67869;
    SIMINT_DBLTYPE * const restrict PRIM_INT__o_s_i_s = primwork + 71145;
    SIMINT_DBLTYPE * const restrict PRIM_INT__q_s_s_s = primwork + 73329;
    SIMINT_DBLTYPE * const restrict PRIM_INT__q_s_p_s = primwork + 73966;
    SIMINT_DBLTYPE * const restrict PRIM_INT__q_s_d_s = primwork + 75604;
    SIMINT_DBLTYPE * const restrict PRIM_INT__q_s_f_s = primwork + 78334;
    SIMINT_DBLTYPE * const restrict PRIM_INT__q_s_g_s = primwork + 81974;
    SIMINT_DBLTYPE * const restrict PRIM_INT__q_s_h_s = primwork + 86069;
    SIMINT_DBLTYPE * const restrict PRIM_INT__q_s_i_s = primwork + 89891;
    double * const hrrwork = (double *)(primwork + 92439);
    double * const HRR_INT__i_p_f_s = hrrwork + 0;
    double * const HRR_INT__i_p_g_s = hrrwork + 840;
    double * const HRR_INT__i_p_h_s = hrrwork + 2100;
    double * const HRR_INT__i_p_i_s = hrrwork + 3864;
    double * const HRR_INT__i_d_f_s = hrrwork + 6216;
    double * const HRR_INT__i_d_g_s = hrrwork + 7896;
    double * const HRR_INT__i_d_h_s = hrrwork + 10416;
    double * const HRR_INT__i_d_i_s = hrrwork + 13944;
    double * const HRR_INT__i_f_f_s = hrrwork + 18648;
    double * const HRR_INT__i_f_g_s = hrrwork + 21448;
    double * const HRR_INT__i_f_h_s = hrrwork + 25648;
    double * const HRR_INT__i_f_i_s = hrrwork + 31528;
    double * const HRR_INT__i_g_f_s = hrrwork + 39368;
    double * const HRR_INT__i_g_g_s = hrrwork + 43568;
    double * const HRR_INT__i_g_h_s = hrrwork + 49868;
    double * const HRR_INT__i_g_i_s = hrrwork + 58688;
    double * const HRR_INT__i_h_f_s = hrrwork + 70448;
    double * const HRR_INT__i_h_g_s = hrrwork + 76328;
    double * const HRR_INT__i_h_h_s = hrrwork + 85148;
    double * const HRR_INT__i_h_i_s = hrrwork + 97496;
    double * const HRR_INT__i_i_f_s = hrrwork + 113960;
    double * const HRR_INT__i_i_f_p = hrrwork + 121800;
    double * const HRR_INT__i_i_f_d = hrrwork + 145320;
    double * const HRR_INT__i_i_g_s = hrrwork + 192360;
    double * const HRR_INT__i_i_g_p = hrrwork + 204120;
    double * const HRR_INT__i_i_g_d = hrrwork + 239400;
    double * const HRR_INT__i_i_h_s = hrrwork + 309960;
    double * const HRR_INT__i_i_h_p = hrrwork + 326424;
    double * const HRR_INT__i_i_i_s = hrrwork + 375816;
    double * const HRR_INT__k_p_f_s = hrrwork + 397768;
    double * const HRR_INT__k_p_g_s = hrrwork + 398848;
    double * const HRR_INT__k_p_h_s = hrrwork + 400468;
    double * const HRR_INT__k_p_i_s = hrrwork + 402736;
    double * const HRR_INT__k_d_f_s = hrrwork + 405760;
    double * const HRR_INT__k_d_g_s = hrrwork + 407920;
    double * const HRR_INT__k_d_h_s = hrrwork + 411160;
    double * const HRR_INT__k_d_i_s = hrrwork + 415696;
    double * const HRR_INT__k_f_f_s = hrrwork + 421744;
    double * const HRR_INT__k_f_g_s = hrrwork + 425344;
    double * const HRR_INT__k_f_h_s = hrrwork + 430744;
    double * const HRR_INT__k_f_i_s = hrrwork + 438304;
    double * const HRR_INT__k_g_f_s = hrrwork + 448384;
    double * const HRR_INT__k_g_g_s = hrrwork + 453784;
    double * const HRR_INT__k_g_h_s = hrrwork + 461884;
    double * const HRR_INT__k_g_i_s = hrrwork + 473224;
    double * const HRR_INT__k_h_f_s = hrrwork + 488344;
    double * const HRR_INT__k_h_g_s = hrrwork + 495904;
    double * const HRR_INT__k_h_h_s = hrrwork + 507244;
    double * const HRR_INT__k_h_i_s = hrrwork + 523120;
    double * const HRR_INT__l_p_f_s = hrrwork + 544288;
    double * const HRR_INT__l_p_g_s = hrrwork + 545638;
    double * const HRR_INT__l_p_h_s = hrrwork + 547663;
    double * const HRR_INT__l_p_i_s = hrrwork + 550498;
    double * const HRR_INT__l_d_f_s = hrrwork + 554278;
    double * const HRR_INT__l_d_g_s = hrrwork + 556978;
    double * const HRR_INT__l_d_h_s = hrrwork + 561028;
    double * const HRR_INT__l_d_i_s = hrrwork + 566698;
    double * const HRR_INT__l_f_f_s = hrrwork + 574258;
    double * const HRR_INT__l_f_g_s = hrrwork + 578758;
    double * const HRR_INT__l_f_h_s = hrrwork + 585508;
    double * const HRR_INT__l_f_i_s = hrrwork + 594958;
    double * const HRR_INT__l_g_f_s = hrrwork + 607558;
    double * const HRR_INT__l_g_g_s = hrrwork + 614308;
    double * const HRR_INT__l_g_h_s = hrrwork + 624433;
    double * const HRR_INT__l_g_i_s = hrrwork + 638608;
    double * const HRR_INT__m_p_f_s = hrrwork + 657508;
    double * const HRR_INT__m_p_g_s = hrrwork + 659158;
    double * const HRR_INT__m_p_h_s = hrrwork + 661633;
    double * const HRR_INT__m_p_i_s = hrrwork + 665098;
    double * const HRR_INT__m_d_f_s = hrrwork + 669718;
    double * const HRR_INT__m_d_g_s = hrrwork + 673018;
    double * const HRR_INT__m_d_h_s = hrrwork + 677968;
    double * const HRR_INT__m_d_i_s = hrrwork + 684898;
    double * const HRR_INT__m_f_f_s = hrrwork + 694138;
    double * const HRR_INT__m_f_g_s = hrrwork + 699638;
    double * const HRR_INT__m_f_h_s = hrrwork + 707888;
    double * const HRR_INT__m_f_i_s = hrrwork + 719438;
    double * const HRR_INT__n_p_f_s = hrrwork + 734838;
    double * const HRR_INT__n_p_g_s = hrrwork + 736818;
    double * const HRR_INT__n_p_h_s = hrrwork + 739788;
    double * const HRR_INT__n_p_i_s = hrrwork + 743946;
    double * const HRR_INT__n_d_f_s = hrrwork + 749490;
    double * const HRR_INT__n_d_g_s = hrrwork + 753450;
    double * const HRR_INT__n_d_h_s = hrrwork + 759390;
    double * const HRR_INT__n_d_i_s = hrrwork + 767706;
    double * const HRR_INT__o_p_f_s = hrrwork + 778794;
    double * const HRR_INT__o_p_g_s = hrrwork + 781134;
    double * const HRR_INT__o_p_h_s = hrrwork + 784644;
    double * const HRR_INT__o_p_i_s = hrrwork + 789558;


    // 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_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 * 29526 * 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__i_s_f_s = INT__i_s_f_s + abcd * 280;
                double * restrict PRIM_PTR_INT__i_s_g_s = INT__i_s_g_s + abcd * 420;
                double * restrict PRIM_PTR_INT__i_s_h_s = INT__i_s_h_s + abcd * 588;
                double * restrict PRIM_PTR_INT__i_s_i_s = INT__i_s_i_s + abcd * 784;
                double * restrict PRIM_PTR_INT__k_s_f_s = INT__k_s_f_s + abcd * 360;
                double * restrict PRIM_PTR_INT__k_s_g_s = INT__k_s_g_s + abcd * 540;
                double * restrict PRIM_PTR_INT__k_s_h_s = INT__k_s_h_s + abcd * 756;
                double * restrict PRIM_PTR_INT__k_s_i_s = INT__k_s_i_s + abcd * 1008;
                double * restrict PRIM_PTR_INT__l_s_f_s = INT__l_s_f_s + abcd * 450;
                double * restrict PRIM_PTR_INT__l_s_g_s = INT__l_s_g_s + abcd * 675;
                double * restrict PRIM_PTR_INT__l_s_h_s = INT__l_s_h_s + abcd * 945;
                double * restrict PRIM_PTR_INT__l_s_i_s = INT__l_s_i_s + abcd * 1260;
                double * restrict PRIM_PTR_INT__m_s_f_s = INT__m_s_f_s + abcd * 550;
                double * restrict PRIM_PTR_INT__m_s_g_s = INT__m_s_g_s + abcd * 825;
                double * restrict PRIM_PTR_INT__m_s_h_s = INT__m_s_h_s + abcd * 1155;
                double * restrict PRIM_PTR_INT__m_s_i_s = INT__m_s_i_s + abcd * 1540;
                double * restrict PRIM_PTR_INT__n_s_f_s = INT__n_s_f_s + abcd * 660;
                double * restrict PRIM_PTR_INT__n_s_g_s = INT__n_s_g_s + abcd * 990;
                double * restrict PRIM_PTR_INT__n_s_h_s = INT__n_s_h_s + abcd * 1386;
                double * restrict PRIM_PTR_INT__n_s_i_s = INT__n_s_i_s + abcd * 1848;
                double * restrict PRIM_PTR_INT__o_s_f_s = INT__o_s_f_s + abcd * 780;
                double * restrict PRIM_PTR_INT__o_s_g_s = INT__o_s_g_s + abcd * 1170;
                double * restrict PRIM_PTR_INT__o_s_h_s = INT__o_s_h_s + abcd * 1638;
                double * restrict PRIM_PTR_INT__o_s_i_s = INT__o_s_i_s + abcd * 2184;
                double * restrict PRIM_PTR_INT__q_s_f_s = INT__q_s_f_s + abcd * 910;
                double * restrict PRIM_PTR_INT__q_s_g_s = INT__q_s_g_s + abcd * 1365;
                double * restrict PRIM_PTR_INT__q_s_h_s = INT__q_s_h_s + abcd * 1911;
                double * restrict PRIM_PTR_INT__q_s_i_s = INT__q_s_i_s + abcd * 2548;



                // 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__i_s_f_s += 280;
                            PRIM_PTR_INT__i_s_g_s += 420;
                            PRIM_PTR_INT__i_s_h_s += 588;
                            PRIM_PTR_INT__i_s_i_s += 784;
                            PRIM_PTR_INT__k_s_f_s += 360;
                            PRIM_PTR_INT__k_s_g_s += 540;
                            PRIM_PTR_INT__k_s_h_s += 756;
                            PRIM_PTR_INT__k_s_i_s += 1008;
                            PRIM_PTR_INT__l_s_f_s += 450;
                            PRIM_PTR_INT__l_s_g_s += 675;
                            PRIM_PTR_INT__l_s_h_s += 945;
                            PRIM_PTR_INT__l_s_i_s += 1260;
                            PRIM_PTR_INT__m_s_f_s += 550;
                            PRIM_PTR_INT__m_s_g_s += 825;
                            PRIM_PTR_INT__m_s_h_s += 1155;
                            PRIM_PTR_INT__m_s_i_s += 1540;
                            PRIM_PTR_INT__n_s_f_s += 660;
                            PRIM_PTR_INT__n_s_g_s += 990;
                            PRIM_PTR_INT__n_s_h_s += 1386;
                            PRIM_PTR_INT__n_s_i_s += 1848;
                            PRIM_PTR_INT__o_s_f_s += 780;
                            PRIM_PTR_INT__o_s_g_s += 1170;
                            PRIM_PTR_INT__o_s_h_s += 1638;
                            PRIM_PTR_INT__o_s_i_s += 2184;
                            PRIM_PTR_INT__q_s_f_s += 910;
                            PRIM_PTR_INT__q_s_g_s += 1365;
                            PRIM_PTR_INT__q_s_h_s += 1911;
                            PRIM_PTR_INT__q_s_i_s += 2548;
                        }
                        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__i_s_f_s += lastoffset*280;
                            PRIM_PTR_INT__i_s_g_s += lastoffset*420;
                            PRIM_PTR_INT__i_s_h_s += lastoffset*588;
                            PRIM_PTR_INT__i_s_i_s += lastoffset*784;
                            PRIM_PTR_INT__k_s_f_s += lastoffset*360;
                            PRIM_PTR_INT__k_s_g_s += lastoffset*540;
                            PRIM_PTR_INT__k_s_h_s += lastoffset*756;
                            PRIM_PTR_INT__k_s_i_s += lastoffset*1008;
                            PRIM_PTR_INT__l_s_f_s += lastoffset*450;
                            PRIM_PTR_INT__l_s_g_s += lastoffset*675;
                            PRIM_PTR_INT__l_s_h_s += lastoffset*945;
                            PRIM_PTR_INT__l_s_i_s += lastoffset*1260;
                            PRIM_PTR_INT__m_s_f_s += lastoffset*550;
                            PRIM_PTR_INT__m_s_g_s += lastoffset*825;
                            PRIM_PTR_INT__m_s_h_s += lastoffset*1155;
                            PRIM_PTR_INT__m_s_i_s += lastoffset*1540;
                            PRIM_PTR_INT__n_s_f_s += lastoffset*660;
                            PRIM_PTR_INT__n_s_g_s += lastoffset*990;
                            PRIM_PTR_INT__n_s_h_s += lastoffset*1386;
                            PRIM_PTR_INT__n_s_i_s += lastoffset*1848;
                            PRIM_PTR_INT__o_s_f_s += lastoffset*780;
                            PRIM_PTR_INT__o_s_g_s += lastoffset*1170;
                            PRIM_PTR_INT__o_s_h_s += lastoffset*1638;
                            PRIM_PTR_INT__o_s_i_s += lastoffset*2184;
                            PRIM_PTR_INT__q_s_f_s += lastoffset*910;
                            PRIM_PTR_INT__q_s_g_s += lastoffset*1365;
                            PRIM_PTR_INT__q_s_h_s += lastoffset*1911;
                            PRIM_PTR_INT__q_s_i_s += lastoffset*2548;
                            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: 18
                    //////////////////////////////////////////////
                    // 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, 18);
                    SIMINT_DBLTYPE prefac = SIMINT_SQRT(one_over_PQalpha_sum);
                    prefac = SIMINT_MUL(SIMINT_MUL(P_prefac, Q_prefac), prefac);
                    for(n = 0; n <= 18; 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_6_over_2p = SIMINT_MUL(const_6, one_over_2p);
                    const SIMINT_DBLTYPE vrr_const_7_over_2p = SIMINT_MUL(const_7, one_over_2p);
                    const SIMINT_DBLTYPE vrr_const_8_over_2p = SIMINT_MUL(const_8, one_over_2p);
                    const SIMINT_DBLTYPE vrr_const_9_over_2p = SIMINT_MUL(const_9, one_over_2p);
                    const SIMINT_DBLTYPE vrr_const_10_over_2p = SIMINT_MUL(const_10, one_over_2p);
                    const SIMINT_DBLTYPE vrr_const_11_over_2p = SIMINT_MUL(const_11, 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_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);



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

                        PRIM_INT__p_s_s_s[n * 3 + 0] = SIMINT_MUL(P_PA[0], PRIM_INT__s_s_s_s[n * 1 + 0]);
                        PRIM_INT__p_s_s_s[n * 3 + 0] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__p_s_s_s[n * 3 + 0]);

                        PRIM_INT__p_s_s_s[n * 3 + 1] = SIMINT_MUL(P_PA[1], PRIM_INT__s_s_s_s[n * 1 + 0]);
                        PRIM_INT__p_s_s_s[n * 3 + 1] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__p_s_s_s[n * 3 + 1]);

                        PRIM_INT__p_s_s_s[n * 3 + 2] = SIMINT_MUL(P_PA[2], PRIM_INT__s_s_s_s[n * 1 + 0]);
                        PRIM_INT__p_s_s_s[n * 3 + 2] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__p_s_s_s[n * 3 + 2]);

                    }



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

                        PRIM_INT__d_s_s_s[n * 6 + 0] = SIMINT_MUL(P_PA[0], PRIM_INT__p_s_s_s[n * 3 + 0]);
                        PRIM_INT__d_s_s_s[n * 6 + 0] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__p_s_s_s[(n+1) * 3 + 0], PRIM_INT__d_s_s_s[n * 6 + 0]);
                        PRIM_INT__d_s_s_s[n * 6 + 0] = SIMINT_FMADD( vrr_const_1_over_2p, SIMINT_FMADD(a_over_p, PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_s_s_s[n * 1 + 0]), PRIM_INT__d_s_s_s[n * 6 + 0]);

                        PRIM_INT__d_s_s_s[n * 6 + 1] = SIMINT_MUL(P_PA[1], PRIM_INT__p_s_s_s[n * 3 + 0]);
                        PRIM_INT__d_s_s_s[n * 6 + 1] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__p_s_s_s[(n+1) * 3 + 0], PRIM_INT__d_s_s_s[n * 6 + 1]);

                        PRIM_INT__d_s_s_s[n * 6 + 2] = SIMINT_MUL(P_PA[2], PRIM_INT__p_s_s_s[n * 3 + 0]);
                        PRIM_INT__d_s_s_s[n * 6 + 2] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__p_s_s_s[(n+1) * 3 + 0], PRIM_INT__d_s_s_s[n * 6 + 2]);

                        PRIM_INT__d_s_s_s[n * 6 + 3] = SIMINT_MUL(P_PA[1], PRIM_INT__p_s_s_s[n * 3 + 1]);
                        PRIM_INT__d_s_s_s[n * 6 + 3] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__p_s_s_s[(n+1) * 3 + 1], PRIM_INT__d_s_s_s[n * 6 + 3]);
                        PRIM_INT__d_s_s_s[n * 6 + 3] = SIMINT_FMADD( vrr_const_1_over_2p, SIMINT_FMADD(a_over_p, PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_s_s_s[n * 1 + 0]), PRIM_INT__d_s_s_s[n * 6 + 3]);

                        PRIM_INT__d_s_s_s[n * 6 + 4] = SIMINT_MUL(P_PA[2], PRIM_INT__p_s_s_s[n * 3 + 1]);
                        PRIM_INT__d_s_s_s[n * 6 + 4] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__p_s_s_s[(n+1) * 3 + 1], PRIM_INT__d_s_s_s[n * 6 + 4]);

                        PRIM_INT__d_s_s_s[n * 6 + 5] = SIMINT_MUL(P_PA[2], PRIM_INT__p_s_s_s[n * 3 + 2]);
                        PRIM_INT__d_s_s_s[n * 6 + 5] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__p_s_s_s[(n+1) * 3 + 2], PRIM_INT__d_s_s_s[n * 6 + 5]);
                        PRIM_INT__d_s_s_s[n * 6 + 5] = SIMINT_FMADD( vrr_const_1_over_2p, SIMINT_FMADD(a_over_p, PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_s_s_s[n * 1 + 0]), PRIM_INT__d_s_s_s[n * 6 + 5]);

                    }



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

                        PRIM_INT__f_s_s_s[n * 10 + 0] = SIMINT_MUL(P_PA[0], PRIM_INT__d_s_s_s[n * 6 + 0]);
                        PRIM_INT__f_s_s_s[n * 10 + 0] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__d_s_s_s[(n+1) * 6 + 0], PRIM_INT__f_s_s_s[n * 10 + 0]);
                        PRIM_INT__f_s_s_s[n * 10 + 0] = SIMINT_FMADD( vrr_const_2_over_2p, SIMINT_FMADD(a_over_p, PRIM_INT__p_s_s_s[(n+1) * 3 + 0], PRIM_INT__p_s_s_s[n * 3 + 0]), PRIM_INT__f_s_s_s[n * 10 + 0]);

                        PRIM_INT__f_s_s_s[n * 10 + 1] = SIMINT_MUL(P_PA[1], PRIM_INT__d_s_s_s[n * 6 + 0]);
                        PRIM_INT__f_s_s_s[n * 10 + 1] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__d_s_s_s[(n+1) * 6 + 0], PRIM_INT__f_s_s_s[n * 10 + 1]);

                        PRIM_INT__f_s_s_s[n * 10 + 2] = SIMINT_MUL(P_PA[2], PRIM_INT__d_s_s_s[n * 6 + 0]);
                        PRIM_INT__f_s_s_s[n * 10 + 2] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__d_s_s_s[(n+1) * 6 + 0], PRIM_INT__f_s_s_s[n * 10 + 2]);

                        PRIM_INT__f_s_s_s[n * 10 + 3] = SIMINT_MUL(P_PA[0], PRIM_INT__d_s_s_s[n * 6 + 3]);
                        PRIM_INT__f_s_s_s[n * 10 + 3] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__d_s_s_s[(n+1) * 6 + 3], PRIM_INT__f_s_s_s[n * 10 + 3]);

                        PRIM_INT__f_s_s_s[n * 10 + 4] = SIMINT_MUL(P_PA[2], PRIM_INT__d_s_s_s[n * 6 + 1]);
                        PRIM_INT__f_s_s_s[n * 10 + 4] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__d_s_s_s[(n+1) * 6 + 1], PRIM_INT__f_s_s_s[n * 10 + 4]);

                        PRIM_INT__f_s_s_s[n * 10 + 5] = SIMINT_MUL(P_PA[0], PRIM_INT__d_s_s_s[n * 6 + 5]);
                        PRIM_INT__f_s_s_s[n * 10 + 5] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__d_s_s_s[(n+1) * 6 + 5], PRIM_INT__f_s_s_s[n * 10 + 5]);

                        PRIM_INT__f_s_s_s[n * 10 + 6] = SIMINT_MUL(P_PA[1], PRIM_INT__d_s_s_s[n * 6 + 3]);
                        PRIM_INT__f_s_s_s[n * 10 + 6] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__d_s_s_s[(n+1) * 6 + 3], PRIM_INT__f_s_s_s[n * 10 + 6]);
                        PRIM_INT__f_s_s_s[n * 10 + 6] = SIMINT_FMADD( vrr_const_2_over_2p, SIMINT_FMADD(a_over_p, PRIM_INT__p_s_s_s[(n+1) * 3 + 1], PRIM_INT__p_s_s_s[n * 3 + 1]), PRIM_INT__f_s_s_s[n * 10 + 6]);

                        PRIM_INT__f_s_s_s[n * 10 + 7] = SIMINT_MUL(P_PA[2], PRIM_INT__d_s_s_s[n * 6 + 3]);
                        PRIM_INT__f_s_s_s[n * 10 + 7] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__d_s_s_s[(n+1) * 6 + 3], PRIM_INT__f_s_s_s[n * 10 + 7]);

                        PRIM_INT__f_s_s_s[n * 10 + 8] = SIMINT_MUL(P_PA[1], PRIM_INT__d_s_s_s[n * 6 + 5]);
                        PRIM_INT__f_s_s_s[n * 10 + 8] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__d_s_s_s[(n+1) * 6 + 5], PRIM_INT__f_s_s_s[n * 10 + 8]);

                        PRIM_INT__f_s_s_s[n * 10 + 9] = SIMINT_MUL(P_PA[2], PRIM_INT__d_s_s_s[n * 6 + 5]);
                        PRIM_INT__f_s_s_s[n * 10 + 9] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__d_s_s_s[(n+1) * 6 + 5], PRIM_INT__f_s_s_s[n * 10 + 9]);
                        PRIM_INT__f_s_s_s[n * 10 + 9] = SIMINT_FMADD( vrr_const_2_over_2p, SIMINT_FMADD(a_over_p, PRIM_INT__p_s_s_s[(n+1) * 3 + 2], PRIM_INT__p_s_s_s[n * 3 + 2]), PRIM_INT__f_s_s_s[n * 10 + 9]);

                    }


                    VRR_I_g_s_s_s(
                            PRIM_INT__g_s_s_s,
                            PRIM_INT__f_s_s_s,
                            PRIM_INT__d_s_s_s,
                            P_PA,
                            a_over_p,
                            aop_PQ,
                            one_over_2p,
                            15);


                    VRR_I_h_s_s_s(
                            PRIM_INT__h_s_s_s,
                            PRIM_INT__g_s_s_s,
                            PRIM_INT__f_s_s_s,
                            P_PA,
                            a_over_p,
                            aop_PQ,
                            one_over_2p,
                            14);


                    ostei_general_vrr1_I(6, 13,
                            one_over_2p, a_over_p, aop_PQ, P_PA,
                            PRIM_INT__h_s_s_s, PRIM_INT__g_s_s_s, PRIM_INT__i_s_s_s);


                    ostei_general_vrr_K(6, 0, 1, 0, 6,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__i_s_s_s, NULL, NULL, PRIM_INT__h_s_s_s, NULL, PRIM_INT__i_s_p_s);


                    ostei_general_vrr_K(5, 0, 1, 0, 6,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__h_s_s_s, NULL, NULL, PRIM_INT__g_s_s_s, NULL, PRIM_INT__h_s_p_s);


                    ostei_general_vrr_K(6, 0, 2, 0, 5,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__i_s_p_s, PRIM_INT__i_s_s_s, NULL, PRIM_INT__h_s_p_s, NULL, PRIM_INT__i_s_d_s);


                    VRR_K_g_s_p_s(
                            PRIM_INT__g_s_p_s,
                            PRIM_INT__g_s_s_s,
                            PRIM_INT__f_s_s_s,
                            Q_PA,
                            aoq_PQ,
                            one_over_2pq,
                            6);


                    ostei_general_vrr_K(5, 0, 2, 0, 5,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__h_s_p_s, PRIM_INT__h_s_s_s, NULL, PRIM_INT__g_s_p_s, NULL, PRIM_INT__h_s_d_s);


                    ostei_general_vrr_K(6, 0, 3, 0, 4,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__i_s_d_s, PRIM_INT__i_s_p_s, NULL, PRIM_INT__h_s_d_s, NULL, PRIM_INT__i_s_f_s);


                    VRR_K_f_s_p_s(
                            PRIM_INT__f_s_p_s,
                            PRIM_INT__f_s_s_s,
                            PRIM_INT__d_s_s_s,
                            Q_PA,
                            aoq_PQ,
                            one_over_2pq,
                            6);


                    ostei_general_vrr_K(4, 0, 2, 0, 5,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__g_s_p_s, PRIM_INT__g_s_s_s, NULL, PRIM_INT__f_s_p_s, NULL, PRIM_INT__g_s_d_s);


                    ostei_general_vrr_K(5, 0, 3, 0, 4,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__h_s_d_s, PRIM_INT__h_s_p_s, NULL, PRIM_INT__g_s_d_s, NULL, PRIM_INT__h_s_f_s);


                    ostei_general_vrr_K(6, 0, 4, 0, 3,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__i_s_f_s, PRIM_INT__i_s_d_s, NULL, PRIM_INT__h_s_f_s, NULL, PRIM_INT__i_s_g_s);


                    ostei_general_vrr1_I(7, 12,
                            one_over_2p, a_over_p, aop_PQ, P_PA,
                            PRIM_INT__i_s_s_s, PRIM_INT__h_s_s_s, PRIM_INT__k_s_s_s);


                    ostei_general_vrr_K(7, 0, 1, 0, 6,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__k_s_s_s, NULL, NULL, PRIM_INT__i_s_s_s, NULL, PRIM_INT__k_s_p_s);


                    ostei_general_vrr_K(7, 0, 2, 0, 5,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__k_s_p_s, PRIM_INT__k_s_s_s, NULL, PRIM_INT__i_s_p_s, NULL, PRIM_INT__k_s_d_s);


                    ostei_general_vrr_K(7, 0, 3, 0, 4,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__k_s_d_s, PRIM_INT__k_s_p_s, NULL, PRIM_INT__i_s_d_s, NULL, PRIM_INT__k_s_f_s);



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

                        PRIM_INT__d_s_p_s[n * 18 + 0] = SIMINT_MUL(Q_PA[0], PRIM_INT__d_s_s_s[n * 6 + 0]);
                        PRIM_INT__d_s_p_s[n * 18 + 0] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__d_s_s_s[(n+1) * 6 + 0], PRIM_INT__d_s_p_s[n * 18 + 0]);
                        PRIM_INT__d_s_p_s[n * 18 + 0] = SIMINT_FMADD( vrr_const_2_over_2pq, PRIM_INT__p_s_s_s[(n+1) * 3 + 0], PRIM_INT__d_s_p_s[n * 18 + 0]);

                        PRIM_INT__d_s_p_s[n * 18 + 1] = SIMINT_MUL(Q_PA[1], PRIM_INT__d_s_s_s[n * 6 + 0]);
                        PRIM_INT__d_s_p_s[n * 18 + 1] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__d_s_s_s[(n+1) * 6 + 0], PRIM_INT__d_s_p_s[n * 18 + 1]);

                        PRIM_INT__d_s_p_s[n * 18 + 2] = SIMINT_MUL(Q_PA[2], PRIM_INT__d_s_s_s[n * 6 + 0]);
                        PRIM_INT__d_s_p_s[n * 18 + 2] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__d_s_s_s[(n+1) * 6 + 0], PRIM_INT__d_s_p_s[n * 18 + 2]);

                        PRIM_INT__d_s_p_s[n * 18 + 3] = SIMINT_MUL(Q_PA[0], PRIM_INT__d_s_s_s[n * 6 + 1]);
                        PRIM_INT__d_s_p_s[n * 18 + 3] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__d_s_s_s[(n+1) * 6 + 1], PRIM_INT__d_s_p_s[n * 18 + 3]);
                        PRIM_INT__d_s_p_s[n * 18 + 3] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__p_s_s_s[(n+1) * 3 + 1], PRIM_INT__d_s_p_s[n * 18 + 3]);

                        PRIM_INT__d_s_p_s[n * 18 + 4] = SIMINT_MUL(Q_PA[1], PRIM_INT__d_s_s_s[n * 6 + 1]);
                        PRIM_INT__d_s_p_s[n * 18 + 4] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__d_s_s_s[(n+1) * 6 + 1], PRIM_INT__d_s_p_s[n * 18 + 4]);
                        PRIM_INT__d_s_p_s[n * 18 + 4] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__p_s_s_s[(n+1) * 3 + 0], PRIM_INT__d_s_p_s[n * 18 + 4]);

                        PRIM_INT__d_s_p_s[n * 18 + 5] = SIMINT_MUL(Q_PA[2], PRIM_INT__d_s_s_s[n * 6 + 1]);
                        PRIM_INT__d_s_p_s[n * 18 + 5] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__d_s_s_s[(n+1) * 6 + 1], PRIM_INT__d_s_p_s[n * 18 + 5]);

                        PRIM_INT__d_s_p_s[n * 18 + 6] = SIMINT_MUL(Q_PA[0], PRIM_INT__d_s_s_s[n * 6 + 2]);
                        PRIM_INT__d_s_p_s[n * 18 + 6] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__d_s_s_s[(n+1) * 6 + 2], PRIM_INT__d_s_p_s[n * 18 + 6]);
                        PRIM_INT__d_s_p_s[n * 18 + 6] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__p_s_s_s[(n+1) * 3 + 2], PRIM_INT__d_s_p_s[n * 18 + 6]);

                        PRIM_INT__d_s_p_s[n * 18 + 7] = SIMINT_MUL(Q_PA[1], PRIM_INT__d_s_s_s[n * 6 + 2]);
                        PRIM_INT__d_s_p_s[n * 18 + 7] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__d_s_s_s[(n+1) * 6 + 2], PRIM_INT__d_s_p_s[n * 18 + 7]);

                        PRIM_INT__d_s_p_s[n * 18 + 8] = SIMINT_MUL(Q_PA[2], PRIM_INT__d_s_s_s[n * 6 + 2]);
                        PRIM_INT__d_s_p_s[n * 18 + 8] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__d_s_s_s[(n+1) * 6 + 2], PRIM_INT__d_s_p_s[n * 18 + 8]);
                        PRIM_INT__d_s_p_s[n * 18 + 8] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__p_s_s_s[(n+1) * 3 + 0], PRIM_INT__d_s_p_s[n * 18 + 8]);

                        PRIM_INT__d_s_p_s[n * 18 + 9] = SIMINT_MUL(Q_PA[0], PRIM_INT__d_s_s_s[n * 6 + 3]);
                        PRIM_INT__d_s_p_s[n * 18 + 9] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__d_s_s_s[(n+1) * 6 + 3], PRIM_INT__d_s_p_s[n * 18 + 9]);

                        PRIM_INT__d_s_p_s[n * 18 + 10] = SIMINT_MUL(Q_PA[1], PRIM_INT__d_s_s_s[n * 6 + 3]);
                        PRIM_INT__d_s_p_s[n * 18 + 10] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__d_s_s_s[(n+1) * 6 + 3], PRIM_INT__d_s_p_s[n * 18 + 10]);
                        PRIM_INT__d_s_p_s[n * 18 + 10] = SIMINT_FMADD( vrr_const_2_over_2pq, PRIM_INT__p_s_s_s[(n+1) * 3 + 1], PRIM_INT__d_s_p_s[n * 18 + 10]);

                        PRIM_INT__d_s_p_s[n * 18 + 11] = SIMINT_MUL(Q_PA[2], PRIM_INT__d_s_s_s[n * 6 + 3]);
                        PRIM_INT__d_s_p_s[n * 18 + 11] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__d_s_s_s[(n+1) * 6 + 3], PRIM_INT__d_s_p_s[n * 18 + 11]);

                        PRIM_INT__d_s_p_s[n * 18 + 12] = SIMINT_MUL(Q_PA[0], PRIM_INT__d_s_s_s[n * 6 + 4]);
                        PRIM_INT__d_s_p_s[n * 18 + 12] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__d_s_s_s[(n+1) * 6 + 4], PRIM_INT__d_s_p_s[n * 18 + 12]);

                        PRIM_INT__d_s_p_s[n * 18 + 13] = SIMINT_MUL(Q_PA[1], PRIM_INT__d_s_s_s[n * 6 + 4]);
                        PRIM_INT__d_s_p_s[n * 18 + 13] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__d_s_s_s[(n+1) * 6 + 4], PRIM_INT__d_s_p_s[n * 18 + 13]);
                        PRIM_INT__d_s_p_s[n * 18 + 13] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__p_s_s_s[(n+1) * 3 + 2], PRIM_INT__d_s_p_s[n * 18 + 13]);

                        PRIM_INT__d_s_p_s[n * 18 + 14] = SIMINT_MUL(Q_PA[2], PRIM_INT__d_s_s_s[n * 6 + 4]);
                        PRIM_INT__d_s_p_s[n * 18 + 14] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__d_s_s_s[(n+1) * 6 + 4], PRIM_INT__d_s_p_s[n * 18 + 14]);
                        PRIM_INT__d_s_p_s[n * 18 + 14] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__p_s_s_s[(n+1) * 3 + 1], PRIM_INT__d_s_p_s[n * 18 + 14]);

                        PRIM_INT__d_s_p_s[n * 18 + 15] = SIMINT_MUL(Q_PA[0], PRIM_INT__d_s_s_s[n * 6 + 5]);
                        PRIM_INT__d_s_p_s[n * 18 + 15] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__d_s_s_s[(n+1) * 6 + 5], PRIM_INT__d_s_p_s[n * 18 + 15]);

                        PRIM_INT__d_s_p_s[n * 18 + 16] = SIMINT_MUL(Q_PA[1], PRIM_INT__d_s_s_s[n * 6 + 5]);
                        PRIM_INT__d_s_p_s[n * 18 + 16] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__d_s_s_s[(n+1) * 6 + 5], PRIM_INT__d_s_p_s[n * 18 + 16]);

                        PRIM_INT__d_s_p_s[n * 18 + 17] = SIMINT_MUL(Q_PA[2], PRIM_INT__d_s_s_s[n * 6 + 5]);
                        PRIM_INT__d_s_p_s[n * 18 + 17] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__d_s_s_s[(n+1) * 6 + 5], PRIM_INT__d_s_p_s[n * 18 + 17]);
                        PRIM_INT__d_s_p_s[n * 18 + 17] = SIMINT_FMADD( vrr_const_2_over_2pq, PRIM_INT__p_s_s_s[(n+1) * 3 + 2], PRIM_INT__d_s_p_s[n * 18 + 17]);

                    }


                    VRR_K_f_s_d_s(
                            PRIM_INT__f_s_d_s,
                            PRIM_INT__f_s_p_s,
                            PRIM_INT__f_s_s_s,
                            PRIM_INT__d_s_p_s,
                            Q_PA,
                            a_over_q,
                            aoq_PQ,
                            one_over_2pq,
                            one_over_2q,
                            5);


                    ostei_general_vrr_K(4, 0, 3, 0, 4,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__g_s_d_s, PRIM_INT__g_s_p_s, NULL, PRIM_INT__f_s_d_s, NULL, PRIM_INT__g_s_f_s);


                    ostei_general_vrr_K(5, 0, 4, 0, 3,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__h_s_f_s, PRIM_INT__h_s_d_s, NULL, PRIM_INT__g_s_f_s, NULL, PRIM_INT__h_s_g_s);


                    ostei_general_vrr_K(6, 0, 5, 0, 2,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__i_s_g_s, PRIM_INT__i_s_f_s, NULL, PRIM_INT__h_s_g_s, NULL, PRIM_INT__i_s_h_s);


                    ostei_general_vrr_K(7, 0, 4, 0, 3,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__k_s_f_s, PRIM_INT__k_s_d_s, NULL, PRIM_INT__i_s_f_s, NULL, PRIM_INT__k_s_g_s);


                    ostei_general_vrr1_I(8, 11,
                            one_over_2p, a_over_p, aop_PQ, P_PA,
                            PRIM_INT__k_s_s_s, PRIM_INT__i_s_s_s, PRIM_INT__l_s_s_s);


                    ostei_general_vrr_K(8, 0, 1, 0, 6,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__l_s_s_s, NULL, NULL, PRIM_INT__k_s_s_s, NULL, PRIM_INT__l_s_p_s);


                    ostei_general_vrr_K(8, 0, 2, 0, 5,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__l_s_p_s, PRIM_INT__l_s_s_s, NULL, PRIM_INT__k_s_p_s, NULL, PRIM_INT__l_s_d_s);


                    ostei_general_vrr_K(8, 0, 3, 0, 4,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__l_s_d_s, PRIM_INT__l_s_p_s, NULL, PRIM_INT__k_s_d_s, NULL, PRIM_INT__l_s_f_s);



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

                        PRIM_INT__p_s_p_s[n * 9 + 0] = SIMINT_MUL(Q_PA[0], PRIM_INT__p_s_s_s[n * 3 + 0]);
                        PRIM_INT__p_s_p_s[n * 9 + 0] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__p_s_s_s[(n+1) * 3 + 0], PRIM_INT__p_s_p_s[n * 9 + 0]);
                        PRIM_INT__p_s_p_s[n * 9 + 0] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__p_s_p_s[n * 9 + 0]);

                        PRIM_INT__p_s_p_s[n * 9 + 1] = SIMINT_MUL(Q_PA[1], PRIM_INT__p_s_s_s[n * 3 + 0]);
                        PRIM_INT__p_s_p_s[n * 9 + 1] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__p_s_s_s[(n+1) * 3 + 0], PRIM_INT__p_s_p_s[n * 9 + 1]);

                        PRIM_INT__p_s_p_s[n * 9 + 2] = SIMINT_MUL(Q_PA[2], PRIM_INT__p_s_s_s[n * 3 + 0]);
                        PRIM_INT__p_s_p_s[n * 9 + 2] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__p_s_s_s[(n+1) * 3 + 0], PRIM_INT__p_s_p_s[n * 9 + 2]);

                        PRIM_INT__p_s_p_s[n * 9 + 3] = SIMINT_MUL(Q_PA[0], PRIM_INT__p_s_s_s[n * 3 + 1]);
                        PRIM_INT__p_s_p_s[n * 9 + 3] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__p_s_s_s[(n+1) * 3 + 1], PRIM_INT__p_s_p_s[n * 9 + 3]);

                        PRIM_INT__p_s_p_s[n * 9 + 4] = SIMINT_MUL(Q_PA[1], PRIM_INT__p_s_s_s[n * 3 + 1]);
                        PRIM_INT__p_s_p_s[n * 9 + 4] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__p_s_s_s[(n+1) * 3 + 1], PRIM_INT__p_s_p_s[n * 9 + 4]);
                        PRIM_INT__p_s_p_s[n * 9 + 4] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__p_s_p_s[n * 9 + 4]);

                        PRIM_INT__p_s_p_s[n * 9 + 5] = SIMINT_MUL(Q_PA[2], PRIM_INT__p_s_s_s[n * 3 + 1]);
                        PRIM_INT__p_s_p_s[n * 9 + 5] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__p_s_s_s[(n+1) * 3 + 1], PRIM_INT__p_s_p_s[n * 9 + 5]);

                        PRIM_INT__p_s_p_s[n * 9 + 6] = SIMINT_MUL(Q_PA[0], PRIM_INT__p_s_s_s[n * 3 + 2]);
                        PRIM_INT__p_s_p_s[n * 9 + 6] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__p_s_s_s[(n+1) * 3 + 2], PRIM_INT__p_s_p_s[n * 9 + 6]);

                        PRIM_INT__p_s_p_s[n * 9 + 7] = SIMINT_MUL(Q_PA[1], PRIM_INT__p_s_s_s[n * 3 + 2]);
                        PRIM_INT__p_s_p_s[n * 9 + 7] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__p_s_s_s[(n+1) * 3 + 2], PRIM_INT__p_s_p_s[n * 9 + 7]);

                        PRIM_INT__p_s_p_s[n * 9 + 8] = SIMINT_MUL(Q_PA[2], PRIM_INT__p_s_s_s[n * 3 + 2]);
                        PRIM_INT__p_s_p_s[n * 9 + 8] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__p_s_s_s[(n+1) * 3 + 2], PRIM_INT__p_s_p_s[n * 9 + 8]);
                        PRIM_INT__p_s_p_s[n * 9 + 8] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__p_s_p_s[n * 9 + 8]);

                    }


                    VRR_K_d_s_d_s(
                            PRIM_INT__d_s_d_s,
                            PRIM_INT__d_s_p_s,
                            PRIM_INT__d_s_s_s,
                            PRIM_INT__p_s_p_s,
                            Q_PA,
                            a_over_q,
                            aoq_PQ,
                            one_over_2pq,
                            one_over_2q,
                            5);


                    ostei_general_vrr_K(3, 0, 3, 0, 4,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__f_s_d_s, PRIM_INT__f_s_p_s, NULL, PRIM_INT__d_s_d_s, NULL, PRIM_INT__f_s_f_s);


                    ostei_general_vrr_K(4, 0, 4, 0, 3,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__g_s_f_s, PRIM_INT__g_s_d_s, NULL, PRIM_INT__f_s_f_s, NULL, PRIM_INT__g_s_g_s);


                    ostei_general_vrr_K(5, 0, 5, 0, 2,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__h_s_g_s, PRIM_INT__h_s_f_s, NULL, PRIM_INT__g_s_g_s, NULL, PRIM_INT__h_s_h_s);


                    ostei_general_vrr_K(6, 0, 6, 0, 1,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__i_s_h_s, PRIM_INT__i_s_g_s, NULL, PRIM_INT__h_s_h_s, NULL, PRIM_INT__i_s_i_s);


                    ostei_general_vrr_K(7, 0, 5, 0, 2,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__k_s_g_s, PRIM_INT__k_s_f_s, NULL, PRIM_INT__i_s_g_s, NULL, PRIM_INT__k_s_h_s);


                    ostei_general_vrr_K(8, 0, 4, 0, 3,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__l_s_f_s, PRIM_INT__l_s_d_s, NULL, PRIM_INT__k_s_f_s, NULL, PRIM_INT__l_s_g_s);


                    ostei_general_vrr1_I(9, 10,
                            one_over_2p, a_over_p, aop_PQ, P_PA,
                            PRIM_INT__l_s_s_s, PRIM_INT__k_s_s_s, PRIM_INT__m_s_s_s);


                    ostei_general_vrr_K(9, 0, 1, 0, 6,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__m_s_s_s, NULL, NULL, PRIM_INT__l_s_s_s, NULL, PRIM_INT__m_s_p_s);


                    ostei_general_vrr_K(9, 0, 2, 0, 5,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__m_s_p_s, PRIM_INT__m_s_s_s, NULL, PRIM_INT__l_s_p_s, NULL, PRIM_INT__m_s_d_s);


                    ostei_general_vrr_K(9, 0, 3, 0, 4,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__m_s_d_s, PRIM_INT__m_s_p_s, NULL, PRIM_INT__l_s_d_s, NULL, PRIM_INT__m_s_f_s);


                    ostei_general_vrr_K(7, 0, 6, 0, 1,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__k_s_h_s, PRIM_INT__k_s_g_s, NULL, PRIM_INT__i_s_h_s, NULL, PRIM_INT__k_s_i_s);


                    ostei_general_vrr_K(8, 0, 5, 0, 2,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__l_s_g_s, PRIM_INT__l_s_f_s, NULL, PRIM_INT__k_s_g_s, NULL, PRIM_INT__l_s_h_s);


                    ostei_general_vrr_K(9, 0, 4, 0, 3,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__m_s_f_s, PRIM_INT__m_s_d_s, NULL, PRIM_INT__l_s_f_s, NULL, PRIM_INT__m_s_g_s);


                    ostei_general_vrr1_I(10, 9,
                            one_over_2p, a_over_p, aop_PQ, P_PA,
                            PRIM_INT__m_s_s_s, PRIM_INT__l_s_s_s, PRIM_INT__n_s_s_s);


                    ostei_general_vrr_K(10, 0, 1, 0, 6,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__n_s_s_s, NULL, NULL, PRIM_INT__m_s_s_s, NULL, PRIM_INT__n_s_p_s);


                    ostei_general_vrr_K(10, 0, 2, 0, 5,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__n_s_p_s, PRIM_INT__n_s_s_s, NULL, PRIM_INT__m_s_p_s, NULL, PRIM_INT__n_s_d_s);


                    ostei_general_vrr_K(10, 0, 3, 0, 4,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__n_s_d_s, PRIM_INT__n_s_p_s, NULL, PRIM_INT__m_s_d_s, NULL, PRIM_INT__n_s_f_s);


                    ostei_general_vrr_K(8, 0, 6, 0, 1,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__l_s_h_s, PRIM_INT__l_s_g_s, NULL, PRIM_INT__k_s_h_s, NULL, PRIM_INT__l_s_i_s);


                    ostei_general_vrr_K(9, 0, 5, 0, 2,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__m_s_g_s, PRIM_INT__m_s_f_s, NULL, PRIM_INT__l_s_g_s, NULL, PRIM_INT__m_s_h_s);


                    ostei_general_vrr_K(10, 0, 4, 0, 3,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__n_s_f_s, PRIM_INT__n_s_d_s, NULL, PRIM_INT__m_s_f_s, NULL, PRIM_INT__n_s_g_s);


                    ostei_general_vrr1_I(11, 8,
                            one_over_2p, a_over_p, aop_PQ, P_PA,
                            PRIM_INT__n_s_s_s, PRIM_INT__m_s_s_s, PRIM_INT__o_s_s_s);


                    ostei_general_vrr_K(11, 0, 1, 0, 6,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__o_s_s_s, NULL, NULL, PRIM_INT__n_s_s_s, NULL, PRIM_INT__o_s_p_s);


                    ostei_general_vrr_K(11, 0, 2, 0, 5,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__o_s_p_s, PRIM_INT__o_s_s_s, NULL, PRIM_INT__n_s_p_s, NULL, PRIM_INT__o_s_d_s);


                    ostei_general_vrr_K(11, 0, 3, 0, 4,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__o_s_d_s, PRIM_INT__o_s_p_s, NULL, PRIM_INT__n_s_d_s, NULL, PRIM_INT__o_s_f_s);


                    ostei_general_vrr_K(9, 0, 6, 0, 1,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__m_s_h_s, PRIM_INT__m_s_g_s, NULL, PRIM_INT__l_s_h_s, NULL, PRIM_INT__m_s_i_s);


                    ostei_general_vrr_K(10, 0, 5, 0, 2,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__n_s_g_s, PRIM_INT__n_s_f_s, NULL, PRIM_INT__m_s_g_s, NULL, PRIM_INT__n_s_h_s);


                    ostei_general_vrr_K(11, 0, 4, 0, 3,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__o_s_f_s, PRIM_INT__o_s_d_s, NULL, PRIM_INT__n_s_f_s, NULL, PRIM_INT__o_s_g_s);


                    ostei_general_vrr1_I(12, 7,
                            one_over_2p, a_over_p, aop_PQ, P_PA,
                            PRIM_INT__o_s_s_s, PRIM_INT__n_s_s_s, PRIM_INT__q_s_s_s);


                    ostei_general_vrr_K(12, 0, 1, 0, 6,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__q_s_s_s, NULL, NULL, PRIM_INT__o_s_s_s, NULL, PRIM_INT__q_s_p_s);


                    ostei_general_vrr_K(12, 0, 2, 0, 5,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__q_s_p_s, PRIM_INT__q_s_s_s, NULL, PRIM_INT__o_s_p_s, NULL, PRIM_INT__q_s_d_s);


                    ostei_general_vrr_K(12, 0, 3, 0, 4,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__q_s_d_s, PRIM_INT__q_s_p_s, NULL, PRIM_INT__o_s_d_s, NULL, PRIM_INT__q_s_f_s);


                    ostei_general_vrr_K(10, 0, 6, 0, 1,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__n_s_h_s, PRIM_INT__n_s_g_s, NULL, PRIM_INT__m_s_h_s, NULL, PRIM_INT__n_s_i_s);


                    ostei_general_vrr_K(11, 0, 5, 0, 2,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__o_s_g_s, PRIM_INT__o_s_f_s, NULL, PRIM_INT__n_s_g_s, NULL, PRIM_INT__o_s_h_s);


                    ostei_general_vrr_K(12, 0, 4, 0, 3,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__q_s_f_s, PRIM_INT__q_s_d_s, NULL, PRIM_INT__o_s_f_s, NULL, PRIM_INT__q_s_g_s);


                    ostei_general_vrr_K(11, 0, 6, 0, 1,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__o_s_h_s, PRIM_INT__o_s_g_s, NULL, PRIM_INT__n_s_h_s, NULL, PRIM_INT__o_s_i_s);


                    ostei_general_vrr_K(12, 0, 5, 0, 2,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__q_s_g_s, PRIM_INT__q_s_f_s, NULL, PRIM_INT__o_s_g_s, NULL, PRIM_INT__q_s_h_s);


                    ostei_general_vrr_K(12, 0, 6, 0, 1,
                            one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
                            PRIM_INT__q_s_h_s, PRIM_INT__q_s_g_s, NULL, PRIM_INT__o_s_h_s, NULL, PRIM_INT__q_s_i_s);




                    ////////////////////////////////////
                    // Accumulate contracted integrals
                    ////////////////////////////////////
                    if(lastoffset == 0)
                    {
                        contract_all(280, PRIM_INT__i_s_f_s, PRIM_PTR_INT__i_s_f_s);
                        contract_all(420, PRIM_INT__i_s_g_s, PRIM_PTR_INT__i_s_g_s);
                        contract_all(588, PRIM_INT__i_s_h_s, PRIM_PTR_INT__i_s_h_s);
                        contract_all(784, PRIM_INT__i_s_i_s, PRIM_PTR_INT__i_s_i_s);
                        contract_all(360, PRIM_INT__k_s_f_s, PRIM_PTR_INT__k_s_f_s);
                        contract_all(540, PRIM_INT__k_s_g_s, PRIM_PTR_INT__k_s_g_s);
                        contract_all(756, PRIM_INT__k_s_h_s, PRIM_PTR_INT__k_s_h_s);
                        contract_all(1008, PRIM_INT__k_s_i_s, PRIM_PTR_INT__k_s_i_s);
                        contract_all(450, PRIM_INT__l_s_f_s, PRIM_PTR_INT__l_s_f_s);
                        contract_all(675, PRIM_INT__l_s_g_s, PRIM_PTR_INT__l_s_g_s);
                        contract_all(945, PRIM_INT__l_s_h_s, PRIM_PTR_INT__l_s_h_s);
                        contract_all(1260, PRIM_INT__l_s_i_s, PRIM_PTR_INT__l_s_i_s);
                        contract_all(550, PRIM_INT__m_s_f_s, PRIM_PTR_INT__m_s_f_s);
                        contract_all(825, PRIM_INT__m_s_g_s, PRIM_PTR_INT__m_s_g_s);
                        contract_all(1155, PRIM_INT__m_s_h_s, PRIM_PTR_INT__m_s_h_s);
                        contract_all(1540, PRIM_INT__m_s_i_s, PRIM_PTR_INT__m_s_i_s);
                        contract_all(660, PRIM_INT__n_s_f_s, PRIM_PTR_INT__n_s_f_s);
                        contract_all(990, PRIM_INT__n_s_g_s, PRIM_PTR_INT__n_s_g_s);
                        contract_all(1386, PRIM_INT__n_s_h_s, PRIM_PTR_INT__n_s_h_s);
                        contract_all(1848, PRIM_INT__n_s_i_s, PRIM_PTR_INT__n_s_i_s);
                        contract_all(780, PRIM_INT__o_s_f_s, PRIM_PTR_INT__o_s_f_s);
                        contract_all(1170, PRIM_INT__o_s_g_s, PRIM_PTR_INT__o_s_g_s);
                        contract_all(1638, PRIM_INT__o_s_h_s, PRIM_PTR_INT__o_s_h_s);
                        contract_all(2184, PRIM_INT__o_s_i_s, PRIM_PTR_INT__o_s_i_s);
                        contract_all(910, PRIM_INT__q_s_f_s, PRIM_PTR_INT__q_s_f_s);
                        contract_all(1365, PRIM_INT__q_s_g_s, PRIM_PTR_INT__q_s_g_s);
                        contract_all(1911, PRIM_INT__q_s_h_s, PRIM_PTR_INT__q_s_h_s);
                        contract_all(2548, PRIM_INT__q_s_i_s, PRIM_PTR_INT__q_s_i_s);
                    }
                    else
                    {
                        contract(280, shelloffsets, PRIM_INT__i_s_f_s, PRIM_PTR_INT__i_s_f_s);
                        contract(420, shelloffsets, PRIM_INT__i_s_g_s, PRIM_PTR_INT__i_s_g_s);
                        contract(588, shelloffsets, PRIM_INT__i_s_h_s, PRIM_PTR_INT__i_s_h_s);
                        contract(784, shelloffsets, PRIM_INT__i_s_i_s, PRIM_PTR_INT__i_s_i_s);
                        contract(360, shelloffsets, PRIM_INT__k_s_f_s, PRIM_PTR_INT__k_s_f_s);
                        contract(540, shelloffsets, PRIM_INT__k_s_g_s, PRIM_PTR_INT__k_s_g_s);
                        contract(756, shelloffsets, PRIM_INT__k_s_h_s, PRIM_PTR_INT__k_s_h_s);
                        contract(1008, shelloffsets, PRIM_INT__k_s_i_s, PRIM_PTR_INT__k_s_i_s);
                        contract(450, shelloffsets, PRIM_INT__l_s_f_s, PRIM_PTR_INT__l_s_f_s);
                        contract(675, shelloffsets, PRIM_INT__l_s_g_s, PRIM_PTR_INT__l_s_g_s);
                        contract(945, shelloffsets, PRIM_INT__l_s_h_s, PRIM_PTR_INT__l_s_h_s);
                        contract(1260, shelloffsets, PRIM_INT__l_s_i_s, PRIM_PTR_INT__l_s_i_s);
                        contract(550, shelloffsets, PRIM_INT__m_s_f_s, PRIM_PTR_INT__m_s_f_s);
                        contract(825, shelloffsets, PRIM_INT__m_s_g_s, PRIM_PTR_INT__m_s_g_s);
                        contract(1155, shelloffsets, PRIM_INT__m_s_h_s, PRIM_PTR_INT__m_s_h_s);
                        contract(1540, shelloffsets, PRIM_INT__m_s_i_s, PRIM_PTR_INT__m_s_i_s);
                        contract(660, shelloffsets, PRIM_INT__n_s_f_s, PRIM_PTR_INT__n_s_f_s);
                        contract(990, shelloffsets, PRIM_INT__n_s_g_s, PRIM_PTR_INT__n_s_g_s);
                        contract(1386, shelloffsets, PRIM_INT__n_s_h_s, PRIM_PTR_INT__n_s_h_s);
                        contract(1848, shelloffsets, PRIM_INT__n_s_i_s, PRIM_PTR_INT__n_s_i_s);
                        contract(780, shelloffsets, PRIM_INT__o_s_f_s, PRIM_PTR_INT__o_s_f_s);
                        contract(1170, shelloffsets, PRIM_INT__o_s_g_s, PRIM_PTR_INT__o_s_g_s);
                        contract(1638, shelloffsets, PRIM_INT__o_s_h_s, PRIM_PTR_INT__o_s_h_s);
                        contract(2184, shelloffsets, PRIM_INT__o_s_i_s, PRIM_PTR_INT__o_s_i_s);
                        contract(910, shelloffsets, PRIM_INT__q_s_f_s, PRIM_PTR_INT__q_s_f_s);
                        contract(1365, shelloffsets, PRIM_INT__q_s_g_s, PRIM_PTR_INT__q_s_g_s);
                        contract(1911, shelloffsets, PRIM_INT__q_s_h_s, PRIM_PTR_INT__q_s_h_s);
                        contract(2548, shelloffsets, PRIM_INT__q_s_i_s, PRIM_PTR_INT__q_s_i_s);
                        PRIM_PTR_INT__i_s_f_s += lastoffset*280;
                        PRIM_PTR_INT__i_s_g_s += lastoffset*420;
                        PRIM_PTR_INT__i_s_h_s += lastoffset*588;
                        PRIM_PTR_INT__i_s_i_s += lastoffset*784;
                        PRIM_PTR_INT__k_s_f_s += lastoffset*360;
                        PRIM_PTR_INT__k_s_g_s += lastoffset*540;
                        PRIM_PTR_INT__k_s_h_s += lastoffset*756;
                        PRIM_PTR_INT__k_s_i_s += lastoffset*1008;
                        PRIM_PTR_INT__l_s_f_s += lastoffset*450;
                        PRIM_PTR_INT__l_s_g_s += lastoffset*675;
                        PRIM_PTR_INT__l_s_h_s += lastoffset*945;
                        PRIM_PTR_INT__l_s_i_s += lastoffset*1260;
                        PRIM_PTR_INT__m_s_f_s += lastoffset*550;
                        PRIM_PTR_INT__m_s_g_s += lastoffset*825;
                        PRIM_PTR_INT__m_s_h_s += lastoffset*1155;
                        PRIM_PTR_INT__m_s_i_s += lastoffset*1540;
                        PRIM_PTR_INT__n_s_f_s += lastoffset*660;
                        PRIM_PTR_INT__n_s_g_s += lastoffset*990;
                        PRIM_PTR_INT__n_s_h_s += lastoffset*1386;
                        PRIM_PTR_INT__n_s_i_s += lastoffset*1848;
                        PRIM_PTR_INT__o_s_f_s += lastoffset*780;
                        PRIM_PTR_INT__o_s_g_s += lastoffset*1170;
                        PRIM_PTR_INT__o_s_h_s += lastoffset*1638;
                        PRIM_PTR_INT__o_s_i_s += lastoffset*2184;
                        PRIM_PTR_INT__q_s_f_s += lastoffset*910;
                        PRIM_PTR_INT__q_s_g_s += lastoffset*1365;
                        PRIM_PTR_INT__q_s_h_s += lastoffset*1911;
                        PRIM_PTR_INT__q_s_i_s += lastoffset*2548;
                    }

                }  // 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__i_s_f_s = INT__i_s_f_s + abcd * 280;
                double const * restrict HRR_INT__i_s_g_s = INT__i_s_g_s + abcd * 420;
                double const * restrict HRR_INT__i_s_h_s = INT__i_s_h_s + abcd * 588;
                double const * restrict HRR_INT__i_s_i_s = INT__i_s_i_s + abcd * 784;
                double const * restrict HRR_INT__k_s_f_s = INT__k_s_f_s + abcd * 360;
                double const * restrict HRR_INT__k_s_g_s = INT__k_s_g_s + abcd * 540;
                double const * restrict HRR_INT__k_s_h_s = INT__k_s_h_s + abcd * 756;
                double const * restrict HRR_INT__k_s_i_s = INT__k_s_i_s + abcd * 1008;
                double const * restrict HRR_INT__l_s_f_s = INT__l_s_f_s + abcd * 450;
                double const * restrict HRR_INT__l_s_g_s = INT__l_s_g_s + abcd * 675;
                double const * restrict HRR_INT__l_s_h_s = INT__l_s_h_s + abcd * 945;
                double const * restrict HRR_INT__l_s_i_s = INT__l_s_i_s + abcd * 1260;
                double const * restrict HRR_INT__m_s_f_s = INT__m_s_f_s + abcd * 550;
                double const * restrict HRR_INT__m_s_g_s = INT__m_s_g_s + abcd * 825;
                double const * restrict HRR_INT__m_s_h_s = INT__m_s_h_s + abcd * 1155;
                double const * restrict HRR_INT__m_s_i_s = INT__m_s_i_s + abcd * 1540;
                double const * restrict HRR_INT__n_s_f_s = INT__n_s_f_s + abcd * 660;
                double const * restrict HRR_INT__n_s_g_s = INT__n_s_g_s + abcd * 990;
                double const * restrict HRR_INT__n_s_h_s = INT__n_s_h_s + abcd * 1386;
                double const * restrict HRR_INT__n_s_i_s = INT__n_s_i_s + abcd * 1848;
                double const * restrict HRR_INT__o_s_f_s = INT__o_s_f_s + abcd * 780;
                double const * restrict HRR_INT__o_s_g_s = INT__o_s_g_s + abcd * 1170;
                double const * restrict HRR_INT__o_s_h_s = INT__o_s_h_s + abcd * 1638;
                double const * restrict HRR_INT__o_s_i_s = INT__o_s_i_s + abcd * 2184;
                double const * restrict HRR_INT__q_s_f_s = INT__q_s_f_s + abcd * 910;
                double const * restrict HRR_INT__q_s_g_s = INT__q_s_g_s + abcd * 1365;
                double const * restrict HRR_INT__q_s_h_s = INT__q_s_h_s + abcd * 1911;
                double const * restrict HRR_INT__q_s_i_s = INT__q_s_i_s + abcd * 2548;
                double * restrict HRR_INT__i_i_f_f = INT__i_i_f_f + real_abcd * 78400;

                // form INT__i_p_f_s
                ostei_general_hrr_J(6, 1, 3, 0, hAB, HRR_INT__k_s_f_s, HRR_INT__i_s_f_s, HRR_INT__i_p_f_s);

                // form INT__i_p_g_s
                ostei_general_hrr_J(6, 1, 4, 0, hAB, HRR_INT__k_s_g_s, HRR_INT__i_s_g_s, HRR_INT__i_p_g_s);

                // form INT__i_p_h_s
                ostei_general_hrr_J(6, 1, 5, 0, hAB, HRR_INT__k_s_h_s, HRR_INT__i_s_h_s, HRR_INT__i_p_h_s);

                // form INT__i_p_i_s
                ostei_general_hrr_J(6, 1, 6, 0, hAB, HRR_INT__k_s_i_s, HRR_INT__i_s_i_s, HRR_INT__i_p_i_s);

                // form INT__k_p_f_s
                ostei_general_hrr_J(7, 1, 3, 0, hAB, HRR_INT__l_s_f_s, HRR_INT__k_s_f_s, HRR_INT__k_p_f_s);

                // form INT__k_p_g_s
                ostei_general_hrr_J(7, 1, 4, 0, hAB, HRR_INT__l_s_g_s, HRR_INT__k_s_g_s, HRR_INT__k_p_g_s);

                // form INT__k_p_h_s
                ostei_general_hrr_J(7, 1, 5, 0, hAB, HRR_INT__l_s_h_s, HRR_INT__k_s_h_s, HRR_INT__k_p_h_s);

                // form INT__k_p_i_s
                ostei_general_hrr_J(7, 1, 6, 0, hAB, HRR_INT__l_s_i_s, HRR_INT__k_s_i_s, HRR_INT__k_p_i_s);

                // form INT__l_p_f_s
                ostei_general_hrr_J(8, 1, 3, 0, hAB, HRR_INT__m_s_f_s, HRR_INT__l_s_f_s, HRR_INT__l_p_f_s);

                // form INT__l_p_g_s
                ostei_general_hrr_J(8, 1, 4, 0, hAB, HRR_INT__m_s_g_s, HRR_INT__l_s_g_s, HRR_INT__l_p_g_s);

                // form INT__l_p_h_s
                ostei_general_hrr_J(8, 1, 5, 0, hAB, HRR_INT__m_s_h_s, HRR_INT__l_s_h_s, HRR_INT__l_p_h_s);

                // form INT__l_p_i_s
                ostei_general_hrr_J(8, 1, 6, 0, hAB, HRR_INT__m_s_i_s, HRR_INT__l_s_i_s, HRR_INT__l_p_i_s);

                // form INT__m_p_f_s
                ostei_general_hrr_J(9, 1, 3, 0, hAB, HRR_INT__n_s_f_s, HRR_INT__m_s_f_s, HRR_INT__m_p_f_s);

                // form INT__m_p_g_s
                ostei_general_hrr_J(9, 1, 4, 0, hAB, HRR_INT__n_s_g_s, HRR_INT__m_s_g_s, HRR_INT__m_p_g_s);

                // form INT__m_p_h_s
                ostei_general_hrr_J(9, 1, 5, 0, hAB, HRR_INT__n_s_h_s, HRR_INT__m_s_h_s, HRR_INT__m_p_h_s);

                // form INT__m_p_i_s
                ostei_general_hrr_J(9, 1, 6, 0, hAB, HRR_INT__n_s_i_s, HRR_INT__m_s_i_s, HRR_INT__m_p_i_s);

                // form INT__n_p_f_s
                ostei_general_hrr_J(10, 1, 3, 0, hAB, HRR_INT__o_s_f_s, HRR_INT__n_s_f_s, HRR_INT__n_p_f_s);

                // form INT__n_p_g_s
                ostei_general_hrr_J(10, 1, 4, 0, hAB, HRR_INT__o_s_g_s, HRR_INT__n_s_g_s, HRR_INT__n_p_g_s);

                // form INT__n_p_h_s
                ostei_general_hrr_J(10, 1, 5, 0, hAB, HRR_INT__o_s_h_s, HRR_INT__n_s_h_s, HRR_INT__n_p_h_s);

                // form INT__n_p_i_s
                ostei_general_hrr_J(10, 1, 6, 0, hAB, HRR_INT__o_s_i_s, HRR_INT__n_s_i_s, HRR_INT__n_p_i_s);

                // form INT__o_p_f_s
                ostei_general_hrr_J(11, 1, 3, 0, hAB, HRR_INT__q_s_f_s, HRR_INT__o_s_f_s, HRR_INT__o_p_f_s);

                // form INT__o_p_g_s
                ostei_general_hrr_J(11, 1, 4, 0, hAB, HRR_INT__q_s_g_s, HRR_INT__o_s_g_s, HRR_INT__o_p_g_s);

                // form INT__o_p_h_s
                ostei_general_hrr_J(11, 1, 5, 0, hAB, HRR_INT__q_s_h_s, HRR_INT__o_s_h_s, HRR_INT__o_p_h_s);

                // form INT__o_p_i_s
                ostei_general_hrr_J(11, 1, 6, 0, hAB, HRR_INT__q_s_i_s, HRR_INT__o_s_i_s, HRR_INT__o_p_i_s);

                // form INT__i_d_f_s
                ostei_general_hrr_J(6, 2, 3, 0, hAB, HRR_INT__k_p_f_s, HRR_INT__i_p_f_s, HRR_INT__i_d_f_s);

                // form INT__i_d_g_s
                ostei_general_hrr_J(6, 2, 4, 0, hAB, HRR_INT__k_p_g_s, HRR_INT__i_p_g_s, HRR_INT__i_d_g_s);

                // form INT__i_d_h_s
                ostei_general_hrr_J(6, 2, 5, 0, hAB, HRR_INT__k_p_h_s, HRR_INT__i_p_h_s, HRR_INT__i_d_h_s);

                // form INT__i_d_i_s
                ostei_general_hrr_J(6, 2, 6, 0, hAB, HRR_INT__k_p_i_s, HRR_INT__i_p_i_s, HRR_INT__i_d_i_s);

                // form INT__k_d_f_s
                ostei_general_hrr_J(7, 2, 3, 0, hAB, HRR_INT__l_p_f_s, HRR_INT__k_p_f_s, HRR_INT__k_d_f_s);

                // form INT__k_d_g_s
                ostei_general_hrr_J(7, 2, 4, 0, hAB, HRR_INT__l_p_g_s, HRR_INT__k_p_g_s, HRR_INT__k_d_g_s);

                // form INT__k_d_h_s
                ostei_general_hrr_J(7, 2, 5, 0, hAB, HRR_INT__l_p_h_s, HRR_INT__k_p_h_s, HRR_INT__k_d_h_s);

                // form INT__k_d_i_s
                ostei_general_hrr_J(7, 2, 6, 0, hAB, HRR_INT__l_p_i_s, HRR_INT__k_p_i_s, HRR_INT__k_d_i_s);

                // form INT__l_d_f_s
                ostei_general_hrr_J(8, 2, 3, 0, hAB, HRR_INT__m_p_f_s, HRR_INT__l_p_f_s, HRR_INT__l_d_f_s);

                // form INT__l_d_g_s
                ostei_general_hrr_J(8, 2, 4, 0, hAB, HRR_INT__m_p_g_s, HRR_INT__l_p_g_s, HRR_INT__l_d_g_s);

                // form INT__l_d_h_s
                ostei_general_hrr_J(8, 2, 5, 0, hAB, HRR_INT__m_p_h_s, HRR_INT__l_p_h_s, HRR_INT__l_d_h_s);

                // form INT__l_d_i_s
                ostei_general_hrr_J(8, 2, 6, 0, hAB, HRR_INT__m_p_i_s, HRR_INT__l_p_i_s, HRR_INT__l_d_i_s);

                // form INT__m_d_f_s
                ostei_general_hrr_J(9, 2, 3, 0, hAB, HRR_INT__n_p_f_s, HRR_INT__m_p_f_s, HRR_INT__m_d_f_s);

                // form INT__m_d_g_s
                ostei_general_hrr_J(9, 2, 4, 0, hAB, HRR_INT__n_p_g_s, HRR_INT__m_p_g_s, HRR_INT__m_d_g_s);

                // form INT__m_d_h_s
                ostei_general_hrr_J(9, 2, 5, 0, hAB, HRR_INT__n_p_h_s, HRR_INT__m_p_h_s, HRR_INT__m_d_h_s);

                // form INT__m_d_i_s
                ostei_general_hrr_J(9, 2, 6, 0, hAB, HRR_INT__n_p_i_s, HRR_INT__m_p_i_s, HRR_INT__m_d_i_s);

                // form INT__n_d_f_s
                ostei_general_hrr_J(10, 2, 3, 0, hAB, HRR_INT__o_p_f_s, HRR_INT__n_p_f_s, HRR_INT__n_d_f_s);

                // form INT__n_d_g_s
                ostei_general_hrr_J(10, 2, 4, 0, hAB, HRR_INT__o_p_g_s, HRR_INT__n_p_g_s, HRR_INT__n_d_g_s);

                // form INT__n_d_h_s
                ostei_general_hrr_J(10, 2, 5, 0, hAB, HRR_INT__o_p_h_s, HRR_INT__n_p_h_s, HRR_INT__n_d_h_s);

                // form INT__n_d_i_s
                ostei_general_hrr_J(10, 2, 6, 0, hAB, HRR_INT__o_p_i_s, HRR_INT__n_p_i_s, HRR_INT__n_d_i_s);

                // form INT__i_f_f_s
                ostei_general_hrr_J(6, 3, 3, 0, hAB, HRR_INT__k_d_f_s, HRR_INT__i_d_f_s, HRR_INT__i_f_f_s);

                // form INT__i_f_g_s
                ostei_general_hrr_J(6, 3, 4, 0, hAB, HRR_INT__k_d_g_s, HRR_INT__i_d_g_s, HRR_INT__i_f_g_s);

                // form INT__i_f_h_s
                ostei_general_hrr_J(6, 3, 5, 0, hAB, HRR_INT__k_d_h_s, HRR_INT__i_d_h_s, HRR_INT__i_f_h_s);

                // form INT__i_f_i_s
                ostei_general_hrr_J(6, 3, 6, 0, hAB, HRR_INT__k_d_i_s, HRR_INT__i_d_i_s, HRR_INT__i_f_i_s);

                // form INT__k_f_f_s
                ostei_general_hrr_J(7, 3, 3, 0, hAB, HRR_INT__l_d_f_s, HRR_INT__k_d_f_s, HRR_INT__k_f_f_s);

                // form INT__k_f_g_s
                ostei_general_hrr_J(7, 3, 4, 0, hAB, HRR_INT__l_d_g_s, HRR_INT__k_d_g_s, HRR_INT__k_f_g_s);

                // form INT__k_f_h_s
                ostei_general_hrr_J(7, 3, 5, 0, hAB, HRR_INT__l_d_h_s, HRR_INT__k_d_h_s, HRR_INT__k_f_h_s);

                // form INT__k_f_i_s
                ostei_general_hrr_J(7, 3, 6, 0, hAB, HRR_INT__l_d_i_s, HRR_INT__k_d_i_s, HRR_INT__k_f_i_s);

                // form INT__l_f_f_s
                ostei_general_hrr_J(8, 3, 3, 0, hAB, HRR_INT__m_d_f_s, HRR_INT__l_d_f_s, HRR_INT__l_f_f_s);

                // form INT__l_f_g_s
                ostei_general_hrr_J(8, 3, 4, 0, hAB, HRR_INT__m_d_g_s, HRR_INT__l_d_g_s, HRR_INT__l_f_g_s);

                // form INT__l_f_h_s
                ostei_general_hrr_J(8, 3, 5, 0, hAB, HRR_INT__m_d_h_s, HRR_INT__l_d_h_s, HRR_INT__l_f_h_s);

                // form INT__l_f_i_s
                ostei_general_hrr_J(8, 3, 6, 0, hAB, HRR_INT__m_d_i_s, HRR_INT__l_d_i_s, HRR_INT__l_f_i_s);

                // form INT__m_f_f_s
                ostei_general_hrr_J(9, 3, 3, 0, hAB, HRR_INT__n_d_f_s, HRR_INT__m_d_f_s, HRR_INT__m_f_f_s);

                // form INT__m_f_g_s
                ostei_general_hrr_J(9, 3, 4, 0, hAB, HRR_INT__n_d_g_s, HRR_INT__m_d_g_s, HRR_INT__m_f_g_s);

                // form INT__m_f_h_s
                ostei_general_hrr_J(9, 3, 5, 0, hAB, HRR_INT__n_d_h_s, HRR_INT__m_d_h_s, HRR_INT__m_f_h_s);

                // form INT__m_f_i_s
                ostei_general_hrr_J(9, 3, 6, 0, hAB, HRR_INT__n_d_i_s, HRR_INT__m_d_i_s, HRR_INT__m_f_i_s);

                // form INT__i_g_f_s
                ostei_general_hrr_J(6, 4, 3, 0, hAB, HRR_INT__k_f_f_s, HRR_INT__i_f_f_s, HRR_INT__i_g_f_s);

                // form INT__i_g_g_s
                ostei_general_hrr_J(6, 4, 4, 0, hAB, HRR_INT__k_f_g_s, HRR_INT__i_f_g_s, HRR_INT__i_g_g_s);

                // form INT__i_g_h_s
                ostei_general_hrr_J(6, 4, 5, 0, hAB, HRR_INT__k_f_h_s, HRR_INT__i_f_h_s, HRR_INT__i_g_h_s);

                // form INT__i_g_i_s
                ostei_general_hrr_J(6, 4, 6, 0, hAB, HRR_INT__k_f_i_s, HRR_INT__i_f_i_s, HRR_INT__i_g_i_s);

                // form INT__k_g_f_s
                ostei_general_hrr_J(7, 4, 3, 0, hAB, HRR_INT__l_f_f_s, HRR_INT__k_f_f_s, HRR_INT__k_g_f_s);

                // form INT__k_g_g_s
                ostei_general_hrr_J(7, 4, 4, 0, hAB, HRR_INT__l_f_g_s, HRR_INT__k_f_g_s, HRR_INT__k_g_g_s);

                // form INT__k_g_h_s
                ostei_general_hrr_J(7, 4, 5, 0, hAB, HRR_INT__l_f_h_s, HRR_INT__k_f_h_s, HRR_INT__k_g_h_s);

                // form INT__k_g_i_s
                ostei_general_hrr_J(7, 4, 6, 0, hAB, HRR_INT__l_f_i_s, HRR_INT__k_f_i_s, HRR_INT__k_g_i_s);

                // form INT__l_g_f_s
                ostei_general_hrr_J(8, 4, 3, 0, hAB, HRR_INT__m_f_f_s, HRR_INT__l_f_f_s, HRR_INT__l_g_f_s);

                // form INT__l_g_g_s
                ostei_general_hrr_J(8, 4, 4, 0, hAB, HRR_INT__m_f_g_s, HRR_INT__l_f_g_s, HRR_INT__l_g_g_s);

                // form INT__l_g_h_s
                ostei_general_hrr_J(8, 4, 5, 0, hAB, HRR_INT__m_f_h_s, HRR_INT__l_f_h_s, HRR_INT__l_g_h_s);

                // form INT__l_g_i_s
                ostei_general_hrr_J(8, 4, 6, 0, hAB, HRR_INT__m_f_i_s, HRR_INT__l_f_i_s, HRR_INT__l_g_i_s);

                // form INT__i_h_f_s
                ostei_general_hrr_J(6, 5, 3, 0, hAB, HRR_INT__k_g_f_s, HRR_INT__i_g_f_s, HRR_INT__i_h_f_s);

                // form INT__i_h_g_s
                ostei_general_hrr_J(6, 5, 4, 0, hAB, HRR_INT__k_g_g_s, HRR_INT__i_g_g_s, HRR_INT__i_h_g_s);

                // form INT__i_h_h_s
                ostei_general_hrr_J(6, 5, 5, 0, hAB, HRR_INT__k_g_h_s, HRR_INT__i_g_h_s, HRR_INT__i_h_h_s);

                // form INT__i_h_i_s
                ostei_general_hrr_J(6, 5, 6, 0, hAB, HRR_INT__k_g_i_s, HRR_INT__i_g_i_s, HRR_INT__i_h_i_s);

                // form INT__k_h_f_s
                ostei_general_hrr_J(7, 5, 3, 0, hAB, HRR_INT__l_g_f_s, HRR_INT__k_g_f_s, HRR_INT__k_h_f_s);

                // form INT__k_h_g_s
                ostei_general_hrr_J(7, 5, 4, 0, hAB, HRR_INT__l_g_g_s, HRR_INT__k_g_g_s, HRR_INT__k_h_g_s);

                // form INT__k_h_h_s
                ostei_general_hrr_J(7, 5, 5, 0, hAB, HRR_INT__l_g_h_s, HRR_INT__k_g_h_s, HRR_INT__k_h_h_s);

                // form INT__k_h_i_s
                ostei_general_hrr_J(7, 5, 6, 0, hAB, HRR_INT__l_g_i_s, HRR_INT__k_g_i_s, HRR_INT__k_h_i_s);

                // form INT__i_i_f_s
                ostei_general_hrr_J(6, 6, 3, 0, hAB, HRR_INT__k_h_f_s, HRR_INT__i_h_f_s, HRR_INT__i_i_f_s);

                // form INT__i_i_g_s
                ostei_general_hrr_J(6, 6, 4, 0, hAB, HRR_INT__k_h_g_s, HRR_INT__i_h_g_s, HRR_INT__i_i_g_s);

                // form INT__i_i_h_s
                ostei_general_hrr_J(6, 6, 5, 0, hAB, HRR_INT__k_h_h_s, HRR_INT__i_h_h_s, HRR_INT__i_i_h_s);

                // form INT__i_i_i_s
                ostei_general_hrr_J(6, 6, 6, 0, hAB, HRR_INT__k_h_i_s, HRR_INT__i_h_i_s, HRR_INT__i_i_i_s);

                // form INT__i_i_f_p
                HRR_L_f_p(
                    HRR_INT__i_i_f_p,
                    HRR_INT__i_i_f_s,
                    HRR_INT__i_i_g_s,
                    hCD, 784);

                // form INT__i_i_g_p
                HRR_L_g_p(
                    HRR_INT__i_i_g_p,
                    HRR_INT__i_i_g_s,
                    HRR_INT__i_i_h_s,
                    hCD, 784);

                // form INT__i_i_h_p
                ostei_general_hrr_L(6, 6, 5, 1, hCD, HRR_INT__i_i_i_s, HRR_INT__i_i_h_s, HRR_INT__i_i_h_p);

                // form INT__i_i_f_d
                HRR_L_f_d(
                    HRR_INT__i_i_f_d,
                    HRR_INT__i_i_f_p,
                    HRR_INT__i_i_g_p,
                    hCD, 784);

                // form INT__i_i_g_d
                ostei_general_hrr_L(6, 6, 4, 2, hCD, HRR_INT__i_i_h_p, HRR_INT__i_i_g_p, HRR_INT__i_i_g_d);

                // form INT__i_i_f_f
                ostei_general_hrr_L(6, 6, 3, 3, hCD, HRR_INT__i_i_g_d, HRR_INT__i_i_f_d, HRR_INT__i_i_f_f);


            }  // close HRR loop


        }   // close loop cdbatch

        istart = iend;
    }  // close loop over ab

    return P.nshell12_clip * Q.nshell12_clip;
}

