// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/inter.cpp
// Function: append_path_connec(asg_t*, unsigned long, unsigned long, unsigned long*, unsigned long, unsigned long)
void append_path_connec(asg_t *g, uint64_t sn, uint64_t en, uint64_t *pa, uint64_t pn, uint64_t min_ou)
{
	uint64_t nv, k, v, w, i, ou; asg_arc_t *av;
    if(sn != (uint64_t)-1) {
        v = sn; i = 0;
    } else {
        v = pa[0]; i = 1; 
    }

    for (; i < pn; i++) {
        w = pa[i]; 

        nv = asg_arc_n(g, v); av = asg_arc_a(g, v);
        for (k = 0; k < nv; k++) {
            if(av[k].del) continue;
            if(av[k].v == w) {
				ou = av[k].ou; ou += min_ou; 
				if(ou > OU_MASK) ou = OU_MASK;
				av[k].ou = ou;
                break;
            }
        }
		assert(k < nv);

        nv = asg_arc_n(g, w^1); av = asg_arc_a(g, w^1);
        for (k = 0; k < nv; k++) {
            if(av[k].del) continue;
            if(av[k].v == (v^1)) {
                ou = av[k].ou; ou += min_ou; 
				if(ou > OU_MASK) ou = OU_MASK;
				av[k].ou = ou;
                break;
            }
        }
		assert(k < nv);

        v = w;
    }
    // fprintf(stderr, "-3-[M::%s::]\n", __func__); 
    if(en != (uint64_t)-1) {
        w = en;
        // fprintf(stderr, "-3a-[M::%s::]\n", __func__); 
        nv = asg_arc_n(g, v); av = asg_arc_a(g, v);
        for (k = 0; k < nv; k++) {
            if(av[k].del) continue;
            if(av[k].v == w) {
                ou = av[k].ou; ou += min_ou; 
				if(ou > OU_MASK) ou = OU_MASK;
				av[k].ou = ou;
                break;
            }
        }
		assert(k < nv);

        // fprintf(stderr, "-3b-[M::%s::]\n", __func__); 
        nv = asg_arc_n(g, w^1); av = asg_arc_a(g, w^1);
        for (k = 0; k < nv; k++) {
            if(av[k].del) continue;
            if(av[k].v == (v^1)) {
                ou = av[k].ou; ou += min_ou; 
				if(ou > OU_MASK) ou = OU_MASK;
				av[k].ou = ou;
                break;
            }
        }
		assert(k < nv);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
cmpq $-0x1, %rsi
je 0x1d5df5
xorl %r10d, %r10d
jmp 0x1d5dfe
movq (%rcx), %rsi
movl $0x1, %r10d
movq %rdx, (%rsp)
cmpq %r8, %r10
jae 0x1d5f2f
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl $0x3fff, %ebx           # imm = 0x3FFF
movq 0x28(%rdi), %rax
movq (%rax,%rsi,8), %r14
movq %r14, %r12
andq %rdx, %r12
je 0x1d6084
movq (%rcx,%r10,8), %rax
movq 0x8(%rdi), %r15
shrq $0x20, %r14
shlq $0x3, %r12
leaq (%r12,%r12,2), %r13
leaq (%r14,%r14,2), %r12
leaq (%r15,%r12,8), %rbp
addq $0x10, %rbp
xorl %r14d, %r14d
cmpl $0x0, -0x4(%rbp,%r14)
js 0x1d5e5e
movl -0x8(%rbp,%r14), %r11d
cmpq %r11, %rax
je 0x1d5e6c
addq $0x18, %r14
cmpq %r14, %r13
jne 0x1d5e4c
jmp 0x1d6084
leaq (%r15,%r12,8), %r11
movzwl 0x10(%r14,%r11), %r15d
movq %r15, %r12
andq %rbx, %r12
addq %r9, %r12
cmpq %rbx, %r12
cmovaeq %rbx, %r12
andl $0xc000, %r15d          # imm = 0xC000
orl %r12d, %r15d
movw %r15w, 0x10(%r14,%r11)
movq 0x28(%rdi), %r11
movq %rax, %r14
xorq $0x1, %r14
movq (%r11,%r14,8), %r14
movq %r14, %r12
andq %rdx, %r12
je 0x1d60a3
movq 0x8(%rdi), %r15
shrq $0x20, %r14
shlq $0x3, %r12
leaq (%r12,%r12,2), %r13
leaq (%r14,%r14,2), %r12
leaq (%r15,%r12,8), %rbp
addq $0x10, %rbp
xorl %r14d, %r14d
cmpl $0x0, -0x4(%rbp,%r14)
js 0x1d5ee6
movl -0x8(%rbp,%r14), %r11d
xorq %rsi, %r11
cmpq $0x1, %r11
je 0x1d5ef4
addq $0x18, %r14
cmpq %r14, %r13
jne 0x1d5ed0
jmp 0x1d60a3
leaq (%r15,%r12,8), %rsi
movzwl 0x10(%r14,%rsi), %r11d
movq %r11, %r15
andq %rbx, %r15
addq %r9, %r15
cmpq %rbx, %r15
cmovaeq %rbx, %r15
andl $0xc000, %r11d          # imm = 0xC000
orl %r15d, %r11d
movw %r11w, 0x10(%r14,%rsi)
incq %r10
movq %rax, %rsi
cmpq %r8, %r10
jne 0x1d5e15
jmp 0x1d5f32
movq %rsi, %rax
movq (%rsp), %rbx
cmpq $-0x1, %rbx
je 0x1d6075
movq 0x28(%rdi), %rcx
movq (%rcx,%rax,8), %rcx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
andq %rcx, %r8
je 0x1d5f8c
movq 0x8(%rdi), %rsi
shrq $0x20, %rcx
shlq $0x3, %r8
leaq (%r8,%r8,2), %r10
leaq (%rcx,%rcx,2), %r8
leaq (%rsi,%r8,8), %r11
addq $0x10, %r11
xorl %ecx, %ecx
cmpl $0x0, -0x4(%r11,%rcx)
js 0x1d5f83
movl -0x8(%r11,%rcx), %edx
cmpq %rbx, %rdx
je 0x1d5fab
addq $0x18, %rcx
cmpq %rcx, %r10
jne 0x1d5f71
leaq 0x6172a(%rip), %rdi     # 0x2376bd
leaq 0x5d9f1(%rip), %rsi     # 0x23398b
leaq 0x61a7f(%rip), %rcx     # 0x237a20
movl $0x4b51, %edx           # imm = 0x4B51
callq 0x2110
leaq (%rsi,%r8,8), %rdx
movzwl 0x10(%rcx,%rdx), %esi
movl $0x3fff, %r8d           # imm = 0x3FFF
movq %rsi, %r10
andq %r8, %r10
addq %r9, %r10
cmpq %r8, %r10
cmovaeq %r8, %r10
andl $0xc000, %esi           # imm = 0xC000
orl %r10d, %esi
movw %si, 0x10(%rcx,%rdx)
movq 0x28(%rdi), %rcx
xorq $0x1, %rbx
movq (%rcx,%rbx,8), %rcx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
andq %rcx, %rsi
je 0x1d602b
movq 0x8(%rdi), %rdx
shrq $0x20, %rcx
shlq $0x3, %rsi
leaq (%rsi,%rsi,2), %rdi
leaq (%rcx,%rcx,2), %rsi
leaq (%rdx,%rsi,8), %r8
addq $0x10, %r8
xorl %ecx, %ecx
cmpl $0x0, -0x4(%r8,%rcx)
js 0x1d6022
movl -0x8(%r8,%rcx), %r10d
xorq %rax, %r10
cmpq $0x1, %r10
je 0x1d604a
addq $0x18, %rcx
cmpq %rcx, %rdi
jne 0x1d600c
leaq 0x6168b(%rip), %rdi     # 0x2376bd
leaq 0x5d952(%rip), %rsi     # 0x23398b
leaq 0x619e0(%rip), %rcx     # 0x237a20
movl $0x4b5e, %edx           # imm = 0x4B5E
callq 0x2110
leaq (%rdx,%rsi,8), %rax
movzwl 0x10(%rcx,%rax), %edx
movl $0x3fff, %esi           # imm = 0x3FFF
movq %rdx, %rdi
andq %rsi, %rdi
addq %r9, %rdi
cmpq %rsi, %rdi
cmovaeq %rsi, %rdi
andl $0xc000, %edx           # imm = 0xC000
orl %edi, %edx
movw %dx, 0x10(%rcx,%rax)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x61632(%rip), %rdi     # 0x2376bd
leaq 0x5d8f9(%rip), %rsi     # 0x23398b
leaq 0x61987(%rip), %rcx     # 0x237a20
movl $0x4b33, %edx           # imm = 0x4B33
callq 0x2110
leaq 0x61613(%rip), %rdi     # 0x2376bd
leaq 0x5d8da(%rip), %rsi     # 0x23398b
leaq 0x61968(%rip), %rcx     # 0x237a20
movl $0x4b3f, %edx           # imm = 0x4B3F
callq 0x2110