// File: chhylp123[P]hifiasm/inter.cpp
// Function: transfor_icoord(long, long, long, long, unsigned char, long, long, int*, int*, int*, int*)
void transfor_icoord(const int64_t iqs, const int64_t iqe, const int64_t irs, const int64_t ire, const uint8_t rev, 
const int64_t qlen, const int64_t rlen, int32_t *r_qs, int32_t *r_qe, int32_t *r_rs, int32_t *r_re)
{
    int64_t qs, qe, rs, re, qtail, rtail;
    qs = iqs; qe = iqe - 1; rs = irs; re = ire - 1;
    if(rev) {
        rs = rlen - ire; re = rlen - irs - 1;
    }
    
    if(qs <= rs) {
        rs -= qs; qs = 0;
    } else {
        qs -= rs; rs = 0;
    }

    qtail = qlen - qe - 1; rtail = rlen - re - 1;
    if(qtail <= rtail) {
        qe = qlen - 1; re += qtail;
    }
    else
    {
        re = rlen - 1; qe += rtail; 
    }

	if(r_qs) (*r_qs) = qs; if(r_qe) (*r_qe) = qe + 1;
	if(r_rs) (*r_rs) = rs; if(r_re) (*r_re) = re + 1;
    if(rev) {
        if(r_rs) (*r_rs) = rlen - re - 1; 
		if(r_re) (*r_re) = rlen - rs;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movb %r8b, %al
movq 0x30(%rbp), %r8
movq 0x28(%rbp), %r8
movq 0x20(%rbp), %r8
movq 0x18(%rbp), %r8
movq 0x10(%rbp), %r8
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movb %al, -0x21(%rbp)
movq %r9, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x20(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x50(%rbp)
cmpb $0x0, -0x21(%rbp)
je 0x28752c
movq 0x10(%rbp), %rax
subq -0x20(%rbp), %rax
movq %rax, -0x48(%rbp)
movq 0x10(%rbp), %rax
subq -0x18(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x50(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x48(%rbp), %rax
jg 0x28754f
movq -0x38(%rbp), %rcx
movq -0x48(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x48(%rbp)
movq $0x0, -0x38(%rbp)
jmp 0x287566
movq -0x48(%rbp), %rcx
movq -0x38(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x38(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x30(%rbp), %rax
subq -0x40(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x58(%rbp)
movq 0x10(%rbp), %rax
subq -0x50(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x60(%rbp)
movq -0x58(%rbp), %rax
cmpq -0x60(%rbp), %rax
jg 0x2875aa
movq -0x30(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x40(%rbp)
movq -0x58(%rbp), %rax
addq -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
jmp 0x2875c2
movq 0x10(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x50(%rbp)
movq -0x60(%rbp), %rax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, 0x18(%rbp)
je 0x2875d5
movq -0x38(%rbp), %rax
movl %eax, %ecx
movq 0x18(%rbp), %rax
movl %ecx, (%rax)
cmpq $0x0, 0x20(%rbp)
je 0x2875ec
movq -0x40(%rbp), %rax
addq $0x1, %rax
movl %eax, %ecx
movq 0x20(%rbp), %rax
movl %ecx, (%rax)
cmpq $0x0, 0x28(%rbp)
je 0x2875ff
movq -0x48(%rbp), %rax
movl %eax, %ecx
movq 0x28(%rbp), %rax
movl %ecx, (%rax)
cmpq $0x0, 0x30(%rbp)
je 0x287616
movq -0x50(%rbp), %rax
addq $0x1, %rax
movl %eax, %ecx
movq 0x30(%rbp), %rax
movl %ecx, (%rax)
cmpb $0x0, -0x21(%rbp)
je 0x287650
cmpq $0x0, 0x28(%rbp)
je 0x287637
movq 0x10(%rbp), %rax
subq -0x50(%rbp), %rax
subq $0x1, %rax
movl %eax, %ecx
movq 0x28(%rbp), %rax
movl %ecx, (%rax)
cmpq $0x0, 0x30(%rbp)
je 0x28764e
movq 0x10(%rbp), %rax
subq -0x48(%rbp), %rax
movl %eax, %ecx
movq 0x30(%rbp), %rax
movl %ecx, (%rax)
jmp 0x287650
popq %rbp
retq
nopw %cs:(%rax,%rax)