// File: /workspace/github_c_makefile_star2_O2/icebert[P]pblat/lib/maf.c
// Function: mafSubsetE
struct mafAli *mafSubsetE(struct mafAli *maf, char *componentSource,
	int newStart, int newEnd, bool getInitialDashes)
/* Extract subset of maf that intersects a given range
 * in a component sequence.  The newStart and newEnd
 * are given in the forward strand coordinates of the
 * component sequence.  The componentSource is typically
 * something like 'mm3.chr1'.  This will return NULL
 * if maf does not intersect range.  The score field
 * in the returned maf will not be filled in (since
 * we don't know which scoring scheme to use). */
{
struct mafComp *mcMaster = mafFindComponent(maf, componentSource);
struct mafAli *subset;
struct mafComp *mc, *subMc;
char *s, *e;
int textStart, textSize;

/* Reverse complement input range if necessary. */
if (mcMaster->strand == '-')
    reverseIntRange(&newStart, &newEnd, mcMaster->srcSize);

/* Check if any real intersection and return NULL if not. */
if (newStart >= newEnd)
    return NULL;
if (newStart >= mcMaster->start + mcMaster->size)
    return NULL;
if (newEnd <= mcMaster->start)
    return NULL;

/* Clip to bounds of actual data. */
if (newStart < mcMaster->start)
    newStart = mcMaster->start;
if (newEnd > mcMaster->start + mcMaster->size)
    newEnd = mcMaster->start + mcMaster->size;

/* Translate position in master sequence to position in
 * multiple alignment. */
s = skipIgnoringDash(mcMaster->text, newStart - mcMaster->start, TRUE);
e = skipIgnoringDash(s, newEnd - newStart, TRUE);
textStart = s - mcMaster->text;
textSize = e - s;

if (getInitialDashes && (newStart == mcMaster->start))
    {
    textStart = 0;
    textSize += s - mcMaster->text;
    }

/* Allocate subset structure and fill it in */
AllocVar(subset);
subset->textSize = textSize;
for (mc = maf->components; mc != NULL; mc = mc->next)
    {
    AllocVar(subMc);
    subMc->src = cloneString(mc->src);
    subMc->srcSize = mc->srcSize;
    subMc->strand = mc->strand;
    if (mc->size != 0)
        {
        subMc->start = mc->start + countNonDash(mc->text, textStart);
        subMc->size = countNonDash(mc->text+textStart, textSize);
        subMc->text = cloneStringZ(mc->text + textStart, textSize);
        if (mc->quality != NULL)
            subMc->quality = cloneStringZ(mc->quality + textStart, textSize);
        }
    else
	{
        /* empty row annotation */
        subMc->size = 0;
        subMc->start = mc->start;
	}

    subMc->leftStatus = mc->leftStatus;
    subMc->leftLen = mc->leftLen;
    subMc->rightStatus = mc->rightStatus;
    subMc->rightLen = mc->rightLen;

    slAddHead(&subset->components, subMc);
    }
slReverse(&subset->components);
return subset;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r8d, %ebp
movl %ecx, %r12d
movl %edx, %r14d
movq %rdi, %rbx
movl %edx, 0x8(%rsp)
movl %ecx, 0xc(%rsp)
callq 0x27f19
movq %rax, %r15
cmpb $0x2d, 0x14(%rax)
jne 0x281a0
movl 0x10(%r15), %edx
leaq 0x8(%rsp), %r14
leaq 0xc(%rsp), %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x20d61
movl (%r14), %r14d
movl (%r12), %r12d
cmpl %r12d, %r14d
jge 0x28317
movl 0x18(%r15), %eax
movl 0x1c(%r15), %ecx
addl %eax, %ecx
cmpl %ecx, %r14d
setge %dl
cmpl %eax, %r12d
setle %sil
orb %dl, %sil
jne 0x28317
cmpl %eax, %r14d
jge 0x281d5
movl %eax, 0x8(%rsp)
movl %eax, %r14d
cmpl %ecx, %r12d
jle 0x281de
movl %ecx, 0xc(%rsp)
movq 0x20(%r15), %rdi
subl %eax, %r14d
pushq $0x1
popq %r13
movl %r14d, %esi
movl %r13d, %edx
callq 0x20f29
movq %rax, %r12
movl 0xc(%rsp), %esi
subl 0x8(%rsp), %esi
movq %rax, %rdi
movl %r13d, %edx
callq 0x20f29
movq %rax, %r14
subq %r12, %r14
subq 0x20(%r15), %r12
testb %bpl, %bpl
je 0x28233
movl 0x8(%rsp), %eax
xorl %ecx, %ecx
cmpl 0x18(%r15), %eax
movl %r12d, %eax
cmovel %ecx, %eax
cmoveq %r12, %rcx
addq %rcx, %r14
movl %eax, %r12d
pushq $0x28
popq %rdi
callq 0x28bb0
movl %r14d, 0x18(%rax)
addq $0x10, %rbx
movslq %r12d, %r13
movq %rax, 0x10(%rsp)
movq %rax, %r12
addq $0x10, %r12
movq (%rbx), %rbx
testq %rbx, %rbx
je 0x2831b
pushq $0x40
popq %rdi
callq 0x28bb0
movq %rax, %r15
movq 0x8(%rbx), %rdi
callq 0x1c306
movq %rax, 0x8(%r15)
movl 0x10(%rbx), %eax
movl %eax, 0x10(%r15)
movb 0x14(%rbx), %al
movb %al, 0x14(%r15)
cmpl $0x0, 0x1c(%rbx)
je 0x282df
movl 0x18(%rbx), %ebp
movq 0x20(%rbx), %rdi
movl %r13d, %esi
callq 0x20f58
addl %ebp, %eax
movl %eax, 0x18(%r15)
movq 0x20(%rbx), %rdi
addq %r13, %rdi
movl %r14d, %esi
callq 0x20f58
movl %eax, 0x1c(%r15)
movq 0x20(%rbx), %rdi
addq %r13, %rdi
movl %r14d, %esi
callq 0x1c2a3
movq %rax, 0x20(%r15)
movq 0x28(%rbx), %rdi
testq %rdi, %rdi
je 0x282eb
addq %r13, %rdi
movl %r14d, %esi
callq 0x1c2a3
movq %rax, 0x28(%r15)
jmp 0x282eb
andl $0x0, 0x1c(%r15)
movl 0x18(%rbx), %eax
movl %eax, 0x18(%r15)
movb 0x30(%rbx), %al
movb %al, 0x30(%r15)
movl 0x34(%rbx), %eax
movl %eax, 0x34(%r15)
movb 0x38(%rbx), %al
movb %al, 0x38(%r15)
movl 0x3c(%rbx), %eax
movl %eax, 0x3c(%r15)
movq (%r12), %rax
movq %rax, (%r15)
movq %r15, (%r12)
jmp 0x28252
xorl %eax, %eax
jmp 0x28328
movq %r12, %rdi
callq 0x1c567
movq 0x10(%rsp), %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq