// File: /workspace/github_c_makefile_star2_O3/icebert[P]pblat/lib/twoBit.c
// Function: twoBitFromDnaSeq
struct twoBit *twoBitFromDnaSeq(struct dnaSeq *seq, boolean doMask)
/* Convert dnaSeq representation in memory to twoBit representation.
 * If doMask is true interpret lower-case letters as masked. */
{
int ubyteSize = packedSize(seq->size);
UBYTE *pt;
struct twoBit *twoBit;
DNA last4[4];	/* Holds few bases. */
DNA *dna;
int i, end;

/* Allocate structure and fill in name. */
AllocVar(twoBit);
pt = AllocArray(twoBit->data, ubyteSize);
twoBit->name = cloneString(seq->name);
twoBit->size = seq->size;

/* Convert to 4-bases per byte representation. */
dna = seq->dna;
end = seq->size - 4;
for (i=0; i<end; i += 4)
    {
    *pt++ = packDna4(dna+i);
    }

/* Take care of conversion of last few bases. */
last4[0] = last4[1] = last4[2] = last4[3] = 'T';
memcpy(last4, dna+i, seq->size-i);
*pt = packDna4(last4);

/* Deal with blocks of N. */
twoBit->nBlockCount = countBlocksOfN(dna, seq->size);
if (twoBit->nBlockCount > 0)
    {
    AllocArray(twoBit->nStarts, twoBit->nBlockCount);
    AllocArray(twoBit->nSizes, twoBit->nBlockCount);
    storeBlocksOfN(dna, seq->size, twoBit->nStarts, twoBit->nSizes);
    }

/* Deal with masking */
if (doMask)
    {
    twoBit->maskBlockCount = countBlocksOfLower(dna, seq->size);
    if (twoBit->maskBlockCount > 0)
        {
	AllocArray(twoBit->maskStarts, twoBit->maskBlockCount);
	AllocArray(twoBit->maskSizes, twoBit->maskBlockCount);
	storeBlocksOfLower(dna, seq->size, 
		twoBit->maskStarts, twoBit->maskSizes);
	}
    }
return twoBit;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, (%rsp)
movq %rdi, %r14
movl 0x18(%rdi), %ebp
addl $0x3, %ebp
sarl $0x2, %ebp
movl $0x50, %edi
callq 0x2dff4
movq %rax, %rbx
movslq %ebp, %rdi
callq 0x2de63
movq %rax, %r15
movq %rax, 0x10(%rbx)
movq 0x8(%r14), %rdi
callq 0x1feba
movq %rax, 0x8(%rbx)
movl 0x18(%r14), %r12d
movl %r12d, 0x18(%rbx)
movq 0x10(%r14), %r13
xorl %ebp, %ebp
cmpl $0x5, %r12d
jl 0x3de43
addl $-0x4, %r12d
xorl %ebp, %ebp
movq %r13, %rdi
addq %rbp, %rdi
callq 0x25a1e
movb %al, (%r15)
incq %r15
addq $0x4, %rbp
cmpl %ebp, %r12d
jg 0x3de25
movl 0x18(%r14), %r12d
movl %ebp, %esi
addq %r13, %rsi
subl %ebp, %r12d
movslq %r12d, %rdx
leaq 0x4(%rsp), %r12
movl $0x54545454, (%r12)     # imm = 0x54545454
movq %r12, %rdi
callq 0x6570
movq %r12, %rdi
callq 0x25a1e
movb %al, (%r15)
movslq 0x18(%r14), %rax
testq %rax, %rax
jle 0x3df47
xorl %edx, %edx
xorl %ecx, %ecx
xorl %esi, %esi
movb (%r13,%rdx), %dil
andb $-0x21, %dil
cmpb $0x4e, %dil
sete %dil
xorb $0x1, %sil
andb %dil, %sil
movzbl %sil, %esi
addl %esi, %ecx
incq %rdx
movl %edi, %esi
cmpq %rdx, %rax
jne 0x3de81
movl %ecx, 0x1c(%rbx)
testl %ecx, %ecx
je 0x3df56
movl %ecx, %edi
shlq $0x2, %rdi
callq 0x2de63
movq %rax, 0x20(%rbx)
movl 0x1c(%rbx), %edi
shlq $0x2, %rdi
callq 0x2de63
movq %rax, 0x28(%rbx)
movslq 0x18(%r14), %rcx
testq %rcx, %rcx
jle 0x3df56
movq 0x20(%rbx), %rdx
movq %rcx, %rsi
negq %rsi
xorl %r8d, %r8d
xorl %edi, %edi
incq %r8
movb $0x1, %r9b
movb -0x1(%r13,%r8), %r10b
andb $-0x21, %r10b
cmpb $0x4e, %r10b
jne 0x3df21
leal -0x1(%r8), %r10d
testb $0x1, %r9b
cmovnel %r10d, %edi
leaq (%rsi,%r8), %r10
incq %r10
incq %r8
xorl %r9d, %r9d
cmpq $0x1, %r10
jne 0x3def1
jmp 0x3df50
testb $0x1, %r9b
jne 0x3df3d
movl %edi, (%rdx)
addq $0x4, %rdx
movl %edi, %r9d
notl %r9d
addl %r8d, %r9d
movl %r9d, (%rax)
addq $0x4, %rax
movq %rsi, %r9
addq %r8, %r9
jne 0x3deeb
jmp 0x3df56
movl $0x0, 0x1c(%rbx)
jmp 0x3df56
movl %edi, (%rdx)
subl %edi, %ecx
movl %ecx, (%rax)
cmpl $0x0, (%rsp)
je 0x3e06b
movslq 0x18(%r14), %r12
testq %r12, %r12
jle 0x3e064
callq 0x6790
movq %rax, %r15
movq (%rax), %rcx
xorl %edx, %edx
xorl %eax, %eax
xorl %esi, %esi
movsbq (%r13,%rdx), %rdi
movzwl (%rcx,%rdi,2), %edi
movl %edi, %r8d
andl $0x200, %r8d            # imm = 0x200
shrl $0x9, %edi
testl %esi, %esi
sete %sil
andb %dil, %sil
movzbl %sil, %esi
addl %esi, %eax
incq %rdx
movl %r8d, %esi
cmpq %rdx, %r12
jne 0x3df7e
movl %eax, 0x30(%rbx)
testl %eax, %eax
je 0x3e06b
movl %eax, %edi
shlq $0x2, %rdi
callq 0x2de63
movq %rax, 0x38(%rbx)
movl 0x30(%rbx), %edi
shlq $0x2, %rdi
callq 0x2de63
movq %rax, 0x40(%rbx)
movslq 0x18(%r14), %rcx
testq %rcx, %rcx
jle 0x3e06b
movq 0x38(%rbx), %rdx
movq (%r15), %rsi
movq %rcx, %rdi
negq %rdi
movb $0x1, %r10b
xorl %r9d, %r9d
xorl %r8d, %r8d
incq %r9
movl %r8d, %r11d
negl %r11d
movsbq -0x1(%r13,%r9), %r14
testb $0x2, 0x1(%rsi,%r14,2)
jne 0x3e043
testb $0x1, %r10b
jne 0x3e02e
movl %r8d, (%rdx)
addq $0x4, %rdx
leal (%r11,%r9), %r10d
decl %r10d
movl %r10d, (%rax)
addq $0x4, %rax
leaq (%rdi,%r9), %r14
incq %r14
incq %r9
movb $0x1, %r10b
cmpq $0x1, %r14
jne 0x3e005
jmp 0x3e06b
leal -0x1(%r9), %r11d
testb $0x1, %r10b
cmovnel %r11d, %r8d
xorl %r10d, %r10d
movq %rdi, %r11
addq %r9, %r11
jne 0x3dffc
movl %r8d, (%rdx)
subl %r8d, %ecx
movl %ecx, (%rax)
jmp 0x3e06b
movl $0x0, 0x30(%rbx)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq