// File: /workspace/github_c_makefile_star2_O1/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 0x266a
movq %r8, -0x80(%rsp,%rcx,8)
movq %r8, (%rsp,%rcx,8)
incq %rcx
addq $0x8, %rdx
cmpq $0x8, %rcx
jne 0x2664
cmpq $0x80, %rax
jb 0x2878
leaq 0x1a85(%rip), %rcx      # 0x4130
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 0x26b7
movq %r9, 0x40(%rsp,%r8,8)
incq %r8
addq $0x8, %rdx
cmpq $0x10, %r8
jne 0x26b1
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)
movaps -0x80(%rsp), %xmm0
movaps %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 0x27a2
movl %edx, %r8d
notl %r8d
testb $0xf, %r8b
jne 0x283c
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 0x27ce
incq %rdx
cmpq $0x50, %rdx
jne 0x26e3
xorl %edx, %edx
movq -0x80(%rsp,%rdx,8), %r8
addq (%rsp,%rdx,8), %r8
movq %r8, -0x80(%rsp,%rdx,8)
movq %r8, (%rsp,%rdx,8)
incq %rdx
cmpq $0x8, %rdx
jne 0x284b
subq $-0x80, %rsi
addq $-0x80, %rax
cmpq $0x7f, %rax
ja 0x26ab
xorl %ecx, %ecx
movq (%rsp,%rcx,8), %rdx
movl $0x8, %esi
movb %dl, -0x1(%rdi,%rsi)
shrq $0x8, %rdx
decq %rsi
jne 0x2883
incq %rcx
addq $0x8, %rdi
cmpq $0x8, %rcx
jne 0x287a
addq $0xc0, %rsp
popq %rbx
popq %r14
popq %r15
retq