// File: /workspace/github_cpp_makefile_star2_O1/msotoodeh[P]asymmetric-passwords/common/curve25519/curve25519_mehdi.c
// Function: ecp_WordMulAddReduce
void ecp_WordMulAddReduce(U32 *Z, const U32* Y, U32 b, const U32* X) 
{
    M64 c;
    ECP_MULADD_W0(Z[0], Y[0], b, X[0]);
    ECP_MULADD_W1(Z[1], Y[1], b, X[1]);
    ECP_MULADD_W1(Z[2], Y[2], b, X[2]);
    ECP_MULADD_W1(Z[3], Y[3], b, X[3]);
    ECP_MULADD_W1(Z[4], Y[4], b, X[4]);
    ECP_MULADD_W1(Z[5], Y[5], b, X[5]);
    ECP_MULADD_W1(Z[6], Y[6], b, X[6]);
    ECP_MULADD_W1(Z[7], Y[7], b, X[7]);

    /* Z += c.u32.hi * 38 */
    ECP_MULADD_W0(Z[0], Z[0], c.u32.hi, 38);
    ECP_ADD_C1(Z[1], Z[1]);
    ECP_ADD_C1(Z[2], Z[2]);
    ECP_ADD_C1(Z[3], Z[3]);
    ECP_ADD_C1(Z[4], Z[4]);
    ECP_ADD_C1(Z[5], Z[5]);
    ECP_ADD_C1(Z[6], Z[6]);
    ECP_ADD_C1(Z[7], Z[7]);

    /* One more time at most */
    ECP_MULADD_W0(Z[0], Z[0], c.u32.hi, 38);
    ECP_ADD_C1(Z[1], Z[1]);
    ECP_ADD_C1(Z[2], Z[2]);
    ECP_ADD_C1(Z[3], Z[3]);
    ECP_ADD_C1(Z[4], Z[4]);
    ECP_ADD_C1(Z[5], Z[5]);
    ECP_ADD_C1(Z[6], Z[6]);
    ECP_ADD_C1(Z[7], Z[7]);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edx, %eax
movl (%rcx), %edx
imulq %rax, %rdx
movl (%rsi), %r8d
addq %rdx, %r8
movl %r8d, (%rdi)
movl %r8d, %edx
shrq $0x20, %r8
movl 0x4(%rcx), %r9d
imulq %rax, %r9
movl 0x4(%rsi), %r10d
addq %r9, %r10
addq %r8, %r10
movl %r10d, 0x4(%rdi)
movl %r10d, %r8d
shrq $0x20, %r10
movl 0x8(%rcx), %r9d
imulq %rax, %r9
movl 0x8(%rsi), %r11d
addq %r9, %r11
addq %r10, %r11
movl %r11d, 0x8(%rdi)
movl %r11d, %r9d
shrq $0x20, %r11
movl 0xc(%rcx), %r10d
imulq %rax, %r10
movl 0xc(%rsi), %ebx
addq %r10, %rbx
addq %r11, %rbx
movl %ebx, 0xc(%rdi)
movl %ebx, %r10d
shrq $0x20, %rbx
movl 0x10(%rcx), %r11d
imulq %rax, %r11
movl 0x10(%rsi), %r14d
addq %r11, %r14
addq %rbx, %r14
movl %r14d, 0x10(%rdi)
movl %r14d, %r11d
shrq $0x20, %r14
movl 0x14(%rcx), %ebx
imulq %rax, %rbx
movl 0x14(%rsi), %r15d
addq %rbx, %r15
addq %r14, %r15
movl %r15d, 0x14(%rdi)
movl %r15d, %ebx
shrq $0x20, %r15
movl 0x18(%rcx), %r14d
imulq %rax, %r14
movl 0x18(%rsi), %r12d
addq %r14, %r12
addq %r15, %r12
movl %r12d, 0x18(%rdi)
movl %r12d, %r14d
shrq $0x20, %r12
movl 0x1c(%rcx), %ecx
imulq %rax, %rcx
movl 0x1c(%rsi), %esi
addq %rcx, %rsi
addq %r12, %rsi
movl %esi, %eax
shrq $0x20, %rsi
imulq $0x26, %rsi, %rcx
addq %rcx, %rdx
movl %edx, %ecx
shrq $0x20, %rdx
addq %rdx, %r8
movl %r8d, %edx
shrq $0x20, %r8
addq %r8, %r9
movl %r9d, %esi
shrq $0x20, %r9
addq %r9, %r10
movl %r10d, %r8d
shrq $0x20, %r10
addq %r10, %r11
movl %r11d, %r9d
shrq $0x20, %r11
addq %r11, %rbx
movl %ebx, %r10d
shrq $0x20, %rbx
addq %rbx, %r14
movl %r14d, %r11d
shrq $0x20, %r14
addq %r14, %rax
movq %rax, %rbx
shrq $0x20, %rbx
imulq $0x26, %rbx, %rbx
addq %rbx, %rcx
movl %ecx, (%rdi)
shrq $0x20, %rcx
addq %rcx, %rdx
movl %edx, 0x4(%rdi)
shrq $0x20, %rdx
addq %rdx, %rsi
movl %esi, 0x8(%rdi)
shrq $0x20, %rsi
addq %rsi, %r8
movl %r8d, 0xc(%rdi)
shrq $0x20, %r8
addq %r8, %r9
movl %r9d, 0x10(%rdi)
shrq $0x20, %r9
addq %r9, %r10
movl %r10d, 0x14(%rdi)
shrq $0x20, %r10
addq %r10, %r11
movl %r11d, 0x18(%rdi)
shrq $0x20, %r11
addl %eax, %r11d
movl %r11d, 0x1c(%rdi)
popq %rbx
popq %r12
popq %r14
popq %r15
retq