// File: /workspace/github_cpp_makefile_star2_O3/msotoodeh[P]asymmetric-passwords/common/curve25519/ed25519_verify.c
// Function: ed25519_Verify_Check
int ed25519_Verify_Check(
    const void  *context,                       /* IN: precomputes */
    const unsigned char *signature,             /* IN: signature (R,S) */
    const unsigned char *msg, size_t msg_size)  /* IN: message to sign */
{
    SHA512_CTX H;
    Affine_POINT T;
    U_WORD h[K_WORDS], s[K_WORDS];
    U8 md[SHA512_DIGEST_LENGTH];

    /* h = H(enc(R) + pk + m)  mod BPO */
    SHA512_Init(&H);
    SHA512_Update(&H, signature, 32);       /* enc(R) */
    SHA512_Update(&H, ((EDP_SIGV_CTX*)context)->pk, 32);
    SHA512_Update(&H, msg, msg_size);
    SHA512_Final(md, &H);
    eco_DigestToWords(h, md);
    eco_Mod(h);

    /* T = s*P + h*(-Q) = (s - h*a)*P = r*P = R */

    ecp_BytesToWords(s, signature+32);
    edp_PolyPointMultiply(&T, s, h, ((EDP_SIGV_CTX*)context)->q_table);
    ed25519_PackPoint(md, T.y, T.x[0]);

    return (memcmp(md, signature, 32) == 0) ? 1 : 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x288, %rsp            # imm = 0x288
movq %rcx, %r14
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r15
leaq 0x1b0(%rsp), %r13
movq %r13, %rdi
callq 0x40827c
movl $0x20, %edx
movq %r13, %rdi
movq %rbx, %rsi
callq 0x409a57
movl $0x20, %edx
movq %r13, %rdi
movq %r15, %rsi
callq 0x409a57
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x409a57
leaq 0xf0(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0x408304
leaq 0x150(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x40aa42
movq %r12, %rdi
callq 0x40a9eb
movq %rbx, 0x8(%rsp)
leaq 0x20(%rbx), %rsi
leaq 0x130(%rsp), %r14
movq %r14, %rdi
callq 0x40ab25
leaq 0x20(%r15), %rbx
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x40ac3a
leaq 0xb0(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0x40abdf
movzbl (%r14), %r14d
shll $0x7, %r14d
leaq (%r15,%r14), %r12
addq $0x20, %r12
leaq 0x40(%r15,%r14), %rbp
leaq 0x30(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
movq %rbp, %rdx
callq 0x409f40
leaq 0x50(%rsp), %rdi
movq %r12, %rsi
movq %rbp, %rdx
callq 0x409e80
leaq 0x90(%rsp), %rdi
leaq (%r15,%r14), %rsi
addq $0x60, %rsi
movq $0x57a7b0, %rdx         # imm = 0x57A7B0
callq 0x40a238
leaq 0x70(%rsp), %r12
leaq (%r15,%r14), %rsi
addq $0x80, %rsi
movq %r12, %rdi
callq 0x409cfa
movl $0x1, %r15d
movq %r13, %rdi
callq 0x407236
movzbl 0xb0(%rsp,%r15), %edx
shll $0x7, %edx
addq %rbx, %rdx
movq %r13, %rdi
movq %r13, %rsi
callq 0x407bf6
incq %r15
cmpq $0x20, %r15
jne 0x408165
movl $0x20, %r13d
leaq 0x30(%rsp), %r15
movq $0x57a7d0, %rbp         # imm = 0x57A7D0
movq %r15, %rdi
callq 0x407236
movzbl -0x10(%rsp,%r13), %eax
leaq (%rax,%rax,2), %rsi
shll $0x5, %esi
addq %rbp, %rsi
movq %r15, %rdi
callq 0x407111
movzbl 0xb0(%rsp,%r13), %edx
shll $0x7, %edx
addq %rbx, %rdx
movq %r15, %rdi
movq %r15, %rsi
callq 0x407bf6
incq %r13
cmpq $0x40, %r13
jne 0x4081a2
movq %r12, %rdi
movq %r12, %rsi
callq 0x40a587
leaq 0x170(%rsp), %rdi
leaq 0x30(%rsp), %rsi
movq %r12, %rdx
callq 0x40a575
leaq 0x190(%rsp), %r15
movq %r15, %rdi
leaq 0x50(%rsp), %rsi
movq %r12, %rdx
callq 0x40a575
movl -0x20(%r15), %edx
andl $0x1, %edx
leaq 0xf0(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x40ab57
movq 0x8(%rsp), %rax
movdqu (%rax), %xmm0
movdqu 0x10(%rax), %xmm1
pcmpeqb 0x10(%r14), %xmm1
pcmpeqb (%r14), %xmm0
pand %xmm1, %xmm0
pmovmskb %xmm0, %ecx
xorl %eax, %eax
cmpl $0xffff, %ecx           # imm = 0xFFFF
sete %al
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq