// File: /workspace/github_c_makefile_star2_O3/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, 0x68(%rsp)
movq %rcx, %r12
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %rsi
leaq 0xd0(%rsp), %rax
movq %r8, (%rax)
movq $0x0, 0x8(%rax)
testq %r8, %r8
leaq 0x50b339(%rip), %r15    # 0x690320
cmovneq %rax, %r15
leaq 0x3d6b78(%rip), %rdi    # 0x55bb6a
xorl %eax, %eax
callq 0x129040
movq %r15, 0x98(%rsp)
movq (%r15), %rdx
testq %rdx, %rdx
je 0x185571
movq 0x68(%rsp), %rax
movq %rax, %rcx
shrq $0x20, %rcx
negl %eax
setno %al
movq %rcx, 0xb0(%rsp)
cmpl $0x80000000, %ecx       # imm = 0x80000000
setne %cl
andb %al, %cl
movb %cl, 0x27(%rsp)
leaq 0x48(%r14), %rax
movq %rax, 0xa8(%rsp)
movb 0x520185(%rip), %al     # 0x6a51cc
movl %eax, %ecx
xorl %esi, %esi
movq %r14, 0xb8(%rsp)
movq %r12, 0x70(%rsp)
movq %rbx, 0x60(%rsp)
movq %rdx, 0xc0(%rsp)
movq (%rdx), %rdx
testb $0x1, %cl
movq %rdx, 0x40(%rsp)
movq %rsi, 0xa0(%rsp)
je 0x185095
movq %rdx, %rsi
leaq 0x3d6b1b(%rip), %rdi    # 0x55bb9f
xorl %eax, %eax
callq 0x129040
movb 0x52013b(%rip), %al     # 0x6a51cc
movl %eax, %ecx
jmp 0x185097
xorl %ecx, %ecx
movl 0x50e073(%rip), %esi    # 0x693110
movl %esi, %edx
negl %edx
jo 0x185550
movl %eax, %ecx
movl %eax, %edx
leaq 0x50e05e(%rip), %rdi    # 0x693110
xorl %r15d, %r15d
movq 0x68(%rsp), %r8
movl %r8d, 0x2c(%rsp)
movq 0xb0(%rsp), %r8
movl %r8d, 0x28(%rsp)
cmpb $0x0, 0x27(%rsp)
jne 0x1850de
movl 0x4(%rdi), %edi
movl %edi, 0x28(%rsp)
movl %esi, 0x2c(%rsp)
testb $0x1, %dl
je 0x185109
movq 0x8(%r14), %rcx
leaq 0x3d6a93(%rip), %rdi    # 0x55bb81
movl 0x2c(%rsp), %esi
movl 0x28(%rsp), %edx
xorl %eax, %eax
callq 0x129040
movb 0x5200c9(%rip), %al     # 0x6a51cc
movl %eax, %ecx
movl %eax, %edx
jmp 0x18510b
xorl %edx, %edx
cmpq $0x0, 0x48(%r14)
je 0x185529
movq (%r14), %rax
movq %rax, 0xc8(%rsp)
movl $0x1, %r13d
movl %ecx, %eax
movq 0xa8(%rsp), %rcx
movq %rcx, 0x30(%rsp)
movq %r15, 0x78(%rsp)
testb $0x1, %al
je 0x185156
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rsi
leaq 0x3d6a4e(%rip), %rdi    # 0x55bb9d
xorl %eax, %eax
callq 0x129040
testq %r12, %r12
jle 0x1854fe
xorl %r9d, %r9d
xorl %ebp, %ebp
movq %r13, 0x48(%rsp)
cvtsi2sd %rbp, %xmm0
movsd %xmm0, 0x38(%rsp)
addsd %xmm0, %xmm0
ucomisd 0x3d68e0(%rip), %xmm0   # 0x55ba60
movq %r9, 0x90(%rsp)
jb 0x185190
sqrtsd %xmm0, %xmm0
jmp 0x185195
callq 0x1290f0
callq 0x1291e0
movsd 0x3d689e(%rip), %xmm2   # 0x55ba40
addsd %xmm2, %xmm0
movsd 0x3d689a(%rip), %xmm3   # 0x55ba48
movapd %xmm3, %xmm1
maxsd %xmm0, %xmm1
movapd %xmm1, %xmm0
addsd %xmm2, %xmm0
mulsd %xmm1, %xmm0
mulsd 0x3d6886(%rip), %xmm0   # 0x55ba50
movsd 0x38(%rsp), %xmm4
movapd %xmm4, %xmm2
subsd %xmm0, %xmm2
ucomisd %xmm1, %xmm2
jb 0x1851e8
addsd %xmm1, %xmm0
addsd %xmm3, %xmm1
jmp 0x1851d0
cvttsd2si %xmm2, %rax
movsd 0x3d6863(%rip), %xmm0   # 0x55ba58
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, %r13
sarq $0x3f, %r13
andq %rcx, %r13
orq %rax, %r13
movq (%rbx), %rax
movq %r14, %rbx
shlq $0x6, %rbx
movq 0x20(%rax,%rbx), %r12
movq %r13, %r15
shlq $0x6, %r15
movq 0x20(%rax,%r15), %rcx
movq %rcx, 0x38(%rsp)
cmpb $0x1, 0x51ff7f(%rip)    # 0x6a51cc
jne 0x18526e
leaq 0x3d694e(%rip), %rdi    # 0x55bba4
movq %rbp, %rsi
movq %r14, %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x129040
movq 0x60(%rsp), %rax
movq (%rax), %rax
movq %r13, 0x80(%rsp)
movq %r14, 0x88(%rsp)
movq %rbp, 0x50(%rsp)
movq 0x28(%rax,%rbx), %rdi
movq 0x28(%rax,%r15), %rdx
movq 0xc0(%rsp), %r13
movq %r13, (%rsp)
movl %r12d, %esi
movq 0x38(%rsp), %rcx
movl 0x2c(%rsp), %r14d
movl %r14d, %r8d
movl 0x28(%rsp), %ebp
movl %ebp, %r9d
callq *0xc8(%rsp)
movq %rax, 0x58(%rsp)
movq 0x60(%rsp), %rax
movq (%rax), %rax
movq 0x28(%rax,%rbx), %rdi
movq 0x28(%rax,%r15), %rdx
movq %r13, (%rsp)
movl %r12d, %esi
movq 0x38(%rsp), %rcx
movl %r14d, %r8d
movl %ebp, %r9d
movq 0x30(%rsp), %rax
callq *(%rax)
movq %rax, %rbp
movq %rax, %rdi
callq 0x186fd6
testl %eax, %eax
je 0x18532c
movq 0x58(%rsp), %rdi
callq 0x186164
movq %rbp, %rdi
callq 0x186164
movq 0x90(%rsp), %r9
incq %r9
movq 0x78(%rsp), %r15
movq 0x70(%rsp), %r12
movq 0x48(%rsp), %r13
movq 0x50(%rsp), %rbp
jmp 0x1854a1
movq %r12, %r13
movq 0x58(%rsp), %r14
movq %r14, %rdi
callq 0x187442
movq %rax, %rbx
movq %rbp, %rdi
callq 0x187442
movq %rax, %r12
movl (%r14), %eax
movl (%rbp), %ecx
cmpl %ecx, %eax
movq 0x88(%rsp), %r15
je 0x1853a6
movq 0x30(%rsp), %rdx
movq 0x8(%rdx), %rsi
movl %ecx, 0x10(%rsp)
movl %eax, 0x8(%rsp)
movq 0x40(%rsp), %rax
movq %rax, (%rsp)
leaq 0x3d6840(%rip), %rdi    # 0x55bbbd
movq %r15, %rdx
movq 0x80(%rsp), %rcx
movl 0x2c(%rsp), %r8d
movl 0x28(%rsp), %r9d
xorl %eax, %eax
callq 0x129040
cmpb $0x1, 0x51fe30(%rip)    # 0x6a51d0
je 0x185583
movq 0x38(%rsp), %rsi
movq %rsi, %r15
imulq %r13, %r15
movl 0xc(%rbp), %eax
movl %eax, %ecx
shrl $0x13, %ecx
testl $0xc00, %eax            # imm = 0xC00
setne %al
testb %al, %cl
jne 0x1853f9
movq %rbp, %r14
testq %r15, %r15
movq 0x40(%rsp), %rdi
movq 0x50(%rsp), %rbp
movq 0x48(%rsp), %r13
je 0x18547d
xorl %eax, %eax
movb (%rbx,%rax), %cl
cmpb (%r12,%rax), %cl
jne 0x18543b
incq %rax
cmpq %rax, %r15
jne 0x1853e3
jmp 0x18547d
movl %r13d, %edi
movq %rbp, %r14
movq %rbp, %rdx
movq %r12, %rcx
callq 0x216168
testq %r15, %r15
movq 0x40(%rsp), %rdi
movq 0x50(%rsp), %rbp
movq 0x48(%rsp), %r13
je 0x185431
xorl %ecx, %ecx
movsbl (%rbx,%rcx), %edx
cmpl %edx, (%rax,%rcx,4)
jne 0x18543b
incq %rcx
cmpq %rcx, %r15
jne 0x185420
movq %rax, %rdi
callq 0x129160
jmp 0x18547d
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rsi
movq %rdi, (%rsp)
leaq 0x3d6799(%rip), %rdi    # 0x55bbe8
movq 0x88(%rsp), %rdx
movq 0x80(%rsp), %rcx
movl 0x2c(%rsp), %r8d
movl 0x28(%rsp), %r9d
xorl %eax, %eax
callq 0x129040
cmpb $0x1, 0x51fd59(%rip)    # 0x6a51d0
je 0x185583
movq 0x58(%rsp), %rdi
callq 0x186164
movq %r14, %rdi
callq 0x186164
movq 0x70(%rsp), %r12
movq 0x78(%rsp), %r15
movq 0x90(%rsp), %r9
incq %rbp
cmpq %r12, %rbp
movq 0x60(%rsp), %rbx
movq 0xb8(%rsp), %r14
jne 0x185169
movb 0x51fd0c(%rip), %al     # 0x6a51cc
testq %r9, %r9
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x185504
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rsi
leaq 0x3d6731(%rip), %rdi    # 0x55bc0e
movl 0x2c(%rsp), %edx
movl 0x28(%rsp), %ecx
movq 0x40(%rsp), %r8
xorl %eax, %eax
callq 0x129040
cmpb $0x1, 0x51fcd8(%rip)    # 0x6a51d0
je 0x185583
movb 0x51fcc8(%rip), %al     # 0x6a51cc
incq %r13
leaq (,%r13,8), %rcx
addq %r13, %rcx
leaq (%r14,%rcx,8), %rcx
movq %rcx, 0x30(%rsp)
cmpq $0x0, (%rcx)
movl %eax, %ecx
movl %eax, %edx
jne 0x18513b
cmpb $0x0, 0x27(%rsp)
jne 0x185550
leaq 0x50dbd9(%rip), %rsi    # 0x693110
leaq (%rsi,%r15,8), %rdi
addq $0x8, %rdi
incq %r15
movl (%rdi), %esi
movl %esi, %r8d
negl %r8d
jno 0x1850b5
movq 0x98(%rsp), %rdx
movq 0xa0(%rsp), %rsi
movq 0x8(%rdx,%rsi,8), %rdx
incq %rsi
testq %rdx, %rdx
jne 0x18505d
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %edi
callq 0x129170
nopl (%rax)