// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %edx, 0xc(%rsp)
movq %rsi, %r14
movq %rdi, %rbx
movslq 0x18(%rdi), %r12
leaq 0x1c(%rdi), %r15
movl 0xe60004(%rdi), %r13d
leaq (,%r12,4), %rdx
movl 0xe6000c(%rdi), %eax
movl %eax, 0x10(%rsp)
xorl %ebp, %ebp
movq %r15, %rdi
xorl %esi, %esi
callq 0x63b0
movl 0xc(%rsp), %r11d
movl %r11d, %eax
subl 0x10(%rsp), %eax
js 0x18b8b
movq (%rbx), %rcx
movq 0x8(%rbx), %rdx
leaq 0xa9144(%rip), %rsi     # 0xc1c70
movslq 0xe6000c(%rbx), %r8
testq %r8, %r8
jle 0x18b59
xorl %r9d, %r9d
xorl %edi, %edi
movsbq (%r14,%r9), %r10
movslq (%rsi,%r10,4), %r10
shll $0x2, %edi
movslq %edi, %rdi
addq %r10, %rdi
incq %r9
cmpq %r9, %r8
jne 0x18b3d
jmp 0x18b5b
xorl %edi, %edi
movl (%rdx,%rdi,4), %r8d
testq %r8, %r8
je 0x18b7b
movq (%rcx,%rdi,8), %rdi
xorl %r9d, %r9d
movl (%rdi,%r9,4), %r10d
incl (%r15,%r10,4)
incq %r9
cmpq %r9, %r8
jne 0x18b6b
movslq 0xe6000c(%rbx), %rdi
addq %rdi, %r14
addl %edi, %ebp
cmpl %eax, %ebp
jle 0x18b2c
xorl %eax, %eax
movl $0x0, %edx
cmpl $0x2, %r12d
jl 0x18bfc
decl %r12d
xorl %ecx, %ecx
xorl %edx, %edx
xorl %eax, %eax
movl 0x1c(%rbx,%rcx,4), %edi
movl 0x20(%rbx,%rcx,4), %esi
leal (%rsi,%rdi), %r8d
cmpl %r13d, %r8d
jl 0x18bf1
testl %edi, %edi
jle 0x18bda
movslq %edx, %r8
testl %edx, %edx
je 0x18bca
movl 0x1cc014(%rbx,%r8,4), %r9d
cmpq %r9, %rcx
je 0x18bda
leal 0x1(%r8), %edx
movl %ecx, 0x1cc018(%rbx,%r8,4)
addl %eax, %edi
movl %edi, %eax
testl %esi, %esi
jle 0x18bf1
movslq %edx, %rdi
incl %edx
leal 0x1(%rcx), %r8d
movl %r8d, 0x1cc018(%rbx,%rdi,4)
addl %esi, %eax
incq %rcx
cmpq %rcx, %r12
jne 0x18ba1
shll $0x3, %eax
testl %edx, %edx
jle 0x18c6f
imull 0xe6000c(%rbx), %eax
cmpl %r11d, %eax
jle 0x18c6f
movl 0xe60008(%rbx), %eax
movl %eax, 0x24(%rsp)
movq $0x0, 0x18(%rsp)
movl 0x1cc018(%rbx), %eax
cmpq $0x72fff, %rax          # imm = 0x72FFF
jae 0x18dfd
leaq (%rax,%rax,2), %r8
movq 0x398018(%rbx,%r8,8), %rcx
movq 0x398020(%rbx,%r8,8), %rdi
movl %ecx, %eax
shrl $0x10, %eax
movl 0x398028(%rbx,%r8,8), %esi
movl 0x39802c(%rbx,%r8,8), %r14d
cmpl $0x1, %edx
jne 0x18c76
movl %esi, %ebp
movq %rdi, %r15
movl %r14d, %r12d
movl %esi, %r10d
jmp 0x18d8d
xorl %eax, %eax
jmp 0x18dee
leaq 0x398018(%rbx), %r8
movq %r8, 0x40(%rsp)
movl %edx, %edx
decq %rdx
movq %rdx, 0x38(%rsp)
xorl %r13d, %r13d
movq %rdi, %r15
movl %esi, %ebp
movq %rbx, 0x30(%rsp)
movl 0x1cc01c(%rbx,%r13,4), %edx
cmpq $0x72fff, %rdx          # imm = 0x72FFF
jae 0x18dfd
leaq (%rdx,%rdx,2), %rdx
movq 0x40(%rsp), %r8
movq (%r8,%rdx,8), %rbx
movq 0x8(%r8,%rdx,8), %r11
movl 0x10(%r8,%rdx,8), %r10d
movl 0x14(%r8,%rdx,8), %r12d
cmpq %rdi, %r11
jne 0x18ce1
movl %r10d, %edi
subl %r14d, %edi
subl %esi, %edi
cmpl 0x24(%rsp), %edi
jle 0x18d71
addl %esi, %r14d
movl $0x80, %esi
addl %esi, %r14d
movl 0x18(%r15), %edx
cmpl %edx, %r14d
cmovgel %edx, %r14d
cmpl $0x81, %ebp
cmovll %esi, %ebp
addl $-0x80, %ebp
movl %r12d, 0xc(%rsp)
movzwl %cx, %ecx
movl %ecx, 0x2c(%rsp)
movq %r15, 0x10(%rsp)
movzwl %ax, %eax
movl %eax, 0x28(%rsp)
movl $0x20, %edi
movl %r10d, %r15d
movq %r11, %r12
callq 0x2dc95
movq %r12, %r11
movl %r15d, %r10d
movl 0x2c(%rsp), %ecx
movl %ecx, 0x8(%rax)
movl 0xc(%rsp), %r12d
movl 0x28(%rsp), %ecx
movl %ecx, 0xc(%rax)
movq 0x10(%rsp), %rcx
movq %rcx, 0x10(%rax)
movl %ebp, 0x18(%rax)
subl %ebp, %r14d
movl %r14d, 0x1c(%rax)
movq 0x18(%rsp), %rcx
movq %rcx, (%rax)
movq %rax, 0x18(%rsp)
movl %ebx, %eax
shrl $0x10, %eax
movl %r15d, %ebp
movq %r11, %r15
movl %ebx, %ecx
incq %r13
movq %r11, %rdi
movl %r10d, %esi
movl %r12d, %r14d
cmpq %r13, 0x38(%rsp)
movq 0x30(%rsp), %rbx
jne 0x18c99
addl %r10d, %r12d
movl $0x80, %ebx
addl %ebx, %r12d
movl 0x18(%r15), %edx
cmpl %edx, %r12d
cmovgel %edx, %r12d
cmpl $0x81, %ebp
cmovgel %ebp, %ebx
addl $-0x80, %ebx
movzwl %cx, %ebp
movzwl %ax, %r14d
movl $0x20, %edi
callq 0x2dc95
movl %ebp, 0x8(%rax)
movl %r14d, 0xc(%rax)
movq %r15, 0x10(%rax)
movl %ebx, 0x18(%rax)
subl %ebx, %r12d
movl %r12d, 0x1c(%rax)
leaq 0x18(%rsp), %rbx
movq (%rbx), %rcx
movq %rcx, (%rax)
movq %rax, (%rbx)
movq %rbx, %rdi
callq 0x1fcb3
movq (%rbx), %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x757c1(%rip), %rdi     # 0x8e5c5
leaq 0x757de(%rip), %rsi     # 0x8e5e9
leaq 0x757eb(%rip), %rcx     # 0x8e5fd
movl $0x141, %edx            # imm = 0x141
callq 0x6460