// File: /workspace/github_c_makefile_star2_O1/nh13[P]ksw/src/parasail/src/io.c
// Function: parasail_pack_fastq_buffer
char * parasail_pack_fastq_buffer(const char *T, off_t size, long * packed_size)
{
    char *P = NULL;
    int first = 1;
    off_t i = 0;
    off_t w = 0;
    unsigned long line = 0;
    parasail_file_stat_t *pfs = NULL;

    if (NULL == T) {
        fprintf(stderr, "parasail_pack_fastq_buffer: NULL pointer\n");
        return NULL;
    }

    if (NULL == packed_size) {
        fprintf(stderr, "parasail_pack_fastq_buffer: NULL size pointer\n");
        return NULL;
    }

    pfs = parasail_stat_fastq_buffer(T, size);
    if (NULL == pfs) {
        fprintf(stderr, "parasail_stat_fastq_buffer: fastq stat failed\n");
        return NULL;
    }

    P = (char*)malloc(sizeof(char) * (pfs->characters+pfs->sequences+1));
    if (NULL == P) {
        perror("malloc");
        fprintf(stderr, "parasail_pack_fastq_buffer: malloc failed\n");
        free(pfs);
        return NULL;
    }
    free(pfs);

    /* read file */
    while (i<size) {
        if (T[i] != '@') {
            fprintf(stderr, "parasail_pack_fastq_buffer: "
                    "poorly formatted FASTQ file, line %lu\n", line);
            free(P);
            return NULL;
        }

        /* encountered a new sequence */
        if (first) {
            first = 0;
        }
        else {
            P[w++] = '$';
        }

        i = skip_line(T, i);

        /* go to next line */
        ++i;
        ++line;

        /* rest of next line is the sequence */
        while (T[i] != '\n' && T[i] != '\r') {
            P[w++] = T[i];
            ++i;
        }

        /* for the case of "\r\n" or "\n\r" */
        if (i+1<size && (T[i+1] == '\n' || T[i+1] == '\r')) {
            ++i;
        }

        /* go to next line */
        ++i;
        ++line;

        if (T[i] != '+') {
            fprintf(stderr, "parasail_pack_fastq_buffer: "
                    "poorly formatted FASTQ file, line %lu\n", line);
            free(P);
            return NULL;
        }

        i = skip_line(T, i);

        /* go to next line */
        ++i;
        ++line;

        /* rest of next line are the quality control values */
        i = skip_line(T, i);

        /* go to next line */
        ++i;
        ++line;
    }

    P[w++] = '$';
    P[w] = '\0';
    *packed_size = w;
    return P;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
testq %rdi, %rdi
je 0x251fdd
movq %rdx, %r14
testq %rdx, %rdx
je 0x251fe4
movq %rsi, %r15
movq %rdi, %r12
callq 0x25177a
testq %rax, %rax
je 0x251feb
movq %rax, %r13
movq (%rax), %rax
movq 0x8(%r13), %rcx
leaq (%rcx,%rax), %rdi
incq %rdi
callq 0x1f01f0
testq %rax, %rax
je 0x251ff2
movq %rax, %rbx
movq %r13, %rdi
callq 0x1f01c0
testq %r15, %r15
jle 0x251fcd
xorl %edx, %edx
xorl %eax, %eax
xorl %ecx, %ecx
xorl %esi, %esi
cmpb $0x40, (%r12,%rcx)
jne 0x251ffc
testb $0x1, %sil
je 0x251ef7
movb $0x24, (%rbx,%rax)
incq %rax
jmp 0x251ef7
incq %rcx
movzbl (%r12,%rcx), %esi
cmpl $0xa, %esi
je 0x251f06
cmpl $0xd, %esi
jne 0x251ef4
leaq 0x1(%rcx), %rsi
movzbl 0x1(%r12,%rcx), %edi
cmpl $0xa, %edi
je 0x251f1d
cmpl $0xd, %edi
je 0x251f1d
movq %rcx, %rsi
addq $0x2, %rsi
movzbl -0x1(%r12,%rsi), %ecx
cmpl $0xa, %ecx
je 0x251f3c
cmpl $0xd, %ecx
je 0x251f3c
movb %cl, (%rbx,%rax)
incq %rax
incq %rsi
jmp 0x251f21
leaq -0x1(%rsi), %rcx
cmpq %r15, %rsi
jge 0x251f54
movzbl (%r12,%rsi), %edi
cmpl $0xa, %edi
je 0x251f57
cmpl $0xd, %edi
je 0x251f57
movq %rcx, %rsi
cmpb $0x2b, 0x1(%rsi,%r12)
jne 0x25201e
addq $0x2, %rsi
movq %rsi, %rcx
movzbl -0x1(%r12,%rcx), %esi
cmpl $0xa, %esi
je 0x251f7f
cmpl $0xd, %esi
je 0x251f7f
incq %rcx
jmp 0x251f6a
movzbl (%r12,%rcx), %esi
cmpl $0xa, %esi
je 0x251f91
cmpl $0xd, %esi
je 0x251f91
decq %rcx
incq %rcx
movzbl (%r12,%rcx), %esi
incq %rcx
cmpl $0xd, %esi
je 0x251fa6
cmpl $0xa, %esi
jne 0x251f94
movzbl (%r12,%rcx), %esi
cmpl $0xa, %esi
je 0x251fb8
cmpl $0xd, %esi
je 0x251fb8
decq %rcx
incq %rcx
addq $0x4, %rdx
movb $0x1, %sil
cmpq %r15, %rcx
jl 0x251eda
jmp 0x251fcf
xorl %eax, %eax
movw $0x24, (%rbx,%rax)
incq %rax
movq %rax, (%r14)
jmp 0x25202b
callq 0x1f0c00
jmp 0x252029
callq 0x1f0be4
jmp 0x252029
callq 0x1f0bc8
jmp 0x252029
movq %r13, %rdi
callq 0x1f0b93
jmp 0x252029
movq 0x55afd5(%rip), %rax    # 0x7acfd8
movq (%rax), %rdi
leaq 0x3c837a(%rip), %rsi    # 0x61a387
xorl %eax, %eax
callq 0x1f0220
movq %rbx, %rdi
callq 0x1f01c0
jmp 0x252029
movq %rdx, %rdi
movq %rbx, %rsi
callq 0x1f0b67
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq