// File: /workspace/github_c_makefile_star2_O1/mjosaarinen[P]brutus/crypto_aead/omdsha512k128n128tau128v2/ref/sha512.c
// Function: sha512_comp
void sha512_comp (hashblock res, const hashblock hash, const messageblock in)
	{
	const uint64_t *W=in;
	uint64_t	a,b,c,d,e,f,g,h,s0,s1,T1,T2;
	uint64_t	X[16];
	uint64_t  H[8];
	int i;

   for (i = 0; i < SHA512_DIGEST_LENGTH/8; i++) {
	   H[i]=PULL64(hash[i*8]);
	}


	a = H[0];	b = H[1];	c = H[2];	d = H[3];
	e = H[4];	f = H[5];	g = H[6];	h = H[7];

	for (i=0;i<16;i++)
		{
#ifdef B_ENDIAN
		T1 = X[i] = W[i];
#else
		T1 = X[i] = PULL64(W[i]);
#endif
		T1 += h + Sigma1(e) + Ch(e,f,g) + K512[i];
		T2 = Sigma0(a) + Maj(a,b,c);
		h = g;	g = f;	f = e;	e = d + T1;
		d = c;	c = b;	b = a;	a = T1 + T2;
		}

	for (;i<80;i++)
		{
		s0 = X[(i+1)&0x0f];	s0 = sigma0(s0);
		s1 = X[(i+14)&0x0f];	s1 = sigma1(s1);

		T1 = X[i&0xf] += s0 + s1 + X[(i+9)&0xf];
		T1 += h + Sigma1(e) + Ch(e,f,g) + K512[i];
		T2 = Sigma0(a) + Maj(a,b,c);
		h = g;	g = f;	f = e;	e = d + T1;
		d = c;	c = b;	b = a;	a = T1 + T2;
		}

	H[0] += a;	H[1] += b;	H[2] += c;	H[3] += d;
	H[4] += e;	H[5] += f;	H[6] += g;	H[7] += h;

   for (i = 0; i < SHA512_DIGEST_LENGTH/8; i++) {
	   PUSH64(H[i],res[i*8]);
	}

	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdx, %r8
movq %rdi, -0x38(%rsp)
xorl %eax, %eax
vmovdqu (%rsi,%rax,8), %ymm0
vpmovqb %ymm0, %xmm1
vpsrlq $0x8, %ymm0, %ymm2
vpmovqb %ymm2, %xmm2
vpsrlq $0x10, %ymm0, %ymm3
vpmovqb %ymm3, %xmm3
vpsrlq $0x18, %ymm0, %ymm4
vpmovqb %ymm4, %xmm4
vpsrlq $0x20, %ymm0, %ymm5
vpmovqb %ymm5, %xmm5
vpsrlq $0x28, %ymm0, %ymm6
vpmovqb %ymm6, %xmm6
vpsrlq $0x30, %ymm0, %ymm7
vpmovqb %ymm7, %xmm7
vpsrlq $0x38, %ymm0, %ymm0
vpmovqb %ymm0, %xmm0
vpmovzxbq %xmm1, %ymm1    # ymm1 = xmm1[0],zero,zero,zero,zero,zero,zero,zero,xmm1[1],zero,zero,zero,zero,zero,zero,zero,xmm1[2],zero,zero,zero,zero,zero,zero,zero,xmm1[3],zero,zero,zero,zero,zero,zero,zero
vpsllq $0x38, %ymm1, %ymm1
vpmovzxbq %xmm2, %ymm2    # ymm2 = xmm2[0],zero,zero,zero,zero,zero,zero,zero,xmm2[1],zero,zero,zero,zero,zero,zero,zero,xmm2[2],zero,zero,zero,zero,zero,zero,zero,xmm2[3],zero,zero,zero,zero,zero,zero,zero
vpsllq $0x30, %ymm2, %ymm2
vpor %ymm1, %ymm2, %ymm1
vpmovzxbq %xmm3, %ymm2    # ymm2 = xmm3[0],zero,zero,zero,zero,zero,zero,zero,xmm3[1],zero,zero,zero,zero,zero,zero,zero,xmm3[2],zero,zero,zero,zero,zero,zero,zero,xmm3[3],zero,zero,zero,zero,zero,zero,zero
vpsllq $0x28, %ymm2, %ymm2
vpmovzxbq %xmm4, %ymm3    # ymm3 = xmm4[0],zero,zero,zero,zero,zero,zero,zero,xmm4[1],zero,zero,zero,zero,zero,zero,zero,xmm4[2],zero,zero,zero,zero,zero,zero,zero,xmm4[3],zero,zero,zero,zero,zero,zero,zero
vpsllq $0x20, %ymm3, %ymm3
vpternlogq $0xfe, %ymm2, %ymm1, %ymm3
vpmovzxbq %xmm5, %ymm1    # ymm1 = xmm5[0],zero,zero,zero,zero,zero,zero,zero,xmm5[1],zero,zero,zero,zero,zero,zero,zero,xmm5[2],zero,zero,zero,zero,zero,zero,zero,xmm5[3],zero,zero,zero,zero,zero,zero,zero
vpsllq $0x18, %ymm1, %ymm1
vpmovzxbq %xmm6, %ymm2    # ymm2 = xmm6[0],zero,zero,zero,zero,zero,zero,zero,xmm6[1],zero,zero,zero,zero,zero,zero,zero,xmm6[2],zero,zero,zero,zero,zero,zero,zero,xmm6[3],zero,zero,zero,zero,zero,zero,zero
vpsllq $0x10, %ymm2, %ymm2
vpternlogq $0xfe, %ymm1, %ymm3, %ymm2
vpmovzxbq %xmm7, %ymm1    # ymm1 = xmm7[0],zero,zero,zero,zero,zero,zero,zero,xmm7[1],zero,zero,zero,zero,zero,zero,zero,xmm7[2],zero,zero,zero,zero,zero,zero,zero,xmm7[3],zero,zero,zero,zero,zero,zero,zero
vpsllq $0x8, %ymm1, %ymm1
vpmovzxbq %xmm0, %ymm0    # ymm0 = xmm0[0],zero,zero,zero,zero,zero,zero,zero,xmm0[1],zero,zero,zero,zero,zero,zero,zero,xmm0[2],zero,zero,zero,zero,zero,zero,zero,xmm0[3],zero,zero,zero,zero,zero,zero,zero
vpternlogq $0xfe, %ymm1, %ymm2, %ymm0
vmovdqu %ymm0, -0x80(%rsp,%rax,8)
addq $0x4, %rax
cmpq $0x8, %rax
jne 0x1ef7
movq -0x80(%rsp), %r12
movq -0x78(%rsp), %r14
movq -0x70(%rsp), %rsi
movq -0x68(%rsp), %rdx
movq -0x60(%rsp), %r13
movq -0x58(%rsp), %r15
movq -0x50(%rsp), %rbx
movq -0x48(%rsp), %r11
xorl %eax, %eax
movq %r12, -0x30(%rsp)
movq %r14, -0x28(%rsp)
movq %r11, 0x8(%rsp)
movq %rbx, (%rsp)
movq %r15, -0x8(%rsp)
movq %r13, -0x10(%rsp)
movq %rdx, -0x18(%rsp)
movq %rsi, -0x20(%rsp)
movq %r8, %rdi
movq (%r8,%rax), %r8
movbeq %r8, 0x10(%rsp,%rax)
movq %rsi, %r9
movq %r13, %rcx
movq %r15, %r10
movq %rbx, %rbp
movq %r14, %rsi
movq %r12, %r14
bswapq %r8
rorxq $0xe, %r13, %rbx
rorxq $0x12, %r13, %r15
xorq %rbx, %r15
rorxq $0x29, %r13, %r12
xorq %r15, %r12
movq %r10, %r15
andq %r13, %r15
andnq %rbp, %r13, %rbx
orq %r15, %rbx
addq %r11, %rbx
addq %r12, %rbx
leaq 0x1042(%rip), %r11      # 0x30b0
addq (%rax,%r11), %rbx
addq %r8, %rbx
rorxq $0x1c, %r14, %r8
rorxq $0x22, %r14, %r11
xorq %r8, %r11
rorxq $0x27, %r14, %r8
xorq %r11, %r8
movq %rsi, %r11
xorq %r9, %r11
andq %r14, %r11
movq %rsi, %r12
andq %r9, %r12
xorq %r11, %r12
addq %r8, %r12
movq %rdi, %r8
movq %rdx, %r13
addq %rbx, %r13
addq %rbx, %r12
addq $0x8, %rax
movq %rbp, %r11
movq %r10, %rbx
movq %rcx, %r15
movq %r9, %rdx
cmpq $0x80, %rax
jne 0x2018
movl $0x1e, %r8d
movq %rsi, %rbx
movq %r13, %r11
movq %rcx, %rax
movq %r10, %rdx
movq %r14, %rsi
movq %r12, %r14
leal -0xe(%r8), %r10d
leal -0xd(%r8), %ecx
andl $0xf, %ecx
movq 0x10(%rsp,%rcx,8), %rcx
rorxq $0x1, %rcx, %r15
rorxq $0x8, %rcx, %r12
xorq %r15, %r12
shrq $0x7, %rcx
xorq %r12, %rcx
movl %r8d, %r15d
andl $0xf, %r15d
movq 0x10(%rsp,%r15,8), %r15
rorxq $0x13, %r15, %r12
rorxq $0x3d, %r15, %r13
xorq %r12, %r13
shrq $0x6, %r15
leal -0x5(%r8), %r12d
andl $0xf, %r12d
andl $0xf, %r10d
addq 0x10(%rsp,%r12,8), %rcx
addq 0x10(%rsp,%r10,8), %rcx
xorq %r13, %r15
addq %r15, %rcx
movq %rcx, 0x10(%rsp,%r10,8)
rorxq $0xe, %r11, %r10
rorxq $0x12, %r11, %r15
xorq %r10, %r15
rorxq $0x29, %r11, %r12
xorq %r15, %r12
movq %rax, %r15
andq %r11, %r15
andnq %rdx, %r11, %r10
orq %r15, %r10
addq %rbp, %r10
addq %r12, %r10
leaq 0xf35(%rip), %r15       # 0x30b0
addq -0x70(%r15,%r8,8), %r10
addq %rcx, %r10
rorxq $0x1c, %r14, %rcx
rorxq $0x22, %r14, %r15
xorq %rcx, %r15
rorxq $0x27, %r14, %rcx
xorq %r15, %rcx
movq %rsi, %r15
xorq %rbx, %r15
andq %r14, %r15
movq %rsi, %r12
andq %rbx, %r12
xorq %r15, %r12
addq %rcx, %r12
movq %r9, %r13
addq %r10, %r13
addq %r10, %r12
incq %r8
movq %rdx, %rbp
movq %rax, %r10
movq %r11, %rcx
movq %rbx, %r9
cmpq $0x5e, %r8
jne 0x20d0
addq -0x30(%rsp), %r12
movq %r12, -0x80(%rsp)
addq -0x28(%rsp), %r14
movq %r14, -0x78(%rsp)
addq -0x20(%rsp), %rsi
movq %rsi, -0x70(%rsp)
addq -0x18(%rsp), %rbx
movq %rbx, -0x68(%rsp)
addq -0x10(%rsp), %r13
movq %r13, -0x60(%rsp)
addq -0x8(%rsp), %r11
movq %r11, -0x58(%rsp)
addq (%rsp), %rax
movq %rax, -0x50(%rsp)
addq 0x8(%rsp), %rdx
movq %rdx, -0x48(%rsp)
xorl %eax, %eax
vpmovsxbq 0xe74(%rip), %ymm0 # 0x30a0
movq -0x38(%rsp), %rsi
movq -0x80(%rsp,%rax,8), %rcx
vpbroadcastq %rcx, %ymm1
vpsrlvq %ymm0, %ymm1, %ymm1
vpmovqb %ymm1, (%rsi,%rax,8)
movl %ecx, %edx
shrl $0x18, %edx
movb %dl, 0x4(%rsi,%rax,8)
movl %ecx, %edx
shrl $0x10, %edx
movb %dl, 0x5(%rsi,%rax,8)
movb %ch, 0x6(%rsi,%rax,8)
movb %cl, 0x7(%rsi,%rax,8)
incq %rax
cmpq $0x8, %rax
jne 0x2231
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
vzeroupper
retq