// File: /workspace/github_c_makefile_star2_O2/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 $0x58, %rsp
movq %rsi, %r12
movq %rdi, %rbx
movq 0x20(%rdi), %r14
addq $0x20, %rbx
leaq 0x8(%rsp), %r13
xorl %ebp, %ebp
movq %r14, %rdi
movq %r13, %rsi
callq 0x278e0
testl %eax, %eax
je 0x27481
movq %r13, %rdi
callq 0x1e9c1
testq %rax, %rax
je 0x27438
cmpb $0x61, (%rax)
jne 0x2745f
cmpb $0x0, 0x1(%rax)
je 0x27490
movq %r14, %rdi
movq %r13, %rsi
callq 0x278e0
testl %eax, %eax
je 0x278ce
movq %r13, %rdi
callq 0x1e9c1
testq %rax, %rax
jne 0x2745f
jmp 0x27438
movq %rbx, %rdi
callq 0x25cd8
xorl %ebp, %ebp
jmp 0x278ce
testq %r12, %r12
je 0x274a4
movq (%rbx), %rax
movslq 0x2c(%rax), %rcx
addq 0x18(%rax), %rcx
movq %rcx, (%r12)
pushq $0x28
popq %rdi
callq 0x28bb0
movq %rax, 0x18(%rsp)
leaq 0x8(%rsp), %r12
leaq 0x5767b(%rip), %r13     # 0x7eb38
movq %r12, %rdi
callq 0x1e9c1
testq %rax, %rax
je 0x2751f
movq %rax, %rbp
movq %rax, %rdi
pushq $0x3d
popq %rsi
callq 0x6270
movq %rax, %r15
testq %rax, %rax
jne 0x274f5
movq 0x8(%r14), %rdx
leaq 0x59230(%rip), %rdi     # 0x8071b
movq %rbp, %rsi
xorl %eax, %eax
callq 0x223fb
movb $0x0, (%r15)
movq %rbp, %rdi
movq %r13, %rsi
callq 0x6a50
testl %eax, %eax
jne 0x274bd
incq %r15
movq %r15, %rdi
callq 0x6920
movq 0x18(%rsp), %rax
movsd %xmm0, 0x8(%rax)
jmp 0x274bd
movq 0x18(%rsp), %rbp
movq %rbp, %r15
addq $0x10, %r15
leaq 0x8(%rsp), %r12
movq %r15, 0x10(%rsp)
movq %r14, %rdi
movq %r12, %rsi
callq 0x278e0
testl %eax, %eax
je 0x278c6
movq %r12, %rdi
callq 0x1e9c1
testq %rax, %rax
je 0x278c6
movq %rax, %r13
movzbl (%rax), %eax
cmpl $0x65, %eax
je 0x2756d
cmpl $0x73, %eax
jne 0x276ed
cmpb $0x0, 0x1(%r13)
jne 0x27535
movq %r13, 0x20(%rsp)
movq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
pushq $0x6
popq %rdx
callq 0x1e59b
leal 0x1(%rax), %edx
movq %r14, %rdi
pushq $0x7
popq %rsi
callq 0x25dfd
pushq $0x40
popq %rdi
callq 0x28bb0
movq %rax, %r12
movq 0x28(%rsp), %rdi
callq 0x1c306
movq %rax, 0x8(%r12)
movq %r14, %rdi
leaq 0x20(%rsp), %r15
movq %r15, %rsi
pushq $0x5
popq %rdx
callq 0x263ca
movl %eax, 0x10(%r12)
movq 0x40(%rsp), %rax
movb (%rax), %al
movb %al, 0x14(%r12)
movq %r14, %rdi
movq %r15, %rsi
pushq $0x2
popq %rdx
callq 0x263ca
movl %eax, 0x18(%r12)
cmpb $0x65, (%r13)
jne 0x275f8
cmpb $0x0, 0x1(%r13)
je 0x27653
movq %r14, %rdi
leaq 0x20(%rsp), %rsi
pushq $0x3
popq %rdx
callq 0x263ca
movl %eax, 0x1c(%r12)
movq 0x50(%rsp), %rdi
callq 0x1c306
movq %rax, 0x20(%r12)
movq %rax, %rdi
callq 0x62d0
movl 0x18(%rbp), %edx
testl %edx, %edx
je 0x2764e
cmpl %eax, %edx
movq 0x10(%rsp), %r15
je 0x27689
movl 0x28(%r14), %ecx
movq 0x8(%r14), %r8
leaq 0x590f8(%rip), %rdi     # 0x8073b
movl %eax, %esi
xorl %eax, %eax
callq 0x223fb
jmp 0x27689
movl %eax, 0x18(%rbp)
jmp 0x27684
andl $0x0, 0x1c(%r12)
movq %r14, %rdi
leaq 0x20(%rsp), %rsi
pushq $0x3
popq %rdx
callq 0x263ca
movl %eax, 0x34(%r12)
movl %eax, 0x3c(%r12)
movq 0x50(%rsp), %rax
movb (%rax), %al
movb %al, 0x30(%r12)
movb %al, 0x38(%r12)
movq 0x10(%rsp), %r15
cmpl $0x0, 0x10(%r12)
js 0x27699
cmpl $0x0, 0x1c(%r12)
jns 0x276af
movl 0x28(%r14), %esi
movq 0x8(%r14), %rdx
leaq 0x590c3(%rip), %rdi     # 0x8076b
xorl %eax, %eax
callq 0x223fb
movl 0x18(%r12), %eax
testl %eax, %eax
js 0x276c4
addl 0x1c(%r12), %eax
cmpl 0x10(%r12), %eax
jle 0x276da
movl 0x28(%r14), %esi
movq 0x8(%r14), %rdx
leaq 0x590ba(%rip), %rdi     # 0x8078d
xorl %eax, %eax
callq 0x223fb
movq (%r15), %rax
movq %rax, (%r12)
movq %r12, (%r15)
movb (%r13), %al
leaq 0x8(%rsp), %r12
cmpb $0x69, %al
jne 0x277a0
cmpb $0x0, 0x1(%r13)
jne 0x27535
movq %r13, 0x20(%rsp)
movq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
pushq $0x5
popq %rdx
callq 0x1e59b
leal 0x1(%rax), %edx
movq %r14, %rdi
pushq $0x6
popq %rsi
callq 0x25dfd
movq %r15, %rax
movq 0x28(%rsp), %r15
movq (%rax), %rbp
movq 0x8(%rbp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x6a50
testl %eax, %eax
je 0x2775f
leaq 0x5906a(%rip), %rdi     # 0x807b4
movq %r15, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0x223fb
movq 0x10(%rsp), %rax
movq (%rax), %rbp
movq 0x30(%rsp), %rax
movb (%rax), %al
movb %al, 0x30(%rbp)
movq 0x38(%rsp), %rdi
callq 0x6bd0
movl %eax, 0x34(%rbp)
movq 0x40(%rsp), %rax
movb (%rax), %al
movb %al, 0x38(%rbp)
movq 0x48(%rsp), %rdi
callq 0x6bd0
movl %eax, 0x3c(%rbp)
movb (%r13), %al
movq 0x18(%rsp), %rbp
movq 0x10(%rsp), %r15
leaq 0x8(%rsp), %r12
cmpb $0x71, %al
jne 0x27833
cmpb $0x0, 0x1(%r13)
jne 0x27535
movq %r13, 0x20(%rsp)
movq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
pushq $0x2
popq %rdx
callq 0x1e59b
leal 0x1(%rax), %edx
movq %r14, %rdi
pushq $0x3
popq %rsi
callq 0x25dfd
movq %r15, %rax
movq 0x28(%rsp), %r15
movq (%rax), %rbp
movq 0x8(%rbp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x6a50
testl %eax, %eax
je 0x27812
leaq 0x58fe0(%rip), %rdi     # 0x807dd
movq %r15, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0x223fb
movq 0x10(%rsp), %rax
movq (%rax), %rbp
movq 0x30(%rsp), %rdi
callq 0x1c306
movq %rax, 0x28(%rbp)
movb (%r13), %al
movq 0x18(%rsp), %rbp
movq 0x10(%rsp), %r15
leaq 0x8(%rsp), %r12
cmpb $0x72, %al
jne 0x27535
cmpb $0x0, 0x1(%r13)
jne 0x27535
movq %r15, %r12
movq 0x8(%rsp), %r15
cmpq $0x0, 0x20(%rbp)
je 0x2786d
movq (%rbx), %rax
movl 0x28(%rax), %esi
movq 0x8(%rax), %rdx
leaq 0x59129(%rip), %rdi     # 0x8098f
xorl %eax, %eax
callq 0x223fb
movq %r15, %rdi
leaq 0x20(%rsp), %rsi
pushq $0x3
popq %rdx
callq 0x1e59b
cmpl $0x3, %eax
je 0x27891
movq (%rbx), %rdi
incl %eax
pushq $0x4
popq %rsi
movl %eax, %edx
callq 0x25dfd
movq 0x20(%rsp), %r15
movq (%rbx), %rdi
leaq 0x20(%rsp), %rsi
pushq $0x1
popq %rdx
callq 0x2634c
movq 0x30(%rsp), %rdx
movq %r15, %rdi
movl %eax, %esi
callq 0x2858a
movq %rax, 0x20(%rbp)
movq %r12, %r15
leaq 0x8(%rsp), %r12
jmp 0x27535
movq %r15, %rdi
callq 0x1c567
movq %rbp, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq