// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/jkOwnLib/genoFind.c
// Function: gfMakeOoc
void gfMakeOoc(char *outName, char *files[], int fileCount, 
	int tileSize, bits32 maxPat, enum gfType tType)
/* Count occurences of tiles in seqList and make a .ooc file. */
{
boolean dbIsPep = (tType == gftProt || tType == gftDnaX || tType == gftRnaX);
struct genoFind *gf = gfNewEmpty(gfMinMatch, gfMaxGap, tileSize, tileSize,
	maxPat, NULL, dbIsPep, FALSE);
bits32 *sizes = gf->listSizes;
int tileSpaceSize = gf->tileSpaceSize;
bioSeq *seq, *seqList;
bits32 sig = oocSig, psz = tileSize;
bits32 i;
int oocCount = 0;
char *inName;
FILE *f = mustOpen(outName, "w");


unsigned faFastBufSize = 0;
DNA     *faFastBuf = NULL;


if (gf->segSize > 0)
    errAbort("Don't yet know how to make ooc files for large tile sizes.");
for (i=0; i<fileCount; ++i)
    {
    inName = files[i];
    printf("Loading %s\n", inName);
    if (nibIsFile(inName))
        {
	seqList = nibLoadAll(inName);
	}
    else if (twoBitIsFile(inName))
        {
	seqList = twoBitLoadAll(inName);
	for (seq = seqList; seq != NULL; seq = seq->next)
	    toLowerN(seq->dna, seq->size);
	}
    else
        {
	seqList = faReadAllSeq(inName, tType != gftProt, &faFastBuf, &faFastBufSize);
    faFreeFastBuf(&faFastBuf, &faFastBufSize);
	}
    printf("Counting %s\n", inName);
    for (seq = seqList; seq != NULL; seq = seq->next)
	{
	int isRc;
	for (isRc = 0; isRc <= 1; ++isRc)
	    {
	    if (tType == gftDnaX || tType == gftRnaX)
		{
		struct trans3 *t3 = trans3New(seq);
		int frame;
		for (frame=0; frame<3; ++frame)
		    {
		    gfCountSeq(gf, t3->trans[frame]);
		    }
		trans3Free(&t3);
		}
	    else
		{
		gfCountSeq(gf, seq);
		}
	    if (tType == gftProt || tType == gftRnaX)
	        break;
	    else 
	        {
		reverseComplement(seq->dna, seq->size);
		}
	    }
	}
    freeDnaSeqList(&seqList);
    }
printf("Writing %s\n", outName);
writeOne(f, sig);
writeOne(f, psz);
for (i=0; i<tileSpaceSize; ++i)
    {
    if (sizes[i] >= maxPat)
	{
	writeOne(f, i);
	++oocCount;
	}
    }
carefulClose(&f);
genoFindFree(&gf);
printf("Wrote %d overused %d-mers to %s\n", oocCount, tileSize, outName);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
movl %r9d, -0x20(%rbp)
movb $0x1, %al
cmpl $0x2, -0x20(%rbp)
movb %al, -0x95(%rbp)
je 0xf20a
movb $0x1, %al
cmpl $0x3, -0x20(%rbp)
movb %al, -0x95(%rbp)
je 0xf20a
cmpl $0x4, -0x20(%rbp)
sete %al
movb %al, -0x95(%rbp)
movb -0x95(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x24(%rbp)
movl -0x18(%rbp), %edx
movl -0x18(%rbp), %ecx
movl -0x1c(%rbp), %r8d
movl -0x24(%rbp), %eax
movl $0x2, %esi
xorl %edi, %edi
movl %edi, %r9d
xorl %edi, %edi
movl %esi, %edi
movl %eax, (%rsp)
movl $0x0, 0x8(%rsp)
callq 0xd0c0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0x3c(%rbp)
movl $0x584155f2, -0x54(%rbp) # imm = 0x584155F2
movl -0x18(%rbp), %eax
movl %eax, -0x58(%rbp)
movl $0x0, -0x60(%rbp)
movq -0x8(%rbp), %rdi
leaq 0xc98d2(%rip), %rsi     # 0xd8b4e
callq 0x2f780
movq %rax, -0x70(%rbp)
movl $0x0, -0x74(%rbp)
movq $0x0, -0x80(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, 0x2c(%rax)
jle 0xf2ac
leaq 0xc880a(%rip), %rdi     # 0xd7aaf
movb $0x0, %al
callq 0x35d40
movl $0x0, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jae 0xf48f
movq -0x10(%rbp), %rax
movl -0x5c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rsi
leaq 0xc8811(%rip), %rdi     # 0xd7aea
movb $0x0, %al
callq 0x6070
movq -0x68(%rbp), %rdi
callq 0x472b0
cmpl $0x0, %eax
je 0xf2fd
movq -0x68(%rbp), %rdi
callq 0x46de0
movq %rax, -0x50(%rbp)
jmp 0xf37a
movq -0x68(%rbp), %rdi
callq 0x5aa00
cmpl $0x0, %eax
je 0xf34a
movq -0x68(%rbp), %rdi
callq 0x5a650
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0xf348
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x48(%rbp), %rax
movl 0x18(%rax), %esi
callq 0x2dc90
movq -0x48(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
jmp 0xf320
jmp 0xf378
movq -0x68(%rbp), %rdi
cmpl $0x2, -0x20(%rbp)
setne %al
andb $0x1, %al
movzbl %al, %esi
leaq -0x80(%rbp), %rdx
leaq -0x74(%rbp), %rcx
callq 0x37820
movq %rax, -0x50(%rbp)
leaq -0x80(%rbp), %rdi
leaq -0x74(%rbp), %rsi
callq 0x36da0
jmp 0xf37a
movq -0x68(%rbp), %rsi
leaq 0xc86f7(%rip), %rdi     # 0xd7a7c
movb $0x0, %al
callq 0x6070
movq -0x50(%rbp), %rax
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0xf478
movl $0x0, -0x84(%rbp)
cmpl $0x1, -0x84(%rbp)
jg 0xf466
cmpl $0x3, -0x20(%rbp)
je 0xf3c2
cmpl $0x4, -0x20(%rbp)
jne 0xf420
movq -0x48(%rbp), %rdi
callq 0x1a4b0
movq %rax, -0x90(%rbp)
movl $0x0, -0x94(%rbp)
cmpl $0x3, -0x94(%rbp)
jge 0xf412
movq -0x30(%rbp), %rdi
movq -0x90(%rbp), %rax
movslq -0x94(%rbp), %rcx
movq 0x18(%rax,%rcx,8), %rsi
callq 0xf540
movl -0x94(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x94(%rbp)
jmp 0xf3dc
leaq -0x90(%rbp), %rdi
callq 0x1a560
jmp 0xf42d
movq -0x30(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0xf540
cmpl $0x2, -0x20(%rbp)
je 0xf439
cmpl $0x4, -0x20(%rbp)
jne 0xf43b
jmp 0xf466
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x48(%rbp), %rax
movslq 0x18(%rax), %rsi
callq 0x33300
jmp 0xf452
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0xf3a9
jmp 0xf468
movq -0x48(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
jmp 0xf394
leaq -0x50(%rbp), %rdi
callq 0x32850
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0xf2b3
movq -0x8(%rbp), %rsi
leaq 0xc865c(%rip), %rdi     # 0xd7af6
movb $0x0, %al
callq 0x6070
movq -0x70(%rbp), %rdi
leaq -0x54(%rbp), %rsi
movl $0x4, %edx
callq 0x2f8b0
movq -0x70(%rbp), %rdi
leaq -0x58(%rbp), %rsi
movl $0x4, %edx
callq 0x2f8b0
movl $0x0, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jae 0xf50b
movq -0x38(%rbp), %rax
movl -0x5c(%rbp), %ecx
movl (%rax,%rcx,4), %eax
cmpl -0x1c(%rbp), %eax
jb 0xf4fe
movq -0x70(%rbp), %rdi
leaq -0x5c(%rbp), %rsi
movl $0x4, %edx
callq 0x2f8b0
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0xf500
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0xf4cc
leaq -0x70(%rbp), %rdi
callq 0x301d0
leaq -0x30(%rbp), %rdi
callq 0xcb10
movl -0x60(%rbp), %esi
movl -0x18(%rbp), %edx
movq -0x8(%rbp), %rcx
leaq 0xc85d4(%rip), %rdi     # 0xd7b02
movb $0x0, %al
callq 0x6070
addq $0xb0, %rsp
popq %rbp
retq
nop