// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/lib/blastOut.c
// Function: ncbiBlastOut
static void ncbiBlastOut(struct axtBundle *abList, int queryIx, boolean isProt, 
	FILE *f, char *databaseName, int databaseSeqCount, 
	double databaseLetterCount, char *ourId, double minIdentity)
/* Do ncbiblast-like output at end of processing query. */
{
char asciiNum[32];
struct targetHits *targetList = NULL, *target;
char *queryName;
int querySize = abList->qSize;
boolean isTranslated = (abList->axtList->frame != 0);

/* Print out stuff that doesn't depend on query or database. */
if (ourId == NULL)
    ourId = "axtBlastOut";
fprintf(f, "%s 2.2.11 [%s]\n", progType(isProt, abList, TRUE), ourId);
fprintf(f, "\n");
fprintf(f, "Reference:  Kent, WJ. (2002) BLAT - The BLAST-like alignment tool\n");
fprintf(f, "\n");

/* Print query and database info. */
queryName = abList->axtList->qName;
fprintf(f, "Query= %s\n", queryName);
fprintf(f, "         (%d letters)\n", abList->qSize);
fprintf(f, "\n");
fprintf(f, "Database: %s \n",  databaseName);
sprintLongWithCommas(asciiNum, databaseLetterCount);
fprintf(f, "           %d sequences; %s total letters\n",  databaseSeqCount, asciiNum);
fprintf(f, "\n");
fprintf(f, "Searching.done\n");

targetList = bundleIntoTargets(abList);

/* Print out summary of hits. */
fprintf(f, "                                                                 Score    E\n");
fprintf(f, "Sequences producing significant alignments:                      (bits) Value\n");
fprintf(f, "\n");
for (target = targetList; target != NULL; target = target->next)
    {
    struct axtRef *ref;
    struct axt *axt;
    int matches;
    double identity, expectation;
    int bit;
    
    for (ref = target->axtList; ref != NULL; ref = ref->next)
	{
	axt = ref->axt;
	
	matches = countMatches(axt->qSym, axt->tSym, axt->symCount);
	identity = round(100.0 * matches / axt->symCount);
	/* skip output if minIdentity not reached */
	if (identity < minIdentity) continue;
    
    	bit = blastzScoreToNcbiBits(axt->score);
        expectation = blastzScoreToNcbiExpectation(axt->score);
    	fprintf(f, "%-67s  %4d   ", target->name, bit);
    	ncbiPrintE(f, expectation);
    	fprintf(f, "\n");
    	}
    }
fprintf(f, "\n");

/* Print out details on each target. */
for (target = targetList; target != NULL; target = target->next)
    {
    struct axtRef *ref;
    struct axt *axt;
    int matches, gaps;
    char *oldName;
    
    int ii = 0;
    double identity;
    oldName = strdup("");

    for (ref = target->axtList; ref != NULL; ref = ref->next)
	{
	ii++;
	axt = ref->axt;
	
	matches = countMatches(axt->qSym, axt->tSym, axt->symCount);
	identity = round(100.0 * matches / axt->symCount);
	
	/* skip output if minIdentity not reached */
	if (identity < minIdentity) continue;
        
	/* print target sequence name and length only once */ 
	if (!sameWord(oldName, target->name))
	    {
	    fprintf(f, "\n\n>%s \n", target->name);
	    fprintf(f, "          Length = %d\n", target->size);
	    oldName = strdup(target->name);
	    }

	fprintf(f, "\n");
	fprintf(f, " Score = %d bits (%d), Expect = ",
	     blastzScoreToNcbiBits(axt->score),
	     blastzScoreToNcbiScore(axt->score));
	ncbiPrintE(f, blastzScoreToNcbiExpectation(axt->score));
	fprintf(f, "\n");
	
	if (isProt)
	    {
	    int positives = countPositives(axt->qSym, axt->tSym, axt->symCount);
	    gaps = countGaps(axt->qSym, axt->tSym, axt->symCount);
	    fprintf(f, " Identities = %d/%d (%d%%),",
		 matches, axt->symCount, round(100.0 * matches / axt->symCount));
	    fprintf(f, " Positives = %d/%d (%d%%),",
		 positives, axt->symCount, round(100.0 * positives / axt->symCount));
	    fprintf(f, " Gaps = %d/%d (%d%%)\n",
		 gaps, axt->symCount, round(100.0 * gaps / axt->symCount));
	    if (axt->frame != 0) 
		fprintf(f, " Frame = %c%d\n", axt->tStrand, axt->frame);
	    /* set the special global variable, answer_for_kg.  
   	       This is needed for Known Genes track building.  Fan 1/21/03 */
            answer_for_kg=axt->symCount - matches;
	    }
	else
	    {
	    fprintf(f, " Identities = %d/%d (%d%%)\n",
		 matches, axt->symCount, round(100.0 * matches / axt->symCount));
	    /* blast displays dna searches as +- instead of blat's default -+ */
	    if (!isTranslated)
		if ((axt->qStrand == '-') && (axt->tStrand == '+'))
		    {
		    reverseIntRange(&axt->qStart, &axt->qEnd, querySize);
		    reverseIntRange(&axt->tStart, &axt->tEnd, target->size);
		    reverseComplement(axt->qSym, axt->symCount);
		    reverseComplement(axt->tSym, axt->symCount);
		    axt->qStrand = '+';
		    axt->tStrand = '-';
		    }
	    fprintf(f, " Strand = %s / %s\n", nameForStrand(axt->qStrand),
		nameForStrand(axt->tStrand));
	    }
	fprintf(f, "\n");
	blastiodAxtOutput(f, axt, target->size, querySize, 60, isProt, isTranslated);
	}
    }

fprintf(f, "  Database: %s\n", databaseName);

/* Cleanup time. */
targetHitsFreeList(&targetList);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
movsd %xmm0, -0x30(%rbp)
movsd %xmm1, -0x38(%rbp)
movq $0x0, -0x68(%rbp)
movq -0x8(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0x7c(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0x0, 0x50(%rax)
setne %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x80(%rbp)
cmpq $0x0, 0x10(%rbp)
jne 0x262ea
leaq 0xb29b7(%rip), %rax     # 0xd8c9d
movq %rax, 0x10(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0xf0(%rbp)
movl -0x10(%rbp), %edi
movq -0x8(%rbp), %rsi
movl $0x1, %edx
callq 0x26f10
movq -0xf0(%rbp), %rdi
movq %rax, %rdx
movq 0x10(%rbp), %rcx
leaq 0xb33ef(%rip), %rsi     # 0xd970a
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
leaq 0xb2cec(%rip), %rsi     # 0xd9019
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
leaq 0xb29b6(%rip), %rsi     # 0xd8cf5
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
leaq 0xb2cc8(%rip), %rsi     # 0xd9019
movb $0x0, %al
callq 0x6a80
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x18(%rbp), %rdi
movq -0x78(%rbp), %rdx
leaq 0xb33a3(%rip), %rsi     # 0xd971a
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x14(%rax), %edx
leaq 0xb3395(%rip), %rsi     # 0xd9725
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
leaq 0xb2c77(%rip), %rsi     # 0xd9019
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rdx
leaq 0xb3384(%rip), %rsi     # 0xd973c
movb $0x0, %al
callq 0x6a80
leaq -0x60(%rbp), %rdi
cvttsd2si -0x30(%rbp), %rsi
callq 0x48710
movq -0x18(%rbp), %rdi
movl -0x24(%rbp), %edx
leaq -0x60(%rbp), %rcx
leaq 0xb2a53(%rip), %rsi     # 0xd8e33
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
leaq 0xb2c27(%rip), %rsi     # 0xd9019
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
leaq 0xb3347(%rip), %rsi     # 0xd974b
movb $0x0, %al
callq 0x6a80
movq -0x8(%rbp), %rdi
callq 0x26f90
movq %rax, -0x68(%rbp)
movq -0x18(%rbp), %rdi
leaq 0xb3338(%rip), %rsi     # 0xd975b
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
leaq 0xb3373(%rip), %rsi     # 0xd97a8
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
leaq 0xb2bd2(%rip), %rsi     # 0xd9019
movb $0x0, %al
callq 0x6a80
movq -0x68(%rbp), %rax
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x70(%rbp)
je 0x265a7
movq -0x70(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x88(%rbp)
cmpq $0x0, -0x88(%rbp)
je 0x26595
movq -0x88(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x90(%rbp), %rax
movq 0x48(%rax), %rsi
movq -0x90(%rbp), %rax
movl 0x38(%rax), %edx
callq 0x27240
movl %eax, -0x94(%rbp)
cvtsi2sdl -0x94(%rbp), %xmm1
movsd 0xb1c4d(%rip), %xmm0    # 0xd8118
mulsd %xmm1, %xmm0
movq -0x90(%rbp), %rax
cvtsi2sdl 0x38(%rax), %xmm1
divsd %xmm1, %xmm0
movsd 0xb2751(%rip), %xmm1    # 0xd8c38
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0xa0(%rbp)
movsd -0xa0(%rbp), %xmm1
movsd -0x38(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x26510
jmp 0x2657f
movq -0x90(%rbp), %rax
movl 0x34(%rax), %edi
callq 0x27940
movl %eax, -0xac(%rbp)
movq -0x90(%rbp), %rax
movl 0x34(%rax), %edi
callq 0x279a0
movsd %xmm0, -0xa8(%rbp)
movq -0x18(%rbp), %rdi
movq -0x70(%rbp), %rax
movq 0x8(%rax), %rdx
movl -0xac(%rbp), %ecx
leaq 0xb32a2(%rip), %rsi     # 0xd97f7
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
movsd -0xa8(%rbp), %xmm0
callq 0x27a20
movq -0x18(%rbp), %rdi
leaq 0xb2aa1(%rip), %rsi     # 0xd9019
movb $0x0, %al
callq 0x6a80
movq -0x88(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x88(%rbp)
jmp 0x26470
jmp 0x26597
movq -0x70(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x70(%rbp)
jmp 0x26456
movq -0x18(%rbp), %rdi
leaq 0xb2a67(%rip), %rsi     # 0xd9019
movb $0x0, %al
callq 0x6a80
movq -0x68(%rbp), %rax
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x70(%rbp)
je 0x26b20
movl $0x0, -0xd4(%rbp)
leaq 0xbee29(%rip), %rdi     # 0xe5406
callq 0x6dd0
movq %rax, -0xd0(%rbp)
movq -0x70(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0xb8(%rbp)
cmpq $0x0, -0xb8(%rbp)
je 0x26b0e
movl -0xd4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xd4(%rbp)
movq -0xb8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0xc0(%rbp), %rax
movq 0x48(%rax), %rsi
movq -0xc0(%rbp), %rax
movl 0x38(%rax), %edx
callq 0x27240
movl %eax, -0xc4(%rbp)
cvtsi2sdl -0xc4(%rbp), %xmm1
movsd 0xb1ab6(%rip), %xmm0    # 0xd8118
mulsd %xmm1, %xmm0
movq -0xc0(%rbp), %rax
cvtsi2sdl 0x38(%rax), %xmm1
divsd %xmm1, %xmm0
movsd 0xb25ba(%rip), %xmm1    # 0xd8c38
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0xe0(%rbp)
movsd -0xe0(%rbp), %xmm1
movsd -0x38(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x266aa
jmp 0x26af8
movq -0xd0(%rbp), %rdi
movq -0x70(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x2b9f0
cmpl $0x0, %eax
je 0x2670a
movq -0x18(%rbp), %rdi
movq -0x70(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0xb312f(%rip), %rsi     # 0xd9805
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
movq -0x70(%rbp), %rax
movl 0x10(%rax), %edx
leaq 0xb311e(%rip), %rsi     # 0xd980d
movb $0x0, %al
callq 0x6a80
movq -0x70(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x6dd0
movq %rax, -0xd0(%rbp)
movq -0x18(%rbp), %rdi
leaq 0xb2904(%rip), %rsi     # 0xd9019
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0xc0(%rbp), %rax
movl 0x34(%rax), %edi
callq 0x27940
movl %eax, -0xfc(%rbp)
movq -0xc0(%rbp), %rax
movl 0x34(%rax), %edi
callq 0x27970
movq -0x108(%rbp), %rdi
movl -0xfc(%rbp), %edx
movl %eax, %ecx
leaq 0xb30c3(%rip), %rsi     # 0xd9824
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0xc0(%rbp), %rax
movl 0x34(%rax), %edi
callq 0x279a0
movq -0xf8(%rbp), %rdi
callq 0x27a20
movq -0x18(%rbp), %rdi
leaq 0xb2880(%rip), %rsi     # 0xd9019
movb $0x0, %al
callq 0x6a80
cmpl $0x0, -0x10(%rbp)
je 0x26954
movq -0xc0(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0xc0(%rbp), %rax
movq 0x48(%rax), %rsi
movq -0xc0(%rbp), %rax
movl 0x38(%rax), %edx
callq 0x272c0
movl %eax, -0xe4(%rbp)
movq -0xc0(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0xc0(%rbp), %rax
movq 0x48(%rax), %rsi
movq -0xc0(%rbp), %rax
movl 0x38(%rax), %edx
callq 0x27b00
movl %eax, -0xc8(%rbp)
movq -0x18(%rbp), %rdi
movl -0xc4(%rbp), %edx
movq -0xc0(%rbp), %rax
movl 0x38(%rax), %ecx
cvtsi2sdl -0xc4(%rbp), %xmm1
movsd 0xb18f4(%rip), %xmm0    # 0xd8118
mulsd %xmm1, %xmm0
movq -0xc0(%rbp), %rax
cvtsi2sdl 0x38(%rax), %xmm1
divsd %xmm1, %xmm0
movsd 0xb23f8(%rip), %xmm1    # 0xd8c38
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %r8d
leaq 0xb2ff5(%rip), %rsi     # 0xd9845
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
movl -0xe4(%rbp), %edx
movq -0xc0(%rbp), %rax
movl 0x38(%rax), %ecx
cvtsi2sdl -0xe4(%rbp), %xmm1
movsd 0xb189d(%rip), %xmm0    # 0xd8118
mulsd %xmm1, %xmm0
movq -0xc0(%rbp), %rax
cvtsi2sdl 0x38(%rax), %xmm1
divsd %xmm1, %xmm0
movsd 0xb23a1(%rip), %xmm1    # 0xd8c38
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %r8d
leaq 0xb2fba(%rip), %rsi     # 0xd9861
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
movl -0xc8(%rbp), %edx
movq -0xc0(%rbp), %rax
movl 0x38(%rax), %ecx
cvtsi2sdl -0xc8(%rbp), %xmm1
movsd 0xb1846(%rip), %xmm0    # 0xd8118
mulsd %xmm1, %xmm0
movq -0xc0(%rbp), %rax
cvtsi2sdl 0x38(%rax), %xmm1
divsd %xmm1, %xmm0
movsd 0xb234a(%rip), %xmm1    # 0xd8c38
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %r8d
leaq 0xb2f7e(%rip), %rsi     # 0xd987c
movb $0x0, %al
callq 0x6a80
movq -0xc0(%rbp), %rax
cmpl $0x0, 0x50(%rax)
je 0x26939
movq -0x18(%rbp), %rdi
movq -0xc0(%rbp), %rax
movsbl 0x30(%rax), %edx
movq -0xc0(%rbp), %rax
movl 0x50(%rax), %ecx
leaq 0xb2f60(%rip), %rsi     # 0xd9892
movb $0x0, %al
callq 0x6a80
movq -0xc0(%rbp), %rax
movl 0x38(%rax), %eax
subl -0xc4(%rbp), %eax
movl %eax, 0xe0f11(%rip)     # 0x107860
jmp 0x26abc
movq -0x18(%rbp), %rdi
movl -0xc4(%rbp), %edx
movq -0xc0(%rbp), %rax
movl 0x38(%rax), %ecx
cvtsi2sdl -0xc4(%rbp), %xmm1
movsd 0xb17a0(%rip), %xmm0    # 0xd8118
mulsd %xmm1, %xmm0
movq -0xc0(%rbp), %rax
cvtsi2sdl 0x38(%rax), %xmm1
divsd %xmm1, %xmm0
movsd 0xb22a4(%rip), %xmm1    # 0xd8c38
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %r8d
leaq 0xb2efd(%rip), %rsi     # 0xd98a1
movb $0x0, %al
callq 0x6a80
cmpl $0x0, -0x80(%rbp)
jne 0x26a6b
movq -0xc0(%rbp), %rax
movsbl 0x18(%rax), %eax
cmpl $0x2d, %eax
jne 0x26a69
movq -0xc0(%rbp), %rax
movsbl 0x30(%rax), %eax
cmpl $0x2b, %eax
jne 0x26a69
movq -0xc0(%rbp), %rdi
addq $0x10, %rdi
movq -0xc0(%rbp), %rsi
addq $0x14, %rsi
movl -0x7c(%rbp), %edx
callq 0x33350
movq -0xc0(%rbp), %rdi
addq $0x28, %rdi
movq -0xc0(%rbp), %rsi
addq $0x2c, %rsi
movq -0x70(%rbp), %rax
movl 0x10(%rax), %edx
callq 0x33350
movq -0xc0(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0xc0(%rbp), %rax
movslq 0x38(%rax), %rsi
callq 0x33300
movq -0xc0(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0xc0(%rbp), %rax
movslq 0x38(%rax), %rsi
callq 0x33300
movq -0xc0(%rbp), %rax
movb $0x2b, 0x18(%rax)
movq -0xc0(%rbp), %rax
movb $0x2d, 0x30(%rax)
jmp 0x26a6b
movq -0x18(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0xc0(%rbp), %rax
movsbl 0x18(%rax), %edi
callq 0x27200
movq %rax, -0x110(%rbp)
movq -0xc0(%rbp), %rax
movsbl 0x30(%rax), %edi
callq 0x27200
movq -0x118(%rbp), %rdi
movq -0x110(%rbp), %rdx
movq %rax, %rcx
leaq 0xb2e08(%rip), %rsi     # 0xd98bd
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
leaq 0xb2552(%rip), %rsi     # 0xd9019
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
movq -0xc0(%rbp), %rsi
movq -0x70(%rbp), %rax
movl 0x10(%rax), %edx
movl -0x7c(%rbp), %ecx
movl -0x10(%rbp), %r9d
movl -0x80(%rbp), %eax
movl $0x3c, %r8d
movl %eax, (%rsp)
callq 0x273b0
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xb8(%rbp)
jmp 0x265f8
jmp 0x26b10
movq -0x70(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x70(%rbp)
jmp 0x265c1
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rdx
leaq 0xb2da1(%rip), %rsi     # 0xd98d0
movb $0x0, %al
callq 0x6a80
leaq -0x68(%rbp), %rdi
callq 0x276f0
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nopl (%rax,%rax)