// File: /workspace/github_c_makefile_star2_O3/Tarsnap[P]kivaloo/liball/../libcperciva/alg/sha256_shani.c
// Function: SHA256_Transform_shani
void
SHA256_Transform_shani(uint32_t state[static restrict 8],
    const uint8_t block[static restrict 64])
{
	__m128i S3210, S7654;
	__m128i S0123, S4567;
	__m128i S0145, S2367;
	__m128i W[4];
	__m128i S[2];

	/* Load state. */
	S3210 = _mm_loadu_si128((const __m128i *)&state[0]);
	S7654 = _mm_loadu_si128((const __m128i *)&state[4]);

	/* Shuffle the 8 32-bit values into the order we need them. */
	S0123 = _mm_shuffle_epi32(S3210, 0x1B);
	S4567 = _mm_shuffle_epi32(S7654, 0x1B);
	S0145 = _mm_unpackhi_epi64(S4567, S0123);
	S2367 = _mm_unpacklo_epi64(S4567, S0123);

	/* Load input block; this is the start of the message schedule. */
	W[0] = be32dec_128(&block[0]);
	W[1] = be32dec_128(&block[16]);
	W[2] = be32dec_128(&block[32]);
	W[3] = be32dec_128(&block[48]);

	/* Initialize working variables. */
	S[0] = S0145;
	S[1] = S2367;

	/* Perform 64 rounds, 4 at a time. */
	RNDMSG(S, W, 0, 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5);
	RNDMSG(S, W, 1, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5);
	RNDMSG(S, W, 2, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3);
	RNDMSG(S, W, 3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174);
	RNDMSG(S, W, 4, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc);
	RNDMSG(S, W, 5, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da);
	RNDMSG(S, W, 6, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7);
	RNDMSG(S, W, 7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967);
	RNDMSG(S, W, 8, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13);
	RNDMSG(S, W, 9, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85);
	RNDMSG(S, W, 10, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3);
	RNDMSG(S, W, 11, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070);
	RNDMSG(S, W, 12, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5);
	RNDMSG(S, W, 13, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3);
	RNDMSG(S, W, 14, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208);
	RNDMSG(S, W, 15, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2);

	/* Mix local working variables into global state. */
	S0145 = _mm_add_epi32(S0145, S[0]);
	S2367 = _mm_add_epi32(S2367, S[1]);

	/* Shuffle state back to the original word order and store. */
	S0123 = _mm_unpackhi_epi64(S2367, S0145);
	S4567 = _mm_unpacklo_epi64(S2367, S0145);
	S3210 = _mm_shuffle_epi32(S0123, 0x1B);
	S7654 = _mm_shuffle_epi32(S4567, 0x1B);
	_mm_storeu_si128((__m128i *)&state[0], S3210);
	_mm_storeu_si128((__m128i *)&state[4], S7654);
}

