// File: /workspace/github_cpp_makefile_star2_O2/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 $0x48, %rsp
movq %r9, 0x38(%rsp)
movq %r8, 0x30(%rsp)
movl %ecx, %r9d
movq %rdx, %r15
leaq 0x20(%rsp), %rax
andq $0x0, (%rax)
leaq 0x18(%rsp), %rax
andq $0x0, (%rax)
movq %rsi, 0x28(%rsp)
andq $0x0, 0x8(%rdx)
xorl %r12d, %r12d
xorl %r14d, %r14d
xorl %r11d, %r11d
movl %ecx, 0xc(%rsp)
movq %rdi, 0x10(%rsp)
cmpq 0x10(%rdi), %r14
jae 0x1606e6
movq (%rdi), %r8
movb 0x2c(%r8,%r12), %al
xorl %ebp, %ebp
cmpb $0x2, %al
sete %bl
testl %r9d, %r9d
je 0x160539
decb %al
cmpb $0x1, %al
jbe 0x160541
jmp 0x1606d1
cmpb $0x1, %al
jne 0x1606d1
movq (%r15), %rax
movq 0x8(%r15), %rdx
cmpq 0x10(%r15), %rdx
jne 0x16058c
leaq (%rdx,%rdx), %rcx
testq %rdx, %rdx
pushq $0x2
popq %rdx
cmoveq %rdx, %rcx
movq %rcx, 0x10(%r15)
imulq $0x1c, %rcx, %rdx
movq 0x38(%rsp), %rdi
movq %rax, %rsi
movl %ebx, %r13d
movq %r11, %rbx
callq 0x1a3acc
movq %rbx, %r11
movl %r13d, %ebx
movq 0x10(%rsp), %rdi
movq %rax, (%r15)
movq 0x8(%r15), %rdx
movq (%rdi), %r8
leaq 0x1(%rdx), %rsi
movq %rsi, 0x8(%r15)
imulq $0x1c, %rdx, %rdx
leaq (%rax,%rdx), %rcx
movl %r14d, (%rax,%rdx)
movl 0x4(%r8,%r12), %esi
movl %esi, 0x4(%rax,%rdx)
movl 0x8(%r8,%r12), %esi
incl %esi
movl %esi, 0x8(%rax,%rdx)
movl 0x10(%r8,%r12), %r10d
movl %r10d, 0xc(%rax,%rdx)
movl 0x18(%rax,%rdx), %esi
movl %esi, %r8d
andl $0xc0000000, %r8d       # imm = 0xC0000000
movl %r8d, 0x18(%rax,%rdx)
movq (%rdi), %r8
movl 0x1c(%r8,%r12), %r13d
movl %r13d, %r8d
shll $0x1f, %r8d
andl $0x40000000, %esi       # imm = 0x40000000
orl %r8d, %esi
movl %esi, 0x18(%rax,%rdx)
movq (%rdi), %rsi
xorl %r9d, %r9d
cmpb $0x1, 0x2c(%rsi,%r12)
sete %r9b
shll $0x1e, %r9d
orl %r8d, %r9d
movl %r9d, 0x18(%rax,%rdx)
testb $0x1, %r13b
jne 0x160623
movq (%rdi), %rax
movl 0x14(%rax,%r12), %edx
movl %edx, 0x10(%rcx)
movl 0x18(%rax,%r12), %edx
incl %edx
jmp 0x16065e
movq 0x28(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rdx
imulq $0x28, %r10, %r8
movl (%rdx,%r8), %esi
movl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
andl %r9d, %esi
movq (%rdi), %rax
movl 0x18(%rax,%r12), %r10d
notl %r10d
addl %esi, %r10d
movl %r10d, 0x10(%rcx)
movl (%rdx,%r8), %edx
andl %r9d, %edx
subl 0x14(%rax,%r12), %edx
movl %edx, 0x14(%rcx)
cmpb $0x2, 0x2c(%rax,%r12)
movl 0xc(%rsp), %r9d
jne 0x1606d1
movl %ebx, %r13d
movq %r15, %rbx
movq %r11, %r15
movq 0x30(%rsp), %rdi
movq %r14, %rsi
movq %rcx, 0x40(%rsp)
leaq 0x20(%rsp), %rdx
leaq 0x18(%rsp), %rcx
pushq $0x1
popq %r8
callq 0x160309
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
movq 0x40(%rsp), %rsi
movl 0x18(%rsi), %ecx
movl $0xc0000000, %edx       # imm = 0xC0000000
andl %edx, %ecx
orl %eax, %ecx
movl %ecx, 0x18(%rsi)
testl %eax, %eax
je 0x1606f8
movq 0x18(%rsp), %rax
movq %rax, 0x20(%rsp)
movl 0xc(%rsp), %r9d
movq %r15, %r11
movq %rbx, %r15
movl %r13d, %ebx
movq 0x10(%rsp), %rdi
movb %bl, %bpl
addq %rbp, %r11
incq %r14
addq $0xa8, %r12
jmp 0x160510
movq %r11, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x91a3e(%rip), %rdi     # 0x1f213d
leaq 0x9141d(%rip), %rsi     # 0x1f1b23
leaq 0x91a3b(%rip), %rcx     # 0x1f2148
movl $0x9b3, %edx            # imm = 0x9B3
callq 0x2110