// File: /workspace/github_c_makefile_star2_O3/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, 0x8(%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 0x8(%rsp), %eax
subl 0x10(%rsp), %eax
js 0x18d11
movq (%rbx), %rcx
movq 0x8(%rbx), %rdx
movl 0xe6000c(%rbx), %edi
leaq 0xa8fbf(%rip), %rsi     # 0xc1c70
testl %edi, %edi
jle 0x18cdb
movl %edi, %r9d
xorl %r10d, %r10d
xorl %r8d, %r8d
movsbq (%r14,%r10), %r11
movslq (%rsi,%r11,4), %r11
shll $0x2, %r8d
movslq %r8d, %r8
addq %r11, %r8
incq %r10
cmpq %r10, %r9
jne 0x18cbe
jmp 0x18cde
xorl %r8d, %r8d
movl (%rdx,%r8,4), %r9d
testq %r9, %r9
je 0x18d04
movq (%rcx,%r8,8), %rdi
xorl %r8d, %r8d
movl (%rdi,%r8,4), %r10d
incl (%r15,%r10,4)
incq %r8
cmpq %r8, %r9
jne 0x18cee
movl 0xe6000c(%rbx), %edi
movslq %edi, %r8
addq %r8, %r14
addl %r8d, %ebp
cmpl %eax, %ebp
jle 0x18cb1
xorl %eax, %eax
cmpl $0x2, %r12d
jl 0x18f8a
decl %r12d
xorl %edx, %edx
xorl %ecx, %ecx
movl 0x1c(%rbx,%rdx,4), %edi
movl 0x20(%rbx,%rdx,4), %esi
leal (%rsi,%rdi), %r8d
cmpl %r13d, %r8d
jl 0x18d77
testl %edi, %edi
jle 0x18d60
testl %eax, %eax
je 0x18d4f
movslq %eax, %r8
movl 0x1cc014(%rbx,%r8,4), %r9d
cmpq %r9, %rdx
jne 0x18d52
jmp 0x18d60
xorl %r8d, %r8d
incl %eax
movl %edx, 0x1cc018(%rbx,%r8,4)
addl %ecx, %edi
movl %edi, %ecx
testl %esi, %esi
jle 0x18d77
movslq %eax, %rdi
incl %eax
leal 0x1(%rdx), %r8d
movl %r8d, 0x1cc018(%rbx,%rdi,4)
addl %esi, %ecx
incq %rdx
cmpq %rdx, %r12
jne 0x18d24
testl %eax, %eax
jle 0x18de5
imull 0xe6000c(%rbx), %ecx
shll $0x3, %ecx
cmpl 0x8(%rsp), %ecx
jle 0x18de5
movl 0x1cc018(%rbx), %ecx
cmpq $0x72fff, %rcx          # imm = 0x72FFF
jae 0x18f99
leaq (%rcx,%rcx,2), %rsi
movq 0x398018(%rbx,%rsi,8), %rdx
movq 0x398020(%rbx,%rsi,8), %r8
movl %edx, %ecx
shrl $0x10, %ecx
movl 0x398028(%rbx,%rsi,8), %r9d
movl 0x39802c(%rbx,%rsi,8), %r10d
cmpl $0x1, %eax
jne 0x18dec
movq $0x0, 0x8(%rsp)
movl %r9d, %ebp
jmp 0x18f1f
xorl %eax, %eax
jmp 0x18f8a
movl 0xe60008(%rbx), %esi
movl %esi, 0x14(%rsp)
leaq 0x398018(%rbx), %r11
movl %eax, %r14d
decq %r14
xorl %r15d, %r15d
movq $0x0, 0x8(%rsp)
movq %r8, %rax
movl %r9d, %esi
movl %r10d, %r12d
movq %r14, 0x20(%rsp)
movl 0x1cc01c(%rbx,%r15,4), %edi
cmpq $0x72fff, %rdi          # imm = 0x72FFF
jae 0x18f99
leaq (%rdi,%rdi,2), %rdi
movq 0x8(%r11,%rdi,8), %r13
movl 0x10(%r11,%rdi,8), %ebp
movl 0x14(%r11,%rdi,8), %r10d
addl %esi, %r12d
cmpq %rax, %r13
jne 0x18e5c
movl %ebp, %eax
subl %r12d, %eax
cmpl 0x14(%rsp), %eax
jle 0x18f0b
movl $0x80, %esi
addl %esi, %r12d
movl 0x18(%r8), %eax
cmpl %eax, %r12d
cmovgel %eax, %r12d
leaq (%r11,%rdi,8), %rax
cmpl $0x81, %r9d
cmovll %esi, %r9d
movq (%rax), %rax
movq %rax, 0x30(%rsp)
addl $-0x80, %r9d
movzwl %dx, %eax
movl %eax, 0x1c(%rsp)
movzwl %cx, %eax
movl %eax, 0x18(%rsp)
movl $0x20, %edi
movq %r8, 0x28(%rsp)
movl %ebp, 0x10(%rsp)
movl %r9d, %ebp
movl %r10d, %r14d
movq %r13, 0x38(%rsp)
movq %r11, %r13
callq 0x2dff4
movq %r13, %r11
movq 0x38(%rsp), %r13
movl %r14d, %r10d
movq 0x20(%rsp), %r14
movl 0x1c(%rsp), %ecx
movl %ecx, 0x8(%rax)
movl 0x18(%rsp), %ecx
movl %ecx, 0xc(%rax)
movq 0x28(%rsp), %rcx
movq %rcx, 0x10(%rax)
movl %ebp, 0x18(%rax)
subl %ebp, %r12d
movl 0x10(%rsp), %ebp
movl %r12d, 0x1c(%rax)
movq 0x8(%rsp), %rcx
movq %rcx, (%rax)
movq 0x30(%rsp), %rdx
movl %edx, %ecx
shrl $0x10, %ecx
movq %rax, 0x8(%rsp)
movl %ebp, %r9d
movq %r13, %r8
incq %r15
movq %r13, %rax
movl %ebp, %esi
movl %r10d, %r12d
cmpq %r15, %r14
jne 0x18e1d
addl %ebp, %r10d
movl $0x80, %ebx
addl %ebx, %r10d
movl 0x18(%r8), %eax
cmpl %eax, %r10d
cmovgel %eax, %r10d
cmpl $0x81, %r9d
cmovgel %r9d, %ebx
addl $-0x80, %ebx
movzwl %dx, %ebp
movzwl %cx, %r14d
movl $0x20, %edi
movq %r8, %r15
movl %r10d, %r12d
callq 0x2dff4
movl %ebp, 0x8(%rax)
movl %r14d, 0xc(%rax)
movq %r15, 0x10(%rax)
movl %ebx, 0x18(%rax)
subl %ebx, %r12d
movl %r12d, 0x1c(%rax)
movq 0x8(%rsp), %rcx
movq %rcx, (%rax)
leaq 0x40(%rsp), %rbx
movq %rax, (%rbx)
movq %rbx, %rdi
callq 0x20173
movq (%rbx), %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x75665(%rip), %rdi     # 0x8e605
leaq 0x75682(%rip), %rsi     # 0x8e629
leaq 0x7568f(%rip), %rcx     # 0x8e63d
movl $0x141, %edx            # imm = 0x141
callq 0x6460