// Assembly:
movdqu (%rdi), %xmm0
movdqu 0x10(%rdi), %xmm1
pshufd $0x1b, %xmm0, %xmm2     # xmm2 = xmm0[3,2,1,0]
pshufd $0x1b, %xmm1, %xmm5     # xmm5 = xmm1[3,2,1,0]
movdqa 0x3b4d(%rip), %xmm0     # 0x13610
movdqu (%rsi), %xmm3
movdqu 0x10(%rsi), %xmm4
movdqu 0x20(%rsi), %xmm9
movdqu 0x30(%rsi), %xmm1
pshufb %xmm0, %xmm3
pshufb %xmm0, %xmm4
pshufb %xmm0, %xmm9
pshufb %xmm0, %xmm1
movdqa 0x3b2c(%rip), %xmm0     # 0x13620
paddd %xmm3, %xmm0
movdqa %xmm5, %xmm6
punpcklqdq %xmm2, %xmm6    # xmm6 = xmm6[0],xmm2[0]
punpckhqdq %xmm2, %xmm5    # xmm5 = xmm5[1],xmm2[1]
movdqa %xmm6, %xmm7
sha256rnds2 %xmm0, %xmm5, %xmm7
psrldq $0x8, %xmm0             # xmm0 = xmm0[8,9,10,11,12,13,14,15],zero,zero,zero,zero,zero,zero,zero,zero
movdqa %xmm5, %xmm8
sha256rnds2 %xmm0, %xmm7, %xmm8
sha256msg1 %xmm4, %xmm3
movdqa %xmm1, %xmm2
palignr $0x4, %xmm9, %xmm2      # xmm2 = xmm9[4,5,6,7,8,9,10,11,12,13,14,15],xmm2[0,1,2,3]
paddd %xmm3, %xmm2
sha256msg2 %xmm1, %xmm2
movdqa 0x3af6(%rip), %xmm0     # 0x13630
paddd %xmm4, %xmm0
sha256rnds2 %xmm0, %xmm8, %xmm7
psrldq $0x8, %xmm0             # xmm0 = xmm0[8,9,10,11,12,13,14,15],zero,zero,zero,zero,zero,zero,zero,zero
sha256rnds2 %xmm0, %xmm7, %xmm8
sha256msg1 %xmm9, %xmm4
movdqa %xmm2, %xmm3
palignr $0x4, %xmm1, %xmm3      # xmm3 = xmm1[4,5,6,7,8,9,10,11,12,13,14,15],xmm3[0,1,2,3]
paddd %xmm4, %xmm3
sha256msg2 %xmm2, %xmm3
movdqa 0x3ad4(%rip), %xmm0     # 0x13640
paddd %xmm9, %xmm0
sha256rnds2 %xmm0, %xmm8, %xmm7
psrldq $0x8, %xmm0             # xmm0 = xmm0[8,9,10,11,12,13,14,15],zero,zero,zero,zero,zero,zero,zero,zero
sha256rnds2 %xmm0, %xmm7, %xmm8
sha256msg1 %xmm1, %xmm9
movdqa %xmm3, %xmm4
palignr $0x4, %xmm2, %xmm4      # xmm4 = xmm2[4,5,6,7,8,9,10,11,12,13,14,15],xmm4[0,1,2,3]
paddd %xmm9, %xmm4
sha256msg2 %xmm3, %xmm4
movdqa 0x3ab0(%rip), %xmm0     # 0x13650
paddd %xmm1, %xmm0
sha256rnds2 %xmm0, %xmm8, %xmm7
psrldq $0x8, %xmm0             # xmm0 = xmm0[8,9,10,11,12,13,14,15],zero,zero,zero,zero,zero,zero,zero,zero
sha256rnds2 %xmm0, %xmm7, %xmm8
sha256msg1 %xmm2, %xmm1
movdqa %xmm4, %xmm9
palignr $0x4, %xmm3, %xmm9      # xmm9 = xmm3[4,5,6,7,8,9,10,11,12,13,14,15],xmm9[0,1,2,3]
paddd %xmm1, %xmm9
sha256msg2 %xmm4, %xmm9
movdqa 0x3a8b(%rip), %xmm0     # 0x13660
paddd %xmm2, %xmm0
sha256rnds2 %xmm0, %xmm8, %xmm7
psrldq $0x8, %xmm0             # xmm0 = xmm0[8,9,10,11,12,13,14,15],zero,zero,zero,zero,zero,zero,zero,zero
sha256rnds2 %xmm0, %xmm7, %xmm8
sha256msg1 %xmm3, %xmm2
movdqa %xmm9, %xmm10
palignr $0x4, %xmm4, %xmm10     # xmm10 = xmm4[4,5,6,7,8,9,10,11,12,13,14,15],xmm10[0,1,2,3]
paddd %xmm2, %xmm10
sha256msg2 %xmm9, %xmm10
movdqa 0x3a66(%rip), %xmm0     # 0x13670
paddd %xmm3, %xmm0
sha256rnds2 %xmm0, %xmm8, %xmm7
psrldq $0x8, %xmm0             # xmm0 = xmm0[8,9,10,11,12,13,14,15],zero,zero,zero,zero,zero,zero,zero,zero
sha256rnds2 %xmm0, %xmm7, %xmm8
sha256msg1 %xmm4, %xmm3
movdqa %xmm10, %xmm11
palignr $0x4, %xmm9, %xmm11     # xmm11 = xmm9[4,5,6,7,8,9,10,11,12,13,14,15],xmm11[0,1,2,3]
paddd %xmm3, %xmm11
sha256msg2 %xmm10, %xmm11
movdqa 0x3a41(%rip), %xmm0     # 0x13680
paddd %xmm4, %xmm0
sha256rnds2 %xmm0, %xmm8, %xmm7
psrldq $0x8, %xmm0             # xmm0 = xmm0[8,9,10,11,12,13,14,15],zero,zero,zero,zero,zero,zero,zero,zero
sha256rnds2 %xmm0, %xmm7, %xmm8
sha256msg1 %xmm9, %xmm4
movdqa %xmm11, %xmm12
palignr $0x4, %xmm10, %xmm12    # xmm12 = xmm10[4,5,6,7,8,9,10,11,12,13,14,15],xmm12[0,1,2,3]
paddd %xmm4, %xmm12
sha256msg2 %xmm11, %xmm12
movdqa 0x3a1b(%rip), %xmm0     # 0x13690
paddd %xmm9, %xmm0
sha256rnds2 %xmm0, %xmm8, %xmm7
psrldq $0x8, %xmm0             # xmm0 = xmm0[8,9,10,11,12,13,14,15],zero,zero,zero,zero,zero,zero,zero,zero
sha256rnds2 %xmm0, %xmm7, %xmm8
sha256msg1 %xmm10, %xmm9
movdqa %xmm12, %xmm13
palignr $0x4, %xmm11, %xmm13    # xmm13 = xmm11[4,5,6,7,8,9,10,11,12,13,14,15],xmm13[0,1,2,3]
paddd %xmm9, %xmm13
sha256msg2 %xmm12, %xmm13
movdqa 0x39f4(%rip), %xmm0     # 0x136a0
paddd %xmm10, %xmm0
sha256rnds2 %xmm0, %xmm8, %xmm7
psrldq $0x8, %xmm0             # xmm0 = xmm0[8,9,10,11,12,13,14,15],zero,zero,zero,zero,zero,zero,zero,zero
sha256rnds2 %xmm0, %xmm7, %xmm8
sha256msg1 %xmm11, %xmm10
movdqa %xmm13, %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 %xmm10, %xmm1
sha256msg2 %xmm13, %xmm1
movdqa 0x39cd(%rip), %xmm0     # 0x136b0
paddd %xmm11, %xmm0
sha256rnds2 %xmm0, %xmm8, %xmm7
psrldq $0x8, %xmm0             # xmm0 = xmm0[8,9,10,11,12,13,14,15],zero,zero,zero,zero,zero,zero,zero,zero
sha256rnds2 %xmm0, %xmm7, %xmm8
sha256msg1 %xmm12, %xmm11
movdqa %xmm1, %xmm2
palignr $0x4, %xmm13, %xmm2     # xmm2 = xmm13[4,5,6,7,8,9,10,11,12,13,14,15],xmm2[0,1,2,3]
paddd %xmm11, %xmm2
sha256msg2 %xmm1, %xmm2
movdqa 0x39a8(%rip), %xmm0     # 0x136c0
paddd %xmm12, %xmm0
sha256rnds2 %xmm0, %xmm8, %xmm7
psrldq $0x8, %xmm0             # xmm0 = xmm0[8,9,10,11,12,13,14,15],zero,zero,zero,zero,zero,zero,zero,zero
sha256rnds2 %xmm0, %xmm7, %xmm8
sha256msg1 %xmm13, %xmm12
movdqa %xmm2, %xmm3
palignr $0x4, %xmm1, %xmm3      # xmm3 = xmm1[4,5,6,7,8,9,10,11,12,13,14,15],xmm3[0,1,2,3]
paddd %xmm12, %xmm3
sha256msg2 %xmm2, %xmm3
movdqa 0x3984(%rip), %xmm0     # 0x136d0
paddd %xmm13, %xmm0
sha256rnds2 %xmm0, %xmm8, %xmm7
psrldq $0x8, %xmm0             # xmm0 = xmm0[8,9,10,11,12,13,14,15],zero,zero,zero,zero,zero,zero,zero,zero
sha256rnds2 %xmm0, %xmm7, %xmm8
sha256msg1 %xmm1, %xmm13
movdqa %xmm3, %xmm4
palignr $0x4, %xmm2, %xmm4      # xmm4 = xmm2[4,5,6,7,8,9,10,11,12,13,14,15],xmm4[0,1,2,3]
paddd %xmm13, %xmm4
sha256msg2 %xmm3, %xmm4
paddd 0x3960(%rip), %xmm1     # 0x136e0
movdqa %xmm1, %xmm0
sha256rnds2 %xmm0, %xmm8, %xmm7
psrldq $0x8, %xmm1             # xmm1 = xmm1[8,9,10,11,12,13,14,15],zero,zero,zero,zero,zero,zero,zero,zero
movdqa %xmm1, %xmm0
sha256rnds2 %xmm0, %xmm7, %xmm8
paddd 0x3951(%rip), %xmm2     # 0x136f0
movdqa %xmm2, %xmm0
sha256rnds2 %xmm0, %xmm8, %xmm7
psrldq $0x8, %xmm2             # xmm2 = xmm2[8,9,10,11,12,13,14,15],zero,zero,zero,zero,zero,zero,zero,zero
paddd 0x394b(%rip), %xmm3     # 0x13700
movdqa %xmm2, %xmm0
sha256rnds2 %xmm0, %xmm7, %xmm8
movdqa %xmm3, %xmm0
sha256rnds2 %xmm0, %xmm8, %xmm7
psrldq $0x8, %xmm3             # xmm3 = xmm3[8,9,10,11,12,13,14,15],zero,zero,zero,zero,zero,zero,zero,zero
movdqa %xmm3, %xmm0
sha256rnds2 %xmm0, %xmm7, %xmm8
paddd 0x3933(%rip), %xmm4     # 0x13710
movdqa %xmm4, %xmm0
sha256rnds2 %xmm0, %xmm8, %xmm7
psrldq $0x8, %xmm4             # xmm4 = xmm4[8,9,10,11,12,13,14,15],zero,zero,zero,zero,zero,zero,zero,zero
movdqa %xmm4, %xmm0
sha256rnds2 %xmm0, %xmm7, %xmm8
paddd %xmm5, %xmm8
paddd %xmm6, %xmm7
movdqa %xmm8, %xmm0
shufps $0xbb, %xmm7, %xmm0     # xmm0 = xmm0[3,2],xmm7[3,2]
shufps $0x11, %xmm7, %xmm8     # xmm8 = xmm8[1,0],xmm7[1,0]
movups %xmm0, (%rdi)
movups %xmm8, 0x10(%rdi)
retq