// File: /workspace/github_cpp_makefile_star2_O1/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 $0x48, %rsp
movq %rdi, %r15
callq 0x9fccc
movq %rax, 0x20(%rsp)
movl $0x1, %edi
movl $0x28, %esi
callq 0x2120
movq %rax, %rbx
movl $0x1, %edi
movl $0x38, %esi
callq 0x2120
movq %rax, %r14
movq %rax, (%rbx)
movl $0x1, %edi
movl $0x20, %esi
callq 0x2120
movq %rax, %r12
movq %rbx, 0x10(%rsp)
movq %rax, 0x20(%rbx)
movq (%r15), %r13
movl $0x28, %esi
movq %r13, %rdi
callq 0x2120
movq %rax, 0x10(%r14)
movq %r13, 0x8(%r14)
movq %r13, (%r14)
movl $0x8, %esi
movq %r13, %rdi
callq 0x2120
movq %r15, %rdx
movq %rax, 0x18(%r12)
xorl %ebp, %ebp
cmpq $0x0, (%r15)
movq %r15, 0x8(%rsp)
je 0x1da89c
xorl %r14d, %r14d
movq $0x0, 0x18(%rsp)
xorl %ebx, %ebx
movq 0x20(%rsp), %r13
movq 0x10(%rsp), %r12
movq 0x10(%rdx), %rax
leaq (%r14,%r14,4), %rcx
movl (%rax,%rcx,8), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmpq %rax, 0x18(%rsp)
jae 0x1da7f5
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, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rbx, %rdi
movq %rsi, 0x18(%rsp)
callq 0x2370
movq 0x8(%rsp), %rdx
movq %rax, %r15
jmp 0x1da7f8
movq %rbx, %r15
movq 0x10(%rdx), %rdx
shlq $0x3, %r14
leaq (%r14,%r14,4), %r14
movl (%rdx,%r14), %r9d
addq %r14, %rdx
andl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
movq $0x0, (%rsp)
xorl %edi, %edi
movq %r15, %rsi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x36b0d
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rax
movl (%rax,%r14), %esi
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andl %eax, %esi
movq (%r12), %rbx
movq 0x20(%r12), %rcx
movq 0x10(%rbx), %rdx
addq %r14, %rdx
movq %r15, %rdi
movl %ebp, %r8d
callq 0x1da178
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rax
movl (%rax,%r14), %esi
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andl %eax, %esi
addq 0x10(%rbx), %r14
movq %r15, %rbx
movq %r15, %rdi
movq %r14, %rdx
movq %r12, %rcx
movl $0x6, %r8d
callq 0x1da408
movq 0x8(%rsp), %rdx
incl %ebp
movq %rbp, %r14
cmpq %rbp, (%rdx)
ja 0x1da790
jmp 0x1da8ac
xorl %ebx, %ebx
movq $0x0, 0x18(%rsp)
movq 0x20(%rsp), %r13
movq 0x18(%rdx), %rax
movq %rdx, %r14
movl 0x4(%rax), %edi
movl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
andq %r15, %rdi
movl $0x80000000, %ebp       # imm = 0x80000000
movl 0x4(%r13), %eax
andl %ebp, %eax
orl %edi, %eax
movl %eax, 0x4(%r13)
movl %edi, (%r13)
movl $0x18, %esi
callq 0x2120
movq %rax, 0x8(%r13)
movq 0x18(%r14), %rax
movl 0x14(%rax), %edi
andq %r15, %rdi
movl 0x14(%r13), %eax
andl %ebp, %eax
orl %edi, %eax
movl %eax, 0x14(%r13)
movl %edi, 0x10(%r13)
movl $0x8, %esi
callq 0x2120
movq %rax, 0x20(%r13)
testl $0x7fffffff, 0x14(%r13) # imm = 0x7FFFFFFF
je 0x1da965
movq 0x10(%rsp), %rax
movq (%rax), %rax
xorl %ecx, %ecx
xorl %edx, %edx
movq 0x20(%r13), %rsi
movb $0x0, 0x4(%rsi,%rdx,8)
andb $0x7f, 0x3(%rsi,%rdx,8)
movq 0x10(%rax), %rsi
movl (%rsi,%rcx), %esi
shrl %esi
andl $0x3fffffff, %esi       # imm = 0x3FFFFFFF
movq 0x20(%r13), %rdi
movl (%rdi,%rdx,8), %r8d
andl %ebp, %r8d
orl %esi, %r8d
movl %r8d, (%rdi,%rdx,8)
incq %rdx
movl 0x14(%r13), %esi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
addq $0x28, %rcx
cmpq %rsi, %rdx
jb 0x1da920
movq 0x8(%r13), %rdi
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x8(%rax), %rsi
movl 0x4(%r13), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shlq $0x3, %rax
leaq (%rax,%rax,2), %rdx
callq 0x2160
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl 0x4(%r13), %eax
andl %ecx, %eax
movq %rbx, %r14
je 0x1dab9c
xorl %esi, %esi
movl $0x1, %edi
xorl %r12d, %r12d
movq 0x10(%rsp), %rbx
movl %eax, %eax
movl %r12d, %r15d
cmpq %rax, %rdi
je 0x1da9d7
movq 0x8(%r13), %rax
leaq (%r15,%r15,2), %rcx
leaq (%rdi,%rdi,2), %rdx
movq (%rax,%rdx,8), %rdx
xorq (%rax,%rcx,8), %rdx
shrq $0x20, %rdx
je 0x1dab7d
movq %rdi, 0x38(%rsp)
movq 0x8(%r13), %rax
leaq (%r15,%r15,2), %rcx
movl 0xc(%rax,%rcx,8), %ebp
andl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
cmpq %rbp, 0x18(%rsp)
movq %rsi, 0x28(%rsp)
jae 0x1daa42
leaq -0x1(%rbp), %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 %r14, %rdi
movq %rsi, 0x18(%rsp)
callq 0x2370
movq %rax, %r14
movq 0x8(%rsp), %rsi
movq 0x8(%r13), %rax
shlq $0x3, %r15
leaq (%r15,%r15,2), %rbx
movq (%rax,%rbx), %rax
movq %rax, %rcx
shrq $0x21, %rcx
leaq (%rcx,%rcx,4), %rdx
shlq $0x3, %rdx
addq 0x10(%rsi), %rdx
xorl %ecx, %ecx
btq $0x20, %rax
setae %cl
movq $0x0, (%rsp)
xorl %edi, %edi
movq %r14, %rsi
xorl %r8d, %r8d
movq %rbp, %r9
callq 0x36b0d
movslq %r12d, %rax
movq 0x38(%rsp), %rdi
movq %rax, 0x40(%rsp)
cmpq %rax, %rdi
jle 0x1dab70
movq %r14, 0x30(%rsp)
movq 0x8(%r13), %rax
movq 0x20(%r13), %rcx
movq (%rax,%rbx), %rax
shrq $0x21, %rax
movl (%rcx,%rax,8), %r12d
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andl %eax, %r12d
xorl %ebx, %ebx
movq 0x28(%rsp), %r14
xorl %eax, %eax
xorl %r15d, %r15d
movl %eax, %esi
movl %r15d, %edx
movq 0x20(%rsp), %rax
movq 0x8(%rax), %r13
movl 0xc(%r13,%r14), %ebp
movl %ebp, %r15d
andl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
movq 0x30(%rsp), %rdi
movq %r15, %rcx
callq 0x1da681
movl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
movl %eax, %ecx
andl %edi, %ecx
andl $0x80000000, %ebp       # imm = 0x80000000
orl %ecx, %ebp
movl %ebp, 0xc(%r13,%r14)
movq 0x20(%rsp), %r13
movq 0x8(%r13), %rcx
movl 0xc(%rcx,%r14), %edx
andl %edi, %edx
movl %r12d, %esi
subl %edx, %esi
movl %esi, (%rcx,%r14)
subq $0x1, %rbx
jb 0x1dab44
movl 0xc(%rcx,%r14), %edx
andl %edi, %edx
movl 0x24(%rcx,%r14), %ecx
andl %edi, %ecx
cmpl %ecx, %edx
jb 0x1dabca
movq 0x38(%rsp), %rdi
leaq (%rdi,%rbx), %rcx
addq $-0x18, %r14
cmpq 0x40(%rsp), %rcx
jg 0x1daacf
movl %edi, %r12d
movq 0x10(%rsp), %rbx
movq 0x30(%rsp), %r14
movq 0x28(%rsp), %rsi
jmp 0x1dab7d
movl %edi, %r12d
movq 0x28(%rsp), %rsi
movq 0x10(%rsp), %rbx
leaq 0x1(%rdi), %rcx
movl 0x4(%r13), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
addq $0x18, %rsi
cmpq %rax, %rdi
movq %rcx, %rdi
jb 0x1da9af
jmp 0x1daba1
movq 0x10(%rsp), %rbx
movq %r13, %rdi
callq 0xa02fa
movq (%rbx), %rax
movq %r13, 0x18(%rax)
movq %r14, %rdi
callq 0x2220
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5d8ca(%rip), %rdi     # 0x23849b
leaq 0x58db3(%rip), %rsi     # 0x23398b
leaq 0x5d8f0(%rip), %rcx     # 0x2384cf
movl $0x51b9, %edx           # imm = 0x51B9
callq 0x2110