// File: /workspace/github_c_makefile_star2_O3/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:
movq $-0x1, (%rsi)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq $0x40, %rcx
jb 0x32c6
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x918, %rsp            # imm = 0x918
movq %r8, %r13
movq %rdx, %r12
movq %rdi, %r14
movq %rsi, 0x8(%rsp)
movq %rcx, (%rsp)
leaq 0x290(%rsp), %rdi
leaq 0x1536(%rip), %rsi      # 0x45a0
movl $0x10, %ecx
rep  movsq (%rsi), %es:(%rdi)
leaq 0x210(%rsp), %rsi
xorl %eax, %eax
movzwl (%r13,%rax,2), %ecx
movq %rcx, 0x210(%rsp,%rax,8)
incq %rax
cmpq $0x10, %rax
jne 0x307c
andq $0x7fff, 0x288(%rsp) # imm = 0x7FFF
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movq %rsi, %rdx
callq 0x2393
leaq 0x166a(%rip), %rdx      # 0x4720
leaq 0x90(%rsp), %rdi
movq %r15, %rsi
callq 0x2393
xorl %eax, %eax
movdqa 0x10(%rsp,%rax,8), %xmm0
psubq 0x290(%rsp,%rax,8), %xmm0
movdqa %xmm0, 0x10(%rsp,%rax,8)
addq $0x2, %rax
cmpq $0x10, %rax
jne 0x30c8
xorl %eax, %eax
movdqa 0x90(%rsp,%rax,8), %xmm0
paddq 0x290(%rsp,%rax,8), %xmm0
movdqa %xmm0, 0x90(%rsp,%rax,8)
addq $0x2, %rax
cmpq $0x10, %rax
jne 0x30e9
leaq 0x690(%rsp), %rbp
leaq 0x90(%rsp), %rbx
movq %rbp, %rdi
movq %rbx, %rsi
movq %rbx, %rdx
callq 0x2393
leaq 0x610(%rsp), %r15
movq %r15, %rdi
movq %rbp, %rsi
movq %rbp, %rdx
callq 0x2393
leaq 0x590(%rsp), %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x2393
leaq 0x710(%rsp), %rbp
leaq 0x10(%rsp), %rdx
movq %rbp, %rdi
leaq 0x590(%rsp), %rsi
callq 0x2393
movq %rbp, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x2393
leaq 0x390(%rsp), %r15
movl $0x10, %ecx
movq %r15, %rdi
movq %rbp, %rsi
rep  movsq (%rsi), %es:(%rdi)
movl $0xfb, %ebx
movq %r15, %rdi
movq %r15, %rsi
movq %r15, %rdx
callq 0x2393
cmpl $0x2, %ebx
je 0x31bc
movq %r15, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x2393
decl %ebx
jne 0x319b
leaq 0x710(%rsp), %r15
leaq 0x390(%rsp), %rsi
movl $0x10, %ecx
movq %r15, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x10(%rsp), %rdx
movq %r15, %rdi
movq %r15, %rsi
callq 0x2393
leaq 0x90(%rsp), %rbp
movq %r15, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x2393
movq %r15, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x2393
leaq 0x190(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x2393
leaq 0x110(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
movq %rbx, %rdx
callq 0x2393
movq %r15, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x2393
movq %r15, %rdi
leaq 0x10(%rsp), %rsi
callq 0x38c2
testl %eax, %eax
je 0x3271
leaq 0x153f(%rip), %rdx      # 0x47a0
leaq 0x190(%rsp), %rdi
movq %rdi, %rsi
callq 0x2393
leaq 0x110(%rsp), %rbx
leaq 0x190(%rsp), %rdx
movq %rbx, %rdi
movq %rdx, %rsi
callq 0x2393
leaq 0x90(%rsp), %rdx
movq %rbx, %rdi
movq %rbx, %rsi
callq 0x2393
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x38c2
testl %eax, %eax
je 0x32c7
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x918, %rsp            # imm = 0x918
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x390(%rsp), %rbx
leaq 0x190(%rsp), %rsi
movq %rbx, %rdi
callq 0x24dd
movb (%rbx), %al
andb $0x1, %al
movb 0x1f(%r13), %cl
shrb $0x7, %cl
cmpb %cl, %al
jne 0x3310
xorl %eax, %eax
pxor %xmm0, %xmm0
psubq 0x190(%rsp,%rax,8), %xmm0
movdqa %xmm0, 0x190(%rsp,%rax,8)
addq $0x2, %rax
cmpq $0x10, %rax
jne 0x32f0
leaq 0x310(%rsp), %rdi
leaq 0x190(%rsp), %rsi
leaq 0x210(%rsp), %rdx
callq 0x2393
xorl %eax, %eax
movq (%rsp), %rdx
movb (%r12,%rax), %cl
movb %cl, (%r14,%rax)
incq %rax
cmpq %rax, %rdx
jne 0x3333
xorl %eax, %eax
movb (%r13,%rax), %cl
movb %cl, 0x20(%r14,%rax)
incq %rax
cmpq $0x20, %rax
jne 0x3345
leaq 0x110(%rsp), %rdi
movq %r14, %rsi
callq 0x29ed
xorl %eax, %eax
movzbl 0x110(%rsp,%rax), %ecx
movq %rcx, 0x390(%rsp,%rax,8)
incq %rax
cmpq $0x40, %rax
jne 0x336a
pxor %xmm0, %xmm0
leaq 0x110(%rsp), %rbx
movdqa %xmm0, 0x30(%rbx)
movdqa %xmm0, 0x20(%rbx)
movdqa %xmm0, 0x10(%rbx)
movdqa %xmm0, (%rbx)
leaq 0x390(%rsp), %rsi
movq %rbx, %rdi
callq 0x2eeb
leaq 0x710(%rsp), %r13
leaq 0x190(%rsp), %rbp
movq %r13, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x34f0
leaq 0x20(%r12), %rbx
leaq 0x10c4(%rip), %rax      # 0x44a0
leaq 0x390(%rsp), %r15
movl $0x10, %ecx
movq %r15, %rdi
movq %rax, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x410(%rsp), %rdi
leaq 0x111f(%rip), %rdx      # 0x4520
movl $0x10, %ecx
movq %rdx, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x490(%rsp), %rdi
leaq 0x1185(%rip), %rsi      # 0x45a0
movl $0x10, %ecx
rep  movsq (%rsi), %es:(%rdi)
leaq 0x510(%rsp), %rdi
movq %rax, %rsi
callq 0x2393
movq %rbp, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x34f0
movq %r13, %rdi
movq %rbp, %rsi
callq 0x3603
leaq 0x390(%rsp), %rdi
movq %r13, %rsi
callq 0x2bde
pxor %xmm2, %xmm2
xorl %eax, %eax
pxor %xmm0, %xmm0
movl 0x390(%rsp,%rax), %ecx
xorl (%r12,%rax), %ecx
movd %ecx, %xmm1
punpcklbw %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1],xmm1[2],xmm2[2],xmm1[3],xmm2[3],xmm1[4],xmm2[4],xmm1[5],xmm2[5],xmm1[6],xmm2[6],xmm1[7],xmm2[7]
punpcklwd %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1],xmm1[2],xmm2[2],xmm1[3],xmm2[3]
por %xmm1, %xmm0
addq $0x4, %rax
cmpq $0x20, %rax
jne 0x3466
pshufd $0xee, %xmm0, %xmm1     # xmm1 = xmm0[2,3,2,3]
por %xmm0, %xmm1
pshufd $0x55, %xmm1, %xmm0     # xmm0 = xmm1[1,1,1,1]
por %xmm1, %xmm0
movd %xmm0, %eax
movq (%rsp), %rdx
addq $-0x40, %rdx
decl %eax
btl $0x8, %eax
jb 0x34c9
testq %rdx, %rdx
je 0x32b0
movq %r14, %rdi
xorl %esi, %esi
callq 0x1060
jmp 0x32b0
testq %rdx, %rdx
je 0x34e1
xorl %eax, %eax
movb 0x40(%r12,%rax), %cl
movb %cl, (%r14,%rax)
incq %rax
cmpq %rax, %rdx
jne 0x34d0
movq 0x8(%rsp), %rax
movq %rdx, (%rax)
xorl %eax, %eax
jmp 0x32b5