// File: /workspace/github_c_makefile_star2_O0/Seclabs-htc[P]slip39/trezor-crypto/sha2.c
// Function: sha512_Transform
void sha512_Transform(const sha2_word64* state_in, const sha2_word64* data, sha2_word64* state_out) {
	sha2_word64	a, b, c, d, e, f, g, h, s0, s1;
	sha2_word64	T1, T2, W512[16];
	int		j;

	/* Initialize registers with the prev. intermediate value */
	a = state_in[0];
	b = state_in[1];
	c = state_in[2];
	d = state_in[3];
	e = state_in[4];
	f = state_in[5];
	g = state_in[6];
	h = state_in[7];

	j = 0;
	do {
		/* Apply the SHA-512 compression function to update a..h with copy */
		T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] + (W512[j] = *data++);
		T2 = Sigma0_512(a) + Maj(a, b, c);
		h = g;
		g = f;
		f = e;
		e = d + T1;
		d = c;
		c = b;
		b = a;
		a = T1 + T2;

		j++;
	} while (j < 16);

	do {
		/* Part of the message block expansion: */
		s0 = W512[(j+1)&0x0f];
		s0 = sigma0_512(s0);
		s1 = W512[(j+14)&0x0f];
		s1 =  sigma1_512(s1);

		/* Apply the SHA-512 compression function to update a..h */
		T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] +
		     (W512[j&0x0f] += s1 + W512[(j+9)&0x0f] + s0);
		T2 = Sigma0_512(a) + Maj(a, b, c);
		h = g;
		g = f;
		f = e;
		e = d + T1;
		d = c;
		c = b;
		b = a;
		a = T1 + T2;

		j++;
	} while (j < 80);

	/* Compute the current intermediate hash value */
	state_out[0] = state_in[0] + a;
	state_out[1] = state_in[1] + b;
	state_out[2] = state_in[2] + c;
	state_out[3] = state_in[3] + d;
	state_out[4] = state_in[4] + e;
	state_out[5] = state_in[5] + f;
	state_out[6] = state_in[6] + g;
	state_out[7] = state_in[7] + h;

	/* Clean up */
	a = b = c = d = e = f = g = h = T1 = T2 = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x58(%rbp)
movl $0x0, -0x104(%rbp)
movq -0x58(%rbp), %rax
movq -0x40(%rbp), %rcx
shrq $0xe, %rcx
movq -0x40(%rbp), %rdx
shlq $0x32, %rdx
orq %rdx, %rcx
movq -0x40(%rbp), %rdx
shrq $0x12, %rdx
movq -0x40(%rbp), %rsi
shlq $0x2e, %rsi
orq %rsi, %rdx
xorq %rdx, %rcx
movq -0x40(%rbp), %rdx
shrq $0x29, %rdx
movq -0x40(%rbp), %rsi
shlq $0x17, %rsi
orq %rsi, %rdx
xorq %rdx, %rcx
addq %rcx, %rax
movq -0x40(%rbp), %rcx
andq -0x48(%rbp), %rcx
movq -0x40(%rbp), %rdx
xorq $-0x1, %rdx
andq -0x50(%rbp), %rdx
xorq %rdx, %rcx
addq %rcx, %rax
movslq -0x104(%rbp), %rdx
leaq 0x4df2(%rip), %rcx      # 0xf190
addq (%rcx,%rdx,8), %rax
movq -0x10(%rbp), %rcx
movq %rcx, %rdx
addq $0x8, %rdx
movq %rdx, -0x10(%rbp)
movq (%rcx), %rcx
movslq -0x104(%rbp), %rdx
movq %rcx, -0x100(%rbp,%rdx,8)
addq %rcx, %rax
movq %rax, -0x70(%rbp)
movq -0x20(%rbp), %rax
shrq $0x1c, %rax
movq -0x20(%rbp), %rcx
shlq $0x24, %rcx
orq %rcx, %rax
movq -0x20(%rbp), %rcx
shrq $0x22, %rcx
movq -0x20(%rbp), %rdx
shlq $0x1e, %rdx
orq %rdx, %rcx
xorq %rcx, %rax
movq -0x20(%rbp), %rcx
shrq $0x27, %rcx
movq -0x20(%rbp), %rdx
shlq $0x19, %rdx
orq %rdx, %rcx
xorq %rcx, %rax
movq -0x20(%rbp), %rcx
andq -0x28(%rbp), %rcx
movq -0x20(%rbp), %rdx
andq -0x30(%rbp), %rdx
xorq %rdx, %rcx
movq -0x28(%rbp), %rdx
andq -0x30(%rbp), %rdx
xorq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rax
addq -0x70(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x70(%rbp), %rax
addq -0x78(%rbp), %rax
movq %rax, -0x20(%rbp)
movl -0x104(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x104(%rbp)
cmpl $0x10, -0x104(%rbp)
jl 0xa330
jmp 0xa494
movl -0x104(%rbp), %eax
addl $0x1, %eax
andl $0xf, %eax
cltq
movq -0x100(%rbp,%rax,8), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
shrq %rax
movq -0x60(%rbp), %rcx
shlq $0x3f, %rcx
orq %rcx, %rax
movq -0x60(%rbp), %rcx
shrq $0x8, %rcx
movq -0x60(%rbp), %rdx
shlq $0x38, %rdx
orq %rdx, %rcx
xorq %rcx, %rax
movq -0x60(%rbp), %rcx
shrq $0x7, %rcx
xorq %rcx, %rax
movq %rax, -0x60(%rbp)
movl -0x104(%rbp), %eax
addl $0xe, %eax
andl $0xf, %eax
cltq
movq -0x100(%rbp,%rax,8), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
shrq $0x13, %rax
movq -0x68(%rbp), %rcx
shlq $0x2d, %rcx
orq %rcx, %rax
movq -0x68(%rbp), %rcx
shrq $0x3d, %rcx
movq -0x68(%rbp), %rdx
shlq $0x3, %rdx
orq %rdx, %rcx
xorq %rcx, %rax
movq -0x68(%rbp), %rcx
shrq $0x6, %rcx
xorq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x58(%rbp), %rax
movq -0x40(%rbp), %rcx
shrq $0xe, %rcx
movq -0x40(%rbp), %rdx
shlq $0x32, %rdx
orq %rdx, %rcx
movq -0x40(%rbp), %rdx
shrq $0x12, %rdx
movq -0x40(%rbp), %rsi
shlq $0x2e, %rsi
orq %rsi, %rdx
xorq %rdx, %rcx
movq -0x40(%rbp), %rdx
shrq $0x29, %rdx
movq -0x40(%rbp), %rsi
shlq $0x17, %rsi
orq %rsi, %rdx
xorq %rdx, %rcx
addq %rcx, %rax
movq -0x40(%rbp), %rcx
andq -0x48(%rbp), %rcx
movq -0x40(%rbp), %rdx
xorq $-0x1, %rdx
andq -0x50(%rbp), %rdx
xorq %rdx, %rcx
addq %rcx, %rax
movslq -0x104(%rbp), %rdx
leaq 0x4beb(%rip), %rcx      # 0xf190
addq (%rcx,%rdx,8), %rax
movq -0x68(%rbp), %rcx
movl -0x104(%rbp), %edx
addl $0x9, %edx
andl $0xf, %edx
movslq %edx, %rdx
addq -0x100(%rbp,%rdx,8), %rcx
addq -0x60(%rbp), %rcx
movl -0x104(%rbp), %edx
andl $0xf, %edx
movslq %edx, %rdx
addq -0x100(%rbp,%rdx,8), %rcx
movq %rcx, -0x100(%rbp,%rdx,8)
addq %rcx, %rax
movq %rax, -0x70(%rbp)
movq -0x20(%rbp), %rax
shrq $0x1c, %rax
movq -0x20(%rbp), %rcx
shlq $0x24, %rcx
orq %rcx, %rax
movq -0x20(%rbp), %rcx
shrq $0x22, %rcx
movq -0x20(%rbp), %rdx
shlq $0x1e, %rdx
orq %rdx, %rcx
xorq %rcx, %rax
movq -0x20(%rbp), %rcx
shrq $0x27, %rcx
movq -0x20(%rbp), %rdx
shlq $0x19, %rdx
orq %rdx, %rcx
xorq %rcx, %rax
movq -0x20(%rbp), %rcx
andq -0x28(%rbp), %rcx
movq -0x20(%rbp), %rdx
andq -0x30(%rbp), %rdx
xorq %rdx, %rcx
movq -0x28(%rbp), %rdx
andq -0x30(%rbp), %rdx
xorq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rax
addq -0x70(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x70(%rbp), %rax
addq -0x78(%rbp), %rax
movq %rax, -0x20(%rbp)
movl -0x104(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x104(%rbp)
cmpl $0x50, -0x104(%rbp)
jl 0xa494
movq -0x8(%rbp), %rax
movq (%rax), %rcx
addq -0x20(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rcx
addq -0x28(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rcx
addq -0x30(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rcx
addq -0x38(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rcx
addq -0x40(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rcx
addq -0x48(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rcx
addq -0x50(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rcx
addq -0x58(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x38(%rax)
movq $0x0, -0x78(%rbp)
movq $0x0, -0x70(%rbp)
movq $0x0, -0x58(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x20(%rbp)
addq $0x90, %rsp
popq %rbp
retq
nopw (%rax,%rax)