// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/zlib-1.3.0.1/gzread.c
// Function: gzgets
char * ZEXPORT gzgets(gzFile file, char *buf, int len) {
    unsigned left, n;
    char *str;
    unsigned char *eol;
    gz_statep state;

    /* check parameters and get internal structure */
    if (file == NULL || buf == NULL || len < 1)
        return NULL;
    state = (gz_statep)file;

    /* check that we're reading and that there's no (serious) error */
    if (state->mode != GZ_READ ||
        (state->err != Z_OK && state->err != Z_BUF_ERROR))
        return NULL;

    /* process a skip request */
    if (state->seek) {
        state->seek = 0;
        if (gz_skip(state, state->skip) == -1)
            return NULL;
    }

    /* copy output bytes up to new line or len - 1, whichever comes first --
       append a terminating zero to the string (we don't check for a zero in
       the contents, let the user worry about that) */
    str = buf;
    left = (unsigned)len - 1;
    if (left) do {
        /* assure that something is in the output buffer */
        if (state->x.have == 0 && gz_fetch(state) == -1)
            return NULL;                /* error */
        if (state->x.have == 0) {       /* end of file */
            state->past = 1;            /* read past end */
            break;                      /* return what we have */
        }

        /* look for end-of-line in current output buffer */
        n = state->x.have > left ? left : state->x.have;
        eol = (unsigned char *)memchr(state->x.next, '\n', n);
        if (eol != NULL)
            n = (unsigned)(eol - state->x.next) + 1;

        /* copy through end-of-line, or remainder if not found */
        memcpy(buf, state->x.next, n);
        state->x.have -= n;
        state->x.next += n;
        state->x.pos += n;
        left -= n;
        buf += n;
    } while (left && eol == NULL);

    /* return terminated string, or if nothing, end of file */
    if (buf == str)
        return NULL;
    buf[0] = 0;
    return str;
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x38(%rsp)
movq %rsi, 0x30(%rsp)
movl %edx, 0x2c(%rsp)
cmpq $0x0, 0x38(%rsp)
je 0xce249
cmpq $0x0, 0x30(%rsp)
je 0xce249
cmpl $0x1, 0x2c(%rsp)
jge 0xce257
movq $0x0, 0x40(%rsp)
jmp 0xce461
movq 0x38(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
cmpl $0x1c4f, 0x18(%rax)     # imm = 0x1C4F
jne 0xce285
movq 0x8(%rsp), %rax
cmpl $0x0, 0x74(%rax)
je 0xce293
movq 0x8(%rsp), %rax
cmpl $-0x5, 0x74(%rax)
je 0xce293
movq $0x0, 0x40(%rsp)
jmp 0xce461
movq 0x8(%rsp), %rax
cmpl $0x0, 0x70(%rax)
je 0xce2d2
movq 0x8(%rsp), %rax
movl $0x0, 0x70(%rax)
movq 0x8(%rsp), %rdi
movq 0x8(%rsp), %rax
movq 0x68(%rax), %rsi
callq 0xce130
cmpl $-0x1, %eax
jne 0xce2d0
movq $0x0, 0x40(%rsp)
jmp 0xce461
jmp 0xce2d2
movq 0x30(%rsp), %rax
movq %rax, 0x18(%rsp)
movl 0x2c(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x28(%rsp)
cmpl $0x0, 0x28(%rsp)
je 0xce438
jmp 0xce2f4
movq 0x8(%rsp), %rax
cmpl $0x0, (%rax)
jne 0xce31b
movq 0x8(%rsp), %rdi
callq 0xce470
cmpl $-0x1, %eax
jne 0xce31b
movq $0x0, 0x40(%rsp)
jmp 0xce461
movq 0x8(%rsp), %rax
cmpl $0x0, (%rax)
jne 0xce336
movq 0x8(%rsp), %rax
movl $0x1, 0x54(%rax)
jmp 0xce436
movq 0x8(%rsp), %rax
movl (%rax), %eax
cmpl 0x28(%rsp), %eax
jbe 0xce34d
movl 0x28(%rsp), %eax
movl %eax, 0x4(%rsp)
jmp 0xce358
movq 0x8(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x4(%rsp)
movl 0x4(%rsp), %eax
movl %eax, 0x24(%rsp)
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rdi
movl 0x24(%rsp), %eax
movl %eax, %edx
movl $0xa, %esi
callq 0xb6e0
movq %rax, 0x10(%rsp)
cmpq $0x0, 0x10(%rsp)
je 0xce39e
movq 0x10(%rsp), %rax
movq 0x8(%rsp), %rcx
movq 0x8(%rcx), %rcx
subq %rcx, %rax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
movq 0x30(%rsp), %rdi
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rsi
movl 0x24(%rsp), %eax
movl %eax, %edx
callq 0xb500
movl 0x24(%rsp), %edx
movq 0x8(%rsp), %rax
movl (%rax), %ecx
subl %edx, %ecx
movl %ecx, (%rax)
movl 0x24(%rsp), %edx
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rcx
movl %edx, %edx
addq %rdx, %rcx
movq %rcx, 0x8(%rax)
movl 0x24(%rsp), %eax
movl %eax, %ecx
movq 0x8(%rsp), %rax
addq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
movl 0x24(%rsp), %ecx
movl 0x28(%rsp), %eax
subl %ecx, %eax
movl %eax, 0x28(%rsp)
movl 0x24(%rsp), %ecx
movq 0x30(%rsp), %rax
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, 0x30(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x28(%rsp)
movb %al, 0x3(%rsp)
je 0xce42a
cmpq $0x0, 0x10(%rsp)
sete %al
movb %al, 0x3(%rsp)
movb 0x3(%rsp), %al
testb $0x1, %al
jne 0xce2f4
jmp 0xce438
movq 0x30(%rsp), %rax
cmpq 0x18(%rsp), %rax
jne 0xce44f
movq $0x0, 0x40(%rsp)
jmp 0xce461
movq 0x30(%rsp), %rax
movb $0x0, (%rax)
movq 0x18(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
addq $0x48, %rsp
retq
nopl (%rax,%rax)