// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r13
movq $0x0, 0x8(%rsp)
movl %edx, (%rsp)
cmpl %edx, 0x24(%rdi)
jl 0x1f27f
cmpl %ecx, 0x28(%rdi)
jle 0x1f404
movq %rdi, 0x10(%rsp)
movq %r8, 0x18(%rsp)
movq %r9, 0x20(%rsp)
testq %r13, %r13
je 0x1f33c
movl $0x3fffffff, %ebx       # imm = 0x3FFFFFFF
movl $0xc0000001, %r14d      # imm = 0xC0000001
xorl %ebp, %ebp
movl $0xc0000001, %r15d      # imm = 0xC0000001
movl $0x3fffffff, %r12d      # imm = 0x3FFFFFFF
cmpl %ecx, 0x8(%r13)
jge 0x1f353
movl %ebx, 0x4(%rsp)
movl %ecx, %ebx
movl $0x28, %esi
movq %r13, %rdi
callq 0x1fe44
movl 0x8(%rax), %r8d
movl (%rsp), %edx
subl %r8d, %edx
jle 0x1f2e4
addl %edx, 0x10(%rax)
movl (%rsp), %r8d
movl %r8d, 0x8(%rax)
movl 0xc(%rax), %edx
movl %ebx, %ecx
movl %ebx, %esi
subl %edx, %esi
jge 0x1f2fc
addl 0x14(%rax), %esi
movl %esi, 0x14(%rax)
movl %ecx, 0xc(%rax)
movl %ecx, %edx
jmp 0x1f2ff
movl 0x14(%rax), %esi
movl 0x4(%rsp), %ebx
movq %rbp, (%rax)
movq %rax, 0x8(%rsp)
movl 0x10(%rax), %edi
cmpl %edi, %r12d
cmovgel %edi, %r12d
cmpl %esi, %r15d
cmovlel %esi, %r15d
cmpl %r8d, %ebx
cmovgel %r8d, %ebx
cmpl %edx, %r14d
cmovlel %edx, %r14d
movq (%r13), %r13
movq %rax, %rbp
testq %r13, %r13
jne 0x1f2b0
jmp 0x1f353
movl $0xc0000001, %r15d      # imm = 0xC0000001
movl $0x3fffffff, %r12d      # imm = 0x3FFFFFFF
movl $0x3fffffff, %ebx       # imm = 0x3FFFFFFF
movl $0xc0000001, %r14d      # imm = 0xC0000001
leaq 0x8(%rsp), %r13
movq %r13, %rdi
callq 0x20173
cmpq $0x0, (%r13)
je 0x1f3ef
movl $0x50, %edi
callq 0x2dff4
movq %rax, %r13
movq 0x8(%rsp), %rax
movq %rax, 0x8(%r13)
movq 0x10(%rsp), %rbp
movq 0x30(%rbp), %rdi
callq 0x1feba
movq %rax, 0x30(%r13)
movl 0x38(%rbp), %eax
movl %eax, 0x38(%r13)
movb 0x3c(%rbp), %al
movb %al, 0x3c(%r13)
movl %r12d, 0x40(%r13)
movl %r15d, 0x44(%r13)
movq 0x18(%rbp), %rdi
callq 0x1feba
movq %rax, 0x18(%r13)
movl 0x20(%rbp), %eax
movl %eax, 0x20(%r13)
movl %ebx, 0x24(%r13)
movl %r14d, 0x28(%r13)
movl 0x48(%rbp), %eax
movl %eax, 0x48(%r13)
subl %ebx, %r14d
cvtsi2sd %r14d, %xmm0
movl 0x28(%rbp), %eax
subl 0x24(%rbp), %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
mulsd 0x10(%rbp), %xmm0
movsd %xmm0, 0x10(%r13)
jmp 0x1f3f2
xorl %r13d, %r13d
movq 0x20(%rsp), %rax
movq %r13, (%rax)
movq 0x18(%rsp), %rax
movq %r13, (%rax)
jmp 0x1f40e
movq %rdi, (%r8)
movq $0x0, (%r9)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq