// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/jkOwnLib/genoFind.c
// Function: gfSegmentedFindNearHits
static struct gfHit *gfSegmentedFindNearHits(struct genoFind *gf, 
	aaSeq *seq, Bits *qMaskBits, int qMaskOffset, struct lm *lm, int *retHitCount,
	struct gfSeqSource *target, int tMin, int tMax)
/* Find hits associated with one sequence in a segmented
 * index where one mismatch is allowed. */
{
struct gfHit *hitList = NULL, *hit;
int size = seq->size;
int tileSize = gf->tileSize;
int tileTailSize = gf->segSize;
int tileHeadSize = gf->tileSize - tileTailSize;
int lastStart = size - tileSize;
char *poly = seq->dna;
int i, j;
int tileHead, tileTail;
int listSize;
bits32 qStart;
bits16 *endList;
int hitCount = 0;
int varPos, varVal;	/* Variable position. */
int (*makeTile)(char *poly, int n); 
int alphabetSize;
char oldChar, zeroChar;
int headPosMul, tailPosMul, avoid;
boolean modTail;
int *seqValLookup;


initNtLookup();
if (gf->isPep)
    {
    makeTile = gfPepTile;
    alphabetSize = 20;
    zeroChar = 'A';
    seqValLookup = aaVal;
    }
else
    {
    makeTile = gfDnaTile;
    alphabetSize = 4;
    zeroChar = 't';
    seqValLookup = ntVal;
    }

for (i=0; i<=lastStart; ++i)
    {
    if (qMaskBits == NULL || bitCountRange(qMaskBits, i+qMaskOffset, tileSize) == 0)
	{
	headPosMul = tailPosMul = 1;
	for (varPos = tileSize-1; varPos >= 0; --varPos)
	    {
	    /* Make a tile that has zero value at variable position. */
	    modTail = (varPos >= tileHeadSize);
	    oldChar = poly[i+varPos];
	    poly[i+varPos] = zeroChar;
	    tileHead = makeTile(poly+i, tileHeadSize);
	    tileTail = makeTile(poly+i+tileHeadSize, tileTailSize);
	    poly[i+varPos] = oldChar;

	    /* Avoid checking the unmodified tile multiple times. */
	    if (varPos == 0)
		avoid = -1;
	    else
		avoid = seqValLookup[(int)oldChar];

	    if (tileHead >= 0 && tileTail >= 0)
		{
		for (varVal=0; varVal<alphabetSize; ++varVal)
		    {
		    if (varVal != avoid)
			{
			listSize = gf->listSizes[tileHead];
			qStart = i;
			endList = gf->endLists[tileHead];
			for (j=0; j<listSize; ++j)
			    {
			    if (endList[0] == tileTail)
				{
				int tStart = (endList[1]<<16) + endList[2];
				if (target == NULL || 
					(target == findSource(gf, tStart) 
					&& tStart >= tMin && tStart < tMax) ) 
				    {
				    lmAllocVar(lm,hit);
				    hit->qStart = qStart;
				    hit->tStart = tStart;
				    hit->diagonal = tStart + size - qStart;
				    slAddHead(&hitList, hit);
				    ++hitCount;
				    }
				}
			    endList += 3;
			    }
			}
		    if (modTail)
			tileTail += tailPosMul;
		    else 
			tileHead += headPosMul;
		    }
		}
	    if (modTail)
		tailPosMul *= alphabetSize;
	    else 
		headPosMul *= alphabetSize;
	    }
	}
    }
*retHitCount = hitCount;
return hitList;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movl 0x20(%rbp), %eax
movl 0x18(%rbp), %eax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x44(%rbp)
movq -0x8(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x48(%rbp)
movq -0x8(%rbp), %rax
movl 0x2c(%rax), %eax
movl %eax, -0x4c(%rbp)
movq -0x8(%rbp), %rax
movl 0xc(%rax), %eax
subl -0x4c(%rbp), %eax
movl %eax, -0x50(%rbp)
movl -0x44(%rbp), %eax
subl -0x48(%rbp), %eax
movl %eax, -0x54(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x60(%rbp)
movl $0x0, -0x84(%rbp)
callq 0xfde0
movq -0x8(%rbp), %rax
cmpb $0x0, 0x28(%rax)
je 0x1092c
leaq -0x3c34(%rip), %rax     # 0xccd0
movq %rax, -0x98(%rbp)
movl $0x14, -0x9c(%rbp)
movb $0x41, -0x9e(%rbp)
leaq 0xf8cad(%rip), %rax     # 0x1095d0
movq %rax, -0xb8(%rbp)
jmp 0x10959
leaq -0x3ce3(%rip), %rax     # 0xcc50
movq %rax, -0x98(%rbp)
movl $0x4, -0x9c(%rbp)
movb $0x74, -0x9e(%rbp)
leaq 0xf6f4e(%rip), %rax     # 0x1078a0
movq %rax, -0xb8(%rbp)
movl $0x0, -0x64(%rbp)
movl -0x64(%rbp), %eax
cmpl -0x54(%rbp), %eax
jg 0x10c83
cmpq $0x0, -0x18(%rbp)
je 0x1098e
movq -0x18(%rbp), %rdi
movl -0x64(%rbp), %esi
addl -0x1c(%rbp), %esi
movl -0x48(%rbp), %edx
callq 0x23e00
cmpl $0x0, %eax
jne 0x10c73
movl $0x1, -0xa8(%rbp)
movl $0x1, -0xa4(%rbp)
movl -0x48(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x88(%rbp)
cmpl $0x0, -0x88(%rbp)
jl 0x10c71
movl -0x88(%rbp), %eax
cmpl -0x50(%rbp), %eax
setge %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0xb0(%rbp)
movq -0x60(%rbp), %rax
movl -0x64(%rbp), %ecx
addl -0x88(%rbp), %ecx
movslq %ecx, %rcx
movb (%rax,%rcx), %al
movb %al, -0x9d(%rbp)
movb -0x9e(%rbp), %dl
movq -0x60(%rbp), %rax
movl -0x64(%rbp), %ecx
addl -0x88(%rbp), %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movq -0x98(%rbp), %rax
movq -0x60(%rbp), %rdi
movslq -0x64(%rbp), %rcx
addq %rcx, %rdi
movl -0x50(%rbp), %esi
callq *%rax
movl %eax, -0x6c(%rbp)
movq -0x98(%rbp), %rax
movq -0x60(%rbp), %rdi
movslq -0x64(%rbp), %rcx
addq %rcx, %rdi
movslq -0x50(%rbp), %rcx
addq %rcx, %rdi
movl -0x4c(%rbp), %esi
callq *%rax
movl %eax, -0x70(%rbp)
movb -0x9d(%rbp), %dl
movq -0x60(%rbp), %rax
movl -0x64(%rbp), %ecx
addl -0x88(%rbp), %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
cmpl $0x0, -0x88(%rbp)
jne 0x10a6d
movl $0xffffffff, -0xac(%rbp) # imm = 0xFFFFFFFF
jmp 0x10a87
movq -0xb8(%rbp), %rax
movsbl -0x9d(%rbp), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0xac(%rbp)
cmpl $0x0, -0x6c(%rbp)
jl 0x10c2a
cmpl $0x0, -0x70(%rbp)
jl 0x10c2a
movl $0x0, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
cmpl -0x9c(%rbp), %eax
jge 0x10c28
movl -0x8c(%rbp), %eax
cmpl -0xac(%rbp), %eax
je 0x10bef
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x6c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x74(%rbp)
movl -0x64(%rbp), %eax
movl %eax, -0x78(%rbp)
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rax
movslq -0x6c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x80(%rbp)
movl $0x0, -0x68(%rbp)
movl -0x68(%rbp), %eax
cmpl -0x74(%rbp), %eax
jge 0x10bed
movq -0x80(%rbp), %rax
movzwl (%rax), %eax
cmpl -0x70(%rbp), %eax
jne 0x10bd3
movq -0x80(%rbp), %rax
movzwl 0x2(%rax), %eax
shll $0x10, %eax
movq -0x80(%rbp), %rcx
movzwl 0x4(%rcx), %ecx
addl %ecx, %eax
movl %eax, -0xbc(%rbp)
cmpq $0x0, 0x10(%rbp)
je 0x10b79
movq 0x10(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0x8(%rbp), %rdi
movl -0xbc(%rbp), %esi
callq 0x10f20
movq %rax, %rcx
movq -0xc8(%rbp), %rax
cmpq %rcx, %rax
jne 0x10bd1
movl -0xbc(%rbp), %eax
cmpl 0x18(%rbp), %eax
jl 0x10bd1
movl -0xbc(%rbp), %eax
cmpl 0x20(%rbp), %eax
jge 0x10bd1
movq -0x28(%rbp), %rdi
movl $0x18, %esi
callq 0x3de60
movq %rax, -0x40(%rbp)
movl -0x78(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x8(%rax)
movl -0xbc(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0xc(%rax)
movl -0xbc(%rbp), %ecx
addl -0x44(%rbp), %ecx
subl -0x78(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x40(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x10f80
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0x10bd3
movq -0x80(%rbp), %rax
addq $0x6, %rax
movq %rax, -0x80(%rbp)
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0x10afc
jmp 0x10bef
cmpl $0x0, -0xb0(%rbp)
je 0x10c06
movl -0xa8(%rbp), %eax
addl -0x70(%rbp), %eax
movl %eax, -0x70(%rbp)
jmp 0x10c12
movl -0xa4(%rbp), %eax
addl -0x6c(%rbp), %eax
movl %eax, -0x6c(%rbp)
jmp 0x10c14
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0x10aa5
jmp 0x10c2a
cmpl $0x0, -0xb0(%rbp)
je 0x10c48
movl -0x9c(%rbp), %eax
imull -0xa8(%rbp), %eax
movl %eax, -0xa8(%rbp)
jmp 0x10c5b
movl -0x9c(%rbp), %eax
imull -0xa4(%rbp), %eax
movl %eax, -0xa4(%rbp)
jmp 0x10c5d
movl -0x88(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x88(%rbp)
jmp 0x109ae
jmp 0x10c73
jmp 0x10c75
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x10960
movl -0x84(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
movq -0x38(%rbp), %rax
addq $0xd0, %rsp
popq %rbp
retq
nopl (%rax)