// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x10(%rbp)
movq %rsi, -0x8(%rbp)
movq %r9, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x60(%rbp)
movq $0x0, -0x68(%rbp)
leaq 0xb9628e(%rip), %rax    # 0xcc0480
movq %rax, -0x70(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x80(%rbp)
movq $0x0, -0x78(%rbp)
xorl %eax, %eax
cmpq -0x30(%rbp), %rax
je 0x12a216
leaq -0x80(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rsi
leaq 0xacfa1e(%rip), %rdi    # 0xbf9c3f
movb $0x0, %al
callq 0x129040
movq $0x0, -0x40(%rbp)
movq -0x70(%rbp), %rcx
movq -0x40(%rbp), %rdx
xorl %eax, %eax
cmpq (%rcx,%rdx,8), %rax
je 0x12a791
movq -0x70(%rbp), %rax
movq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x90(%rbp)
cmpl $0x0, 0xba86fd(%rip)    # 0xcd296c
je 0x12a286
movq -0x90(%rbp), %rsi
leaq 0xacf9f5(%rip), %rdi    # 0xbf9c74
movb $0x0, %al
callq 0x129040
movq $0x0, -0x48(%rbp)
movq -0x48(%rbp), %rdx
movl $0x80000000, %eax       # imm = 0x80000000
leaq 0xb95e72(%rip), %rcx    # 0xcc0110
cmpl (%rcx,%rdx,8), %eax
je 0x12a77e
movq -0x48(%rbp), %rcx
leaq 0xb95e5e(%rip), %rax    # 0xcc0110
movl (%rax,%rcx,8), %eax
movl %eax, -0x94(%rbp)
movq -0x48(%rbp), %rcx
leaq 0xb95e4a(%rip), %rax    # 0xcc0110
movl 0x4(%rax,%rcx,8), %eax
movl %eax, -0x98(%rbp)
cmpl $0x80000000, -0x18(%rbp) # imm = 0x80000000
je 0x12a2f4
cmpl $0x80000000, -0x14(%rbp) # imm = 0x80000000
je 0x12a2f4
movl -0x18(%rbp), %eax
movl %eax, -0x94(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x98(%rbp)
cmpl $0x0, 0xba8671(%rip)    # 0xcd296c
je 0x12a31f
movl -0x94(%rbp), %esi
movl -0x98(%rbp), %edx
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rcx
leaq 0xacf93e(%rip), %rdi    # 0xbf9c56
movb $0x0, %al
callq 0x129040
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x68(%rbp)
movq $0x1, -0x50(%rbp)
movq -0x38(%rbp), %rcx
imulq $0x48, -0x50(%rbp), %rax
addq %rax, %rcx
xorl %eax, %eax
cmpq (%rcx), %rax
je 0x12a757
movq $0x0, -0xa0(%rbp)
cmpl $0x0, 0xba8611(%rip)    # 0xcd296c
je 0x12a37b
movq -0x38(%rbp), %rax
imulq $0x48, -0x50(%rbp), %rcx
addq %rcx, %rax
movq 0x8(%rax), %rsi
leaq 0xacf8fe(%rip), %rdi    # 0xbf9c72
movb $0x0, %al
callq 0x129040
movq $0x0, -0x58(%rbp)
movq -0x58(%rbp), %rax
cmpq -0x60(%rbp), %rax
jge 0x12a6e4
movq $0x0, -0xa8(%rbp)
movq $0x0, -0xb0(%rbp)
movq $0x0, -0xb8(%rbp)
movq $0x1, -0xc0(%rbp)
movq $0x0, -0xc8(%rbp)
movq $0x0, -0xd0(%rbp)
movq $0x0, -0xd8(%rbp)
movq $0x0, -0xe0(%rbp)
movq -0x58(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
leaq -0xc0(%rbp), %rdx
callq 0x12a7a0
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq -0xb8(%rbp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movq 0x20(%rax), %rax
movq %rax, -0xd8(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq -0xc0(%rbp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movq 0x20(%rax), %rax
movq %rax, -0xe0(%rbp)
cmpl $0x0, 0xba8525(%rip)    # 0xcd296c
je 0x12a469
movq -0x58(%rbp), %rsi
movq -0xb8(%rbp), %rdx
movq -0xc0(%rbp), %rcx
leaq 0xacf817(%rip), %rdi    # 0xbf9c79
movb $0x0, %al
callq 0x129040
movq -0x68(%rbp), %rax
movq -0x20(%rbp), %rcx
movq (%rcx), %rcx
movq -0xb8(%rbp), %rdx
shlq $0x6, %rdx
addq %rdx, %rcx
movq 0x28(%rcx), %rdi
movq -0xd8(%rbp), %rcx
movl %ecx, %esi
movq -0x20(%rbp), %rcx
movq (%rcx), %rcx
movq -0xc0(%rbp), %rdx
shlq $0x6, %rdx
addq %rdx, %rcx
movq 0x28(%rcx), %rdx
movq -0xe0(%rbp), %rcx
movl -0x94(%rbp), %r8d
movl -0x98(%rbp), %r9d
movq -0x88(%rbp), %r10
movq %r10, (%rsp)
callq *%rax
movq %rax, -0xa8(%rbp)
movq -0x38(%rbp), %rax
imulq $0x48, -0x50(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
movq -0x20(%rbp), %rcx
movq (%rcx), %rcx
movq -0xb8(%rbp), %rdx
shlq $0x6, %rdx
addq %rdx, %rcx
movq 0x28(%rcx), %rdi
movq -0xd8(%rbp), %rcx
movl %ecx, %esi
movq -0x20(%rbp), %rcx
movq (%rcx), %rcx
movq -0xc0(%rbp), %rdx
shlq $0x6, %rdx
addq %rdx, %rcx
movq 0x28(%rcx), %rdx
movq -0xe0(%rbp), %rcx
movl -0x94(%rbp), %r8d
movl -0x98(%rbp), %r9d
movq -0x88(%rbp), %r10
movq %r10, (%rsp)
callq *%rax
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rdi
callq 0x12dde0
cmpl $0x0, %eax
je 0x12a584
movq -0xa8(%rbp), %rdi
callq 0x12bfe0
movq -0xb0(%rbp), %rdi
callq 0x12bfe0
movq -0xa0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xa0(%rbp)
jmp 0x12a6d3
movq -0xa8(%rbp), %rdi
callq 0x12eec0
movq %rax, -0xc8(%rbp)
movq -0xb0(%rbp), %rdi
callq 0x12eec0
movq %rax, -0xd0(%rbp)
movq -0xa8(%rbp), %rax
movl (%rax), %eax
movq -0xb0(%rbp), %rcx
cmpl (%rcx), %eax
je 0x12a634
movq -0x38(%rbp), %rax
imulq $0x48, -0x50(%rbp), %rcx
addq %rcx, %rax
movq 0x8(%rax), %rsi
movq -0xb8(%rbp), %rdx
movq -0xc0(%rbp), %rcx
movl -0x94(%rbp), %r8d
movl -0x98(%rbp), %r9d
movq -0x90(%rbp), %r11
movq -0xa8(%rbp), %rax
movl (%rax), %r10d
movq -0xb0(%rbp), %rax
movl (%rax), %eax
leaq 0xacf687(%rip), %rdi    # 0xbf9c92
movq %r11, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movb $0x0, %al
callq 0x129040
cmpl $0x0, 0xba834a(%rip)    # 0xcd2970
je 0x12a632
movl $0x1, %edi
callq 0x129150
jmp 0x12a634
movq -0xd8(%rbp), %rdi
movq -0xe0(%rbp), %rsi
movq -0xc8(%rbp), %rdx
movq -0xd0(%rbp), %rcx
movq -0xb0(%rbp), %r8
callq 0x12a930
cmpl $0x0, %eax
je 0x12a6bb
movq -0x38(%rbp), %rax
imulq $0x48, -0x50(%rbp), %rcx
addq %rcx, %rax
movq 0x8(%rax), %rsi
movq -0xb8(%rbp), %rdx
movq -0xc0(%rbp), %rcx
movl -0x94(%rbp), %r8d
movl -0x98(%rbp), %r9d
movq -0x90(%rbp), %rax
leaq 0xacf622(%rip), %rdi    # 0xbf9cbd
movq %rax, (%rsp)
movb $0x0, %al
callq 0x129040
cmpl $0x0, 0xba82c3(%rip)    # 0xcd2970
je 0x12a6b9
movl $0x1, %edi
callq 0x129150
jmp 0x12a6bb
movq -0xa8(%rbp), %rdi
callq 0x12bfe0
movq -0xb0(%rbp), %rdi
callq 0x12bfe0
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x12a383
cmpl $0x0, 0xba8281(%rip)    # 0xcd296c
je 0x12a744
cmpq $0x0, -0xa0(%rbp)
je 0x12a744
movq -0x38(%rbp), %rax
imulq $0x48, -0x50(%rbp), %rcx
addq %rcx, %rax
movq 0x8(%rax), %rsi
movl -0x94(%rbp), %edx
movl -0x98(%rbp), %ecx
movq -0x90(%rbp), %r8
movq -0xa0(%rbp), %r9
leaq 0xacf5bb(%rip), %rdi    # 0xbf9ce3
movb $0x0, %al
callq 0x129040
cmpl $0x0, 0xba823a(%rip)    # 0xcd2970
je 0x12a742
movl $0x1, %edi
callq 0x129150
jmp 0x12a744
jmp 0x12a746
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x12a332
cmpl $0x80000000, -0x18(%rbp) # imm = 0x80000000
je 0x12a76b
cmpl $0x80000000, -0x14(%rbp) # imm = 0x80000000
je 0x12a76b
jmp 0x12a77e
jmp 0x12a76d
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x12a28e
jmp 0x12a780
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x12a230
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
nopw (%rax,%rax)