// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/lib/maf.c
// Function: mafNextWithPos
struct mafAli *mafNextWithPos(struct mafFile *mf, off_t *retOffset)
/* Return next alignment in FILE or NULL if at end.  If retOffset is
 * nonNULL, return start offset of record in file. */
{
struct lineFile *lf = mf->lf;
struct mafAli *ali;
char *line, *word;

/* Loop until get an alignment paragraph or reach end of file. */
for (;;)
    {
    /* Get alignment header line.  If it's not there assume end of file. */
    if (!nextLine(lf, &line))
	{
	lineFileClose(&mf->lf);
	return NULL;
	}

    /* Parse alignment header line. */
    word = nextWord(&line);
    if (word == NULL)
	continue;	/* Ignore blank lines. */
	
    if (sameString(word, "a"))
	{
	if (retOffset != NULL)
	    *retOffset = lineFileTell(mf->lf);
	AllocVar(ali);
	while ((word = nextWord(&line)) != NULL)
	    {
	    /* Parse name=val. */
	    char *name = word;
	    char *val = strchr(word, '=');
	    if (val == NULL)
	       errAbort("Missing = after %s line 1 of %s", name, lf->fileName);
	    *val++ = 0;

	    if (sameString(name, "score"))
		ali->score = atof(val);
	    }

	/* Parse alignment components until blank line. */
	for (;;)
	    {
	    if (!nextLine(lf, &line))
		break;
	    word = nextWord(&line);
	    if (word == NULL)
		break;
	    if (sameString(word, "s") || sameString(word, "e"))
		{
		struct mafComp *comp;
		int wordCount;
		char *row[7];
		int textSize;

		/* Chop line up by white space.  This involves a few +-1's because
		 * have already chopped out first word. */
		row[0] = word;
		wordCount = chopByWhite(line, row+1, ArraySize(row)-1) + 1; /* +-1 because of "s" */
		lineFileExpectWords(lf, ArraySize(row), wordCount);
		AllocVar(comp);

		/* Convert ascii text representation to mafComp structure. */
		comp->src = cloneString(row[1]);
		comp->srcSize = lineFileNeedNum(lf, row, 5);
		comp->strand = row[4][0];
		comp->start = lineFileNeedNum(lf, row, 2);

		if (sameString(word, "e"))
		    {
		    comp->size = 0;
		    comp->rightLen = comp->leftLen = lineFileNeedNum(lf, row, 3);
		    comp->rightStatus = comp->leftStatus = *row[6];
		    }
		else
		    {
		    comp->size = lineFileNeedNum(lf, row, 3);
		    comp->text = cloneString(row[6]);
		    textSize = strlen(comp->text);

		    /* Fill in ali->text size. */
		    if (ali->textSize == 0)
			ali->textSize = textSize;
		    else if (ali->textSize != textSize)
			errAbort("Text size inconsistent (%d vs %d) line %d of %s",
			    textSize, ali->textSize, lf->lineIx, lf->fileName);
		    }

		/* Do some sanity checking. */
		if (comp->srcSize < 0 || comp->size < 0)
		     errAbort("Got a negative size line %d of %s", lf->lineIx, lf->fileName);
		if (comp->start < 0 || comp->start + comp->size > comp->srcSize)
		     errAbort("Coordinates out of range line %d of %s", lf->lineIx, lf->fileName);
		  
		/* Add component to head of list. */
		slAddHead(&ali->components, comp);
		}
	    if (sameString(word, "i"))
		{
		struct mafComp *comp;
		int wordCount;
		char *row[6];

		/* Chop line up by white space.  This involves a few +-1's because
		 * have already chopped out first word. */
		row[0] = word;
		wordCount = chopByWhite(line, row+1, ArraySize(row)-1) + 1; /* +-1 because of "s" */
		lineFileExpectWords(lf, ArraySize(row), wordCount);
		if (!sameString(row[1],ali->components->src))
		    errAbort("i line src mismatch: i is %s :: s is %s\n", row[1], ali->components->src);

		comp = ali->components;
		comp->leftStatus = *row[2];
		comp->leftLen = atoi(row[3]);
		comp->rightStatus = *row[4];
		comp->rightLen = atoi(row[5]);
		}
            if (sameString(word, "q"))
		{
		struct mafComp *comp;
		int wordCount;
		char *row[3];

		/* Chop line up by white space.  This involves a few +-1's because
		 * have already chopped out first word. */
		row[0] = word;
		wordCount = chopByWhite(line, row+1, ArraySize(row)-1) + 1; /* +-1 because of "s" */
		lineFileExpectWords(lf, ArraySize(row), wordCount);
		if (!sameString(row[1],ali->components->src))
		    errAbort("q line src mismatch: q is %s :: s is %s\n", row[1], ali->components->src);

			comp = ali->components;
			comp->quality = cloneString(row[2]);
		}
	    if (sameString(word, "r"))
                mafRegDefParse(mf, ali, line);
	    }
	slReverse(&ali->components);
	return ali;
	}
    else  /* Skip over paragraph we don't understand. */
	{
	for (;;)
	    {
	    if (!nextLine(lf, &line))
		return NULL;
            if (nextWord(&line) == NULL)
		break;
	    }
	}
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r12
movq %rdi, %rbx
movq 0x20(%rdi), %r15
addq $0x20, %rbx
xorl %r14d, %r14d
leaq 0x8(%rsp), %r13
leaq 0x64108(%rip), %rbp     # 0x9053a
movq %r15, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x2a455
testl %eax, %eax
je 0x2c49b
movq 0x8(%rsp), %rcx
cmpb $0x23, (%rcx)
je 0x2c432
testl %eax, %eax
je 0x2c49b
movq %r13, %rdi
callq 0x229cd
testq %rax, %rax
je 0x2c432
movq %rax, %rdi
movq %rbp, %rsi
callq 0x6a50
testl %eax, %eax
je 0x2c4b8
movq %r15, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x2a455
testl %eax, %eax
je 0x2c4a6
movq 0x8(%rsp), %rcx
cmpb $0x23, (%rcx)
je 0x2c46d
testl %eax, %eax
je 0x2c4a6
movq %r13, %rdi
callq 0x229cd
testq %rax, %rax
jne 0x2c46d
jmp 0x2c432
movq %rbx, %rdi
callq 0x2ab48
xorl %r14d, %r14d
movq %r14, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %r12, %r12
je 0x2c4cc
movq (%rbx), %rax
movslq 0x2c(%rax), %rcx
addq 0x18(%rax), %rcx
movq %rcx, (%r12)
movl $0x28, %edi
callq 0x2dc95
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x229cd
testq %rax, %rax
je 0x2c553
movq %rax, %r12
leaq 0x8(%rsp), %rbp
movq %r12, %rdi
movl $0x3d, %esi
callq 0x6270
movq %rax, %r13
testq %rax, %rax
jne 0x2c51a
movq 0x8(%r15), %rdx
leaq 0x6521b(%rip), %rdi     # 0x9172b
movq %r12, %rsi
xorl %eax, %eax
callq 0x26b6f
movb $0x0, (%r13)
movq %r12, %rdi
leaq 0x6361f(%rip), %rsi     # 0x8fb48
callq 0x6a50
testl %eax, %eax
jne 0x2c543
incq %r13
movq %r13, %rdi
callq 0x6920
movsd %xmm0, 0x8(%r14)
movq %rbp, %rdi
callq 0x229cd
movq %rax, %r12
testq %rax, %rax
jne 0x2c4f0
leaq 0x8(%rsp), %r13
movq %r15, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x2a455
testl %eax, %eax
je 0x2c90a
movq 0x8(%rsp), %rcx
cmpb $0x23, (%rcx)
je 0x2c558
testl %eax, %eax
je 0x2c90a
movq %r13, %rdi
callq 0x229cd
testq %rax, %rax
je 0x2c90a
movq %rax, %rbp
movq %rax, %rdi
leaq 0x63bfd(%rip), %rsi     # 0x9019a
callq 0x6a50
testl %eax, %eax
je 0x2c5bd
movq %rbp, %rdi
leaq 0x634bd(%rip), %rsi     # 0x8fa6d
callq 0x6a50
testl %eax, %eax
jne 0x2c73e
movq %rbp, 0x10(%rsp)
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
movl $0x6, %edx
callq 0x223ad
leal 0x1(%rax), %edx
movq %r15, %rdi
movl $0x7, %esi
callq 0x2ac73
movl $0x40, %edi
callq 0x2dc95
movq %rax, %r12
movq 0x18(%rsp), %rdi
callq 0x1f9f6
movq %rax, 0x8(%r12)
movq %r15, %rdi
leaq 0x10(%rsp), %r13
movq %r13, %rsi
movl $0x5, %edx
callq 0x2b2eb
movl %eax, 0x10(%r12)
movq 0x30(%rsp), %rax
movb (%rax), %al
movb %al, 0x14(%r12)
movq %r15, %rdi
movq %r13, %rsi
movl $0x2, %edx
callq 0x2b2eb
movl %eax, 0x18(%r12)
movq %rbp, %rdi
leaq 0x63426(%rip), %rsi     # 0x8fa6d
callq 0x6a50
testl %eax, %eax
je 0x2c6a2
movq %r15, %rdi
movq %r13, %rsi
movl $0x3, %edx
callq 0x2b2eb
movl %eax, 0x1c(%r12)
movq 0x40(%rsp), %rdi
callq 0x1f9f6
movq %rax, 0x20(%r12)
movq %rax, %rdi
callq 0x62d0
movl 0x18(%r14), %edx
testl %edx, %edx
je 0x2c6d8
cmpl %eax, %edx
je 0x2c6dc
movl 0x28(%r15), %ecx
movq 0x8(%r15), %r8
leaq 0x650b4(%rip), %rdi     # 0x9174b
movl %eax, %esi
xorl %eax, %eax
callq 0x26b6f
jmp 0x2c6dc
movl $0x0, 0x1c(%r12)
movq %r15, %rdi
movq %r13, %rsi
movl $0x3, %edx
callq 0x2b2eb
movl %eax, 0x34(%r12)
movl %eax, 0x3c(%r12)
movq 0x40(%rsp), %rax
movb (%rax), %al
movb %al, 0x30(%r12)
movb %al, 0x38(%r12)
jmp 0x2c6dc
movl %eax, 0x18(%r14)
cmpl $0x0, 0x10(%r12)
js 0x2c6ec
cmpl $0x0, 0x1c(%r12)
jns 0x2c702
movl 0x28(%r15), %esi
movq 0x8(%r15), %rdx
leaq 0x65080(%rip), %rdi     # 0x9177b
xorl %eax, %eax
callq 0x26b6f
movl 0x18(%r12), %eax
testl %eax, %eax
js 0x2c717
addl 0x1c(%r12), %eax
cmpl 0x10(%r12), %eax
jle 0x2c72d
movl 0x28(%r15), %esi
movq 0x8(%r15), %rdx
leaq 0x65077(%rip), %rdi     # 0x9179d
xorl %eax, %eax
callq 0x26b6f
movq 0x10(%r14), %rax
movq %rax, (%r12)
movq %r12, 0x10(%r14)
leaq 0x8(%rsp), %r13
movq %rbp, %rdi
leaq 0x6bf6e(%rip), %rsi     # 0x986b6
callq 0x6a50
testl %eax, %eax
jne 0x2c7ed
movq %rbp, 0x10(%rsp)
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
movl $0x5, %edx
callq 0x223ad
leal 0x1(%rax), %edx
movq %r15, %rdi
movl $0x6, %esi
callq 0x2ac73
movq 0x18(%rsp), %r12
movq 0x10(%r14), %rax
movq 0x8(%rax), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x6a50
testl %eax, %eax
je 0x2c7ae
leaq 0x65023(%rip), %rdi     # 0x917c4
movq %r12, %rsi
movq %r13, %rdx
xorl %eax, %eax
callq 0x26b6f
movq 0x10(%r14), %r12
movq 0x20(%rsp), %rax
movb (%rax), %al
movb %al, 0x30(%r12)
movq 0x28(%rsp), %rdi
callq 0x6bd0
movl %eax, 0x34(%r12)
movq 0x30(%rsp), %rax
movb (%rax), %al
movb %al, 0x38(%r12)
movq 0x38(%rsp), %rdi
callq 0x6bd0
movl %eax, 0x3c(%r12)
leaq 0x8(%rsp), %r13
movq %rbp, %rdi
leaq 0x61caa(%rip), %rsi     # 0x8e4a1
callq 0x6a50
testl %eax, %eax
jne 0x2c871
movq %rbp, 0x10(%rsp)
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
movl $0x2, %edx
callq 0x223ad
leal 0x1(%rax), %edx
movq %r15, %rdi
movl $0x3, %esi
callq 0x2ac73
movq 0x18(%rsp), %r12
movq 0x10(%r14), %rax
movq 0x8(%rax), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x6a50
testl %eax, %eax
je 0x2c859
leaq 0x64fa1(%rip), %rdi     # 0x917ed
movq %r12, %rsi
movq %r13, %rdx
xorl %eax, %eax
callq 0x26b6f
movq 0x10(%r14), %r12
movq 0x20(%rsp), %rdi
callq 0x1f9f6
movq %rax, 0x28(%r12)
leaq 0x8(%rsp), %r13
movq %rbp, %rdi
leaq 0x695ae(%rip), %rsi     # 0x95e29
callq 0x6a50
testl %eax, %eax
jne 0x2c558
movq %r13, %rbp
movq 0x8(%rsp), %r12
cmpq $0x0, 0x20(%r14)
je 0x2c8af
movq (%rbx), %rax
movl 0x28(%rax), %esi
movq 0x8(%rax), %rdx
leaq 0x650f7(%rip), %rdi     # 0x9199f
xorl %eax, %eax
callq 0x26b6f
movq %r12, %rdi
leaq 0x10(%rsp), %r13
movq %r13, %rsi
movl $0x3, %edx
callq 0x223ad
cmpl $0x3, %eax
je 0x2c8da
movq (%rbx), %rdi
incl %eax
movl $0x4, %esi
movl %eax, %edx
callq 0x2ac73
movq 0x10(%rsp), %r12
movq (%rbx), %rdi
movq %r13, %rsi
movl $0x1, %edx
callq 0x2b26d
movq 0x20(%rsp), %rdx
movq %r12, %rdi
movl %eax, %esi
callq 0x2d660
movq %rax, 0x20(%r14)
movq %rbp, %r13
jmp 0x2c558
movq %r14, %rdi
addq $0x10, %rdi
callq 0x1fcb3
jmp 0x2c4a6