// File: /workspace/github_c_makefile_star2_O1/sbp[P]tweetnacl-tools/tweetnacl.c
// Function: crypto_onetimeauth_poly1305_tweet
int crypto_onetimeauth(u8 *out,const u8 *m,u64 n,const u8 *k)
{
  u32 s,i,j,u,x[17],r[17],h[17],c[17],g[17];

  FOR(j,17) r[j]=h[j]=0;
  FOR(j,16) r[j]=k[j];
  r[3]&=15;
  r[4]&=252;
  r[7]&=15;
  r[8]&=252;
  r[11]&=15;
  r[12]&=252;
  r[15]&=15;

  while (n > 0) {
    FOR(j,17) c[j] = 0;
    for (j = 0;(j < 16) && (j < n);++j) c[j] = m[j];
    c[j] = 1;
    m += j; n -= j;
    add1305(h,c);
    FOR(i,17) {
      x[i] = 0;
      FOR(j,17) x[i] += h[j] * ((j <= i) ? r[i - j] : 320 * r[i + 17 - j]);
    }
    FOR(i,17) h[i] = x[i];
    u = 0;
    FOR(j,16) {
      u += h[j];
      h[j] = u & 255;
      u >>= 8;
    }
    u += h[16]; h[16] = u & 3;
    u = 5 * (u >> 2);
    FOR(j,16) {
      u += h[j];
      h[j] = u & 255;
      u >>= 8;
    }
    u += h[16]; h[16] = u;
  }

  FOR(j,17) g[j] = h[j];
  add1305(h,minusp);
  s = -(h[16] >> 7);
  FOR(j,17) h[j] ^= s & (g[j] ^ h[j]);

  FOR(j,16) c[j] = k[j + 16];
  c[16] = 0;
  add1305(h,c);
  FOR(j,16) out[j] = h[j];
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2c8, %rsp            # imm = 0x2C8
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %rbx
movq %rsp, %rdi
xorl %r13d, %r13d
movl $0x88, %edx
xorl %esi, %esi
callq 0x1060
leaq 0x90(%rsp), %rdi
movl $0x88, %edx
xorl %esi, %esi
callq 0x1060
movzbl (%r14,%r13), %eax
movq %rax, 0x90(%rsp,%r13,8)
incq %r13
cmpq $0x10, %r13
jne 0x1a30
andq $0xf, 0xa8(%rsp)
movl $0xfc, %eax
andq %rax, 0xb0(%rsp)
andq $0xf, 0xc8(%rsp)
andq %rax, 0xd0(%rsp)
andq $0xf, 0xe8(%rsp)
andq %rax, 0xf0(%rsp)
andq $0xf, 0x108(%rsp)
testq %r15, %r15
je 0x1be3
leaq 0x1b0(%rsp), %rbp
movl $0x88, %edx
leaq 0x120(%rsp), %rdi
xorl %esi, %esi
callq 0x1060
cmpq $0x10, %r15
movl $0x10, %eax
cmovbq %r15, %rax
cmpq $0x1, %rax
adcq $0x0, %rax
xorl %r13d, %r13d
movzbl (%r12,%r13), %ecx
movq %rcx, 0x120(%rsp,%r13,8)
incq %r13
cmpq %r13, %rax
jne 0x1ac4
movq $0x1, 0x120(%rsp,%r13,8)
addq %r13, %r12
xorl %eax, %eax
xorl %ecx, %ecx
addq (%rsp,%rcx,8), %rax
addq 0x120(%rsp,%rcx,8), %rax
movzbl %al, %edx
movq %rdx, (%rsp,%rcx,8)
shrq $0x8, %rax
incq %rcx
cmpq $0x11, %rcx
jne 0x1aec
leaq 0x90(%rsp), %rax
xorl %ecx, %ecx
movq $0x0, 0x1b0(%rsp,%rcx,8)
movq %rax, %rdx
xorl %edi, %edi
xorl %esi, %esi
movq (%rsp,%rdi,8), %r8
cmpq %rcx, %rdi
jbe 0x1b43
movq 0x88(%rdx), %r9
shlq $0x6, %r9
leaq (%r9,%r9,4), %r9
jmp 0x1b46
movq (%rdx), %r9
imulq %r8, %r9
addq %r9, %rsi
incq %rdi
addq $-0x8, %rdx
cmpq $0x11, %rdi
jne 0x1b29
movq %rsi, 0x1b0(%rsp,%rcx,8)
incq %rcx
addq $0x8, %rax
cmpq $0x11, %rcx
jne 0x1b16
movl $0x88, %edx
movq %rsp, %rdi
movq %rbp, %rsi
callq 0x10c0
xorl %eax, %eax
xorl %ecx, %ecx
addq (%rsp,%rcx,8), %rax
movzbl %al, %edx
movq %rdx, (%rsp,%rcx,8)
shrq $0x8, %rax
incq %rcx
cmpq $0x10, %rcx
jne 0x1b83
addq 0x80(%rsp), %rax
movl %eax, %ecx
andl $0x3, %ecx
movq %rcx, 0x80(%rsp)
shrq $0x2, %rax
leaq (%rax,%rax,4), %rax
xorl %ecx, %ecx
addq (%rsp,%rcx,8), %rax
movzbl %al, %edx
movq %rdx, (%rsp,%rcx,8)
shrq $0x8, %rax
incq %rcx
cmpq $0x10, %rcx
jne 0x1bba
addq %rax, 0x80(%rsp)
subq %r13, %r15
jne 0x1a98
leaq 0x240(%rsp), %rdi
movq %rsp, %rsi
movl $0x88, %edx
callq 0x10c0
xorl %eax, %eax
leaq 0x248f(%rip), %rcx      # 0x4090
xorl %edx, %edx
addq (%rsp,%rax), %rdx
addq (%rax,%rcx), %rdx
movzbl %dl, %esi
movq %rsi, (%rsp,%rax)
shrq $0x8, %rdx
addq $0x8, %rax
cmpq $0x88, %rax
jne 0x1c03
movq 0x80(%rsp), %rax
shrq $0x7, %rax
negq %rax
xorl %ecx, %ecx
movq (%rsp,%rcx,8), %rdx
movq 0x240(%rsp,%rcx,8), %rsi
xorq %rdx, %rsi
andq %rax, %rsi
xorq %rdx, %rsi
movq %rsi, (%rsp,%rcx,8)
incq %rcx
cmpq $0x11, %rcx
jne 0x1c33
xorl %eax, %eax
movzbl 0x10(%r14,%rax), %ecx
movq %rcx, 0x120(%rsp,%rax,8)
incq %rax
cmpq $0x10, %rax
jne 0x1c57
movq $0x0, 0x1a0(%rsp)
xorl %eax, %eax
xorl %ecx, %ecx
addq (%rsp,%rcx,8), %rax
addq 0x120(%rsp,%rcx,8), %rax
movzbl %al, %edx
movq %rdx, (%rsp,%rcx,8)
shrq $0x8, %rax
incq %rcx
cmpq $0x11, %rcx
jne 0x1c7e
xorl %eax, %eax
movb (%rsp,%rax,8), %cl
movb %cl, (%rbx,%rax)
incq %rax
cmpq $0x10, %rax
jne 0x1ca0
xorl %eax, %eax
addq $0x2c8, %rsp            # imm = 0x2C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq