// File: /workspace/github_c_makefile_star2_O3/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, 0x38(%rsp)
movq %rcx, 0x40(%rsp)
movq %rdx, 0x50(%rsp)
movq %rsi, %r12
movq %rdi, %rsi
leaq 0xc0(%rsp), %rax
movq %r8, (%rax)
movq $0x0, 0x8(%rax)
testq %r8, %r8
leaq 0x51089e(%rip), %r14    # 0x6ba320
cmovneq %rax, %r14
leaq 0x3d70fe(%rip), %rdi    # 0x580b8b
xorl %eax, %eax
callq 0x14d040
movq %r14, 0x60(%rsp)
movq (%r14), %rdx
testq %rdx, %rdx
je 0x1aa1d5
movq 0x38(%rsp), %rax
movq %rax, %rcx
shrq $0x20, %rcx
negl %eax
setno %al
movq %rcx, 0x78(%rsp)
cmpl $0x80000000, %ecx       # imm = 0x80000000
setne %cl
andb %al, %cl
movb %cl, 0xb(%rsp)
leaq 0x48(%r12), %rax
movq %rax, 0x70(%rsp)
movb 0x535542(%rip), %al     # 0x6df01c
movl %eax, %ecx
xorl %esi, %esi
movq %r12, 0x90(%rsp)
movq (%rdx), %r14
testb $0x1, %cl
movq %rdx, 0xa0(%rsp)
movq %rsi, 0x68(%rsp)
je 0x1a9b16
leaq 0x3d70b7(%rip), %rdi    # 0x580bb9
movq %r14, %rsi
xorl %eax, %eax
callq 0x14d040
movb 0x53550a(%rip), %al     # 0x6df01c
movl %eax, %ecx
jmp 0x1a9b18
xorl %ecx, %ecx
movl 0x5135f2(%rip), %esi    # 0x6bd110
movl %esi, %edx
negl %edx
jo 0x1aa1ba
movl %eax, %ecx
movl %eax, %edx
leaq 0x5135dd(%rip), %rdi    # 0x6bd110
xorl %r15d, %r15d
movq %r14, 0x98(%rsp)
movq 0x38(%rsp), %r8
movl %r8d, %ebp
movq 0x78(%rsp), %r8
movl %r8d, 0xc(%rsp)
cmpb $0x0, 0xb(%rsp)
jne 0x1a9b60
movl 0x4(%rdi), %edi
movl %edi, 0xc(%rsp)
movl %esi, %ebp
testb $0x1, %dl
je 0x1a9b85
leaq 0x3d7036(%rip), %rdi    # 0x580ba2
movl %ebp, %esi
movl 0xc(%rsp), %edx
xorl %eax, %eax
callq 0x14d040
movb 0x53549d(%rip), %al     # 0x6df01c
movl %eax, %ecx
movl %eax, %edx
jmp 0x1a9b87
xorl %edx, %edx
cmpq $0x0, 0x48(%r12)
je 0x1aa193
movq (%r12), %rax
movq %rax, 0xb0(%rsp)
movl $0x1, %r13d
movl %ecx, %eax
movq 0x70(%rsp), %rbx
movq %r15, 0xa8(%rsp)
testb $0x1, %al
je 0x1a9bca
movq 0x8(%rbx), %rsi
leaq 0x3d6ff4(%rip), %rdi    # 0x580bb7
xorl %eax, %eax
callq 0x14d040
cmpq $0x0, 0x40(%rsp)
jle 0x1aa16d
xorl %eax, %eax
xorl %r9d, %r9d
movq %rbx, 0x28(%rsp)
movq %r13, 0xb8(%rsp)
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x10(%rsp)
addsd %xmm0, %xmm0
ucomisd 0x3d6e81(%rip), %xmm0   # 0x580a80
movq %r9, 0x48(%rsp)
movq %rax, 0x58(%rsp)
jb 0x1a9c11
sqrtsd %xmm0, %xmm0
jmp 0x1a9c16
callq 0x14d0f0
callq 0x14d1e0
movsd 0x3d6e3d(%rip), %xmm2   # 0x580a60
addsd %xmm2, %xmm0
movsd 0x3d6e39(%rip), %xmm3   # 0x580a68
movapd %xmm3, %xmm1
maxsd %xmm0, %xmm1
movapd %xmm1, %xmm0
addsd %xmm2, %xmm0
mulsd %xmm1, %xmm0
mulsd 0x3d6e25(%rip), %xmm0   # 0x580a70
movsd 0x10(%rsp), %xmm4
movapd %xmm4, %xmm2
subsd %xmm0, %xmm2
ucomisd %xmm1, %xmm2
jb 0x1a9c69
addsd %xmm1, %xmm0
addsd %xmm3, %xmm1
jmp 0x1a9c51
cvttsd2si %xmm2, %rax
movsd 0x3d6e02(%rip), %xmm0   # 0x580a78
subsd %xmm0, %xmm2
cvttsd2si %xmm2, %rcx
movq %rax, %rbx
sarq $0x3f, %rbx
andq %rcx, %rbx
orq %rax, %rbx
cvttsd2si %xmm1, %rax
subsd %xmm0, %xmm1
cvttsd2si %xmm1, %rcx
movq %rax, %r15
sarq $0x3f, %r15
andq %rcx, %r15
orq %rax, %r15
cmpb $0x1, 0x53536e(%rip)    # 0x6df01c
jne 0x1a9cc9
leaq 0x3d6f07(%rip), %rdi    # 0x580bbe
movq 0x58(%rsp), %rsi
movq %rbx, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x14d040
movq 0x50(%rsp), %rax
movq (%rax), %rax
movq %rbx, %r12
shlq $0x6, %r12
movl 0x20(%rax,%r12), %esi
movl %esi, 0x30(%rsp)
movq %rbx, 0x20(%rsp)
movq %r15, 0x18(%rsp)
shlq $0x6, %r15
movl 0x20(%rax,%r15), %ecx
movl %ecx, 0x10(%rsp)
movq 0x28(%rax,%r12), %rdi
movq 0x28(%rax,%r15), %rdx
subq $0x8, %rsp
movl %ebp, %r8d
movl 0x14(%rsp), %ebx
movl %ebx, %r9d
movq 0xa8(%rsp), %r14
pushq %r14
callq *0xc0(%rsp)
addq $0x10, %rsp
movq %rax, %r13
movq 0x50(%rsp), %rax
movq (%rax), %rax
movq 0x28(%rax,%r12), %rdi
movq 0x28(%rax,%r15), %rdx
movq 0x20(%rsp), %r15
subq $0x8, %rsp
movl 0x38(%rsp), %esi
movl 0x18(%rsp), %ecx
movl %ebp, %r8d
movl %ebx, %r9d
pushq %r14
movq 0x38(%rsp), %r14
callq *(%r14)
addq $0x10, %rsp
movq %rax, %r12
movq %r13, 0x10(%rsp)
movl 0xc(%r13), %r10d
movl %ebp, %r13d
movl %ebx, %ebp
movq %r14, %rbx
testl $0x80000020, %r10d      # imm = 0x80000020
movq 0x98(%rsp), %r14
je 0x1a9dc2
movq 0x8(%rbx), %rsi
subq $0x8, %rsp
leaq 0x3d6e44(%rip), %rdi    # 0x580bd7
movq %r15, %rdx
movq 0x20(%rsp), %rcx
movl %r13d, %r8d
movl %ebp, %r9d
xorl %eax, %eax
pushq $-0x7fffffe0            # imm = 0x80000020
pushq %r10
pushq %r14
callq 0x14d040
addq $0x20, %rsp
cmpb $0x1, 0x535264(%rip)    # 0x6df020
je 0x1aa1e7
movl 0xc(%r12), %r10d
testl $0x80000020, %r10d      # imm = 0x80000020
je 0x1a9e13
movq 0x8(%rbx), %rsi
subq $0x8, %rsp
leaq 0x3d6e2d(%rip), %rdi    # 0x580c0c
movq %r15, %rdx
movq 0x20(%rsp), %rcx
movl %r13d, %r8d
movl %ebp, %r9d
xorl %eax, %eax
pushq $-0x7fffffe0            # imm = 0x80000020
pushq %r10
pushq %r14
callq 0x14d040
addq $0x20, %rsp
cmpb $0x0, 0x535218(%rip)    # 0x6df020
jne 0x1aa1e7
movl 0xc(%r12), %r10d
movq 0x10(%rsp), %rax
movl 0xc(%rax), %r11d
testb $0x1, %r11b
jne 0x1a9e36
testb $0x2, %r11b
jne 0x1a9e3e
testb $0x4, %r11b
je 0x1a9e48
movl %r10d, %eax
andl $0x4, %eax
jmp 0x1a9e44
movl %r10d, %eax
andl $0x1, %eax
jmp 0x1a9e44
movl %r10d, %eax
andl $0x2, %eax
testl %eax, %eax
jne 0x1a9e83
movq 0x8(%rbx), %rsi
subq $0x8, %rsp
leaq 0x3d6de7(%rip), %rdi    # 0x580c3e
movq %r15, %rdx
movq 0x20(%rsp), %rcx
movl %r13d, %r8d
movl %ebp, %r9d
xorl %eax, %eax
pushq %r10
pushq %r11
pushq %r14
callq 0x14d040
addq $0x20, %rsp
cmpb $0x1, 0x5351a3(%rip)    # 0x6df020
je 0x1aa1e7
movq %r12, %rdi
callq 0x1abc3a
testl %eax, %eax
je 0x1a9eb1
movl %r13d, %ebp
movq 0x10(%rsp), %rdi
callq 0x1aadc8
movq %r12, %rdi
callq 0x1aadc8
movq 0x48(%rsp), %r9
incq %r9
jmp 0x1aa114
movq 0x10(%rsp), %rax
movl (%rax), %r10d
movl (%r12), %r11d
cmpl %r11d, %r10d
je 0x1a9efd
movq 0x8(%rbx), %rsi
subq $0x8, %rsp
leaq 0x3d6d97(%rip), %rdi    # 0x580c68
movq %r15, %rdx
movq 0x20(%rsp), %rcx
movl %r13d, %r8d
movl %ebp, %r9d
xorl %eax, %eax
pushq %r11
pushq %r10
pushq %r14
callq 0x14d040
addq $0x20, %rsp
cmpb $0x1, 0x535129(%rip)    # 0x6df020
je 0x1aa1e7
movq 0x10(%rsp), %rax
movl 0x4(%rax), %r10d
movl 0x4(%r12), %r11d
cmpl %r11d, %r10d
je 0x1a9f4f
movq 0x8(%rbx), %rsi
movl (%r12), %r15d
leaq 0x3d6d74(%rip), %rdi    # 0x580c93
movq 0x20(%rsp), %rdx
movq 0x18(%rsp), %rcx
movl %r13d, %r8d
movl %ebp, %r9d
xorl %eax, %eax
pushq %r15
pushq %r11
pushq %r10
pushq %r14
callq 0x14d040
addq $0x20, %rsp
cmpb $0x1, 0x5350d7(%rip)    # 0x6df020
je 0x1aa1e7
movq 0x10(%rsp), %rax
movl 0x8(%rax), %r10d
movl 0x8(%r12), %r11d
cmpl %r11d, %r10d
je 0x1a9fa1
movq 0x8(%rbx), %rsi
movl (%r12), %r15d
leaq 0x3d6d5a(%rip), %rdi    # 0x580ccb
movq 0x20(%rsp), %rdx
movq 0x18(%rsp), %rcx
movl %r13d, %r8d
movl %ebp, %r9d
xorl %eax, %eax
pushq %r15
pushq %r11
pushq %r10
pushq %r14
callq 0x14d040
addq $0x20, %rsp
cmpb $0x1, 0x535085(%rip)    # 0x6df020
je 0x1aa1e7
movq %r12, %rdi
callq 0x1abcda
testl %eax, %eax
je 0x1aa0fa
movl %ebp, 0xc(%rsp)
movl %r13d, %ebx
movq 0x10(%rsp), %r13
movq %r13, %rdi
callq 0x1abdcd
movl %eax, %r15d
movq %r13, %rdi
callq 0x1abdf1
movq %rax, 0x30(%rsp)
movq %r13, %rdi
movl %ebx, %r13d
callq 0x1abe16
movq %rax, 0x88(%rsp)
movq %r12, %rdi
callq 0x1abdcd
movl %eax, %ebp
movq %r12, %rdi
callq 0x1abdf1
movl %eax, %ebx
movq %r12, %rdi
callq 0x1abe16
movq %rax, 0x80(%rsp)
cmpl %ebp, %r15d
je 0x1aa054
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rsi
subq $0x8, %rsp
leaq 0x3d6cdc(%rip), %rdi    # 0x580d01
movq 0x28(%rsp), %rdx
movq 0x20(%rsp), %rcx
movl %r13d, %r8d
movl 0x14(%rsp), %r9d
xorl %eax, %eax
pushq %rbp
pushq %r15
pushq %r14
callq 0x14d040
addq $0x20, %rsp
cmpb $0x1, 0x534fd2(%rip)    # 0x6df020
je 0x1aa1e7
movq 0x30(%rsp), %r10
cmpl %ebx, %r10d
movq %rbx, %r11
movq 0x28(%rsp), %rbx
movl 0xc(%rsp), %r15d
je 0x1aa0a8
movq 0x8(%rbx), %rsi
subq $0x8, %rsp
leaq 0x3d6cb4(%rip), %rdi    # 0x580d2e
movq 0x28(%rsp), %rdx
movq 0x20(%rsp), %rcx
movl %r13d, %r8d
movl %r15d, %r9d
xorl %eax, %eax
pushq %r11
pushq %r10
pushq %r14
callq 0x14d040
addq $0x20, %rsp
cmpb $0x1, 0x534f7e(%rip)    # 0x6df020
je 0x1aa1e7
movq 0x88(%rsp), %r10
movq 0x80(%rsp), %r11
cmpl %r11d, %r10d
je 0x1aa0fa
movq 0x8(%rbx), %rsi
subq $0x8, %rsp
leaq 0x3d6c8f(%rip), %rdi    # 0x580d5b
movq 0x28(%rsp), %rdx
movq 0x20(%rsp), %rcx
movl %r13d, %r8d
movl %r15d, %r9d
xorl %eax, %eax
pushq %r11
pushq %r10
pushq %r14
callq 0x14d040
addq $0x20, %rsp
cmpb $0x1, 0x534f2c(%rip)    # 0x6df020
je 0x1aa1e7
movl %r13d, %ebp
movq 0x10(%rsp), %rdi
callq 0x1aadc8
movq %r12, %rdi
callq 0x1aadc8
movq 0x48(%rsp), %r9
movq 0x58(%rsp), %rax
incq %rax
cmpq 0x40(%rsp), %rax
movq 0x90(%rsp), %r12
movq 0xa8(%rsp), %r15
movq 0xb8(%rsp), %r13
jne 0x1a9be8
movb 0x534ed7(%rip), %al     # 0x6df01c
testq %r9, %r9
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x1aa173
movq 0x8(%rbx), %rsi
leaq 0x3d6c2a(%rip), %rdi    # 0x580d87
movl %ebp, %edx
movl 0xc(%rsp), %ecx
movq %r14, %r8
xorl %eax, %eax
callq 0x14d040
movb 0x534ea9(%rip), %al     # 0x6df01c
incq %r13
leaq (,%r13,8), %rcx
addq %r13, %rcx
leaq (%r12,%rcx,8), %rbx
cmpq $0x0, (%rbx)
movl %eax, %ecx
movl %eax, %edx
jne 0x1a9bb4
cmpb $0x0, 0xb(%rsp)
jne 0x1aa1ba
leaq 0x512f6f(%rip), %rsi    # 0x6bd110
leaq (%rsi,%r15,8), %rdi
addq $0x8, %rdi
incq %r15
movl (%rdi), %esi
movl %esi, %r8d
negl %r8d
jno 0x1a9b3e
movq 0x60(%rsp), %rdx
movq 0x68(%rsp), %rsi
movq 0x8(%rdx,%rsi,8), %rdx
incq %rsi
testq %rdx, %rdx
jne 0x1a9ae6
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %edi
callq 0x14d170
nopl (%rax)