// File: /workspace/github_cpp_makefile_star2_O1/msotoodeh[P]asymmetric-passwords/common/curve25519/ed25519_verify.c
// Function: ed25519_Verify_Init
void * ed25519_Verify_Init(
    void *context,                      /* IO: null or context buffer to use */
    const unsigned char *publicKey)     /* IN: [32 bytes] public key */
{
    int i;
    Ext_POINT Q, T;
    EDP_SIGV_CTX *ctx = (EDP_SIGV_CTX*)context;

    if (ctx == 0) ctx = (EDP_SIGV_CTX*)mem_alloc(sizeof(EDP_SIGV_CTX));

    if (ctx)
    {
        memcpy(ctx->pk, publicKey, 32);
        i = ecp_DecodeInt(Q.y, publicKey);
        ed25519_CalculateX(Q.x, Q.y, ~i);       /* Invert parity for -Q */
        ecp_MulMod(Q.t, Q.x, Q.y);
        ecp_SetValue(Q.z, 1);

        /* pre-compute q-table */

        /* Calculate: Q0=Q, Q1=(2^64)*Q, Q2=(2^128)*Q, Q3=(2^192)*Q */

        ecp_SetValue(ctx->q_table[0].YpX, 1);           /* -- -- -- -- */
        ecp_SetValue(ctx->q_table[0].YmX, 1);
        ecp_SetValue(ctx->q_table[0].T2d, 0);
        ecp_SetValue(ctx->q_table[0].Z2, 2);

        edp_ExtPoint2PE(&ctx->q_table[1], &Q);          /* -- -- -- q0 */

        for (i = 0; i < 64; i++) edp_DoublePoint(&Q);

        edp_ExtPoint2PE(&ctx->q_table[2], &Q);          /* -- -- q1 -- */
        QTABLE_SET(3,1);                                /* -- -- q1 q0 */

        do edp_DoublePoint(&Q); while (++i < 128);

        edp_ExtPoint2PE(&ctx->q_table[4], &Q);          /* -- q2 -- -- */
        QTABLE_SET(5, 1);                               /* -- q2 -- q0 */
        QTABLE_SET(6, 2);                               /* -- q2 q1 -- */
        QTABLE_SET(7, 3);                               /* -- q2 q1 q0 */

        do edp_DoublePoint(&Q); while (++i < 192);

        edp_ExtPoint2PE(&ctx->q_table[8], &Q);          /* q3 -- -- -- */
        QTABLE_SET(9, 1);                               /* q3 -- -- q0 */
        QTABLE_SET(10, 2);                              /* q3 -- q1 -- */
        QTABLE_SET(11, 3);                              /* q3 -- q1 q0 */
        QTABLE_SET(12, 4);                              /* q3 q2 -- -- */
        QTABLE_SET(13, 5);                              /* q3 q2 -- q0 */
        QTABLE_SET(14, 6);                              /* q3 q2 q1 -- */
        QTABLE_SET(15, 7);                              /* q3 q2 q1 q0 */
    }
    return ctx;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %rsi, %r14
movq %rdi, %rbx
testq %rdi, %rdi
jne 0x407e42
movl $0x820, %edi            # imm = 0x820
callq 0x4e6a50
movq %rax, %rbx
testq %rbx, %rbx
je 0x4080d4
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups %xmm1, 0x10(%rbx)
movups %xmm0, (%rbx)
leaq 0x48(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x40ac4f
movzbl %al, %edx
notl %edx
leaq 0x28(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x407978
leaq 0x88(%rsp), %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x40a62d
leaq 0x68(%rsp), %rdi
movl $0x1, %esi
callq 0x409da4
leaq 0x20(%rbx), %rdi
movl $0x1, %esi
callq 0x409da4
leaq 0x40(%rbx), %rdi
movl $0x1, %esi
callq 0x409da4
leaq 0x60(%rbx), %rdi
xorl %esi, %esi
callq 0x409da4
leaq 0x80(%rbx), %rdi
movl $0x2, %esi
callq 0x409da4
leaq 0xa0(%rbx), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x407587
movl $0x40, %ebp
movq %r15, %rdi
callq 0x4072d2
decl %ebp
jne 0x407ef1
leaq 0x120(%rbx), %r15
leaq 0x28(%rsp), %r13
movq %r15, %rdi
movq %r13, %rsi
callq 0x407587
leaq 0xa8(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x407cb6
leaq 0x1a0(%rbx), %r12
movq %r12, %rdi
movq %rbp, %rsi
callq 0x407587
movl $0x40, %ebp
movq %r13, %rdi
callq 0x4072d2
decl %ebp
jne 0x407f41
leaq 0x220(%rbx), %rdi
leaq 0x28(%rsp), %r13
movq %rdi, 0x20(%rsp)
movq %r13, %rsi
callq 0x407587
leaq 0xa8(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x407cb6
leaq 0x2a0(%rbx), %rdi
movq %rdi, 0x18(%rsp)
movq %rbp, %rsi
callq 0x407587
movq %rbp, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x407cb6
leaq 0x320(%rbx), %rdi
movq %rdi, 0x10(%rsp)
movq %rbp, %rsi
callq 0x407587
movq %rbp, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x407cb6
leaq 0x3a0(%rbx), %rdi
movq %rdi, 0x8(%rsp)
movq %rbp, %rsi
callq 0x407587
movl $0x40, %ebp
movq %r13, %rdi
callq 0x4072d2
decl %ebp
jne 0x407fd9
leaq 0x420(%rbx), %rdi
leaq 0x28(%rsp), %rbp
movq %rbp, %rsi
callq 0x407587
leaq 0xa8(%rsp), %r13
movq %r13, %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x407cb6
leaq 0x4a0(%rbx), %rdi
movq %r13, %rsi
callq 0x407587
movq %r13, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x407cb6
leaq 0x520(%rbx), %rdi
movq %r13, %rsi
callq 0x407587
movq %r13, %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x407cb6
leaq 0x5a0(%rbx), %rdi
movq %r13, %rsi
callq 0x407587
movq %r13, %rdi
movq %rbp, %rsi
movq 0x20(%rsp), %rdx
callq 0x407cb6
leaq 0x620(%rbx), %rdi
movq %r13, %rsi
callq 0x407587
movq %r13, %rdi
movq %rbp, %rsi
movq 0x18(%rsp), %rdx
callq 0x407cb6
leaq 0x6a0(%rbx), %rdi
movq %r13, %rsi
callq 0x407587
movq %r13, %rdi
movq %rbp, %rsi
movq 0x10(%rsp), %rdx
callq 0x407cb6
leaq 0x720(%rbx), %rdi
movq %r13, %rsi
callq 0x407587
movq %r13, %rdi
movq %rbp, %rsi
movq 0x8(%rsp), %rdx
callq 0x407cb6
leaq 0x7a0(%rbx), %rdi
movq %r13, %rsi
callq 0x407587
movq %rbx, %rax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq