// File: /workspace/github_cpp_makefile_star2_O2/simap[P]ecctools/lib/uECC.c
// Function: XYcZ_addC(unsigned long*, unsigned long*, unsigned long*, unsigned long*, uECC_Curve_t const*)
static void XYcZ_addC(uECC_word_t * X1,
                      uECC_word_t * Y1,
                      uECC_word_t * X2,
                      uECC_word_t * Y2,
                      uECC_Curve curve) {
    /* t1 = X1, t2 = Y1, t3 = X2, t4 = Y2 */
    uECC_word_t t5[uECC_MAX_WORDS];
    uECC_word_t t6[uECC_MAX_WORDS];
    uECC_word_t t7[uECC_MAX_WORDS];
    wordcount_t num_words = curve->num_words;

    uECC_vli_modSub(t5, X2, X1, curve->p, num_words); /* t5 = x2 - x1 */
    uECC_vli_modSquare_fast(t5, t5, curve);                  /* t5 = (x2 - x1)^2 = A */
    uECC_vli_modMult_fast(X1, X1, t5, curve);                /* t1 = x1*A = B */
    uECC_vli_modMult_fast(X2, X2, t5, curve);                /* t3 = x2*A = C */
    uECC_vli_modAdd(t5, Y2, Y1, curve->p, num_words); /* t5 = y2 + y1 */
    uECC_vli_modSub(Y2, Y2, Y1, curve->p, num_words); /* t4 = y2 - y1 */

    uECC_vli_modSub(t6, X2, X1, curve->p, num_words); /* t6 = C - B */
    uECC_vli_modMult_fast(Y1, Y1, t6, curve);                /* t2 = y1 * (C - B) = E */
    uECC_vli_modAdd(t6, X1, X2, curve->p, num_words); /* t6 = B + C */
    uECC_vli_modSquare_fast(X2, Y2, curve);                  /* t3 = (y2 - y1)^2 = D */
    uECC_vli_modSub(X2, X2, t6, curve->p, num_words); /* t3 = D - (B + C) = x3 */

    uECC_vli_modSub(t7, X1, X2, curve->p, num_words); /* t7 = B - x3 */
    uECC_vli_modMult_fast(Y2, Y2, t7, curve);                /* t4 = (y2 - y1)*(B - x3) */
    uECC_vli_modSub(Y2, Y2, Y1, curve->p, num_words); /* t4 = (y2 - y1)*(B - x3) - E = y3 */

    uECC_vli_modSquare_fast(t7, t5, curve);                  /* t7 = (y2 + y1)^2 = F */
    uECC_vli_modSub(t7, t7, t6, curve->p, num_words); /* t7 = F - (B + C) = x3' */
    uECC_vli_modSub(t6, t7, X1, curve->p, num_words); /* t6 = x3' - B */
    uECC_vli_modMult_fast(t6, t6, t5, curve);                /* t6 = (y2+y1)*(x3' - B) */
    uECC_vli_modSub(Y1, t6, Y1, curve->p, num_words); /* t2 = (y2+y1)*(x3' - B) - E = y3' */

    uECC_vli_set(X1, t7, num_words);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %r8, %r13
movq %rcx, %rbp
movq %rdx, %r15
movq %rsi, (%rsp)
movq %rdi, %r14
movsbl (%r8), %ebx
leaq 0x8(%r8), %r12
leaq 0x10(%rsp), %rdi
movq %rdx, %rsi
movq %r14, %rdx
movq %r12, %rcx
movl %ebx, %r8d
callq 0x3034
leaq 0x10(%rsp), %rdi
movq %rdi, %rsi
movq %r13, %rdx
callq 0x1f4e
movq %r14, 0x8(%rsp)
movq %r14, %rdi
movq %r14, %rsi
leaq 0x10(%rsp), %rdx
movq %r13, %rcx
callq 0x328d
movq %r15, %rdi
movq %r15, %rsi
leaq 0x10(%rsp), %r14
movq %r14, %rdx
movq %r13, %rcx
callq 0x328d
movq %r14, %rdi
movq %rbp, %rsi
movq (%rsp), %r14
movq %r14, %rdx
movq %r12, %rcx
movl %ebx, %r8d
callq 0x371b
movq %rbp, %rdi
movq %rbp, %rsi
movq %r14, %rdx
movq %r12, %rcx
movl %ebx, %r8d
callq 0x3034
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
movq 0x8(%rsp), %r14
movq %r14, %rdx
movq %r12, %rcx
movl %ebx, %r8d
callq 0x3034
movq (%rsp), %rdi
movq %rdi, %rsi
leaq 0x30(%rsp), %rdx
movq %r13, %rcx
callq 0x328d
leaq 0x30(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %r12, %rcx
movl %ebx, %r8d
callq 0x371b
movq %r15, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x1f4e
movq %r15, %rdi
movq %r15, %rsi
leaq 0x30(%rsp), %rdx
movq %r12, %rcx
movl %ebx, %r8d
callq 0x3034
leaq 0x50(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %r12, %rcx
movl %ebx, %r8d
callq 0x3034
movq %rbp, %rdi
movq %rbp, %rsi
leaq 0x50(%rsp), %r14
movq %r14, %rdx
movq %r13, %rcx
callq 0x328d
movq %rbp, %rdi
movq %rbp, %rsi
movq (%rsp), %r15
movq %r15, %rdx
movq %r12, %rcx
movl %ebx, %r8d
callq 0x3034
movq %r14, %rdi
leaq 0x10(%rsp), %rsi
movq %r13, %rdx
callq 0x1f4e
movq %r14, %rdi
movq %r14, %rsi
leaq 0x30(%rsp), %rbp
movq %rbp, %rdx
movq %r12, %rcx
movl %ebx, %r8d
callq 0x3034
movq %rbp, %rdi
movq %r14, %rsi
movq 0x8(%rsp), %r14
movq %r14, %rdx
movq %r12, %rcx
movl %ebx, %r8d
callq 0x3034
movq %rbp, %rdi
movq %rbp, %rsi
leaq 0x10(%rsp), %rdx
movq %r13, %rcx
callq 0x328d
movq %r15, %rdi
movq %rbp, %rsi
movq %r15, %rdx
movq %r12, %rcx
movl %ebx, %r8d
callq 0x3034
movq %r14, %rdi
leaq 0x50(%rsp), %rsi
movl %ebx, %edx
callq 0x3017
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq