// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: normlize_gdis_exact(ma_ug_t*, uc_block_t*, unsigned int, unsigned int, long)
int64_t normlize_gdis_exact(ma_ug_t *ug, uc_block_t *a, uint32_t i, uint32_t k, int64_t is_i2k_forward)
{
    assert(i > k);
    uint32_t li, lk, pk, bi = i; int64_t l;
    for (li = i, l = 0; i != (uint32_t)-1 && i >= k; i = a[i].pidx) {
        li = i; 
        if(a[i].pidx != (uint32_t)-1 && i > k) l += a[i].pdis;
    }
    
    if(is_i2k_forward) {
        l += (int64_t)(ug->g->seq[a[li].hid].len);
        l -= (int64_t)(ug->g->seq[a[bi].hid].len);
    }
    i = li;
    if(i == k) return l;
    assert(i > k); pk = k;
    for (lk = k; k != (uint32_t)-1 && k <= i; k = a[k].aidx) lk = k;
    for (k = lk; k != (uint32_t)-1 && k != pk; k = a[k].pidx) l += a[k].pdis;
    // assert(k == pk);
    if(is_i2k_forward) {
        l += (int64_t)(ug->g->seq[a[pk].hid].len);
        l -= (int64_t)(ug->g->seq[a[lk].hid].len);
    }
    if(l < 0) l = 0;
    k = lk;
    assert(i > k);
    return l + normlize_gdis(ug, &(a[i]), &(a[k]), is_i2k_forward);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
cmpl %ecx, %edx
jbe 0x1ff5ee
cmpl $-0x1, %edx
je 0x1ff501
xorl %eax, %eax
movl %edx, %r10d
movl %r10d, %r9d
movl %r10d, %r10d
leaq (%r10,%r10,8), %r11
movl 0x14(%rsi,%r11,4), %r10d
cmpl $-0x1, %r10d
sete %bl
cmpl %ecx, %r9d
setbe %bpl
orb %bl, %bpl
jne 0x1ff4f4
leaq (%rsi,%r11,4), %r11
movl 0x18(%r11), %r11d
addq %r11, %rax
cmpl $-0x1, %r10d
je 0x1ff509
cmpl %ecx, %r10d
jae 0x1ff4c7
jmp 0x1ff509
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
xorl %eax, %eax
movl %r9d, %r10d
testq %r8, %r8
je 0x1ff543
movq 0x18(%rdi), %r11
movq 0x20(%r11), %r11
leaq (%r10,%r10,8), %rbx
movl (%rsi,%rbx,4), %ebx
movl (%r11,%rbx,8), %ebx
movl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
andq %r14, %rbx
addq %rbx, %rax
movl %edx, %edx
leaq (%rdx,%rdx,8), %rdx
movl (%rsi,%rdx,4), %edx
movl (%r11,%rdx,8), %edx
andq %r14, %rdx
subq %rdx, %rax
cmpl %ecx, %r9d
je 0x1ff5e9
jbe 0x1ff60d
movl %ecx, %ebx
movl %ebx, %r11d
movl %ebx, %edx
leaq (%rdx,%rdx,8), %rdx
movl 0x1c(%rsi,%rdx,4), %ebx
cmpl $-0x1, %ebx
je 0x1ff56b
cmpl %r9d, %ebx
jbe 0x1ff554
cmpl %ecx, %r11d
je 0x1ff590
movl %r11d, %ebx
movq %rax, %r14
movl %ebx, %eax
leaq (%rax,%rax,8), %rax
movl 0x14(%rsi,%rax,4), %ebx
movl 0x18(%rsi,%rax,4), %eax
addq %r14, %rax
cmpl $-0x1, %ebx
je 0x1ff590
cmpl %ecx, %ebx
jne 0x1ff573
testq %r8, %r8
je 0x1ff5c1
movq 0x18(%rdi), %rbx
movq 0x20(%rbx), %rbx
movl %ecx, %ecx
leaq (%rcx,%rcx,8), %rcx
movl (%rsi,%rcx,4), %ecx
movl (%rbx,%rcx,8), %ecx
movl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
andq %r14, %rcx
addq %rcx, %rax
movl (%rsi,%rdx,4), %ecx
movl (%rbx,%rcx,8), %ecx
andq %r14, %rcx
subq %rcx, %rax
cmpl %r11d, %r9d
jbe 0x1ff62c
xorl %ebx, %ebx
testq %rax, %rax
cmovgq %rax, %rbx
leaq (%r10,%r10,8), %rax
leaq (%rsi,%rax,4), %rax
leaq (%rsi,%rdx,4), %rdx
movq %rax, %rsi
movq %r8, %rcx
callq 0x1ff427
addq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x46c93(%rip), %rdi     # 0x246288
leaq 0x4600d(%rip), %rsi     # 0x245609
leaq 0x46c8b(%rip), %rcx     # 0x24628e
movl $0x114a, %edx           # imm = 0x114A
callq 0x2110
leaq 0x46c74(%rip), %rdi     # 0x246288
leaq 0x45fee(%rip), %rsi     # 0x245609
leaq 0x46c6c(%rip), %rcx     # 0x24628e
movl $0x1157, %edx           # imm = 0x1157
callq 0x2110
leaq 0x46c55(%rip), %rdi     # 0x246288
leaq 0x45fcf(%rip), %rsi     # 0x245609
leaq 0x46c4d(%rip), %rcx     # 0x24628e
movl $0x1161, %edx           # imm = 0x1161
callq 0x2110