// File: /workspace/github_c_makefile_star2_O3/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
xorl %r15d, %r15d
leaq 0x8(%rsp), %r13
movq %r14, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x2a7a9
testl %eax, %eax
je 0x2c7e4
movq 0x8(%rsp), %rax
cmpb $0x23, (%rax)
je 0x2c787
movq %r13, %rdi
callq 0x22cf1
testq %rax, %rax
je 0x2c787
cmpb $0x61, (%rax)
jne 0x2c7ba
cmpb $0x0, 0x1(%rax)
je 0x2c801
movq %r14, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x2a7a9
testl %eax, %eax
je 0x2c7ef
movq 0x8(%rsp), %rax
cmpb $0x23, (%rax)
je 0x2c7ba
movq %r13, %rdi
callq 0x22cf1
testq %rax, %rax
jne 0x2c7ba
jmp 0x2c787
movq %rbx, %rdi
callq 0x2ae73
xorl %r15d, %r15d
movq %r15, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %r12, %r12
je 0x2c815
movq (%rbx), %rax
movslq 0x2c(%rax), %rcx
addq 0x18(%rax), %rcx
movq %rcx, (%r12)
movl $0x28, %edi
callq 0x2dff4
movq %rax, %r15
leaq 0x8(%rsp), %rdi
callq 0x22cf1
testq %rax, %rax
je 0x2c89c
movq %rax, %r12
leaq 0x8(%rsp), %rbp
movq %r12, %rdi
movl $0x3d, %esi
callq 0x6270
movq %rax, %r13
testq %rax, %rax
jne 0x2c863
movq 0x8(%r14), %rdx
leaq 0x64fc2(%rip), %rdi     # 0x9181b
movq %r12, %rsi
xorl %eax, %eax
callq 0x26e94
movb $0x0, (%r13)
movq %r12, %rdi
leaq 0x63396(%rip), %rsi     # 0x8fc08
callq 0x6a50
testl %eax, %eax
jne 0x2c88c
incq %r13
movq %r13, %rdi
callq 0x6920
movsd %xmm0, 0x8(%r15)
movq %rbp, %rdi
callq 0x22cf1
movq %rax, %r12
testq %rax, %rax
jne 0x2c839
movq %r15, %rbp
addq $0x10, %rbp
leaq 0x8(%rsp), %r12
movq %rbp, 0x10(%rsp)
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x2a7a9
testl %eax, %eax
je 0x2cc6c
movq 0x8(%rsp), %rax
cmpb $0x23, (%rax)
je 0x2c8ad
movq %r12, %rdi
callq 0x22cf1
testq %rax, %rax
je 0x2cc6c
movq %rax, %r13
movzbl (%rax), %eax
cmpl $0x65, %eax
je 0x2c8f1
cmpl $0x73, %eax
jne 0x2ca86
cmpb $0x0, 0x1(%r13)
jne 0x2c8ad
movq %r13, 0x20(%rsp)
movq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
movl $0x6, %edx
callq 0x226f5
leal 0x1(%rax), %edx
movq %r14, %rdi
movl $0x7, %esi
callq 0x2afa3
movl $0x40, %edi
callq 0x2dff4
movq %rax, %r12
movq 0x28(%rsp), %rdi
callq 0x1feba
movq %rax, 0x8(%r12)
movq %r14, %rdi
leaq 0x20(%rsp), %rbp
movq %rbp, %rsi
movl $0x5, %edx
callq 0x2b605
movl %eax, 0x10(%r12)
movq 0x40(%rsp), %rax
movb (%rax), %al
movb %al, 0x14(%r12)
movq %r14, %rdi
movq %rbp, %rsi
movl $0x2, %edx
callq 0x2b605
movl %eax, 0x18(%r12)
cmpb $0x65, (%r13)
jne 0x2c986
cmpb $0x0, 0x1(%r13)
je 0x2c9e5
movq %r14, %rdi
leaq 0x20(%rsp), %rsi
movl $0x3, %edx
callq 0x2b605
movl %eax, 0x1c(%r12)
movq 0x50(%rsp), %rdi
callq 0x1feba
movq %rax, 0x20(%r12)
movq %rax, %rdi
callq 0x62d0
movl 0x18(%r15), %edx
testl %edx, %edx
je 0x2c9df
cmpl %eax, %edx
movq 0x10(%rsp), %rbp
je 0x2ca20
movl 0x28(%r14), %ecx
movq 0x8(%r14), %r8
leaq 0x64e67(%rip), %rdi     # 0x9183b
movl %eax, %esi
xorl %eax, %eax
callq 0x26e94
jmp 0x2ca20
movl %eax, 0x18(%r15)
jmp 0x2ca1b
movl $0x0, 0x1c(%r12)
movq %r14, %rdi
leaq 0x20(%rsp), %rsi
movl $0x3, %edx
callq 0x2b605
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), %rbp
cmpl $0x0, 0x10(%r12)
js 0x2ca30
cmpl $0x0, 0x1c(%r12)
jns 0x2ca46
movl 0x28(%r14), %esi
movq 0x8(%r14), %rdx
leaq 0x64e2c(%rip), %rdi     # 0x9186b
xorl %eax, %eax
callq 0x26e94
movl 0x18(%r12), %eax
testl %eax, %eax
js 0x2ca5b
addl 0x1c(%r12), %eax
cmpl 0x10(%r12), %eax
jle 0x2ca71
movl 0x28(%r14), %esi
movq 0x8(%r14), %rdx
leaq 0x64e23(%rip), %rdi     # 0x9188d
xorl %eax, %eax
callq 0x26e94
movq (%rbp), %rax
movq %rax, (%r12)
movq %r12, (%rbp)
movb (%r13), %al
leaq 0x8(%rsp), %r12
cmpb $0x69, %al
jne 0x2cb43
cmpb $0x0, 0x1(%r13)
jne 0x2c8ad
movq %r13, 0x20(%rsp)
movq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
movl $0x5, %edx
callq 0x226f5
leal 0x1(%rax), %edx
movq %r14, %rdi
movl $0x6, %esi
callq 0x2afa3
movq 0x28(%rsp), %rdi
movq (%rbp), %r12
movq 0x8(%r12), %rbp
movq %rdi, 0x18(%rsp)
movq %rbp, %rsi
callq 0x6a50
testl %eax, %eax
je 0x2caff
leaq 0x64dcc(%rip), %rdi     # 0x918b4
movq 0x18(%rsp), %rsi
movq %rbp, %rdx
xorl %eax, %eax
callq 0x26e94
movq 0x10(%rsp), %rax
movq (%rax), %r12
movq 0x30(%rsp), %rax
movb (%rax), %al
movb %al, 0x30(%r12)
movq 0x38(%rsp), %rdi
callq 0x6bd0
movl %eax, 0x34(%r12)
movq 0x40(%rsp), %rax
movb (%rax), %al
movb %al, 0x38(%r12)
movq 0x48(%rsp), %rdi
callq 0x6bd0
movl %eax, 0x3c(%r12)
movb (%r13), %al
movq 0x10(%rsp), %rbp
leaq 0x8(%rsp), %r12
cmpb $0x71, %al
jne 0x2cbd9
cmpb $0x0, 0x1(%r13)
jne 0x2c8ad
movq %r13, 0x20(%rsp)
movq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
movl $0x2, %edx
callq 0x226f5
leal 0x1(%rax), %edx
movq %r14, %rdi
movl $0x3, %esi
callq 0x2afa3
movq 0x28(%rsp), %rdi
movq (%rbp), %r12
movq 0x8(%r12), %rbp
movq %rdi, 0x18(%rsp)
movq %rbp, %rsi
callq 0x6a50
testl %eax, %eax
je 0x2cbbc
leaq 0x64d38(%rip), %rdi     # 0x918dd
movq 0x18(%rsp), %rsi
movq %rbp, %rdx
xorl %eax, %eax
callq 0x26e94
movq 0x10(%rsp), %rax
movq (%rax), %r12
movq 0x30(%rsp), %rdi
callq 0x1feba
movq %rax, 0x28(%r12)
movb (%r13), %al
movq 0x10(%rsp), %rbp
leaq 0x8(%rsp), %r12
cmpb $0x72, %al
jne 0x2c8ad
cmpb $0x0, 0x1(%r13)
jne 0x2c8ad
movq 0x8(%rsp), %r12
cmpq $0x0, 0x20(%r15)
je 0x2cc10
movq (%rbx), %rax
movl 0x28(%rax), %esi
movq 0x8(%rax), %rdx
leaq 0x64e86(%rip), %rdi     # 0x91a8f
xorl %eax, %eax
callq 0x26e94
movq %r12, %rdi
leaq 0x20(%rsp), %rsi
movl $0x3, %edx
callq 0x226f5
cmpl $0x3, %eax
je 0x2cc38
movq (%rbx), %rdi
incl %eax
movl $0x4, %esi
movl %eax, %edx
callq 0x2afa3
movq 0x20(%rsp), %r12
movq (%rbx), %rdi
leaq 0x20(%rsp), %rsi
movl $0x1, %edx
callq 0x2b587
movq 0x30(%rsp), %rdx
movq %r12, %rdi
movl %eax, %esi
callq 0x2d9c2
movq %rax, 0x20(%r15)
leaq 0x8(%rsp), %r12
jmp 0x2c8ad
movq %rbp, %rdi
callq 0x20173
jmp 0x2c7ef