// File: /workspace/github_cpp_makefile_star2_O1/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 %r12
pushq %rbx
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 0x75280
addq %rcx, %r9
subq %rcx, %r8
addq %rcx, %r10
subq %rcx, %r11
jmp 0x75399
movq (%rdx), %rdx
movl (%rdi), %ecx
leaq (%rcx,%rcx,2), %r14
cmpq %rbx, 0x8(%rdx,%r14,8)
jbe 0x75308
leaq (%rdx,%r14,8), %r14
movl 0xc(%rdi), %ebp
movq (%r14), %r14
movq %rbx, %r15
shlq $0x5, %r15
cmpl (%r14,%r15), %ebp
jne 0x75308
addq %r15, %r14
movl %eax, %r15d
shrl $0x1f, %r15d
movzbl 0x1c(%r14), %ebp
movl %ebp, %r12d
shrl $0x7, %r12d
cmpl %r12d, %r15d
jne 0x75308
cmpl 0xc(%r14), %r9d
jne 0x75308
cmpl 0x10(%r14), %r8d
jne 0x75308
cmpl 0x14(%r14), %r10d
jne 0x75308
cmpl 0x18(%r14), %r11d
jne 0x75308
movl 0x8(%r14), %ecx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
cmpq %rdx, %rcx
je 0x7541f
shrl %ecx
testb $0x1f, %bpl
je 0x753d1
addq %rcx, %r9
testl %eax, %eax
jns 0x753dc
jmp 0x75278
movl 0xc(%rdi), %r14d
leaq (%r14,%r14,2), %r14
cmpq %rbx, 0x8(%rdx,%r14,8)
jbe 0x753e1
leaq (%rdx,%r14,8), %rdx
movq (%rdx), %rdx
shlq $0x5, %rbx
cmpl (%rdx,%rbx), %ecx
jne 0x753e1
addq %rbx, %rdx
movl %eax, %ebx
shrl $0x1f, %ebx
movzbl 0x1c(%rdx), %ecx
movl %ecx, %ebp
shrl $0x7, %ebp
cmpl %ebp, %ebx
jne 0x753e1
cmpl 0x14(%rdx), %r9d
jne 0x753e1
cmpl 0x18(%rdx), %r8d
jne 0x753e1
cmpl 0xc(%rdx), %r10d
jne 0x753e1
cmpl 0x10(%rdx), %r11d
jne 0x753e1
movl 0x8(%rdx), %edx
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpq %rbx, %rdx
je 0x75400
andb $0x1f, %cl
shrl %edx
cmpb $0x1, %cl
jne 0x7538f
subq %rdx, %r8
testl %eax, %eax
js 0x75396
subq %rdx, %r11
jmp 0x75399
addq %rdx, %r9
testl %eax, %eax
js 0x7538a
addq %rdx, %r10
xorl %eax, %eax
cmpq %r9, %r8
jle 0x753c8
cmpq %r10, %r11
jle 0x753c8
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
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
subq %rcx, %r8
testl %eax, %eax
jns 0x75278
addq %rcx, %r10
jmp 0x75399
leaq 0x1b3037(%rip), %rdi    # 0x22841f
leaq 0x1b0254(%rip), %rsi    # 0x225643
leaq 0x1b2fe3(%rip), %rcx    # 0x2283d9
movl $0x507d, %edx           # imm = 0x507D
callq 0x2110
leaq 0x1b2fba(%rip), %rdi    # 0x2283c1
leaq 0x1b0235(%rip), %rsi    # 0x225643
leaq 0x1b2fc4(%rip), %rcx    # 0x2283d9
movl $0x507e, %edx           # imm = 0x507E
callq 0x2110
leaq 0x1b2f9b(%rip), %rdi    # 0x2283c1
leaq 0x1b0216(%rip), %rsi    # 0x225643
leaq 0x1b2fa5(%rip), %rcx    # 0x2283d9
movl $0x506f, %edx           # imm = 0x506F
callq 0x2110