// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/inter.cpp
// Function: gl_chain_gen(overlap_region_alloc*, ul_idx_t const*, kv_ul_ov_t*, unsigned int, haplotype_evdience_alloc*, void*)
uint64_t gl_chain_gen(overlap_region_alloc* olist, const ul_idx_t *uref, kv_ul_ov_t *res, uint32_t rec_trans, haplotype_evdience_alloc *hap, void *km)
{
	uint64_t k, o2 = 0, si = 0, ei = 0; ul_ov_t *p = NULL;
	res->n = 0;
	for (k = 0; k < olist->length; k++) {
		if(olist->list[k].is_match==2) o2++;
		if((!rec_trans) && olist->list[k].is_match!=1) continue;
		if(rec_trans && olist->list[k].is_match!=1 && olist->list[k].is_match!=2) continue;
		kv_pushp_km(km, ul_ov_t, *res, &p);
		p->qn = k/**olist->list[k].x_id**/; p->qs = olist->list[k].x_pos_s; p->qe = olist->list[k].x_pos_e+1;
		p->tn = olist->list[k].y_id; p->sec = 0; p->rev = olist->list[k].y_pos_strand;
		p->el = (olist->list[k].is_match==1?1:0);
		if(p->rev) {
			p->ts = uref->ug->u.a[p->tn].len - (olist->list[k].y_pos_e+1); 
			p->te = uref->ug->u.a[p->tn].len - olist->list[k].y_pos_s;
		} else {
			p->ts = olist->list[k].y_pos_s; 
			p->te = olist->list[k].y_pos_e+1;
		}
		if(olist->list[k].is_match==2) {
			p->sec = update_ava_het_site(hap, k, &si, &ei, 1);
			assert(p->sec > 0);
			si = ei;
		}
	}
	return o2;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, 0x30(%rsp)
movq %r8, 0x28(%rsp)
movq %rsi, 0x20(%rsp)
xorl %ebx, %ebx
movq %rbx, 0x18(%rsp)
movq %rbx, 0x10(%rsp)
movq %rbx, 0x8(%rdx)
cmpq %rbx, 0x10(%rdi)
je 0x1a8384
movq %rdi, %r13
xorl %r12d, %r12d
xorl %ebx, %ebx
xorl %r14d, %r14d
movl %ecx, 0x4(%rsp)
movq %rdx, 0x8(%rsp)
movq (%r13), %rdi
movb 0x2c(%rdi,%r12), %al
xorl %ebp, %ebp
cmpb $0x2, %al
sete %sil
testl %ecx, %ecx
je 0x1a81d2
decb %al
cmpb $0x1, %al
jbe 0x1a81da
jmp 0x1a836a
cmpb $0x1, %al
jne 0x1a836a
movb %sil, 0x3(%rsp)
movq (%rdx), %rax
movq 0x8(%rdx), %rsi
cmpq 0x10(%rdx), %rsi
jne 0x1a822c
leaq (%rsi,%rsi), %rcx
testq %rsi, %rsi
movl $0x2, %esi
cmoveq %rsi, %rcx
movq %rcx, 0x10(%rdx)
leaq (%rcx,%rcx,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rcx, %rdx
movq 0x30(%rsp), %rdi
movq %rax, %rsi
callq 0x1ee21d
movq 0x8(%rsp), %rdx
movl 0x4(%rsp), %ecx
movq %rax, (%rdx)
movq 0x8(%rdx), %rsi
movq (%r13), %rdi
leaq 0x1(%rsi), %r8
movq %r8, 0x8(%rdx)
leaq (%rsi,%rsi,8), %r8
leaq (%r8,%r8,2), %r11
addq %rsi, %r11
leaq (%rax,%r11), %r15
movl %r14d, (%rax,%r11)
movl 0x4(%rdi,%r12), %esi
movl %esi, 0x4(%rax,%r11)
movl 0x8(%rdi,%r12), %esi
incl %esi
movl %esi, 0x8(%rax,%r11)
movl 0x10(%rdi,%r12), %r10d
movl %r10d, 0xc(%rax,%r11)
movl 0x18(%rax,%r11), %esi
movl %esi, %edi
andl $0xc0000000, %edi       # imm = 0xC0000000
movl %edi, 0x18(%rax,%r11)
movq (%r13), %rdi
movl 0x1c(%rdi,%r12), %edi
movl %edi, %r8d
shll $0x1f, %r8d
andl $0x40000000, %esi       # imm = 0x40000000
orl %r8d, %esi
movl %esi, 0x18(%rax,%r11)
movq (%r13), %rsi
xorl %r9d, %r9d
cmpb $0x1, 0x2c(%rsi,%r12)
sete %r9b
shll $0x1e, %r9d
orl %r8d, %r9d
movl %r9d, 0x18(%rax,%r11)
testb $0x1, %dil
jne 0x1a82d0
movq (%r13), %rax
movl 0x14(%rax,%r12), %esi
movl %esi, 0x10(%r15)
movl 0x18(%rax,%r12), %esi
incl %esi
jmp 0x1a830a
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rax), %r9
leaq (%r10,%r10,4), %r8
movl (%r9,%r8,8), %esi
movl $0x7fffffff, %r10d      # imm = 0x7FFFFFFF
andl %r10d, %esi
movq (%r13), %rax
movl 0x18(%rax,%r12), %edi
notl %edi
addl %esi, %edi
movl %edi, 0x10(%r15)
movl (%r9,%r8,8), %esi
andl %r10d, %esi
subl 0x14(%rax,%r12), %esi
movl %esi, 0x14(%r15)
cmpb $0x2, 0x2c(%rax,%r12)
movb 0x3(%rsp), %sil
jne 0x1a836a
movl $0x1, %r8d
movq 0x28(%rsp), %rdi
movq %r14, %rsi
leaq 0x18(%rsp), %rdx
leaq 0x10(%rsp), %rcx
callq 0x1a7f4d
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
movl 0x18(%r15), %ecx
movl $0xc0000000, %edx       # imm = 0xC0000000
andl %edx, %ecx
orl %eax, %ecx
movl %ecx, 0x18(%r15)
testl %eax, %eax
je 0x1a8396
movq 0x10(%rsp), %rax
movq %rax, 0x18(%rsp)
movl 0x4(%rsp), %ecx
movq 0x8(%rsp), %rdx
movb 0x3(%rsp), %sil
movb %sil, %bpl
addq %rbp, %rbx
incq %r14
addq $0xa8, %r12
cmpq 0x10(%r13), %r14
jb 0x1a81b2
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x97ed8(%rip), %rdi     # 0x240275
leaq 0x978b7(%rip), %rsi     # 0x23fc5b
leaq 0x97ed5(%rip), %rcx     # 0x240280
movl $0x9b3, %edx            # imm = 0x9B3
callq 0x2110