// File: 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
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
cmpq $-0x1, -0x10(%rbp)
je 0x2eee29
movq -0x10(%rbp), %rax
movq %rax, -0x48(%rbp)
movq $0x0, -0x58(%rbp)
jmp 0x2eee3c
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movq $0x1, -0x58(%rbp)
jmp 0x2eee3e
movq -0x58(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x2ef0cb
movq -0x20(%rbp), %rax
movq -0x58(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x28(%rcx), %rcx
movq -0x48(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x38(%rbp), %rax
jae 0x2eef53
movq -0x68(%rbp), %rax
imulq $0x18, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x2eeec8
jmp 0x2eef42
movq -0x68(%rbp), %rax
imulq $0x18, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
cmpq -0x50(%rbp), %rax
jne 0x2eef40
movq -0x68(%rbp), %rax
imulq $0x18, -0x40(%rbp), %rcx
addq %rcx, %rax
movw 0x10(%rax), %ax
andw $0x3fff, %ax            # imm = 0x3FFF
movzwl %ax, %eax
movq %rax, -0x60(%rbp)
movq -0x30(%rbp), %rax
addq -0x60(%rbp), %rax
movq %rax, -0x60(%rbp)
cmpq $0x3fff, -0x60(%rbp)    # imm = 0x3FFF
jbe 0x2eef16
movq $0x3fff, -0x60(%rbp)    # imm = 0x3FFF
movq -0x60(%rbp), %rax
movw %ax, %dx
movq -0x68(%rbp), %rax
imulq $0x18, -0x40(%rbp), %rcx
addq %rcx, %rax
movw 0x10(%rax), %cx
andw $0x3fff, %dx            # imm = 0x3FFF
andw $0xc000, %cx            # imm = 0xC000
orw %dx, %cx
movw %cx, 0x10(%rax)
jmp 0x2eef53
jmp 0x2eef42
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x2eeea1
movq -0x40(%rbp), %rax
cmpq -0x38(%rbp), %rax
jae 0x2eef5f
jmp 0x2eef7e
leaq 0xa55fb(%rip), %rdi     # 0x394561
leaq 0xa18c2(%rip), %rsi     # 0x39082f
movl $0x4b33, %edx           # imm = 0x4B33
leaq 0xa594b(%rip), %rcx     # 0x3948c4
callq 0x2130
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x50(%rbp), %rcx
xorq $0x1, %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x28(%rcx), %rcx
movq -0x50(%rbp), %rdx
xorq $0x1, %rdx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x38(%rbp), %rax
jae 0x2ef087
movq -0x68(%rbp), %rax
imulq $0x18, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x2eeff5
jmp 0x2ef076
movq -0x68(%rbp), %rax
imulq $0x18, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq -0x48(%rbp), %rcx
xorq $0x1, %rcx
cmpq %rcx, %rax
jne 0x2ef074
movq -0x68(%rbp), %rax
imulq $0x18, -0x40(%rbp), %rcx
addq %rcx, %rax
movw 0x10(%rax), %ax
andw $0x3fff, %ax            # imm = 0x3FFF
movzwl %ax, %eax
movq %rax, -0x60(%rbp)
movq -0x30(%rbp), %rax
addq -0x60(%rbp), %rax
movq %rax, -0x60(%rbp)
cmpq $0x3fff, -0x60(%rbp)    # imm = 0x3FFF
jbe 0x2ef04a
movq $0x3fff, -0x60(%rbp)    # imm = 0x3FFF
movq -0x60(%rbp), %rax
movw %ax, %dx
movq -0x68(%rbp), %rax
imulq $0x18, -0x40(%rbp), %rcx
addq %rcx, %rax
movw 0x10(%rax), %cx
andw $0x3fff, %dx            # imm = 0x3FFF
andw $0xc000, %cx            # imm = 0xC000
orw %dx, %cx
movw %cx, 0x10(%rax)
jmp 0x2ef087
jmp 0x2ef076
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x2eefcb
movq -0x40(%rbp), %rax
cmpq -0x38(%rbp), %rax
jae 0x2ef093
jmp 0x2ef0b2
leaq 0xa54c7(%rip), %rdi     # 0x394561
leaq 0xa178e(%rip), %rsi     # 0x39082f
movl $0x4b3f, %edx           # imm = 0x4B3F
leaq 0xa5817(%rip), %rcx     # 0x3948c4
callq 0x2130
movq -0x50(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x2eee3e
cmpq $-0x1, -0x18(%rbp)
je 0x2ef336
movq -0x18(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x28(%rcx), %rcx
movq -0x48(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x38(%rbp), %rax
jae 0x2ef1d5
movq -0x68(%rbp), %rax
imulq $0x18, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x2ef14a
jmp 0x2ef1c4
movq -0x68(%rbp), %rax
imulq $0x18, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
cmpq -0x50(%rbp), %rax
jne 0x2ef1c2
movq -0x68(%rbp), %rax
imulq $0x18, -0x40(%rbp), %rcx
addq %rcx, %rax
movw 0x10(%rax), %ax
andw $0x3fff, %ax            # imm = 0x3FFF
movzwl %ax, %eax
movq %rax, -0x60(%rbp)
movq -0x30(%rbp), %rax
addq -0x60(%rbp), %rax
movq %rax, -0x60(%rbp)
cmpq $0x3fff, -0x60(%rbp)    # imm = 0x3FFF
jbe 0x2ef198
movq $0x3fff, -0x60(%rbp)    # imm = 0x3FFF
movq -0x60(%rbp), %rax
movw %ax, %dx
movq -0x68(%rbp), %rax
imulq $0x18, -0x40(%rbp), %rcx
addq %rcx, %rax
movw 0x10(%rax), %cx
andw $0x3fff, %dx            # imm = 0x3FFF
andw $0xc000, %cx            # imm = 0xC000
orw %dx, %cx
movw %cx, 0x10(%rax)
jmp 0x2ef1d5
jmp 0x2ef1c4
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x2ef123
movq -0x40(%rbp), %rax
cmpq -0x38(%rbp), %rax
jae 0x2ef1e1
jmp 0x2ef200
leaq 0xa5379(%rip), %rdi     # 0x394561
leaq 0xa1640(%rip), %rsi     # 0x39082f
movl $0x4b51, %edx           # imm = 0x4B51
leaq 0xa56c9(%rip), %rcx     # 0x3948c4
callq 0x2130
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x50(%rbp), %rcx
xorq $0x1, %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x28(%rcx), %rcx
movq -0x50(%rbp), %rdx
xorq $0x1, %rdx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x38(%rbp), %rax
jae 0x2ef309
movq -0x68(%rbp), %rax
imulq $0x18, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x2ef277
jmp 0x2ef2f8
movq -0x68(%rbp), %rax
imulq $0x18, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq -0x48(%rbp), %rcx
xorq $0x1, %rcx
cmpq %rcx, %rax
jne 0x2ef2f6
movq -0x68(%rbp), %rax
imulq $0x18, -0x40(%rbp), %rcx
addq %rcx, %rax
movw 0x10(%rax), %ax
andw $0x3fff, %ax            # imm = 0x3FFF
movzwl %ax, %eax
movq %rax, -0x60(%rbp)
movq -0x30(%rbp), %rax
addq -0x60(%rbp), %rax
movq %rax, -0x60(%rbp)
cmpq $0x3fff, -0x60(%rbp)    # imm = 0x3FFF
jbe 0x2ef2cc
movq $0x3fff, -0x60(%rbp)    # imm = 0x3FFF
movq -0x60(%rbp), %rax
movw %ax, %dx
movq -0x68(%rbp), %rax
imulq $0x18, -0x40(%rbp), %rcx
addq %rcx, %rax
movw 0x10(%rax), %cx
andw $0x3fff, %dx            # imm = 0x3FFF
andw $0xc000, %cx            # imm = 0xC000
orw %dx, %cx
movw %cx, 0x10(%rax)
jmp 0x2ef309
jmp 0x2ef2f8
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x2ef24d
movq -0x40(%rbp), %rax
cmpq -0x38(%rbp), %rax
jae 0x2ef315
jmp 0x2ef334
leaq 0xa5245(%rip), %rdi     # 0x394561
leaq 0xa150c(%rip), %rsi     # 0x39082f
movl $0x4b5e, %edx           # imm = 0x4B5E
leaq 0xa5595(%rip), %rcx     # 0x3948c4
callq 0x2130
jmp 0x2ef336
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)