// File: /workspace/github_cpp_makefile_star2_O2/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 0x42aee
addq %rcx, %r9
subq %rcx, %r8
addq %rcx, %r10
subq %rcx, %r11
jmp 0x42c06
movq (%rdx), %rdx
movl (%rdi), %ecx
movl 0xc(%rdi), %r14d
imulq $0x18, %rcx, %r15
cmpq %rbx, 0x8(%rdx,%r15)
jbe 0x42b76
addq %rdx, %r15
movq (%r15), %r15
movq %rbx, %r12
shlq $0x5, %r12
cmpl (%r15,%r12), %r14d
jne 0x42b76
addq %r12, %r15
movl %eax, %r12d
shrl $0x1f, %r12d
movzbl 0x1c(%r15), %ebp
movl %ebp, %r13d
shrl $0x7, %r13d
cmpl %r13d, %r12d
jne 0x42b76
cmpl 0xc(%r15), %r9d
jne 0x42b76
cmpl 0x10(%r15), %r8d
jne 0x42b76
cmpl 0x14(%r15), %r10d
jne 0x42b76
cmpl 0x18(%r15), %r11d
jne 0x42b76
movl 0x8(%r15), %ecx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
cmpq %rdx, %rcx
je 0x42c90
shrl %ecx
testb $0x1f, %bpl
je 0x42c42
addq %rcx, %r9
testl %eax, %eax
jns 0x42c4d
jmp 0x42ae6
imulq $0x18, %r14, %r14
cmpq %rbx, 0x8(%rdx,%r14)
jbe 0x42c52
addq %r14, %rdx
movq (%rdx), %rdx
shlq $0x5, %rbx
cmpl (%rdx,%rbx), %ecx
jne 0x42c52
addq %rbx, %rdx
movl %eax, %ebx
shrl $0x1f, %ebx
movzbl 0x1c(%rdx), %ecx
movl %ecx, %ebp
shrl $0x7, %ebp
cmpl %ebp, %ebx
jne 0x42c52
cmpl 0x14(%rdx), %r9d
jne 0x42c52
cmpl 0x18(%rdx), %r8d
jne 0x42c52
cmpl 0xc(%rdx), %r10d
jne 0x42c52
cmpl 0x10(%rdx), %r11d
jne 0x42c52
movl 0x8(%rdx), %edx
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpq %rbx, %rdx
je 0x42c71
andb $0x1f, %cl
shrl %edx
cmpb $0x1, %cl
jne 0x42bfc
subq %rdx, %r8
testl %eax, %eax
js 0x42c03
subq %rdx, %r11
jmp 0x42c06
addq %rdx, %r9
testl %eax, %eax
js 0x42bf7
addq %rdx, %r10
xorl %eax, %eax
cmpq %r9, %r8
jle 0x42c33
cmpq %r10, %r11
jle 0x42c33
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)
pushq $0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
subq %rcx, %r8
testl %eax, %eax
jns 0x42ae6
addq %rcx, %r10
jmp 0x42c06
leaq 0x1a3826(%rip), %rdi    # 0x1e647f
leaq 0x1a0a43(%rip), %rsi    # 0x1e36a3
leaq 0x1a37d2(%rip), %rcx    # 0x1e6439
movl $0x507d, %edx           # imm = 0x507D
callq 0x2110
leaq 0x1a37a9(%rip), %rdi    # 0x1e6421
leaq 0x1a0a24(%rip), %rsi    # 0x1e36a3
leaq 0x1a37b3(%rip), %rcx    # 0x1e6439
movl $0x507e, %edx           # imm = 0x507E
callq 0x2110
leaq 0x1a378a(%rip), %rdi    # 0x1e6421
leaq 0x1a0a05(%rip), %rsi    # 0x1e36a3
leaq 0x1a3794(%rip), %rcx    # 0x1e6439
movl $0x506f, %edx           # imm = 0x506F
callq 0x2110