// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/jkOwnLib/patSpace.c
// Function: addToPatSpace
static int addToPatSpace(struct patSpace *ps, int bacIx, int seqIx, struct dnaSeq *seq,int startBlock)
/* Add contents of one sequence to pattern space. Returns end block. */
{
int size = seq->size;
int mask = ps->seedSpaceSize-1;
DNA *dna = seq->dna;
int i;
int bits = 0;
int bVal;
int blockMod = blockSize;
int curCount;
psBits maxPat = ps->maxPat;
psBits *listSizes = ps->listSizes;
psBits **lists = ps->lists;
struct blockPos *bp = &ps->blockPos[startBlock];

bp->bacIx = bacIx;
bp->seqIx = seqIx;
bp->seq = seq;
bp->offset = 0;
fixBlockSize(bp, startBlock);
++bp;
for (i=0; i<ps->seedSize-1; ++i)
    {
    bVal = ntValNoN[(int)dna[i]];
    bits <<= 2;
    bits += bVal;
    }
for (i=ps->seedSize-1; i<size; ++i)
    {
    bVal = ntValNoN[(int)dna[i]];
    bits <<= 2;
    bits += bVal;
    bits &= mask;
    if ((curCount = listSizes[bits]) < maxPat)
        {
        listSizes[bits] = curCount+1;
        lists[bits][curCount] = startBlock;
        }
    if (--blockMod == 0)
        {
        if (++startBlock >= maxBlockCount)
	    tooManyBlocks();
        blockMod = blockSize;
	bp->bacIx = bacIx;
	bp->seqIx = seqIx;
	bp->seq = seq;
	bp->offset = i - (ps->seedSize-1) + 1;
	fixBlockSize(bp, startBlock);
	++bp;
        }
    }
for (i=0; i<ps->seedSize-1; ++i)
    {
    if (--blockMod == 0)
        {
        if (++startBlock >= maxBlockCount)
	    tooManyBlocks();
        blockMod = blockSize;
        }
    }
if (blockMod != blockSize)
    ++startBlock;
return startBlock;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
movq -0x18(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movl 0xe60010(%rax), %eax
subl $0x1, %eax
movl %eax, -0x24(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x38(%rbp)
movl $0x100, -0x40(%rbp)     # imm = 0x100
movq -0x8(%rbp), %rax
movl 0xe60000(%rax), %eax
movl %eax, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rax
addq $0x398018, %rax         # imm = 0x398018
movslq -0x1c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x60(%rbp)
movl -0xc(%rbp), %eax
movw %ax, %cx
movq -0x60(%rbp), %rax
movw %cx, (%rax)
movl -0x10(%rbp), %eax
movw %ax, %cx
movq -0x60(%rbp), %rax
movw %cx, 0x2(%rax)
movq -0x18(%rbp), %rcx
movq -0x60(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x60(%rbp), %rax
movl $0x0, 0x10(%rax)
movq -0x60(%rbp), %rdi
movl -0x1c(%rbp), %esi
callq 0x1f950
movq -0x60(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x60(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x8(%rbp), %rcx
movl 0xe6000c(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x1f329
movq -0x30(%rbp), %rax
movslq -0x34(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movslq %eax, %rcx
leaq 0xe8daa(%rip), %rax     # 0x1080b0
movl (%rax,%rcx,4), %eax
movl %eax, -0x3c(%rbp)
movl -0x38(%rbp), %eax
shll $0x2, %eax
movl %eax, -0x38(%rbp)
movl -0x3c(%rbp), %eax
addl -0x38(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x1f2dc
movq -0x8(%rbp), %rax
movl 0xe6000c(%rax), %eax
subl $0x1, %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x1f44b
movq -0x30(%rbp), %rax
movslq -0x34(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movslq %eax, %rcx
leaq 0xe8d55(%rip), %rax     # 0x1080b0
movl (%rax,%rcx,4), %eax
movl %eax, -0x3c(%rbp)
movl -0x38(%rbp), %eax
shll $0x2, %eax
movl %eax, -0x38(%rbp)
movl -0x3c(%rbp), %eax
addl -0x38(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0x24(%rbp), %eax
andl -0x38(%rbp), %eax
movl %eax, -0x38(%rbp)
movq -0x50(%rbp), %rax
movslq -0x38(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x44(%rbp)
cmpl -0x48(%rbp), %eax
jae 0x1f3b6
movl -0x44(%rbp), %edx
addl $0x1, %edx
movq -0x50(%rbp), %rax
movslq -0x38(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x1c(%rbp), %edx
movq -0x58(%rbp), %rax
movslq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x44(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x40(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x40(%rbp)
cmpl $0x0, %eax
jne 0x1f43b
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
cmpl $0x72fff, %eax          # imm = 0x72FFF
jl 0x1f3d9
callq 0x1ecf0
movl $0x100, -0x40(%rbp)     # imm = 0x100
movl -0xc(%rbp), %eax
movw %ax, %cx
movq -0x60(%rbp), %rax
movw %cx, (%rax)
movl -0x10(%rbp), %eax
movw %ax, %cx
movq -0x60(%rbp), %rax
movw %cx, 0x2(%rax)
movq -0x18(%rbp), %rcx
movq -0x60(%rbp), %rax
movq %rcx, 0x8(%rax)
movl -0x34(%rbp), %ecx
movq -0x8(%rbp), %rax
movl 0xe6000c(%rax), %eax
subl $0x1, %eax
subl %eax, %ecx
addl $0x1, %ecx
movq -0x60(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x60(%rbp), %rdi
movl -0x1c(%rbp), %esi
callq 0x1f950
movq -0x60(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x60(%rbp)
jmp 0x1f43d
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x1f339
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x8(%rbp), %rcx
movl 0xe6000c(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x1f49d
movl -0x40(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x40(%rbp)
cmpl $0x0, %eax
jne 0x1f490
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
cmpl $0x72fff, %eax          # imm = 0x72FFF
jl 0x1f489
callq 0x1ecf0
movl $0x100, -0x40(%rbp)     # imm = 0x100
jmp 0x1f492
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x1f452
cmpl $0x100, -0x40(%rbp)     # imm = 0x100
je 0x1f4af
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)