// File: /workspace/github_cpp_makefile_star2_O3/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 0xa0485
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, 0x28(%rsp)
movq %rax, 0x20(%rbx)
movq %r15, 0x10(%rsp)
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 %rax, 0x18(%r12)
xorl %ebp, %ebp
testq %r13, %r13
je 0x1e4b05
xorl %r14d, %r14d
movq $0x0, 0x18(%rsp)
movq $0x0, 0x8(%rsp)
movq 0x10(%rsp), %rdi
movq 0x10(%rdi), %rdx
leaq (%r14,%r14,4), %rbx
movl (%rdx,%rbx,8), %r9d
andl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
cmpq %r9, 0x18(%rsp)
jae 0x1e4a68
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 %rdi, %r15
movq 0x8(%rsp), %rdi
movq %rsi, 0x18(%rsp)
callq 0x2370
movq %rax, %rsi
movq 0x10(%r15), %rdx
movl (%rdx,%rbx,8), %r9d
andl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
jmp 0x1e4a70
movq %rdi, %r15
movq 0x8(%rsp), %rsi
shlq $0x3, %r14
leaq (%r14,%r14,4), %r14
addq %r14, %rdx
movq $0x0, (%rsp)
xorl %edi, %edi
xorl %ecx, %ecx
movq %rsi, %r13
xorl %r8d, %r8d
callq 0x36049
movq 0x10(%r15), %rax
movl (%rax,%r14), %esi
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andl %eax, %esi
movq 0x28(%rsp), %r12
movq (%r12), %rbx
movq 0x20(%r12), %rcx
movq 0x10(%rbx), %rdx
addq %r14, %rdx
movq %r13, %rdi
movl %ebp, %r8d
callq 0x1e43da
movq 0x10(%r15), %rax
movl (%rax,%r14), %esi
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andl %eax, %esi
addq 0x10(%rbx), %r14
movq %r13, 0x8(%rsp)
movq %r13, %rdi
movq %r14, %rdx
movq %r12, %rcx
movl $0x6, %r8d
callq 0x1e466e
incl %ebp
movq %rbp, %r14
cmpq %rbp, (%r15)
movq %r15, %rdi
movq 0x20(%rsp), %r12
ja 0x1e49f1
jmp 0x1e4b21
movq $0x0, 0x8(%rsp)
movq $0x0, 0x18(%rsp)
movq 0x20(%rsp), %r12
movq 0x10(%rsp), %rdi
movq 0x18(%rdi), %rax
movl 0x4(%rax), %ebp
movl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
andq %r15, %rbp
movl $0x80000000, %ebx       # imm = 0x80000000
movl 0x4(%r12), %eax
andl %ebx, %eax
orl %ebp, %eax
movl %eax, 0x4(%r12)
movl %ebp, (%r12)
movl $0x18, %esi
movq %rdi, %r14
movq %rbp, %rdi
callq 0x2120
movq %rax, %r13
movq %rax, 0x8(%r12)
movq 0x18(%r14), %rax
movl 0x14(%rax), %r14d
andq %r15, %r14
movl 0x14(%r12), %eax
andl %ebx, %eax
orl %r14d, %eax
movl %eax, 0x14(%r12)
movl %r14d, 0x10(%r12)
movl $0x8, %esi
movq %r14, %rdi
callq 0x2120
movq %rax, 0x20(%r12)
testq %r14, %r14
je 0x1e4bf9
movq 0x28(%rsp), %rax
movq (%rax), %rax
xorl %ecx, %ecx
xorl %edx, %edx
movq 0x20(%r12), %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(%r12), %rdi
movl (%rdi,%rdx,8), %r8d
andl %ebx, %r8d
orl %esi, %r8d
movl %r8d, (%rdi,%rdx,8)
incq %rdx
movl 0x14(%r12), %esi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
addq $0x28, %rcx
cmpq %rsi, %rdx
jb 0x1e4ba2
movq 0x8(%r12), %r13
movl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
andl 0x4(%r12), %ebp
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x8(%rax), %rsi
movl %ebp, %eax
shlq $0x3, %rax
leaq (%rax,%rax,2), %rdx
movq %r13, %rdi
callq 0x2160
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl 0x4(%r12), %eax
andl %ecx, %eax
je 0x1e4e17
movl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
movq 0x8(%r12), %r15
xorl %edx, %edx
movl $0x1, %esi
xorl %edi, %edi
movq 0x8(%rsp), %r8
movl %eax, %eax
movl %edi, %ebx
cmpq %rax, %rsi
je 0x1e4c65
leaq (%rbx,%rbx,2), %rax
leaq (%rsi,%rsi,2), %rcx
movq (%r15,%rcx,8), %rcx
xorq (%r15,%rax,8), %rcx
shrq $0x20, %rcx
je 0x1e4df7
movq %rsi, 0x40(%rsp)
leaq (%rbx,%rbx,2), %rax
movl 0xc(%r15,%rax,8), %r13d
andl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
cmpq %r13, 0x18(%rsp)
movq %rdx, 0x30(%rsp)
movl %edi, 0x38(%rsp)
jae 0x1e4cd7
leaq -0x1(%r13), %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 %r8, %rdi
movq %rsi, 0x18(%rsp)
callq 0x2370
movq %rax, %r8
movq 0x8(%r12), %r15
movq 0x10(%rsp), %rsi
shlq $0x3, %rbx
leaq (%rbx,%rbx,2), %r14
movq (%r15,%r14), %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 %r8, 0x8(%rsp)
movq %r8, %rsi
xorl %r8d, %r8d
movq %r13, %r9
callq 0x36049
movq 0x8(%r12), %r15
movslq 0x38(%rsp), %rax
movq 0x40(%rsp), %rsi
movq %rax, 0x38(%rsp)
cmpq %rax, %rsi
jle 0x1e4deb
movq 0x20(%r12), %rax
movq (%r15,%r14), %rcx
shrq $0x21, %rcx
movl (%rax,%rcx,8), %r12d
andl %ebp, %r12d
xorl %r14d, %r14d
movq 0x30(%rsp), %r13
xorl %eax, %eax
xorl %ebx, %ebx
movq 0x8(%rsp), %r8
movl %eax, %esi
movl %ebx, %edx
movl 0xc(%r15,%r13), %ebp
movl %ebp, %ebx
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
movq %r8, %rdi
movq %rbx, %rcx
callq 0x1e48e4
movl %eax, %ecx
movl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
andl %esi, %ecx
andl $0x80000000, %ebp       # imm = 0x80000000
orl %ecx, %ebp
movl %ebp, 0xc(%r15,%r13)
movq 0x20(%rsp), %rcx
movq 0x8(%rcx), %r15
movl 0xc(%r15,%r13), %ecx
andl %esi, %ecx
movl %r12d, %edx
subl %ecx, %edx
movl %edx, (%r15,%r13)
subq $0x1, %r14
jb 0x1e4dc4
movl 0x24(%r15,%r13), %edx
andl %esi, %edx
cmpl %edx, %ecx
jb 0x1e4e4d
movl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
movq 0x40(%rsp), %rsi
leaq (%rsi,%r14), %rcx
addq $-0x18, %r13
cmpq 0x38(%rsp), %rcx
movq 0x8(%rsp), %r8
jg 0x1e4d64
movl %esi, %edi
movq 0x20(%rsp), %r12
jmp 0x1e4df2
movl %esi, %edi
movq 0x8(%rsp), %r8
movq 0x30(%rsp), %rdx
leaq 0x1(%rsi), %rcx
movl 0x4(%r12), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
addq $0x18, %rdx
cmpq %rax, %rsi
movq %rcx, %rsi
jb 0x1e4c42
jmp 0x1e4e1c
movq 0x8(%rsp), %r8
movq %r12, %rdi
movq %r8, %rbx
callq 0xa0a7d
movq 0x28(%rsp), %r14
movq (%r14), %rax
movq %r12, 0x18(%rax)
movq %rbx, %rdi
callq 0x2220
movq %r14, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5f917(%rip), %rdi     # 0x24476b
leaq 0x5ae00(%rip), %rsi     # 0x23fc5b
leaq 0x5f93d(%rip), %rcx     # 0x24479f
movl $0x51b9, %edx           # imm = 0x51B9
callq 0x2110