// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/external/zlib-1.3.0.1/gzread.c
// Function: gzungetc
int ZEXPORT gzungetc(int c, gzFile file) {
    gz_statep state;

    /* get internal structure */
    if (file == NULL)
        return -1;
    state = (gz_statep)file;

    /* in case this was just opened, set up the input buffer */
    if (state->mode == GZ_READ && state->how == LOOK && state->x.have == 0)
        (void)gz_look(state);

    /* 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 -1;

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

    /* can't push EOF */
    if (c < 0)
        return -1;

    /* if output buffer empty, put byte at end (allows more pushing) */
    if (state->x.have == 0) {
        state->x.have = 1;
        state->x.next = state->out + (state->size << 1) - 1;
        state->x.next[0] = (unsigned char)c;
        state->x.pos--;
        state->past = 0;
        return c;
    }

    /* if no room, give up (must have already done a gzungetc()) */
    if (state->x.have == (state->size << 1)) {
        gz_error(state, Z_DATA_ERROR, "out of room to push characters");
        return -1;
    }

    /* slide output data if needed and insert byte before existing data */
    if (state->x.next == state->out) {
        unsigned char *src = state->out + state->x.have;
        unsigned char *dest = state->out + (state->size << 1);
        while (src > state->out)
            *--dest = *--src;
        state->x.next = dest;
    }
    state->x.have++;
    state->x.next--;
    state->x.next[0] = (unsigned char)c;
    state->x.pos--;
    state->past = 0;
    return c;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
testq %rsi, %rsi
je 0x9a374
movq %rsi, %r14
cmpl $0x1c4f, 0x18(%rsi)     # imm = 0x1C4F
jne 0x9a374
movl %edi, %ebx
cmpl $0x0, 0x44(%r14)
jne 0x9a317
cmpl $0x0, (%r14)
jne 0x9a317
movq %r14, %rdi
callq 0x9a3ea
cmpl $0x1c4f, 0x18(%r14)     # imm = 0x1C4F
jne 0x9a374
movl 0x74(%r14), %eax
testl %eax, %eax
je 0x9a324
cmpl $-0x5, %eax
jne 0x9a374
cmpl $0x0, 0x70(%r14)
je 0x9a34a
movl $0x0, 0x70(%r14)
movq 0x68(%r14), %rsi
movq %r14, %rdi
callq 0x9a57a
testl %ebx, %ebx
js 0x9a374
cmpl $-0x1, %eax
jne 0x9a34e
jmp 0x9a374
testl %ebx, %ebx
js 0x9a374
movl (%r14), %eax
testq %rax, %rax
je 0x9a383
movl 0x28(%r14), %edx
addl %edx, %edx
cmpl %edx, %eax
jne 0x9a3a2
leaq 0x5da71(%rip), %rdx     # 0xf7dd8
movq %r14, %rdi
movl $0xfffffffd, %esi       # imm = 0xFFFFFFFD
callq 0x99e17
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movl $0x1, (%r14)
movq 0x38(%r14), %rax
movl 0x28(%r14), %ecx
addl %ecx, %ecx
addq %rcx, %rax
decq %rax
movq %rax, 0x8(%r14)
movb %bl, (%rax)
jmp 0x9a3dc
movq 0x8(%r14), %rcx
movq 0x38(%r14), %rsi
cmpq %rsi, %rcx
jne 0x9a3cc
addq %rsi, %rax
movl %edx, %ecx
addq %rsi, %rcx
movb -0x1(%rax), %dl
decq %rax
movb %dl, -0x1(%rcx)
decq %rcx
cmpq 0x38(%r14), %rax
ja 0x9a3b7
movl (%r14), %eax
incl %eax
movl %eax, (%r14)
leaq -0x1(%rcx), %rax
movq %rax, 0x8(%r14)
movb %bl, -0x1(%rcx)
decq 0x10(%r14)
movl $0x0, 0x54(%r14)
jmp 0x9a379