// File: /workspace/github_cpp_makefile_star2_O3/theuni[P]libutreexo/crypto/sha256_shani.cpp
// Function: sha256_shani::Transform(unsigned int*, unsigned char const*, unsigned long)
void Transform(uint32_t* s, const unsigned char* chunk, size_t blocks)
{
    __m128i m0, m1, m2, m3, s0, s1, so0, so1;

    /* Load state */
    s0 = _mm_loadu_si128((const __m128i*)s);
    s1 = _mm_loadu_si128((const __m128i*)(s + 4));
    Shuffle(s0, s1);

    while (blocks--) {
        /* Remember old state */
        so0 = s0;
        so1 = s1;

        /* Load data and transform */
        m0 = Load(chunk);
        QuadRound(s0, s1, m0, 0xe9b5dba5b5c0fbcfull, 0x71374491428a2f98ull);
        m1 = Load(chunk + 16);
        QuadRound(s0, s1, m1, 0xab1c5ed5923f82a4ull, 0x59f111f13956c25bull);
        ShiftMessageA(m0, m1);
        m2 = Load(chunk + 32);
        QuadRound(s0, s1, m2, 0x550c7dc3243185beull, 0x12835b01d807aa98ull);
        ShiftMessageA(m1, m2);
        m3 = Load(chunk + 48);
        QuadRound(s0, s1, m3, 0xc19bf1749bdc06a7ull, 0x80deb1fe72be5d74ull);
        ShiftMessageB(m2, m3, m0);
        QuadRound(s0, s1, m0, 0x240ca1cc0fc19dc6ull, 0xefbe4786E49b69c1ull);
        ShiftMessageB(m3, m0, m1);
        QuadRound(s0, s1, m1, 0x76f988da5cb0a9dcull, 0x4a7484aa2de92c6full);
        ShiftMessageB(m0, m1, m2);
        QuadRound(s0, s1, m2, 0xbf597fc7b00327c8ull, 0xa831c66d983e5152ull);
        ShiftMessageB(m1, m2, m3);
        QuadRound(s0, s1, m3, 0x1429296706ca6351ull, 0xd5a79147c6e00bf3ull);
        ShiftMessageB(m2, m3, m0);
        QuadRound(s0, s1, m0, 0x53380d134d2c6dfcull, 0x2e1b213827b70a85ull);
        ShiftMessageB(m3, m0, m1);
        QuadRound(s0, s1, m1, 0x92722c8581c2c92eull, 0x766a0abb650a7354ull);
        ShiftMessageB(m0, m1, m2);
        QuadRound(s0, s1, m2, 0xc76c51A3c24b8b70ull, 0xa81a664ba2bfe8a1ull);
        ShiftMessageB(m1, m2, m3);
        QuadRound(s0, s1, m3, 0x106aa070f40e3585ull, 0xd6990624d192e819ull);
        ShiftMessageB(m2, m3, m0);
        QuadRound(s0, s1, m0, 0x34b0bcb52748774cull, 0x1e376c0819a4c116ull);
        ShiftMessageB(m3, m0, m1);
        QuadRound(s0, s1, m1, 0x682e6ff35b9cca4full, 0x4ed8aa4a391c0cb3ull);
        ShiftMessageC(m0, m1, m2);
        QuadRound(s0, s1, m2, 0x8cc7020884c87814ull, 0x78a5636f748f82eeull);
        ShiftMessageC(m1, m2, m3);
        QuadRound(s0, s1, m3, 0xc67178f2bef9A3f7ull, 0xa4506ceb90befffaull);

        /* Combine with old state */
        s0 = _mm_add_epi32(s0, so0);
        s1 = _mm_add_epi32(s1, so1);

        /* Advance */
        chunk += 64;
    }

    Unshuffle(s0, s1);
    _mm_storeu_si128((__m128i*)s, s0);
    _mm_storeu_si128((__m128i*)(s + 4), s1);
}

// Assembly:
movdqu (%rdi), %xmm0
movdqu 0x10(%rdi), %xmm1
pshufd $0xb1, %xmm0, %xmm0     # xmm0 = xmm0[1,0,3,2]
pshufd $0x1b, %xmm1, %xmm12    # xmm12 = xmm1[3,2,1,0]
movdqa %xmm0, %xmm13
palignr $0x8, %xmm12, %xmm13    # xmm13 = xmm12[8,9,10,11,12,13,14,15],xmm13[0,1,2,3,4,5,6,7]
pblendw $0xf0, %xmm0, %xmm12    # xmm12 = xmm12[0,1,2,3],xmm0[4,5,6,7]
testq %rdx, %rdx
je 0x1644c
movdqa 0x12814(%rip), %xmm5    # 0x28910
movdqa 0x128eb(%rip), %xmm9    # 0x289f0
movdqa 0x128f2(%rip), %xmm10   # 0x28a00
movdqa 0x128f9(%rip), %xmm11   # 0x28a10
movdqu (%rsi), %xmm8
movdqu 0x10(%rsi), %xmm15
pshufb %xmm5, %xmm8
movdqa %xmm8, %xmm0
paddd 0x127eb(%rip), %xmm0    # 0x28920
movdqa %xmm12, %xmm3
sha256rnds2 %xmm0, %xmm13, %xmm3
pshufd $0xe, %xmm0, %xmm0      # xmm0 = xmm0[2,3,0,0]
movdqa %xmm13, %xmm4
sha256rnds2 %xmm0, %xmm3, %xmm4
pshufb %xmm5, %xmm15
movdqu 0x20(%rsi), %xmm6
movdqa %xmm15, %xmm0
paddd 0x127cb(%rip), %xmm0    # 0x28930
sha256rnds2 %xmm0, %xmm4, %xmm3
pshufd $0xe, %xmm0, %xmm0      # xmm0 = xmm0[2,3,0,0]
sha256rnds2 %xmm0, %xmm3, %xmm4
movdqu 0x30(%rsi), %xmm7
pshufb %xmm5, %xmm6
movdqa %xmm6, %xmm0
paddd 0x127b8(%rip), %xmm0    # 0x28940
sha256msg1 %xmm15, %xmm8
sha256rnds2 %xmm0, %xmm4, %xmm3
pshufd $0xe, %xmm0, %xmm0      # xmm0 = xmm0[2,3,0,0]
sha256rnds2 %xmm0, %xmm3, %xmm4
pshufb %xmm5, %xmm7
movdqa %xmm7, %xmm0
sha256msg1 %xmm6, %xmm15
paddd 0x127a0(%rip), %xmm0    # 0x28950
pshufd $0xe, %xmm0, %xmm1      # xmm1 = xmm0[2,3,0,0]
sha256rnds2 %xmm0, %xmm4, %xmm3
movdqa %xmm7, %xmm2
palignr $0x4, %xmm6, %xmm2      # xmm2 = xmm6[4,5,6,7,8,9,10,11,12,13,14,15],xmm2[0,1,2,3]
movdqa %xmm1, %xmm0
sha256rnds2 %xmm0, %xmm3, %xmm4
paddd %xmm8, %xmm2
sha256msg2 %xmm7, %xmm2
movdqa %xmm2, %xmm0
sha256msg1 %xmm7, %xmm6
paddd 0x1277c(%rip), %xmm0    # 0x28960
pshufd $0xe, %xmm0, %xmm1      # xmm1 = xmm0[2,3,0,0]
sha256rnds2 %xmm0, %xmm4, %xmm3
movdqa %xmm2, %xmm14
palignr $0x4, %xmm7, %xmm14     # xmm14 = xmm7[4,5,6,7,8,9,10,11,12,13,14,15],xmm14[0,1,2,3]
movdqa %xmm1, %xmm0
sha256rnds2 %xmm0, %xmm3, %xmm4
paddd %xmm15, %xmm14
sha256msg2 %xmm2, %xmm14
movdqa %xmm14, %xmm0
sha256msg1 %xmm2, %xmm7
paddd 0x12754(%rip), %xmm0    # 0x28970
pshufd $0xe, %xmm0, %xmm1      # xmm1 = xmm0[2,3,0,0]
sha256rnds2 %xmm0, %xmm4, %xmm3
movdqa %xmm14, %xmm8
palignr $0x4, %xmm2, %xmm8      # xmm8 = xmm2[4,5,6,7,8,9,10,11,12,13,14,15],xmm8[0,1,2,3]
movdqa %xmm1, %xmm0
sha256rnds2 %xmm0, %xmm3, %xmm4
paddd %xmm6, %xmm8
sha256msg2 %xmm14, %xmm8
movdqa %xmm8, %xmm0
sha256msg1 %xmm14, %xmm2
paddd 0x1272b(%rip), %xmm0    # 0x28980
pshufd $0xe, %xmm0, %xmm1      # xmm1 = xmm0[2,3,0,0]
sha256rnds2 %xmm0, %xmm4, %xmm3
movdqa %xmm8, %xmm15
palignr $0x4, %xmm14, %xmm15    # xmm15 = xmm14[4,5,6,7,8,9,10,11,12,13,14,15],xmm15[0,1,2,3]
movdqa %xmm1, %xmm0
sha256rnds2 %xmm0, %xmm3, %xmm4
paddd %xmm7, %xmm15
sha256msg2 %xmm8, %xmm15
movdqa %xmm15, %xmm0
sha256msg1 %xmm8, %xmm14
paddd 0x12702(%rip), %xmm0    # 0x28990
pshufd $0xe, %xmm0, %xmm1      # xmm1 = xmm0[2,3,0,0]
sha256rnds2 %xmm0, %xmm4, %xmm3
movdqa %xmm15, %xmm7
palignr $0x4, %xmm8, %xmm7      # xmm7 = xmm8[4,5,6,7,8,9,10,11,12,13,14,15],xmm7[0,1,2,3]
movdqa %xmm1, %xmm0
sha256rnds2 %xmm0, %xmm3, %xmm4
paddd %xmm2, %xmm7
sha256msg2 %xmm15, %xmm7
movdqa %xmm7, %xmm0
paddd 0x126e0(%rip), %xmm0    # 0x289a0
sha256rnds2 %xmm0, %xmm4, %xmm3
movdqa %xmm7, %xmm6
sha256msg1 %xmm15, %xmm8
palignr $0x4, %xmm15, %xmm6     # xmm6 = xmm15[4,5,6,7,8,9,10,11,12,13,14,15],xmm6[0,1,2,3]
paddd %xmm14, %xmm6
sha256msg2 %xmm7, %xmm6
pshufd $0xe, %xmm0, %xmm0      # xmm0 = xmm0[2,3,0,0]
movdqa %xmm6, %xmm1
paddd 0x126c2(%rip), %xmm1    # 0x289b0
sha256rnds2 %xmm0, %xmm3, %xmm4
movdqa %xmm1, %xmm0
sha256rnds2 %xmm0, %xmm4, %xmm3
movdqa %xmm6, %xmm14
sha256msg1 %xmm7, %xmm15
palignr $0x4, %xmm7, %xmm14     # xmm14 = xmm7[4,5,6,7,8,9,10,11,12,13,14,15],xmm14[0,1,2,3]
paddd %xmm8, %xmm14
sha256msg2 %xmm6, %xmm14
pshufd $0xe, %xmm1, %xmm0      # xmm0 = xmm1[2,3,0,0]
sha256msg1 %xmm6, %xmm7
movdqa %xmm14, %xmm8
palignr $0x4, %xmm6, %xmm8      # xmm8 = xmm6[4,5,6,7,8,9,10,11,12,13,14,15],xmm8[0,1,2,3]
paddd %xmm15, %xmm8
movdqa %xmm14, %xmm1
paddd 0x12684(%rip), %xmm1    # 0x289c0
sha256rnds2 %xmm0, %xmm3, %xmm4
sha256msg2 %xmm14, %xmm8
sha256msg1 %xmm14, %xmm6
movdqa %xmm1, %xmm0
sha256rnds2 %xmm0, %xmm4, %xmm3
movdqa %xmm8, %xmm15
palignr $0x4, %xmm14, %xmm15    # xmm15 = xmm14[4,5,6,7,8,9,10,11,12,13,14,15],xmm15[0,1,2,3]
paddd %xmm7, %xmm15
pshufd $0xe, %xmm1, %xmm0      # xmm0 = xmm1[2,3,0,0]
movdqa %xmm8, %xmm1
paddd 0x1265b(%rip), %xmm1    # 0x289d0
sha256rnds2 %xmm0, %xmm3, %xmm4
pshufd $0xe, %xmm1, %xmm2      # xmm2 = xmm1[2,3,0,0]
sha256msg2 %xmm8, %xmm15
movdqa %xmm1, %xmm0
sha256rnds2 %xmm0, %xmm4, %xmm3
sha256msg1 %xmm8, %xmm14
movdqa %xmm15, %xmm7
movdqa %xmm2, %xmm0
sha256rnds2 %xmm0, %xmm3, %xmm4
palignr $0x4, %xmm8, %xmm7      # xmm7 = xmm8[4,5,6,7,8,9,10,11,12,13,14,15],xmm7[0,1,2,3]
paddd %xmm6, %xmm7
sha256msg2 %xmm15, %xmm7
sha256msg1 %xmm15, %xmm8
movdqa %xmm7, %xmm2
palignr $0x4, %xmm15, %xmm2     # xmm2 = xmm15[4,5,6,7,8,9,10,11,12,13,14,15],xmm2[0,1,2,3]
movdqa %xmm15, %xmm0
paddd 0x12616(%rip), %xmm0    # 0x289e0
sha256rnds2 %xmm0, %xmm4, %xmm3
pshufd $0xe, %xmm0, %xmm0      # xmm0 = xmm0[2,3,0,0]
sha256rnds2 %xmm0, %xmm3, %xmm4
paddd %xmm14, %xmm2
sha256msg2 %xmm7, %xmm2
movdqa %xmm2, %xmm1
palignr $0x4, %xmm7, %xmm1      # xmm1 = xmm7[4,5,6,7,8,9,10,11,12,13,14,15],xmm1[0,1,2,3]
movdqa %xmm7, %xmm0
paddd %xmm9, %xmm0
sha256rnds2 %xmm0, %xmm4, %xmm3
pshufd $0xe, %xmm0, %xmm0      # xmm0 = xmm0[2,3,0,0]
sha256rnds2 %xmm0, %xmm3, %xmm4
paddd %xmm8, %xmm1
sha256msg2 %xmm2, %xmm1
movdqa %xmm2, %xmm0
paddd %xmm10, %xmm0
sha256rnds2 %xmm0, %xmm4, %xmm3
pshufd $0xe, %xmm0, %xmm0      # xmm0 = xmm0[2,3,0,0]
sha256rnds2 %xmm0, %xmm3, %xmm4
paddd %xmm11, %xmm1
movdqa %xmm1, %xmm0
sha256rnds2 %xmm0, %xmm4, %xmm3
pshufd $0xe, %xmm1, %xmm0      # xmm0 = xmm1[2,3,0,0]
sha256rnds2 %xmm0, %xmm3, %xmm4
paddd %xmm4, %xmm13
paddd %xmm3, %xmm12
addq $0x40, %rsi
decq %rdx
jne 0x16117
pshufd $0x1b, %xmm13, %xmm0    # xmm0 = xmm13[3,2,1,0]
pshufd $0xb1, %xmm12, %xmm1    # xmm1 = xmm12[1,0,3,2]
movdqa %xmm0, %xmm2
pblendw $0xf0, %xmm1, %xmm2     # xmm2 = xmm2[0,1,2,3],xmm1[4,5,6,7]
palignr $0x8, %xmm0, %xmm1      # xmm1 = xmm0[8,9,10,11,12,13,14,15],xmm1[0,1,2,3,4,5,6,7]
movdqu %xmm2, (%rdi)
movdqu %xmm1, 0x10(%rdi)
retq