// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/inter.cpp
// Function: gen_gl_aln(overlap_region_alloc*, ul_idx_t const*, kv_ul_ov_t*)
void gen_gl_aln(overlap_region_alloc* olist, const ul_idx_t *uref, kv_ul_ov_t *res)
{
	uint64_t k; ul_ov_t *p = NULL;
	res->n = 0; kv_resize(ul_ov_t, *res, olist->length);
	for (k = 0; k < olist->length; k++) {
		// fprintf(stderr, "+++[M::%s::utg%.6dl] q[%d, %d), t[%d, %d), tot::%u, cis::%u, err::%u\n", __func__, 
        // (int32_t)olist->list[k].y_id+1, olist->list[k].x_pos_s, olist->list[k].x_pos_e+1,
		// olist->list[k].y_pos_s, olist->list[k].y_pos_e+1,
		// olist->list[k].overlapLen, olist->list[k].align_length, olist->list[k].non_homopolymer_errors);
		p = &(res->a[res->n++]); assert(olist->list[k].overlapLen >= olist->list[k].align_length);
		p->qn = k; 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 = olist->list[k].align_length; 
		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;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %rbx
movq %rsi, %r14
andq $0x0, 0x8(%rdx)
movq %rdi, %r15
movq 0x10(%rdi), %rax
cmpq %rax, 0x10(%rdx)
jae 0x16aec4
decq %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x10, %rcx
orq %rax, %rcx
incq %rcx
movq %rcx, 0x10(%rbx)
movq (%rbx), %rdi
imulq $0x1c, %rcx, %rsi
callq 0x2370
movq %rax, (%rbx)
xorl %eax, %eax
movl $0xc0000000, %ecx       # imm = 0xC0000000
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
xorl %esi, %esi
cmpq 0x10(%r15), %rsi
jae 0x16afcd
movq 0x8(%rbx), %rdi
leaq 0x1(%rdi), %r8
movq %r8, 0x8(%rbx)
movq (%r15), %r9
movl 0x28(%r9,%rax), %r8d
cmpl %r8d, 0x20(%r9,%rax)
jb 0x16afd6
imulq $0x1c, %rdi, %rdi
addq (%rbx), %rdi
movl %esi, (%rdi)
movl 0x4(%r9,%rax), %r10d
movl %r10d, 0x4(%rdi)
movl 0x8(%r9,%rax), %r10d
incl %r10d
movl %r10d, 0x8(%rdi)
movl 0x10(%r9,%rax), %r9d
movl %r9d, 0xc(%rdi)
andl $0x3fffffff, %r8d       # imm = 0x3FFFFFFF
movl 0x18(%rdi), %r10d
andl %ecx, %r10d
orl %r8d, %r10d
movl %r10d, 0x18(%rdi)
movq (%r15), %r11
movl 0x1c(%r11,%rax), %r11d
movl %r11d, %ebp
shll $0x1f, %ebp
andl $0x7fffffff, %r10d      # imm = 0x7FFFFFFF
orl %ebp, %r10d
movl %r10d, 0x18(%rdi)
movq (%r15), %r10
xorl %r12d, %r12d
cmpb $0x1, 0x2c(%r10,%rax)
sete %r12b
shll $0x1e, %r12d
orl %r8d, %r12d
orl %ebp, %r12d
movl %r12d, 0x18(%rdi)
testb $0x1, %r11b
jne 0x16af8d
movq (%r15), %r8
movl 0x14(%r8,%rax), %r9d
movl %r9d, 0x10(%rdi)
movl 0x18(%r8,%rax), %r8d
incl %r8d
jmp 0x16afbb
movq (%r14), %r8
movq 0x10(%r8), %r8
imulq $0x28, %r9, %r9
movl (%r8,%r9), %r10d
andl %edx, %r10d
movq (%r15), %r11
movl 0x18(%r11,%rax), %ebp
notl %ebp
addl %r10d, %ebp
movl %ebp, 0x10(%rdi)
movl (%r8,%r9), %r8d
andl %edx, %r8d
subl 0x14(%r11,%rax), %r8d
movl %r8d, 0x14(%rdi)
incq %rsi
addq $0xa8, %rax
jmp 0x16aed2
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x87fdf(%rip), %rdi     # 0x1f2fbc
leaq 0x86b3f(%rip), %rsi     # 0x1f1b23
leaq 0x8800a(%rip), %rcx     # 0x1f2ff5
movl $0x1470, %edx           # imm = 0x1470
callq 0x2110