// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/lib/blastOut.c
// Function: tabBlastOut
static void tabBlastOut(struct axtBundle *abList, int queryIx, boolean isProt, 
	FILE *f, char *databaseName, int databaseSeqCount, 
	double databaseLetterCount, char *ourId, boolean withComment)
/* Do NCBI tabular blast output. */
{
char *queryName = abList->axtList->qName;
int querySize = abList->qSize;
struct targetHits *targetList = NULL, *target;

if (withComment)
    {
    // use date from CVS, unless checked out with -kk, then ignore.
    char * rcsDate = "$Date: 2009/02/26 00:05:49 $";
    char dateStamp[11];
    if (strlen(rcsDate) > 17)
        safencpy(dateStamp, sizeof(dateStamp), rcsDate+7, 10);
    else
        safecpy(dateStamp, sizeof(dateStamp), "");
    dateStamp[10] = 0;
    fprintf(f, "# BLAT %s [%s]\n", gfVersion, dateStamp);
    fprintf(f, "# Query: %s\n", queryName);
    fprintf(f, "# Database: %s\n", databaseName);
    fprintf(f, "%s\n", 
    	"# Fields: Query id, Subject id, % identity, alignment length, "
	"mismatches, gap openings, q. start, q. end, s. start, s. end, "
	"e-value, bit score");
    }

/* Print out details on each target. */
targetList = bundleIntoTargets(abList);
for (target = targetList; target != NULL; target = target->next)
    {
    struct axtRef *ref;
    for (ref = target->axtList; ref != NULL; ref = ref->next)
        {
	struct axt *axt = ref->axt;
	int matches = countMatches(axt->qSym, axt->tSym, axt->symCount);
	int gaps = countGaps(axt->qSym, axt->tSym, axt->symCount);
	int gapOpens = countGapOpens(axt->qSym, axt->tSym, axt->symCount);
	fprintf(f, "%s\t", axt->qName);
	fprintf(f, "%s\t", axt->tName);
	fprintf(f, "%.2f\t", 100.0 * matches/axt->symCount);
	fprintf(f, "%d\t", axt->symCount);
	fprintf(f, "%d\t", axt->symCount - matches - gaps);
	fprintf(f, "%d\t", gapOpens);
	if (axt->qStrand == '-')
	    {
	    int s = axt->qStart, e = axt->qEnd;
	    reverseIntRange(&s, &e, querySize);
	    fprintf(f, "%d\t", s+1);
	    fprintf(f, "%d\t", e);
	    printAxtTargetBlastTab(f, axt, target->size);
	    }
	else
	    {
	    fprintf(f, "%d\t", axt->qStart + 1);
	    fprintf(f, "%d\t", axt->qEnd);
	    printAxtTargetBlastTab(f, axt, target->size);
	    }
	fprintf(f, "%3.1e\t", blastzScoreToNcbiExpectation(axt->score));
	fprintf(f, "%d.0\n", blastzScoreToNcbiBits(axt->score));
	}
    }

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movl 0x18(%rbp), %eax
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)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0x3c(%rbp)
movq $0x0, -0x48(%rbp)
cmpl $0x0, 0x18(%rbp)
je 0x26c5b
leaq 0xb2d3d(%rip), %rax     # 0xd98ed
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
callq 0x62c0
cmpq $0x11, %rax
jbe 0x26be0
leaq -0x63(%rbp), %rdi
movq -0x58(%rbp), %rdx
addq $0x7, %rdx
movl $0xb, %esi
movl $0xa, %ecx
callq 0x31130
jmp 0x26bf5
leaq -0x63(%rbp), %rdi
movl $0xb, %esi
leaq 0xbe816(%rip), %rdx     # 0xe5406
callq 0x2caf0
movb $0x0, -0x59(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x63(%rbp), %rcx
leaq 0xb2d02(%rip), %rsi     # 0xd990a
leaq 0xb07d5(%rip), %rdx     # 0xd73e4
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
movq -0x38(%rbp), %rdx
leaq 0xb2cf5(%rip), %rsi     # 0xd991a
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rdx
leaq 0xb2cec(%rip), %rsi     # 0xd9927
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
leaq 0xb4043(%rip), %rsi     # 0xdac90
leaq 0xb2ce3(%rip), %rdx     # 0xd9937
movb $0x0, %al
callq 0x6a80
movq -0x8(%rbp), %rdi
callq 0x26f90
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x26efd
movq -0x50(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x70(%rbp)
je 0x26eeb
movq -0x70(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x78(%rbp), %rax
movq 0x48(%rax), %rsi
movq -0x78(%rbp), %rax
movl 0x38(%rax), %edx
callq 0x27240
movl %eax, -0x7c(%rbp)
movq -0x78(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x78(%rbp), %rax
movq 0x48(%rax), %rsi
movq -0x78(%rbp), %rax
movl 0x38(%rax), %edx
callq 0x27b00
movl %eax, -0x80(%rbp)
movq -0x78(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x78(%rbp), %rax
movq 0x48(%rax), %rsi
movq -0x78(%rbp), %rax
movl 0x38(%rax), %edx
callq 0x27b70
movl %eax, -0x84(%rbp)
movq -0x18(%rbp), %rdi
movq -0x78(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0xb2cb5(%rip), %rsi     # 0xd99c6
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
movq -0x78(%rbp), %rax
movq 0x20(%rax), %rdx
leaq 0xb2c9b(%rip), %rsi     # 0xd99c6
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
cvtsi2sdl -0x7c(%rbp), %xmm1
movsd 0xb13d5(%rip), %xmm0    # 0xd8118
mulsd %xmm1, %xmm0
movq -0x78(%rbp), %rax
cvtsi2sdl 0x38(%rax), %xmm1
divsd %xmm1, %xmm0
leaq 0xb2c6f(%rip), %rsi     # 0xd99ca
movb $0x1, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
movq -0x78(%rbp), %rax
movl 0x38(%rax), %edx
leaq 0xb1462(%rip), %rsi     # 0xd81d6
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
movq -0x78(%rbp), %rax
movl 0x38(%rax), %edx
subl -0x7c(%rbp), %edx
subl -0x80(%rbp), %edx
leaq 0xb1443(%rip), %rsi     # 0xd81d6
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
movl -0x84(%rbp), %edx
leaq 0xb142b(%rip), %rsi     # 0xd81d6
movb $0x0, %al
callq 0x6a80
movq -0x78(%rbp), %rax
movsbl 0x18(%rax), %eax
cmpl $0x2d, %eax
jne 0x26e38
movq -0x78(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x88(%rbp)
movq -0x78(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0x8c(%rbp)
movl -0x3c(%rbp), %edx
leaq -0x88(%rbp), %rdi
leaq -0x8c(%rbp), %rsi
callq 0x33350
movq -0x18(%rbp), %rdi
movl -0x88(%rbp), %edx
addl $0x1, %edx
leaq 0xb13d3(%rip), %rsi     # 0xd81d6
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
movl -0x8c(%rbp), %edx
leaq 0xb13bb(%rip), %rsi     # 0xd81d6
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
movq -0x78(%rbp), %rsi
movq -0x50(%rbp), %rax
movl 0x10(%rax), %edx
callq 0x27bf0
jmp 0x26e81
movq -0x18(%rbp), %rdi
movq -0x78(%rbp), %rax
movl 0x10(%rax), %edx
addl $0x1, %edx
leaq 0xb1389(%rip), %rsi     # 0xd81d6
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
movq -0x78(%rbp), %rax
movl 0x14(%rax), %edx
leaq 0xb1370(%rip), %rsi     # 0xd81d6
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
movq -0x78(%rbp), %rsi
movq -0x50(%rbp), %rax
movl 0x10(%rax), %edx
callq 0x27bf0
movq -0x18(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x78(%rbp), %rax
movl 0x34(%rax), %edi
callq 0x279a0
movq -0xa0(%rbp), %rdi
leaq 0xb2b2a(%rip), %rsi     # 0xd99d0
movb $0x1, %al
callq 0x6a80
movq -0x18(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x78(%rbp), %rax
movl 0x34(%rax), %edi
callq 0x27940
movq -0x98(%rbp), %rdi
movl %eax, %edx
leaq 0xb2b03(%rip), %rsi     # 0xd99d7
movb $0x0, %al
callq 0x6a80
movq -0x70(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x70(%rbp)
jmp 0x26c87
jmp 0x26eed
movq -0x50(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x50(%rbp)
jmp 0x26c70
leaq -0x48(%rbp), %rdi
callq 0x276f0
addq $0xa0, %rsp
popq %rbp
retq
nop