// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/lib/blastOut.c
// Function: xmlBlastOut
static void xmlBlastOut(struct axtBundle *abList, int queryIx, boolean isProt, 
	FILE *f, char *databaseName, int databaseSeqCount, 
	double databaseLetterCount, char *ourId)
/* Do ncbi blast xml-like output at end of processing query. 
 * WARNING - still not completely baked.  Format at NCBI seems
 * to be missing some end tags actually when I checked. -jk */
{
char *queryName = abList->axtList->qName;
int querySize = abList->qSize;
int hitNum = 0;
struct targetHits *targetList = NULL, *target;

if (ourId == NULL)
    ourId = "axtBlastOut";
fprintf(f, "<?xml version=\"1.0\"?>\n");
fprintf(f, "<!DOCTYPE BlastOutput PUBLIC \"-//NCBI//NCBI BlastOutput/EN\" \"NCBI_BlastOutput.dtd\">\n");
fprintf(f, "<BlastOutput>\n");
fprintf(f, "  <BlastOutput_program>%s</BlastOutput_program>\n", 
	progType(isProt, abList, FALSE));
fprintf(f, "  <BlastOutput_version>%s 2.2.4 [%s]</BlastOutput_version>\n",
	progType(isProt, abList, FALSE), ourId);
fprintf(f, "  <BlastOutput_reference>~Reference: Kent, WJ. (2002) BLAT - The BLAST-like alignment tool</BlastOutput_reference>\n");
fprintf(f, "  <BlastOutput_db>%s</BlastOutput_db>\n", databaseName);
fprintf(f, "  <BlastOutput_query-ID>%d</BlastOutput_query-ID>\n", queryIx);
fprintf(f, "  <BlastOutput_query-def>%s</BlastOutput_query-def>\n", queryName);
fprintf(f, "  <BlastOutput_query-len>%d</BlastOutput_query-len>\n", querySize);

if (isProt)
    {
    fprintf(f, "  <BlastOutput_param>\n");
    fprintf(f, "    <Parameters_matrix>BLOSUM62</Parameters_matrix>\n");
    fprintf(f, "    <Parameters_expect>0.001</Parameters_expect>\n");
    fprintf(f, "    <Parameters_expect>10</Parameters_expect>\n");
    fprintf(f, "    <Parameters_gap-extend>1</Parameters_gap-extend>\n");
    fprintf(f, "  </BlastOutput_param>\n");
    }

fprintf(f, "  <BlastOutput_iterations>\n");
fprintf(f, "    <Iteration>\n");
fprintf(f, "      <Iteration_iter-num>1</Iteration_iter-num>\n");
fprintf(f, "      <Iteration_hits>\n");

/* Print out details on each target. */
targetList = bundleIntoTargets(abList);
for (target = targetList; target != NULL; target = target->next)
    {
    struct axtRef *ref;
    fprintf(f, "      <hit>\n");
    fprintf(f, "        <Hit_num>%d</Hit_num>\n", hitNum);
    fprintf(f, "        <Hit_id>%s</Hit_id>\n", target->name);
    fprintf(f, "        <Hit_accession>%s</Hit_accession>\n", target->name);
    fprintf(f, "        <Hit_len>%d</Hit_len>\n", target->size);
    fprintf(f, "        <Hit_hsps>\n");
    for (ref = target->axtList; ref != NULL; ref = ref->next)
        {
	struct axt *axt = ref->axt;
	int hspIx = 0;
	fprintf(f, "        <Hsp>\n");
	fprintf(f, "          <Hsp_num>%d</Hsp_num>\n", ++hspIx);
	fprintf(f, "          <Hsp_bit-score>%d</Hsp_bit-score>\n", 
		blastzScoreToNcbiBits(axt->score));
	fprintf(f, "          <Hsp_score>%d</Hsp_score>\n",
		blastzScoreToNcbiScore(axt->score));
	fprintf(f, "          <Hsp_evalue>%f</Hsp_evalue>\n",
	        blastzScoreToNcbiExpectation(axt->score));
	fprintf(f, "          <Hsp_query-from>%d</Hsp_query-from>\n", 
		axt->qStart+1);
	fprintf(f, "          <Hsp_query-to>%d</Hsp_query-to>\n", axt->qEnd);
	fprintf(f, "          <Hsp_hit-from>%d</Hsp_hit-from>\n", 
		axt->tStart+1);
	fprintf(f, "          <Hsp_hit-to>%d</Hsp_hit-to>\n", axt->tEnd);
	fprintf(f, "        </Hsp>\n");
	}

    fprintf(f, "        </Hit_hsps>\n");
    }

fprintf(f, "      </Iteration_hits>\n");
fprintf(f, "    </Iteration>\n");
fprintf(f, "  </BlastOutput_iterations>\n");
fprintf(f, "</BlastOutput>\n");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
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)
movl $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
cmpq $0x0, 0x10(%rbp)
jne 0x25e45
leaq 0xb2e5c(%rip), %rax     # 0xd8c9d
movq %rax, 0x10(%rbp)
movq -0x18(%rbp), %rdi
leaq 0xb32af(%rip), %rsi     # 0xd90ff
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
leaq 0xb32b4(%rip), %rsi     # 0xd9116
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
leaq 0xb32f7(%rip), %rsi     # 0xd916b
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rax
movq %rax, -0x78(%rbp)
movl -0x10(%rbp), %edi
movq -0x8(%rbp), %rsi
xorl %edx, %edx
callq 0x26f10
movq -0x78(%rbp), %rdi
movq %rax, %rdx
leaq 0xb32db(%rip), %rsi     # 0xd917a
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rax
movq %rax, -0x70(%rbp)
movl -0x10(%rbp), %edi
movq -0x8(%rbp), %rsi
xorl %edx, %edx
callq 0x26f10
movq -0x70(%rbp), %rdi
movq %rax, %rdx
movq 0x10(%rbp), %rcx
leaq 0xb32dd(%rip), %rsi     # 0xd91ab
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
leaq 0xb3307(%rip), %rsi     # 0xd91e7
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rdx
leaq 0xb3365(%rip), %rsi     # 0xd925b
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
movl -0xc(%rbp), %edx
leaq 0xb3377(%rip), %rsi     # 0xd9282
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
movq -0x38(%rbp), %rdx
leaq 0xb3394(%rip), %rsi     # 0xd92b5
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
movl -0x3c(%rbp), %edx
leaq 0xb33b4(%rip), %rsi     # 0xd92ea
movb $0x0, %al
callq 0x6a80
cmpl $0x0, -0x10(%rbp)
je 0x25faf
movq -0x18(%rbp), %rdi
leaq 0xb33d1(%rip), %rsi     # 0xd931f
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
leaq 0xb33d6(%rip), %rsi     # 0xd9336
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
leaq 0xb33f9(%rip), %rsi     # 0xd936b
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
leaq 0xb3419(%rip), %rsi     # 0xd939d
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
leaq 0xb3436(%rip), %rsi     # 0xd93cc
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
leaq 0xb345a(%rip), %rsi     # 0xd9402
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
leaq 0xb3460(%rip), %rsi     # 0xd941a
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
leaq 0xb346a(%rip), %rsi     # 0xd9436
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
leaq 0xb3469(%rip), %rsi     # 0xd9447
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
leaq 0xb3489(%rip), %rsi     # 0xd9479
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 0x26224
movq -0x18(%rbp), %rdi
leaq 0xb346f(%rip), %rsi     # 0xd9491
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
movl -0x40(%rbp), %edx
leaq 0xb3467(%rip), %rsi     # 0xd949e
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0xb346c(%rip), %rsi     # 0xd94bd
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0xb346f(%rip), %rsi     # 0xd94da
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
movq -0x50(%rbp), %rax
movl 0x10(%rax), %edx
leaq 0xb3481(%rip), %rsi     # 0xd9505
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
leaq 0xb348e(%rip), %rsi     # 0xd9524
movb $0x0, %al
callq 0x6a80
movq -0x50(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0x26202
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x60(%rbp)
movl $0x0, -0x64(%rbp)
movq -0x18(%rbp), %rdi
leaq 0xb3466(%rip), %rsi     # 0xd9538
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
movl -0x64(%rbp), %edx
addl $0x1, %edx
movl %edx, -0x64(%rbp)
leaq 0xb345a(%rip), %rsi     # 0xd9547
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x60(%rbp), %rax
movl 0x34(%rax), %edi
callq 0x27940
movq -0x90(%rbp), %rdi
movl %eax, %edx
leaq 0xb344d(%rip), %rsi     # 0xd9568
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x60(%rbp), %rax
movl 0x34(%rax), %edi
callq 0x27970
movq -0x88(%rbp), %rdi
movl %eax, %edx
leaq 0xb344c(%rip), %rsi     # 0xd9595
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x60(%rbp), %rax
movl 0x34(%rax), %edi
callq 0x279a0
movq -0x80(%rbp), %rdi
leaq 0xb344b(%rip), %rsi     # 0xd95ba
movb $0x1, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
movq -0x60(%rbp), %rax
movl 0x10(%rax), %edx
addl $0x1, %edx
leaq 0xb3456(%rip), %rsi     # 0xd95e1
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
movq -0x60(%rbp), %rax
movl 0x14(%rax), %edx
leaq 0xb346c(%rip), %rsi     # 0xd9610
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
movq -0x60(%rbp), %rax
movl 0x28(%rax), %edx
addl $0x1, %edx
leaq 0xb347b(%rip), %rsi     # 0xd963b
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
movq -0x60(%rbp), %rax
movl 0x2c(%rax), %edx
leaq 0xb348d(%rip), %rsi     # 0xd9666
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
leaq 0xb34a2(%rip), %rsi     # 0xd968d
movb $0x0, %al
callq 0x6a80
movq -0x58(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x58(%rbp)
jmp 0x260a9
movq -0x18(%rbp), %rdi
leaq 0xb3490(%rip), %rsi     # 0xd969d
movb $0x0, %al
callq 0x6a80
movq -0x50(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x50(%rbp)
jmp 0x2600c
movq -0x18(%rbp), %rdi
leaq 0xb3483(%rip), %rsi     # 0xd96b2
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
leaq 0xb348a(%rip), %rsi     # 0xd96cb
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
leaq 0xb348a(%rip), %rsi     # 0xd96dd
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
leaq 0xb3495(%rip), %rsi     # 0xd96fa
movb $0x0, %al
callq 0x6a80
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)