// File: /workspace/github_c_makefile_star2_O2/rongarret[P]clmm/tweetnacl.c
// Function: crypto_scalarmult_curve25519_tweet
int crypto_scalarmult(u8 *q,const u8 *n,const u8 *p)
{
  u8 z[32];
  i64 x[96],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+32]=a[i];
    x[i+48]=c[i];
    x[i+64]=b[i];
    x[i+80]=d[i];
  }
  inv25519(x+48,x+48);
  M(x+32,x+32,x+48);
  pack25519(q,x+32);
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x638, %rsp            # imm = 0x638
movq %rdi, -0x38(%rbp)
xorl %eax, %eax
cmpq $0x1f, %rax
je 0x224c
movb (%rsi,%rax), %cl
movb %cl, -0x60(%rbp,%rax)
incq %rax
jmp 0x223a
movb 0x1f(%rsi), %al
andb $0x3f, %al
orb $0x40, %al
movb %al, -0x41(%rbp)
andb $-0x8, -0x60(%rbp)
leaq -0x660(%rbp), %rdi
movq %rdx, %rsi
callq 0x24f6
xorl %eax, %eax
cmpq $0x10, %rax
je 0x22a1
movq -0x660(%rbp,%rax,8), %rcx
andq $0x0, -0x260(%rbp,%rax,8)
movq %rcx, -0x2e0(%rbp,%rax,8)
andq $0x0, -0x360(%rbp,%rax,8)
andq $0x0, -0xe0(%rbp,%rax,8)
incq %rax
jmp 0x226b
pushq $0x1
popq %rax
leaq -0xe0(%rbp), %rcx
movq %rax, (%rcx)
leaq -0x360(%rbp), %r15
movq %rax, (%r15)
movl $0xfe, %eax
leaq -0x260(%rbp), %r13
testq %rax, %rax
js 0x245f
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
shrq $0x3, %rax
movzbl -0x60(%rbp,%rax), %eax
movq -0x30(%rbp), %rcx
andl $0x7, %ecx
xorl %ebx, %ebx
btl %ecx, %eax
setb %bl
movq %r15, %rdi
leaq -0x2e0(%rbp), %r14
movq %r14, %rsi
movl %ebx, %edx
callq 0x2519
movq %r13, %rdi
leaq -0xe0(%rbp), %r12
movq %r12, %rsi
movl %ebx, %edx
callq 0x2519
leaq -0x160(%rbp), %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x254a
movq %r15, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x2569
movq %r13, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x254a
movq %r14, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x2569
movq %r12, %rdi
leaq -0x160(%rbp), %rsi
callq 0x2588
leaq -0x1e0(%rbp), %rdi
movq %r15, %rsi
callq 0x2588
movq %r15, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x2592
movq %r13, %rdi
movq %r14, %rsi
movq %r14, %r12
leaq -0x160(%rbp), %rdx
movq %rdx, %r14
callq 0x2592
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x254a
movq %r15, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x2569
movq %r12, %rdi
movq %r12, %r14
movq %r15, %rsi
callq 0x2588
movq %r13, %rdi
leaq -0xe0(%rbp), %r12
movq %r12, %rsi
leaq -0x1e0(%rbp), %rdx
callq 0x2569
movq %r15, %rdi
movq %r13, %rsi
leaq 0x222b(%rip), %rdx      # 0x4610
callq 0x2592
movq %r15, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x254a
movq %r13, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x2592
movq %r15, %rdi
movq %r12, %rsi
leaq -0x1e0(%rbp), %rdx
callq 0x2592
movq %r12, %rdi
movq %r14, %rsi
leaq -0x660(%rbp), %rdx
callq 0x2592
movq %r14, %rdi
leaq -0x160(%rbp), %rsi
callq 0x2588
movq %r15, %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0x2519
movq %r13, %rdi
movq %r12, %rsi
movl %ebx, %edx
callq 0x2519
movq -0x30(%rbp), %rax
decq %rax
jmp 0x22c4
xorl %eax, %eax
cmpq $0x80, %rax
je 0x24af
movq -0x360(%rbp,%rax), %rcx
movq %rcx, -0x560(%rbp,%rax)
movq -0x260(%rbp,%rax), %rcx
movq %rcx, -0x4e0(%rbp,%rax)
movq -0x2e0(%rbp,%rax), %rcx
movq %rcx, -0x460(%rbp,%rax)
movq -0xe0(%rbp,%rax), %rcx
movq %rcx, -0x3e0(%rbp,%rax)
addq $0x8, %rax
jmp 0x2461
leaq -0x4e0(%rbp), %rbx
movq %rbx, %rdi
movq %rbx, %rsi
callq 0x263a
leaq -0x560(%rbp), %r14
movq %r14, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x2592
movq -0x38(%rbp), %rdi
movq %r14, %rsi
callq 0x26d0
xorl %eax, %eax
addq $0x638, %rsp            # imm = 0x638
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq