// File: /workspace/github_c_makefile_star2_O3/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 $0x358, %rsp            # imm = 0x358
movl %r9d, %r10d
movq %rsi, 0x40(%rsp)
movl %edi, %ebp
movl 0x3a0(%rsp), %eax
movq 0x390(%rsp), %r9
movl 0x398(%rsp), %ebx
movl %edx, %edi
movl %ecx, %esi
movl %r8d, %edx
movl %eax, %ecx
movl %r10d, %r8d
pushq %rbx
pushq $0x0
callq 0xcc67
addq $0x10, %rsp
movq %rax, 0x10(%rsp)
testl %ebx, %ebx
je 0xc80a
leaq 0x81237(%rip), %rdi     # 0x8da3a
xorl %eax, %eax
callq 0x26e94
movl %ebp, %eax
movq %rax, 0x38(%rsp)
movl %ebp, 0x34(%rsp)
testl %ebp, %ebp
jle 0xc9f0
leaq 0x50(%rsp), %rbp
leaq 0x18(%rsp), %r13
xorl %r15d, %r15d
xorl %r12d, %r12d
xorl %r14d, %r14d
movq 0x10(%rsp), %rbx
movq %r14, 0x8(%rsp)
movq 0x40(%rsp), %rax
movq (%rax,%r15,8), %r14
movq %r14, %rdi
callq 0x3efc9
testl %eax, %eax
je 0xc8f1
movq %r15, 0x28(%rsp)
movl %r12d, 0x20(%rsp)
movq %r14, %rdi
callq 0x3e405
movq %rax, %r12
movq %rax, 0x18(%rsp)
movq %rax, %rdi
callq 0xd61a
movq %rax, 0x48(%rsp)
movq %rbp, %r15
xorl %ebp, %ebp
leaq 0x813d8(%rip), %rdi     # 0x8dc5e
movq %r14, %rsi
xorl %eax, %eax
callq 0x6070
movq 0x28(%r12), %r14
testq %r14, %r14
je 0xc8d2
xorl %ebp, %ebp
movq 0x8(%r14), %rsi
movq %r12, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x3ec0b
movq %rax, 0x50(%rsp)
movq 0x10(%rax), %rsi
movl 0x18(%rax), %edx
movq %rbx, %rdi
callq 0xf2da
incl %ebp
movq %r15, %rdi
callq 0x24db1
movq (%r14), %r14
testq %r14, %r14
jne 0xc89c
movq %r13, %rdi
callq 0x3e30e
movq 0x8(%rsp), %r14
addq 0x48(%rsp), %r14
movl 0x20(%rsp), %r12d
addl %ebp, %r12d
jmp 0xc9a3
movq %r14, %rdi
callq 0x324f7
testl %eax, %eax
je 0xc9d8
movq %r15, 0x28(%rsp)
movl %r12d, 0x20(%rsp)
movl 0xc(%rbx), %r12d
leaq 0x81348(%rip), %rdi     # 0x8dc5e
movq %r14, %rsi
xorl %eax, %eax
callq 0x6070
movq %r14, %rdi
movq %rbp, %r15
movq %rbp, %rsi
movq %rsp, %rdx
callq 0x31b2d
movl (%rsp), %edx
testl %edx, %edx
movq %rbx, %rbp
jle 0xc982
shll $0xe, %r12d
xorl %ecx, %ecx
leal (%rcx,%r12), %ebx
cmpl %edx, %ebx
cmovgel %edx, %ebx
movl %ebx, %r8d
subl %ecx, %r8d
movq 0x50(%rsp), %rsi
movq %r14, %rdi
callq 0x3208c
movq %rax, 0x18(%rsp)
movq 0x10(%rax), %rsi
movl 0x18(%rax), %edx
movq %rbp, %rdi
callq 0xf2da
movq %r13, %rdi
callq 0x24db1
movl (%rsp), %edx
movl %ebx, %ecx
cmpl %edx, %ebx
jl 0xc941
movq 0x50(%rsp), %rdi
callq 0x66e0
movslq (%rsp), %rax
movq 0x8(%rsp), %r14
addq %rax, %r14
movl 0x20(%rsp), %r12d
incl %r12d
movq %rbp, %rbx
movq %r15, %rbp
movq 0x28(%rsp), %r15
movabsq $0x100000000, %rax      # imm = 0x100000000
cmpq %rax, %r14
jl 0xc9c8
leaq 0x810d5(%rip), %rdi     # 0x8da96
xorl %eax, %eax
callq 0x26e94
incq %r15
cmpq 0x38(%rsp), %r15
jne 0xc835
jmp 0xc9f8
leaq 0x8109d(%rip), %rdi     # 0x8da7c
movq %r14, %rsi
xorl %eax, %eax
callq 0x26e94
movq 0x8(%rsp), %r14
jmp 0xc9ab
xorl %r12d, %r12d
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0xcec3
movslq 0x14(%rbx), %rax
testq %rax, %rax
jle 0xca25
movq 0x38(%rbx), %rcx
movl (%rbx), %edx
xorl %esi, %esi
cmpl %edx, (%rcx,%rsi,4)
jae 0xca1d
movl $0x0, (%rcx,%rsi,4)
incq %rsi
cmpq %rsi, %rax
jne 0xca11
movslq %r12d, %rbx
leaq (,%rbx,8), %rax
leaq (%rax,%rax,4), %rdi
callq 0x2de63
movq %rax, %r15
movq 0x10(%rsp), %rax
movq %r15, 0x20(%rax)
movq 0x10(%rsp), %rax
movl %ebx, 0x1c(%rax)
movq 0x10(%rsp), %rbx
cmpl $0x0, 0x34(%rsp)
jle 0xcc1a
leaq 0x86055(%rip), %rbp     # 0x92ab9
leaq 0x50(%rsp), %r14
movq %rsp, %r12
xorl %ecx, %ecx
xorl %r13d, %r13d
movq 0x40(%rsp), %rax
movq %rcx, 0x20(%rsp)
movq (%rax,%rcx,8), %rdi
movq %rdi, 0x8(%rsp)
callq 0x324f7
testl %eax, %eax
je 0xcb50
movl 0xc(%rbx), %ebp
leaq 0x811d9(%rip), %rdi     # 0x8dc74
movq 0x8(%rsp), %rbx
movq %rbx, %rsi
xorl %eax, %eax
callq 0x6070
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x31b2d
movl (%rsp), %edx
testl %edx, %edx
movq 0x10(%rsp), %r14
jle 0xcb19
shll $0xe, %ebp
xorl %r12d, %r12d
leal (%r12,%rbp), %ebx
cmpl %edx, %ebx
cmovgel %edx, %ebx
movl %ebx, %r8d
subl %r12d, %r8d
movq 0x50(%rsp), %rsi
movq 0x8(%rsp), %rdi
movl %r12d, %ecx
callq 0x3208c
movq %rax, 0x18(%rsp)
addl %r13d, %r12d
movq 0x10(%rax), %rsi
movl 0x18(%rax), %edx
movq %r14, %rdi
movl %r12d, %ecx
callq 0xcf39
leaq 0x18(%rsp), %rdi
callq 0x24db1
movl (%rsp), %edx
movl %ebx, %r12d
cmpl %edx, %ebx
jl 0xcaca
movq 0x50(%rsp), %rdi
callq 0x66e0
movl (%rsp), %eax
addl %r13d, %eax
movq 0x8(%rsp), %rcx
movq %rcx, 0x8(%r15)
movl %r13d, 0x18(%r15)
movl %eax, 0x1c(%r15)
addq $0x28, %r15
movl %eax, %r13d
movq %r14, %rbx
leaq 0x85f6e(%rip), %rbp     # 0x92ab9
jmp 0xcbfd
movq 0x8(%rsp), %rdi
callq 0x3e405
movq %rax, 0x18(%rsp)
movq 0x28(%rax), %r12
testq %r12, %r12
je 0xcbee
leaq 0x50(%rsp), %r14
movq 0x10(%rsp), %rbx
movq 0x18(%rsp), %rdi
movq 0x8(%r12), %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x3ec0b
movq %rax, (%rsp)
movq 0x10(%rax), %rsi
movl 0x18(%rax), %edx
movq %rbx, %rdi
movl %r13d, %ecx
callq 0xcf39
movq 0x8(%r12), %r8
movq %r14, %rdi
movl $0x300, %esi            # imm = 0x300
movq %rbp, %rdx
movq 0x8(%rsp), %rcx
xorl %eax, %eax
callq 0x23f33
movq %r14, %rdi
callq 0x1feba
movq %rax, 0x8(%r15)
movl %r13d, 0x18(%r15)
movq (%rsp), %rax
addl 0x18(%rax), %r13d
movl %r13d, 0x1c(%r15)
addq $0x28, %r15
movq %rsp, %rdi
callq 0x24db1
movq (%r12), %r12
testq %r12, %r12
jne 0xcb76
jmp 0xcbf3
movq 0x10(%rsp), %rbx
leaq 0x18(%rsp), %rdi
callq 0x3e30e
movq 0x20(%rsp), %rcx
incq %rcx
cmpq 0x38(%rsp), %rcx
leaq 0x50(%rsp), %r14
movq %rsp, %r12
jne 0xca71
jmp 0xcc1d
xorl %r13d, %r13d
movl %r13d, 0x30(%rbx)
movslq 0x14(%rbx), %rax
testq %rax, %rax
jle 0xcc46
movq 0x38(%rbx), %rcx
movl (%rbx), %edx
xorl %esi, %esi
cmpl %edx, (%rcx,%rsi,4)
jb 0xcc3e
movl $0x0, (%rcx,%rsi,4)
incq %rsi
cmpq %rsi, %rax
jne 0xcc32
leaq 0x81169(%rip), %rdi     # 0x8ddb6
callq 0x6bb0
movq %rbx, %rax
addq $0x358, %rsp            # imm = 0x358
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq