// File: /workspace/github_c_makefile_star2_O1/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 0x9adbf
movq %rsi, %r14
movl %edi, %ebx
cmpl $0x1c4f, 0x18(%rsi)     # imm = 0x1C4F
jne 0x9ad58
cmpl $0x0, 0x44(%r14)
jne 0x9ad58
cmpl $0x0, (%r14)
jne 0x9ad58
movq %r14, %rdi
callq 0x9ae37
cmpl $0x1c4f, 0x18(%r14)     # imm = 0x1C4F
jne 0x9adbf
movl 0x74(%r14), %eax
testl %eax, %eax
je 0x9ad6f
cmpl $-0x5, %eax
jne 0x9adbf
cmpl $0x0, 0x70(%r14)
je 0x9ad95
movl $0x0, 0x70(%r14)
movq 0x68(%r14), %rsi
movq %r14, %rdi
callq 0x9afc5
testl %ebx, %ebx
js 0x9adbf
cmpl $-0x1, %eax
jne 0x9ad99
jmp 0x9adbf
testl %ebx, %ebx
js 0x9adbf
movl (%r14), %eax
testq %rax, %rax
je 0x9adce
movl 0x28(%r14), %ecx
addl %ecx, %ecx
cmpl %ecx, %eax
jne 0x9aded
leaq 0x5d0be(%rip), %rdx     # 0xf7e70
movq %r14, %rdi
movl $0xfffffffd, %esi       # imm = 0xFFFFFFFD
callq 0x9a863
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 0x9ae29
movq 0x38(%r14), %rdx
cmpq %rdx, 0x8(%r14)
jne 0x9ae17
addq %rdx, %rax
movl %ecx, %ecx
addq %rdx, %rcx
cmpq 0x38(%r14), %rax
jbe 0x9ae13
movb -0x1(%rax), %dl
decq %rax
movb %dl, -0x1(%rcx)
decq %rcx
jmp 0x9adff
movq %rcx, 0x8(%r14)
incl (%r14)
movq 0x8(%r14), %rax
leaq -0x1(%rax), %rcx
movq %rcx, 0x8(%r14)
movb %bl, -0x1(%rax)
decq 0x10(%r14)
movl $0x0, 0x54(%r14)
jmp 0x9adc4