// File: /workspace/github_cpp_makefile_star2_O1/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 0x19f648
movq %rdi, %r13
xorl %r12d, %r12d
xorl %ebx, %ebx
xorl %r14d, %r14d
movl %ecx, 0x4(%rsp)
movq %rdx, 0x8(%rsp)
movq (%r13), %rax
movb 0x2c(%rax,%r12), %al
xorl %ebp, %ebp
cmpb $0x2, %al
sete %sil
testl %ecx, %ecx
je 0x19f491
decb %al
cmpb $0x1, %al
jbe 0x19f499
jmp 0x19f62e
cmpb $0x1, %al
jne 0x19f62e
movb %sil, 0x3(%rsp)
movq 0x10(%rdx), %rax
cmpq %rax, 0x8(%rdx)
jne 0x19f4e0
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rcx
movq %rcx, 0x10(%rdx)
movq (%rdx), %rsi
leaq (%rcx,%rcx,8), %rax
leaq (%rax,%rax,2), %rdx
addq %rcx, %rdx
movq 0x30(%rsp), %rdi
callq 0x1e3800
movq 0x8(%rsp), %rdx
movl 0x4(%rsp), %ecx
movq %rax, (%rdx)
movq (%rdx), %rax
movq 0x8(%rdx), %rdi
leaq 0x1(%rdi), %rsi
movq %rsi, 0x8(%rdx)
leaq (%rdi,%rdi,8), %rsi
leaq (%rsi,%rsi,2), %r10
addq %rdi, %r10
leaq (%rax,%r10), %r15
movl %r14d, (%rax,%r10)
movq (%r13), %rdi
movl 0x4(%rdi,%r12), %esi
movl %esi, 0x4(%rax,%r10)
movl 0x8(%rdi,%r12), %esi
incl %esi
movl %esi, 0x8(%rax,%r10)
movl 0x10(%rdi,%r12), %r11d
movl %r11d, 0xc(%rax,%r10)
movl 0x18(%rax,%r10), %esi
movl %esi, %edi
andl $0xc0000000, %edi       # imm = 0xC0000000
movl %edi, 0x18(%rax,%r10)
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,%r10)
movq (%r13), %rsi
xorl %r9d, %r9d
cmpb $0x1, 0x2c(%rsi,%r12)
sete %r9b
shll $0x1e, %r9d
orl %r8d, %r9d
movl %r9d, 0x18(%rax,%r10)
testb $0x1, %dil
jne 0x19f58f
movq (%r13), %rax
movl 0x14(%rax,%r12), %esi
movl %esi, 0x10(%r15)
movl 0x18(%rax,%r12), %eax
incl %eax
jmp 0x19f5ca
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
leaq (%r11,%r11,4), %r8
movl (%rax,%r8,8), %r9d
movl $0x7fffffff, %r10d      # imm = 0x7FFFFFFF
andl %r10d, %r9d
movq (%r13), %rsi
movl 0x18(%rsi,%r12), %edi
notl %edi
addl %r9d, %edi
movl %edi, 0x10(%r15)
movl (%rax,%r8,8), %eax
andl %r10d, %eax
subl 0x14(%rsi,%r12), %eax
movl %eax, 0x14(%r15)
movq (%r13), %rax
cmpb $0x2, 0x2c(%rax,%r12)
movb 0x3(%rsp), %sil
jne 0x19f62e
movl $0x1, %r8d
movq 0x28(%rsp), %rdi
movq %r14, %rsi
leaq 0x18(%rsp), %rdx
leaq 0x10(%rsp), %rcx
callq 0x19f226
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 0x19f65a
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 0x19f471
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x94944(%rip), %rdi     # 0x233fa5
leaq 0x94323(%rip), %rsi     # 0x23398b
leaq 0x94941(%rip), %rcx     # 0x233fb0
movl $0x9b3, %edx            # imm = 0x9B3
callq 0x2110