// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/jkOwnLib/patSpace.c
// Function: patSpaceFindOne
struct patClump *patSpaceFindOne(struct patSpace *ps, DNA *dna, int dnaSize)
/* Find occurrences of DNA in patSpace. */
{
int lastStart = dnaSize - ps->seedSize;
int i,j;
int pat;
int hitBlockCount = 0;
int totalSigHits = 0;
DNA *tile = dna;
int blocksUsed = ps->blocksUsed;
int *posBuf = ps->posBuf;
int *hitBlocks = ps->hitBlocks;
int minMatch = ps->minMatch;

memset(ps->posBuf, 0, sizeof(ps->posBuf[0]) * blocksUsed);
for (i=0; i<=lastStart; i += ps->seedSize)
    {
    psBits *list;
    psBits count;

    pat = 0;
    for (j=0; j<ps->seedSize; ++j)
        {
        int bVal = ntValNoN[(int)tile[j]];
        pat <<= 2;
        pat += bVal;
        }
    list = ps->lists[pat];
    if ((count = ps->listSizes[pat]) > 0)
        {
        for (j=0; j<count; ++j)
            posBuf[list[j]] += 1;            
        }
    tile += ps->seedSize;
    }

/* Scan through array that records counts of hits at positions. */
for (i=0; i<blocksUsed-1; ++i)
    {
    /* Save significant hits in a more compact array */
    int a = posBuf[i], b = posBuf[i+1];
    int sum = a + b;
    if (sum >= minMatch)
        {
        if (a > 0)
            {
            if (hitBlockCount == 0 || hitBlocks[hitBlockCount-1] != i)
                {
                hitBlocks[hitBlockCount++] = i;
                totalSigHits += a;
                }
            }
        if (b > 0)
            {
            hitBlocks[hitBlockCount++] = i+1;
            totalSigHits += b;
            }
        }
    }

/* Output data with significant hits. */
if (hitBlockCount > 0 && totalSigHits*ps->seedSize*8 > dnaSize)
    {
    return clumpHits(ps, hitBlocks, hitBlockCount, posBuf, dna, 
        dnaSize);
    }        
else
    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x10(%rbp), %rcx
subl 0xe6000c(%rcx), %eax
movl %eax, -0x20(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x44(%rbp)
movq -0x10(%rbp), %rax
addq $0x1c, %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
addq $0x1cc018, %rax         # imm = 0x1CC018
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movl 0xe60004(%rax), %eax
movl %eax, -0x5c(%rbp)
movq -0x10(%rbp), %rdi
addq $0x1c, %rdi
movslq -0x44(%rbp), %rdx
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x63a0
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x20(%rbp), %eax
jg 0x1f6b8
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0xe6000c(%rcx), %eax
jge 0x1f62d
movq -0x40(%rbp), %rax
movslq -0x28(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movslq %eax, %rcx
leaq 0xe8aa6(%rip), %rax     # 0x1080b0
movl (%rax,%rcx,4), %eax
movl %eax, -0x70(%rbp)
movl -0x2c(%rbp), %eax
shll $0x2, %eax
movl %eax, -0x2c(%rbp)
movl -0x70(%rbp), %eax
addl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x1f5e5
movq -0x10(%rbp), %rax
movq (%rax), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x2c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x6c(%rbp)
cmpl $0x0, %eax
jbe 0x1f68b
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x6c(%rbp), %eax
jae 0x1f689
movq -0x50(%rbp), %rax
movq -0x68(%rbp), %rcx
movslq -0x28(%rbp), %rdx
movl (%rcx,%rdx,4), %ecx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x1f65e
jmp 0x1f68b
movq -0x10(%rbp), %rax
movl 0xe6000c(%rax), %ecx
movq -0x40(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movl 0xe6000c(%rax), %eax
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
jmp 0x1f5cb
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl -0x44(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x1f782
movq -0x50(%rbp), %rax
movslq -0x24(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x74(%rbp)
movq -0x50(%rbp), %rax
movl -0x24(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x78(%rbp)
movl -0x74(%rbp), %eax
addl -0x78(%rbp), %eax
movl %eax, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jl 0x1f772
cmpl $0x0, -0x74(%rbp)
jle 0x1f746
cmpl $0x0, -0x30(%rbp)
je 0x1f723
movq -0x58(%rbp), %rax
movl -0x30(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
cmpl -0x24(%rbp), %eax
je 0x1f744
movl -0x24(%rbp), %edx
movq -0x58(%rbp), %rax
movl -0x30(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x30(%rbp)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl -0x74(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
jmp 0x1f746
cmpl $0x0, -0x78(%rbp)
jle 0x1f770
movl -0x24(%rbp), %edx
addl $0x1, %edx
movq -0x58(%rbp), %rax
movl -0x30(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x30(%rbp)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl -0x78(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
jmp 0x1f772
jmp 0x1f774
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x1f6bf
cmpl $0x0, -0x30(%rbp)
jle 0x1f7c0
movl -0x34(%rbp), %eax
movq -0x10(%rbp), %rcx
imull 0xe6000c(%rcx), %eax
shll $0x3, %eax
cmpl -0x1c(%rbp), %eax
jle 0x1f7c0
movq -0x10(%rbp), %rdi
movq -0x58(%rbp), %rsi
movl -0x30(%rbp), %edx
movq -0x50(%rbp), %rcx
movq -0x18(%rbp), %r8
movl -0x1c(%rbp), %r9d
callq 0x1f7e0
movq %rax, -0x8(%rbp)
jmp 0x1f7c8
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)