// File: chhylp123[P]hifiasm/hic.cpp
// Function: push_LCA_edges_rev(hc_edge*, hc_edge*, long long, long long, long long, unsigned int, unsigned int, unsigned long*, unsigned long*)
void push_LCA_edges_rev(hc_edge *hx, hc_edge *hy, 
long long xLen, long long yLen, long long rLen, 
uint32_t v, uint32_t w, uint64_t *e0, uint64_t *e1)
{
    long long x_beg, x_end, y_beg, y_end, dx, dy;
    uint64_t d, rev;
    dx = (hx->dis>>3); 
    if((hx->dis&(uint64_t)2))
    {
        x_beg = rLen - dx - 1; x_end = x_beg + xLen - 1;
    }
    else
    {
        x_end = dx; x_beg = x_end - xLen + 1;
    } 
    
    dy = (hy->dis>>3);
    if((hy->dis&(uint64_t)2))
    {
        y_beg = rLen - dy - 1; y_end = y_beg + yLen - 1;
    } 
    else
    {
        y_end = dy; 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 $0x48, %rsp
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
shrq $0x3, %rax
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
andq $0x2, %rax
cmpq $0x0, %rax
je 0x1cf48f
movq -0x28(%rbp), %rax
subq -0x58(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
addq -0x18(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x1cf4a7
movq -0x58(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
subq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
shrq $0x3, %rax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
andq $0x2, %rax
cmpq $0x0, %rax
je 0x1cf4eb
movq -0x28(%rbp), %rax
subq -0x60(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
addq -0x20(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x1cf503
movq -0x60(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
subq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x50(%rbp), %rax
jg 0x1cf517
movq -0x40(%rbp), %rax
movq %rax, -0x80(%rbp)
jmp 0x1cf51f
movq -0x50(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x48(%rbp), %rax
jl 0x1cf541
movq -0x38(%rbp), %rax
movq %rax, -0x90(%rbp)
jmp 0x1cf54c
movq -0x48(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x88(%rbp), %rax
movq -0x90(%rbp), %rcx
cmpq %rcx, %rax
jl 0x1cf5cf
movq -0x40(%rbp), %rax
cmpq -0x50(%rbp), %rax
jg 0x1cf576
movq -0x40(%rbp), %rax
movq %rax, -0x98(%rbp)
jmp 0x1cf581
movq -0x50(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x48(%rbp), %rax
jl 0x1cf5a6
movq -0x38(%rbp), %rax
movq %rax, -0xa8(%rbp)
jmp 0x1cf5b1
movq -0x48(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0xa0(%rbp), %rax
movq -0xa8(%rbp), %rcx
subq %rcx, %rax
addq $0x1, %rax
movq %rax, -0xb0(%rbp)
jmp 0x1cf5da
xorl %eax, %eax
movq %rax, -0xb0(%rbp)
jmp 0x1cf5da
movq -0xb0(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
cmpq -0x18(%rbp), %rax
je 0x1cf779
movq -0x78(%rbp), %rax
cmpq -0x20(%rbp), %rax
je 0x1cf779
movq -0x40(%rbp), %rax
cmpq -0x50(%rbp), %rax
jl 0x1cf618
movq -0x40(%rbp), %rax
movq %rax, -0xb8(%rbp)
jmp 0x1cf623
movq -0x50(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x48(%rbp), %rax
jg 0x1cf648
movq -0x38(%rbp), %rax
movq %rax, -0xc8(%rbp)
jmp 0x1cf653
movq -0x48(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0xc0(%rbp), %rax
movq -0xc8(%rbp), %rcx
subq %rcx, %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x50(%rbp), %rax
jl 0x1cf680
movq $0x1, -0x70(%rbp)
jmp 0x1cf688
movq $0x0, -0x70(%rbp)
movq -0x68(%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 -0x2c(%rbp), %eax
andl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
xorq -0x70(%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 0x10(%rbp), %eax
andl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
xorq -0x70(%rbp), %rcx
movq 0x18(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq -0x70(%rbp), %rax
xorq $0x1, %rax
movq %rax, -0x70(%rbp)
movq -0x68(%rbp), %rcx
movq 0x20(%rbp), %rax
movq %rcx, (%rax)
movq 0x20(%rbp), %rax
movq (%rax), %rcx
shlq %rcx
movq %rcx, (%rax)
movq 0x20(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movq 0x20(%rbp), %rax
movq (%rax), %rcx
shlq %rcx
movq %rcx, (%rax)
movl 0x10(%rbp), %eax
andl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
xorq -0x70(%rbp), %rcx
movq 0x20(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq 0x20(%rbp), %rax
movq (%rax), %rcx
shlq %rcx
movq %rcx, (%rax)
movl -0x2c(%rbp), %eax
andl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
xorq -0x70(%rbp), %rcx
movq 0x20(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
jmp 0x1cf8d5
movq -0x18(%rbp), %rax
cmpq -0x20(%rbp), %rax
jl 0x1cf7a0
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq -0x50(%rbp), %rcx
subq -0x48(%rbp), %rcx
addq $0x1, %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
jmp 0x1cf7bf
movq -0x40(%rbp), %rax
subq -0x38(%rbp), %rax
addq $0x1, %rax
movq -0x20(%rbp), %rcx
subq -0x50(%rbp), %rcx
subq $0x1, %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x68(%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 -0x2c(%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 0x10(%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
cmpq -0x20(%rbp), %rax
jl 0x1cf852
movq -0x50(%rbp), %rax
subq -0x48(%rbp), %rax
addq $0x1, %rax
movq -0x18(%rbp), %rcx
subq -0x40(%rbp), %rcx
subq $0x1, %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
jmp 0x1cf86d
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq -0x40(%rbp), %rcx
subq -0x38(%rbp), %rcx
addq $0x1, %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rcx
movq 0x20(%rbp), %rax
movq %rcx, (%rax)
movq 0x20(%rbp), %rax
movq (%rax), %rcx
shlq %rcx
movq %rcx, (%rax)
movq 0x20(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movq 0x20(%rbp), %rax
movq (%rax), %rcx
shlq %rcx
movq %rcx, (%rax)
movl 0x10(%rbp), %eax
andl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
movq 0x20(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq 0x20(%rbp), %rax
movq (%rax), %rcx
shlq %rcx
movq %rcx, (%rax)
movl -0x2c(%rbp), %eax
andl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
movq 0x20(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
addq $0x48, %rsp
popq %rbp
retq
nopl (%rax,%rax)