// File: /workspace/github_cpp_makefile_star2_O2/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 0x1b3523
xorl %eax, %eax
movl %edx, %r9d
movl %edx, %r11d
cmpl $-0x1, %r11d
je 0x1b342f
movl %r11d, %r10d
cmpl %ecx, %r11d
jb 0x1b342f
movl %r10d, %r9d
imulq $0x24, %r9, %rbx
movl 0x14(%rsi,%rbx), %r11d
cmpl $-0x1, %r11d
sete %r9b
cmpl %ecx, %r10d
setbe %bpl
orb %r9b, %bpl
movl %r10d, %r9d
jne 0x1b33ef
addq %rsi, %rbx
movl 0x18(%rbx), %r9d
addq %r9, %rax
movl %r10d, %r9d
jmp 0x1b33ef
movl %r9d, %r10d
testq %r8, %r8
je 0x1b3469
movq 0x18(%rdi), %r11
movq 0x20(%r11), %r11
imulq $0x24, %r10, %rbx
movl (%rsi,%rbx), %ebx
movl (%r11,%rbx,8), %ebx
movl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
andq %r14, %rbx
addq %rbx, %rax
movl %edx, %edx
imulq $0x24, %rdx, %rdx
movl (%rsi,%rdx), %edx
movl (%r11,%rdx,8), %edx
andq %r14, %rdx
subq %rdx, %rax
cmpl %ecx, %r9d
je 0x1b351e
jbe 0x1b3542
movl %ecx, %ebx
movl %ecx, %edx
cmpl $-0x1, %ebx
je 0x1b3499
movl %ebx, %r11d
cmpl %r9d, %ebx
ja 0x1b3499
movl %r11d, %edx
imulq $0x24, %rdx, %rdx
movl 0x1c(%rsi,%rdx), %ebx
movl %r11d, %edx
jmp 0x1b347c
movl %edx, %r11d
cmpl $-0x1, %r11d
je 0x1b34bc
cmpl %ecx, %r11d
je 0x1b34bc
movl %r11d, %r11d
imulq $0x24, %r11, %rbx
movl 0x14(%rsi,%rbx), %r11d
movl 0x18(%rsi,%rbx), %ebx
addq %rbx, %rax
jmp 0x1b349c
movl %edx, %r11d
testq %r8, %r8
je 0x1b34f4
movq 0x18(%rdi), %rbx
movq 0x20(%rbx), %rbx
movl %ecx, %ecx
imulq $0x24, %rcx, %rcx
movl (%rsi,%rcx), %ecx
movl (%rbx,%rcx,8), %ecx
movl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
andq %r14, %rcx
addq %rcx, %rax
imulq $0x24, %r11, %rcx
movl (%rsi,%rcx), %ecx
movl (%rbx,%rcx,8), %ecx
andq %r14, %rcx
subq %rcx, %rax
cmpl %edx, %r9d
jbe 0x1b3561
xorl %ebx, %ebx
testq %rax, %rax
cmovgq %rax, %rbx
imulq $0x24, %r10, %rax
addq %rsi, %rax
imulq $0x24, %r11, %rdx
addq %rsi, %rdx
movq %rax, %rsi
movq %r8, %rcx
callq 0x1b3351
addq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x44c2e(%rip), %rdi     # 0x1f8158
leaq 0x43fa8(%rip), %rsi     # 0x1f74d9
leaq 0x44c26(%rip), %rcx     # 0x1f815e
movl $0x114a, %edx           # imm = 0x114A
callq 0x2110
leaq 0x44c0f(%rip), %rdi     # 0x1f8158
leaq 0x43f89(%rip), %rsi     # 0x1f74d9
leaq 0x44c07(%rip), %rcx     # 0x1f815e
movl $0x1157, %edx           # imm = 0x1157
callq 0x2110
leaq 0x44bf0(%rip), %rdi     # 0x1f8158
leaq 0x43f6a(%rip), %rsi     # 0x1f74d9
leaq 0x44be8(%rip), %rcx     # 0x1f815e
movl $0x1161, %edx           # imm = 0x1161
callq 0x2110