// File: /workspace/github_c_makefile_star2_O1/sbp[P]tweetnacl-tools/tweetnacl.c
// Function: crypto_scalarmult_curve25519_tweet
int crypto_scalarmult(u8 *q,const u8 *n,const u8 *p)
{
  u8 z[32];
  i64 x[80],r,i;
  gf a,b,c,d,e,f;
  FOR(i,31) z[i]=n[i];
  z[31]=(n[31]&127)|64;
  z[0]&=248;
  unpack25519(x,p);
  FOR(i,16) {
    b[i]=x[i];
    d[i]=a[i]=c[i]=0;
  }
  a[0]=d[0]=1;
  for(i=254;i>=0;--i) {
    r=(z[i>>3]>>(i&7))&1;
    sel25519(a,b,r);
    sel25519(c,d,r);
    A(e,a,c);
    Z(a,a,c);
    A(c,b,d);
    Z(b,b,d);
    S(d,e);
    S(f,a);
    M(a,c,a);
    M(c,b,e);
    A(e,a,c);
    Z(a,a,c);
    S(b,a);
    Z(c,d,f);
    M(a,c,_121665);
    A(a,a,d);
    M(c,c,a);
    M(a,d,f);
    M(d,b,x);
    S(b,e);
    sel25519(a,b,r);
    sel25519(c,d,r);
  }
  FOR(i,16) {
    x[i+16]=a[i];
    x[i+32]=c[i];
    x[i+48]=b[i];
    x[i+64]=d[i];
  }
  inv25519(x+32,x+32);
  M(x+16,x+16,x+32);
  pack25519(q,x+16);
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x5b8, %rsp            # imm = 0x5B8
movq %rdi, 0x8(%rsp)
movups (%rsi), %xmm0
movups 0xf(%rsi), %xmm1
movups %xmm1, 0x1f(%rsp)
movaps %xmm0, 0x10(%rsp)
movb 0x1f(%rsi), %al
andb $0x3f, %al
orb $0x40, %al
movb %al, 0x2f(%rsp)
andb $-0x8, 0x10(%rsp)
xorl %eax, %eax
movzwl (%rdx,%rax,2), %ecx
movq %rcx, 0x330(%rsp,%rax,8)
incq %rax
cmpq $0x10, %rax
jne 0x1e9c
leaq 0x330(%rsp), %rsi
andq $0x7fff, 0x78(%rsi)     # imm = 0x7FFF
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %rax
movaps %xmm0, (%rax)
movaps %xmm0, 0x10(%rax)
movaps %xmm0, 0x20(%rax)
movaps %xmm0, 0x30(%rax)
movaps %xmm0, 0x40(%rax)
movaps %xmm0, 0x50(%rax)
movaps %xmm0, 0x60(%rax)
movaps %xmm0, 0x70(%rax)
leaq 0x130(%rsp), %r12
movaps %xmm0, (%r12)
movaps %xmm0, 0x10(%r12)
movaps %xmm0, 0x20(%r12)
movaps %xmm0, 0x30(%r12)
movaps %xmm0, 0x40(%r12)
movaps %xmm0, 0x50(%r12)
movaps %xmm0, 0x60(%r12)
movaps %xmm0, 0x70(%r12)
leaq 0xb0(%rsp), %rdx
movaps %xmm0, 0x70(%rdx)
movaps %xmm0, 0x60(%rdx)
movaps %xmm0, 0x50(%rdx)
movaps %xmm0, 0x40(%rdx)
movaps %xmm0, 0x30(%rdx)
movaps %xmm0, 0x20(%rdx)
movaps %xmm0, 0x10(%rdx)
movaps %xmm0, (%rdx)
leaq 0x1b0(%rsp), %rbp
movl $0x10, %ecx
movq %rbp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movl $0x1, %eax
movq %rax, (%rdx)
movq %rax, (%r12)
movl $0xfe, %r14d
leaq 0x2b0(%rsp), %rbx
movq %r14, %rax
shrq $0x3, %rax
movzbl 0x10(%rsp,%rax), %eax
movl %r14d, %ecx
andl $0x7, %ecx
btl %ecx, %eax
movl $0x0, %r13d
sbbq %r13, %r13
xorl %eax, %eax
movq 0x130(%rsp,%rax,8), %rcx
movq 0x1b0(%rsp,%rax,8), %rdx
movq %rdx, %rsi
xorq %rcx, %rsi
andq %r13, %rsi
xorq %rsi, %rcx
movq %rcx, 0x130(%rsp,%rax,8)
xorq %rdx, %rsi
movq %rsi, 0x1b0(%rsp,%rax,8)
incq %rax
cmpq $0x10, %rax
jne 0x1f93
xorl %eax, %eax
movq 0x30(%rsp,%rax,8), %rcx
movq 0xb0(%rsp,%rax,8), %rdx
movq %rdx, %rsi
xorq %rcx, %rsi
andq %r13, %rsi
xorq %rsi, %rcx
movq %rcx, 0x30(%rsp,%rax,8)
xorq %rdx, %rsi
movq %rsi, 0xb0(%rsp,%rax,8)
incq %rax
cmpq $0x10, %rax
jne 0x1fcd
xorl %eax, %eax
movq 0x30(%rsp,%rax,8), %rcx
addq 0x130(%rsp,%rax,8), %rcx
movq %rcx, 0x2b0(%rsp,%rax,8)
incq %rax
cmpq $0x10, %rax
jne 0x2001
xorl %eax, %eax
movq 0x30(%rsp,%rax,8), %rcx
subq %rcx, 0x130(%rsp,%rax,8)
incq %rax
cmpq $0x10, %rax
jne 0x2021
xorl %eax, %eax
movq 0xb0(%rsp,%rax,8), %rcx
addq 0x1b0(%rsp,%rax,8), %rcx
movq %rcx, 0x30(%rsp,%rax,8)
incq %rax
cmpq $0x10, %rax
jne 0x2039
xorl %eax, %eax
movq 0xb0(%rsp,%rax,8), %rcx
subq %rcx, 0x1b0(%rsp,%rax,8)
incq %rax
cmpq $0x10, %rax
jne 0x2059
leaq 0xb0(%rsp), %rdi
movq %rbx, %rsi
movq %rbx, %rdx
callq 0x22ad
leaq 0x230(%rsp), %rdi
movq %r12, %rsi
movq %r12, %rdx
callq 0x22ad
movq %r12, %rdi
leaq 0x30(%rsp), %r15
movq %r15, %rsi
movq %r12, %rdx
callq 0x22ad
movq %r15, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x22ad
xorl %eax, %eax
movq 0x30(%rsp,%rax,8), %rcx
addq 0x130(%rsp,%rax,8), %rcx
movq %rcx, 0x2b0(%rsp,%rax,8)
incq %rax
cmpq $0x10, %rax
jne 0x20bb
xorl %eax, %eax
movq 0x30(%rsp,%rax,8), %rcx
subq %rcx, 0x130(%rsp,%rax,8)
incq %rax
cmpq $0x10, %rax
jne 0x20db
movq %rbp, %rdi
movq %r12, %rsi
movq %r12, %rdx
callq 0x22ad
xorl %eax, %eax
movq 0xb0(%rsp,%rax,8), %rcx
subq 0x230(%rsp,%rax,8), %rcx
movq %rcx, 0x30(%rsp,%rax,8)
incq %rax
cmpq $0x10, %rax
jne 0x2101
movq %rbp, %r15
movq %r12, %rdi
leaq 0x30(%rsp), %rsi
leaq 0x22bf(%rip), %rdx      # 0x43f0
callq 0x22ad
xorl %eax, %eax
movq 0xb0(%rsp,%rax,8), %rcx
addq %rcx, 0x130(%rsp,%rax,8)
incq %rax
cmpq $0x10, %rax
jne 0x2138
leaq 0x30(%rsp), %rdi
movq %rdi, %rsi
movq %r12, %rdx
callq 0x22ad
movq %r12, %rdi
leaq 0xb0(%rsp), %rbp
movq %rbp, %rsi
leaq 0x230(%rsp), %rdx
callq 0x22ad
movq %rbp, %rdi
movq %r15, %rbp
movq %r15, %rsi
leaq 0x330(%rsp), %rdx
callq 0x22ad
movq %r15, %rdi
movq %rbx, %rsi
movq %rbx, %rdx
callq 0x22ad
xorl %eax, %eax
movq 0x130(%rsp,%rax,8), %rcx
movq 0x1b0(%rsp,%rax,8), %rdx
movq %rdx, %rsi
xorq %rcx, %rsi
andq %r13, %rsi
xorq %rsi, %rcx
movq %rcx, 0x130(%rsp,%rax,8)
xorq %rdx, %rsi
movq %rsi, 0x1b0(%rsp,%rax,8)
incq %rax
cmpq $0x10, %rax
jne 0x21a2
xorl %eax, %eax
movq 0x30(%rsp,%rax,8), %rcx
movq 0xb0(%rsp,%rax,8), %rdx
movq %rdx, %rsi
xorq %rcx, %rsi
andq %r13, %rsi
xorq %rsi, %rcx
movq %rcx, 0x30(%rsp,%rax,8)
xorq %rdx, %rsi
movq %rsi, 0xb0(%rsp,%rax,8)
incq %rax
cmpq $0x10, %rax
jne 0x21dc
subq $0x1, %r14
jae 0x1f73
xorl %eax, %eax
movq 0x130(%rsp,%rax), %rcx
movq %rcx, 0x3b0(%rsp,%rax)
movq 0x30(%rsp,%rax), %rcx
movq %rcx, 0x430(%rsp,%rax)
movq 0x1b0(%rsp,%rax), %rcx
movq %rcx, 0x4b0(%rsp,%rax)
movq 0xb0(%rsp,%rax), %rcx
movq %rcx, 0x530(%rsp,%rax)
addq $0x8, %rax
cmpq $0x80, %rax
jne 0x221a
leaq 0x430(%rsp), %rbx
movq %rbx, %rdi
movq %rbx, %rsi
callq 0x2349
leaq 0x3b0(%rsp), %r14
movq %r14, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x22ad
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x23b6
xorl %eax, %eax
addq $0x5b8, %rsp            # imm = 0x5B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq