// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/Correct.cpp
// Function: cal_no_bd_coor(ul_ov_t*, ul_ov_t*, idx_emask_t*, long)
uint64_t cal_no_bd_coor(ul_ov_t *in, ul_ov_t *ou, idx_emask_t *mm, int64_t bd)
{
    int64_t qs, qe, ts, te; emask_t *z;
    qs = in->qs; qe = in->qe; ts = in->ts; te = in->te;
    if(in->sec != ((uint32_t)(0x3fffffff))) {///might be an end mask; no need shrink
        if((in->sec < mm->a[in->qn].n) && (in->tn == mm->a[in->qn].a[in->sec].tn) && (in->rev == mm->a[in->qn].a[in->sec].rev) && 
            (in->qs == mm->a[in->qn].a[in->sec].qs) && (in->qe == mm->a[in->qn].a[in->sec].qe) && 
                (in->ts == mm->a[in->qn].a[in->sec].ts) && (in->te == mm->a[in->qn].a[in->sec].te)) {
            z = &(mm->a[in->qn].a[in->sec]); assert(z->el != ((uint32_t)-1));
            if(z->dir == 0) {
                qe -= (z->el>>1); 
                if(in->rev) ts += (z->el>>1);
                else te -= (z->el>>1);
            } else {
                qs += (z->el>>1); 
                if(in->rev) te -= (z->el>>1);
                else ts += (z->el>>1);
            }
            // fprintf(stderr, "+[M::%s]\tz->dir::%u\tz->el::%u\tq::[%ld,\t%ld)\tt::[%ld,\t%ld)\n", __func__, z->dir, z->el, qs, qe, ts, te); 
        } else {
            assert((in->sec < mm->a[in->tn].n) && (in->qn == mm->a[in->tn].a[in->sec].tn) && (in->rev == mm->a[in->tn].a[in->sec].rev) && 
                (in->qs == mm->a[in->tn].a[in->sec].ts) && (in->qe == mm->a[in->tn].a[in->sec].te) && 
                (in->ts == mm->a[in->tn].a[in->sec].qs) && (in->te == mm->a[in->tn].a[in->sec].qe));
            z = &(mm->a[in->tn].a[in->sec]); assert(z->el != ((uint32_t)-1));
            if(z->dir == 1) {
                qe -= (z->el>>1); 
                if(in->rev) ts += (z->el>>1);
                else te -= (z->el>>1);
            } else {
                qs += (z->el>>1); 
                if(in->rev) te -= (z->el>>1);
                else ts += (z->el>>1);
            }
            // fprintf(stderr, "-[M::%s]\tz->dir::%u\tz->el::%u\tq::[%ld,\t%ld)\tt::[%ld,\t%ld)\n", __func__, z->dir, z->el, qs, qe, ts, te); 
        }
    } else {///shrink anyway
        qs += bd; qe -= bd; ts += bd; te -= bd;
    }
    if(qe > qs && te > ts) {
        (*ou) = (*in);
        ou->qs = qs; ou->qe = qe; ou->ts = ts; ou->te = te;
        return 1;
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl 0x4(%rdi), %r9d
movl 0x8(%rdi), %r8d
movl 0x10(%rdi), %r10d
movl 0x14(%rdi), %r11d
movl 0x18(%rdi), %eax
movl $0x3fffffff, %r14d      # imm = 0x3FFFFFFF
movq %rax, %rbx
andq %r14, %rbx
cmpq %r14, %rbx
jne 0x74ce1
addq %rcx, %r9
subq %rcx, %r8
addq %rcx, %r10
subq %rcx, %r11
jmp 0x74dfb
movq (%rdx), %rdx
movl (%rdi), %ecx
movl 0xc(%rdi), %r14d
leaq (%rcx,%rcx,2), %r15
cmpq %rbx, 0x8(%rdx,%r15,8)
jbe 0x74d6a
leaq (%rdx,%r15,8), %r15
movq (%r15), %r15
movq %rbx, %r12
shlq $0x5, %r12
cmpl (%r15,%r12), %r14d
jne 0x74d6a
addq %r12, %r15
movl %eax, %r12d
shrl $0x1f, %r12d
movzbl 0x1c(%r15), %ebp
movl %ebp, %r13d
shrl $0x7, %r13d
cmpl %r13d, %r12d
jne 0x74d6a
cmpl 0xc(%r15), %r9d
jne 0x74d6a
cmpl 0x10(%r15), %r8d
jne 0x74d6a
cmpl 0x14(%r15), %r10d
jne 0x74d6a
cmpl 0x18(%r15), %r11d
jne 0x74d6a
movl 0x8(%r15), %ecx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
cmpq %rdx, %rcx
je 0x74e87
shrl %ecx
testb $0x1f, %bpl
je 0x74e39
addq %rcx, %r9
testl %eax, %eax
jns 0x74e44
jmp 0x74cd9
leaq (%r14,%r14,2), %r14
cmpq %rbx, 0x8(%rdx,%r14,8)
jbe 0x74e49
leaq (%rdx,%r14,8), %rdx
movq (%rdx), %rdx
shlq $0x5, %rbx
cmpl (%rdx,%rbx), %ecx
jne 0x74e49
addq %rbx, %rdx
movl %eax, %ebx
shrl $0x1f, %ebx
movzbl 0x1c(%rdx), %ecx
movl %ecx, %ebp
shrl $0x7, %ebp
cmpl %ebp, %ebx
jne 0x74e49
cmpl 0x14(%rdx), %r9d
jne 0x74e49
cmpl 0x18(%rdx), %r8d
jne 0x74e49
cmpl 0xc(%rdx), %r10d
jne 0x74e49
cmpl 0x10(%rdx), %r11d
jne 0x74e49
movl 0x8(%rdx), %edx
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpq %rbx, %rdx
je 0x74e68
andb $0x1f, %cl
shrl %edx
cmpb $0x1, %cl
jne 0x74df1
subq %rdx, %r8
testl %eax, %eax
js 0x74df8
subq %rdx, %r11
jmp 0x74dfb
addq %rdx, %r9
testl %eax, %eax
js 0x74dec
addq %rdx, %r10
xorl %eax, %eax
cmpq %r9, %r8
jle 0x74e2a
cmpq %r10, %r11
jle 0x74e2a
movups (%rdi), %xmm0
movups 0xc(%rdi), %xmm1
movups %xmm0, (%rsi)
movups %xmm1, 0xc(%rsi)
movl %r9d, 0x4(%rsi)
movl %r8d, 0x8(%rsi)
movl %r10d, 0x10(%rsi)
movl %r11d, 0x14(%rsi)
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
subq %rcx, %r8
testl %eax, %eax
jns 0x74cd9
addq %rcx, %r10
jmp 0x74dfb
leaq 0x1bf6df(%rip), %rdi    # 0x23452f
leaq 0x1bc8fc(%rip), %rsi    # 0x231753
leaq 0x1bf68b(%rip), %rcx    # 0x2344e9
movl $0x507d, %edx           # imm = 0x507D
callq 0x2110
leaq 0x1bf662(%rip), %rdi    # 0x2344d1
leaq 0x1bc8dd(%rip), %rsi    # 0x231753
leaq 0x1bf66c(%rip), %rcx    # 0x2344e9
movl $0x507e, %edx           # imm = 0x507E
callq 0x2110
leaq 0x1bf643(%rip), %rdi    # 0x2344d1
leaq 0x1bc8be(%rip), %rsi    # 0x231753
leaq 0x1bf64d(%rip), %rcx    # 0x2344e9
movl $0x506f, %edx           # imm = 0x506F
callq 0x2110