// File: /workspace/github_cpp_makefile_star2_O1/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 0x1f40db
xorl %eax, %eax
cmpl $-0x1, %edx
je 0x1f3fdd
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 0x1f3fd0
leaq (%rsi,%r11,4), %r11
movl 0x18(%r11), %r11d
addq %r11, %rax
cmpl $-0x1, %r10d
je 0x1f3fe0
cmpl %ecx, %r10d
jae 0x1f3fa3
jmp 0x1f3fe0
movl %edx, %r9d
movl %r9d, %r10d
testq %r8, %r8
je 0x1f401a
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 0x1f40d6
jbe 0x1f40fa
movl %ecx, %ebx
movl %ebx, %r11d
movl %ebx, %edx
leaq (%rdx,%rdx,8), %rbx
movl 0x1c(%rsi,%rbx,4), %ebx
cmpl $-0x1, %ebx
je 0x1f4042
cmpl %r9d, %ebx
jbe 0x1f402b
cmpl $-0x1, %r11d
sete %bl
cmpl %ecx, %r11d
sete %bpl
orb %bl, %bpl
jne 0x1f4075
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 0x1f4075
cmpl %ecx, %ebx
jne 0x1f4058
testq %r8, %r8
je 0x1f40aa
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
leaq (%rdx,%rdx,8), %rcx
movl (%rsi,%rcx,4), %ecx
movl (%rbx,%rcx,8), %ecx
andq %r14, %rcx
subq %rcx, %rax
cmpl %r11d, %r9d
jbe 0x1f4119
xorl %ebx, %ebx
testq %rax, %rax
cmovgq %rax, %rbx
leaq (%r10,%r10,8), %rax
leaq (%rsi,%rax,4), %rax
leaq (%rdx,%rdx,8), %rcx
leaq (%rsi,%rcx,4), %rdx
movq %rax, %rsi
movq %r8, %rcx
callq 0x1f3f03
addq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x45ec2(%rip), %rdi     # 0x239fa4
leaq 0x4523c(%rip), %rsi     # 0x239325
leaq 0x45eba(%rip), %rcx     # 0x239faa
movl $0x114a, %edx           # imm = 0x114A
callq 0x2110
leaq 0x45ea3(%rip), %rdi     # 0x239fa4
leaq 0x4521d(%rip), %rsi     # 0x239325
leaq 0x45e9b(%rip), %rcx     # 0x239faa
movl $0x1157, %edx           # imm = 0x1157
callq 0x2110
leaq 0x45e84(%rip), %rdi     # 0x239fa4
leaq 0x451fe(%rip), %rsi     # 0x239325
leaq 0x45e7c(%rip), %rcx     # 0x239faa
movl $0x1161, %edx           # imm = 0x1161
callq 0x2110