// File: simap[P]ecctools/lib/uECC.c
// Function: uECC_vli_mult(unsigned long*, unsigned long const*, unsigned long const*, signed char)
uECC_VLI_API void uECC_vli_mult(uECC_word_t *result,
                                const uECC_word_t *left,
                                const uECC_word_t *right,
                                wordcount_t num_words) {
    uECC_word_t r0 = 0;
    uECC_word_t r1 = 0;
    uECC_word_t r2 = 0;
    wordcount_t i, k;

    /* Compute each digit of result in sequence, maintaining the carries. */
    for (k = 0; k < num_words; ++k) {
        for (i = 0; i <= k; ++i) {
            muladd(left[i], right[k - i], &r0, &r1, &r2);
        }
        result[k] = r0;
        r0 = r1;
        r1 = r2;
        r2 = 0;
    }
    for (k = num_words; k < num_words * 2 - 1; ++k) {
        for (i = (k + 1) - num_words; i < num_words; ++i) {
            muladd(left[i], right[k - i], &r0, &r1, &r2);
        }
        result[k] = r0;
        r0 = r1;
        r1 = r2;
        r2 = 0;
    }
    result[num_words * 2 - 1] = r0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movb %cl, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movb %al, -0x19(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movb $0x0, -0x3a(%rbp)
movsbl -0x3a(%rbp), %eax
movsbl -0x19(%rbp), %ecx
cmpl %ecx, %eax
jge 0x61d8
movb $0x0, -0x39(%rbp)
movsbl -0x39(%rbp), %eax
movsbl -0x3a(%rbp), %ecx
cmpl %ecx, %eax
jg 0x61a2
movq -0x10(%rbp), %rax
movsbq -0x39(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x18(%rbp), %rax
movsbl -0x3a(%rbp), %ecx
movsbl -0x39(%rbp), %edx
subl %edx, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
leaq -0x28(%rbp), %rdx
leaq -0x30(%rbp), %rcx
leaq -0x38(%rbp), %r8
callq 0x5ca0
movb -0x39(%rbp), %al
addb $0x1, %al
movb %al, -0x39(%rbp)
jmp 0x6159
movq -0x28(%rbp), %rdx
movq -0x8(%rbp), %rax
movsbq -0x3a(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x30(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movb -0x3a(%rbp), %al
addb $0x1, %al
movb %al, -0x3a(%rbp)
jmp 0x6145
movb -0x19(%rbp), %al
movb %al, -0x3a(%rbp)
movsbl -0x3a(%rbp), %eax
movsbl -0x19(%rbp), %ecx
shll %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x6282
movsbl -0x3a(%rbp), %eax
addl $0x1, %eax
movsbl -0x19(%rbp), %ecx
subl %ecx, %eax
movb %al, -0x39(%rbp)
movsbl -0x39(%rbp), %eax
movsbl -0x19(%rbp), %ecx
cmpl %ecx, %eax
jge 0x624c
movq -0x10(%rbp), %rax
movsbq -0x39(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x18(%rbp), %rax
movsbl -0x3a(%rbp), %ecx
movsbl -0x39(%rbp), %edx
subl %edx, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
leaq -0x28(%rbp), %rdx
leaq -0x30(%rbp), %rcx
leaq -0x38(%rbp), %r8
callq 0x5ca0
movb -0x39(%rbp), %al
addb $0x1, %al
movb %al, -0x39(%rbp)
jmp 0x6203
movq -0x28(%rbp), %rdx
movq -0x8(%rbp), %rax
movsbq -0x3a(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x30(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movb -0x3a(%rbp), %al
addb $0x1, %al
movb %al, -0x3a(%rbp)
jmp 0x61de
movq -0x28(%rbp), %rdx
movq -0x8(%rbp), %rax
movsbl -0x19(%rbp), %ecx
shll %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
addq $0x40, %rsp
popq %rbp
retq