// File: /workspace/github_c_makefile_star2_O2/sbp[P]tweetnacl-tools/tweetnacl.c
// Function: crypto_sign_ed25519_tweet_open
int crypto_sign_open(u8 *m,u64 *mlen,const u8 *sm,u64 n,const u8 *pk)
{
  int i;
  u8 t[32],h[64];
  gf p[4],q[4];

  *mlen = -1;
  if (n < 64) return -1;

  if (unpackneg(q,pk)) return -1;

  FOR(i,n) m[i] = sm[i];
  FOR(i,32) m[i+32] = pk[i];
  crypto_hash(h,m,n);
  reduce(h);
  scalarmult(p,q,h);

  scalarbase(q,sm + 32);
  add(p,q);
  pack(t,p);

  n -= 64;
  if (crypto_verify_32(sm, t)) {
    FOR(i,n) m[i] = 0;
    return -1;
  }

  FOR(i,n) m[i] = sm[i + 64];
  *mlen = n;
  return 0;
}

// Assembly:
orq $-0x1, (%rsi)
pushq $-0x1
popq %rax
cmpq $0x40, %rcx
jb 0x2d97
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x798, %rsp            # imm = 0x798
movq %r8, %r15
movq %rcx, %rbx
movq %rdx, %r12
movq %rdi, %r14
movq %rsi, (%rsp)
leaq 0x310(%rsp), %rbp
leaq 0x1a3a(%rip), %rsi      # 0x45a0
movq %rbp, %rdi
callq 0x3196
leaq 0x290(%rsp), %r13
movq %r13, %rdi
movq %r15, 0x8(%rsp)
movq %r15, %rsi
callq 0x1f9c
leaq 0x90(%rsp), %r15
movq %r15, %rdi
movq %r13, %rsi
callq 0x201a
leaq 0x1b80(%rip), %rdx      # 0x4720
leaq 0x110(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0x201f
movq %r15, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x2000
movq %r13, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x1fe6
leaq 0x710(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
callq 0x201a
leaq 0x690(%rsp), %r15
movq %r15, %rdi
movq %rbp, %rsi
callq 0x201a
leaq 0x610(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x201f
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movq %r13, %rsi
leaq 0x90(%rsp), %rdx
callq 0x201f
movq %r15, %rdi
movq %r15, %rsi
leaq 0x110(%rsp), %rdx
callq 0x201f
xorl %eax, %eax
cmpq $0x10, %rax
je 0x2c50
movq 0x10(%rsp,%rax,8), %rcx
movq %rcx, 0x410(%rsp,%rax,8)
incq %rax
jmp 0x2c38
movl $0xfa, %r13d
leaq 0x410(%rsp), %r15
leaq 0x10(%rsp), %rbp
testl %r13d, %r13d
js 0x2c8c
movq %r15, %rdi
movq %r15, %rsi
callq 0x201a
cmpl $0x1, %r13d
je 0x2c87
movq %r15, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x201f
decl %r13d
jmp 0x2c63
xorl %eax, %eax
cmpq $0x10, %rax
je 0x2ca6
movq 0x410(%rsp,%rax,8), %rcx
movq %rcx, 0x10(%rsp,%rax,8)
incq %rax
jmp 0x2c8e
leaq 0x10(%rsp), %rbp
leaq 0x90(%rsp), %rdx
movq %rbp, %rdi
movq %rbp, %rsi
callq 0x201f
leaq 0x110(%rsp), %r15
movq %rbp, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x201f
movq %rbp, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x201f
leaq 0x210(%rsp), %r13
movq %r13, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x201f
leaq 0x190(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
callq 0x201a
movq %rbp, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x201f
movq %rbp, %rdi
leaq 0x90(%rsp), %rsi
callq 0x31c9
testl %eax, %eax
je 0x2d44
leaq 0x1a6c(%rip), %rdx      # 0x47a0
leaq 0x210(%rsp), %rdi
movq %rdi, %rsi
callq 0x201f
leaq 0x190(%rsp), %r15
leaq 0x210(%rsp), %rsi
movq %r15, %rdi
callq 0x201a
leaq 0x110(%rsp), %rdx
movq %r15, %rdi
movq %r15, %rsi
callq 0x201f
leaq 0x90(%rsp), %rsi
movq %r15, %rdi
callq 0x31c9
testl %eax, %eax
je 0x2d98
pushq $-0x1
popq %rax
addq $0x798, %rsp            # imm = 0x798
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x210(%rsp), %rdi
callq 0x31ac
movq 0x8(%rsp), %r15
movb 0x1f(%r15), %cl
shrb $0x7, %cl
cmpb %cl, %al
jne 0x2dcc
leaq 0x1a64(%rip), %rsi      # 0x4820
leaq 0x210(%rsp), %rdi
movq %rdi, %rdx
callq 0x2000
leaq 0x390(%rsp), %rdi
leaq 0x210(%rsp), %rsi
leaq 0x290(%rsp), %rdx
callq 0x201f
xorl %eax, %eax
cmpq %rax, %rbx
je 0x2dfd
movb (%r12,%rax), %cl
movb %cl, (%r14,%rax)
incq %rax
jmp 0x2deb
pushq $0x20
popq %rax
cmpq $0x40, %rax
je 0x2e14
movb -0x20(%r15,%rax), %cl
movb %cl, (%r14,%rax)
incq %rax
jmp 0x2e00
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x25e7
movq %r15, %rdi
callq 0x29e9
leaq 0x410(%rsp), %r13
leaq 0x210(%rsp), %rbp
movq %r13, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x2ec3
leaq 0x20(%r12), %rsi
movq %rbp, %rdi
callq 0x2759
movq %r13, %rdi
movq %rbp, %rsi
callq 0x2f82
leaq 0x190(%rsp), %r15
movq %r15, %rdi
movq %r13, %rsi
callq 0x27e1
addq $-0x40, %rbx
movq %r12, %rdi
movq %r15, %rsi
callq 0x1548
testl %eax, %eax
je 0x2ea0
xorl %eax, %eax
cmpq %rax, %rbx
je 0x2d83
movb $0x0, (%r14,%rax)
incq %rax
jmp 0x2e8d
xorl %eax, %eax
movq (%rsp), %rdx
cmpq %rax, %rbx
je 0x2eb9
movb 0x40(%r12,%rax), %cl
movb %cl, (%r14,%rax)
incq %rax
jmp 0x2ea6
movq %rbx, (%rdx)
xorl %eax, %eax
jmp 0x2d86