// File: chhylp123[P]hifiasm/Overlaps.cpp
// Function: prt_gen_scaf_path_lst(unsigned long*, unsigned long, unsigned long, ma_ug_t*, ma_ug_t*)
uint64_t prt_gen_scaf_path_lst(uint64_t *a, uint64_t n, uint64_t is_circle, ma_ug_t *hu1, ma_ug_t *hu2)
{
    uint64_t k, nl, el, tl, id, rev, ui, uid; ma_utg_t *u;
    for (k = nl = el = tl = 0; k < n; k++) {
        nl += (a[k]>>32); id = ((uint32_t)a[k])>>1;
        u = ((id<hu1->u.n)?&(hu1->u.a[id]):&(hu2->u.a[id-hu1->u.n]));
        el += u->len;
    }
    tl = el + nl;
    fprintf(stderr, "[M::%s]tot::%lu\tel::%lu\tnl::%lu\tis_c::%lu\t#::%lu\t%s\n", __func__, tl, el, nl, is_circle, n, ((n>1)?"scf":"ctg"));
    for (k = 0; k < n; k++) {
        id = ((uint32_t)a[k])>>1; rev = ((uint32_t)a[k])&1;
        u = ((id<hu1->u.n)?&(hu1->u.a[id]):&(hu2->u.a[id-hu1->u.n]));
        ui = ((id<hu1->u.n)?1:2); nl = (a[k]>>32);
        uid = ((id<hu1->u.n)?(id):(id-hu1->u.n));
        fprintf(stderr, "[M::%s] h%lutg%.6lu%c(%c)\tlen::%u\tNs::%lu\n", __func__,
        ui, uid+1, "lc"[u->circ], "+-"[rev], u->len, nl);
    }
    return tl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x10(%rbp), %rax
jae 0x12d328
movq -0x8(%rbp), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrl %eax
movl %eax, %eax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq -0x20(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x12d2dc
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0x28, -0x50(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
jmp 0x12d2fa
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x50(%rbp), %rcx
movq -0x20(%rbp), %rdx
subq (%rdx), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x12d27f
movq -0x40(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x48(%rbp)
movq 0x296ca5(%rip), %rax    # 0x3c3fe0
movq (%rax), %rax
movq %rax, -0xa8(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x80(%rbp)
cmpq $0x1, -0x10(%rbp)
jbe 0x12d390
leaq 0x259c0e(%rip), %rax    # 0x386f95
movq %rax, -0xb0(%rbp)
jmp 0x12d3a0
leaq 0x259c02(%rip), %rax    # 0x386f99
movq %rax, -0xb0(%rbp)
jmp 0x12d3a0
movq -0x80(%rbp), %r10
movq -0x88(%rbp), %r11
movq -0x90(%rbp), %r9
movq -0x98(%rbp), %r8
movq -0xa0(%rbp), %rcx
movq -0xa8(%rbp), %rdi
movq -0xb0(%rbp), %rax
leaq 0x25b309(%rip), %rsi    # 0x3886de
leaq 0x25b337(%rip), %rdx    # 0x388713
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movb $0x0, %al
callq 0x22a0
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x10(%rbp), %rax
jae 0x12d573
movq -0x8(%rbp), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrl %eax
movl %eax, %eax
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
andl $0x1, %eax
movl %eax, %eax
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rax
movq -0x20(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x12d456
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0x28, -0x50(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0xb8(%rbp)
jmp 0x12d477
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x50(%rbp), %rcx
movq -0x20(%rbp), %rdx
subq (%rdx), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x50(%rbp), %rdx
movq -0x20(%rbp), %rax
movq (%rax), %rsi
movl $0x2, %eax
movl $0x1, %ecx
cmpq %rsi, %rdx
cmovbl %ecx, %eax
cltq
movq %rax, -0x60(%rbp)
movq -0x8(%rbp), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movq %rax, -0x38(%rbp)
movq -0x50(%rbp), %rax
movq -0x20(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x12d4d1
movq -0x50(%rbp), %rax
movq %rax, -0xc0(%rbp)
jmp 0x12d4e3
movq -0x50(%rbp), %rax
movq -0x20(%rbp), %rcx
subq (%rcx), %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
movq %rax, -0x68(%rbp)
movq 0x296aeb(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movq -0x60(%rbp), %rcx
movq -0x68(%rbp), %r8
addq $0x1, %r8
movq -0x70(%rbp), %rax
movl (%rax), %eax
shrl $0x1f, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x257deb(%rip), %rax    # 0x385303
movsbl (%rax,%rdx), %r9d
movq -0x58(%rbp), %rdx
leaq 0x255973(%rip), %rax    # 0x382e9b
movsbl (%rax,%rdx), %r11d
movq -0x70(%rbp), %rax
movl (%rax), %r10d
andl $0x7fffffff, %r10d      # imm = 0x7FFFFFFF
movq -0x38(%rbp), %rax
leaq 0x25b1e3(%rip), %rsi    # 0x388729
leaq 0x25b1c6(%rip), %rdx    # 0x388713
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movb $0x0, %al
callq 0x22a0
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x12d3f9
movq -0x48(%rbp), %rax
addq $0xe0, %rsp
popq %rbp
retq