// File: /workspace/github_cpp_makefile_star2_O3/CK7[P]abawaca/src/abawaca-build.cpp
// Function: Scaf::Scaf(Bio::Sequence<Bio::DNAString> const&, unsigned long)
Scaf::Scaf(const Bio::DNASequence& s, size_t window_size) : Sequence(s.display_id(), s.seq())
{
	// Split the scaffold into segments
	const Bio::DNAString& seq = s.seq();
	size_t			nsegments = (seq.size() - Bio::Ns(seq)) / window_size;

	if(nsegments == 0)
		nsegments = 1;
	size_t	nbps = (seq.size() - Bio::Ns(seq)) / nsegments;

	size_t	nbps_segment = 0;
	for(auto it=seq.begin(), sit=seq.begin(); it!=seq.end(); it++) {
		if(*it != 'N')
			nbps_segment++;
		if(nbps_segment == nbps) {
			Bio::DNAString subs = seq.subseq(sit-seq.begin(), it-seq.begin());
			char display_id[1024], desc[1024];

			segment_coords.push_back(pair<size_t, size_t>(sit-seq.begin()+1, it-seq.begin()+1));
			sprintf(display_id, "%s_%lu", s.display_id().c_str(), segment_coords.size());
			// SCNpilot_BF_INOC_scaffold_3677:(1,2811), 0 segment(s), 2811/2811 non-N bps
			sprintf(desc, "%s:(%lu, %lu), %lu/%lu non-Ns bps", s.display_id().c_str(), (sit-seq.begin()+1), (it-seq.begin()+1), subs.size()-Bio::Ns(subs), subs.size());
			segments.push_back(new Scaf_segment(display_id, desc, (sit-seq.begin()+1), (it-seq.begin()+1), subs));
			sit = it;
			sit++;
			nbps_segment = 0;
		}
	}

	// Last few bps may be nglected 
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x8e8, %rsp            # imm = 0x8E8
movq %rdx, %r13
movq %rsi, %r12
movq %rdi, %r15
leaq -0xe8(%rbp), %rbx
movq %rbx, -0x10(%rbx)
movq 0x8(%rsi), %rsi
movq 0x10(%r12), %rdx
addq %rsi, %rdx
leaq -0xf8(%rbp), %r14
movq %r14, %rdi
callq 0x63a2
movq %r12, -0x58(%rbp)
addq $0x48, %r12
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0xbb1c
movq %r13, -0x30(%rbp)
movq -0xf8(%rbp), %rdi
cmpq %rbx, %rdi
je 0x8e56
callq 0x4280
leaq 0xecbb(%rip), %rax      # 0x17b18
movq %rax, (%r15)
leaq 0x48(%r15), %rax
movq %rax, -0x38(%rbp)
leaq 0x60(%r15), %rax
movq %rax, -0x50(%rbp)
xorps %xmm0, %xmm0
movups %xmm0, 0x48(%r15)
movups %xmm0, 0x58(%r15)
movups %xmm0, 0x68(%r15)
movq %r15, -0x40(%rbp)
movq $0x0, 0x78(%r15)
movq -0x58(%rbp), %rbx
movq 0x50(%rbx), %r15
movq %r12, %rdi
callq 0xff73
movq %rax, %r13
movq 0x50(%rbx), %r14
movq %r12, -0x48(%rbp)
movq %r12, %rdi
callq 0xff73
movq %rax, %rcx
subq %r13, %r15
movq %r15, %rax
xorl %edx, %edx
movq -0x30(%rbp), %rsi
divq %rsi
cmpq %rsi, %r15
movl $0x1, %esi
cmovaeq %rax, %rsi
subq %rcx, %r14
movq %r14, %rax
xorl %edx, %edx
divq %rsi
movq %rax, -0xb8(%rbp)
movq 0x50(%rbx), %rax
testq %rax, %rax
movq -0x48(%rbp), %r14
je 0x914e
movq %rbx, %r15
movq (%r14), %rcx
leaq 0x1(%rcx), %rbx
xorl %esi, %esi
movq %rcx, %r12
movq %rcx, %r13
xorl %edx, %edx
cmpb $0x4e, (%r12)
setne %dl
addq %rsi, %rdx
cmpq -0xb8(%rbp), %rdx
jne 0x9138
movq %r13, %rdx
subq %rcx, %rdx
notq %rcx
addq %rbx, %rcx
leaq -0xb0(%rbp), %rdi
movq %r14, %rsi
callq 0xbbcc
movq (%r14), %rax
incq %r13
movq %r13, %rcx
subq %rax, %rcx
movq %rbx, %rdx
subq %rax, %rdx
movq %rcx, -0x70(%rbp)
movq %rdx, -0x68(%rbp)
movq -0x40(%rbp), %r14
movq 0x50(%r14), %rsi
cmpq 0x58(%r14), %rsi
movq %r13, -0x30(%rbp)
je 0x8f7a
movups -0x70(%rbp), %xmm0
movups %xmm0, (%rsi)
movq 0x50(%r14), %rcx
addq $0x10, %rcx
movq %rcx, 0x50(%r14)
jmp 0x8f8b
movq -0x38(%rbp), %rdi
leaq -0x70(%rbp), %rdx
callq 0xd860
movq 0x50(%r14), %rcx
movq 0x8(%r15), %rdx
movq -0x38(%rbp), %rax
subq (%rax), %rcx
sarq $0x4, %rcx
leaq -0x900(%rbp), %rdi
leaq 0x8646(%rip), %rsi      # 0x115ee
xorl %eax, %eax
callq 0x4070
movq 0x8(%r15), %r13
movq 0x48(%r15), %r14
movq -0xa8(%rbp), %r15
leaq -0xb0(%rbp), %rdi
callq 0xff73
movq %rbx, %r8
subq %r14, %r8
movq -0x30(%rbp), %rcx
subq %r14, %rcx
subq %rax, %r15
movq -0xa8(%rbp), %rax
movq %rax, (%rsp)
leaq -0x500(%rbp), %rdi
leaq 0x8602(%rip), %rsi      # 0x115f5
movq %r13, %rdx
movq %r15, %r9
xorl %eax, %eax
callq 0x4070
movl $0x90, %edi
callq 0x42b0
movq %rax, -0x60(%rbp)
leaq -0x80(%rbp), %rax
movq %rax, -0x90(%rbp)
leaq -0x900(%rbp), %r14
movq %r14, %rdi
callq 0x4130
leaq (%rax,%rbp), %rdx
addq $-0x900, %rdx           # imm = 0xF700
leaq -0x90(%rbp), %rdi
movq %r14, %rsi
callq 0x6440
movq -0x48(%rbp), %r14
leaq -0xc8(%rbp), %rax
movq %rax, -0xd8(%rbp)
leaq -0x500(%rbp), %r13
movq %r13, %rdi
callq 0x4130
leaq (%rax,%rbp), %rdx
addq $-0x500, %rdx           # imm = 0xFB00
leaq -0xd8(%rbp), %r15
movq %r15, %rdi
movq %r13, %rsi
callq 0x6440
movq (%r14), %rax
movq -0x30(%rbp), %rcx
subq %rax, %rcx
movq %rbx, %r8
subq %rax, %r8
movb $0x1, %r13b
movq -0x60(%rbp), %rdi
leaq -0x90(%rbp), %rsi
movq %r15, %rdx
movq %rdi, %r14
leaq -0xb0(%rbp), %r9
callq 0x8822
movq %r14, -0x70(%rbp)
movq -0x40(%rbp), %rax
movq 0x68(%rax), %rsi
cmpq 0x70(%rax), %rsi
je 0x90cc
movq %r14, (%rsi)
addq $0x8, 0x68(%rax)
jmp 0x90dc
xorl %r13d, %r13d
movq -0x50(%rbp), %rdi
leaq -0x70(%rbp), %rdx
callq 0xd9a6
movq -0xd8(%rbp), %rdi
leaq -0xc8(%rbp), %rax
cmpq %rax, %rdi
je 0x90f4
callq 0x4280
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
movq -0x58(%rbp), %r15
movq -0x48(%rbp), %r14
je 0x9111
callq 0x4280
movq -0xb0(%rbp), %rdi
leaq -0xa0(%rbp), %rax
cmpq %rax, %rdi
je 0x9129
callq 0x4280
leaq 0x1(%r12), %r13
movq 0x48(%r15), %rcx
movq 0x50(%r15), %rax
xorl %edx, %edx
incq %r12
leaq (%rcx,%rax), %rdi
incq %rbx
movq %rdx, %rsi
cmpq %rdi, %r12
jne 0x8f04
addq $0x8e8, %rsp            # imm = 0x8E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x91a9
jmp 0x91a9
movq %rax, %r14
movq -0xf8(%rbp), %rdi
cmpq %rbx, %rdi
je 0x922f
callq 0x4280
jmp 0x922f
jmp 0x918a
jmp 0x918a
movq %rax, %r14
jmp 0x91e3
movq %rax, %r14
jmp 0x91ec
movq %rax, %r14
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x91e3
callq 0x4280
jmp 0x91e3
movq %rax, %r14
jmp 0x9204
movq %rax, %r14
movq -0xd8(%rbp), %rdi
leaq -0xc8(%rbp), %rax
cmpq %rax, %rdi
je 0x91c9
callq 0x4280
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x91de
callq 0x4280
testb %r13b, %r13b
je 0x91ec
movq -0x60(%rbp), %rdi
callq 0x4280
movq -0xb0(%rbp), %rdi
leaq -0xa0(%rbp), %rax
cmpq %rax, %rdi
je 0x9204
callq 0x4280
movq -0x50(%rbp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x9215
callq 0x4280
movq -0x38(%rbp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x9226
callq 0x4280
movq -0x40(%rbp), %rdi
callq 0xc630
movq %r14, %rdi
callq 0x44f0
nop