// File: 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
movq %rsp, %rbp
subq $0x30, %rsp
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movl %r9d, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
subq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
subq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x48(%rbp), %rax
jg 0x1cf06c
movq -0x38(%rbp), %rax
movq %rax, -0x68(%rbp)
jmp 0x1cf074
movq -0x48(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x40(%rbp), %rax
jl 0x1cf090
movq -0x30(%rbp), %rax
movq %rax, -0x78(%rbp)
jmp 0x1cf098
movq -0x40(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x70(%rbp), %rax
movq -0x78(%rbp), %rcx
cmpq %rcx, %rax
jl 0x1cf10c
movq -0x38(%rbp), %rax
cmpq -0x48(%rbp), %rax
jg 0x1cf0b9
movq -0x38(%rbp), %rax
movq %rax, -0x80(%rbp)
jmp 0x1cf0c1
movq -0x48(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x40(%rbp), %rax
jl 0x1cf0e3
movq -0x30(%rbp), %rax
movq %rax, -0x90(%rbp)
jmp 0x1cf0ee
movq -0x40(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x88(%rbp), %rax
movq -0x90(%rbp), %rcx
subq %rcx, %rax
addq $0x1, %rax
movq %rax, -0x98(%rbp)
jmp 0x1cf117
xorl %eax, %eax
movq %rax, -0x98(%rbp)
jmp 0x1cf117
movq -0x98(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
cmpq -0x18(%rbp), %rax
je 0x1cf2b6
movq -0x60(%rbp), %rax
cmpq -0x20(%rbp), %rax
je 0x1cf2b6
movq -0x38(%rbp), %rax
cmpq -0x48(%rbp), %rax
jl 0x1cf155
movq -0x38(%rbp), %rax
movq %rax, -0xa0(%rbp)
jmp 0x1cf160
movq -0x48(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x40(%rbp), %rax
jg 0x1cf185
movq -0x30(%rbp), %rax
movq %rax, -0xb0(%rbp)
jmp 0x1cf190
movq -0x40(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0xa8(%rbp), %rax
movq -0xb0(%rbp), %rcx
subq %rcx, %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x48(%rbp), %rax
jl 0x1cf1bd
movq $0x1, -0x58(%rbp)
jmp 0x1cf1c5
movq $0x0, -0x58(%rbp)
movq -0x50(%rbp), %rcx
movq 0x10(%rbp), %rax
movq %rcx, (%rax)
movq 0x10(%rbp), %rax
movq (%rax), %rcx
shlq %rcx
movq %rcx, (%rax)
movq 0x10(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movq 0x10(%rbp), %rax
movq (%rax), %rcx
shlq %rcx
movq %rcx, (%rax)
movl -0x24(%rbp), %eax
andl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
xorq -0x58(%rbp), %rcx
movq 0x10(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq 0x10(%rbp), %rax
movq (%rax), %rcx
shlq %rcx
movq %rcx, (%rax)
movl -0x28(%rbp), %eax
andl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
xorq -0x58(%rbp), %rcx
movq 0x10(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq -0x58(%rbp), %rax
xorq $0x1, %rax
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rcx
movq 0x18(%rbp), %rax
movq %rcx, (%rax)
movq 0x18(%rbp), %rax
movq (%rax), %rcx
shlq %rcx
movq %rcx, (%rax)
movq 0x18(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movq 0x18(%rbp), %rax
movq (%rax), %rcx
shlq %rcx
movq %rcx, (%rax)
movl -0x28(%rbp), %eax
andl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
xorq -0x58(%rbp), %rcx
movq 0x18(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq 0x18(%rbp), %rax
movq (%rax), %rcx
shlq %rcx
movq %rcx, (%rax)
movl -0x24(%rbp), %eax
andl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
xorq -0x58(%rbp), %rcx
movq 0x18(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
jmp 0x1cf412
movq -0x18(%rbp), %rax
cmpq -0x20(%rbp), %rax
jl 0x1cf2dd
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq -0x48(%rbp), %rcx
subq -0x40(%rbp), %rcx
addq $0x1, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
jmp 0x1cf2fc
movq -0x38(%rbp), %rax
subq -0x30(%rbp), %rax
addq $0x1, %rax
movq -0x20(%rbp), %rcx
subq -0x48(%rbp), %rcx
subq $0x1, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rcx
movq 0x10(%rbp), %rax
movq %rcx, (%rax)
movq 0x10(%rbp), %rax
movq (%rax), %rcx
shlq %rcx
movq %rcx, (%rax)
movq 0x10(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movq 0x10(%rbp), %rax
movq (%rax), %rcx
shlq %rcx
movq %rcx, (%rax)
movl -0x24(%rbp), %eax
andl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
movq 0x10(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq 0x10(%rbp), %rax
movq (%rax), %rcx
shlq %rcx
movq %rcx, (%rax)
movl -0x28(%rbp), %eax
andl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
movq 0x10(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
cmpq -0x20(%rbp), %rax
jl 0x1cf38f
movq -0x48(%rbp), %rax
subq -0x40(%rbp), %rax
addq $0x1, %rax
movq -0x18(%rbp), %rcx
subq -0x38(%rbp), %rcx
subq $0x1, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
jmp 0x1cf3aa
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq -0x38(%rbp), %rcx
subq -0x30(%rbp), %rcx
addq $0x1, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rcx
movq 0x18(%rbp), %rax
movq %rcx, (%rax)
movq 0x18(%rbp), %rax
movq (%rax), %rcx
shlq %rcx
movq %rcx, (%rax)
movq 0x18(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movq 0x18(%rbp), %rax
movq (%rax), %rcx
shlq %rcx
movq %rcx, (%rax)
movl -0x28(%rbp), %eax
andl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
movq 0x18(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq 0x18(%rbp), %rax
movq (%rax), %rcx
shlq %rcx
movq %rcx, (%rax)
movl -0x24(%rbp), %eax
andl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
movq 0x18(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)