// File: /workspace/github_c_makefile_star2_O3/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
pushq %rax
movl %r8d, %ebp
movl %ecx, %r12d
movl %edx, %ebx
movq %rdi, %r15
movl %edx, (%rsp)
movl %ecx, 0x4(%rsp)
callq 0x2d2d0
movq %rax, %r14
cmpb $0x2d, 0x14(%rax)
jne 0x2d5a8
movl 0x10(%r14), %edx
movq %rsp, %rbx
leaq 0x4(%rsp), %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x25472
movl (%rbx), %ebx
movl (%r12), %r12d
cmpl %r12d, %ebx
jge 0x2d73b
movl 0x18(%r14), %eax
movl 0x1c(%r14), %ecx
addl %eax, %ecx
cmpl %ecx, %ebx
setge %dl
cmpl %eax, %r12d
setle %sil
orb %dl, %sil
jne 0x2d73b
cmpl %eax, %ebx
jge 0x2d5d9
movl %eax, (%rsp)
movl %eax, %ebx
cmpl %ecx, %r12d
jle 0x2d5e2
movl %ecx, 0x4(%rsp)
movq 0x20(%r14), %rdi
subl %eax, %ebx
movl %ebx, %esi
movl $0x1, %edx
callq 0x25672
movq %rax, %r12
movl 0x4(%rsp), %esi
subl (%rsp), %esi
movq %rax, %rdi
movl $0x1, %edx
callq 0x25672
movq %rax, %rbx
subq %r12, %rbx
subq 0x20(%r14), %r12
testb %bpl, %bpl
je 0x2d633
movl (%rsp), %eax
xorl %ecx, %ecx
cmpl 0x18(%r14), %eax
movl %r12d, %eax
cmovel %ecx, %eax
cmoveq %r12, %rcx
addq %rcx, %rbx
movl %eax, %r12d
movl $0x28, %edi
callq 0x2dff4
movq %rax, %r14
movl %ebx, 0x18(%rax)
movq 0x10(%r15), %r13
testq %r13, %r13
je 0x2d72d
movslq %r12d, %r15
movl $0x40, %edi
callq 0x2dff4
movq %rax, %r12
movq 0x8(%r13), %rdi
callq 0x1feba
movq %rax, 0x8(%r12)
movl 0x10(%r13), %eax
movl %eax, 0x10(%r12)
movb 0x14(%r13), %al
movb %al, 0x14(%r12)
cmpl $0x0, 0x1c(%r13)
je 0x2d6de
movl 0x18(%r13), %ebp
movq 0x20(%r13), %rdi
movl %r15d, %esi
callq 0x256a6
addl %ebp, %eax
movl %eax, 0x18(%r12)
movq 0x20(%r13), %rdi
addq %r15, %rdi
movl %ebx, %esi
callq 0x256a6
movl %eax, 0x1c(%r12)
movq 0x20(%r13), %rdi
addq %r15, %rdi
movl %ebx, %esi
callq 0x1fe6b
movq %rax, 0x20(%r12)
movq 0x28(%r13), %rdi
testq %rdi, %rdi
je 0x2d6f0
addq %r15, %rdi
movl %ebx, %esi
callq 0x1fe6b
movq %rax, 0x28(%r12)
jmp 0x2d6f0
movl $0x0, 0x1c(%r12)
movl 0x18(%r13), %eax
movl %eax, 0x18(%r12)
movb 0x30(%r13), %al
movb %al, 0x30(%r12)
movl 0x34(%r13), %eax
movl %eax, 0x34(%r12)
movb 0x38(%r13), %al
movb %al, 0x38(%r12)
movl 0x3c(%r13), %eax
movl %eax, 0x3c(%r12)
movq 0x10(%r14), %rax
movq %rax, (%r12)
movq %r12, 0x10(%r14)
movq (%r13), %r13
testq %r13, %r13
jne 0x2d653
movq %r14, %rdi
addq $0x10, %rdi
callq 0x20173
jmp 0x2d73e
xorl %r14d, %r14d
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq