// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/lib/chain.c
// Function: chainFastSubsetOnT
void chainFastSubsetOnT(struct chain *chain, struct cBlock *firstBlock,
	int subStart, int subEnd, struct chain **retSubChain,  struct chain **retChainToFree)
/* Get subchain as in chainSubsetOnT. Pass in initial block that may
 * be known from some index to speed things up. */
{
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->tStart && subEnd >= chain->tEnd)
    {
    *retSubChain = chain;
    *retChainToFree = NULL;
    return;
    }
/* Build new block list and calculate bounds. */
for (oldB = firstBlock; oldB != NULL; oldB = oldB->next)
    {
    if (oldB->tStart >= subEnd)
        break;
    b = CloneVar(oldB);
    if (b->tStart < subStart)
        {
	b->qStart += subStart - b->tStart;
	b->tStart = subStart;
	}
    if (b->tEnd > subEnd)
        {
	b->qEnd -= b->tEnd - subEnd;
	b->tEnd = subEnd;
	}
    slAddHead(&bList, b);
    if (qStart > b->qStart)
        qStart = b->qStart;
    if (qEnd < b->qEnd)
        qEnd = b->qEnd;
    if (tStart > b->tStart)
        tStart = b->tStart;
    if (tEnd < b->tEnd)
        tEnd = b->tEnd;
    }
slReverse(&bList);

/* Make new chain based on old. */
if (bList != NULL)
    {
    double sizeRatio;
    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;

    /* Fake new score. */
    sizeRatio = (sub->tEnd - sub->tStart);
    sizeRatio /= (chain->tEnd - chain->tStart);
    sub->score = sizeRatio * chain->score;
    }
*retSubChain = *retChainToFree = sub;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x48(%rbp)
movl $0x3fffffff, -0x4c(%rbp) # imm = 0x3FFFFFFF
movl $0xc0000001, -0x50(%rbp) # imm = 0xC0000001
movl $0x3fffffff, -0x54(%rbp) # imm = 0x3FFFFFFF
movl $0xc0000001, -0x58(%rbp) # imm = 0xC0000001
movl -0x14(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x24(%rcx), %eax
jg 0x28e8d
movl -0x18(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x28(%rcx), %eax
jl 0x28e8d
movq -0x8(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
movq $0x0, (%rax)
jmp 0x290ae
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x28f90
movq -0x38(%rbp), %rax
movl 0x8(%rax), %eax
cmpl -0x18(%rbp), %eax
jl 0x28eb1
jmp 0x28f90
movq -0x38(%rbp), %rdi
movl $0x28, %esi
callq 0x2a360
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movl 0x8(%rax), %eax
cmpl -0x14(%rbp), %eax
jge 0x28eed
movl -0x14(%rbp), %ecx
movq -0x40(%rbp), %rax
subl 0x8(%rax), %ecx
movq -0x40(%rbp), %rax
addl 0x10(%rax), %ecx
movl %ecx, 0x10(%rax)
movl -0x14(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x40(%rbp), %rax
movl 0xc(%rax), %eax
cmpl -0x18(%rbp), %eax
jle 0x28f19
movq -0x40(%rbp), %rax
movl 0xc(%rax), %edx
subl -0x18(%rbp), %edx
movq -0x40(%rbp), %rax
movl 0x14(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x14(%rax)
movl -0x18(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x40(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0x27ff0
movl -0x4c(%rbp), %eax
movq -0x40(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jle 0x28f3c
movq -0x40(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x4c(%rbp)
movl -0x50(%rbp), %eax
movq -0x40(%rbp), %rcx
cmpl 0x14(%rcx), %eax
jge 0x28f52
movq -0x40(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0x50(%rbp)
movl -0x54(%rbp), %eax
movq -0x40(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jle 0x28f68
movq -0x40(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x54(%rbp)
movl -0x58(%rbp), %eax
movq -0x40(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jge 0x28f7e
movq -0x40(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x58(%rbp)
jmp 0x28f80
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
jmp 0x28e95
leaq -0x48(%rbp), %rdi
callq 0x2aad0
cmpq $0x0, -0x48(%rbp)
je 0x2909c
movl $0x50, %edi
callq 0x40c50
movq %rax, -0x30(%rbp)
movq -0x48(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x2a450
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x8(%rbp), %rax
movl 0x38(%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x38(%rax)
movq -0x8(%rbp), %rax
movb 0x3c(%rax), %cl
movq -0x30(%rbp), %rax
movb %cl, 0x3c(%rax)
movl -0x4c(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x40(%rax)
movl -0x50(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x44(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x2a450
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rax
movl 0x20(%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x20(%rax)
movl -0x54(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x24(%rax)
movl -0x58(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x28(%rax)
movq -0x8(%rbp), %rax
movl 0x48(%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x48(%rax)
movq -0x30(%rbp), %rax
movl 0x28(%rax), %eax
movq -0x30(%rbp), %rcx
subl 0x24(%rcx), %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x60(%rbp)
movq -0x8(%rbp), %rax
movl 0x28(%rax), %eax
movq -0x8(%rbp), %rcx
subl 0x24(%rcx), %eax
cvtsi2sd %eax, %xmm1
movsd -0x60(%rbp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
movsd -0x60(%rbp), %xmm0
movq -0x8(%rbp), %rax
mulsd 0x10(%rax), %xmm0
movq -0x30(%rbp), %rax
movsd %xmm0, 0x10(%rax)
movq -0x30(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)