// File: /workspace/github_c_makefile_star2_O1/nh13[P]ksw/src/parasail/tests/test_verify_traces.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;
                    int8_t *ref_trace_table = NULL;
                    int *trace_table = 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_trace_table = parasail_result_get_trace_table(reference_result);
                    trace_table = parasail_result_get_trace_table(result);
                    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 (diff_array(size_a, size_b, ref_trace_table, trace_table, result)) {
#pragma omp critical(printer)
                        {
                            printf("%s(%lu,%lu,%d,%d,%s) bad trace table\n",
                                    functions[function_index].name,
                                    a, b, open, extend,
                                    matrixname);
                            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 (exit_on_mismatch) exit(EXIT_FAILURE);
                }
            }
            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, 0x58(%rsp)
movq %rcx, %r15
movq %rdx, 0x50(%rsp)
movq %rsi, 0x30(%rsp)
movq %rdi, %rsi
leaq 0xd0(%rsp), %rax
movq %r8, (%rax)
movq $0x0, 0x8(%rax)
testq %r8, %r8
leaq 0x4d92ce(%rip), %rbx    # 0x65e320
cmovneq %rax, %rbx
leaq 0x3a5b0d(%rip), %rdi    # 0x52ab6a
xorl %eax, %eax
callq 0x129040
movq %rbx, 0x88(%rsp)
movq (%rbx), %rcx
testq %rcx, %rcx
je 0x1855dc
movq 0x58(%rsp), %rax
movq %rax, %rdx
shrq $0x20, %rdx
negl %eax
setno %al
movq %rdx, 0xa0(%rsp)
cmpl $0x80000000, %edx       # imm = 0x80000000
setne %dl
andb %al, %dl
movb %dl, 0x1f(%rsp)
movq 0x30(%rsp), %rax
addq $0x48, %rax
movq %rax, 0x98(%rsp)
xorl %eax, %eax
movq %r15, 0x60(%rsp)
movq %rax, 0x90(%rsp)
movq %rcx, 0xa8(%rsp)
movq (%rcx), %rax
movq %rax, 0x38(%rsp)
cmpb $0x1, 0x4ee0f5(%rip)    # 0x6731cc
jne 0x1850ec
leaq 0x3a5abf(%rip), %rdi    # 0x52ab9f
movq 0x38(%rsp), %rsi
xorl %eax, %eax
callq 0x129040
movl 0x4dc01e(%rip), %eax    # 0x661110
movl %eax, %ecx
negl %ecx
jo 0x1855b8
leaq 0x4dc00d(%rip), %rcx    # 0x661110
xorl %ebx, %ebx
movq 0x58(%rsp), %rdx
movl %edx, 0x24(%rsp)
movq 0xa0(%rsp), %rdx
movl %edx, 0x20(%rsp)
cmpb $0x0, 0x1f(%rsp)
jne 0x18512c
movl 0x4(%rcx), %ecx
movl %ecx, 0x20(%rsp)
movl %eax, 0x24(%rsp)
cmpb $0x1, 0x4ee099(%rip)    # 0x6731cc
jne 0x185154
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rcx
leaq 0x3a5a3c(%rip), %rdi    # 0x52ab81
movl 0x24(%rsp), %esi
movl 0x20(%rsp), %edx
xorl %eax, %eax
callq 0x129040
movq 0x30(%rsp), %rax
cmpq $0x0, 0x48(%rax)
je 0x185593
movq 0x30(%rsp), %rax
movq (%rax), %rax
movq %rax, 0xb0(%rsp)
movl $0x1, %r14d
movq 0x98(%rsp), %rax
movq %rax, 0x28(%rsp)
movq %rbx, 0x68(%rsp)
cmpb $0x1, 0x4ee039(%rip)    # 0x6731cc
jne 0x1851ac
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rsi
leaq 0x3a59f8(%rip), %rdi    # 0x52ab9d
xorl %eax, %eax
callq 0x129040
xorl %r9d, %r9d
testq %r15, %r15
jle 0x185537
xorl %r13d, %r13d
movq %r14, 0xb8(%rsp)
cvtsi2sd %r13, %xmm0
movsd %xmm0, 0x40(%rsp)
addsd %xmm0, %xmm0
ucomisd 0x3a5886(%rip), %xmm0   # 0x52aa60
movq %r9, 0x78(%rsp)
jb 0x1851e7
sqrtsd %xmm0, %xmm0
jmp 0x1851ec
callq 0x1290f0
callq 0x1291e0
movsd 0x3a5847(%rip), %xmm2   # 0x52aa40
addsd %xmm2, %xmm0
movsd 0x3a5843(%rip), %xmm3   # 0x52aa48
movapd %xmm3, %xmm1
maxsd %xmm0, %xmm1
movapd %xmm1, %xmm0
addsd %xmm2, %xmm0
mulsd %xmm1, %xmm0
mulsd 0x3a582f(%rip), %xmm0   # 0x52aa50
movsd 0x40(%rsp), %xmm4
movapd %xmm4, %xmm2
subsd %xmm0, %xmm2
ucomisd %xmm1, %xmm2
jb 0x18523f
addsd %xmm1, %xmm0
addsd %xmm3, %xmm1
jmp 0x185227
cvttsd2si %xmm2, %rax
movsd 0x3a580c(%rip), %xmm0   # 0x52aa58
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 0x50(%rsp), %rax
movq (%rax), %rax
movq %r14, %rbx
shlq $0x6, %rbx
movq 0x20(%rax,%rbx), %rbp
movq %r15, %r12
shlq $0x6, %r12
movq 0x20(%rax,%r12), %rax
movq %rax, 0x40(%rsp)
cmpb $0x1, 0x4edf23(%rip)    # 0x6731cc
jne 0x1852c2
leaq 0x3a58f2(%rip), %rdi    # 0x52aba4
movq %r13, %rsi
movq %r14, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x129040
movq %r15, 0x70(%rsp)
movq %r14, 0xc0(%rsp)
movq %r13, 0xc8(%rsp)
movq 0x50(%rsp), %rax
movq (%rax), %rax
movq 0x28(%rax,%rbx), %rdi
movq 0x28(%rax,%r12), %rdx
movq 0xa8(%rsp), %r15
movq %r15, (%rsp)
movl %ebp, %esi
movq 0x40(%rsp), %r13
movl %r13d, %ecx
movl 0x24(%rsp), %r14d
movl %r14d, %r8d
movq %rbp, 0x80(%rsp)
movl 0x20(%rsp), %ebp
movl %ebp, %r9d
callq *0xb0(%rsp)
movq %rax, 0x48(%rsp)
movq 0x50(%rsp), %rax
movq (%rax), %rax
movq 0x28(%rax,%rbx), %rdi
movq 0x28(%rax,%r12), %rdx
movq %r15, (%rsp)
movq 0x80(%rsp), %rsi
movl %r13d, %ecx
movl %r14d, %r8d
movl %ebp, %r9d
movq 0x28(%rsp), %rax
callq *(%rax)
movq %rax, %rbx
movq %rax, %rdi
callq 0x186b65
testl %eax, %eax
je 0x185388
movq 0x48(%rsp), %rdi
callq 0x185cf9
movq %rbx, %rdi
callq 0x185cf9
movq 0x78(%rsp), %r9
incq %r9
movq 0x68(%rsp), %rbx
movq 0x60(%rsp), %r15
jmp 0x18551b
movq 0x48(%rsp), %r15
movq %r15, %rdi
callq 0x187002
movq %rax, %r13
movq %rbx, %rdi
callq 0x187002
movq %rax, %r12
movl (%r15), %eax
movl (%rbx), %ecx
cmpl %ecx, %eax
movq 0xc0(%rsp), %r8
movq 0x70(%rsp), %rbp
je 0x18540a
movq 0x28(%rsp), %rdx
movq 0x8(%rdx), %rsi
movl %ecx, 0x10(%rsp)
movl %eax, 0x8(%rsp)
movq 0x38(%rsp), %rax
movq %rax, (%rsp)
leaq 0x3a57e3(%rip), %rdi    # 0x52abbd
movq %r8, %rdx
movq %rbp, %rcx
movq %r15, %r14
movq %r8, %r15
movl 0x24(%rsp), %r8d
movl 0x20(%rsp), %r9d
xorl %eax, %eax
callq 0x129040
movq %r15, %r8
movq %r14, %r15
cmpb $0x1, 0x4eddcc(%rip)    # 0x6731d0
je 0x1855ee
movq %rbx, %rdx
movq 0x40(%rsp), %rsi
movq %rsi, %rbx
movq 0x80(%rsp), %rdi
imulq %rdi, %rbx
movl 0xc(%rdx), %eax
movl %eax, %ecx
shrl $0x13, %ecx
testl $0xc00, %eax            # imm = 0xC00
setne %al
testb %al, %cl
jne 0x18545b
movq %rdx, %rbp
testq %rbx, %rbx
je 0x1854fc
xorl %eax, %eax
movb (%r13,%rax), %cl
cmpb (%r12,%rax), %cl
jne 0x1854bd
incq %rax
cmpq %rax, %rbx
jne 0x185443
jmp 0x1854fc
movq %r8, %r14
movq %rdx, %rbp
movq %r12, %rcx
callq 0x215dc8
testq %rbx, %rbx
setne %r15b
je 0x1854a8
movsbl (%r13), %ecx
cmpl %ecx, (%rax)
movq %r14, %r8
jne 0x1854b3
leaq -0x1(%rbx), %rcx
xorl %edx, %edx
cmpq %rdx, %rcx
je 0x1854a5
movsbl 0x1(%r13,%rdx), %edi
leaq 0x1(%rdx), %rsi
cmpl %edi, 0x4(%rax,%rdx,4)
movq %rsi, %rdx
je 0x185484
cmpq %rbx, %rsi
setb %r15b
jmp 0x1854b3
xorl %r15d, %r15d
movq %rax, %rdi
callq 0x129160
movq %r14, %r8
testb %r15b, %r15b
movq 0x48(%rsp), %r15
je 0x1854fc
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rsi
movq 0x38(%rsp), %rax
movq %rax, (%rsp)
leaq 0x3a5712(%rip), %rdi    # 0x52abe8
movq %r8, %rdx
movq 0x70(%rsp), %rcx
movl 0x24(%rsp), %r8d
movl 0x20(%rsp), %r9d
xorl %eax, %eax
callq 0x129040
cmpb $0x1, 0x4edcda(%rip)    # 0x6731d0
je 0x1855ee
movq %r15, %rdi
callq 0x185cf9
movq %rbp, %rdi
callq 0x185cf9
movq 0x60(%rsp), %r15
movq 0x68(%rsp), %rbx
movq 0x78(%rsp), %r9
movq 0xc8(%rsp), %r13
incq %r13
cmpq %r15, %r13
movq 0xb8(%rsp), %r14
jne 0x1851c3
testq %r9, %r9
setne %al
andb 0x4edc89(%rip), %al     # 0x6731cc
cmpb $0x1, %al
jne 0x185574
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rsi
leaq 0x3a56b7(%rip), %rdi    # 0x52ac0e
movl 0x24(%rsp), %edx
movl 0x20(%rsp), %ecx
movq 0x38(%rsp), %r8
xorl %eax, %eax
callq 0x129040
cmpb $0x1, 0x4edc5e(%rip)    # 0x6731d0
je 0x1855ee
incq %r14
leaq (%r14,%r14,8), %rax
movq 0x30(%rsp), %rcx
leaq (%rcx,%rax,8), %rax
movq %rax, 0x28(%rsp)
cmpq $0x0, (%rax)
jne 0x18518c
cmpb $0x0, 0x1f(%rsp)
jne 0x1855b8
leaq 0x4dbb6f(%rip), %rax    # 0x661110
leaq (%rax,%rbx,8), %rcx
addq $0x8, %rcx
incq %rbx
movl (%rcx), %eax
movl %eax, %edx
negl %edx
jno 0x185105
movq 0x88(%rsp), %rax
movq 0x90(%rsp), %rdx
movq 0x8(%rax,%rdx,8), %rcx
movq %rdx, %rax
incq %rax
testq %rcx, %rcx
jne 0x1850b8
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %edi
callq 0x129170