// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movl 0x18(%rax), %edi
callq 0x58e40
movl %eax, -0x10(%rbp)
movl $0x50, %edi
callq 0x40c50
movq %rax, -0x20(%rbp)
movslq -0x10(%rbp), %rdi
shlq $0x0, %rdi
callq 0x409d0
movq -0x20(%rbp), %rcx
movq %rax, 0x10(%rcx)
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x2a450
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
movl 0x18(%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movl 0x18(%rax), %eax
subl $0x4, %eax
movl %eax, -0x38(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x38(%rbp), %eax
jge 0x58cf1
movq -0x30(%rbp), %rdi
movslq -0x34(%rbp), %rax
addq %rax, %rdi
callq 0x33ce0
movb %al, %cl
movq -0x18(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x18(%rbp)
movb %cl, (%rax)
movl -0x34(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x34(%rbp)
jmp 0x58cbb
movb $0x54, -0x21(%rbp)
movb $0x54, -0x22(%rbp)
movb $0x54, -0x23(%rbp)
movb $0x54, -0x24(%rbp)
leaq -0x24(%rbp), %rdi
movq -0x30(%rbp), %rsi
movslq -0x34(%rbp), %rax
addq %rax, %rsi
movq -0x8(%rbp), %rax
movl 0x18(%rax), %eax
subl -0x34(%rbp), %eax
movslq %eax, %rdx
callq 0x6570
leaq -0x24(%rbp), %rdi
callq 0x33ce0
movb %al, %cl
movq -0x18(%rbp), %rax
movb %cl, (%rax)
movq -0x30(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x18(%rax), %esi
callq 0x58e60
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x1c(%rax)
movq -0x20(%rbp), %rax
cmpl $0x0, 0x1c(%rax)
jbe 0x58db0
movq -0x20(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, %edi
shlq $0x2, %rdi
callq 0x409d0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x20(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, %edi
shlq $0x2, %rdi
callq 0x409d0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x30(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x18(%rax), %esi
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rdx
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rcx
callq 0x58ef0
cmpl $0x0, -0xc(%rbp)
je 0x58e35
movq -0x30(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x18(%rax), %esi
callq 0x58fd0
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x30(%rax)
movq -0x20(%rbp), %rax
cmpl $0x0, 0x30(%rax)
jbe 0x58e33
movq -0x20(%rbp), %rax
movl 0x30(%rax), %eax
movl %eax, %edi
shlq $0x2, %rdi
callq 0x409d0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x20(%rbp), %rax
movl 0x30(%rax), %eax
movl %eax, %edi
shlq $0x2, %rdi
callq 0x409d0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x30(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x18(%rax), %esi
movq -0x20(%rbp), %rax
movq 0x38(%rax), %rdx
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rcx
callq 0x59050
jmp 0x58e35
movq -0x20(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nop