// File: /workspace/github_c_makefile_star2_O0/nh13[P]ksw/src/parasail/apps/parasail_aligner.cpp
// Function: output_edges(_IO_FILE*, bool, long, unsigned char*, int, int, int, parasail_matrix const*, std::vector<long, std::allocator<long>> const&, std::vector<long, std::allocator<long>> const&, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int>>> const&, std::vector<parasail_result*, std::allocator<parasail_result*>> const&, long long, long long)
inline static void output_edges(
        FILE *fop,
        bool has_query,
        long sid_crossover,
        unsigned char *T,
        int AOL,
        int SIM,
        int OS,
        const parasail_matrix_t *matrix,
        const vector<long> &BEG,
        const vector<long> &END,
        const PairVec &vpairs,
        const vector<parasail_result_t*> &results,
        long long start,
        long long stop)
{
    unsigned long edge_count = 0;
    for (long long index=start; index<stop; ++index) {
        parasail_result_t *result = results[index];
        int i = vpairs[index].first;
        int j = vpairs[index].second;
        long i_beg = BEG[i];
        long i_end = END[i];
        long i_len = i_end-i_beg;
        long j_beg = BEG[j];
        long j_end = END[j];
        long j_len = j_end-j_beg;

        if (has_query) {
            i = i - sid_crossover;
        }

        if (parasail_result_is_saturated(result)) {
            if (has_query) {
                fprintf(stderr, "query %d and ref %d saturated\n", i, j);
            } else {
                fprintf(stderr, "seq %d and seq %d saturated\n", i, j);
            }
            continue;
        }

        int score = parasail_result_get_score(result);
        int matches = parasail_result_get_matches(result);
        int length = parasail_result_get_length(result);
        int self_score_ = 0;
        int max_len = 0;
        int i_self_score = self_score(
                (const char*)&T[i_beg], i_len, matrix);
        int j_self_score = self_score(
                (const char*)&T[j_beg], j_len, matrix);

        if (i_len > j_len) {
            max_len = i_len;
            self_score_ = i_self_score;
        }
        else {
            max_len = j_len;
            self_score_ = j_self_score;
        }

        if ((length * 100 >= AOL * int(max_len))
                && (matches * 100 >= SIM * length)
                && (score * 100 >= OS * self_score_)) {
            ++edge_count;
            fprintf(fop, "%d,%d,%f,%f,%f\n",
                    i, j,
                    1.0*length/max_len,
                    1.0*matches/length,
                    1.0*score/self_score_);
        }
    }

    fprintf(stdout, "%20s: %lu\n", "edges count", edge_count);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movb %sil, %al
movq 0x48(%rbp), %rsi
movq 0x40(%rbp), %rsi
movq 0x38(%rbp), %rsi
movq 0x30(%rbp), %rsi
movq 0x28(%rbp), %rsi
movq 0x20(%rbp), %rsi
movq 0x18(%rbp), %rsi
movl 0x10(%rbp), %esi
movq %rdi, -0x8(%rbp)
andb $0x1, %al
movb %al, -0x9(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movl %r9d, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq 0x40(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq 0x48(%rbp), %rax
jge 0x2b683c
movq 0x38(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x2bdca0
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movq 0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x2bdcc0
movl (%rax), %eax
movl %eax, -0x44(%rbp)
movq 0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x2bdcc0
movl 0x4(%rax), %eax
movl %eax, -0x48(%rbp)
movq 0x20(%rbp), %rdi
movslq -0x44(%rbp), %rsi
callq 0x2bdce0
movq (%rax), %rax
movq %rax, -0x50(%rbp)
movq 0x28(%rbp), %rdi
movslq -0x44(%rbp), %rsi
callq 0x2bdce0
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
subq -0x50(%rbp), %rax
movq %rax, -0x60(%rbp)
movq 0x20(%rbp), %rdi
movslq -0x48(%rbp), %rsi
callq 0x2bdce0
movq (%rax), %rax
movq %rax, -0x68(%rbp)
movq 0x28(%rbp), %rdi
movslq -0x48(%rbp), %rsi
callq 0x2bdce0
movq (%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
subq -0x68(%rbp), %rax
movq %rax, -0x78(%rbp)
testb $0x1, -0x9(%rbp)
je 0x2b6666
movslq -0x44(%rbp), %rax
subq -0x18(%rbp), %rax
movl %eax, -0x44(%rbp)
movq -0x40(%rbp), %rdi
callq 0x2daa80
cmpl $0x0, %eax
je 0x2b66bd
testb $0x1, -0x9(%rbp)
je 0x2b669a
movq 0xcc494f(%rip), %rax    # 0xf7afd0
movq (%rax), %rdi
movl -0x44(%rbp), %edx
movl -0x48(%rbp), %ecx
leaq 0xaf915d(%rip), %rsi    # 0xdaf7ee
movb $0x0, %al
callq 0x2af440
jmp 0x2b66b8
movq 0xcc492f(%rip), %rax    # 0xf7afd0
movq (%rax), %rdi
movl -0x44(%rbp), %edx
movl -0x48(%rbp), %ecx
leaq 0xaf90e7(%rip), %rsi    # 0xdaf798
movb $0x0, %al
callq 0x2af440
jmp 0x2b682b
movq -0x40(%rbp), %rdi
callq 0x2daf60
movl %eax, -0x7c(%rbp)
movq -0x40(%rbp), %rdi
callq 0x2db080
movl %eax, -0x80(%rbp)
movq -0x40(%rbp), %rdi
callq 0x2db1c0
movl %eax, -0x84(%rbp)
movl $0x0, -0x88(%rbp)
movl $0x0, -0x8c(%rbp)
movq -0x20(%rbp), %rdi
addq -0x50(%rbp), %rdi
movq -0x60(%rbp), %rax
movl %eax, %esi
movq 0x18(%rbp), %rdx
callq 0x2b64d0
movl %eax, -0x90(%rbp)
movq -0x20(%rbp), %rdi
addq -0x68(%rbp), %rdi
movq -0x78(%rbp), %rax
movl %eax, %esi
movq 0x18(%rbp), %rdx
callq 0x2b64d0
movl %eax, -0x94(%rbp)
movq -0x60(%rbp), %rax
cmpq -0x78(%rbp), %rax
jle 0x2b6754
movq -0x60(%rbp), %rax
movl %eax, -0x8c(%rbp)
movl -0x90(%rbp), %eax
movl %eax, -0x88(%rbp)
jmp 0x2b676a
movq -0x78(%rbp), %rax
movl %eax, -0x8c(%rbp)
movl -0x94(%rbp), %eax
movl %eax, -0x88(%rbp)
imull $0x64, -0x84(%rbp), %eax
movl -0x24(%rbp), %ecx
imull -0x8c(%rbp), %ecx
cmpl %ecx, %eax
jl 0x2b6829
imull $0x64, -0x80(%rbp), %eax
movl -0x28(%rbp), %ecx
imull -0x84(%rbp), %ecx
cmpl %ecx, %eax
jl 0x2b6829
imull $0x64, -0x7c(%rbp), %eax
movl 0x10(%rbp), %ecx
imull -0x88(%rbp), %ecx
cmpl %ecx, %eax
jl 0x2b6829
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movl -0x44(%rbp), %edx
movl -0x48(%rbp), %ecx
cvtsi2sdl -0x84(%rbp), %xmm1
movsd 0xaf7857(%rip), %xmm0   # 0xdae028
mulsd %xmm1, %xmm0
cvtsi2sdl -0x8c(%rbp), %xmm1
divsd %xmm1, %xmm0
cvtsi2sdl -0x80(%rbp), %xmm2
movsd 0xaf783a(%rip), %xmm1   # 0xdae028
mulsd %xmm2, %xmm1
cvtsi2sdl -0x84(%rbp), %xmm2
divsd %xmm2, %xmm1
cvtsi2sdl -0x7c(%rbp), %xmm3
movsd 0xaf781d(%rip), %xmm2   # 0xdae028
mulsd %xmm3, %xmm2
cvtsi2sdl -0x88(%rbp), %xmm3
divsd %xmm3, %xmm2
leaq 0xaf8feb(%rip), %rsi    # 0xdaf80d
movb $0x3, %al
callq 0x2af440
jmp 0x2b682b
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x2b65a6
movq 0xcc475d(%rip), %rax    # 0xf7afa0
movq (%rax), %rdi
movq -0x30(%rbp), %rcx
leaq 0xaf8225(%rip), %rsi    # 0xdaea76
leaq 0xaf8f70(%rip), %rdx    # 0xdaf7c8
movb $0x0, %al
callq 0x2af440
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax,%rax)