// File: /workspace/github_c_makefile_star2_O2/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, %r14
movq %rcx, %r13
movq %rdx, 0x50(%rsp)
movq %rsi, %r15
movq %rdi, %rsi
movq %r9, %r12
shrq $0x20, %r12
leaq 0xd0(%rsp), %rax
movq %r8, (%rax)
andq $0x0, 0x8(%rax)
testq %r8, %r8
leaq 0x4ce459(%rip), %rcx    # 0x5f8320
cmovneq %rax, %rcx
movq %rcx, 0x70(%rsp)
leaq 0x3d3c93(%rip), %rdi    # 0x4fdb6a
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x129040
movq %r14, 0x88(%rsp)
movl %r14d, %eax
negl %eax
setno %al
movl $0x80000000, %ecx       # imm = 0x80000000
movq %r12, 0x80(%rsp)
cmpq %rcx, %r12
setne %cl
andb %al, %cl
movb %cl, 0x27(%rsp)
testq %r13, %r13
cmovleq %rbx, %r13
movq %r13, 0xb8(%rsp)
xorl %ecx, %ecx
movq %r15, 0x98(%rsp)
movq 0x70(%rsp), %rax
movq (%rax,%rcx,8), %rax
testq %rax, %rax
je 0x12a3be
movq %rcx, 0x78(%rsp)
movq %rax, 0xa0(%rsp)
movq (%rax), %rax
movq %rax, 0x30(%rsp)
cmpb $0x1, 0x4e327c(%rip)    # 0x60d1cc
jne 0x129f65
leaq 0x3d3c46(%rip), %rdi    # 0x4fdb9f
movq 0x30(%rsp), %rsi
xorl %eax, %eax
callq 0x129040
xorl %ebx, %ebx
leaq 0x4d11a2(%rip), %rax    # 0x5fb110
movl (%rax,%rbx,8), %eax
movl %eax, %ecx
negl %ecx
jo 0x12a3b1
movq 0x88(%rsp), %rcx
movl %ecx, 0x2c(%rsp)
movq 0x80(%rsp), %rcx
movl %ecx, 0x28(%rsp)
cmpb $0x0, 0x27(%rsp)
jne 0x129fad
leaq 0x4d116f(%rip), %rcx    # 0x5fb110
movl 0x4(%rcx,%rbx,8), %ecx
movl %ecx, 0x28(%rsp)
movl %eax, 0x2c(%rsp)
cmpb $0x1, 0x4e3218(%rip)    # 0x60d1cc
jne 0x129fd0
movq 0x8(%r15), %rcx
leaq 0x3d3bc0(%rip), %rdi    # 0x4fdb81
movl 0x2c(%rsp), %esi
movl 0x28(%rsp), %edx
xorl %eax, %eax
callq 0x129040
movq (%r15), %rax
movq %rax, 0xb0(%rsp)
pushq $0x1
popq %r14
movq %rbx, 0xa8(%rsp)
imulq $0x48, %r14, %rax
cmpq $0x0, (%r15,%rax)
je 0x12a3a3
addq %r15, %rax
movq %rax, 0x40(%rsp)
cmpb $0x1, 0x4e31c7(%rip)    # 0x60d1cc
jne 0x12a01e
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rsi
leaq 0x3d3b86(%rip), %rdi    # 0x4fdb9d
xorl %eax, %eax
callq 0x129040
xorl %r13d, %r13d
xorl %r9d, %r9d
movq %r14, 0x58(%rsp)
cmpq 0xb8(%rsp), %r13
je 0x12a35e
cvtsi2sd %r13, %xmm0
movsd %xmm0, 0x38(%rsp)
addsd %xmm0, %xmm0
ucomisd 0x3d3a12(%rip), %xmm0   # 0x4fda60
movq %r9, 0x68(%rsp)
jb 0x12a05b
sqrtsd %xmm0, %xmm0
jmp 0x12a060
callq 0x1290f0
callq 0x1291e0
movsd 0x3d39d3(%rip), %xmm2   # 0x4fda40
addsd %xmm2, %xmm0
movsd 0x3d39cf(%rip), %xmm3   # 0x4fda48
movapd %xmm3, %xmm1
maxsd %xmm0, %xmm1
movapd %xmm1, %xmm0
addsd %xmm2, %xmm0
mulsd %xmm1, %xmm0
mulsd 0x3d39bb(%rip), %xmm0   # 0x4fda50
movsd 0x38(%rsp), %xmm4
movapd %xmm4, %xmm2
subsd %xmm0, %xmm2
ucomisd %xmm1, %xmm2
jb 0x12a0b3
addsd %xmm1, %xmm0
addsd %xmm3, %xmm1
jmp 0x12a09b
cvttsd2si %xmm2, %rax
movsd 0x3d3998(%rip), %xmm0   # 0x4fda58
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, %r14
sarq $0x3f, %r14
andq %rcx, %r14
orq %rax, %r14
movq 0x50(%rsp), %rax
movq (%rax), %rax
movq %rbx, %r15
shlq $0x6, %r15
movq 0x20(%rax,%r15), %rsi
movq %r14, %r12
shlq $0x6, %r12
movq 0x20(%rax,%r12), %rcx
cmpb $0x1, 0x4e30b4(%rip)    # 0x60d1cc
jne 0x12a149
leaq 0x3d3a83(%rip), %rdi    # 0x4fdba4
movq %rcx, 0x48(%rsp)
movq %rsi, %rbp
movq %r13, %rsi
movq %rbx, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x129040
movq %rbp, %rsi
movq 0x48(%rsp), %rcx
movq 0x50(%rsp), %rax
movq (%rax), %rax
movq %r14, 0x60(%rsp)
movq %rbx, 0xc0(%rsp)
movq %r13, 0xc8(%rsp)
movq 0x28(%rax,%r15), %rdi
movq 0x28(%rax,%r12), %rdx
movq 0xa0(%rsp), %rbp
movq %rbp, (%rsp)
movq %rsi, %rbx
movl 0x2c(%rsp), %r13d
movq %rcx, %r14
movl %r13d, %r8d
movl 0x28(%rsp), %r9d
callq *0xb0(%rsp)
movq %rax, 0x38(%rsp)
movq 0x50(%rsp), %rax
movq (%rax), %rax
movq 0x28(%rax,%r15), %rdi
movq 0x28(%rax,%r12), %rdx
movq %rbp, (%rsp)
movl %ebx, %esi
movq %r14, %r15
movl %r14d, %ecx
movl %r13d, %r8d
movl 0x28(%rsp), %r9d
movq 0x40(%rsp), %r14
callq *(%r14)
movq %rax, %r13
movq %rax, %rdi
callq 0x12bd0a
testl %eax, %eax
je 0x12a1f4
movq 0x38(%rsp), %rdi
callq 0x12ac75
movq %r13, %rdi
callq 0x12ac75
movq 0x68(%rsp), %r9
incq %r9
movq 0x58(%rsp), %r14
jmp 0x12a33e
movq %r15, 0x48(%rsp)
movq %rbx, 0x90(%rsp)
movq 0x38(%rsp), %rbx
movq %rbx, %rdi
callq 0x12c704
movq %rax, %r15
movq %r13, %rdi
callq 0x12c704
movq %rax, %rbp
movl (%rbx), %eax
movl (%r13), %ecx
cmpl %ecx, %eax
movq 0xc0(%rsp), %r8
je 0x12a276
movq 0x8(%r14), %rsi
movl %ecx, 0x10(%rsp)
movl %eax, 0x8(%rsp)
movq 0x30(%rsp), %rax
movq %rax, (%rsp)
leaq 0x3d3973(%rip), %rdi    # 0x4fdbbd
movq %r8, %rdx
movq 0x60(%rsp), %rcx
movq %r8, %r12
movl 0x2c(%rsp), %r8d
movl 0x28(%rsp), %r9d
xorl %eax, %eax
callq 0x129040
movq %r12, %r8
cmpb $0x1, 0x4e2f60(%rip)    # 0x60d1d0
je 0x12a3d0
movq 0x48(%rsp), %rsi
movq %rsi, %r12
movq 0x90(%rsp), %rdi
imulq %rdi, %r12
movl 0xc(%r13), %eax
movl %eax, %ecx
shrl $0x13, %ecx
testw $0xc00, %ax             # imm = 0xC00
setne %al
testb %al, %cl
jne 0x12a2b8
xorl %eax, %eax
cmpq %rax, %r12
je 0x12a324
movb (%r15,%rax), %cl
leaq 0x1(%rax), %rdx
cmpb (%rbp,%rax), %cl
movq %rdx, %rax
je 0x12a2a0
jmp 0x12a2e1
movq %r13, %rdx
movq %rbp, %rcx
movq %r8, %rbp
callq 0x1bb438
movq %rbp, %r8
xorl %ecx, %ecx
cmpq %rcx, %r12
je 0x12a31c
movsbl (%r15,%rcx), %edx
leaq 0x1(%rcx), %rsi
cmpl %edx, (%rax,%rcx,4)
movq %rsi, %rcx
je 0x12a2cb
movq 0x8(%r14), %rsi
movq 0x30(%rsp), %rax
movq %rax, (%rsp)
leaq 0x3d38f3(%rip), %rdi    # 0x4fdbe8
movq %r8, %rdx
movq 0x60(%rsp), %rcx
movl 0x2c(%rsp), %r8d
movl 0x28(%rsp), %r9d
xorl %eax, %eax
callq 0x129040
cmpb $0x1, 0x4e2ebb(%rip)    # 0x60d1d0
jne 0x12a324
jmp 0x12a3d0
movq %rax, %rdi
callq 0x129160
movq %rbx, %rdi
callq 0x12ac75
movq %r13, %rdi
callq 0x12ac75
movq 0x58(%rsp), %r14
movq 0x68(%rsp), %r9
movq 0xc8(%rsp), %r13
incq %r13
movq 0x98(%rsp), %r15
movq 0xa8(%rsp), %rbx
jmp 0x12a029
testq %r9, %r9
setne %al
andb 0x4e2e62(%rip), %al     # 0x60d1cc
cmpb $0x1, %al
jne 0x12a39b
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rsi
leaq 0x3d3890(%rip), %rdi    # 0x4fdc0e
movl 0x2c(%rsp), %edx
movl 0x28(%rsp), %ecx
movq 0x30(%rsp), %r8
xorl %eax, %eax
callq 0x129040
cmpb $0x1, 0x4e2e37(%rip)    # 0x60d1d0
je 0x12a3d0
incq %r14
jmp 0x129fe7
incq %rbx
cmpb $0x0, 0x27(%rsp)
je 0x129f67
movq 0x78(%rsp), %rcx
incq %rcx
jmp 0x129f22
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x1
popq %rdi
callq 0x129170