// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/Purge_Dups.cpp
// Function: get_xy_pos(asg_t*, asg_arc_t*, unsigned int, unsigned int, unsigned int, unsigned int, unsigned long*, unsigned char*)
inline uint64_t get_xy_pos(asg_t *read_g, asg_arc_t* t, uint32_t v_in_unitig, uint32_t w_in_unitig, 
uint32_t xUnitigLen, uint32_t yUnitigLen, uint64_t* position_index, uint8_t* rev)
{
    uint32_t x_pos, y_pos, x_dir = 0, y_dir = 0;
    uint64_t tmp;
    x_pos = y_pos = (uint32_t)-1;
    if((t->ul>>32)==v_in_unitig)///end pos
    {
        x_pos = (position_index[v_in_unitig>>1]>>32) + read_g->seq[v_in_unitig>>1].len - 1;
        x_dir = 0;
    }
    else if((t->ul>>32)==(v_in_unitig^1))///start pos
    {
        x_pos = (position_index[v_in_unitig>>1]>>32);
        x_dir = 1;
    }
    else
    {
        fprintf(stderr, "ERROR\n");
    }
    
    if(t->v == w_in_unitig)
    {
        y_pos = (position_index[w_in_unitig>>1]>>32) + t->ol - 1;
        y_dir = 0;
    }
    else if(t->v == (w_in_unitig^1))
    {
        y_pos = (position_index[w_in_unitig>>1]>>32) + read_g->seq[w_in_unitig>>1].len - t->ol;
        y_dir = 1;
    }
    else
    {
        fprintf(stderr, "ERROR\n");
    }

    (*rev) = x_dir^y_dir;
    if((*rev))
    {
        if(yUnitigLen <= y_pos)
        {
            y_pos = (uint32_t)-1;
        }
        else
        {
            y_pos = yUnitigLen - y_pos - 1;
        }
    } 

    if(x_pos>=xUnitigLen) x_pos = (uint32_t)-1;
    if(y_pos>=yUnitigLen) y_pos = (uint32_t)-1;
    
    tmp = x_pos; tmp = tmp << 32; tmp = tmp | y_pos;
    return tmp;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %r9d, %ebx
movl %ecx, %r14d
movq %rsi, %r15
movq %rdi, %r12
movq 0x40(%rsp), %rdi
movq (%rsi), %rax
shrq $0x20, %rax
movl %edx, %ecx
cmpq %rcx, %rax
jne 0xd3da1
shrl %edx
movl 0x4(%rdi,%rdx,8), %eax
movq 0x20(%r12), %rcx
movl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
andl (%rcx,%rdx,8), %esi
leal (%rax,%rsi), %r13d
decl %r13d
xorl %ebp, %ebp
jmp 0xd3db8
movl %edx, %ecx
xorl $0x1, %ecx
cmpl %ecx, %eax
jne 0xd3e49
shrl %edx
movl 0x4(%rdi,%rdx,8), %r13d
movb $0x1, %bpl
movq 0x48(%rsp), %rsi
movl 0x8(%r15), %eax
cmpl %r14d, %eax
jne 0xd3ddf
shrl %r14d
movl 0x4(%rdi,%r14,8), %eax
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andl 0xc(%r15), %ecx
addl %eax, %ecx
decl %ecx
xorl %eax, %eax
jmp 0xd3e0b
xorl %r14d, %eax
cmpl $0x1, %eax
jne 0xd3e79
shrl %r14d
movq 0x20(%r12), %rax
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movl (%rax,%r14,8), %ecx
andl %edx, %ecx
andl 0xc(%r15), %edx
addl 0x4(%rdi,%r14,8), %ecx
subl %edx, %ecx
movb $0x1, %al
movl %eax, %edx
xorb %bpl, %dl
movb %dl, (%rsi)
cmpb %al, %bpl
je 0xd3e24
cmpl %ebx, %ecx
jae 0xd3e21
notl %ecx
addl %ebx, %ecx
jmp 0xd3e24
pushq $-0x1
popq %rcx
cmpl %r8d, %r13d
pushq $-0x1
popq %rax
cmovael %eax, %r13d
cmpl %ebx, %ecx
cmovbl %ecx, %eax
shlq $0x20, %r13
orq %r13, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $-0x1
popq %r13
movq 0x17f18c(%rip), %rax    # 0x252fe0
movq (%rax), %rcx
leaq 0x116f26(%rip), %rdi    # 0x1ead84
pushq $0x6
popq %rsi
pushq $0x1
popq %rdx
movl %r8d, %ebp
callq 0x2410
movq 0x40(%rsp), %rdi
movl %ebp, %r8d
jmp 0xd3d9d
movq 0x17f160(%rip), %rax    # 0x252fe0
movq (%rax), %rcx
leaq 0x116efa(%rip), %rdi    # 0x1ead84
movq %rsi, %r15
pushq $0x6
popq %rsi
pushq $0x1
popq %rdx
movl %r8d, %r14d
callq 0x2410
movq %r15, %rsi
movl %r14d, %r8d
pushq $-0x1
popq %rcx
jmp 0xd3ddb