// File: /workspace/github_c_makefile_star2_O3/icebert[P]pblat/jkOwnLib/gfInternal.c
// Function: gfiExpandAndLoadCached
struct dnaSeq *gfiExpandAndLoadCached(struct gfRange *range, 
	struct hash *tFileCache, char *tSeqDir, int querySize, 
	int *retTotalSeqSize, boolean respectFrame, boolean isRc, int expansion)
/* Expand range to cover an additional expansion bases on either side.
 * Load up target sequence and return. (Done together because don't
 * know target size before loading.) */
{
struct dnaSeq *target = NULL;
char fileName[PATH_LEN+256];

safef(fileName, sizeof(fileName), "%s/%s", tSeqDir, range->tName);
if (nibIsFile(fileName))
    {
    struct nibInfo *nib = hashFindVal(tFileCache, fileName);
    if (nib == NULL)
        {
	nib = nibInfoNew(fileName);
	hashAdd(tFileCache, fileName, nib);
	}
    if (isRc)
	reverseIntRange(&range->tStart, &range->tEnd, nib->size);
    gfiExpandRange(range, querySize, nib->size, respectFrame, isRc, expansion);
    target = nibLdPart(fileName, nib->f, nib->size, 
    	range->tStart, range->tEnd - range->tStart);
    if (isRc)
	{
	reverseComplement(target->dna, target->size);
	reverseIntRange(&range->tStart, &range->tEnd, nib->size);
	}
    *retTotalSeqSize = nib->size;
    }
else
    {
    struct twoBitFile *tbf = NULL;
    // split a filename+chrom like "/gbdb/hg19/hg19.2bit:chr1"
    // (can also be URL like "http://hgdownload.soe.ucsc.edu/gbdb/hg19/hg19.2bit:chr1")
    // into filename and tSeqName
    char *tSeqName = strrchr(fileName, ':');
    int tSeqSize = 0;
    if (tSeqName == NULL)
        errAbort("No colon in .2bit response from gfServer");
    *tSeqName++ = 0;
    tbf = hashFindVal(tFileCache, fileName);
    if (tbf == NULL)
        {
	tbf = twoBitOpen(fileName);
	hashAdd(tFileCache, fileName, tbf);
	}
    tSeqSize = twoBitSeqSize(tbf, tSeqName);
    if (isRc)
	reverseIntRange(&range->tStart, &range->tEnd, tSeqSize);
    gfiExpandRange(range, querySize, tSeqSize, respectFrame, isRc, expansion);
    target = twoBitReadSeqFragLower(tbf, tSeqName, range->tStart, range->tEnd);
    if (isRc)
	{
	reverseComplement(target->dna, target->size);
	reverseIntRange(&range->tStart, &range->tEnd, tSeqSize);
	}
    *retTotalSeqSize = tSeqSize;
    }
return target;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x328, %rsp            # imm = 0x328
movl %r9d, %r15d
movq %r8, 0x18(%rsp)
movl %ecx, 0x8(%rsp)
movq %rdx, %rcx
movq %rsi, %r12
movq %rdi, %r14
movl 0x368(%rsp), %r13d
movl 0x360(%rsp), %ebp
movq 0x10(%rdi), %r8
leaq 0x7f896(%rip), %rdx     # 0x92c0a
leaq 0x20(%rsp), %rbx
movq %rbx, %rdi
movl $0x300, %esi            # imm = 0x300
xorl %eax, %eax
callq 0x23f33
movq %rbx, %rdi
callq 0x324f7
testl %eax, %eax
je 0x133f3
leaq 0x20(%rsp), %rsi
movq %r12, %rdi
callq 0x293ad
movq %rax, %rbx
testq %rax, %rax
jne 0x133cf
leaq 0x20(%rsp), %r13
movq %r13, %rdi
callq 0x325dd
movq %rax, %rbx
movq %r12, %rdi
movq %r13, %rsi
movl 0x368(%rsp), %r13d
movq %rax, %rdx
callq 0x29142
testl %ebp, %ebp
je 0x134e4
leaq 0x20(%r14), %rdi
leaq 0x24(%r14), %rsi
leaq 0x10(%rbx), %r12
movl 0x10(%rbx), %edx
callq 0x25472
movl %ebp, %r8d
jmp 0x134eb
movl %r15d, 0xc(%rsp)
leaq 0x20(%rsp), %rdi
movl $0x3a, %esi
callq 0x67c0
movq %rax, %rbx
movq %rax, %r15
testq %rax, %rax
jne 0x13420
leaq 0x7adbe(%rip), %rdi     # 0x8e1d7
xorl %eax, %eax
callq 0x26e94
incq %rbx
movb $0x0, (%r15)
leaq 0x20(%rsp), %rsi
movq %r12, %rdi
callq 0x293ad
movq %rax, %rbp
testq %rax, %rax
jne 0x1345a
leaq 0x20(%rsp), %r15
movq %r15, %rdi
callq 0x3e405
movq %rax, %rbp
movq %r12, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x29142
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x3ec16
movl %eax, %r12d
movl 0x360(%rsp), %r15d
testl %r15d, %r15d
je 0x13568
leaq 0x20(%r14), %rdi
movq %rdi, 0x10(%rsp)
leaq 0x24(%r14), %r13
movq %r13, %rsi
movl %r12d, %edx
callq 0x25472
movq %r14, %rdi
movl 0x8(%rsp), %esi
movl %r12d, %edx
movl 0xc(%rsp), %ecx
movl %r15d, %r8d
movl 0x368(%rsp), %r9d
callq 0x13240
movl 0x20(%r14), %edx
movl 0x24(%r14), %ecx
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x3ec0b
movq %rax, %rbx
movq 0x10(%rax), %rdi
movslq 0x18(%rax), %rsi
callq 0x25423
movq 0x10(%rsp), %rdi
movq %r13, %rsi
movl %r12d, %edx
callq 0x25472
jmp 0x1354b
leaq 0x10(%rbx), %r12
xorl %r8d, %r8d
movl 0x10(%rbx), %edx
movq %r14, %rdi
movl 0x8(%rsp), %esi
movl %r15d, %ecx
movl %r13d, %r9d
callq 0x13240
movq 0x18(%rbx), %rsi
movl 0x10(%rbx), %edx
movl 0x20(%r14), %ecx
movl 0x24(%r14), %r8d
subl %ecx, %r8d
leaq 0x20(%rsp), %rdi
callq 0x3208c
movq %rax, %rbx
testl %ebp, %ebp
je 0x13547
leaq 0x20(%r14), %r15
addq $0x24, %r14
movq 0x10(%rbx), %rdi
movslq 0x18(%rbx), %rsi
callq 0x25423
movl (%r12), %edx
movq %r15, %rdi
movq %r14, %rsi
callq 0x25472
movl (%r12), %r12d
movq 0x18(%rsp), %rax
movl %r12d, (%rax)
movq %rbx, %rax
addq $0x328, %rsp            # imm = 0x328
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
movl 0x8(%rsp), %esi
movl %r12d, %edx
movl 0xc(%rsp), %ecx
xorl %r8d, %r8d
movl %r13d, %r9d
callq 0x13240
movl 0x20(%r14), %edx
movl 0x24(%r14), %ecx
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x3ec0b
movq %rax, %rbx
jmp 0x1354b