// File: kingufl[P]Rmapper/src/buildgraph.cpp
// Function: extract_bilabels(int, int, int, std::vector<int, std::allocator<int>>&, std::vector<int, std::allocator<int>>&, int, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int)
vector<bilabel> extract_bilabels(int kmer_size, int dsize, int start_locus, vector<int>& temp, vector<int>& temp_sum, int orientation, int chromosome, string rmapname,int rmap_id){

    vector<bilabel> retvar;
    int locus=start_locus;

    for(int i=0;i<temp.size()-(2*kmer_size+3)+1;i++){

        bilabel tembi;

        tembi.rmap_from=rmapname;
        tembi.rmap_id=rmap_id;
        tembi.i_rmap=i;
        tembi.chromosome=chromosome;
        tembi.locus=locus;
        tembi.orientation=orientation;

        int k1_end=i+kmer_size-1;
        int p_rmap=k1_end+1;
        int q_rmap=p_rmap;

        if(i>0)
            tembi.sums[0]=temp_sum[k1_end]-temp_sum[i-1];
        else
            tembi.sums[0]=temp_sum[k1_end];


        while(temp_sum[q_rmap]-temp_sum[k1_end]<dsize){
            q_rmap++;
            if(q_rmap+kmer_size>=temp.size())
                return(retvar);
        }

        tembi.sums[1]=temp_sum[q_rmap]-temp_sum[k1_end];
        tembi.q_rmap=q_rmap;
        tembi.sums[2]=temp_sum[q_rmap+kmer_size]-temp_sum[q_rmap];
        locus+=(temp[i]);

        point_t thisbib=uncover_frags(kmer_size,tembi.i_rmap,tembi.q_rmap, temp);

        retvar.push_back(tembi);

    }

    return(retvar);


}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0xe8(%rbp)
movq %rdi, %rax
movq %rax, -0xe0(%rbp)
movl 0x28(%rbp), %eax
movq 0x20(%rbp), %rax
movq %rax, -0xd8(%rbp)
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movq %r8, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movb $0x0, -0x29(%rbp)
callq 0x17470
movl -0x14(%rbp), %eax
movl %eax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movslq -0x34(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0x20(%rbp), %rdi
callq 0x56e0
movq %rax, %rcx
movq -0xf0(%rbp), %rax
movl -0xc(%rbp), %edx
shll %edx
addl $0x3, %edx
movslq %edx, %rdx
subq %rdx, %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
jae 0xe5da
leaq -0x98(%rbp), %rdi
callq 0x17410
movq -0xd8(%rbp), %rsi
leaq -0x88(%rbp), %rdi
callq 0x3040
jmp 0xe355
movl 0x28(%rbp), %eax
movl %eax, -0x68(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x64(%rbp)
movl 0x18(%rbp), %eax
movl %eax, -0x8c(%rbp)
movl -0x30(%rbp), %eax
movl %eax, -0x94(%rbp)
movl 0x10(%rbp), %eax
movl %eax, -0x90(%rbp)
movl -0x34(%rbp), %eax
addl -0xc(%rbp), %eax
subl $0x1, %eax
movl %eax, -0xa8(%rbp)
movl -0xa8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xac(%rbp)
movl -0xac(%rbp), %eax
movl %eax, -0xb0(%rbp)
cmpl $0x0, -0x34(%rbp)
jle 0xe3fd
movq -0x28(%rbp), %rdi
movslq -0xa8(%rbp), %rsi
callq 0x9a30
movl (%rax), %eax
movl %eax, -0xf4(%rbp)
movq -0x28(%rbp), %rdi
movl -0x34(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x9a30
movq %rax, %rcx
movl -0xf4(%rbp), %eax
subl (%rcx), %eax
movl %eax, -0x5c(%rbp)
jmp 0xe412
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0xe5c0
movq -0x28(%rbp), %rdi
movslq -0xa8(%rbp), %rsi
callq 0x9a30
movl (%rax), %eax
movl %eax, -0x5c(%rbp)
jmp 0xe414
movq -0x28(%rbp), %rdi
movslq -0xb0(%rbp), %rsi
callq 0x9a30
movl (%rax), %eax
movl %eax, -0xf8(%rbp)
movq -0x28(%rbp), %rdi
movslq -0xa8(%rbp), %rsi
callq 0x9a30
movq %rax, %rcx
movl -0xf8(%rbp), %eax
subl (%rcx), %eax
cmpl -0x10(%rbp), %eax
jge 0xe49d
movl -0xb0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb0(%rbp)
movl -0xb0(%rbp), %eax
addl -0xc(%rbp), %eax
cltq
movq %rax, -0x100(%rbp)
movq -0x20(%rbp), %rdi
callq 0x56e0
movq %rax, %rcx
movq -0x100(%rbp), %rax
cmpq %rcx, %rax
jb 0xe498
movb $0x1, -0x29(%rbp)
movl $0x1, -0xb4(%rbp)
jmp 0xe57a
jmp 0xe414
movq -0x28(%rbp), %rdi
movslq -0xb0(%rbp), %rsi
callq 0x9a30
movl (%rax), %eax
movl %eax, -0x108(%rbp)
movq -0x28(%rbp), %rdi
movslq -0xa8(%rbp), %rsi
callq 0x9a30
movq %rax, %rcx
movl -0x108(%rbp), %eax
movl (%rcx), %ecx
subl %ecx, %eax
movl %eax, -0x58(%rbp)
movl -0xb0(%rbp), %eax
movl %eax, -0x60(%rbp)
movq -0x28(%rbp), %rdi
movl -0xb0(%rbp), %eax
movl -0xc(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
callq 0x9a30
movl (%rax), %eax
movl %eax, -0x104(%rbp)
movq -0x28(%rbp), %rdi
movslq -0xb0(%rbp), %rsi
callq 0x9a30
movq %rax, %rcx
movl -0x104(%rbp), %eax
movl (%rcx), %ecx
subl %ecx, %eax
movl %eax, -0x54(%rbp)
movq -0x20(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0x9a30
movl (%rax), %ecx
movl -0x30(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x30(%rbp)
movl -0xc(%rbp), %esi
movl -0x64(%rbp), %edx
movl -0x60(%rbp), %ecx
movq -0x20(%rbp), %r8
leaq -0xd0(%rbp), %rdi
callq 0xdf40
jmp 0xe54f
movq -0xe8(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x17490
jmp 0xe564
leaq -0xd0(%rbp), %rdi
callq 0x5400
movl $0x0, -0xb4(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x17440
movl -0xb4(%rbp), %eax
testl %eax, %eax
jne 0xe5e8
jmp 0xe592
jmp 0xe594
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xe2fb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x5400
leaq -0x98(%rbp), %rdi
callq 0x17440
movq -0xe8(%rbp), %rdi
callq 0x17500
jmp 0xe60a
movb $0x1, -0x29(%rbp)
movl $0x1, -0xb4(%rbp)
testb $0x1, -0x29(%rbp)
jne 0xe5fa
movq -0xe8(%rbp), %rdi
callq 0x17500
movq -0xe0(%rbp), %rax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
movq -0xa0(%rbp), %rdi
callq 0x33d0
nopw %cs:(%rax,%rax)