// File: /workspace/github_c_makefile_star2_O1/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, 0x48(%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 0xccd3
addq $0x10, %rsp
movq %rax, 0x28(%rsp)
testl %ebx, %ebx
je 0xc887
leaq 0x8116a(%rip), %rdi     # 0x8d9ea
xorl %eax, %eax
callq 0x26b6f
movl %ebp, %eax
movq %rax, 0x40(%rsp)
movl %ebp, 0x3c(%rsp)
testl %ebp, %ebp
jle 0xca51
leaq 0x50(%rsp), %r15
leaq 0x18(%rsp), %r13
xorl %r12d, %r12d
movl $0x0, 0x24(%rsp)
xorl %r14d, %r14d
movq 0x28(%rsp), %rbx
movq %r14, 0x10(%rsp)
movq 0x48(%rsp), %rax
movq (%rax,%r12,8), %r14
movq %r14, %rdi
callq 0x3ec3e
movq %r14, %rdi
testl %eax, %eax
je 0xc96b
callq 0x3e08d
movq %rax, 0x18(%rsp)
movq %rax, %rdi
callq 0xd57e
movq %rax, 0x30(%rsp)
movq %r15, %rbp
xorl %r15d, %r15d
leaq 0x81312(%rip), %rdi     # 0x8dc0e
movq %r14, %rsi
xorl %eax, %eax
callq 0x6070
movq 0x18(%rsp), %rax
movq 0x28(%rax), %r14
testq %r14, %r14
je 0xc94c
xorl %r15d, %r15d
movq 0x18(%rsp), %rdi
movq 0x8(%r14), %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x3e8a7
movq %rax, 0x50(%rsp)
movq %rbx, %rdi
movq %rax, %rsi
callq 0xf1ba
incl %r15d
movq %rbp, %rdi
callq 0x24ab1
movq (%r14), %r14
testq %r14, %r14
jne 0xc917
movq %r13, %rdi
callq 0x3df96
movq 0x10(%rsp), %r14
addq 0x30(%rsp), %r14
addl %r15d, 0x24(%rsp)
movq %rbp, %r15
jmp 0xca24
callq 0x3221b
testl %eax, %eax
je 0xca0e
movl 0xc(%rbx), %ebp
leaq 0x8128c(%rip), %rdi     # 0x8dc0e
movq %r14, %rsi
xorl %eax, %eax
callq 0x6070
movq %r14, %rdi
movq %r15, %rsi
leaq 0x8(%rsp), %rdx
callq 0x3185d
movl 0x8(%rsp), %edx
testl %edx, %edx
movq %rbx, %r15
jle 0xc9e9
shll $0xe, %ebp
xorl %ecx, %ecx
leal (%rcx,%rbp), %ebx
cmpl %edx, %ebx
cmovgel %edx, %ebx
movl %ebx, %r8d
subl %ecx, %r8d
movq 0x50(%rsp), %rsi
movq %r14, %rdi
callq 0x31db3
movq %rax, 0x18(%rsp)
movq %r15, %rdi
movq %rax, %rsi
callq 0xf1ba
movq %r13, %rdi
callq 0x24ab1
movl 0x8(%rsp), %edx
movl %ebx, %ecx
cmpl %edx, %ebx
jl 0xc9ac
movq 0x50(%rsp), %rdi
callq 0x66e0
movslq 0x8(%rsp), %rax
movq 0x10(%rsp), %r14
addq %rax, %r14
incl 0x24(%rsp)
movq %r15, %rbx
leaq 0x50(%rsp), %r15
jmp 0xca24
leaq 0x81017(%rip), %rdi     # 0x8da2c
movq %r14, %rsi
xorl %eax, %eax
callq 0x26b6f
movq 0x10(%rsp), %r14
movabsq $0x100000000, %rax      # imm = 0x100000000
cmpq %rax, %r14
jl 0xca41
leaq 0x8100c(%rip), %rdi     # 0x8da46
xorl %eax, %eax
callq 0x26b6f
incq %r12
cmpq 0x40(%rsp), %r12
jne 0xc8b7
jmp 0xca5e
movl $0x0, 0x24(%rsp)
movq 0x28(%rsp), %rbx
movq %rbx, %rdi
callq 0xce4f
movslq 0x14(%rbx), %rax
testq %rax, %rax
movl 0x3c(%rsp), %ebp
jle 0xca8f
movq 0x38(%rbx), %rcx
movl (%rbx), %edx
xorl %esi, %esi
cmpl %edx, (%rcx,%rsi,4)
jae 0xca87
movl $0x0, (%rcx,%rsi,4)
incq %rsi
cmpq %rsi, %rax
jne 0xca7b
movslq 0x24(%rsp), %rbx
leaq (,%rbx,8), %rax
leaq (%rax,%rax,4), %rdi
callq 0x2db04
movq %rax, %r15
movq 0x28(%rsp), %rax
movq %r15, 0x20(%rax)
movq 0x28(%rsp), %rax
movl %ebx, 0x1c(%rax)
movq 0x28(%rsp), %rbx
testl %ebp, %ebp
jle 0xcc86
leaq 0x85efc(%rip), %rbp     # 0x929c9
leaq 0x50(%rsp), %r14
leaq 0x8(%rsp), %r12
xorl %ecx, %ecx
xorl %r13d, %r13d
movq 0x48(%rsp), %rax
movq %rcx, 0x30(%rsp)
movq (%rax,%rcx,8), %rdi
movq %rdi, 0x10(%rsp)
callq 0x3221b
testl %eax, %eax
je 0xcbba
movl 0xc(%rbx), %ebp
leaq 0x8111e(%rip), %rdi     # 0x8dc24
movq 0x10(%rsp), %rbx
movq %rbx, %rsi
xorl %eax, %eax
callq 0x6070
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x3185d
movl 0x8(%rsp), %edx
testl %edx, %edx
movq 0x28(%rsp), %r14
jle 0xcb82
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 0x10(%rsp), %rdi
movl %r12d, %ecx
callq 0x31db3
movq %rax, 0x18(%rsp)
addl %r13d, %r12d
movq %r14, %rdi
movq %rax, %rsi
movl %r12d, %edx
callq 0xcec9
leaq 0x18(%rsp), %rdi
callq 0x24ab1
movl 0x8(%rsp), %edx
movl %ebx, %r12d
cmpl %edx, %ebx
jl 0xcb36
movq 0x50(%rsp), %rdi
callq 0x66e0
movl 0x8(%rsp), %eax
addl %r13d, %eax
movq 0x10(%rsp), %rcx
movq %rcx, 0x8(%r15)
movl %r13d, 0x18(%r15)
movl %eax, 0x1c(%r15)
addq $0x28, %r15
movl %eax, %r13d
movq %r14, %rbx
leaq 0x85e14(%rip), %rbp     # 0x929c9
jmp 0xcc67
movq 0x10(%rsp), %rdi
callq 0x3e08d
movq %rax, 0x18(%rsp)
movq 0x28(%rax), %r12
testq %r12, %r12
je 0xcc58
leaq 0x50(%rsp), %r14
movq 0x28(%rsp), %rbx
movq 0x18(%rsp), %rdi
movq 0x8(%r12), %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x3e8a7
movq %rax, 0x8(%rsp)
movq %rbx, %rdi
movq %rax, %rsi
movl %r13d, %edx
callq 0xcec9
movq 0x8(%r12), %r8
movq %r14, %rdi
movl $0x300, %esi            # imm = 0x300
movq %rbp, %rdx
movq 0x10(%rsp), %rcx
xorl %eax, %eax
callq 0x23c18
movq %r14, %rdi
callq 0x1f9f6
movq %rax, 0x8(%r15)
movl %r13d, 0x18(%r15)
movq 0x8(%rsp), %rax
addl 0x18(%rax), %r13d
movl %r13d, 0x1c(%r15)
addq $0x28, %r15
leaq 0x8(%rsp), %rdi
callq 0x24ab1
movq (%r12), %r12
testq %r12, %r12
jne 0xcbe0
jmp 0xcc5d
movq 0x28(%rsp), %rbx
leaq 0x18(%rsp), %rdi
callq 0x3df96
movq 0x30(%rsp), %rcx
incq %rcx
cmpq 0x40(%rsp), %rcx
leaq 0x50(%rsp), %r14
leaq 0x8(%rsp), %r12
jne 0xcadc
jmp 0xcc89
xorl %r13d, %r13d
movl %r13d, 0x30(%rbx)
movslq 0x14(%rbx), %rax
testq %rax, %rax
jle 0xccb2
movq 0x38(%rbx), %rcx
movl (%rbx), %edx
xorl %esi, %esi
cmpl %edx, (%rcx,%rsi,4)
jb 0xccaa
movl $0x0, (%rcx,%rsi,4)
incq %rsi
cmpq %rsi, %rax
jne 0xcc9e
leaq 0x810ad(%rip), %rdi     # 0x8dd66
callq 0x6bb0
movq %rbx, %rax
addq $0x358, %rsp            # imm = 0x358
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq