// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x5d0, %rsp            # imm = 0x5D0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq $0x0, -0x2d0(%rbp)
cmpq $0x1f, -0x2d0(%rbp)
jge 0x2809
movq -0x10(%rbp), %rax
movq -0x2d0(%rbp), %rcx
movb (%rax,%rcx), %cl
movq -0x2d0(%rbp), %rax
movb %cl, -0x40(%rbp,%rax)
movq -0x2d0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x2d0(%rbp)
jmp 0x27d2
movq -0x10(%rbp), %rax
movzbl 0x1f(%rax), %eax
andl $0x7f, %eax
orl $0x40, %eax
movb %al, -0x21(%rbp)
movzbl -0x40(%rbp), %eax
andl $0xf8, %eax
movb %al, -0x40(%rbp)
leaq -0x2c0(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x2c70
movq $0x0, -0x2d0(%rbp)
cmpq $0x10, -0x2d0(%rbp)
jge 0x28b6
movq -0x2d0(%rbp), %rax
movq -0x2c0(%rbp,%rax,8), %rcx
movq -0x2d0(%rbp), %rax
movq %rcx, -0x3d0(%rbp,%rax,8)
movq -0x2d0(%rbp), %rax
movq $0x0, -0x450(%rbp,%rax,8)
movq -0x2d0(%rbp), %rax
movq $0x0, -0x350(%rbp,%rax,8)
movq -0x2d0(%rbp), %rax
movq $0x0, -0x4d0(%rbp,%rax,8)
movq -0x2d0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x2d0(%rbp)
jmp 0x2841
movq $0x1, -0x4d0(%rbp)
movq $0x1, -0x350(%rbp)
movq $0xfe, -0x2d0(%rbp)
cmpq $0x0, -0x2d0(%rbp)
jl 0x2b4d
movq -0x2d0(%rbp), %rax
sarq $0x3, %rax
movzbl -0x40(%rbp,%rax), %eax
movq -0x2d0(%rbp), %rcx
andq $0x7, %rcx
sarl %cl, %eax
andl $0x1, %eax
cltq
movq %rax, -0x2c8(%rbp)
leaq -0x350(%rbp), %rdi
leaq -0x3d0(%rbp), %rsi
movq -0x2c8(%rbp), %rax
movl %eax, %edx
callq 0x2cf0
leaq -0x450(%rbp), %rdi
leaq -0x4d0(%rbp), %rsi
movq -0x2c8(%rbp), %rax
movl %eax, %edx
callq 0x2cf0
leaq -0x550(%rbp), %rdi
leaq -0x350(%rbp), %rsi
leaq -0x450(%rbp), %rdx
callq 0x2d80
leaq -0x350(%rbp), %rdi
leaq -0x350(%rbp), %rsi
leaq -0x450(%rbp), %rdx
callq 0x2dd0
leaq -0x450(%rbp), %rdi
leaq -0x3d0(%rbp), %rsi
leaq -0x4d0(%rbp), %rdx
callq 0x2d80
leaq -0x3d0(%rbp), %rdi
leaq -0x3d0(%rbp), %rsi
leaq -0x4d0(%rbp), %rdx
callq 0x2dd0
leaq -0x4d0(%rbp), %rdi
leaq -0x550(%rbp), %rsi
callq 0x2e20
leaq -0x5d0(%rbp), %rdi
leaq -0x350(%rbp), %rsi
callq 0x2e20
leaq -0x350(%rbp), %rdi
leaq -0x450(%rbp), %rsi
leaq -0x350(%rbp), %rdx
callq 0x2e50
leaq -0x450(%rbp), %rdi
leaq -0x3d0(%rbp), %rsi
leaq -0x550(%rbp), %rdx
callq 0x2e50
leaq -0x550(%rbp), %rdi
leaq -0x350(%rbp), %rsi
leaq -0x450(%rbp), %rdx
callq 0x2d80
leaq -0x350(%rbp), %rdi
leaq -0x350(%rbp), %rsi
leaq -0x450(%rbp), %rdx
callq 0x2dd0
leaq -0x3d0(%rbp), %rdi
leaq -0x350(%rbp), %rsi
callq 0x2e20
leaq -0x450(%rbp), %rdi
leaq -0x4d0(%rbp), %rsi
leaq -0x5d0(%rbp), %rdx
callq 0x2dd0
leaq -0x350(%rbp), %rdi
leaq -0x450(%rbp), %rsi
leaq 0x3972(%rip), %rdx      # 0x63f0
callq 0x2e50
leaq -0x350(%rbp), %rdi
leaq -0x350(%rbp), %rsi
leaq -0x4d0(%rbp), %rdx
callq 0x2d80
leaq -0x450(%rbp), %rdi
leaq -0x450(%rbp), %rsi
leaq -0x350(%rbp), %rdx
callq 0x2e50
leaq -0x350(%rbp), %rdi
leaq -0x4d0(%rbp), %rsi
leaq -0x5d0(%rbp), %rdx
callq 0x2e50
leaq -0x4d0(%rbp), %rdi
leaq -0x3d0(%rbp), %rsi
leaq -0x2c0(%rbp), %rdx
callq 0x2e50
leaq -0x3d0(%rbp), %rdi
leaq -0x550(%rbp), %rsi
callq 0x2e20
leaq -0x350(%rbp), %rdi
leaq -0x3d0(%rbp), %rsi
movq -0x2c8(%rbp), %rax
movl %eax, %edx
callq 0x2cf0
leaq -0x450(%rbp), %rdi
leaq -0x4d0(%rbp), %rsi
movq -0x2c8(%rbp), %rax
movl %eax, %edx
callq 0x2cf0
movq -0x2d0(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x2d0(%rbp)
jmp 0x28d7
movq $0x0, -0x2d0(%rbp)
cmpq $0x10, -0x2d0(%rbp)
jge 0x2bf5
movq -0x2d0(%rbp), %rax
movq -0x350(%rbp,%rax,8), %rcx
movq -0x2d0(%rbp), %rax
movq %rcx, -0x240(%rbp,%rax,8)
movq -0x2d0(%rbp), %rax
movq -0x450(%rbp,%rax,8), %rcx
movq -0x2d0(%rbp), %rax
movq %rcx, -0x1c0(%rbp,%rax,8)
movq -0x2d0(%rbp), %rax
movq -0x3d0(%rbp,%rax,8), %rcx
movq -0x2d0(%rbp), %rax
movq %rcx, -0x140(%rbp,%rax,8)
movq -0x2d0(%rbp), %rax
movq -0x4d0(%rbp,%rax,8), %rcx
movq -0x2d0(%rbp), %rax
movq %rcx, -0xc0(%rbp,%rax,8)
movq -0x2d0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x2d0(%rbp)
jmp 0x2b58
leaq -0x2c0(%rbp), %rdi
addq $0x100, %rdi            # imm = 0x100
leaq -0x2c0(%rbp), %rsi
addq $0x100, %rsi            # imm = 0x100
callq 0x2f90
leaq -0x2c0(%rbp), %rdi
addq $0x80, %rdi
leaq -0x2c0(%rbp), %rsi
addq $0x80, %rsi
leaq -0x2c0(%rbp), %rdx
addq $0x100, %rdx            # imm = 0x100
callq 0x2e50
movq -0x8(%rbp), %rdi
leaq -0x2c0(%rbp), %rsi
addq $0x80, %rsi
callq 0x30a0
xorl %eax, %eax
addq $0x5d0, %rsp            # imm = 0x5D0
popq %rbp
retq
nopw (%rax,%rax)