// File: /workspace/github_c_makefile_star2_O3/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 0x25219f
movq %rdx, %r14
testq %rdx, %rdx
je 0x2521a6
movq %rsi, %r15
movq %rdi, %r12
callq 0x251910
testq %rax, %rax
je 0x2521ad
movq %rax, %r13
movq (%rax), %rax
movq 0x8(%r13), %rcx
leaq (%rcx,%rax), %rdi
incq %rdi
callq 0x1f01f0
testq %rax, %rax
je 0x2521b4
movq %rax, %rbx
movq %r13, %rdi
callq 0x1f01c0
testq %r15, %r15
jle 0x25218f
xorl %edx, %edx
xorl %eax, %eax
xorl %ecx, %ecx
xorl %esi, %esi
cmpb $0x40, (%r12,%rcx)
jne 0x2521be
testb $0x1, %sil
je 0x2520a6
movb $0x24, (%rbx,%rax)
incq %rax
movb $0x40, %sil
cmpb $0xa, %sil
je 0x2520c2
movzbl %sil, %esi
cmpl $0xd, %esi
je 0x2520c2
movb 0x1(%r12,%rcx), %sil
incq %rcx
jmp 0x2520a9
leaq 0x1(%rcx), %rsi
movzbl 0x1(%r12,%rcx), %edi
cmpl $0xa, %edi
je 0x2520d9
cmpl $0xd, %edi
je 0x2520d9
movq %rcx, %rsi
addq $0x2, %rsi
movzbl -0x1(%r12,%rsi), %ecx
cmpl $0xa, %ecx
je 0x2520f8
cmpl $0xd, %ecx
je 0x2520f8
movb %cl, (%rbx,%rax)
incq %rax
incq %rsi
jmp 0x2520dd
leaq -0x1(%rsi), %rcx
cmpq %r15, %rsi
jge 0x252110
movzbl (%r12,%rsi), %edi
cmpl $0xa, %edi
je 0x252113
cmpl $0xd, %edi
je 0x252113
movq %rcx, %rsi
cmpb $0x2b, 0x1(%rsi,%r12)
jne 0x2521e0
addq $0x2, %rsi
movb $0x2b, %dil
movq %rsi, %rcx
cmpb $0xa, %dil
je 0x252141
movzbl %dil, %esi
cmpl $0xd, %esi
je 0x252141
movb (%r12,%rcx), %dil
incq %rcx
jmp 0x252129
movzbl (%r12,%rcx), %esi
cmpl $0xa, %esi
je 0x252153
cmpl $0xd, %esi
je 0x252153
decq %rcx
incq %rcx
movzbl (%r12,%rcx), %esi
incq %rcx
cmpl $0xd, %esi
je 0x252168
cmpl $0xa, %esi
jne 0x252156
movzbl (%r12,%rcx), %esi
cmpl $0xa, %esi
je 0x25217a
cmpl $0xd, %esi
je 0x25217a
decq %rcx
incq %rcx
addq $0x4, %rdx
movb $0x1, %sil
cmpq %r15, %rcx
jl 0x25208e
jmp 0x252191
xorl %eax, %eax
movw $0x24, (%rbx,%rax)
incq %rax
movq %rax, (%r14)
jmp 0x2521ed
callq 0x1f0c00
jmp 0x2521eb
callq 0x1f0be4
jmp 0x2521eb
callq 0x1f0bc8
jmp 0x2521eb
movq %r13, %rdi
callq 0x1f0b93
jmp 0x2521eb
movq 0x58fe13(%rip), %rax    # 0x7e1fd8
movq (%rax), %rdi
leaq 0x3fb1b8(%rip), %rsi    # 0x64d387
xorl %eax, %eax
callq 0x1f0220
movq %rbx, %rdi
callq 0x1f01c0
jmp 0x2521eb
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