// File: /workspace/github_cpp_makefile_star2_O1/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, %rbx
movq %rcx, %rbp
movq %rdx, 0x18(%rsp)
movq %rsi, %rdx
movq %rdi, 0x10(%rsp)
leaq 0x1(%r9), %r13
incq %rbp
movq %r13, %r12
imulq %rbp, %r12
cmpq %r12, 0x20(%rsi)
movq %rsi, 0x8(%rsp)
jae 0x1f7ecf
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(%rdx)
movq 0x28(%rdx), %rdi
callq 0x2370
movq 0x8(%rsp), %rdx
movq %rax, 0x28(%rdx)
movq %rbx, %r14
cmpq %r12, 0x8(%rdx)
jae 0x1f7f30
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(%rdx)
movq 0x10(%rdx), %rdi
leaq 0x8(,%rcx,8), %rsi
callq 0x2370
movq 0x8(%rsp), %rdx
movq %rax, 0x10(%rdx)
movq 0x80(%rsp), %rbx
cmpq %r12, 0x38(%rdx)
jae 0x1f7f94
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(%rdx)
movq 0x40(%rdx), %rdi
leaq 0x8(,%rax,8), %rsi
callq 0x2370
movq 0x8(%rsp), %rdx
movq %rax, 0x40(%rdx)
movq %r13, 0x48(%rdx)
movq %rbp, 0x50(%rdx)
cmpq %r15, 0x98(%rbx)
jae 0x1f8005
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(%rbx)
movq 0xa0(%rbx), %rdi
leaq 0x8(,%rcx,8), %rsi
callq 0x2370
movq 0x8(%rsp), %rdx
movq %rax, 0xa0(%rbx)
movq 0x10(%rdx), %rbp
movq 0x28(%rdx), %rax
movq %rax, 0x20(%rsp)
movq 0xa0(%rbx), %rsi
movq 0x40(%rdx), %rax
movq %rax, 0x28(%rsp)
movq 0x18(%rsp), %rax
movq 0x90(%rax), %rcx
movq %rcx, 0x30(%rsp)
movq 0xa8(%rax), %rbx
testq %r15, %r15
je 0x1f8099
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
xorl %r12d, %r12d
movl 0x4(%r14,%r12,8), %eax
leaq (%rax,%rax,8), %rax
movq 0x78(%rsp), %rdx
movl (%rdx,%rax,4), %ecx
movl 0xc(%rdx,%rax,4), %edi
movq %r15, %r13
movq %r14, %r15
movq %rsi, %r14
movl 0x10(%rdx,%rax,4), %esi
leaq (%rcx,%rcx,4), %rax
movq 0x10(%rsp), %rcx
leaq (%rcx,%rax,8), %rdx
callq 0x1f2d50
movq %r14, %rsi
movq %r15, %r14
movq %r13, %r15
movq %rax, (%rsi,%r12,8)
incq %r12
cmpq %r12, %r13
jne 0x1f8050
movq 0x20(%rsp), %r11
movb $0x0, (%r11)
movq $0x0, (%rbp)
movq 0x8(%rsp), %r10
cmpq $0x2, 0x48(%r10)
movq 0x28(%rsp), %r9
jb 0x1f811d
movq %rsi, %r14
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 (%r14,%r8,8), %rdi
movq 0x50(%r10), %r8
imulq %rcx, %r8
movq %rdi, (%rbp,%r8,8)
movq 0x50(%r10), %r8
imulq %rcx, %r8
movb $0x2, (%r11,%r8)
movq 0x50(%r10), %r8
imulq %rcx, %r8
movq %rdx, (%r9,%r8,8)
incq %rcx
addq %rsi, %rdx
decq %r15
cmpq 0x48(%r10), %rcx
jb 0x1f80d9
cmpq $0x2, 0x50(%r10)
movq 0x18(%rsp), %r13
jb 0x1f81fc
movl $0x1, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq 0x30(%rsp), %rdx
movl -0x4(%rdx,%rax,4), %edx
leal (%rdx,%rdx), %esi
movq 0x40(%r13), %rdi
movq 0x8(%rdi,%rsi,8), %rdi
movq %rdi, %rsi
andq %rcx, %rsi
je 0x1f81c7
movq 0x28(%r13), %r8
shrq $0x20, %rdi
shlq $0x4, %rsi
shlq $0x4, %rdi
addq %r8, %rdi
addq $0x8, %rdi
xorl %r8d, %r8d
xorl %r10d, %r10d
xorl %r15d, %r15d
movl (%rdi,%r8), %r9d
shrl %r9d
movl (%rbx,%r9,4), %r11d
incl %r11d
cmpq %r11, %rax
jbe 0x1f820b
movq (%rbp,%r11,8), %r9
cmpq %r10, %r9
setl %r14b
testl %r15d, %r15d
sete %r12b
orb %r14b, %r12b
jne 0x1f81a9
movl %r15d, %r11d
movq %r10, %r9
addq $0x10, %r8
movq %r9, %r10
movl %r11d, %r15d
cmpq %r8, %rsi
jne 0x1f8174
movl %r11d, %esi
movq 0x8(%rsp), %r10
movq 0x20(%rsp), %r11
jmp 0x1f81cc
xorl %esi, %esi
xorl %r9d, %r9d
movq 0x10(%r13), %rdi
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movl (%rdi,%rdx,8), %edx
addq %r9, %rdx
movq %rdx, (%rbp,%rax,8)
movb $0x3, (%r11,%rax)
movq 0x28(%rsp), %rdx
movq %rsi, (%rdx,%rax,8)
incq %rax
cmpq 0x50(%r10), %rax
jb 0x1f8137
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x42a7d(%rip), %rdi     # 0x23ac8f
leaq 0x4110c(%rip), %rsi     # 0x239325
leaq 0x42a77(%rip), %rcx     # 0x23ac97
movl $0x1673, %edx           # imm = 0x1673
callq 0x2110