// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/jkOwnLib/genoFind.c
// Function: clumpHits
static struct gfClump *clumpHits(struct genoFind *gf, struct gfHit *hitList, int minMatch)
/* Clump together hits according to parameters in gf. */
{
struct gfClump *clumpList = NULL, *clump = NULL;
int maxGap = gf->maxGap;
struct gfHit *hit, *nextHit, *lastHit = NULL;
int totalHits = 0, usedHits = 0, clumpCount = 0;
int tileSize = gf->tileSize;
int bucketShift = 16;		/* 64k buckets. */
bits32 bucketSize = (1<<bucketShift);
int bucketCount = (gf->totalSeqSize >> bucketShift) + 1;
int nearEnough = (gf->isPep ? gfNearEnough/3 : gfNearEnough);
bits32 boundary = bucketSize - nearEnough;
int i;
struct gfHit **buckets = NULL, **pb;

/* Sort hit list into buckets. */
AllocArray(buckets, bucketCount);
for (hit = hitList; hit != NULL; hit = nextHit)
    {
    nextHit = hit->next;
    pb = buckets + (hit->tStart >> bucketShift);
    slAddHead(pb, hit);
    }

/* Sort each bucket on diagonal and clump. */
for (i=0; i<bucketCount; ++i)
    {
    int clumpSize;
    bits32 maxT;
    struct gfHit *clumpHits;
    pb = buckets + i;
    gfHitSortDiagonal(pb);
    for (hit = *pb; hit != NULL; )
         {
	 /* Each time through this loop will get info on a clump.  Will only
	  * actually create clump if it is big enough though. */
	 clumpSize = 0;
	 clumpHits = lastHit = NULL;
	 maxT = 0;
	 for (; hit != NULL; hit = nextHit)
	     {
	     nextHit = hit->next;
	     if (lastHit != NULL && hit->diagonal - lastHit->diagonal > maxGap)
		 break;
	     if (hit->tStart > maxT) maxT = hit->tStart;
	     slAddHead(&clumpHits, hit);
	     ++clumpSize;
	     ++totalHits;
	     lastHit = hit;
	     }
	 if (maxT > boundary && i < bucketCount-1)
	     {
	     /* Move clumps that are near boundary to next bucket to give them a
	      * chance to merge with hits there. */
	     buckets[i+1] = slCat(clumpHits, buckets[i+1]);
	     }
	 else if (clumpSize >= minMatch)
	     {
	     /* Save clumps that are large enough on list. */
	     AllocVar(clump);
	     slAddHead(&clumpList, clump);
	     clump->hitCount = clumpSize;
	     clump->hitList = clumpHits;
	     usedHits += clumpSize;
	     ++clumpCount;
	     }
	 }
    *pb = NULL;
    boundary += bucketSize;
    }
clumpList = clumpNear(gf, clumpList, minMatch);
gfClumpComputeQueryCoverage(clumpList, tileSize);	/* Thanks AG */
slSort(&clumpList, gfClumpCmpQueryCoverage);

#ifdef DEBUG
uglyf("Dumping clumps B\n");
for (clump = clumpList; clump != NULL; clump = clump->next)	/* uglyf */
    {
    uglyf(" %d %d %s %d %d (%d hits)\n", clump->qStart, clump->qEnd, clump->target->seq->name,   clump->tStart, clump->tEnd, clump->hitCount);
    }
#endif /* DEBUG */
freez(&buckets);
return clumpList;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x8(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x2c(%rbp)
movq $0x0, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movl $0x0, -0x50(%rbp)
movl $0x0, -0x54(%rbp)
movq -0x8(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x58(%rbp)
movl $0x10, -0x5c(%rbp)
movl -0x5c(%rbp), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0x60(%rbp)
movq -0x8(%rbp), %rax
movl 0x30(%rax), %eax
movl -0x5c(%rbp), %ecx
shrl %cl, %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
movq -0x8(%rbp), %rax
movsbl 0x28(%rax), %eax
cmpl $0x0, %eax
je 0xed40
movl 0xf70b0(%rip), %eax     # 0x105de0
movl $0x3, %ecx
cltd
idivl %ecx
movl %eax, -0x94(%rbp)
jmp 0xed4c
movl 0xf709a(%rip), %eax     # 0x105de0
movl %eax, -0x94(%rbp)
movl -0x94(%rbp), %eax
movl %eax, -0x68(%rbp)
movl -0x60(%rbp), %eax
subl -0x68(%rbp), %eax
movl %eax, -0x6c(%rbp)
movq $0x0, -0x78(%rbp)
movslq -0x64(%rbp), %rdi
shlq $0x3, %rdi
callq 0x409d0
movq %rax, -0x78(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0xedc7
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x78(%rbp), %rax
movq -0x38(%rbp), %rcx
movl 0xc(%rcx), %edx
movl -0x5c(%rbp), %ecx
shrl %cl, %edx
movl %edx, %ecx
movl %ecx, %ecx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x10f80
movq -0x40(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0xed7f
movl $0x0, -0x70(%rbp)
movl -0x70(%rbp), %eax
cmpl -0x64(%rbp), %eax
jge 0xef89
movq -0x78(%rbp), %rax
movslq -0x70(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rdi
callq 0xe6e0
movq -0x80(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0xef67
movl $0x0, -0x84(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x90(%rbp)
movl $0x0, -0x88(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0xeebe
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0xee65
movq -0x38(%rbp), %rax
movl 0x10(%rax), %eax
movq -0x48(%rbp), %rcx
subl 0x10(%rcx), %eax
cmpl -0x2c(%rbp), %eax
jbe 0xee65
jmp 0xeebe
movq -0x38(%rbp), %rax
movl 0xc(%rax), %eax
cmpl -0x88(%rbp), %eax
jbe 0xee81
movq -0x38(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x88(%rbp)
movq -0x38(%rbp), %rsi
leaq -0x90(%rbp), %rdi
callq 0x10f80
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0xee33
movl -0x88(%rbp), %eax
cmpl -0x6c(%rbp), %eax
jbe 0xef09
movl -0x70(%rbp), %eax
movl -0x64(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0xef09
movq -0x90(%rbp), %rdi
movq -0x78(%rbp), %rax
movl -0x70(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
callq 0x2aa60
movq %rax, %rdx
movq -0x78(%rbp), %rax
movl -0x70(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0xef62
movl -0x84(%rbp), %eax
cmpl -0x14(%rbp), %eax
jl 0xef60
movl $0x38, %edi
callq 0x40c50
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rsi
leaq -0x20(%rbp), %rdi
callq 0x10f80
movl -0x84(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x90(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x28(%rax)
movl -0x84(%rbp), %eax
addl -0x50(%rbp), %eax
movl %eax, -0x50(%rbp)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0xef62
jmp 0xee01
movq -0x80(%rbp), %rax
movq $0x0, (%rax)
movl -0x60(%rbp), %eax
addl -0x6c(%rbp), %eax
movl %eax, -0x6c(%rbp)
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0xedce
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl -0x14(%rbp), %edx
callq 0x11020
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
movl -0x58(%rbp), %esi
callq 0x11220
leaq -0x20(%rbp), %rdi
leaq 0x236c(%rip), %rsi      # 0x11320
callq 0x2ab90
leaq -0x78(%rbp), %rdi
callq 0x40d70
movq -0x20(%rbp), %rax
addq $0xa0, %rsp
popq %rbp
retq
nop