// File: /workspace/github_c_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
xorl %r12d, %r12d
cmpq $0x40, %r12
je 0x23aa
leaq (%r14,%r12), %rdi
callq 0x25b6
movq %rax, 0x10(%rsp,%r12)
movq %rax, 0x90(%rsp,%r12)
addq $0x8, %r12
jmp 0x2388
movq %r14, 0x8(%rsp)
leaq 0x1d8a(%rip), %r12      # 0x4140
pushq $0x1
popq %r13
pushq $0xe
popq %rbp
cmpq $0x80, %rbx
jb 0x257d
xorl %r14d, %r14d
cmpq $0x80, %r14
je 0x23ed
leaq (%r15,%r14), %rdi
callq 0x25b6
movq %rax, 0xd0(%rsp,%r14)
addq $0x8, %r14
jmp 0x23cd
xorl %eax, %eax
cmpq $0x50, %rax
je 0x2549
xorl %ecx, %ecx
cmpq $0x8, %rcx
je 0x2410
movq 0x10(%rsp,%rcx,8), %rdx
movq %rdx, 0x50(%rsp,%rcx,8)
incq %rcx
jmp 0x23fb
movq 0x30(%rsp), %rdx
movq %rdx, %rcx
rolq $0x32, %rcx
movq %rdx, %rsi
rolq $0x2e, %rsi
xorq %rcx, %rsi
movq %rdx, %rdi
rolq $0x17, %rdi
xorq %rsi, %rdi
movq 0x38(%rsp), %rcx
andq %rdx, %rcx
notq %rdx
andq 0x40(%rsp), %rdx
movl %eax, %esi
andl $0xf, %esi
addq 0x48(%rsp), %rcx
addq %rdi, %rcx
addq %rdx, %rcx
addq (%r12,%rax,8), %rcx
addq 0xd0(%rsp,%rsi,8), %rcx
movq 0x10(%rsp), %rdx
movq 0x18(%rsp), %rsi
movq %rdx, %rdi
movq 0x20(%rsp), %r8
movq %r8, %r9
xorq %rsi, %r9
andq %rdx, %r9
movq %rdx, %r10
rolq $0x24, %r10
rolq $0x1e, %rdi
xorq %r10, %rdi
rolq $0x19, %rdx
xorq %rdi, %rdx
andq %rsi, %r8
xorq %r9, %r8
addq %rdx, %r8
addq %rcx, %r8
movq %r8, 0x88(%rsp)
addq %rcx, 0x68(%rsp)
movq %r13, %rcx
cmpq $0x9, %rcx
je 0x24c2
movq 0x48(%rsp,%rcx,8), %rdx
movl %ecx, %esi
andl $0x7, %esi
movq %rdx, 0x10(%rsp,%rsi,8)
incq %rcx
jmp 0x24a8
movl %eax, %ecx
notl %ecx
testb $0xf, %cl
jne 0x2541
movq %rbp, %rcx
cmpq $0x1e, %rcx
je 0x2541
leal -0x5(%rcx), %edx
andl $0xf, %edx
leal -0xd(%rcx), %esi
andl $0xf, %esi
movq 0xd0(%rsp,%rsi,8), %rsi
movq %rsi, %rdi
rorq %rdi
movq %rsi, %r8
rolq $0x38, %r8
xorq %rdi, %r8
shrq $0x7, %rsi
xorq %r8, %rsi
movl %ecx, %edi
andl $0xf, %edi
movq 0xd0(%rsp,%rdi,8), %rdi
movq %rdi, %r8
rolq $0x2d, %r8
movq %rdi, %r9
rolq $0x3, %r9
xorq %r8, %r9
shrq $0x6, %rdi
xorq %r9, %rdi
movq 0x60(%rsp,%rcx,8), %r8
addq 0xd0(%rsp,%rdx,8), %r8
addq %rdi, %r8
addq %rsi, %r8
movq %r8, 0x60(%rsp,%rcx,8)
incq %rcx
jmp 0x24ce
incq %rax
jmp 0x23ef
xorl %eax, %eax
cmpq $0x8, %rax
je 0x2570
movq 0x10(%rsp,%rax,8), %rcx
addq 0x90(%rsp,%rax,8), %rcx
movq %rcx, 0x10(%rsp,%rax,8)
movq %rcx, 0x90(%rsp,%rax,8)
incq %rax
jmp 0x254b
subq $-0x80, %r15
addq $-0x80, %rbx
jmp 0x23bd
xorl %r15d, %r15d
movq 0x8(%rsp), %r14
cmpq $0x40, %r15
je 0x25a2
leaq (%r14,%r15), %rdi
movq 0x90(%rsp,%r15), %rsi
callq 0x25d1
addq $0x8, %r15
jmp 0x2585
movl %ebx, %eax
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq