// File: /workspace/github_c_makefile_star2_O3/icebert[P]pblat/lib/nib.c
// Function: nibWriteMasked
static void nibOutput(int options, struct dnaSeq *seq, char *fileName)
/* Write out file in format of four bits per nucleotide, with control over
 * handling of masked positions. */
{
UBYTE byte;
DNA *dna = seq->dna;
int dVal1, dVal2;
bits32 size = seq->size;
int byteCount = (size>>1);
bits32 sig = nibSig;
int *ntValTbl = ((options & NIB_MASK_MIXED) ? ntValMasked : ntVal5);
Bits* mask = ((options & NIB_MASK_MAP) ? seq->mask : NULL);
int maskIdx = 0;
FILE *f = mustOpen(fileName, "w");

assert(sizeof(bits32) == 4);

writeOne(f, sig);
writeOne(f, seq->size);

printf("Writing %d bases in %d bytes\n", seq->size, ((seq->size+1)/2) + 8);
while (--byteCount >= 0)
    {
    dVal1 = ntValTbl[(int)dna[0]];
    dVal2 = ntValTbl[(int)dna[1]];
    /* Set from mask, remember bit in character is opposite sense of bit
     * in mask. */
    if (mask != NULL)
        {
        if (!bitReadOne(mask, maskIdx))
            dVal1 |= MASKED_BASE_BIT;
        if (!bitReadOne(mask, maskIdx+1))
            dVal2 |= MASKED_BASE_BIT;
        maskIdx += 2;
        }
    byte = (dVal1<<4) | dVal2;
    if (putc(byte, f) < 0)
	{
	perror("");
	errAbort("Couldn't write all of %s", fileName);
	}
    dna += 2;
    }
if (size & 1)
    {
    dVal1 = ntValTbl[(int)dna[0]];
    if ((mask != NULL) && !bitReadOne(mask, maskIdx))
        dVal1 |= MASKED_BASE_BIT;
    byte = (dVal1<<4);
    putc(byte, f);
    }
carefulClose(&f);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq 0x10(%rsi), %rbp
movl 0x18(%rsi), %ebx
movl $0x6be93d3a, 0xc(%rsp)  # imm = 0x6BE93D3A
testb $0x1, %dil
jne 0x321ec
leaq 0x906a6(%rip), %rax     # 0xc2890
jmp 0x321f3
leaq 0x90a9d(%rip), %rax     # 0xc2c90
movq %rax, (%rsp)
leaq 0x18(%rsi), %r13
xorl %r12d, %r12d
testb $0x2, %dil
jne 0x32209
xorl %r15d, %r15d
jmp 0x3220d
movq 0x20(%rsi), %r15
leaq 0x5cb35(%rip), %rsi     # 0x8ed49
movq %rdx, 0x18(%rsp)
movq %rdx, %rdi
callq 0x23072
movq %rax, %r14
movq %rax, 0x20(%rsp)
leaq 0xc(%rsp), %rsi
movl $0x4, %edx
movq %rax, %rdi
callq 0x23138
movl $0x4, %edx
movq %r14, 0x10(%rsp)
movq %r14, %rdi
movq %r13, %rsi
callq 0x23138
movl (%r13), %esi
leal 0x1(%rsi), %eax
shrl $0x1f, %eax
leal (%rsi,%rax), %edx
incl %edx
sarl %edx
addl $0x8, %edx
leaq 0x60af1(%rip), %rdi     # 0x92d5c
xorl %eax, %eax
callq 0x6070
cmpl $0x2, %ebx
movl %ebx, 0x8(%rsp)
jae 0x322d1
testb $0x1, 0x8(%rsp)
je 0x322b8
movsbq (%rbp), %rax
movq (%rsp), %rcx
movl (%rcx,%rax,4), %ebx
testq %r15, %r15
je 0x322a8
movq %r15, %rdi
movl %r12d, %esi
callq 0x1bc74
movl %ebx, %ecx
orl $0x8, %ecx
testl %eax, %eax
cmovel %ecx, %ebx
shll $0x4, %ebx
movzbl %bl, %edi
movq 0x10(%rsp), %rsi
callq 0x6e50
leaq 0x20(%rsp), %rdi
callq 0x2371e
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %ebx, %r13d
shrl %r13d
incl %r13d
xorl %r12d, %r12d
movsbq (%rbp), %rax
movq (%rsp), %rcx
movl (%rcx,%rax,4), %ebx
movsbq 0x1(%rbp), %rax
movl (%rcx,%rax,4), %r14d
testq %r15, %r15
je 0x32329
movq %r15, %rdi
movl %r12d, %esi
callq 0x1bc74
movl %ebx, %ecx
orl $0x8, %ecx
testl %eax, %eax
cmovel %ecx, %ebx
leal 0x1(%r12), %esi
movq %r15, %rdi
callq 0x1bc74
movl %r14d, %ecx
orl $0x8, %ecx
testl %eax, %eax
cmovel %ecx, %r14d
addl $0x2, %r12d
shll $0x4, %ebx
orl %r14d, %ebx
movzbl %bl, %edi
movq 0x10(%rsp), %rsi
callq 0x6e50
testl %eax, %eax
js 0x32352
addq $0x2, %rbp
decl %r13d
cmpl $0x1, %r13d
ja 0x322dd
jmp 0x3227b
leaq 0x660fb(%rip), %rdi     # 0x98454
callq 0x6590
leaq 0x60a15(%rip), %rdi     # 0x92d7a
movq 0x18(%rsp), %rsi
xorl %eax, %eax
callq 0x26e94
jmp 0x32340