// File: /workspace/github_c_makefile_star2_O2/icebert[P]pblat/jkOwnLib/genoFind.c
// Function: gfIndexNibsAndTwoBits
struct genoFind *gfIndexNibsAndTwoBits(int fileCount, char *fileNames[],
	int minMatch, int maxGap, int tileSize, int maxPat, char *oocFile,
	boolean allowOneMismatch, int stepSize)
/* Make index for all nibs and .2bits in list. 
 *      minMatch - minimum number of matching tiles to trigger alignments
 *      maxGap   - maximum deviation from diagonal of tiles
 *      tileSize - size of tile in nucleotides
 *      maxPat   - maximum use of tile to not be considered a repeat
 *      oocFile  - .ooc format file that lists repeat tiles.  May be NULL. 
 *      allowOneMismatch - allow one mismatch in a tile.  
 *      stepSize - space between tiles.  Zero means default (which is tileSize). */
{
struct genoFind *gf = gfNewEmpty(minMatch, maxGap, tileSize, stepSize,
	maxPat, oocFile, FALSE, allowOneMismatch);
int i;
bits32 offset = 0, nibSize;
char *fileName;
struct gfSeqSource *ss;
long long totalBases = 0, warnAt = maxTotalBases();
int totalSeq = 0;

if (allowOneMismatch)
    errAbort("Don't currently support allowOneMismatch in gfIndexNibsAndTwoBits");
if (stepSize == 0)
    stepSize = gf->tileSize;
for (i=0; i<fileCount; ++i)
    {
    fileName = fileNames[i];
    if (twoBitIsFile(fileName))
	{
	int seqCount;
	long long baseCount;
        gfCountTilesInTwoBit(gf, stepSize, fileName, &seqCount, &baseCount);
	totalBases += baseCount;
	totalSeq += seqCount;
	}
    else if (nibIsFile(fileName))
	{
	totalBases += gfCountTilesInNib(gf, stepSize, fileName);
	totalSeq += 1;
	}
    else
        errAbort("Unrecognized file type %s", fileName);
    /* Warn if they exceed 4 gig. */
    if (totalBases >= warnAt)
	errAbort("Exceeding 4 billion bases, sorry gfServer can't handle that.");
    }
gfAllocLists(gf);
gfZeroNonOverused(gf);
AllocArray(gf->sources, totalSeq);
gf->sourceCount = totalSeq;
ss = gf->sources;
for (i=0; i<fileCount; ++i)
    {
    fileName = fileNames[i];
    if (nibIsFile(fileName))
	{
	nibSize = gfAddTilesInNib(gf, fileName, offset, stepSize);
	ss->fileName = fileName;
	ss->start = offset;
	offset += nibSize;
	ss->end = offset;
	++ss;
	}
    else
        {
	struct twoBitFile *tbf = twoBitOpen(fileName);
	struct twoBitIndex *index;
	char nameBuf[PATH_LEN+256];
	for (index = tbf->indexList; index != NULL; index = index->next)
	    {
	    struct dnaSeq *seq = twoBitReadSeqFragLower(tbf, index->name, 0,0);
	    gfAddSeq(gf, seq, offset);
	    safef(nameBuf, sizeof(nameBuf), "%s:%s", fileName, index->name);
	    ss->fileName = cloneString(nameBuf);
	    ss->start = offset;
	    offset += seq->size;
	    ss->end = offset;
	    ++ss;
	    dnaSeqFree(&seq);
	    }
	twoBitClose(&tbf);
	}
    }
gf->totalSeqSize = offset;
gfZeroOverused(gf);
printf("Done adding\n");
return gf;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x348, %rsp            # imm = 0x348
movl %r9d, %r10d
movq %rsi, 0x28(%rsp)
movl %edi, %r14d
movl 0x390(%rsp), %eax
movq 0x380(%rsp), %r9
movl 0x388(%rsp), %ebx
movl %edx, %edi
movl %ecx, %esi
movl %r8d, %edx
movl %eax, %ecx
movl %r10d, %r8d
pushq %rbx
pushq $0x0
callq 0xae1c
popq %rcx
popq %rdx
movq %rax, %r15
testl %ebx, %ebx
je 0xaa7f
leaq 0x71f52(%rip), %rdi     # 0x7c9ca
xorl %eax, %eax
callq 0x223fb
xorl %eax, %eax
testl %r14d, %r14d
cmovlel %eax, %r14d
movq %r14, 0x30(%rsp)
leaq 0x40(%rsp), %r12
xorl %ebp, %ebp
xorl %r14d, %r14d
xorl %r13d, %r13d
cmpq 0x30(%rsp), %rbp
je 0xac32
movq 0x28(%rsp), %rax
movq (%rax,%rbp,8), %rbx
movq %rbx, %rdi
callq 0x38f60
testl %eax, %eax
je 0xab46
movq %r14, 0x18(%rsp)
movq %rbx, %rdi
callq 0x3842b
movq %rax, %r14
movq %rax, 0x10(%rsp)
movq %rax, %rdi
callq 0xb5c0
movq %rax, 0x20(%rsp)
leaq 0x72107(%rip), %rdi     # 0x7cbee
movq %rbx, %rsi
xorl %eax, %eax
callq 0x6070
movq %r14, %rbx
addq $0x28, %rbx
movq (%rbx), %rbx
testq %rbx, %rbx
je 0xab2d
movq 0x8(%rbx), %rsi
movq %r14, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x38bdb
movq %rax, 0x40(%rsp)
movq %r15, %rdi
movq %rax, %rsi
callq 0xcf26
movq %r12, %rdi
callq 0x20737
incl %r13d
jmp 0xaaf8
leaq 0x10(%rsp), %rdi
callq 0x3833b
movq 0x18(%rsp), %r14
addq 0x20(%rsp), %r14
jmp 0xac0d
movq %rbx, %rdi
callq 0x2ce73
testl %eax, %eax
je 0xabfc
movq %r14, 0x18(%rsp)
movq %rbp, 0x20(%rsp)
movq %r12, %rbp
movl 0xc(%r15), %r12d
shll $0xe, %r12d
xorl %r14d, %r14d
leaq 0x72079(%rip), %rdi     # 0x7cbee
movq %rbx, %rsi
xorl %eax, %eax
callq 0x6070
movq %rbx, %rdi
movq %rbp, %rsi
leaq 0x8(%rsp), %rdx
callq 0x2c4ad
movl 0x8(%rsp), %edx
cmpl %edx, %r14d
jge 0xabd6
leal (%r14,%r12), %ebp
cmpl %edx, %ebp
cmovgel %edx, %ebp
movl %ebp, %r8d
subl %r14d, %r8d
movq 0x40(%rsp), %rsi
movq %rbx, %rdi
movl %r14d, %ecx
callq 0x2ca0c
movq %rax, 0x10(%rsp)
movq %r15, %rdi
movq %rax, %rsi
callq 0xcf26
leaq 0x10(%rsp), %rdi
callq 0x20737
movl %ebp, %r14d
jmp 0xab8f
movq 0x40(%rsp), %rdi
callq 0x66e0
movslq 0x8(%rsp), %rax
movq 0x18(%rsp), %r14
addq %rax, %r14
incl %r13d
leaq 0x40(%rsp), %r12
movq 0x20(%rsp), %rbp
jmp 0xac0d
leaq 0x71e09(%rip), %rdi     # 0x7ca0c
movq %rbx, %rsi
xorl %eax, %eax
callq 0x223fb
movabsq $0x100000000, %rax      # imm = 0x100000000
cmpq %rax, %r14
jl 0xac2a
leaq 0x71e03(%rip), %rdi     # 0x7ca26
xorl %eax, %eax
callq 0x223fb
incq %rbp
jmp 0xaa9a
movq %r15, %rdi
callq 0xaf4f
movq %r15, %rdi
callq 0xafc6
movslq %r13d, %rax
imulq $0x28, %rax, %rdi
callq 0x28a1f
movq %rax, %r12
movq %rax, 0x20(%r15)
movl %r13d, 0x1c(%r15)
leaq 0x40(%rsp), %r14
xorl %ecx, %ecx
xorl %ebp, %ebp
movq %r15, 0x38(%rsp)
cmpq 0x30(%rsp), %rcx
je 0xadef
movq 0x28(%rsp), %rax
movq %rcx, 0x18(%rsp)
movq (%rax,%rcx,8), %r13
movq %r13, %rdi
callq 0x2ce73
testl %eax, %eax
je 0xad48
movl 0xc(%r15), %ebx
shll $0xe, %ebx
movq %r13, %r15
xorl %r13d, %r13d
leaq 0x71f60(%rip), %rdi     # 0x7cc04
movq %r15, %rsi
xorl %eax, %eax
callq 0x6070
movq %r15, %r14
movq %r15, %rdi
leaq 0x40(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq 0x2c4ad
movl 0x8(%rsp), %edx
cmpl %edx, %r13d
jge 0xad14
leal (%rbx,%r13), %r15d
cmpl %edx, %r15d
cmovgel %edx, %r15d
movl %r15d, %r8d
subl %r13d, %r8d
movq 0x40(%rsp), %rsi
movq %r14, %rdi
movl %r13d, %ecx
callq 0x2ca0c
movq %rax, 0x10(%rsp)
addl %ebp, %r13d
movq 0x38(%rsp), %rdi
movq %rax, %rsi
movl %r13d, %edx
callq 0xafea
leaq 0x10(%rsp), %rdi
callq 0x20737
movl %r15d, %r13d
jmp 0xacc3
movq 0x40(%rsp), %rdi
callq 0x66e0
movl 0x8(%rsp), %eax
addl %ebp, %eax
movq %r14, 0x8(%r12)
movl %ebp, 0x18(%r12)
movl %eax, 0x1c(%r12)
addq $0x28, %r12
movl %eax, %ebp
movq 0x38(%rsp), %r15
leaq 0x40(%rsp), %r14
jmp 0xade2
movq %r13, %rbx
movq %r13, %rdi
callq 0x3842b
movq %rax, %r13
movq %rax, 0x10(%rsp)
addq $0x28, %r13
movq (%r13), %r13
testq %r13, %r13
je 0xadd8
movq 0x10(%rsp), %rdi
movq 0x8(%r13), %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x38bdb
movq %rax, 0x8(%rsp)
movq %r15, %rdi
movq %rax, %rsi
movl %ebp, %edx
callq 0xafea
movq 0x8(%r13), %r8
movq %r14, %rdi
movl $0x300, %esi            # imm = 0x300
leaq 0x76c1a(%rip), %rdx     # 0x819b9
movq %rbx, %rcx
xorl %eax, %eax
callq 0x1fab2
movq %r14, %rdi
callq 0x1c306
movq %rax, 0x8(%r12)
movl %ebp, 0x18(%r12)
movq 0x8(%rsp), %rax
addl 0x18(%rax), %ebp
movl %ebp, 0x1c(%r12)
addq $0x28, %r12
leaq 0x8(%rsp), %rdi
callq 0x20737
jmp 0xad5f
leaq 0x10(%rsp), %rdi
callq 0x3833b
movq 0x18(%rsp), %rcx
incq %rcx
jmp 0xac67
movl %ebp, 0x30(%r15)
movq %r15, %rdi
callq 0xb09c
leaq 0x71f44(%rip), %rdi     # 0x7cd46
callq 0x6bb0
movq %r15, %rax
addq $0x348, %rsp            # imm = 0x348
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq