// File: /workspace/github_c_makefile_star2_O1/nh13[P]ksw/src/parasail/tests/test_verify_cigars.c
// Function: check_functions
static void check_functions(
        parasail_function_group_t f,
        parasail_sequences_t *sequences,
        unsigned long pair_limit_,
        const parasail_matrix_t *matrix_,
        gap_score_t gap)
{
    const parasail_function_info_t *functions = f.fs;
    unsigned long matrix_index = 0;
    unsigned long gap_index = 0;
    unsigned long function_index = 0;
    long long pair_index = 0;
    long long pair_limit = (long long)pair_limit_;
    parasail_function_t *reference_function = NULL;
    const parasail_matrix_t ** matrices = parasail_matrices;
    const parasail_matrix_t * single_matrix[] = {
        matrix_,
        NULL
    };

    if (NULL != matrix_) {
        matrices = single_matrix;
    }

    printf("checking %s functions\n", f.name);
    for (matrix_index=0; NULL!=matrices[matrix_index]; ++matrix_index) {
        const parasail_matrix_t *matrix = matrices[matrix_index];
        const char *matrixname = matrix->name;
        if (verbose) printf("\t%s\n", matrixname);
        for (gap_index=0; INT_MIN!=gap_scores[gap_index].open; ++gap_index) {
            int open = gap_scores[gap_index].open;
            int extend = gap_scores[gap_index].extend;
            if (gap.open != INT_MIN && gap.extend != INT_MIN) {
                open = gap.open;
                extend = gap.extend;
            }
            if (verbose) printf("\t\topen=%d extend=%d ref=%s\n", open, extend, functions[0].name);
            reference_function = functions[0].pointer;
            for (function_index=1;
                    NULL!=functions[function_index].pointer;
                    ++function_index) {
				unsigned long saturated = 0;
                if (verbose) printf("\t\t\t%s\n", functions[function_index].name);
#pragma omp parallel for
                for (pair_index=0; pair_index<pair_limit; ++pair_index) {
                    parasail_result_t *reference_result = NULL;
                    parasail_result_t *result = NULL;
                    unsigned long a = 0;
                    unsigned long b = 1;
                    parasail_cigar_t *ref_cigar = NULL;
                    parasail_cigar_t *tst_cigar = NULL;
                    char *ref_cigar_str = NULL;
                    char *tst_cigar_str = NULL;
                    size_t size_a = 0;
                    size_t size_b = 0;
                    k_combination2(pair_index, &a, &b);
                    size_a = sequences->seqs[a].seq.l;
                    size_b = sequences->seqs[b].seq.l;
                    if (verbose) printf("\t\t\t\tpair=%lld (%lu,%lu)\n", pair_index, a, b);
                    reference_result = reference_function(
                            sequences->seqs[a].seq.s, size_a,
                            sequences->seqs[b].seq.s, size_b,
                            open, extend,
                            matrix);
                    result = functions[function_index].pointer(
                            sequences->seqs[a].seq.s, size_a,
                            sequences->seqs[b].seq.s, size_b,
                            open, extend,
                            matrix);
                    if (parasail_result_is_saturated(result)) {
                        /* no point in comparing a result that saturated */
                        parasail_result_free(reference_result);
                        parasail_result_free(result);
#pragma omp atomic
                        saturated += 1;
                        continue;
                    }
                    ref_cigar = parasail_result_get_cigar(reference_result,
                            sequences->seqs[a].seq.s, size_a,
                            sequences->seqs[b].seq.s, size_b,
                            matrix);
                    if (NULL == ref_cigar) {
#pragma omp critical(printer)
                        {
                            printf("%s(%lu,%lu,%d,%d,%s) invalid ref cigar\n",
                                    functions[function_index].name,
                                    a, b, open, extend,
                                    matrixname);
                        }
                        parasail_result_free(reference_result);
                        parasail_result_free(result);
                        continue;
                    }
                    tst_cigar = parasail_result_get_cigar(result,
                            sequences->seqs[a].seq.s, size_a,
                            sequences->seqs[b].seq.s, size_b,
                            matrix);
                    if (NULL == tst_cigar) {
#pragma omp critical(printer)
                        {
                            printf("%s(%lu,%lu,%d,%d,%s) invalid test cigar\n",
                                    functions[function_index].name,
                                    a, b, open, extend,
                                    matrixname);
                        }
                        parasail_cigar_free(ref_cigar);
                        parasail_result_free(reference_result);
                        parasail_result_free(result);
                        continue;
                    }
                    ref_cigar_str = parasail_cigar_decode(ref_cigar);
                    tst_cigar_str = parasail_cigar_decode(tst_cigar);
                    if (reference_result->score != result->score) {
#pragma omp critical(printer)
                        {
                            printf("%s(%lu,%lu,%d,%d,%s) wrong score (%d!=%d)\n",
                                    functions[function_index].name,
                                    a, b, open, extend,
                                    matrixname,
                                    reference_result->score, result->score);
                        }
                    }
                    if (reference_result->end_query != result->end_query) {
#pragma omp critical(printer)
                        {
                            printf("%s(%lu,%lu,%d,%d,%s) wrong end_query (%d!=%d)\n",
                                    functions[function_index].name,
                                    a, b, open, extend,
                                    matrixname,
                                    reference_result->end_query, result->end_query);
                        }
                    }
                    if (reference_result->end_ref != result->end_ref) {
#pragma omp critical(printer)
                        {
                            printf("%s(%lu,%lu,%d,%d,%s) wrong end_ref (%d!=%d)\n",
                                    functions[function_index].name,
                                    a, b, open, extend,
                                    matrixname,
                                    reference_result->end_ref, result->end_ref);
                        }
                    }
                    if (ref_cigar->len != tst_cigar->len) {
#pragma omp critical(printer)
                        {
                            printf("%s(%lu,%lu,%d,%d,%s) wrong cigar len (%d!=%d)\n",
                                    functions[function_index].name,
                                    a, b, open, extend,
                                    matrixname,
                                    ref_cigar->len, tst_cigar->len);
                        }
                    }
                    if (ref_cigar->beg_query != tst_cigar->beg_query) {
#pragma omp critical(printer)
                        {
                            printf("%s(%lu,%lu,%d,%d,%s) wrong cigar beg_query (%d!=%d)\n",
                                    functions[function_index].name,
                                    a, b, open, extend,
                                    matrixname,
                                    ref_cigar->beg_query, tst_cigar->beg_query);
                        }
                    }
                    if (ref_cigar->beg_ref != tst_cigar->beg_ref) {
#pragma omp critical(printer)
                        {
                            printf("%s(%lu,%lu,%d,%d,%s) wrong cigar beg_ref (%d!=%d)\n",
                                    functions[function_index].name,
                                    a, b, open, extend,
                                    matrixname,
                                    ref_cigar->beg_ref, tst_cigar->beg_ref);
                        }
                    }
                    if (diff_cigar(ref_cigar->seq, tst_cigar->seq, ref_cigar->len, tst_cigar->len)) {
#pragma omp critical(printer)
                        {
                            printf("%s(%lu,%lu,%d,%d,%s) bad cigar seq\n",
                                    functions[function_index].name,
                                    a, b, open, extend,
                                    matrixname);
                        }
                    }
                    free(ref_cigar_str);
                    free(tst_cigar_str);
                    parasail_cigar_free(ref_cigar);
                    parasail_cigar_free(tst_cigar);
                    parasail_result_free(reference_result);
                    parasail_result_free(result);
                }
                if (verbose && saturated) {
                    printf("%s %d %d %s saturated %lu times\n",
                            functions[function_index].name,
                            open, extend,
                            matrixname,
                            saturated);
                }
            }
            if (gap.open != INT_MIN && gap.extend != INT_MIN) {
                /* user-specified gap, don't loop */
                break;
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %r9, 0x80(%rsp)
movq %rcx, 0x90(%rsp)
movq %rdx, %rbx
movq %rsi, 0x48(%rsp)
movq %rdi, %rsi
leaq 0xd0(%rsp), %rax
movq %r8, (%rax)
movq $0x0, 0x8(%rax)
testq %r8, %r8
leaq 0x4dc261(%rip), %r14    # 0x661320
cmovneq %rax, %r14
leaq 0x3a8a9f(%rip), %rdi    # 0x52db69
xorl %eax, %eax
callq 0x129040
movq %r14, 0x98(%rsp)
movq (%r14), %rcx
testq %rcx, %rcx
je 0x1858ae
movq 0x80(%rsp), %rax
movq %rax, %rdx
shrq $0x20, %rdx
negl %eax
setno %al
movq %rdx, 0xb0(%rsp)
cmpl $0x80000000, %edx       # imm = 0x80000000
setne %dl
andb %al, %dl
movb %dl, 0xf(%rsp)
movq 0x48(%rsp), %rax
addq $0x48, %rax
movq %rax, 0xa8(%rsp)
xorl %eax, %eax
movq %rbx, 0x38(%rsp)
movq %rax, 0xa0(%rsp)
movq %rcx, 0xc0(%rsp)
movq (%rcx), %rax
movq %rax, 0x18(%rsp)
cmpb $0x1, 0x4f10a5(%rip)    # 0x6761ec
jne 0x18515c
leaq 0x3a8a4e(%rip), %rdi    # 0x52db9e
movq 0x18(%rsp), %rsi
xorl %eax, %eax
callq 0x129040
movl 0x4defce(%rip), %eax    # 0x664130
movl %eax, %ecx
negl %ecx
jo 0x18588a
leaq 0x4defbd(%rip), %rcx    # 0x664130
xorl %r14d, %r14d
movq 0x80(%rsp), %rdx
movl %edx, 0x8(%rsp)
movq 0xb0(%rsp), %rdx
movl %edx, 0x4(%rsp)
cmpb $0x0, 0xf(%rsp)
jne 0x1851a0
movl 0x4(%rcx), %ecx
movl %ecx, 0x4(%rsp)
movl %eax, 0x8(%rsp)
cmpb $0x1, 0x4f1045(%rip)    # 0x6761ec
jne 0x1851c8
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rcx
leaq 0x3a89c7(%rip), %rdi    # 0x52db80
movl 0x8(%rsp), %esi
movl 0x4(%rsp), %edx
xorl %eax, %eax
callq 0x129040
movq 0x48(%rsp), %rax
cmpq $0x0, 0x48(%rax)
je 0x185865
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq %rax, 0xc8(%rsp)
movl $0x1, %r15d
movq 0xa8(%rsp), %rax
movq %rax, 0x10(%rsp)
movq %r14, 0x50(%rsp)
cmpb $0x1, 0x4f0fe5(%rip)    # 0x6761ec
jne 0x185220
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rsi
leaq 0x3a8983(%rip), %rdi    # 0x52db9c
xorl %eax, %eax
callq 0x129040
cmpq $0x0, 0x90(%rsp)
jle 0x18580f
xorl %r9d, %r9d
movq $0x0, 0x70(%rsp)
movq %r15, 0x60(%rsp)
cvtsi2sdq 0x70(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
addsd %xmm0, %xmm0
ucomisd 0x3a8807(%rip), %xmm0   # 0x52da60
movq %r9, 0x68(%rsp)
jb 0x185266
sqrtsd %xmm0, %xmm0
jmp 0x18526b
callq 0x1290f0
callq 0x129200
movsd 0x3a87c8(%rip), %xmm2   # 0x52da40
addsd %xmm2, %xmm0
movsd 0x3a87c4(%rip), %xmm3   # 0x52da48
movapd %xmm3, %xmm1
maxsd %xmm0, %xmm1
movapd %xmm1, %xmm0
addsd %xmm2, %xmm0
mulsd %xmm1, %xmm0
mulsd 0x3a87b0(%rip), %xmm0   # 0x52da50
movsd 0x40(%rsp), %xmm4
movapd %xmm4, %xmm2
subsd %xmm0, %xmm2
ucomisd %xmm1, %xmm2
jb 0x1852be
addsd %xmm1, %xmm0
addsd %xmm3, %xmm1
jmp 0x1852a6
cvttsd2si %xmm2, %rax
movsd 0x3a878d(%rip), %xmm0   # 0x52da58
subsd %xmm0, %xmm2
cvttsd2si %xmm2, %rcx
movq %rax, %r14
sarq $0x3f, %r14
andq %rcx, %r14
orq %rax, %r14
cvttsd2si %xmm1, %rax
subsd %xmm0, %xmm1
cvttsd2si %xmm1, %rcx
movq %rax, %r15
sarq $0x3f, %r15
andq %rcx, %r15
orq %rax, %r15
movq (%rbx), %rax
movq %r14, %rbx
shlq $0x6, %rbx
movq 0x20(%rax,%rbx), %r13
movq %r15, %rbp
shlq $0x6, %rbp
movq 0x20(%rax,%rbp), %r12
cmpb $0x1, 0x4f0ece(%rip)    # 0x6761ec
jne 0x185339
leaq 0x3a887c(%rip), %rdi    # 0x52dba3
movq 0x70(%rsp), %rsi
movq %r14, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x129040
movq %r15, 0x20(%rsp)
movq %r14, 0x28(%rsp)
movq 0x38(%rsp), %r14
movq (%r14), %rax
movq 0x28(%rax,%rbx), %rdi
movq 0x28(%rax,%rbp), %rdx
subq $0x8, %rsp
movl %r13d, %esi
movl %r12d, %ecx
movl 0x10(%rsp), %r8d
movl 0xc(%rsp), %r9d
movq 0xc8(%rsp), %r15
pushq %r15
callq *0xd8(%rsp)
addq $0x10, %rsp
movq %rax, 0x40(%rsp)
movq (%r14), %rax
movq %r12, %r14
movq %rbx, %r12
movq 0x28(%rax,%rbx), %rdi
movq %rbp, 0x78(%rsp)
movq 0x28(%rax,%rbp), %rdx
subq $0x8, %rsp
movq %r13, 0x38(%rsp)
movl %r13d, %esi
movq %r15, %r13
movl %r14d, %ecx
movl 0x10(%rsp), %r8d
movl 0xc(%rsp), %r9d
pushq %r15
movq 0x20(%rsp), %rax
callq *(%rax)
addq $0x10, %rsp
movq %rax, %r15
movq %rax, %rdi
callq 0x18a931
testl %eax, %eax
je 0x185401
movq 0x40(%rsp), %rdi
callq 0x189ac5
movq %r15, %rdi
callq 0x189ac5
movq 0x68(%rsp), %r9
incq %r9
movq 0x38(%rsp), %rbx
movq 0x50(%rsp), %r14
movq 0x60(%rsp), %r15
jmp 0x1857f2
movq %r15, 0x58(%rsp)
movq 0x38(%rsp), %rax
movq (%rax), %rax
movq %r12, %rbx
movq 0x28(%rax,%r12), %rsi
movq 0x78(%rsp), %rbp
movq 0x28(%rax,%rbp), %rcx
movq 0x40(%rsp), %r12
movq %r12, %rdi
movq 0x30(%rsp), %rdx
movl %r14d, %r8d
movq %r13, %r9
callq 0x1893b4
movq %rax, 0x88(%rsp)
testq %rax, %rax
movq 0x60(%rsp), %r15
je 0x1856b9
movq 0x38(%rsp), %rax
movq (%rax), %rax
movq 0x28(%rax,%rbx), %rsi
movq 0x28(%rax,%rbp), %rcx
movq 0x58(%rsp), %rbx
movq %rbx, %rdi
movq 0x30(%rsp), %rdx
movl %r14d, %r8d
movq %r13, %r9
callq 0x1893b4
testq %rax, %rax
je 0x185711
movq 0x88(%rsp), %rbp
movq %rax, %r14
movq %rbp, %rdi
callq 0x185a12
movq %rax, 0x78(%rsp)
movq %r14, 0x30(%rsp)
movq %r14, %rdi
callq 0x185a12
movq %rax, 0xb8(%rsp)
movq 0x40(%rsp), %r13
movl (%r13), %r10d
movl (%rbx), %r11d
cmpl %r11d, %r10d
movq 0x50(%rsp), %r14
je 0x1854ff
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rsi
subq $0x8, %rsp
leaq 0x3a8735(%rip), %rdi    # 0x52dc0d
movq 0x30(%rsp), %rdx
movq 0x28(%rsp), %rcx
movl 0x10(%rsp), %r8d
movl 0xc(%rsp), %r9d
xorl %eax, %eax
pushq %r11
pushq %r10
pushq 0x30(%rsp)
callq 0x129040
addq $0x20, %rsp
movl 0x4(%r13), %r10d
movl 0x4(%rbx), %r11d
cmpl %r11d, %r10d
movq 0x38(%rsp), %rbx
movq 0x60(%rsp), %r15
je 0x185551
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rsi
subq $0x8, %rsp
leaq 0x3a870e(%rip), %rdi    # 0x52dc38
movq 0x30(%rsp), %rdx
movq 0x28(%rsp), %rcx
movl 0x10(%rsp), %r8d
movl 0xc(%rsp), %r9d
xorl %eax, %eax
pushq %r11
pushq %r10
pushq 0x30(%rsp)
callq 0x129040
addq $0x20, %rsp
movl 0x8(%r13), %r10d
movq 0x58(%rsp), %rax
movl 0x8(%rax), %r11d
cmpl %r11d, %r10d
je 0x18559e
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rsi
subq $0x8, %rsp
leaq 0x3a86f0(%rip), %rdi    # 0x52dc67
movq 0x30(%rsp), %rdx
movq 0x28(%rsp), %rcx
movl 0x10(%rsp), %r8d
movl 0xc(%rsp), %r9d
xorl %eax, %eax
pushq %r11
pushq %r10
pushq 0x30(%rsp)
callq 0x129040
addq $0x20, %rsp
movl 0x8(%rbp), %r10d
movq 0x30(%rsp), %rax
movl 0x8(%rax), %r11d
cmpl %r11d, %r10d
je 0x1855f0
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rsi
subq $0x8, %rsp
leaq 0x3a86d0(%rip), %rdi    # 0x52dc94
movq 0x30(%rsp), %rdx
movq 0x28(%rsp), %rcx
movl 0x10(%rsp), %r8d
movl 0xc(%rsp), %r9d
xorl %eax, %eax
pushq %r11
pushq %r10
pushq 0x30(%rsp)
callq 0x129040
movq 0x50(%rsp), %rax
addq $0x20, %rsp
movl 0xc(%rbp), %r10d
movl 0xc(%rax), %r11d
cmpl %r11d, %r10d
je 0x18563d
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rsi
subq $0x8, %rsp
leaq 0x3a86b2(%rip), %rdi    # 0x52dcc3
movq 0x30(%rsp), %rdx
movq 0x28(%rsp), %rcx
movl 0x10(%rsp), %r8d
movl 0xc(%rsp), %r9d
xorl %eax, %eax
pushq %r11
pushq %r10
pushq 0x30(%rsp)
callq 0x129040
movq 0x50(%rsp), %rax
addq $0x20, %rsp
movl 0x10(%rbp), %r10d
movl 0x10(%rax), %r11d
cmpl %r11d, %r10d
je 0x185685
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rsi
subq $0x8, %rsp
leaq 0x3a869a(%rip), %rdi    # 0x52dcf8
movq 0x30(%rsp), %rdx
movq 0x28(%rsp), %rcx
movl 0x10(%rsp), %r8d
movl 0xc(%rsp), %r9d
xorl %eax, %eax
pushq %r11
pushq %r10
pushq 0x30(%rsp)
callq 0x129040
addq $0x20, %rsp
movslq 0x8(%rbp), %rax
testq %rax, %rax
jle 0x1857b2
movq (%rbp), %rcx
movq 0x30(%rsp), %rdx
movq (%rdx), %rdx
xorl %esi, %esi
movl (%rcx,%rsi,4), %edi
cmpl (%rdx,%rsi,4), %edi
jne 0x18577b
incq %rsi
cmpq %rsi, %rax
jne 0x1856a0
jmp 0x1857b2
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rsi
subq $0x8, %rsp
leaq 0x3a84ef(%rip), %rdi    # 0x52dbbc
movq 0x30(%rsp), %rdx
movq 0x28(%rsp), %rcx
movl 0x10(%rsp), %r8d
movl 0xc(%rsp), %r9d
xorl %eax, %eax
pushq 0x20(%rsp)
callq 0x129040
addq $0x10, %rsp
movq %r12, %rdi
callq 0x189ac5
movq 0x58(%rsp), %rdi
callq 0x189ac5
movq 0x38(%rsp), %rbx
movq 0x50(%rsp), %r14
jmp 0x1857ed
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rsi
subq $0x8, %rsp
leaq 0x3a84bf(%rip), %rdi    # 0x52dbe4
movq 0x30(%rsp), %rdx
movq 0x28(%rsp), %rcx
movl 0x10(%rsp), %r8d
movl 0xc(%rsp), %r9d
xorl %eax, %eax
pushq 0x20(%rsp)
callq 0x129040
addq $0x10, %rsp
movq 0x88(%rsp), %rdi
callq 0x1859e2
movq 0x40(%rsp), %rdi
callq 0x189ac5
movq %rbx, %rdi
callq 0x189ac5
movq 0x38(%rsp), %rbx
movq 0x50(%rsp), %r14
movq 0x68(%rsp), %r9
jmp 0x1853f7
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rsi
subq $0x8, %rsp
leaq 0x3a859c(%rip), %rdi    # 0x52dd2b
movq 0x30(%rsp), %rdx
movq 0x28(%rsp), %rcx
movl 0x10(%rsp), %r8d
movl 0xc(%rsp), %r9d
xorl %eax, %eax
pushq 0x20(%rsp)
callq 0x129040
addq $0x10, %rsp
movq 0x78(%rsp), %rdi
callq 0x129170
movq 0xb8(%rsp), %rdi
callq 0x129170
movq %rbp, %rdi
callq 0x1859e2
movq 0x30(%rsp), %rdi
callq 0x1859e2
movq %r13, %rdi
callq 0x189ac5
movq 0x58(%rsp), %rdi
callq 0x189ac5
movq 0x68(%rsp), %r9
movq 0x70(%rsp), %r12
incq %r12
movq %r12, 0x70(%rsp)
cmpq 0x90(%rsp), %r12
jne 0x185240
jmp 0x185812
xorl %r9d, %r9d
testq %r9, %r9
setne %al
andb 0x4f09ce(%rip), %al     # 0x6761ec
cmpb $0x1, %al
jne 0x185846
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rsi
leaq 0x3a851d(%rip), %rdi    # 0x52dd4f
movl 0x8(%rsp), %edx
movl 0x4(%rsp), %ecx
movq 0x18(%rsp), %r8
xorl %eax, %eax
callq 0x129040
incq %r15
leaq (%r15,%r15,8), %rax
movq 0x48(%rsp), %rcx
leaq (%rcx,%rax,8), %rax
movq %rax, 0x10(%rsp)
cmpq $0x0, (%rax)
jne 0x185200
cmpb $0x0, 0xf(%rsp)
jne 0x18588a
leaq 0x4de8bd(%rip), %rax    # 0x664130
leaq (%rax,%r14,8), %rcx
addq $0x8, %rcx
incq %r14
movl (%rcx), %eax
movl %eax, %edx
negl %edx
jno 0x185176
movq 0x98(%rsp), %rax
movq 0xa0(%rsp), %rdx
movq 0x8(%rax,%rdx,8), %rcx
movq %rdx, %rax
incq %rax
testq %rcx, %rcx
jne 0x185128
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq