// File: kingufl[P]Rmapper/src/buildgraph.cpp
// Function: extract_one_bilabel(int, 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)
bilabel extract_one_bilabel(int index, int kmer_size, int dsize, int start_locus, vector<int>& temp, vector<int>& temp_sum, int orientation, int chromosome, string rmapname,int rmap_id){

    bilabel tembi;
    int locus=start_locus;

    int i=index;
    tembi.kmer_size=kmer_size;
    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()){
            tembi.kmer_size=-1;
            return(tembi);
        }

    }

    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];

    return(tembi);


}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x60(%rbp)
movq %rdi, %rax
movq %rax, -0x68(%rbp)
movl 0x30(%rbp), %eax
movq 0x28(%rbp), %rax
movq %rax, -0x58(%rbp)
movl 0x20(%rbp), %eax
movl 0x18(%rbp), %eax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movl %r8d, -0x18(%rbp)
movq %r9, -0x20(%rbp)
movb $0x0, -0x21(%rbp)
callq 0x17410
movq -0x60(%rbp), %rdi
movq -0x58(%rbp), %rsi
movl -0x18(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x10(%rbp), %eax
movl %eax, (%rdi)
addq $0x10, %rdi
callq 0x3040
jmp 0xe0ed
movq -0x60(%rbp), %rax
movl 0x30(%rbp), %ecx
movl %ecx, 0x30(%rax)
movl -0x2c(%rbp), %ecx
movl %ecx, 0x34(%rax)
movl 0x20(%rbp), %ecx
movl %ecx, 0xc(%rax)
movl -0x28(%rbp), %ecx
movl %ecx, 0x4(%rax)
movl 0x18(%rbp), %ecx
movl %ecx, 0x8(%rax)
movl -0x2c(%rbp), %eax
addl -0x10(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x48(%rbp)
cmpl $0x0, -0x2c(%rbp)
jle 0xe17f
movq 0x10(%rbp), %rdi
movslq -0x40(%rbp), %rsi
callq 0x9a30
movl (%rax), %eax
movl %eax, -0x6c(%rbp)
movq 0x10(%rbp), %rdi
movl -0x2c(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x9a30
movl -0x6c(%rbp), %ecx
movq %rax, %rdx
movq -0x60(%rbp), %rax
subl (%rdx), %ecx
movl %ecx, 0x3c(%rax)
jmp 0xe198
movq -0x60(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
callq 0x17440
jmp 0xe297
movq 0x10(%rbp), %rdi
movslq -0x40(%rbp), %rsi
callq 0x9a30
movq %rax, %rcx
movq -0x60(%rbp), %rax
movl (%rcx), %ecx
movl %ecx, 0x3c(%rax)
jmp 0xe19a
movq 0x10(%rbp), %rdi
movslq -0x48(%rbp), %rsi
callq 0x9a30
movl (%rax), %eax
movl %eax, -0x70(%rbp)
movq 0x10(%rbp), %rdi
movslq -0x40(%rbp), %rsi
callq 0x9a30
movq %rax, %rcx
movl -0x70(%rbp), %eax
subl (%rcx), %eax
cmpl -0x14(%rbp), %eax
jge 0xe209
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
addl -0x10(%rbp), %eax
cltq
movq %rax, -0x78(%rbp)
movq -0x20(%rbp), %rdi
callq 0x56e0
movq %rax, %rcx
movq -0x78(%rbp), %rax
cmpq %rcx, %rax
jb 0xe207
movq -0x60(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movb $0x1, -0x21(%rbp)
movl $0x1, -0x4c(%rbp)
jmp 0xe27b
jmp 0xe19a
movq 0x10(%rbp), %rdi
movslq -0x48(%rbp), %rsi
callq 0x9a30
movl (%rax), %eax
movl %eax, -0x80(%rbp)
movq 0x10(%rbp), %rdi
movslq -0x40(%rbp), %rsi
callq 0x9a30
movl -0x80(%rbp), %ecx
movq %rax, %rdx
movq -0x60(%rbp), %rax
subl (%rdx), %ecx
movl %ecx, 0x40(%rax)
movl -0x48(%rbp), %ecx
movl %ecx, 0x38(%rax)
movq 0x10(%rbp), %rdi
movl -0x48(%rbp), %eax
addl -0x10(%rbp), %eax
movslq %eax, %rsi
callq 0x9a30
movl (%rax), %eax
movl %eax, -0x7c(%rbp)
movq 0x10(%rbp), %rdi
movslq -0x48(%rbp), %rsi
callq 0x9a30
movl -0x7c(%rbp), %ecx
movq %rax, %rdx
movq -0x60(%rbp), %rax
subl (%rdx), %ecx
movl %ecx, 0x44(%rax)
movb $0x1, -0x21(%rbp)
movl $0x1, -0x4c(%rbp)
testb $0x1, -0x21(%rbp)
jne 0xe28a
movq -0x60(%rbp), %rdi
callq 0x17440
movq -0x68(%rbp), %rax
addq $0x80, %rsp
popq %rbp
retq
movq -0x38(%rbp), %rdi
callq 0x33d0