// File: /workspace/github_c_makefile_star2_O2/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, %rbx
movq %rcx, %r14
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %rsi
movq %r9, %r13
shrq $0x20, %r13
leaq 0xd0(%rsp), %rax
movq %r8, (%rax)
andq $0x0, 0x8(%rax)
testq %r8, %r8
leaq 0x4d13b5(%rip), %rcx    # 0x5fb320
cmovneq %rax, %rcx
movq %rcx, 0x88(%rsp)
leaq 0x3d6beb(%rip), %rdi    # 0x500b69
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x129040
movq %rbx, 0xa0(%rsp)
movl %ebx, %eax
negl %eax
setno %al
movl $0x80000000, %ecx       # imm = 0x80000000
movq %r13, 0x98(%rsp)
cmpq %rcx, %r13
setne %cl
andb %al, %cl
movb %cl, 0xf(%rsp)
testq %r14, %r14
cmovleq %rbp, %r14
movq %r14, 0xc0(%rsp)
xorl %ecx, %ecx
movq %r12, 0x28(%rsp)
movq %r15, 0xa8(%rsp)
movq 0x88(%rsp), %rax
movq (%rax,%rcx,8), %rax
testq %rax, %rax
je 0x12a722
movq %rcx, 0x90(%rsp)
movq %rax, 0xb0(%rsp)
movq (%rax), %rax
movq %rax, 0x10(%rsp)
cmpb $0x1, 0x4e61eb(%rip)    # 0x6101ec
jne 0x12a016
leaq 0x3d6b94(%rip), %rdi    # 0x500b9e
movq 0x10(%rsp), %rsi
xorl %eax, %eax
callq 0x129040
xorl %ebx, %ebx
leaq 0x4d4111(%rip), %rax    # 0x5fe130
movl (%rax,%rbx,8), %eax
movl %eax, %ecx
negl %ecx
jo 0x12a712
movq 0xa0(%rsp), %rcx
movl %ecx, 0x8(%rsp)
movq 0x98(%rsp), %rcx
movl %ecx, 0x4(%rsp)
cmpb $0x0, 0xf(%rsp)
jne 0x12a05e
leaq 0x4d40de(%rip), %rcx    # 0x5fe130
movl 0x4(%rcx,%rbx,8), %ecx
movl %ecx, 0x4(%rsp)
movl %eax, 0x8(%rsp)
cmpb $0x1, 0x4e6187(%rip)    # 0x6101ec
jne 0x12a081
movq 0x8(%r15), %rcx
leaq 0x3d6b0e(%rip), %rdi    # 0x500b80
movl 0x8(%rsp), %esi
movl 0x4(%rsp), %edx
xorl %eax, %eax
callq 0x129040
movq (%r15), %rax
movq %rax, 0xb8(%rsp)
pushq $0x1
popq %r14
movq %rbx, 0x48(%rsp)
imulq $0x48, %r14, %r13
cmpq $0x0, (%r15,%r13)
je 0x12a704
addq %r15, %r13
cmpb $0x1, 0x4e613e(%rip)    # 0x6101ec
jne 0x12a0c2
movq 0x8(%r13), %rsi
leaq 0x3d6ae1(%rip), %rdi    # 0x500b9c
xorl %eax, %eax
callq 0x129040
xorl %eax, %eax
xorl %r9d, %r9d
movq %r14, 0x58(%rsp)
movq %r13, 0x18(%rsp)
cmpq 0xc0(%rsp), %rax
je 0x12a6cd
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x40(%rsp)
addsd %xmm0, %xmm0
ucomisd 0x3d696a(%rip), %xmm0   # 0x500a60
movq %r9, 0x68(%rsp)
movq %rax, 0x80(%rsp)
jb 0x12a10b
sqrtsd %xmm0, %xmm0
jmp 0x12a110
callq 0x1290f0
callq 0x129200
movsd 0x3d6923(%rip), %xmm2   # 0x500a40
addsd %xmm2, %xmm0
movsd 0x3d691f(%rip), %xmm3   # 0x500a48
movapd %xmm3, %xmm1
maxsd %xmm0, %xmm1
movapd %xmm1, %xmm0
addsd %xmm2, %xmm0
mulsd %xmm1, %xmm0
mulsd 0x3d690b(%rip), %xmm0   # 0x500a50
movsd 0x40(%rsp), %xmm4
movapd %xmm4, %xmm2
subsd %xmm0, %xmm2
ucomisd %xmm1, %xmm2
jb 0x12a163
addsd %xmm1, %xmm0
addsd %xmm3, %xmm1
jmp 0x12a14b
cvttsd2si %xmm2, %rax
movsd 0x3d68e8(%rip), %xmm0   # 0x500a58
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 (%r12), %rax
movq %r14, %r12
shlq $0x6, %r12
movq 0x20(%rax,%r12), %r13
movq %r15, %rbx
shlq $0x6, %rbx
movq 0x20(%rax,%rbx), %rbp
cmpb $0x1, 0x4e6028(%rip)    # 0x6101ec
jne 0x12a1ea
leaq 0x3d69d6(%rip), %rdi    # 0x500ba3
movq 0x80(%rsp), %rsi
movq %r14, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x129040
movq 0x28(%rsp), %rax
movq (%rax), %rax
movq %r15, 0x20(%rsp)
movq %r14, 0x78(%rsp)
movq 0x28(%rax,%r12), %rdi
movq 0x28(%rax,%rbx), %rdx
subq $0x8, %rsp
movl %r13d, %esi
movl %ebp, %ecx
movl 0x10(%rsp), %r14d
movl %r14d, %r8d
movq %rbx, 0x40(%rsp)
movq %r13, %rbx
movl 0xc(%rsp), %r15d
movl %r15d, %r9d
movq 0xb8(%rsp), %r13
pushq %r13
callq *0xc8(%rsp)
addq $0x10, %rsp
movq %rax, 0x40(%rsp)
movq 0x28(%rsp), %rax
movq (%rax), %rax
movq %r12, 0xc8(%rsp)
movq 0x28(%rax,%r12), %rdi
movq 0x38(%rsp), %r12
movq 0x28(%rax,%r12), %rdx
subq $0x8, %rsp
movq %rbx, 0x68(%rsp)
movl %ebx, %esi
movq %rbp, 0x78(%rsp)
movl %ebp, %ecx
movl %r14d, %r8d
movl %r15d, %r9d
movq %r13, %rbp
pushq %r13
movq 0x28(%rsp), %r13
callq *(%r13)
addq $0x10, %rsp
movq %rax, %r14
movq %rax, %rdi
callq 0x12fdc2
testl %eax, %eax
je 0x12a2d2
movq 0x40(%rsp), %rdi
callq 0x12ed2d
movq %r14, %rdi
callq 0x12ed2d
movq 0x68(%rsp), %r9
incq %r9
movq 0x28(%rsp), %r12
movq 0x48(%rsp), %rbx
movq 0x58(%rsp), %r14
movq 0x80(%rsp), %rax
incq %rax
movq 0xa8(%rsp), %r15
jmp 0x12a0d1
movq %r14, 0x50(%rsp)
movq 0x28(%rsp), %rax
movq (%rax), %rax
movq 0xc8(%rsp), %rbx
movq 0x28(%rax,%rbx), %rsi
movq 0x28(%rax,%r12), %rcx
movq 0x40(%rsp), %rdi
movq 0x60(%rsp), %rdx
movq 0x70(%rsp), %r15
movl %r15d, %r8d
movq %rbp, %r9
callq 0x12e47f
movq %rax, 0x30(%rsp)
testq %rax, %rax
movq 0x58(%rsp), %r14
je 0x12a607
movq 0x40(%rsp), %r14
movq 0x28(%rsp), %rax
movq (%rax), %rax
movq 0x28(%rax,%rbx), %rsi
movq 0x28(%rax,%r12), %rcx
movq 0x50(%rsp), %r12
movq %r12, %rdi
movq 0x60(%rsp), %rdx
movl %r15d, %r8d
movq %rbp, %r9
callq 0x12e47f
testq %rax, %rax
je 0x12a667
movq %rax, %rbx
movq 0x30(%rsp), %rdi
callq 0x12a89a
movq %rax, 0x60(%rsp)
movq %rbx, 0x38(%rsp)
movq %rbx, %rdi
callq 0x12a89a
movq %rax, 0x70(%rsp)
movq %r14, %r13
movl (%r14), %r10d
movl (%r12), %r11d
cmpl %r11d, %r10d
movq 0x48(%rsp), %rbx
movq 0x78(%rsp), %r15
je 0x12a3cc
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rsi
subq $0x8, %rsp
leaq 0x3d6866(%rip), %rdi    # 0x500c0d
movq %r15, %rdx
movq 0x28(%rsp), %rcx
movl 0x10(%rsp), %r8d
movl 0xc(%rsp), %r9d
xorl %eax, %eax
pushq %r11
pushq %r10
pushq 0x28(%rsp)
callq 0x129040
addq $0x20, %rsp
movl 0x4(%r13), %r10d
movl 0x4(%r12), %r11d
cmpl %r11d, %r10d
movq 0x28(%rsp), %r12
movq 0x58(%rsp), %r14
je 0x12a41d
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rsi
subq $0x8, %rsp
leaq 0x3d6840(%rip), %rdi    # 0x500c38
movq %r15, %rdx
movq 0x28(%rsp), %rcx
movl 0x10(%rsp), %r8d
movl 0xc(%rsp), %r9d
xorl %eax, %eax
pushq %r11
pushq %r10
pushq 0x28(%rsp)
callq 0x129040
addq $0x20, %rsp
movl 0x8(%r13), %r10d
movq 0x50(%rsp), %rax
movl 0x8(%rax), %r11d
cmpl %r11d, %r10d
je 0x12a468
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rsi
subq $0x8, %rsp
leaq 0x3d6824(%rip), %rdi    # 0x500c67
movq %r15, %rdx
movq 0x28(%rsp), %rcx
movl 0x10(%rsp), %r8d
movl 0xc(%rsp), %r9d
xorl %eax, %eax
pushq %r11
pushq %r10
pushq 0x28(%rsp)
callq 0x129040
addq $0x20, %rsp
movq 0x30(%rsp), %rax
movl 0x8(%rax), %r10d
movq 0x38(%rsp), %rcx
movl 0x8(%rcx), %r11d
cmpl %r11d, %r10d
je 0x12a4bd
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rsi
subq $0x8, %rsp
leaq 0x3d6801(%rip), %rdi    # 0x500c94
movq %r15, %rdx
movq 0x28(%rsp), %rcx
movl 0x10(%rsp), %r8d
movl 0xc(%rsp), %r9d
xorl %eax, %eax
pushq %r11
pushq %r10
pushq 0x28(%rsp)
callq 0x129040
movq 0x58(%rsp), %rcx
addq $0x20, %rsp
movq 0x30(%rsp), %rax
movl 0xc(%rax), %r10d
movl 0xc(%rcx), %r11d
cmpl %r11d, %r10d
je 0x12a50d
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rsi
subq $0x8, %rsp
leaq 0x3d67e0(%rip), %rdi    # 0x500cc3
movq %r15, %rdx
movq 0x28(%rsp), %rcx
movl 0x10(%rsp), %r8d
movl 0xc(%rsp), %r9d
xorl %eax, %eax
pushq %r11
pushq %r10
pushq 0x28(%rsp)
callq 0x129040
movq 0x58(%rsp), %rcx
addq $0x20, %rsp
movq 0x30(%rsp), %rax
movl 0x10(%rax), %r10d
movl 0x10(%rcx), %r11d
cmpl %r11d, %r10d
je 0x12a55d
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rsi
subq $0x8, %rsp
leaq 0x3d67c5(%rip), %rdi    # 0x500cf8
movq %r15, %rdx
movq 0x28(%rsp), %rcx
movl 0x10(%rsp), %r8d
movl 0xc(%rsp), %r9d
xorl %eax, %eax
pushq %r11
pushq %r10
pushq 0x28(%rsp)
callq 0x129040
movq 0x58(%rsp), %rcx
addq $0x20, %rsp
movq 0x30(%rsp), %rdx
movq (%rdx), %rax
movq (%rcx), %rcx
movl 0x8(%rdx), %edx
testl %edx, %edx
movl $0x0, %esi
cmovlel %esi, %edx
xorl %esi, %esi
cmpq %rsi, %rdx
je 0x12a5be
movl (%rax,%rsi,4), %edi
leaq 0x1(%rsi), %r8
cmpl (%rcx,%rsi,4), %edi
movq %r8, %rsi
je 0x12a577
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rsi
subq $0x8, %rsp
leaq 0x3d678c(%rip), %rdi    # 0x500d2b
movq %r15, %rdx
movq 0x28(%rsp), %rcx
movl 0x10(%rsp), %r8d
movl 0xc(%rsp), %r9d
xorl %eax, %eax
pushq 0x18(%rsp)
callq 0x129040
popq %rcx
popq %rdx
movq 0x60(%rsp), %rdi
callq 0x129170
movq 0x70(%rsp), %rdi
callq 0x129170
movq 0x30(%rsp), %rdi
callq 0x12a86a
movq 0x38(%rsp), %rdi
callq 0x12a86a
movq %r13, %rdi
callq 0x12ed2d
movq 0x50(%rsp), %rdi
callq 0x12ed2d
movq 0x68(%rsp), %r9
movq 0x18(%rsp), %r13
jmp 0x12a2ba
movq 0x18(%rsp), %r13
movq 0x8(%r13), %rsi
subq $0x8, %rsp
leaq 0x3d65a1(%rip), %rdi    # 0x500bbc
movq 0x80(%rsp), %rdx
movq 0x28(%rsp), %rcx
movl 0x10(%rsp), %r8d
movl 0xc(%rsp), %r9d
xorl %eax, %eax
pushq 0x18(%rsp)
callq 0x129040
popq %rcx
popq %rdx
movq 0x40(%rsp), %rdi
callq 0x12ed2d
movq 0x50(%rsp), %rdi
callq 0x12ed2d
movq 0x28(%rsp), %r12
movq 0x48(%rsp), %rbx
movq 0x68(%rsp), %r9
jmp 0x12a2ba
movq 0x18(%rsp), %r13
movq 0x8(%r13), %rsi
subq $0x8, %rsp
leaq 0x3d6569(%rip), %rdi    # 0x500be4
movq 0x80(%rsp), %rdx
movq 0x28(%rsp), %rcx
movl 0x10(%rsp), %r8d
movl 0xc(%rsp), %r9d
xorl %eax, %eax
pushq 0x18(%rsp)
callq 0x129040
popq %rcx
popq %rdx
movq 0x30(%rsp), %rdi
callq 0x12a86a
movq %r14, %rdi
callq 0x12ed2d
movq %r12, %rdi
callq 0x12ed2d
movq 0x28(%rsp), %r12
movq 0x48(%rsp), %rbx
movq 0x68(%rsp), %r9
jmp 0x12a2b5
testq %r9, %r9
setne %al
andb 0x4e5b13(%rip), %al     # 0x6101ec
cmpb $0x1, %al
jne 0x12a6fc
movq 0x8(%r13), %rsi
leaq 0x3d6667(%rip), %rdi    # 0x500d4f
movl 0x8(%rsp), %edx
movl 0x4(%rsp), %ecx
movq 0x10(%rsp), %r8
xorl %eax, %eax
callq 0x129040
incq %r14
jmp 0x12a095
incq %rbx
cmpb $0x0, 0xf(%rsp)
je 0x12a018
movq 0x90(%rsp), %rcx
incq %rcx
jmp 0x129fcd
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq