// File: /workspace/github_c_makefile_star2_O2/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 $0xc8, %rsp
movq %r9, %r14
movq %rcx, %r15
movq %rdx, 0x48(%rsp)
movq %rsi, %r12
movq %rdi, %rsi
movq %r9, %r13
shrq $0x20, %r13
leaq 0xb0(%rsp), %rax
movq %r8, (%rax)
andq $0x0, 0x8(%rax)
testq %r8, %r8
leaq 0x4d3918(%rip), %rcx    # 0x622320
cmovneq %rax, %rcx
movq %rcx, 0x58(%rsp)
leaq 0x3d4173(%rip), %rdi    # 0x522b8b
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x14d040
movq %r14, 0x70(%rsp)
movl %r14d, %eax
negl %eax
setno %al
movl $0x80000000, %ecx       # imm = 0x80000000
movq %r13, 0x68(%rsp)
cmpq %rcx, %r13
setne %cl
andb %al, %cl
movb %cl, 0xb(%rsp)
testq %r15, %r15
cmovleq %rbx, %r15
movq %r15, 0xa8(%rsp)
xorl %ecx, %ecx
movq %r12, 0x80(%rsp)
movq 0x58(%rsp), %rax
movq (%rax,%rcx,8), %rax
testq %rax, %rax
je 0x14f0e3
movq %rcx, 0x60(%rsp)
movq %rax, 0x88(%rsp)
movq (%rax), %r14
cmpb $0x1, 0x4f8596(%rip)    # 0x64701c
jne 0x14ea99
leaq 0x3d412a(%rip), %rdi    # 0x522bb9
movq %r14, %rsi
xorl %eax, %eax
callq 0x14d040
xorl %ebx, %ebx
movq %r14, 0x18(%rsp)
leaq 0x4d6669(%rip), %rax    # 0x625110
movl (%rax,%rbx,8), %eax
movl %eax, %ecx
negl %ecx
jo 0x14f0ce
movq 0x70(%rsp), %rcx
movl %ecx, %ebp
movq 0x68(%rsp), %rcx
movl %ecx, 0xc(%rsp)
cmpb $0x0, 0xb(%rsp)
jne 0x14eadc
leaq 0x4d663e(%rip), %rcx    # 0x625110
movl 0x4(%rcx,%rbx,8), %ecx
movl %ecx, 0xc(%rsp)
movl %eax, %ebp
cmpb $0x1, 0x4f8539(%rip)    # 0x64701c
jne 0x14eaf9
leaq 0x3d40b6(%rip), %rdi    # 0x522ba2
movl %ebp, %esi
movl 0xc(%rsp), %edx
xorl %eax, %eax
callq 0x14d040
movq (%r12), %rax
movq %rax, 0x98(%rsp)
pushq $0x1
popq %r14
movq %rbx, 0x90(%rsp)
imulq $0x48, %r14, %r15
cmpq $0x0, (%r12,%r15)
je 0x14f0c0
addq %r12, %r15
cmpb $0x1, 0x4f84f2(%rip)    # 0x64701c
jne 0x14eb3e
movq 0x8(%r15), %rsi
leaq 0x3d4080(%rip), %rdi    # 0x522bb7
xorl %eax, %eax
callq 0x14d040
xorl %r9d, %r9d
xorl %eax, %eax
movq %r14, 0xa0(%rsp)
movq %r15, 0x28(%rsp)
cmpq 0xa8(%rsp), %rax
je 0x14f08b
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x10(%rsp)
addsd %xmm0, %xmm0
ucomisd 0x3d3f0b(%rip), %xmm0   # 0x522a80
movq %r9, 0x40(%rsp)
movq %rax, 0x50(%rsp)
jb 0x14eb87
sqrtsd %xmm0, %xmm0
jmp 0x14eb8c
callq 0x14d0f0
callq 0x14d1e0
movsd 0x3d3ec7(%rip), %xmm2   # 0x522a60
addsd %xmm2, %xmm0
movsd 0x3d3ec3(%rip), %xmm3   # 0x522a68
movapd %xmm3, %xmm1
maxsd %xmm0, %xmm1
movapd %xmm1, %xmm0
addsd %xmm2, %xmm0
mulsd %xmm1, %xmm0
mulsd 0x3d3eaf(%rip), %xmm0   # 0x522a70
movsd 0x10(%rsp), %xmm4
movapd %xmm4, %xmm2
subsd %xmm0, %xmm2
ucomisd %xmm1, %xmm2
jb 0x14ebdf
addsd %xmm1, %xmm0
addsd %xmm3, %xmm1
jmp 0x14ebc7
movl %ebp, %r13d
cvttsd2si %xmm2, %rax
movsd 0x3d3e89(%rip), %xmm0   # 0x522a78
subsd %xmm0, %xmm2
cvttsd2si %xmm2, %rcx
movq %rax, %rbp
sarq $0x3f, %rbp
andq %rcx, %rbp
orq %rax, %rbp
cvttsd2si %xmm1, %rax
subsd %xmm0, %xmm1
cvttsd2si %xmm1, %rcx
movq %rax, %r15
sarq $0x3f, %r15
andq %rcx, %r15
orq %rax, %r15
cmpb $0x1, 0x4f83f5(%rip)    # 0x64701c
jne 0x14ec42
leaq 0x3d3f8e(%rip), %rdi    # 0x522bbe
movq 0x50(%rsp), %rsi
movq %rbp, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x14d040
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq %rbp, 0x20(%rsp)
shlq $0x6, %rbp
movl 0x20(%rax,%rbp), %esi
movl %esi, 0x30(%rsp)
movq %r15, 0x10(%rsp)
shlq $0x6, %r15
movl 0x20(%rax,%r15), %ecx
movl %ecx, 0x38(%rsp)
movq 0x28(%rax,%rbp), %rdi
movq 0x28(%rax,%r15), %rdx
subq $0x8, %rsp
movl %r13d, %ebx
movl %r13d, %r8d
movl 0x14(%rsp), %r12d
movl %r12d, %r9d
movq 0x90(%rsp), %r13
pushq %r13
callq *0xa8(%rsp)
addq $0x10, %rsp
movq %rax, %r14
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x28(%rax,%rbp), %rdi
movl %ebx, %ebp
movq 0x28(%rax,%r15), %rdx
subq $0x8, %rsp
movl 0x38(%rsp), %esi
movl 0x40(%rsp), %ecx
movl %ebx, %r8d
movl %r12d, %r9d
pushq %r13
movq 0x38(%rsp), %r15
callq *(%r15)
addq $0x10, %rsp
movq %rax, %rbx
movq %r14, %r13
movl 0xc(%r14), %r10d
testl $0x80000020, %r10d      # imm = 0x80000020
movq 0x18(%rsp), %r14
je 0x14ed2d
movq 0x8(%r15), %rsi
subq $0x8, %rsp
leaq 0x3d3edb(%rip), %rdi    # 0x522bd7
movq 0x28(%rsp), %rdx
movq 0x18(%rsp), %rcx
movl %ebp, %r8d
movl %r12d, %r9d
xorl %eax, %eax
pushq $-0x7fffffe0            # imm = 0x80000020
pushq %r10
pushq %r14
callq 0x14d040
addq $0x20, %rsp
cmpb $0x1, 0x4f82f9(%rip)    # 0x647020
je 0x14f0db
movl 0xc(%rbx), %r10d
testl $0x80000020, %r10d      # imm = 0x80000020
je 0x14ed7e
movq 0x8(%r15), %rsi
subq $0x8, %rsp
leaq 0x3d3ec3(%rip), %rdi    # 0x522c0c
movq 0x28(%rsp), %rdx
movq 0x18(%rsp), %rcx
movl %ebp, %r8d
movl %r12d, %r9d
xorl %eax, %eax
pushq $-0x7fffffe0            # imm = 0x80000020
pushq %r10
pushq %r14
callq 0x14d040
addq $0x20, %rsp
cmpb $0x0, 0x4f82ac(%rip)    # 0x647020
jne 0x14f0db
movl 0xc(%rbx), %r10d
movl 0xc(%r13), %r11d
testb $0x1, %r11b
jne 0x14ed9c
testb $0x2, %r11b
jne 0x14eda4
testb $0x4, %r11b
je 0x14edae
movl %r10d, %eax
andl $0x4, %eax
jmp 0x14edaa
movl %r10d, %eax
andl $0x1, %eax
jmp 0x14edaa
movl %r10d, %eax
andl $0x2, %eax
testl %eax, %eax
jne 0x14eded
movq 0x8(%r15), %rsi
subq $0x8, %rsp
leaq 0x3d3e81(%rip), %rdi    # 0x522c3e
movq 0x28(%rsp), %rdx
movq 0x18(%rsp), %rcx
movl %ebp, %r8d
movl %r12d, %r9d
xorl %eax, %eax
pushq %r10
pushq %r11
pushq 0x30(%rsp)
callq 0x14d040
addq $0x20, %rsp
cmpb $0x1, 0x4f8239(%rip)    # 0x647020
je 0x14f0db
movq %rbx, %rdi
callq 0x150a2a
testl %eax, %eax
je 0x14ee16
movq %r13, %rdi
callq 0x14f995
movq %rbx, %rdi
callq 0x14f995
movq 0x40(%rsp), %r9
incq %r9
jmp 0x14f066
movl (%r13), %r10d
movl (%rbx), %r11d
cmpl %r11d, %r10d
je 0x14ee61
movq 0x8(%r15), %rsi
subq $0x8, %rsp
leaq 0x3d3e37(%rip), %rdi    # 0x522c68
movq 0x28(%rsp), %rdx
movq 0x18(%rsp), %rcx
movl %ebp, %r8d
movl %r12d, %r9d
xorl %eax, %eax
pushq %r11
pushq %r10
pushq 0x30(%rsp)
callq 0x14d040
addq $0x20, %rsp
cmpb $0x1, 0x4f81c5(%rip)    # 0x647020
je 0x14f0db
movl 0x4(%r13), %r10d
movl 0x4(%rbx), %r11d
cmpl %r11d, %r10d
je 0x14eeb3
movq 0x8(%r15), %rsi
movl (%rbx), %r15d
leaq 0x3d3e17(%rip), %rdi    # 0x522c93
movq 0x20(%rsp), %rdx
movq 0x10(%rsp), %rcx
movl %ebp, %r8d
movl %r12d, %r9d
xorl %eax, %eax
pushq %r15
movq 0x30(%rsp), %r15
pushq %r11
pushq %r10
pushq 0x30(%rsp)
callq 0x14d040
addq $0x20, %rsp
cmpb $0x1, 0x4f8173(%rip)    # 0x647020
je 0x14f0db
movl 0x8(%r13), %r10d
movl 0x8(%rbx), %r11d
cmpl %r11d, %r10d
je 0x14ef00
movq 0x8(%r15), %rsi
movl (%rbx), %r15d
leaq 0x3d3dfd(%rip), %rdi    # 0x522ccb
movq 0x20(%rsp), %rdx
movq 0x10(%rsp), %rcx
movl %ebp, %r8d
movl %r12d, %r9d
xorl %eax, %eax
pushq %r15
pushq %r11
pushq %r10
pushq 0x30(%rsp)
callq 0x14d040
addq $0x20, %rsp
cmpb $0x1, 0x4f8126(%rip)    # 0x647020
je 0x14f0db
movq %rbx, %rdi
callq 0x150b90
testl %eax, %eax
je 0x14f04c
movq %r13, %rdi
callq 0x150dac
movl %eax, %r14d
movq %r13, %rdi
callq 0x150e0d
movq %rax, 0x38(%rsp)
movq %r13, %rdi
callq 0x150e6f
movq %rax, 0x30(%rsp)
movq %rbx, %rdi
callq 0x150dac
movl %eax, %r12d
movq %rbx, %rdi
callq 0x150e0d
movl %eax, %r15d
movq %rbx, %rdi
callq 0x150e6f
movq %rax, 0x78(%rsp)
cmpl %r12d, %r14d
je 0x14efa3
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rsi
subq $0x8, %rsp
leaq 0x3d3d90(%rip), %rdi    # 0x522d01
movq 0x28(%rsp), %rdx
movq 0x18(%rsp), %rcx
movl %ebp, %r8d
movl 0x14(%rsp), %r9d
xorl %eax, %eax
pushq %r12
pushq %r14
pushq 0x30(%rsp)
callq 0x14d040
addq $0x20, %rsp
cmpb $0x1, 0x4f8083(%rip)    # 0x647020
je 0x14f0db
movq 0x38(%rsp), %r10
cmpl %r15d, %r10d
movq %r15, %r11
movl 0xc(%rsp), %r15d
je 0x14eff9
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rsi
subq $0x8, %rsp
leaq 0x3d3d65(%rip), %rdi    # 0x522d2e
movq 0x28(%rsp), %rdx
movq 0x18(%rsp), %rcx
movl %ebp, %r8d
movl %r15d, %r9d
xorl %eax, %eax
pushq %r11
pushq %r10
pushq 0x30(%rsp)
callq 0x14d040
addq $0x20, %rsp
cmpb $0x1, 0x4f802d(%rip)    # 0x647020
je 0x14f0db
movq 0x30(%rsp), %r10
movq 0x78(%rsp), %r11
cmpl %r11d, %r10d
je 0x14f04c
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rsi
subq $0x8, %rsp
leaq 0x3d3d3f(%rip), %rdi    # 0x522d5b
movq 0x28(%rsp), %rdx
movq 0x18(%rsp), %rcx
movl %ebp, %r8d
movl %r15d, %r9d
xorl %eax, %eax
pushq %r11
pushq %r10
pushq 0x30(%rsp)
callq 0x14d040
addq $0x20, %rsp
cmpb $0x1, 0x4f7fda(%rip)    # 0x647020
je 0x14f0db
movq %r13, %rdi
callq 0x14f995
movq %rbx, %rdi
callq 0x14f995
movq 0x28(%rsp), %r15
movq 0x40(%rsp), %r9
movq 0x50(%rsp), %rax
incq %rax
movq 0x80(%rsp), %r12
movq 0x90(%rsp), %rbx
movq 0xa0(%rsp), %r14
jmp 0x14eb50
testq %r9, %r9
setne %al
andb 0x4f7f85(%rip), %al     # 0x64701c
cmpb $0x1, %al
jne 0x14f0b8
movq 0x8(%r15), %rsi
leaq 0x3d3ce1(%rip), %rdi    # 0x522d87
movl %ebp, %edx
movl 0xc(%rsp), %ecx
movq 0x18(%rsp), %r8
xorl %eax, %eax
callq 0x14d040
incq %r14
jmp 0x14eb11
incq %rbx
cmpb $0x0, 0xb(%rsp)
je 0x14eaa0
movq 0x60(%rsp), %rcx
incq %rcx
jmp 0x14ea5d
pushq $0x1
popq %rdi
callq 0x14d170
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)