// File: /workspace/github_cpp_makefile_star2_O2/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, %xmm10    # xmm10 = xmm1[3,2,1,0]
movdqa %xmm0, %xmm11
palignr $0x8, %xmm10, %xmm11    # xmm11 = xmm10[8,9,10,11,12,13,14,15],xmm11[0,1,2,3,4,5,6,7]
pblendw $0xf0, %xmm0, %xmm10    # xmm10 = xmm10[0,1,2,3],xmm0[4,5,6,7]
movdqa 0x126d5(%rip), %xmm4    # 0x268c0
movdqa 0x1279d(%rip), %xmm6    # 0x26990
movdqa 0x127a5(%rip), %xmm7    # 0x269a0
movdqa 0x127ac(%rip), %xmm8    # 0x269b0
movdqa 0x127b3(%rip), %xmm9    # 0x269c0
subq $0x1, %rdx
jb 0x14527
movdqu (%rsi), %xmm5
movdqu 0x10(%rsi), %xmm13
movdqu 0x20(%rsi), %xmm12
movdqu 0x30(%rsi), %xmm14
pshufb %xmm4, %xmm5
movdqa %xmm5, %xmm0
paddd 0x12692(%rip), %xmm0    # 0x268d0
movdqa %xmm10, %xmm2
sha256rnds2 %xmm0, %xmm11, %xmm2
pshufd $0xe, %xmm0, %xmm0      # xmm0 = xmm0[2,3,0,0]
movdqa %xmm11, %xmm3
sha256rnds2 %xmm0, %xmm2, %xmm3
pshufb %xmm4, %xmm13
movdqa %xmm13, %xmm0
paddd 0x12677(%rip), %xmm0    # 0x268e0
sha256rnds2 %xmm0, %xmm3, %xmm2
pshufd $0xe, %xmm0, %xmm0      # xmm0 = xmm0[2,3,0,0]
sha256rnds2 %xmm0, %xmm2, %xmm3
sha256msg1 %xmm13, %xmm5
pshufb %xmm4, %xmm12
movdqa %xmm12, %xmm0
paddd 0x12662(%rip), %xmm0    # 0x268f0
sha256rnds2 %xmm0, %xmm3, %xmm2
pshufd $0xe, %xmm0, %xmm0      # xmm0 = xmm0[2,3,0,0]
sha256rnds2 %xmm0, %xmm2, %xmm3
sha256msg1 %xmm12, %xmm13
pshufb %xmm4, %xmm14
movdqa %xmm14, %xmm0
paddd 0x1264d(%rip), %xmm0    # 0x26900
sha256rnds2 %xmm0, %xmm3, %xmm2
pshufd $0xe, %xmm0, %xmm0      # xmm0 = xmm0[2,3,0,0]
sha256rnds2 %xmm0, %xmm2, %xmm3
movdqa %xmm14, %xmm1
palignr $0x4, %xmm12, %xmm1     # xmm1 = xmm12[4,5,6,7,8,9,10,11,12,13,14,15],xmm1[0,1,2,3]
paddd %xmm5, %xmm1
sha256msg2 %xmm14, %xmm1
sha256msg1 %xmm14, %xmm12
movdqa %xmm1, %xmm0
paddd 0x1262a(%rip), %xmm0    # 0x26910
sha256rnds2 %xmm0, %xmm3, %xmm2
pshufd $0xe, %xmm0, %xmm0      # xmm0 = xmm0[2,3,0,0]
sha256rnds2 %xmm0, %xmm2, %xmm3
movdqa %xmm1, %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 %xmm13, %xmm15
sha256msg2 %xmm1, %xmm15
sha256msg1 %xmm1, %xmm14
movdqa %xmm15, %xmm0
paddd 0x12605(%rip), %xmm0    # 0x26920
sha256rnds2 %xmm0, %xmm3, %xmm2
pshufd $0xe, %xmm0, %xmm0      # xmm0 = xmm0[2,3,0,0]
sha256rnds2 %xmm0, %xmm2, %xmm3
movdqa %xmm15, %xmm13
palignr $0x4, %xmm1, %xmm13     # xmm13 = xmm1[4,5,6,7,8,9,10,11,12,13,14,15],xmm13[0,1,2,3]
paddd %xmm12, %xmm13
sha256msg2 %xmm15, %xmm13
sha256msg1 %xmm15, %xmm1
movdqa %xmm13, %xmm0
paddd 0x125e0(%rip), %xmm0    # 0x26930
sha256rnds2 %xmm0, %xmm3, %xmm2
pshufd $0xe, %xmm0, %xmm0      # xmm0 = xmm0[2,3,0,0]
sha256rnds2 %xmm0, %xmm2, %xmm3
movdqa %xmm13, %xmm5
palignr $0x4, %xmm15, %xmm5     # xmm5 = xmm15[4,5,6,7,8,9,10,11,12,13,14,15],xmm5[0,1,2,3]
paddd %xmm14, %xmm5
sha256msg2 %xmm13, %xmm5
sha256msg1 %xmm13, %xmm15
movdqa %xmm5, %xmm0
paddd 0x125bc(%rip), %xmm0    # 0x26940
sha256rnds2 %xmm0, %xmm3, %xmm2
pshufd $0xe, %xmm0, %xmm0      # xmm0 = xmm0[2,3,0,0]
sha256rnds2 %xmm0, %xmm2, %xmm3
movdqa %xmm5, %xmm14
palignr $0x4, %xmm13, %xmm14    # xmm14 = xmm13[4,5,6,7,8,9,10,11,12,13,14,15],xmm14[0,1,2,3]
paddd %xmm1, %xmm14
sha256msg2 %xmm5, %xmm14
sha256msg1 %xmm5, %xmm13
movdqa %xmm14, %xmm0
paddd 0x12597(%rip), %xmm0    # 0x26950
sha256rnds2 %xmm0, %xmm3, %xmm2
pshufd $0xe, %xmm0, %xmm0      # xmm0 = xmm0[2,3,0,0]
sha256rnds2 %xmm0, %xmm2, %xmm3
movdqa %xmm14, %xmm1
palignr $0x4, %xmm5, %xmm1      # xmm1 = xmm5[4,5,6,7,8,9,10,11,12,13,14,15],xmm1[0,1,2,3]
paddd %xmm15, %xmm1
sha256msg2 %xmm14, %xmm1
sha256msg1 %xmm14, %xmm5
movdqa %xmm1, %xmm0
paddd 0x12574(%rip), %xmm0    # 0x26960
sha256rnds2 %xmm0, %xmm3, %xmm2
pshufd $0xe, %xmm0, %xmm0      # xmm0 = xmm0[2,3,0,0]
sha256rnds2 %xmm0, %xmm2, %xmm3
movdqa %xmm1, %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 %xmm13, %xmm15
sha256msg2 %xmm1, %xmm15
sha256msg1 %xmm1, %xmm14
movdqa %xmm15, %xmm0
paddd 0x1254f(%rip), %xmm0    # 0x26970
sha256rnds2 %xmm0, %xmm3, %xmm2
pshufd $0xe, %xmm0, %xmm0      # xmm0 = xmm0[2,3,0,0]
sha256rnds2 %xmm0, %xmm2, %xmm3
movdqa %xmm15, %xmm12
palignr $0x4, %xmm1, %xmm12     # xmm12 = xmm1[4,5,6,7,8,9,10,11,12,13,14,15],xmm12[0,1,2,3]
paddd %xmm5, %xmm12
sha256msg2 %xmm15, %xmm12
sha256msg1 %xmm15, %xmm1
movdqa %xmm12, %xmm0
paddd 0x1252a(%rip), %xmm0    # 0x26980
sha256rnds2 %xmm0, %xmm3, %xmm2
pshufd $0xe, %xmm0, %xmm0      # xmm0 = xmm0[2,3,0,0]
sha256rnds2 %xmm0, %xmm2, %xmm3
movdqa %xmm12, %xmm0
palignr $0x4, %xmm15, %xmm0     # xmm0 = xmm15[4,5,6,7,8,9,10,11,12,13,14,15],xmm0[0,1,2,3]
paddd %xmm14, %xmm0
sha256msg2 %xmm12, %xmm0
sha256msg1 %xmm12, %xmm15
movdqa %xmm0, %xmm5
palignr $0x4, %xmm12, %xmm5     # xmm5 = xmm12[4,5,6,7,8,9,10,11,12,13,14,15],xmm5[0,1,2,3]
paddd %xmm1, %xmm5
sha256msg2 %xmm0, %xmm5
sha256msg1 %xmm0, %xmm12
movdqa %xmm5, %xmm13
palignr $0x4, %xmm0, %xmm13     # xmm13 = xmm0[4,5,6,7,8,9,10,11,12,13,14,15],xmm13[0,1,2,3]
paddd %xmm6, %xmm0
sha256rnds2 %xmm0, %xmm3, %xmm2
pshufd $0xe, %xmm0, %xmm0      # xmm0 = xmm0[2,3,0,0]
sha256rnds2 %xmm0, %xmm2, %xmm3
paddd %xmm15, %xmm13
sha256msg2 %xmm5, %xmm13
movdqa %xmm13, %xmm1
palignr $0x4, %xmm5, %xmm1      # xmm1 = xmm5[4,5,6,7,8,9,10,11,12,13,14,15],xmm1[0,1,2,3]
movdqa %xmm5, %xmm0
paddd %xmm7, %xmm0
sha256rnds2 %xmm0, %xmm3, %xmm2
pshufd $0xe, %xmm0, %xmm0      # xmm0 = xmm0[2,3,0,0]
sha256rnds2 %xmm0, %xmm2, %xmm3
paddd %xmm12, %xmm1
sha256msg2 %xmm13, %xmm1
movdqa %xmm13, %xmm0
paddd %xmm8, %xmm0
sha256rnds2 %xmm0, %xmm3, %xmm2
pshufd $0xe, %xmm0, %xmm0      # xmm0 = xmm0[2,3,0,0]
sha256rnds2 %xmm0, %xmm2, %xmm3
paddd %xmm9, %xmm1
movdqa %xmm1, %xmm0
sha256rnds2 %xmm0, %xmm3, %xmm2
pshufd $0xe, %xmm1, %xmm0      # xmm0 = xmm1[2,3,0,0]
sha256rnds2 %xmm0, %xmm2, %xmm3
paddd %xmm3, %xmm11
paddd %xmm2, %xmm10
addq $0x40, %rsi
jmp 0x1420d
pshufd $0x1b, %xmm11, %xmm0    # xmm0 = xmm11[3,2,1,0]
pshufd $0xb1, %xmm10, %xmm1    # xmm1 = xmm10[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