// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/inter.cpp
// Function: hpc_g_gen(ma_ug_t*)
hpc_t *hpc_g_gen(ma_ug_t *ug)
{
	uint32_t k, i, ho, so, len; int32_t z; hpc_t *p; kvec_t(char) cc; asg_t *ng = asg_init();
	CALLOC(p, 1); CALLOC(p->hg, 1); kv_init(cc); CALLOC(p->mm, 1);
	CALLOC(p->hg->u.a, ug->u.n); p->hg->u.n = p->hg->u.m = ug->u.n;
	CALLOC(p->mm->idx, ug->u.n);

	for (k = 0; k < ug->u.n; k++) {
		kv_resize(char, cc, ug->u.a[k].len);
		retrieve_u_seq(NULL, cc.a, &(ug->u.a[k]), 0, 0, ug->u.a[k].len, NULL);
		gen_hpc_seq(cc.a, ug->u.a[k].len, &(p->hg->u.a[k]), p->mm, k);
		gen_microsatellite(cc.a, ug->u.a[k].len, &(p->hg->u.a[k]), p, 6);
	}

	ng->m_arc = ng->n_arc = ug->g->n_arc; CALLOC(ng->arc, ng->n_arc);
	ng->m_seq = ng->n_seq = ug->g->n_seq; CALLOC(ng->seq, ng->n_seq);
	for (k = 0; k < ng->n_seq; k++) {
		ng->seq[k].del = ng->seq[k].c = 0; ng->seq[k].len = p->hg->u.a[k].len>>1;///hpc len
	}
	memcpy(ng->arc, ug->g->arc, ng->n_arc*(sizeof((*(ng->arc))))); 
	for (k = 1, i = 0; k <= ng->n_arc; k++) {
		if(k == ng->n_arc || (ng->arc[i].ul>>32) != (ng->arc[k].ul>>32)) {
			//sorted by ol
			len = ng->arc[i].ol; kv_resize(char, cc, len); 
			retrieve_u_seq(NULL, cc.a, &(ug->u.a[ng->arc[i].ul>>33]), ((ng->arc[i].ul>>32)&1)^1, 0, len, NULL);
			// min_o = ng->arc[k-1].ol; max_o = ng->arc[i].ol;
			len = ng->seq[ng->arc[i].ul>>33].len;///hpc len
			for (z = k-1, ho = so = 0; z >= (int32_t)i; z--) {
				ho = hpc_l(cc.a, ho, so, ng->arc[z].ol);
				so = ng->arc[z].ol;
				ng->arc[z].ol = ho; 
				ng->arc[z].ul>>=32; 
				ng->arc[z].ul<<=32;
				ng->arc[z].ul += len - ng->arc[z].ol;
				assert(z == (int32_t)k-1 || ng->arc[z].ol>=ng->arc[z+1].ol);
			}
			i = k;
		}
	}
	asg_cleanup(ng);
	p->hg->g = ng;
	kv_destroy(cc);
	return p;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %rbx
callq 0x68f5d
movq %rax, 0x20(%rsp)
pushq $0x1
popq %r15
pushq $0x28
popq %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x2120
movq %rax, %r14
movq %rax, 0x10(%rsp)
pushq $0x38
popq %rsi
movq %r15, %rdi
callq 0x2120
movq %rax, %r13
movq %rax, (%r14)
pushq $0x20
popq %rsi
movq %r15, %rdi
callq 0x2120
movq %rax, %rbp
movq %rax, 0x20(%r14)
movq (%rbx), %r15
movq %r15, %rdi
movq %r12, %rsi
movq %rbx, %r12
callq 0x2120
movq %rax, 0x10(%r13)
movq %r15, 0x8(%r13)
movq %r15, (%r13)
pushq $0x8
popq %rsi
movq %r15, %rdi
callq 0x2120
movq %rax, 0x18(%rbp)
xorl %r14d, %r14d
movq $0x0, 0x18(%rsp)
xorl %ebp, %ebp
movl %ebp, %ebp
cmpq %rbp, %r15
jbe 0x198216
movq 0x10(%r12), %rdx
imulq $0x28, %rbp, %r15
movl (%rdx,%r15), %r9d
andl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
cmpq %r9, 0x18(%rsp)
jae 0x198199
decq %r9
movq %r9, %rax
shrq %rax
orq %r9, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %r14, %rdi
movq %rsi, 0x18(%rsp)
callq 0x2370
movq %rax, %r14
movq 0x10(%r12), %rdx
movl (%rdx,%r15), %r9d
andl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
addq %r15, %rdx
andq $0x0, (%rsp)
xorl %edi, %edi
movq %r14, %rsi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x9f29
movq 0x10(%r12), %rax
movl (%rax,%r15), %esi
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andl %eax, %esi
movq %r12, %r13
movq 0x10(%rsp), %r12
movq (%r12), %rbx
movq 0x20(%r12), %rcx
movq 0x10(%rbx), %rdx
addq %r15, %rdx
movq %r14, %rdi
movl %ebp, %r8d
callq 0x197b96
movq 0x10(%r13), %rax
movl (%rax,%r15), %esi
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andl %eax, %esi
addq 0x10(%rbx), %r15
movq %r14, %rdi
movq %r15, %rdx
movq %r12, %rcx
movq %r13, %r12
pushq $0x6
popq %r8
callq 0x197df2
incl %ebp
movq (%r13), %r15
jmp 0x19811c
movq %r14, %r15
movq 0x18(%r12), %rax
movl 0x4(%rax), %edi
movl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
andq %rbx, %rdi
movl $0x80000000, %ebp       # imm = 0x80000000
movq 0x20(%rsp), %r14
movl 0x4(%r14), %eax
andl %ebp, %eax
orl %edi, %eax
movl %eax, 0x4(%r14)
movl %edi, (%r14)
pushq $0x18
popq %rsi
callq 0x2120
movq %rax, 0x8(%r14)
movq 0x18(%r12), %rax
movl 0x14(%rax), %edi
andq %rbx, %rdi
movl 0x14(%r14), %ebx
andl %ebp, %ebx
orl %edi, %ebx
movl %ebx, 0x14(%r14)
movl %edi, 0x10(%r14)
pushq $0x8
popq %rsi
callq 0x2120
movq %rax, 0x20(%r14)
xorl %eax, %eax
xorl %ecx, %ecx
movq 0x10(%rsp), %r8
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
cmpq %rbx, %rcx
jae 0x1982c4
movq 0x20(%r14), %rdx
movb $0x0, 0x4(%rdx,%rcx,8)
andb $0x7f, 0x3(%rdx,%rcx,8)
movq (%r8), %rdx
movq 0x10(%rdx), %rdx
movl (%rdx,%rax), %edx
shrl %edx
andl $0x3fffffff, %edx       # imm = 0x3FFFFFFF
movq 0x20(%r14), %rsi
movl (%rsi,%rcx,8), %edi
andl %ebp, %edi
orl %edx, %edi
movl %edi, (%rsi,%rcx,8)
incq %rcx
movl 0x14(%r14), %ebx
addq $0x28, %rax
jmp 0x19827e
movq 0x8(%r14), %rdi
movq 0x18(%r12), %rax
movq 0x8(%rax), %rsi
movl 0x4(%r14), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
imulq $0x18, %rax, %rdx
callq 0x2160
movq 0x10(%rsp), %r10
pushq $0x1
popq %rdi
xorl %ebp, %ebp
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
movq $0x0, 0x40(%rsp)
xorl %r9d, %r9d
movq %r15, %rbx
movq %r12, 0x48(%rsp)
movl 0x4(%r14), %eax
andl %r8d, %eax
cmpl %eax, %edi
ja 0x1984c2
movq 0x8(%r14), %rax
movl %r9d, %ecx
je 0x19833b
imulq $0x18, %rcx, %rdx
movl %edi, %esi
imulq $0x18, %rsi, %rsi
movq (%rax,%rsi), %rsi
xorq (%rax,%rdx), %rsi
shrq $0x20, %rsi
je 0x1984b2
movl %r9d, 0x28(%rsp)
imulq $0x18, %rcx, %r13
movl 0xc(%rax,%r13), %r15d
andl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
cmpq %r15, 0x18(%rsp)
movl %edi, 0x34(%rsp)
jae 0x1983a7
leaq -0x1(%r15), %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, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rbx, %rdi
movq %rsi, 0x18(%rsp)
callq 0x2370
movq %rax, %rbx
movq 0x8(%r14), %rax
movq (%rax,%r13), %rax
movq %rax, %rcx
shrq $0x21, %rcx
imulq $0x28, %rcx, %rdx
addq 0x10(%r12), %rdx
xorl %ecx, %ecx
btq $0x20, %rax
setae %cl
andq $0x0, (%rsp)
movq %r13, %r12
xorl %r13d, %r13d
xorl %edi, %edi
movq %rbx, 0x38(%rsp)
movq %rbx, %rsi
xorl %r8d, %r8d
movq %r15, %r9
callq 0x9f29
movq 0x8(%r14), %rbx
movq 0x20(%r14), %rax
movq (%rbx,%r12), %rcx
shrq $0x21, %rcx
movl (%rax,%rcx,8), %r12d
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
andl %r8d, %r12d
movslq 0x28(%rsp), %rax
movq %rax, 0x28(%rsp)
movq %rbp, 0x50(%rsp)
movq %rbp, %r14
xorl %ebp, %ebp
xorl %eax, %eax
movq 0x40(%rsp), %rcx
addq %r13, %rcx
cmpq 0x28(%rsp), %rcx
jl 0x198492
movl %eax, %esi
movl %ebp, %edx
movl 0xc(%rbx,%r14), %r15d
movl %r15d, %ebp
andl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
movq 0x38(%rsp), %rdi
movq %rbp, %rcx
callq 0x198039
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
movl %eax, %ecx
andl %r8d, %ecx
andl $0x80000000, %r15d      # imm = 0x80000000
orl %ecx, %r15d
movl %r15d, 0xc(%rbx,%r14)
movq 0x20(%rsp), %rcx
movq 0x8(%rcx), %rbx
movl 0xc(%rbx,%r14), %ecx
andl %r8d, %ecx
movl %r12d, %edx
subl %ecx, %edx
movl %edx, (%rbx,%r14)
subq $0x1, %r13
jb 0x19848c
movl 0x24(%rbx,%r14), %edx
andl %r8d, %edx
cmpl %edx, %ecx
jb 0x1984ee
addq $-0x18, %r14
jmp 0x198418
movl 0x34(%rsp), %edi
movl %edi, %r9d
movq 0x20(%rsp), %r14
movq 0x48(%rsp), %r12
movq 0x10(%rsp), %r10
movq 0x38(%rsp), %rbx
movq 0x50(%rsp), %rbp
incl %edi
incq 0x40(%rsp)
addq $0x18, %rbp
jmp 0x198307
movq %r14, %rdi
movq %r10, %r15
callq 0x694eb
movq (%r15), %rax
movq %r14, 0x18(%rax)
movq %rbx, %rdi
callq 0x2220
movq %r15, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5e13e(%rip), %rdi     # 0x1f6633
leaq 0x59627(%rip), %rsi     # 0x1f1b23
leaq 0x5e164(%rip), %rcx     # 0x1f6667
movl $0x51b9, %edx           # imm = 0x51B9
callq 0x2110