// File: /workspace/github_c_makefile_star2_O0/nh13[P]ksw/src/parasail/src/io.c
// Function: parasail_pack_fasta_buffer
char * parasail_pack_fasta_buffer(const char *T, off_t size, long * packed_size)
{
    parasail_file_stat_t *pfs = NULL;
    off_t i = 0;
    off_t w = 0;
    char *P = NULL;

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

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

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

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

    /* first line is always first sequence ID */
    if (T[i] != '>') {
        fprintf(stderr, "parasail_pack_fasta_buffer: "
                "poorly formatted FASTA file\n");
        free(P);
        return NULL;
    }

    i = skip_line(T, i);
    ++i;

    /* read rest of file */
    while (i<size) {
        if (T[i] == '>') {
            /* encountered a new sequence */
            P[w++] = '$';
            i = skip_line(T, i);
        }
        else if (isalpha(T[i])) {
            P[w++] = T[i];
        }
        else if (T[i] == '\n' || T[i] == '\r') {
            /* ignore newline */
            /* for the case of "\r\n" or "\n\r" */
            if (i+1<size && (T[i+1] == '\n' || T[i+1] == '\r')) {
                ++i;
            }
        }
        else if (isprint(T[i])) {
            fprintf(stderr, "parasail_pack_fasta_buffer: "
                    "non-alpha character ('%c')\n", T[i]);
            free(P);
            return NULL;
        }
        else {
            fprintf(stderr, "parasail_pack_fasta_buffer: "
                    "non-printing character ('%d')\n", T[i]);
            free(P);
            return NULL;
        }
        ++i;
    }

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
xorl %eax, %eax
cmpq -0x10(%rbp), %rax
jne 0x1f5711
movq 0xc2c8e5(%rip), %rax    # 0xe21fd8
movq (%rax), %rdi
leaq 0xb0ca55(%rip), %rsi    # 0xd02152
movb $0x0, %al
callq 0x1f01f0
movq $0x0, -0x8(%rbp)
jmp 0x1f5a20
xorl %eax, %eax
cmpq -0x20(%rbp), %rax
jne 0x1f573e
movq 0xc2c8b8(%rip), %rax    # 0xe21fd8
movq (%rax), %rdi
leaq 0xb0ca52(%rip), %rsi    # 0xd0217c
movb $0x0, %al
callq 0x1f01f0
movq $0x0, -0x8(%rbp)
jmp 0x1f5a20
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x1f4810
movq %rax, -0x28(%rbp)
xorl %eax, %eax
cmpq -0x28(%rbp), %rax
jne 0x1f577c
movq 0xc2c87a(%rip), %rax    # 0xe21fd8
movq (%rax), %rdi
leaq 0xb0ca43(%rip), %rsi    # 0xd021ab
movb $0x0, %al
callq 0x1f01f0
movq $0x0, -0x8(%rbp)
jmp 0x1f5a20
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x28(%rbp), %rax
addq (%rax), %rdi
addq $0x1, %rdi
shlq $0x0, %rdi
callq 0x1f01c0
movq %rax, -0x40(%rbp)
xorl %eax, %eax
cmpq -0x40(%rbp), %rax
jne 0x1f57de
leaq 0xb0c3c4(%rip), %rdi    # 0xd01b6f
callq 0x1f0120
movq 0xc2c821(%rip), %rax    # 0xe21fd8
movq (%rax), %rdi
leaq 0xb0ca19(%rip), %rsi    # 0xd021da
movb $0x0, %al
callq 0x1f01f0
movq -0x28(%rbp), %rdi
callq 0x1f01a0
movq $0x0, -0x8(%rbp)
jmp 0x1f5a20
movq -0x28(%rbp), %rdi
callq 0x1f01a0
movq -0x10(%rbp), %rax
movq -0x30(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x3e, %eax
je 0x1f5826
movq 0xc2c7d9(%rip), %rax    # 0xe21fd8
movq (%rax), %rdi
leaq 0xb0c9fc(%rip), %rsi    # 0xd02205
movb $0x0, %al
callq 0x1f01f0
movq -0x40(%rbp), %rdi
callq 0x1f01a0
movq $0x0, -0x8(%rbp)
jmp 0x1f5a20
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x1f5000
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x18(%rbp), %rax
jge 0x1f59ea
movq -0x10(%rbp), %rax
movq -0x30(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x3e, %eax
jne 0x1f588f
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x38(%rbp)
movb $0x24, (%rax,%rcx)
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x1f5000
movq %rax, -0x30(%rbp)
jmp 0x1f59d9
callq 0x1f0170
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movq -0x30(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
je 0x1f58da
movq -0x10(%rbp), %rax
movq -0x30(%rbp), %rcx
movb (%rax,%rcx), %dl
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x38(%rbp)
movb %dl, (%rax,%rcx)
jmp 0x1f59d7
movq -0x10(%rbp), %rax
movq -0x30(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
je 0x1f58fc
movq -0x10(%rbp), %rax
movq -0x30(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xd, %eax
jne 0x1f593f
movq -0x30(%rbp), %rax
addq $0x1, %rax
cmpq -0x18(%rbp), %rax
jge 0x1f593a
movq -0x10(%rbp), %rax
movq -0x30(%rbp), %rcx
movsbl 0x1(%rax,%rcx), %eax
cmpl $0xa, %eax
je 0x1f592e
movq -0x10(%rbp), %rax
movq -0x30(%rbp), %rcx
movsbl 0x1(%rax,%rcx), %eax
cmpl $0xd, %eax
jne 0x1f593a
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x1f59d5
callq 0x1f0170
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movq -0x30(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x4000, %eax           # imm = 0x4000
cmpl $0x0, %eax
je 0x1f599e
movq 0xc2c66d(%rip), %rax    # 0xe21fd8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq -0x30(%rbp), %rcx
movsbl (%rax,%rcx), %edx
leaq 0xb0c8bd(%rip), %rsi    # 0xd0223e
movb $0x0, %al
callq 0x1f01f0
movq -0x40(%rbp), %rdi
callq 0x1f01a0
movq $0x0, -0x8(%rbp)
jmp 0x1f5a20
movq 0xc2c633(%rip), %rax    # 0xe21fd8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq -0x30(%rbp), %rcx
movsbl (%rax,%rcx), %edx
leaq 0xb0c8bb(%rip), %rsi    # 0xd02276
movb $0x0, %al
callq 0x1f01f0
movq -0x40(%rbp), %rdi
callq 0x1f01a0
movq $0x0, -0x8(%rbp)
jmp 0x1f5a20
jmp 0x1f59d7
jmp 0x1f59d9
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x1f5843
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x38(%rbp)
movb $0x24, (%rax,%rcx)
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq -0x38(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)