// File: /workspace/github_cpp_makefile_star2_O2/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, %r15
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r13
leaq 0x1b0(%rsp), %rbp
movq %rbp, %rdi
callq 0x407abc
pushq $0x20
popq %r14
movq %rbp, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x409252
movq %rbp, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x409252
movq %rbp, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x409252
leaq 0xf0(%rsp), %r15
movq %r15, %rdi
movq %rbp, %rsi
callq 0x407b44
leaq 0x150(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x40a1f3
movq %r12, %rdi
callq 0x40a19c
movq %rbx, 0x8(%rsp)
leaq 0x20(%rbx), %rsi
leaq 0x130(%rsp), %r15
movq %r15, %rdi
callq 0x40a2d7
leaq 0x20(%r13), %rbx
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x40a3ef
leaq 0xb0(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x40a38a
movzbl (%r15), %r12d
shll $0x7, %r12d
movq %r13, %rax
movq %r13, (%rsp)
addq %r12, %r13
addq $0x20, %r13
leaq 0x40(%rax,%r12), %r15
leaq 0x30(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x4096e8
leaq 0x50(%rsp), %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x409628
leaq 0x90(%rsp), %rdi
movq (%rsp), %r15
leaq (%r15,%r12), %rsi
addq $0x60, %rsi
movq $0x579780, %rdx         # imm = 0x579780
callq 0x4099e0
leaq 0x70(%rsp), %r13
leaq (%r15,%r12), %rsi
addq $0x80, %rsi
movq %r13, %rdi
callq 0x4094a2
pushq $0x1
popq %r15
movq %rbp, %rdi
callq 0x406ac6
movzbl 0xb0(%rsp,%r15), %edx
shll $0x7, %edx
addq %rbx, %rdx
movq %rbp, %rdi
movq %rbp, %rsi
callq 0x407457
incq %r15
cmpq $0x20, %r15
jne 0x4079c3
leaq 0x30(%rsp), %r12
movq $0x5797a0, %r15         # imm = 0x5797A0
movq %r12, %rdi
callq 0x406ac6
movzbl -0x10(%rsp,%r14), %eax
imulq $0x60, %rax, %rsi
addq %r15, %rsi
movq %r12, %rdi
callq 0x4069a1
movzbl 0xb0(%rsp,%r14), %edx
shll $0x7, %edx
addq %rbx, %rdx
movq %r12, %rdi
movq %r12, %rsi
callq 0x407457
incq %r14
cmpq $0x40, %r14
jne 0x4079fa
movq %r13, %rdi
movq %r13, %rsi
callq 0x409d2b
leaq 0x170(%rsp), %rdi
leaq 0x30(%rsp), %rsi
movq %r13, %rdx
callq 0x409d19
leaq 0x190(%rsp), %r14
movq %r14, %rdi
leaq 0x50(%rsp), %rsi
movq %r13, %rdx
callq 0x409d19
movl -0x20(%r14), %edx
andl $0x1, %edx
leaq 0xf0(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x40a306
pushq $0x20
popq %rdx
movq %r15, %rdi
movq 0x8(%rsp), %rsi
callq 0x401098
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
movl %ecx, %eax
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq