// File: /workspace/github_c_makefile_star2_O1/nh13[P]ksw/src/parasail/tests/test_verify.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\n", open, extend);
            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;
                    size_t size_a = 0;
                    size_t size_b = 0;
                    k_combination2(pair_index, &a, &b);
                    if (verbose ) printf("\t\t\t\tpair=%lld (%lu,%lu)\n", pair_index, a, b);
                    size_a = sequences->seqs[a].seq.l;
                    size_b = sequences->seqs[b].seq.l;
                    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_FLAG_INVALID & reference_result->flag) {
#pragma omp critical(printer)
                        {
                            printf("%s(%lu,%lu,%d,%d,%s) invalid reference flag (%d %d)\n",
                                    functions[function_index].name,
                                    a, b, open, extend,
                                    matrixname,
                                    reference_result->flag, PARASAIL_FLAG_INVALID);
                            if (exit_on_mismatch) exit(EXIT_FAILURE);
                        }
                    }
                    if (PARASAIL_FLAG_INVALID & result->flag) {
#pragma omp critical(printer)
                        {
                            printf("%s(%lu,%lu,%d,%d,%s) invalid result flag (%d %d)\n",
                                    functions[function_index].name,
                                    a, b, open, extend,
                                    matrixname,
                                    result->flag, PARASAIL_FLAG_INVALID);
                            if (exit_on_mismatch) exit(EXIT_FAILURE);
                        }
                    }
                    if (!check_flags(reference_result->flag, result->flag)) {
#pragma omp critical(printer)
                        {
                            printf("%s(%lu,%lu,%d,%d,%s) wrong flag (%d!=%d)\n",
                                    functions[function_index].name,
                                    a, b, open, extend,
                                    matrixname,
                                    reference_result->flag, result->flag);
                            if (exit_on_mismatch) exit(EXIT_FAILURE);
                        }
                    }
                    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;
                    }
                    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 (exit_on_mismatch) exit(EXIT_FAILURE);
                        }
                    }
                    if (reference_result->end_query != result->end_query) {
#pragma omp critical(printer)
                        {
                            printf("%s(%lu,%lu,%d,%d,%s) wrong end_query (%d!=%d) score=%d\n",
                                    functions[function_index].name,
                                    a, b, open, extend,
                                    matrixname,
                                    reference_result->end_query, result->end_query, result->score);
                            if (exit_on_mismatch) exit(EXIT_FAILURE);
                        }
                    }
                    if (reference_result->end_ref != result->end_ref) {
#pragma omp critical(printer)
                        {
                            printf("%s(%lu,%lu,%d,%d,%s) wrong end_ref (%d!=%d) score=%d\n",
                                    functions[function_index].name,
                                    a, b, open, extend,
                                    matrixname,
                                    reference_result->end_ref, result->end_ref, result->score);
                            if (exit_on_mismatch) exit(EXIT_FAILURE);
                        }
                    }
                    if (parasail_result_is_stats(result)) {
                        int ref_matches = parasail_result_get_matches(reference_result);
                        int ref_similar = parasail_result_get_similar(reference_result);
                        int ref_length = parasail_result_get_length(reference_result);
                        int matches = parasail_result_get_matches(result);
                        int similar = parasail_result_get_similar(result);
                        int length = parasail_result_get_length(result);
                        if (ref_matches != matches) {
#pragma omp critical(printer)
                            {
                                printf("%s(%lu,%lu,%d,%d,%s) wrong matches (%d!=%d)\n",
                                        functions[function_index].name,
                                        a, b, open, extend,
                                        matrixname,
                                        ref_matches, matches);
                                if (exit_on_mismatch) exit(EXIT_FAILURE);
                            }
                        }
                        if (ref_similar != similar) {
#pragma omp critical(printer)
                            {
                                printf("%s(%lu,%lu,%d,%d,%s) wrong similar (%d!=%d)\n",
                                        functions[function_index].name,
                                        a, b, open, extend,
                                        matrixname,
                                        ref_similar, similar);
                                if (exit_on_mismatch) exit(EXIT_FAILURE);
                            }
                        }
                        if (ref_length != length) {
#pragma omp critical(printer)
                            {
                                printf("%s(%lu,%lu,%d,%d,%s) wrong length (%d!=%d)\n",
                                        functions[function_index].name,
                                        a, b, open, extend,
                                        matrixname,
                                        ref_length, length);
                                if (exit_on_mismatch) exit(EXIT_FAILURE);
                            }
                        }
                    }
                    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 $0xd8, %rsp
movq %r9, 0x40(%rsp)
movq %rcx, 0x48(%rsp)
movq %rdx, 0x58(%rsp)
movq %rsi, 0x28(%rsp)
movq %rdi, %rsi
leaq 0xc0(%rsp), %rax
movq %r8, (%rax)
movq $0x0, 0x8(%rax)
testq %r8, %r8
leaq 0x4dd82d(%rip), %rbx    # 0x687320
cmovneq %rax, %rbx
leaq 0x3a608d(%rip), %rdi    # 0x54fb8b
xorl %eax, %eax
callq 0x14d040
movq %rbx, 0x60(%rsp)
movq (%rbx), %rcx
testq %rcx, %rcx
je 0x1aa229
movq 0x40(%rsp), %rax
movq %rax, %rdx
shrq $0x20, %rdx
negl %eax
setno %al
movq %rdx, 0x78(%rsp)
cmpl $0x80000000, %edx       # imm = 0x80000000
setne %dl
andb %al, %dl
movb %dl, 0x3(%rsp)
movq 0x28(%rsp), %rax
addq $0x48, %rax
movq %rax, 0x70(%rsp)
xorl %eax, %eax
movq %rax, 0x68(%rsp)
movq %rcx, 0x98(%rsp)
movq (%rcx), %rbx
cmpb $0x1, 0x5024ba(%rip)    # 0x6ac01c
jne 0x1a9b75
leaq 0x3a604e(%rip), %rdi    # 0x54fbb9
movq %rbx, %rsi
xorl %eax, %eax
callq 0x14d040
movl 0x4e0595(%rip), %eax    # 0x68a110
movl %eax, %ecx
negl %ecx
jo 0x1aa20b
leaq 0x4e0584(%rip), %rcx    # 0x68a110
xorl %r14d, %r14d
movq %rbx, 0x90(%rsp)
movq 0x40(%rsp), %rdx
movl %edx, %r12d
movq 0x78(%rsp), %rdx
movl %edx, %ebp
cmpb $0x0, 0x3(%rsp)
jne 0x1a9bb3
movl 0x4(%rcx), %ebp
movl %eax, %r12d
cmpb $0x1, 0x502462(%rip)    # 0x6ac01c
jne 0x1a9bcf
leaq 0x3a5fdf(%rip), %rdi    # 0x54fba2
movl %r12d, %esi
movl %ebp, %edx
xorl %eax, %eax
callq 0x14d040
movq 0x28(%rsp), %rax
cmpq $0x0, 0x48(%rax)
je 0x1aa1e6
movq 0x28(%rsp), %rax
movq (%rax), %rax
movq %rax, 0xa8(%rsp)
movl $0x1, %r15d
movq 0x70(%rsp), %rax
movq %rax, 0x30(%rsp)
movl %ebp, 0x1c(%rsp)
movq %r14, 0xa0(%rsp)
movl %r12d, 0x4(%rsp)
cmpb $0x1, 0x502405(%rip)    # 0x6ac01c
jne 0x1a9c30
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rsi
leaq 0x3a5f8e(%rip), %rdi    # 0x54fbb7
xorl %eax, %eax
callq 0x14d040
cmpq $0x0, 0x48(%rsp)
jle 0x1aa195
xorl %r13d, %r13d
xorl %r9d, %r9d
movq %r15, 0xb0(%rsp)
cvtsi2sd %r13, %xmm0
movsd %xmm0, 0x8(%rsp)
addsd %xmm0, %xmm0
ucomisd 0x3a5e1f(%rip), %xmm0   # 0x54fa80
movq %r9, 0x50(%rsp)
jb 0x1a9c6e
sqrtsd %xmm0, %xmm0
jmp 0x1a9c73
callq 0x14d0f0
callq 0x14d1e0
movsd 0x3a5de0(%rip), %xmm2   # 0x54fa60
addsd %xmm2, %xmm0
movsd 0x3a5ddc(%rip), %xmm3   # 0x54fa68
movapd %xmm3, %xmm1
maxsd %xmm0, %xmm1
movapd %xmm1, %xmm0
addsd %xmm2, %xmm0
mulsd %xmm1, %xmm0
mulsd 0x3a5dc8(%rip), %xmm0   # 0x54fa70
movsd 0x8(%rsp), %xmm4
movapd %xmm4, %xmm2
subsd %xmm0, %xmm2
ucomisd %xmm1, %xmm2
jb 0x1a9cc6
addsd %xmm1, %xmm0
addsd %xmm3, %xmm1
jmp 0x1a9cae
movl %r12d, %ebp
cvttsd2si %xmm2, %rax
movsd 0x3a5da2(%rip), %xmm0   # 0x54fa78
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
cmpb $0x1, 0x50230e(%rip)    # 0x6ac01c
jne 0x1a9d27
leaq 0x3a5ea7(%rip), %rdi    # 0x54fbbe
movq %r13, %rsi
movq %r14, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x14d040
movq %r13, 0xb8(%rsp)
movq 0x58(%rsp), %rax
movq (%rax), %rax
movq %r14, %r12
shlq $0x6, %r12
movl 0x20(%rax,%r12), %esi
movl %esi, 0x38(%rsp)
movq %r14, 0x20(%rsp)
movq %r15, 0x10(%rsp)
shlq $0x6, %r15
movl 0x20(%rax,%r15), %ecx
movl %ecx, 0x8(%rsp)
movq 0x28(%rax,%r12), %rdi
movq 0x28(%rax,%r15), %rdx
subq $0x8, %rsp
movl %ebp, %r13d
movl %ebp, %r8d
movl 0x24(%rsp), %ebp
movl %ebp, %r9d
movq 0xa0(%rsp), %r14
pushq %r14
callq *0xb8(%rsp)
addq $0x10, %rsp
movq %rax, %rbx
movq 0x58(%rsp), %rax
movq (%rax), %rax
movq 0x28(%rax,%r12), %rdi
movq 0x28(%rax,%r15), %rdx
movq 0x20(%rsp), %r15
subq $0x8, %rsp
movl 0x40(%rsp), %esi
movl 0x10(%rsp), %ecx
movl %r13d, %r8d
movl %ebp, %r9d
pushq %r14
movq 0x40(%rsp), %r14
callq *(%r14)
addq $0x10, %rsp
movq %rax, %r12
movq %rbx, 0x8(%rsp)
movl 0xc(%rbx), %r10d
testl $0x80000020, %r10d      # imm = 0x80000020
movq 0x90(%rsp), %rbx
je 0x1a9e22
movq 0x8(%r14), %rsi
subq $0x8, %rsp
leaq 0x3a5de3(%rip), %rdi    # 0x54fbd7
movq %r15, %rdx
movq 0x18(%rsp), %rcx
movl %r13d, %r8d
movl %ebp, %r9d
xorl %eax, %eax
pushq $-0x7fffffe0            # imm = 0x80000020
pushq %r10
pushq %rbx
callq 0x14d040
addq $0x20, %rsp
cmpb $0x1, 0x502204(%rip)    # 0x6ac020
je 0x1aa23b
movl 0xc(%r12), %r10d
testl $0x80000020, %r10d      # imm = 0x80000020
je 0x1a9e6f
movq 0x8(%r14), %rsi
subq $0x8, %rsp
leaq 0x3a5dcd(%rip), %rdi    # 0x54fc0c
movq %r15, %rdx
movq 0x18(%rsp), %rcx
movl 0xc(%rsp), %r8d
movl %ebp, %r9d
xorl %eax, %eax
pushq $-0x7fffffe0            # imm = 0x80000020
pushq %r10
pushq %rbx
callq 0x14d040
addq $0x20, %rsp
cmpb $0x1, 0x5021b7(%rip)    # 0x6ac020
je 0x1aa23b
movq 0x8(%rsp), %rax
movl 0xc(%rax), %r10d
movl 0xc(%r12), %r11d
movl %r11d, %eax
testb $0x1, %r10b
jne 0x1a9e94
testb $0x2, %r10b
jne 0x1a9e99
andl %r10d, %eax
andl $0x4, %eax
jmp 0x1a9e9c
andl $0x1, %eax
jmp 0x1a9e9c
andl $0x2, %eax
testl %eax, %eax
jne 0x1a9edc
movq 0x8(%r14), %rsi
subq $0x8, %rsp
leaq 0x3a5d8f(%rip), %rdi    # 0x54fc3e
movq %r15, %rdx
movq 0x18(%rsp), %rcx
movl 0xc(%rsp), %r8d
movl %ebp, %r9d
xorl %eax, %eax
pushq %r11
pushq %r10
pushq %rbx
callq 0x14d040
addq $0x20, %rsp
cmpb $0x1, 0x50214a(%rip)    # 0x6ac020
je 0x1aa23b
movq %r12, %rdi
callq 0x1ab7b5
testl %eax, %eax
je 0x1a9f07
movq 0x8(%rsp), %rdi
callq 0x1aa949
movq %r12, %rdi
callq 0x1aa949
movq 0x50(%rsp), %r9
incq %r9
jmp 0x1aa168
movq 0x8(%rsp), %rax
movl (%rax), %r10d
movl (%r12), %r11d
cmpl %r11d, %r10d
je 0x1a9f54
movq 0x8(%r14), %rsi
subq $0x8, %rsp
leaq 0x3a5d41(%rip), %rdi    # 0x54fc68
movq %r15, %rdx
movq 0x18(%rsp), %rcx
movl 0xc(%rsp), %r8d
movl %ebp, %r9d
xorl %eax, %eax
pushq %r11
pushq %r10
pushq %rbx
callq 0x14d040
addq $0x20, %rsp
cmpb $0x1, 0x5020d2(%rip)    # 0x6ac020
je 0x1aa23b
movq 0x8(%rsp), %rax
movl 0x4(%rax), %r10d
movl 0x4(%r12), %r11d
cmpl %r11d, %r10d
je 0x1a9fa7
movq 0x8(%r14), %rsi
movl (%r12), %r15d
leaq 0x3a5d1d(%rip), %rdi    # 0x54fc93
movq 0x20(%rsp), %rdx
movq 0x10(%rsp), %rcx
movl 0x4(%rsp), %r8d
movl %ebp, %r9d
xorl %eax, %eax
pushq %r15
pushq %r11
pushq %r10
pushq %rbx
callq 0x14d040
addq $0x20, %rsp
cmpb $0x1, 0x50207f(%rip)    # 0x6ac020
je 0x1aa23b
movq 0x8(%rsp), %rax
movl 0x8(%rax), %r10d
movl 0x8(%r12), %r11d
cmpl %r11d, %r10d
je 0x1a9ffa
movq 0x8(%r14), %rsi
movl (%r12), %r15d
leaq 0x3a5d02(%rip), %rdi    # 0x54fccb
movq 0x20(%rsp), %rdx
movq 0x10(%rsp), %rcx
movl 0x4(%rsp), %r8d
movl %ebp, %r9d
xorl %eax, %eax
pushq %r15
pushq %r11
pushq %r10
pushq %rbx
callq 0x14d040
addq $0x20, %rsp
cmpb $0x1, 0x50202c(%rip)    # 0x6ac020
je 0x1aa23b
movq %r12, %rdi
callq 0x1ab855
testl %eax, %eax
movq 0x20(%rsp), %r15
je 0x1aa151
movq 0x8(%rsp), %rbp
movq %rbp, %rdi
callq 0x1ab948
movl %eax, %r13d
movq %rbp, %rdi
callq 0x1ab96c
movq %rax, 0x88(%rsp)
movq %rbp, %rdi
callq 0x1ab991
movq %rax, 0x38(%rsp)
movq %r12, %rdi
callq 0x1ab948
movl %eax, %ebp
movq %r12, %rdi
callq 0x1ab96c
movq %rax, 0x80(%rsp)
movq %r12, %rdi
callq 0x1ab991
movl %eax, %r10d
cmpl %ebp, %r13d
je 0x1aa0a9
movq 0x8(%r14), %rsi
subq $0x8, %rsp
leaq 0x3a5c8c(%rip), %rdi    # 0x54fd01
movq %r15, %rdx
movq 0x18(%rsp), %rcx
movl 0xc(%rsp), %r8d
movl 0x24(%rsp), %r9d
xorl %eax, %eax
pushq %rbp
pushq %r13
pushq %rbx
movq %r10, %rbp
callq 0x14d040
movq %rbp, %r10
addq $0x20, %rsp
cmpb $0x1, 0x501f7d(%rip)    # 0x6ac020
je 0x1aa23b
movq 0x88(%rsp), %r11
movq 0x80(%rsp), %rax
cmpl %eax, %r11d
movl 0x1c(%rsp), %ebp
je 0x1aa10c
movq 0x8(%r14), %rsi
subq $0x8, %rsp
leaq 0x3a5c5d(%rip), %rdi    # 0x54fd2e
movq %r15, %rdx
movq 0x18(%rsp), %rcx
movl 0xc(%rsp), %r8d
movl %ebp, %r9d
movq %rax, %r13
xorl %eax, %eax
pushq %r13
pushq %r11
pushq %rbx
movq %r10, %r13
callq 0x14d040
movq %r13, %r10
movq 0x40(%rsp), %r15
addq $0x20, %rsp
cmpb $0x1, 0x501f1a(%rip)    # 0x6ac020
je 0x1aa23b
cmpl %r10d, 0x38(%rsp)
je 0x1aa151
movq 0x8(%r14), %rsi
subq $0x8, %rsp
leaq 0x3a5c39(%rip), %rdi    # 0x54fd5b
movq %r15, %rdx
movq 0x18(%rsp), %rcx
movl 0xc(%rsp), %r8d
movl %ebp, %r9d
xorl %eax, %eax
pushq %r10
pushq 0x48(%rsp)
pushq %rbx
callq 0x14d040
addq $0x20, %rsp
cmpb $0x1, 0x501ed5(%rip)    # 0x6ac020
je 0x1aa23b
movq 0x8(%rsp), %rdi
callq 0x1aa949
movq %r12, %rdi
callq 0x1aa949
movq 0x50(%rsp), %r9
movq 0xb8(%rsp), %r13
incq %r13
cmpq 0x48(%rsp), %r13
movq 0xa0(%rsp), %r14
movq 0xb0(%rsp), %r15
movl 0x4(%rsp), %r12d
jne 0x1a9c4a
jmp 0x1aa198
xorl %r9d, %r9d
testq %r9, %r9
setne %al
andb 0x501e78(%rip), %al     # 0x6ac01c
cmpb $0x1, %al
jne 0x1aa1c7
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rsi
leaq 0x3a5bcf(%rip), %rdi    # 0x54fd87
movl %r12d, %edx
movl %ebp, %ecx
movq %rbx, %r8
xorl %eax, %eax
callq 0x14d040
incq %r15
leaq (%r15,%r15,8), %rax
movq 0x28(%rsp), %rcx
leaq (%rcx,%rax,8), %rax
movq %rax, 0x30(%rsp)
cmpq $0x0, (%rax)
jne 0x1a9c10
cmpb $0x0, 0x3(%rsp)
jne 0x1aa20b
leaq 0x4dff1c(%rip), %rax    # 0x68a110
leaq (%rax,%r14,8), %rcx
addq $0x8, %rcx
incq %r14
movl (%rcx), %eax
movl %eax, %edx
negl %edx
jno 0x1a9b97
movq 0x60(%rsp), %rax
movq 0x68(%rsp), %rdx
movq 0x8(%rax,%rdx,8), %rcx
movq %rdx, %rax
incq %rax
testq %rcx, %rcx
jne 0x1a9b4b
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %edi
callq 0x14d170
nopl (%rax)