// File: /workspace/github_c_makefile_star2_O3/sbp[P]tweetnacl-tools/tweetnacl.c
// Function: crypto_hashblocks_sha512_tweet
int crypto_hashblocks(u8 *x,const u8 *m,u64 n)
{
  u64 z[8],b[8],a[8],w[16],t;
  int i,j;

  FOR(i,8) z[i] = a[i] = dl64(x + 8 * i);

  while (n >= 128) {
    FOR(i,16) w[i] = dl64(m + 8 * i);

    FOR(i,80) {
      FOR(j,8) b[j] = a[j];
      t = a[7] + Sigma1(a[4]) + Ch(a[4],a[5],a[6]) + K[i] + w[i%16];
      b[7] = t + Sigma0(a[0]) + Maj(a[0],a[1],a[2]);
      b[3] += t;
      FOR(j,8) a[(j+1)%8] = b[j];
      if (i%16 == 15)
	FOR(j,16)
	  w[j] += w[(j+9)%16] + sigma0(w[(j+1)%16]) + sigma1(w[(j+14)%16]);
    }

    FOR(i,8) { a[i] += z[i]; z[i] = a[i]; }

    m += 128;
    n -= 128;
  }

  FOR(i,8) ts64(x+8*i,z[i]);

  return n;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0xc0, %rsp
movq %rdx, %rax
xorl %ecx, %ecx
movq %rdi, %rdx
xorl %r8d, %r8d
xorl %r9d, %r9d
movq %r8, %r10
shlq $0x8, %r10
movzbl (%rdx,%r9), %r8d
orq %r10, %r8
incq %r9
cmpq $0x8, %r9
jne 0x27a6
movq %r8, -0x80(%rsp,%rcx,8)
movq %r8, (%rsp,%rcx,8)
incq %rcx
addq $0x8, %rdx
cmpq $0x8, %rcx
jne 0x27a0
cmpq $0x80, %rax
jb 0x29bb
leaq 0x1959(%rip), %rcx      # 0x4140
movq %rsi, %rdx
xorl %r8d, %r8d
xorl %r9d, %r9d
xorl %r10d, %r10d
movq %r9, %r11
shlq $0x8, %r11
movzbl (%rdx,%r10), %r9d
orq %r11, %r9
incq %r10
cmpq $0x8, %r10
jne 0x27f3
movq %r9, 0x40(%rsp,%r8,8)
incq %r8
addq $0x8, %rdx
cmpq $0x10, %r8
jne 0x27ed
xorl %edx, %edx
movq -0x60(%rsp), %r9
movq %r9, %r8
rolq $0x32, %r8
movq %r9, %r10
rolq $0x2e, %r10
xorq %r8, %r10
movq %r9, %r11
rolq $0x17, %r11
xorq %r10, %r11
movq -0x58(%rsp), %r8
andq %r9, %r8
notq %r9
andq -0x50(%rsp), %r9
movl %edx, %r10d
andl $0xf, %r10d
addq -0x48(%rsp), %r8
addq %r11, %r8
addq %r9, %r8
addq (%rcx,%rdx,8), %r8
addq 0x40(%rsp,%r10,8), %r8
movq -0x80(%rsp), %r10
movq -0x78(%rsp), %r9
movq %r10, %r11
movq -0x70(%rsp), %rbx
movq %rbx, %r14
xorq %r9, %r14
andq %r10, %r14
movq %r10, %r15
rolq $0x24, %r15
rolq $0x1e, %r11
xorq %r15, %r11
movaps -0x50(%rsp), %xmm0
movaps %xmm0, -0x10(%rsp)
movaps -0x70(%rsp), %xmm0
movaps %xmm0, -0x30(%rsp)
movaps -0x60(%rsp), %xmm0
movaps %xmm0, -0x20(%rsp)
movdqa -0x80(%rsp), %xmm0
movdqa %xmm0, -0x40(%rsp)
rolq $0x19, %r10
xorq %r11, %r10
andq %r9, %rbx
xorq %r14, %rbx
addq %r10, %rbx
addq %r8, %rbx
movq %rbx, -0x8(%rsp)
addq %r8, -0x28(%rsp)
movl $0x1, %r8d
movq -0x48(%rsp,%r8,8), %r9
movl %r8d, %r10d
andl $0x7, %r10d
movq %r9, -0x80(%rsp,%r10,8)
incq %r8
cmpq $0x9, %r8
jne 0x28e0
movl %edx, %r8d
notl %r8d
testb $0xf, %r8b
jne 0x297a
movl $0xe, %r8d
leal -0xd(%r8), %r9d
andl $0xf, %r9d
movq 0x40(%rsp,%r9,8), %r9
movq %r9, %r10
rorq %r10
leal -0x5(%r8), %r11d
movq %r9, %rbx
rolq $0x38, %rbx
xorq %r10, %rbx
shrq $0x7, %r9
movl %r8d, %r10d
andl $0xf, %r10d
movq 0x40(%rsp,%r10,8), %r10
movq %r10, %r14
rolq $0x2d, %r14
xorq %rbx, %r9
movq %r10, %rbx
rolq $0x3, %rbx
andl $0xf, %r11d
xorq %r14, %rbx
shrq $0x6, %r10
xorq %rbx, %r10
movq -0x30(%rsp,%r8,8), %rbx
addq 0x40(%rsp,%r11,8), %rbx
addq %r10, %rbx
addq %r9, %rbx
movq %rbx, -0x30(%rsp,%r8,8)
incq %r8
cmpq $0x1e, %r8
jne 0x290c
incq %rdx
cmpq $0x50, %rdx
jne 0x281f
xorl %edx, %edx
movdqa -0x80(%rsp,%rdx,8), %xmm0
paddq (%rsp,%rdx,8), %xmm0
movdqa %xmm0, -0x80(%rsp,%rdx,8)
movdqa %xmm0, (%rsp,%rdx,8)
addq $0x2, %rdx
cmpq $0x8, %rdx
jne 0x2989
subq $-0x80, %rsi
addq $-0x80, %rax
cmpq $0x7f, %rax
ja 0x27e7
xorl %ecx, %ecx
movq (%rsp,%rcx,8), %rdx
movl $0x8, %esi
movb %dl, -0x1(%rdi,%rsi)
shrq $0x8, %rdx
decq %rsi
jne 0x29c6
incq %rcx
addq $0x8, %rdi
cmpq $0x8, %rcx
jne 0x29bd
addq $0xc0, %rsp
popq %rbx
popq %r14
popq %r15
retq