// File: 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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x18(%rbp), %rax
movq $0x0, 0x8(%rax)
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jae 0x28ceec
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rcx
addq %rcx, %rax
movzbl 0x2c(%rax), %eax
cmpl $0x2, %eax
jne 0x28cbac
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x28cbd2
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rcx
addq %rcx, %rax
movzbl 0x2c(%rax), %eax
cmpl $0x1, %eax
je 0x28cbd2
jmp 0x28cedb
cmpl $0x0, -0x1c(%rbp)
je 0x28cc13
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rcx
addq %rcx, %rax
movzbl 0x2c(%rax), %eax
cmpl $0x1, %eax
je 0x28cc13
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rcx
addq %rcx, %rax
movzbl 0x2c(%rax), %eax
cmpl $0x2, %eax
je 0x28cc13
jmp 0x28cedb
jmp 0x28cc15
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jne 0x28cc7d
movq -0x18(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x28cc43
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
shlq %rax
movq %rax, -0x60(%rbp)
jmp 0x28cc4e
movl $0x2, %eax
movq %rax, -0x60(%rbp)
jmp 0x28cc4e
movq -0x60(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
movq -0x18(%rbp), %rax
imulq $0x1c, 0x10(%rax), %rdx
callq 0x30e740
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rdx
movq 0x8(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x8(%rdx)
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x38(%rbp), %rax
movl %eax, %ecx
movq -0x58(%rbp), %rax
movl %ecx, (%rax)
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x4(%rax), %ecx
movq -0x58(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movq -0x58(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x10(%rax), %ecx
movq -0x58(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x58(%rbp), %rax
movl 0x18(%rax), %ecx
andl $0xc0000000, %ecx       # imm = 0xC0000000
orl $0x0, %ecx
movl %ecx, 0x18(%rax)
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x1c(%rax), %edx
movq -0x58(%rbp), %rax
movl 0x18(%rax), %ecx
andl $0x1, %edx
shll $0x1f, %edx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl %edx, %ecx
movl %ecx, 0x18(%rax)
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rcx
addq %rcx, %rax
movzbl 0x2c(%rax), %ecx
xorl %edx, %edx
movl $0x1, %eax
cmpl $0x1, %ecx
cmovel %eax, %edx
movq -0x58(%rbp), %rax
movl 0x18(%rax), %ecx
andl $0x1, %edx
shll $0x1e, %edx
andl $0xbfffffff, %ecx       # imm = 0xBFFFFFFF
orl %edx, %ecx
movl %ecx, 0x18(%rax)
movq -0x58(%rbp), %rax
movl 0x18(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x28ce14
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq -0x58(%rbp), %rcx
movl 0xc(%rcx), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rdx
addq %rdx, %rax
movl 0x18(%rax), %eax
addl $0x1, %eax
subl %eax, %ecx
movq -0x58(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq -0x58(%rbp), %rcx
movl 0xc(%rcx), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rdx
addq %rdx, %rax
subl 0x14(%rax), %ecx
movq -0x58(%rbp), %rax
movl %ecx, 0x14(%rax)
jmp 0x28ce4f
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x14(%rax), %ecx
movq -0x58(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x18(%rax), %ecx
addl $0x1, %ecx
movq -0x58(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x38(%rbp), %rcx
addq %rcx, %rax
movzbl 0x2c(%rax), %eax
cmpl $0x2, %eax
jne 0x28ced9
movq -0x28(%rbp), %rdi
movq -0x38(%rbp), %rsi
leaq -0x48(%rbp), %rdx
leaq -0x50(%rbp), %rcx
movl $0x1, %r8d
callq 0x28c790
movl %eax, %edx
movq -0x58(%rbp), %rax
movl 0x18(%rax), %ecx
andl $0x3fffffff, %edx       # imm = 0x3FFFFFFF
andl $0xc0000000, %ecx       # imm = 0xC0000000
orl %edx, %ecx
movl %ecx, 0x18(%rax)
movq -0x58(%rbp), %rax
movl 0x18(%rax), %eax
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
cmpl $0x0, %eax
jle 0x28ceb2
jmp 0x28ced1
leaq 0x103f90(%rip), %rdi    # 0x390e49
leaq 0x10396f(%rip), %rsi    # 0x39082f
movl $0x9b3, %edx            # imm = 0x9B3
leaq 0x103f88(%rip), %rcx    # 0x390e54
callq 0x2130
movq -0x50(%rbp), %rax
movq %rax, -0x48(%rbp)
jmp 0x28cedb
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x28cb73
movq -0x40(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)