// File: /workspace/github_c_makefile_star2_O2/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 $0x88, %rsp
movq %rdx, %r8
xorl %eax, %eax
cmpq $0x8, %rax
je 0x1c3c
movq (%rsi,%rax,8), %rcx
movbeq %rcx, -0x80(%rsp,%rax,8)
incq %rax
jmp 0x1c26
movq -0x80(%rsp), %rbx
movq -0x78(%rsp), %r11
movq -0x70(%rsp), %r9
movq -0x68(%rsp), %rcx
movq -0x60(%rsp), %r10
movq -0x58(%rsp), %r14
movq -0x50(%rsp), %rbp
movq -0x48(%rsp), %r15
xorl %esi, %esi
movq %r9, -0x30(%rsp)
movq %rcx, -0x28(%rsp)
movq %r10, -0x20(%rsp)
movq %r14, -0x18(%rsp)
movq %rbp, -0x10(%rsp)
movq %r15, -0x8(%rsp)
movq %r11, -0x38(%rsp)
movq %rbx, -0x40(%rsp)
movq %rbp, %rdx
movq %r14, %rbp
movq %r10, %r14
movq %r9, %r12
cmpq $0x80, %rsi
je 0x1d39
movq (%r8,%rsi), %r9
movbeq %r9, (%rsp,%rsi)
bswapq %r9
rorxq $0xe, %r14, %r10
rorxq $0x12, %r14, %rax
xorq %r10, %rax
rorxq $0x29, %r14, %r10
xorq %rax, %r10
movq %rbp, %rax
andq %r14, %rax
andnq %rdx, %r14, %r13
orq %rax, %r13
addq %r13, %r15
addq %r10, %r15
leaq 0x13c9(%rip), %rax      # 0x30b0
addq (%rsi,%rax), %r15
addq %r9, %r15
rorxq $0x1c, %rbx, %rax
rorxq $0x22, %rbx, %r9
xorq %rax, %r9
rorxq $0x27, %rbx, %rax
xorq %r9, %rax
movq %r11, %r13
movq %r11, %r9
xorq %r12, %r11
andq %rbx, %r11
andq %r12, %r13
xorq %r11, %r13
addq %rax, %r13
movq %rcx, %r10
addq %r15, %r10
addq %r15, %r13
addq $0x8, %rsi
movq %r12, %rcx
movq %rdx, %r15
movq %rbx, %r11
movq %r13, %rbx
jmp 0x1c8e
movabsq $0x1e, %rsi
movq %rdx, %r8
movq %rbp, %rdx
movq %r14, %rbp
movq %r12, %r9
cmpq $0x5e, %rsi
je 0x1e3c
leaq -0xe(%rsi), %r12
leal -0xd(%rsi), %eax
andl $0xf, %eax
movq (%rsp,%rax,8), %r14
rorxq $0x1, %r14, %rax
rorxq $0x8, %r14, %r10
xorq %rax, %r10
shrq $0x7, %r14
xorq %r10, %r14
movl %esi, %eax
andl $0xf, %eax
movq (%rsp,%rax,8), %rax
rorxq $0x13, %rax, %r10
rorxq $0x3d, %rax, %r13
xorq %r10, %r13
shrq $0x6, %rax
xorq %r13, %rax
leal -0x5(%rsi), %r10d
andl $0xf, %r10d
andl $0xf, %r12d
addq (%rsp,%r10,8), %r14
addq (%rsp,%r12,8), %r14
addq %rax, %r14
movq %r14, (%rsp,%r12,8)
rorxq $0xe, %rbp, %rax
rorxq $0x12, %rbp, %r10
xorq %rax, %r10
rorxq $0x29, %rbp, %rax
xorq %r10, %rax
movq %rdx, %r10
andq %rbp, %r10
andnq %r8, %rbp, %r12
orq %r10, %r12
addq %r12, %r15
addq %rax, %r15
leaq 0x12c6(%rip), %rax      # 0x30b0
addq -0x70(%rax,%rsi,8), %r15
addq %r14, %r15
rorxq $0x1c, %rbx, %rax
rorxq $0x22, %rbx, %r10
xorq %rax, %r10
rorxq $0x27, %rbx, %rax
xorq %r10, %rax
movq %r11, %r10
movq %r11, %r12
xorq %r9, %r11
andq %rbx, %r11
andq %r9, %r10
xorq %r11, %r10
addq %rax, %r10
movq %rcx, %r14
addq %r15, %r14
addq %r15, %r10
incq %rsi
movq %r9, %rcx
movq %r8, %r15
movq %rbx, %r11
movq %r10, %rbx
jmp 0x1d43
addq -0x40(%rsp), %rbx
movq %rbx, -0x80(%rsp)
addq -0x38(%rsp), %r11
movq %r11, -0x78(%rsp)
addq -0x30(%rsp), %r9
movq %r9, -0x70(%rsp)
addq -0x28(%rsp), %rcx
movq %rcx, -0x68(%rsp)
addq -0x20(%rsp), %rbp
movq %rbp, -0x60(%rsp)
addq -0x18(%rsp), %rdx
movq %rdx, -0x58(%rsp)
addq -0x10(%rsp), %r8
movq %r8, -0x50(%rsp)
addq -0x8(%rsp), %r15
movq %r15, -0x48(%rsp)
xorl %eax, %eax
vpmovsxbq 0x1209(%rip), %ymm0 # 0x30a0
cmpq $0x8, %rax
je 0x1ed3
movq -0x80(%rsp,%rax,8), %rcx
vpbroadcastq %rcx, %ymm1
vpsrlvq %ymm0, %ymm1, %ymm1
vpmovqb %ymm1, (%rdi,%rax,8)
movl %ecx, %edx
shrl $0x18, %edx
movb %dl, 0x4(%rdi,%rax,8)
movl %ecx, %edx
shrl $0x10, %edx
movb %dl, 0x5(%rdi,%rax,8)
movb %ch, 0x6(%rdi,%rax,8)
movb %cl, 0x7(%rdi,%rax,8)
incq %rax
jmp 0x1e97
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
vzeroupper
retq