// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/hic.cpp
// Function: push_LCA_edges(long long, long long, long long, long long, unsigned int, unsigned int, unsigned long*, unsigned long*)
void push_LCA_edges(long long d_x, long long d_y, long long xLen, long long yLen, 
uint32_t v, uint32_t w, uint64_t *e0, uint64_t *e1)
{
    long long x_beg, x_end, y_beg, y_end;
    uint64_t d, rev;
    x_end = d_x; x_beg = x_end - xLen + 1;
    y_end = d_y; y_beg = y_end - yLen + 1;

    long long ovlp = ((MIN(x_end, y_end) >= MAX(x_beg, y_beg))? 
                                    MIN(x_end, y_end) - MAX(x_beg, y_beg) + 1 : 0);
    if(ovlp != xLen && ovlp != yLen)
    {
        d = MAX(x_end, y_end) - MIN(x_beg, y_beg) + 1;
        if(x_end >= y_end) rev = 1;
        else rev = 0;

        (*e0) = d;
        (*e0) <<= 1;
        (*e0) += 1;
        (*e0) <<= 1;
        (*e0) += ((v&1)^rev);//s-direction
        (*e0) <<= 1;
        (*e0) += ((w&1)^rev);//e-direction

        rev ^= 1;
        (*e1) = d;
        (*e1) <<= 1;
        (*e1) += 1;
        (*e1) <<= 1;
        (*e1) += ((w&1)^rev);//s-direction
        (*e1) <<= 1;
        (*e1) += ((v&1)^rev);//e-direction
    }
    else
    {
        if(xLen >= yLen) d = (x_beg + 1) + (y_end - y_beg + 1);
        else d = (x_end - x_beg + 1) + (yLen - y_end - 1);

        (*e0) = d;
        (*e0) <<= 1;
        (*e0) += 1;
        (*e0) <<= 1;
        (*e0) += (v&1);//s-direction
        (*e0) <<= 1;
        (*e0) += (w&1);//e-direction

        if(xLen >= yLen) d = (y_end - y_beg + 1) + (xLen - x_end - 1);
        else d = (y_beg + 1) + (x_end - x_beg + 1);
        (*e1) = d;
        (*e1) <<= 1;
        (*e1) += 1;
        (*e1) <<= 1;
        (*e1) += (w&1);//s-direction
        (*e1) <<= 1;
        (*e1) += (v&1);//e-direction
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %r14
subq %rdx, %r14
leaq 0x1(%r14), %r15
movq %rsi, %r10
subq %rcx, %r10
leaq 0x1(%r10), %r12
movq %rdi, %rbx
subq %rsi, %rbx
movq %rsi, %rax
cmovlq %rdi, %rax
cmpq %r12, %r15
movq %r12, %r11
cmovgq %r15, %r11
xorl %r13d, %r13d
subq %r11, %rax
leaq 0x1(%rax), %rax
cmovgeq %rax, %r13
cmpq %rdx, %r13
sete %r11b
cmpq %rcx, %r13
movq 0x40(%rsp), %rax
sete %bpl
orb %r11b, %bpl
movq 0x38(%rsp), %r11
je 0x13d8a0
movq %r14, %r12
notq %r12
movq %r10, %r15
notq %r15
cmpq %rcx, %rdx
jge 0x13d8f1
addq %rcx, %rbx
addq %r12, %rbx
jmp 0x13d8fc
xorl %ecx, %ecx
cmpq %rsi, %rdi
cmovgq %rdi, %rsi
setge %cl
cmpq %r12, %r15
cmovlq %r15, %r12
subq %r12, %rsi
andl $0x1, %r8d
movq %r8, %rdx
xorq %rcx, %rdx
leaq (%rdx,%rsi,4), %rdx
addq $0x6, %rdx
andl $0x1, %r9d
movq %r9, %rdi
xorq %rcx, %rdi
leaq (%rdi,%rdx,2), %rdx
movq %rdx, (%r11)
xorq $0x1, %rcx
xorq %rcx, %r9
leaq (%r9,%rsi,4), %rdx
addq $0x6, %rdx
xorq %r8, %rcx
leaq (%rcx,%rdx,2), %rcx
jmp 0x13d93f
addq %rsi, %r14
leaq (%r15,%r14), %rbx
addq $0x3, %rbx
andl $0x1, %r8d
leaq (%r8,%r8), %r14
andl $0x1, %r9d
leaq (%r14,%rbx,8), %rbx
addq %r9, %rbx
addq $0x4, %rbx
movq %rbx, (%r11)
cmpq %rcx, %rdx
jge 0x13d928
addq %r12, %rdi
leaq (%r10,%rdi), %rsi
addq $0x3, %rsi
jmp 0x13d931
subq %rdi, %rsi
addq %rdx, %rsi
addq %r15, %rsi
addq %r9, %r9
leaq (%r9,%rsi,8), %rcx
addq %r8, %rcx
addq $0x4, %rcx
movq %rcx, (%rax)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq