// File: /workspace/github_c_makefile_star2_O0/nh13[P]ksw/src/parasail/apps/parasail_aligner.cpp
// Function: output_graph(_IO_FILE*, int, 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&, std::vector<std::vector<std::pair<int, float>, std::allocator<std::pair<int, float>>>, std::allocator<std::vector<std::pair<int, float>, std::allocator<std::pair<int, float>>>>>&, unsigned long&, long long, long long)
inline static void output_graph(
        FILE *fop,
        int which,
        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,
        vector<vector<pair<int,float> > > &graph,
        unsigned long &edge_count,
        long long start,
        long long stop)
{
    if (NULL == fop) {
        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 (parasail_result_is_saturated(result)) {
                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_)) {
                float value;
                ++edge_count;
                switch (which) {
                    case 0:
                        value = 1.0*length/max_len;
                        break;
                    case 1:
                        value = 1.0*matches/length;
                        break;
                    case 2:
                        value = 1.0*score/self_score_;
                        break;
                }
                graph[i].push_back(make_pair(j,value));
                graph[j].push_back(make_pair(i,value));
            }
        }
    }
    else {
        fprintf(fop, "%lu %lu 1\n", (unsigned long)graph.size(), edge_count);
        for (size_t i=0; i<graph.size(); ++i) {
            if (graph[i].size() > 0) {
                fprintf(fop, "%d %f", graph[i][0].first+1, graph[i][0].second);
                for (size_t j=1; j<graph[i].size(); ++j) {
                    fprintf(fop, "  %d %f", graph[i][j].first+1, graph[i][j].second);
                }
                fprintf(fop, "\n");
            } else {
                fprintf(fop, "\n");
            }
        }
        fprintf(stdout, "%20s: %lu\n", "edges count", edge_count);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq 0x50(%rbp), %rax
movq 0x48(%rbp), %rax
movq 0x40(%rbp), %rax
movq 0x38(%rbp), %rax
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
xorl %eax, %eax
cmpq -0x8(%rbp), %rax
jne 0x2b5909
movq 0x48(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq 0x50(%rbp), %rax
jge 0x2b5904
movq 0x30(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x2bdca0
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq 0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x2bdcc0
movl (%rax), %eax
movl %eax, -0x3c(%rbp)
movq 0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x2bdcc0
movl 0x4(%rax), %eax
movl %eax, -0x40(%rbp)
movq 0x18(%rbp), %rdi
movslq -0x3c(%rbp), %rsi
callq 0x2bdce0
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movq 0x20(%rbp), %rdi
movslq -0x3c(%rbp), %rsi
callq 0x2bdce0
movq (%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
subq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
movq 0x18(%rbp), %rdi
movslq -0x40(%rbp), %rsi
callq 0x2bdce0
movq (%rax), %rax
movq %rax, -0x60(%rbp)
movq 0x20(%rbp), %rdi
movslq -0x40(%rbp), %rsi
callq 0x2bdce0
movq (%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
subq -0x60(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x38(%rbp), %rdi
callq 0x2daa80
cmpl $0x0, %eax
je 0x2b56e9
movq 0xcc5903(%rip), %rax    # 0xf7afd0
movq (%rax), %rdi
movl -0x3c(%rbp), %edx
movl -0x40(%rbp), %ecx
leaq 0xafa0bb(%rip), %rsi    # 0xdaf798
movb $0x0, %al
callq 0x2af440
jmp 0x2b58f3
movq -0x38(%rbp), %rdi
callq 0x2daf60
movl %eax, -0x74(%rbp)
movq -0x38(%rbp), %rdi
callq 0x2db080
movl %eax, -0x78(%rbp)
movq -0x38(%rbp), %rdi
callq 0x2db1c0
movl %eax, -0x7c(%rbp)
movl $0x0, -0x80(%rbp)
movl $0x0, -0x84(%rbp)
movq -0x18(%rbp), %rdi
addq -0x48(%rbp), %rdi
movq -0x58(%rbp), %rax
movl %eax, %esi
movq 0x10(%rbp), %rdx
callq 0x2b64d0
movl %eax, -0x88(%rbp)
movq -0x18(%rbp), %rdi
addq -0x60(%rbp), %rdi
movq -0x70(%rbp), %rax
movl %eax, %esi
movq 0x10(%rbp), %rdx
callq 0x2b64d0
movl %eax, -0x8c(%rbp)
movq -0x58(%rbp), %rax
cmpq -0x70(%rbp), %rax
jle 0x2b5777
movq -0x58(%rbp), %rax
movl %eax, -0x84(%rbp)
movl -0x88(%rbp), %eax
movl %eax, -0x80(%rbp)
jmp 0x2b578a
movq -0x70(%rbp), %rax
movl %eax, -0x84(%rbp)
movl -0x8c(%rbp), %eax
movl %eax, -0x80(%rbp)
imull $0x64, -0x7c(%rbp), %eax
movl -0x1c(%rbp), %ecx
imull -0x84(%rbp), %ecx
cmpl %ecx, %eax
jl 0x2b58f1
imull $0x64, -0x78(%rbp), %eax
movl -0x20(%rbp), %ecx
imull -0x7c(%rbp), %ecx
cmpl %ecx, %eax
jl 0x2b58f1
imull $0x64, -0x74(%rbp), %eax
movl -0x24(%rbp), %ecx
imull -0x80(%rbp), %ecx
cmpl %ecx, %eax
jl 0x2b58f1
movq 0x40(%rbp), %rax
movq (%rax), %rcx
incq %rcx
movq %rcx, (%rax)
movl -0xc(%rbp), %eax
movl %eax, -0xb4(%rbp)
testl %eax, %eax
je 0x2b57fc
jmp 0x2b57e2
movl -0xb4(%rbp), %eax
subl $0x1, %eax
je 0x2b5827
jmp 0x2b57ef
movl -0xb4(%rbp), %eax
subl $0x2, %eax
je 0x2b584f
jmp 0x2b5875
cvtsi2sdl -0x7c(%rbp), %xmm1
movsd 0xaf881f(%rip), %xmm0   # 0xdae028
mulsd %xmm1, %xmm0
cvtsi2sdl -0x84(%rbp), %xmm1
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x90(%rbp)
jmp 0x2b5875
cvtsi2sdl -0x78(%rbp), %xmm1
movsd 0xaf87f4(%rip), %xmm0   # 0xdae028
mulsd %xmm1, %xmm0
cvtsi2sdl -0x7c(%rbp), %xmm1
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x90(%rbp)
jmp 0x2b5875
cvtsi2sdl -0x74(%rbp), %xmm1
movsd 0xaf87cc(%rip), %xmm0   # 0xdae028
mulsd %xmm1, %xmm0
cvtsi2sdl -0x80(%rbp), %xmm1
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x90(%rbp)
movq 0x38(%rbp), %rdi
movslq -0x3c(%rbp), %rsi
callq 0x2bdd00
movq %rax, -0xc8(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x2bdd50
movq -0xc8(%rbp), %rdi
movq %rax, -0x98(%rbp)
leaq -0x98(%rbp), %rsi
callq 0x2bdd20
movq 0x38(%rbp), %rdi
movslq -0x40(%rbp), %rsi
callq 0x2bdd00
movq %rax, -0xc0(%rbp)
leaq -0x3c(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x2bdd50
movq -0xc0(%rbp), %rdi
movq %rax, -0xa0(%rbp)
leaq -0xa0(%rbp), %rsi
callq 0x2bdd20
jmp 0x2b58f3
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x2b5609
jmp 0x2b5b3d
movq -0x8(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq 0x38(%rbp), %rdi
callq 0x2bdd80
movq -0xd0(%rbp), %rdi
movq %rax, %rdx
movq 0x40(%rbp), %rax
movq (%rax), %rcx
leaq 0xaf9e80(%rip), %rsi    # 0xdaf7b5
movb $0x0, %al
callq 0x2af440
movq $0x0, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq 0x38(%rbp), %rdi
callq 0x2bdd80
movq %rax, %rcx
movq -0xd8(%rbp), %rax
cmpq %rcx, %rax
jae 0x2b5b17
movq 0x38(%rbp), %rdi
movq -0xa8(%rbp), %rsi
callq 0x2bdd00
movq %rax, %rdi
callq 0x2bddb0
cmpq $0x0, %rax
jbe 0x2b5aec
movq -0x8(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq 0x38(%rbp), %rdi
movq -0xa8(%rbp), %rsi
callq 0x2bdd00
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2bddd0
movl (%rax), %eax
addl $0x1, %eax
movl %eax, -0xdc(%rbp)
movq 0x38(%rbp), %rdi
movq -0xa8(%rbp), %rsi
callq 0x2bdd00
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2bddd0
movq -0xe8(%rbp), %rdi
movl -0xdc(%rbp), %edx
movss 0x4(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0xaf9dc4(%rip), %rsi    # 0xdaf7c2
movb $0x1, %al
callq 0x2af440
movq $0x1, -0xb0(%rbp)
movq -0xb0(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq 0x38(%rbp), %rdi
movq -0xa8(%rbp), %rsi
callq 0x2bdd00
movq %rax, %rdi
callq 0x2bddb0
movq %rax, %rcx
movq -0xf0(%rbp), %rax
cmpq %rcx, %rax
jae 0x2b5ad8
movq -0x8(%rbp), %rax
movq %rax, -0x100(%rbp)
movq 0x38(%rbp), %rdi
movq -0xa8(%rbp), %rsi
callq 0x2bdd00
movq %rax, %rdi
movq -0xb0(%rbp), %rsi
callq 0x2bddd0
movl (%rax), %eax
addl $0x1, %eax
movl %eax, -0xf4(%rbp)
movq 0x38(%rbp), %rdi
movq -0xa8(%rbp), %rsi
callq 0x2bdd00
movq %rax, %rdi
movq -0xb0(%rbp), %rsi
callq 0x2bddd0
movq -0x100(%rbp), %rdi
movl -0xf4(%rbp), %edx
movss 0x4(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0xaf9d06(%rip), %rsi    # 0xdaf7c0
movb $0x1, %al
callq 0x2af440
movq -0xb0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xb0(%rbp)
jmp 0x2b5a10
movq -0x8(%rbp), %rdi
leaq 0xaf96e7(%rip), %rsi    # 0xdaf1ca
movb $0x0, %al
callq 0x2af440
jmp 0x2b5afe
movq -0x8(%rbp), %rdi
leaq 0xaf96d3(%rip), %rsi    # 0xdaf1ca
movb $0x0, %al
callq 0x2af440
jmp 0x2b5b00
movq -0xa8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xa8(%rbp)
jmp 0x2b5947
movq 0xcc5482(%rip), %rax    # 0xf7afa0
movq (%rax), %rdi
movq 0x40(%rbp), %rax
movq (%rax), %rcx
leaq 0xaf8f47(%rip), %rsi    # 0xdaea76
leaq 0xaf9c92(%rip), %rdx    # 0xdaf7c8
movb $0x0, %al
callq 0x2af440
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
nopw %cs:(%rax,%rax)