// File: /workspace/github_c_makefile_star2_O2/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 %rbp
pushq %r14
pushq %rbx
pushq $-0x1
popq %rbp
testq %rsi, %rsi
je 0x7aa1a
movq %rsi, %r14
cmpl $0x1c4f, 0x18(%rsi)     # imm = 0x1C4F
jne 0x7aa1a
movl %edi, %ebx
cmpl $0x0, 0x44(%r14)
jne 0x7a9c2
cmpl $0x0, (%r14)
jne 0x7a9c2
movq %r14, %rdi
callq 0x7aa91
cmpl $0x1c4f, 0x18(%r14)     # imm = 0x1C4F
jne 0x7aa1a
movl 0x74(%r14), %eax
testl %eax, %eax
je 0x7a9cf
cmpl $-0x5, %eax
jne 0x7aa1a
cmpl $0x0, 0x70(%r14)
je 0x7a9f2
andl $0x0, 0x70(%r14)
movq 0x68(%r14), %rsi
movq %r14, %rdi
callq 0x7ac10
testl %ebx, %ebx
js 0x7aa1a
cmpl $-0x1, %eax
jne 0x7a9f6
jmp 0x7aa1a
testl %ebx, %ebx
js 0x7aa1a
movl (%r14), %eax
testq %rax, %rax
je 0x7aa23
movl 0x28(%r14), %ecx
addl %ecx, %ecx
cmpl %ecx, %eax
jne 0x7aa42
leaq 0x66741(%rip), %rdx     # 0xe1150
pushq $-0x3
popq %rsi
movq %r14, %rdi
callq 0x7a532
movl %ebp, %ebx
movl %ebx, %eax
popq %rbx
popq %r14
popq %rbp
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 0x7aa86
movq 0x8(%r14), %rdx
movq 0x38(%r14), %rsi
cmpq %rsi, %rdx
je 0x7aa54
movq %rdx, %rcx
jmp 0x7aa76
addq %rsi, %rax
movl %ecx, %ecx
addq %rsi, %rcx
cmpq %rdx, %rax
jbe 0x7aa73
movb -0x1(%rax), %dl
decq %rax
movb %dl, -0x1(%rcx)
decq %rcx
movq 0x38(%r14), %rdx
jmp 0x7aa5c
movl (%r14), %eax
incl %eax
movl %eax, (%r14)
leaq -0x1(%rcx), %rax
movq %rax, 0x8(%r14)
movb %bl, -0x1(%rcx)
decq 0x10(%r14)
andl $0x0, 0x54(%r14)
jmp 0x7aa1c