// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/lib/psl.c
// Function: pslFromAlign
struct psl* pslFromAlign(char *qName, int qSize, int qStart, int qEnd, char *qString,
                         char *tName, int tSize, int tStart, int tEnd, char *tString,
                         char* strand, unsigned options)
/* Create a PSL from an alignment.  Options PSL_IS_SOFTMASK if lower case
 * bases indicate repeat masking.  Returns NULL if alignment is empty after
 * triming leading and trailing indels.*/
{
/* Note, the unit tests for these programs exercise this function:
 *   hg/embossToPsl
 *   hg/mouseStuff/axtToPsl
 *   hg/spideyToPsl
 *   utils/est2genomeToPsl
 */

int blockSpace = 16;
struct psl* psl = NULL;
int aliSize = strlen(qString);
boolean eitherInsert = FALSE;	/* True if either in insert state. */
int i, qs,qe,ts,te;
char prevQ = '\0',  prevT = '\0';
AllocVar(psl);

if (strlen(tString) != aliSize)
    errAbort("query and target alignment strings are different lengths");

psl = pslNew(qName, qSize, qStart, qEnd, tName, tSize, tStart, tEnd,
             strand, blockSpace, 0);
trimAlignment(psl, &qString, &tString, &aliSize);

/* Don't create if either query or target is zero length after trim */
 if ((psl->qStart == psl->qEnd) || (psl->tStart == psl->tEnd))
     {
     pslFree(&psl);
     return NULL;
     }

/* Get range of alignment in strand-specified coordinates */
qs = psl->qStart;
qe = psl->qEnd;
if (strand[0] == '-')
    reverseIntRange(&qs, &qe, psl->qSize);
ts = psl->tStart;
te = psl->tEnd;
if (strand[1] == '-')
    reverseIntRange(&ts, &te, psl->tSize);

eitherInsert = FALSE;
qe = qs;  /* current block coords */
te = ts;
for (i=0; i<aliSize; ++i)
    {
    char q = qString[i];
    char t = tString[i];
    if (isDelChar(q) && isDelChar(t))
        {
        continue; /* nothing in this column, just ignore it */
        }
    else if (isDelChar(q) || isDelChar(t))
        {
        /* insert in one of the columns */
	if (!eitherInsert)
	    {
            /* end of a block */
            addBlock(psl, qs, qe, ts, te, &blockSpace);
	    eitherInsert = TRUE;
	    }
	if (!isDelChar(q))
            qe += 1;
	if (!isDelChar(t))
            te += 1;
	}
    else
        {
        /* columns aligned */
	if (eitherInsert)
	    {
            /* start new block */
	    qs = qe;
	    ts = te;
	    eitherInsert = FALSE;
	    }
	qe += 1;
	te += 1;
	}
    accumCounts(psl, prevQ, prevT, q, t, options);
    prevQ = q; /* will not include skipped empty columns */
    prevT = t;
    }
addBlock(psl, qs, qe, ts, te, &blockSpace);
return psl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x90, %rsp
movl 0x38(%rbp), %eax
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movl 0x20(%rbp), %eax
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movq %rdi, -0x20(%rbp)
movl %esi, -0x24(%rbp)
movl %edx, -0x28(%rbp)
movl %ecx, -0x2c(%rbp)
movq %r8, -0x38(%rbp)
movq %r9, -0x40(%rbp)
movl $0x10, -0x44(%rbp)
movq $0x0, -0x50(%rbp)
movq -0x38(%rbp), %rdi
callq 0x62c0
movl %eax, -0x54(%rbp)
movl $0x0, -0x58(%rbp)
movb $0x0, -0x6d(%rbp)
movb $0x0, -0x6e(%rbp)
movl $0x88, %edi
callq 0x40c50
movq %rax, -0x50(%rbp)
movq 0x28(%rbp), %rdi
callq 0x62c0
movslq -0x54(%rbp), %rcx
cmpq %rcx, %rax
je 0x51bcf
leaq 0x8c320(%rip), %rdi     # 0xddee8
movb $0x0, %al
callq 0x35d40
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %esi
movl -0x28(%rbp), %edx
movl -0x2c(%rbp), %ecx
movq -0x40(%rbp), %r8
movl 0x10(%rbp), %r9d
movl 0x18(%rbp), %ebx
movl 0x20(%rbp), %r11d
movq 0x30(%rbp), %r10
movl -0x44(%rbp), %eax
xorl %r14d, %r14d
movl %ebx, (%rsp)
movl %r11d, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movl %eax, 0x18(%rsp)
movl $0x0, 0x20(%rsp)
callq 0x51e50
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq 0x28(%rbp), %rdx
leaq -0x54(%rbp), %rcx
callq 0x51fd0
movq -0x50(%rbp), %rax
movl 0x3c(%rax), %eax
movq -0x50(%rbp), %rcx
cmpl 0x40(%rcx), %eax
je 0x51c4c
movq -0x50(%rbp), %rax
movl 0x54(%rax), %eax
movq -0x50(%rbp), %rcx
cmpl 0x58(%rcx), %eax
jne 0x51c62
leaq -0x50(%rbp), %rdi
callq 0x4da30
movq $0x0, -0x18(%rbp)
jmp 0x51e32
movq -0x50(%rbp), %rax
movl 0x3c(%rax), %eax
movl %eax, -0x60(%rbp)
movq -0x50(%rbp), %rax
movl 0x40(%rax), %eax
movl %eax, -0x64(%rbp)
movq 0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x51c96
movq -0x50(%rbp), %rax
movl 0x38(%rax), %edx
leaq -0x60(%rbp), %rdi
leaq -0x64(%rbp), %rsi
callq 0x33350
movq -0x50(%rbp), %rax
movl 0x54(%rax), %eax
movl %eax, -0x68(%rbp)
movq -0x50(%rbp), %rax
movl 0x58(%rax), %eax
movl %eax, -0x6c(%rbp)
movq 0x30(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x2d, %eax
jne 0x51ccb
movq -0x50(%rbp), %rax
movl 0x50(%rax), %edx
leaq -0x68(%rbp), %rdi
leaq -0x6c(%rbp), %rsi
callq 0x33350
movl $0x0, -0x58(%rbp)
movl -0x60(%rbp), %eax
movl %eax, -0x64(%rbp)
movl -0x68(%rbp), %eax
movl %eax, -0x6c(%rbp)
movl $0x0, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x54(%rbp), %eax
jge 0x51e10
movq -0x38(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x6f(%rbp)
movq 0x28(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x70(%rbp)
movsbl -0x6f(%rbp), %edi
callq 0x521a0
cmpl $0x0, %eax
je 0x51d2e
movsbl -0x70(%rbp), %edi
callq 0x521a0
cmpl $0x0, %eax
je 0x51d2e
jmp 0x51e02
movsbl -0x6f(%rbp), %edi
callq 0x521a0
cmpl $0x0, %eax
jne 0x51d4a
movsbl -0x70(%rbp), %edi
callq 0x521a0
cmpl $0x0, %eax
je 0x51da1
cmpl $0x0, -0x58(%rbp)
jne 0x51d71
movq -0x50(%rbp), %rdi
movl -0x60(%rbp), %esi
movl -0x64(%rbp), %edx
movl -0x68(%rbp), %ecx
movl -0x6c(%rbp), %r8d
leaq -0x44(%rbp), %r9
callq 0x521f0
movl $0x1, -0x58(%rbp)
movsbl -0x6f(%rbp), %edi
callq 0x521a0
cmpl $0x0, %eax
jne 0x51d88
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
movsbl -0x70(%rbp), %edi
callq 0x521a0
cmpl $0x0, %eax
jne 0x51d9f
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x51dcc
cmpl $0x0, -0x58(%rbp)
je 0x51dba
movl -0x64(%rbp), %eax
movl %eax, -0x60(%rbp)
movl -0x6c(%rbp), %eax
movl %eax, -0x68(%rbp)
movl $0x0, -0x58(%rbp)
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x51dce
movq -0x50(%rbp), %rdi
movb -0x6d(%rbp), %sil
movb -0x6e(%rbp), %dl
movb -0x6f(%rbp), %cl
movb -0x70(%rbp), %al
movl 0x38(%rbp), %r9d
movsbl %sil, %esi
movsbl %dl, %edx
movsbl %cl, %ecx
movsbl %al, %r8d
callq 0x522b0
movb -0x6f(%rbp), %al
movb %al, -0x6d(%rbp)
movb -0x70(%rbp), %al
movb %al, -0x6e(%rbp)
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x51ce5
movq -0x50(%rbp), %rdi
movl -0x60(%rbp), %esi
movl -0x64(%rbp), %edx
movl -0x68(%rbp), %ecx
movl -0x6c(%rbp), %r8d
leaq -0x44(%rbp), %r9
callq 0x521f0
movq -0x50(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
addq $0x90, %rsp
popq %rbx
popq %r14
popq %rbp
retq
nopw %cs:(%rax,%rax)