// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x360, %rsp            # imm = 0x360
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
movq $0x0, -0x38(%rbp)
leaq -0x340(%rbp), %rdi
movq -0x18(%rbp), %rcx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %r8
movl $0x300, %esi            # imm = 0x300
leaq 0xc65fa(%rip), %rdx     # 0xdc9d9
movb $0x0, %al
callq 0x31090
leaq -0x340(%rbp), %rdi
callq 0x472b0
cmpl $0x0, %eax
je 0x16517
movq -0x10(%rbp), %rdi
leaq -0x340(%rbp), %rsi
callq 0x39630
movq %rax, -0x348(%rbp)
cmpq $0x0, -0x348(%rbp)
jne 0x16446
leaq -0x340(%rbp), %rdi
callq 0x473c0
movq %rax, -0x348(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x340(%rbp), %rsi
movq -0x348(%rbp), %rdx
callq 0x39230
cmpl $0x0, 0x10(%rbp)
je 0x1646b
movq -0x8(%rbp), %rdi
addq $0x20, %rdi
movq -0x8(%rbp), %rsi
addq $0x24, %rsi
movq -0x348(%rbp), %rax
movl 0x10(%rax), %edx
callq 0x33350
movq -0x8(%rbp), %rdi
movl -0x1c(%rbp), %esi
movq -0x348(%rbp), %rax
movl 0x10(%rax), %edx
movl -0x2c(%rbp), %ecx
movl 0x10(%rbp), %r8d
movl 0x18(%rbp), %r9d
callq 0x16240
leaq -0x340(%rbp), %rdi
movq -0x348(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x348(%rbp), %rax
movl 0x10(%rax), %edx
movq -0x8(%rbp), %rax
movl 0x20(%rax), %ecx
movq -0x8(%rbp), %rax
movl 0x24(%rax), %r8d
movq -0x8(%rbp), %rax
subl 0x20(%rax), %r8d
callq 0x46c60
movq %rax, -0x38(%rbp)
cmpl $0x0, 0x10(%rbp)
je 0x16502
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x38(%rbp), %rax
movslq 0x18(%rax), %rsi
callq 0x33300
movq -0x8(%rbp), %rdi
addq $0x20, %rdi
movq -0x8(%rbp), %rsi
addq $0x24, %rsi
movq -0x348(%rbp), %rax
movl 0x10(%rax), %edx
callq 0x33350
movq -0x348(%rbp), %rax
movl 0x10(%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
jmp 0x1667d
movq $0x0, -0x350(%rbp)
leaq -0x340(%rbp), %rdi
movl $0x3a, %esi
callq 0x67b0
movq %rax, -0x358(%rbp)
movl $0x0, -0x35c(%rbp)
cmpq $0x0, -0x358(%rbp)
jne 0x1655c
leaq 0xc1b7b(%rip), %rdi     # 0xd80d0
movb $0x0, %al
callq 0x35d40
movq -0x358(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x358(%rbp)
movb $0x0, (%rax)
movq -0x10(%rbp), %rdi
leaq -0x340(%rbp), %rsi
callq 0x39630
movq %rax, -0x350(%rbp)
cmpq $0x0, -0x350(%rbp)
jne 0x165bf
leaq -0x340(%rbp), %rdi
callq 0x59660
movq %rax, -0x350(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x340(%rbp), %rsi
movq -0x350(%rbp), %rdx
callq 0x39230
movq -0x350(%rbp), %rdi
movq -0x358(%rbp), %rsi
callq 0x5a4a0
movl %eax, -0x35c(%rbp)
cmpl $0x0, 0x10(%rbp)
je 0x165f9
movq -0x8(%rbp), %rdi
addq $0x20, %rdi
movq -0x8(%rbp), %rsi
addq $0x24, %rsi
movl -0x35c(%rbp), %edx
callq 0x33350
movq -0x8(%rbp), %rdi
movl -0x1c(%rbp), %esi
movl -0x35c(%rbp), %edx
movl -0x2c(%rbp), %ecx
movl 0x10(%rbp), %r8d
movl 0x18(%rbp), %r9d
callq 0x16240
movq -0x350(%rbp), %rdi
movq -0x358(%rbp), %rsi
movq -0x8(%rbp), %rax
movl 0x20(%rax), %edx
movq -0x8(%rbp), %rax
movl 0x24(%rax), %ecx
callq 0x5a460
movq %rax, -0x38(%rbp)
cmpl $0x0, 0x10(%rbp)
je 0x16671
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x38(%rbp), %rax
movslq 0x18(%rax), %rsi
callq 0x33300
movq -0x8(%rbp), %rdi
addq $0x20, %rdi
movq -0x8(%rbp), %rsi
addq $0x24, %rsi
movl -0x35c(%rbp), %edx
callq 0x33350
movl -0x35c(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movq -0x38(%rbp), %rax
addq $0x360, %rsp            # imm = 0x360
popq %rbp
retq
nopw (%rax,%rax)