// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/lib/chain.c
// Function: chainSubsetOnQ
void chainSubsetOnQ(struct chain *chain, int subStart, int subEnd, 
    struct chain **retSubChain,  struct chain **retChainToFree)
/* Get subchain of chain bounded by subStart-subEnd on 
 * query side.  Return result in *retSubChain.  In some
 * cases this may be the original chain, in which case
 * *retChainToFree is NULL.  When done call chainFree on
 * *retChainToFree.  The score and id fields are not really
 * properly filled in. */
{
struct chain *sub = NULL;
struct cBlock *oldB, *b, *bList = NULL;
int qStart = BIGNUM, qEnd = -BIGNUM;
int tStart = BIGNUM, tEnd = -BIGNUM;

/* Check for easy case. */
if (subStart <= chain->qStart && subEnd >= chain->qEnd)
    {
    *retSubChain = chain;
    *retChainToFree = NULL;
    return;
    }
/* Build new block list and calculate bounds. */
for (oldB = chain->blockList; oldB != NULL; oldB = oldB->next)
    {
    if (oldB->qEnd <= subStart)
        continue;
    if (oldB->qStart >= subEnd)
        break;
    b = CloneVar(oldB);
    if (b->qStart < subStart)
        {
	b->tStart += subStart - b->qStart;
	b->qStart = subStart;
	}
    if (b->qEnd > subEnd)
        {
	b->tEnd -= b->qEnd - subEnd;
	b->qEnd = subEnd;
	}
    slAddHead(&bList, b);
    if (tStart > b->tStart)
        tStart = b->tStart;
    if (tEnd < b->tEnd)
        tEnd = b->tEnd;
    if (qStart > b->qStart)
        qStart = b->qStart;
    if (qEnd < b->qEnd)
        qEnd = b->qEnd;
    }
slReverse(&bList);

/* Make new chain based on old. */
if (bList != NULL)
    {
    AllocVar(sub);
    sub->blockList = bList;
    sub->qName = cloneString(chain->qName);
    sub->qSize = chain->qSize;
    sub->qStrand = chain->qStrand;
    sub->qStart = qStart;
    sub->qEnd = qEnd;
    sub->tName = cloneString(chain->tName);
    sub->tSize = chain->tSize;
    sub->tStart = tStart;
    sub->tEnd = tEnd;
    sub->id = chain->id;
    }
*retSubChain = *retChainToFree = sub;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x40(%rbp)
movl $0x3fffffff, -0x44(%rbp) # imm = 0x3FFFFFFF
movl $0xc0000001, -0x48(%rbp) # imm = 0xC0000001
movl $0x3fffffff, -0x4c(%rbp) # imm = 0x3FFFFFFF
movl $0xc0000001, -0x50(%rbp) # imm = 0xC0000001
movl -0xc(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x40(%rcx), %eax
jg 0x29139
movl -0x10(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x44(%rcx), %eax
jl 0x29139
movq -0x8(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movq $0x0, (%rax)
jmp 0x29321
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x29251
movq -0x30(%rbp), %rax
movl 0x14(%rax), %eax
cmpl -0xc(%rbp), %eax
jg 0x29161
jmp 0x29241
movq -0x30(%rbp), %rax
movl 0x10(%rax), %eax
cmpl -0x10(%rbp), %eax
jl 0x29172
jmp 0x29251
movq -0x30(%rbp), %rdi
movl $0x28, %esi
callq 0x2a360
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movl 0x10(%rax), %eax
cmpl -0xc(%rbp), %eax
jge 0x291ae
movl -0xc(%rbp), %ecx
movq -0x38(%rbp), %rax
subl 0x10(%rax), %ecx
movq -0x38(%rbp), %rax
addl 0x8(%rax), %ecx
movl %ecx, 0x8(%rax)
movl -0xc(%rbp), %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x38(%rbp), %rax
movl 0x14(%rax), %eax
cmpl -0x10(%rbp), %eax
jle 0x291da
movq -0x38(%rbp), %rax
movl 0x14(%rax), %edx
subl -0x10(%rbp), %edx
movq -0x38(%rbp), %rax
movl 0xc(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0xc(%rax)
movl -0x10(%rbp), %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0x27ff0
movl -0x4c(%rbp), %eax
movq -0x38(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jle 0x291fd
movq -0x38(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x4c(%rbp)
movl -0x50(%rbp), %eax
movq -0x38(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jge 0x29213
movq -0x38(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x50(%rbp)
movl -0x44(%rbp), %eax
movq -0x38(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jle 0x29229
movq -0x38(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x44(%rbp)
movl -0x48(%rbp), %eax
movq -0x38(%rbp), %rcx
cmpl 0x14(%rcx), %eax
jge 0x2923f
movq -0x38(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0x48(%rbp)
jmp 0x29241
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0x29145
leaq -0x40(%rbp), %rdi
callq 0x2aad0
cmpq $0x0, -0x40(%rbp)
je 0x2930f
movl $0x50, %edi
callq 0x40c50
movq %rax, -0x28(%rbp)
movq -0x40(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x2a450
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x8(%rbp), %rax
movl 0x38(%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x38(%rax)
movq -0x8(%rbp), %rax
movb 0x3c(%rax), %cl
movq -0x28(%rbp), %rax
movb %cl, 0x3c(%rax)
movl -0x44(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x40(%rax)
movl -0x48(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x44(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x2a450
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rax
movl 0x20(%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x20(%rax)
movl -0x4c(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x24(%rax)
movl -0x50(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x28(%rax)
movq -0x8(%rbp), %rax
movl 0x48(%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x48(%rax)
movq -0x28(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)