openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/libxcrypt/4.4.6-r0/git/lib/alg-yescrypt-opt.c
static void smix2(uint8_t* B, size_t r, uint32_t N, uint64_t Nloop,
                  yescrypt_flags_t flags, salsa20_blk_t* V, uint32_t NROM,
                  const salsa20_blk_t* VROM, salsa20_blk_t* XY,
                  pwxform_ctx_t* ctx)
{
    size_t s = 2 * r;
    salsa20_blk_t *X = XY, *Y = &XY[s];
    uint32_t i, j;

    if (Nloop == 0)
        return;

    for (i = 0; i < 2 * r; i++)
    {
        const salsa20_blk_t* src = (salsa20_blk_t*)&B[i * 64];
        salsa20_blk_t* tmp = Y;
        salsa20_blk_t* dst = &X[i];
        size_t k;
        for (k = 0; k < 16; k++)
            tmp->w[k] = le32dec(&src->w[k]);
        salsa20_simd_shuffle(tmp, dst);
    }

    j = integerify(X, r) & (N - 1);

    /*
     * Normally, VROM implies YESCRYPT_RW, but we check for these separately
     * because our SMix resets YESCRYPT_RW for the smix2() calls operating on
     * the entire V when p > 1.
     */
    if (VROM && (flags & YESCRYPT_RW))
    {
        do
        {
            salsa20_blk_t* V_j = &V[j * s];
            const salsa20_blk_t* VROM_j;
            j = blockmix_xor_save(X, V_j, r, ctx) & (NROM - 1);
            VROM_j = &VROM[j * s];
            j = blockmix_xor(X, VROM_j, X, r, 1, ctx) & (N - 1);
        } while (Nloop -= 2);
    }
    else if (VROM)
    {
        do
        {
            const salsa20_blk_t* V_j = &V[j * s];
            j = blockmix_xor(X, V_j, X, r, 0, ctx) & (NROM - 1);
            V_j = &VROM[j * s];
            j = blockmix_xor(X, V_j, X, r, 1, ctx) & (N - 1);
        } while (Nloop -= 2);
    }
    else if (flags & YESCRYPT_RW)
    {
        do
        {
            salsa20_blk_t* V_j = &V[j * s];
            j = blockmix_xor_save(X, V_j, r, ctx) & (N - 1);
            V_j = &V[j * s];
            j = blockmix_xor_save(X, V_j, r, ctx) & (N - 1);
        } while (Nloop -= 2);
    }
    else if (ctx)
    {
        do
        {
            const salsa20_blk_t* V_j = &V[j * s];
            j = blockmix_xor(X, V_j, X, r, 0, ctx) & (N - 1);
            V_j = &V[j * s];
            j = blockmix_xor(X, V_j, X, r, 0, ctx) & (N - 1);
        } while (Nloop -= 2);
    }
    else
    {
        do
        {
            const salsa20_blk_t* V_j = &V[j * s];
            j = blockmix_salsa8_xor(X, V_j, Y, r) & (N - 1);
            V_j = &V[j * s];
            j = blockmix_salsa8_xor(Y, V_j, X, r) & (N - 1);
        } while (Nloop -= 2);
    }

    for (i = 0; i < 2 * r; i++)
    {
        const salsa20_blk_t* src = &X[i];
        salsa20_blk_t* tmp = Y;
        salsa20_blk_t* dst = (salsa20_blk_t*)&B[i * 64];
        size_t k;
        for (k = 0; k < 16; k++)
            le32enc(&tmp->w[k], src->w[k]);
        salsa20_simd_unshuffle(tmp, dst);
    }
}
/**
 * smix2(B, r, N, Nloop, flags, V, NROM, VROM, XY, ctx):
 * Compute second loop of B = SMix_r(B, N).  The input B must be 128r bytes in
 * length; the temporary storage V must be 128rN bytes in length; the temporary
 * storage XY must be 256r bytes in length.  N must be a power of 2 and at
 * least 2.  Nloop must be even.  The array V must be aligned to a multiple of
 * 64 bytes, and arrays B and XY to a multiple of at least 16 bytes.
 */
smix2(B, r, N, Nloop, flags, V, NROM, VROM, XY, ctx):
Compute second loop of B = SMix_r(B, N).  The input B must be 128r bytes in
length; the temporary storage V must be 128rN bytes in length; the temporary
storage XY must be 256r bytes in length.  N must be a power of 2 and at
least 2.  Nloop must be even.  The array V must be aligned to a multiple of
64 bytes, and arrays B and XY to a multiple of at least 16 bytes.
smix2 ( B r N Nloop flags V NROM VROM XY ctx ) : Compute second loop of B = SMix_r ( B N ) . The input B must be 128r bytes in length ; the temporary storage V must be 128rN bytes in length ; the temporary storage XY must be 256r bytes in length . N must be a power of 2 and at least 2 . Nloop must be even . The array V must be aligned to a multiple of 64 bytes and arrays B and XY to a multiple of at least 16 bytes .
static void smix2(uint8_t* B, size_t r, uint32_t N, uint64_t Nloop,
                  yescrypt_flags_t flags, salsa20_blk_t* V, uint32_t NROM,
                  const salsa20_blk_t* VROM, salsa20_blk_t* XY,
                  pwxform_ctx_t* ctx)
{
    size_t s = 2 * r;
    salsa20_blk_t *X = XY, *Y = &XY[s];
    uint32_t i, j;
    if (Nloop == 0)
        return;
    for (i = 0; i < 2 * r; i++)
    {
        const salsa20_blk_t* src = (salsa20_blk_t*)&B[i * 64];
        salsa20_blk_t* tmp = Y;
        salsa20_blk_t* dst = &X[i];
        size_t k;
        for (k = 0; k < 16; k++)
            tmp->w[k] = le32dec(&src->w[k]);
        salsa20_simd_shuffle(tmp, dst);
    }
    j = integerify(X, r) & (N - 1);
    if (VROM && (flags & YESCRYPT_RW))
    {
        do
        {
            salsa20_blk_t* V_j = &V[j * s];
            const salsa20_blk_t* VROM_j;
            j = blockmix_xor_save(X, V_j, r, ctx) & (NROM - 1);
            VROM_j = &VROM[j * s];
            j = blockmix_xor(X, VROM_j, X, r, 1, ctx) & (N - 1);
        } while (Nloop -= 2);
    }
    else if (VROM)
    {
        do
        {
            const salsa20_blk_t* V_j = &V[j * s];
            j = blockmix_xor(X, V_j, X, r, 0, ctx) & (NROM - 1);
            V_j = &VROM[j * s];
            j = blockmix_xor(X, V_j, X, r, 1, ctx) & (N - 1);
        } while (Nloop -= 2);
    }
    else if (flags & YESCRYPT_RW)
    {
        do
        {
            salsa20_blk_t* V_j = &V[j * s];
            j = blockmix_xor_save(X, V_j, r, ctx) & (N - 1);
            V_j = &V[j * s];
            j = blockmix_xor_save(X, V_j, r, ctx) & (N - 1);
        } while (Nloop -= 2);
    }
    else if (ctx)
    {
        do
        {
            const salsa20_blk_t* V_j = &V[j * s];
            j = blockmix_xor(X, V_j, X, r, 0, ctx) & (N - 1);
            V_j = &V[j * s];
            j = blockmix_xor(X, V_j, X, r, 0, ctx) & (N - 1);
        } while (Nloop -= 2);
    }
    else
    {
        do
        {
            const salsa20_blk_t* V_j = &V[j * s];
            j = blockmix_salsa8_xor(X, V_j, Y, r) & (N - 1);
            V_j = &V[j * s];
            j = blockmix_salsa8_xor(Y, V_j, X, r) & (N - 1);
        } while (Nloop -= 2);
    }
    for (i = 0; i < 2 * r; i++)
    {
        const salsa20_blk_t* src = &X[i];
        salsa20_blk_t* tmp = Y;
        salsa20_blk_t* dst = (salsa20_blk_t*)&B[i * 64];
        size_t k;
        for (k = 0; k < 16; k++)
            le32enc(&tmp->w[k], src->w[k]);
        salsa20_simd_unshuffle(tmp, dst);
    }
}
static void smix2 ( uint8_t * B , size_t r , uint32_t N , uint64_t Nloop , yescrypt_flags_t flags , salsa20_blk_t * V , uint32_t NROM , const salsa20_blk_t * VROM , salsa20_blk_t * XY , pwxform_ctx_t * ctx ) { size_t s = 2 * r ; salsa20_blk_t * X = XY , * Y = & XY [ s ] ; uint32_t i , j ; if ( Nloop == 0 ) return ; for ( i = 0 ; i < 2 * r ; i ++ ) { const salsa20_blk_t * src = ( salsa20_blk_t * ) & B [ i * 64 ] ; salsa20_blk_t * tmp = Y ; salsa20_blk_t * dst = & X [ i ] ; size_t k ; for ( k = 0 ; k < 16 ; k ++ ) tmp -> w [ k ] = le32dec ( & src -> w [ k ] ) ; salsa20_simd_shuffle ( tmp , dst ) ; } j = integerify ( X , r ) & ( N - 1 ) ; if ( VROM && ( flags & YESCRYPT_RW ) ) { do { salsa20_blk_t * V_j = & V [ j * s ] ; const salsa20_blk_t * VROM_j ; j = blockmix_xor_save ( X , V_j , r , ctx ) & ( NROM - 1 ) ; VROM_j = & VROM [ j * s ] ; j = blockmix_xor ( X , VROM_j , X , r , 1 , ctx ) & ( N - 1 ) ; } while ( Nloop -= 2 ) ; } else if ( VROM ) { do { const salsa20_blk_t * V_j = & V [ j * s ] ; j = blockmix_xor ( X , V_j , X , r , 0 , ctx ) & ( NROM - 1 ) ; V_j = & VROM [ j * s ] ; j = blockmix_xor ( X , V_j , X , r , 1 , ctx ) & ( N - 1 ) ; } while ( Nloop -= 2 ) ; } else if ( flags & YESCRYPT_RW ) { do { salsa20_blk_t * V_j = & V [ j * s ] ; j = blockmix_xor_save ( X , V_j , r , ctx ) & ( N - 1 ) ; V_j = & V [ j * s ] ; j = blockmix_xor_save ( X , V_j , r , ctx ) & ( N - 1 ) ; } while ( Nloop -= 2 ) ; } else if ( ctx ) { do { const salsa20_blk_t * V_j = & V [ j * s ] ; j = blockmix_xor ( X , V_j , X , r , 0 , ctx ) & ( N - 1 ) ; V_j = & V [ j * s ] ; j = blockmix_xor ( X , V_j , X , r , 0 , ctx ) & ( N - 1 ) ; } while ( Nloop -= 2 ) ; } else { do { const salsa20_blk_t * V_j = & V [ j * s ] ; j = blockmix_salsa8_xor ( X , V_j , Y , r ) & ( N - 1 ) ; V_j = & V [ j * s ] ; j = blockmix_salsa8_xor ( Y , V_j , X , r ) & ( N - 1 ) ; } while ( Nloop -= 2 ) ; } for ( i = 0 ; i < 2 * r ; i ++ ) { const salsa20_blk_t * src = & X [ i ] ; salsa20_blk_t * tmp = Y ; salsa20_blk_t * dst = ( salsa20_blk_t * ) & B [ i * 64 ] ; size_t k ; for ( k = 0 ; k < 16 ; k ++ ) le32enc ( & tmp -> w [ k ] , src -> w [ k ] ) ; salsa20_simd_unshuffle ( tmp , dst ) ; } }
smix2(B, r, N, Nloop, flags, V, NROM, VROM, XY, ctx):
 Compute second loop of B = SMix_r(B, N).
smix2 ( B r N Nloop flags V NROM VROM XY ctx ) : Compute second loop of B = SMix_r ( B N ) .
/*
     * Normally, VROM implies YESCRYPT_RW, but we check for these separately
     * because our SMix resets YESCRYPT_RW for the smix2() calls operating on
     * the entire V when p > 1.
     */