// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/lib/nib.c
// Function: nibOutput
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
movq %rsp, %rbp
subq $0x70, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
shrl %eax
movl %eax, -0x38(%rbp)
movl $0x6be93d3a, -0x3c(%rbp) # imm = 0x6BE93D3A
movl -0x4(%rbp), %edx
andl $0x1, %edx
leaq 0xc1e5b(%rip), %rax     # 0x108cd0
leaq 0xc2254(%rip), %rcx     # 0x1090d0
cmpl $0x0, %edx
cmovneq %rcx, %rax
movq %rax, -0x48(%rbp)
movl -0x4(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x46ea0
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x68(%rbp)
jmp 0x46ea8
xorl %eax, %eax
movq %rax, -0x68(%rbp)
jmp 0x46ea8
movq -0x68(%rbp), %rax
movq %rax, -0x50(%rbp)
movl $0x0, -0x54(%rbp)
movq -0x18(%rbp), %rdi
leaq 0x91c8c(%rip), %rsi     # 0xd8b4e
callq 0x2f780
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
leaq -0x3c(%rbp), %rsi
movl $0x4, %edx
callq 0x2f8b0
movq -0x60(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x18, %rsi
movl $0x4, %edx
callq 0x2f8b0
movq -0x10(%rbp), %rax
movl 0x18(%rax), %esi
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
addl $0x1, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %edx
addl $0x8, %edx
leaq 0x95c13(%rip), %rdi     # 0xdcb2b
movb $0x0, %al
callq 0x6070
movl -0x38(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x38(%rbp)
cmpl $0x0, %eax
jl 0x46fee
movq -0x48(%rbp), %rax
movq -0x28(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x2c(%rbp)
movq -0x48(%rbp), %rax
movq -0x28(%rbp), %rcx
movsbl 0x1(%rcx), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x30(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x46fa1
movq -0x50(%rbp), %rdi
movl -0x54(%rbp), %esi
callq 0x23dc0
cmpl $0x0, %eax
jne 0x46f7b
movl -0x2c(%rbp), %eax
orl $0x8, %eax
movl %eax, -0x2c(%rbp)
movq -0x50(%rbp), %rdi
movl -0x54(%rbp), %esi
addl $0x1, %esi
callq 0x23dc0
cmpl $0x0, %eax
jne 0x46f98
movl -0x30(%rbp), %eax
orl $0x8, %eax
movl %eax, -0x30(%rbp)
movl -0x54(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x54(%rbp)
movl -0x2c(%rbp), %eax
shll $0x4, %eax
orl -0x30(%rbp), %eax
movb %al, -0x19(%rbp)
movzbl -0x19(%rbp), %edi
movq -0x60(%rbp), %rsi
callq 0x6e60
cmpl $0x0, %eax
jge 0x46fdd
leaq 0x9e440(%rip), %rdi     # 0xe5406
callq 0x6590
movq -0x18(%rbp), %rsi
leaq 0x95b73(%rip), %rdi     # 0xdcb49
movb $0x0, %al
callq 0x35d40
movq -0x28(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x28(%rbp)
jmp 0x46f1f
movl -0x34(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x47044
movq -0x48(%rbp), %rax
movq -0x28(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x2c(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x4702e
movq -0x50(%rbp), %rdi
movl -0x54(%rbp), %esi
callq 0x23dc0
cmpl $0x0, %eax
jne 0x4702e
movl -0x2c(%rbp), %eax
orl $0x8, %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
shll $0x4, %eax
movb %al, -0x19(%rbp)
movzbl -0x19(%rbp), %edi
movq -0x60(%rbp), %rsi
callq 0x6e60
leaq -0x60(%rbp), %rdi
callq 0x301d0
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)