// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: init_poa_dp(ma_ug_t*, poa_dp_t*, poa_g_t*, unsigned long, unsigned long*, unsigned long, unsigned long, uc_block_t*, integer_t*)
void init_poa_dp(ma_ug_t *ug, poa_dp_t *dp, poa_g_t *g, uint64_t g_occ, uint64_t *str, uint64_t str_occ, uint64_t is_rev, uc_block_t *raw, integer_t *buf)
{
    kv_resize(uint8_t, dp->dir, (str_occ+1)*(g_occ+1));
    kv_resize(int64_t, dp->sc, (str_occ+1)*(g_occ+1));
    kv_resize(uint64_t, dp->prefix, (str_occ+1)*(g_occ+1));
    dp->n = str_occ+1; dp->m = g_occ+1;
    kv_resize(uint64_t, buf->u, str_occ);
    int64_t *sc = dp->sc.a, bsc, ss; uint8_t *dir = dp->dir.a; uint64_t k, l, *str_w = buf->u.a, *prefix = dp->prefix.a, m; 
    uc_block_t *z; uint32_t *g_idx = g->srt_b.res.a, *n2gidx = g->srt_b.res2nid.a, v, w, a_n, bsc_i; poa_arc_t *a; 
    for (k = 0; k < str_occ; k++) {
        z = &(raw[str[k]>>32]); str_w[k] = ug_occ_w(z->ts, z->te, &(ug->u.a[z->hid]));
    }
    
    sc[poa_dp_idx(*dp, 0, 0)] = dir[poa_dp_idx(*dp, 0, 0)] = 0;
    for (k = 1, l = 0; k < dp->n; k++) {///pat; new ul read
        l += str_w[poa_str_idx(k-1, str_occ, is_rev)];
        sc[poa_dp_idx(*dp, k, 0)] = l;
        dir[poa_dp_idx(*dp, k, 0)] = lstr_dp;
        prefix[poa_dp_idx(*dp, k, 0)] = ((k - 1)<<32);
    }
    
    for (k = 1; k < dp->m; k++) {///ref; graph
        v = (g_idx[k-1]<<1) + 1;
        a_n = poa_arc_n(g, v); a = poa_arc_a(g, v);
        for (m = 0, bsc = bsc_i = 0; m < a_n; m++) {
            w = n2gidx[a[m].v>>1]; assert(w+1 < k);
            ss = sc[poa_dp_idx(*dp, 0, w+1)];
            if(ss < bsc || bsc_i == 0) {
                bsc = ss; bsc_i = w + 1;
            }
        }
        sc[poa_dp_idx(*dp, 0, k)] = bsc + g->seq.a[v>>1].occ;
        dir[poa_dp_idx(*dp, 0, k)] = lref_dp;
        prefix[poa_dp_idx(*dp, 0, k)] = bsc_i;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, %r15
movq %r8, %r14
movq %rcx, %rbp
movq %rdx, 0x8(%rsp)
movq %rsi, %r10
movq %rdi, 0x18(%rsp)
leaq 0x1(%r9), %rbx
incq %rbp
movq %rbx, %r12
imulq %rbp, %r12
cmpq %r12, 0x20(%rsi)
movq %rsi, (%rsp)
jae 0x2034fd
leaq -0x1(%r12), %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 %rsi, 0x20(%r10)
movq 0x28(%r10), %rdi
callq 0x2370
movq (%rsp), %r10
movq %rax, 0x28(%r10)
cmpq %r12, 0x8(%r10)
jae 0x20355a
leaq -0x1(%r12), %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
leaq 0x1(%rcx), %rax
movq %rax, 0x8(%r10)
movq 0x10(%r10), %rdi
leaq 0x8(,%rcx,8), %rsi
callq 0x2370
movq (%rsp), %r10
movq %rax, 0x10(%r10)
movq 0x80(%rsp), %r13
cmpq %r12, 0x38(%r10)
jae 0x2035bd
decq %r12
movq %r12, %rax
shrq %rax
orq %r12, %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, %rax
shrq $0x10, %rax
orq %rcx, %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x38(%r10)
movq 0x40(%r10), %rdi
leaq 0x8(,%rax,8), %rsi
callq 0x2370
movq (%rsp), %r10
movq %rax, 0x40(%r10)
movq %rbx, 0x48(%r10)
movq %rbp, 0x50(%r10)
cmpq %r15, 0x98(%r13)
jae 0x20365a
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, %rcx
shrq $0x10, %rcx
orq %rax, %rcx
leaq 0x1(%rcx), %rax
movq %rax, 0x98(%r13)
movq 0xa0(%r13), %rdi
leaq 0x8(,%rcx,8), %rsi
callq 0x2370
movq (%rsp), %rcx
movq %rax, %r9
movq %rax, 0xa0(%r13)
movq 0x10(%rcx), %r13
movq 0x28(%rcx), %r11
movq 0x40(%rcx), %rbx
movq 0x8(%rsp), %rax
movq 0x90(%rax), %rcx
movq %rcx, 0x20(%rsp)
movq 0xa8(%rax), %r12
jmp 0x20368a
movq 0xa0(%r13), %r9
movq 0x10(%r10), %r13
movq 0x28(%r10), %r11
movq 0x40(%r10), %rbx
movq 0x8(%rsp), %rax
movq 0x90(%rax), %rcx
movq %rcx, 0x20(%rsp)
movq 0xa8(%rax), %r12
testq %r15, %r15
je 0x2036fb
movq %rbx, 0x10(%rsp)
movq %r11, 0x30(%rsp)
movq 0x78(%rsp), %rbx
movq %r15, 0x28(%rsp)
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x18(%rsp)
xorl %ebp, %ebp
movl 0x4(%r14,%rbp,8), %eax
leaq (%rax,%rax,8), %rax
movl (%rbx,%rax,4), %ecx
movl 0xc(%rbx,%rax,4), %edi
movl 0x10(%rbx,%rax,4), %esi
leaq (%rcx,%rcx,4), %rax
movq 0x18(%rsp), %rcx
leaq (%rcx,%rax,8), %rdx
movq %r9, %r15
callq 0x1fe266
movq %r15, %r9
movq %rax, (%r15,%rbp,8)
incq %rbp
cmpq %rbp, 0x28(%rsp)
jne 0x2036ae
movq (%rsp), %r10
movq 0x30(%rsp), %r11
movq 0x10(%rsp), %rbx
movq 0x28(%rsp), %r15
movb $0x0, (%r11)
movq $0x0, (%r13)
cmpq $0x2, 0x48(%r10)
jb 0x20376d
movq 0x70(%rsp), %rax
decq %r15
movl $0x1, %ecx
xorl %edx, %edx
movabsq $0x100000000, %rsi      # imm = 0x100000000
xorl %edi, %edi
leaq -0x1(%rcx), %r8
testq %rax, %rax
cmovneq %r15, %r8
addq (%r9,%r8,8), %rdi
movq 0x50(%r10), %r8
imulq %rcx, %r8
movq %rdi, (%r13,%r8,8)
movq 0x50(%r10), %r8
imulq %rcx, %r8
movb $0x2, (%r11,%r8)
movq 0x50(%r10), %r8
imulq %rcx, %r8
movq %rdx, (%rbx,%r8,8)
incq %rcx
addq %rsi, %rdx
decq %r15
cmpq 0x48(%r10), %rcx
jb 0x203729
cmpq $0x2, 0x50(%r10)
movq 0x8(%rsp), %r15
jb 0x20384a
movl $0x1, %eax
movq %rbx, 0x10(%rsp)
movq 0x20(%rsp), %rcx
movl -0x4(%rcx,%rax,4), %edx
leal (%rdx,%rdx), %esi
movq 0x40(%r15), %rdi
movq 0x8(%rdi,%rsi,8), %rdi
movq %rdi, %rsi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
andq %rcx, %rsi
je 0x20381a
movq %r11, %rcx
movq 0x28(%r15), %r8
shrq $0x20, %rdi
shlq $0x4, %rsi
shlq $0x4, %rdi
addq %r8, %rdi
addq $0x8, %rdi
xorl %r8d, %r8d
xorl %r10d, %r10d
xorl %ebp, %ebp
movl (%rdi,%r8), %r9d
shrl %r9d
movl (%r12,%r9,4), %r11d
incl %r11d
cmpq %r11, %rax
jbe 0x203859
movq (%r13,%r11,8), %r9
cmpq %r10, %r9
setl %bl
testl %ebp, %ebp
sete %r14b
orb %bl, %r14b
jne 0x2037fa
movl %ebp, %r11d
movq %r10, %r9
addq $0x10, %r8
movq %r9, %r10
movl %r11d, %ebp
cmpq %r8, %rsi
jne 0x2037cb
movl %r11d, %esi
movq (%rsp), %r10
movq %rcx, %r11
movq 0x10(%rsp), %rbx
jmp 0x20381f
xorl %esi, %esi
xorl %r9d, %r9d
movq 0x10(%r15), %rdi
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movl (%rdi,%rdx,8), %edx
addq %r9, %rdx
movq %rdx, (%r13,%rax,8)
movb $0x3, (%r11,%rax)
movq %rsi, (%rbx,%rax,8)
incq %rax
cmpq 0x50(%r10), %rax
jb 0x203787
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x43713(%rip), %rdi     # 0x246f73
leaq 0x41da2(%rip), %rsi     # 0x245609
leaq 0x4370d(%rip), %rcx     # 0x246f7b
movl $0x1673, %edx           # imm = 0x1673
callq 0x2110