// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/zlib-1.3.0.1/gzlib.c
// Function: gzseek64
z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence) {
    unsigned n;
    z_off64_t ret;
    gz_statep state;

    /* get internal structure and check integrity */
    if (file == NULL)
        return -1;
    state = (gz_statep)file;
    if (state->mode != GZ_READ && state->mode != GZ_WRITE)
        return -1;

    /* check that there's no error */
    if (state->err != Z_OK && state->err != Z_BUF_ERROR)
        return -1;

    /* can only seek from start or relative to current position */
    if (whence != SEEK_SET && whence != SEEK_CUR)
        return -1;

    /* normalize offset to a SEEK_CUR specification */
    if (whence == SEEK_SET)
        offset -= state->x.pos;
    else if (state->seek)
        offset += state->skip;
    state->seek = 0;

    /* if within raw area while reading, just go there */
    if (state->mode == GZ_READ && state->how == COPY &&
            state->x.pos + offset >= 0) {
        ret = LSEEK(state->fd, offset - (z_off64_t)state->x.have, SEEK_CUR);
        if (ret == -1)
            return -1;
        state->x.have = 0;
        state->eof = 0;
        state->past = 0;
        state->seek = 0;
        gz_error(state, Z_OK, NULL);
        state->strm.avail_in = 0;
        state->x.pos += offset;
        return state->x.pos;
    }

    /* calculate skip amount, rewinding if needed for back seek when reading */
    if (offset < 0) {
        if (state->mode != GZ_READ)         /* writing -- can't go backwards */
            return -1;
        offset += state->x.pos;
        if (offset < 0)                     /* before start of file! */
            return -1;
        if (gzrewind(file) == -1)           /* rewind, then skip to offset */
            return -1;
    }

    /* if reading, skip what's in output buffer (one less gzgetc() check) */
    if (state->mode == GZ_READ) {
        n = GT_OFF(state->x.have) || (z_off64_t)state->x.have > offset ?
            (unsigned)offset : state->x.have;
        state->x.have -= n;
        state->x.next += n;
        state->x.pos += n;
        offset -= n;
    }

    /* request skip (if not zero) */
    if (offset) {
        state->seek = 1;
        state->skip = offset;
    }
    return state->x.pos + offset;
}

// Assembly:
subq $0x38, %rsp
movq %rdi, 0x28(%rsp)
movq %rsi, 0x20(%rsp)
movl %edx, 0x1c(%rsp)
cmpq $0x0, 0x28(%rsp)
jne 0xcce78
movq $-0x1, 0x30(%rsp)
jmp 0xcd145
movq 0x28(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
cmpl $0x1c4f, 0x18(%rax)     # imm = 0x1C4F
je 0xcceac
movq 0x8(%rsp), %rax
cmpl $0x79b1, 0x18(%rax)     # imm = 0x79B1
je 0xcceac
movq $-0x1, 0x30(%rsp)
jmp 0xcd145
movq 0x8(%rsp), %rax
cmpl $0x0, 0x74(%rax)
je 0xcced0
movq 0x8(%rsp), %rax
cmpl $-0x5, 0x74(%rax)
je 0xcced0
movq $-0x1, 0x30(%rsp)
jmp 0xcd145
cmpl $0x0, 0x1c(%rsp)
je 0xcceec
cmpl $0x1, 0x1c(%rsp)
je 0xcceec
movq $-0x1, 0x30(%rsp)
jmp 0xcd145
cmpl $0x0, 0x1c(%rsp)
jne 0xccf0b
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rcx
movq 0x20(%rsp), %rax
subq %rcx, %rax
movq %rax, 0x20(%rsp)
jmp 0xccf2b
movq 0x8(%rsp), %rax
cmpl $0x0, 0x70(%rax)
je 0xccf29
movq 0x8(%rsp), %rax
movq 0x68(%rax), %rax
addq 0x20(%rsp), %rax
movq %rax, 0x20(%rsp)
jmp 0xccf2b
movq 0x8(%rsp), %rax
movl $0x0, 0x70(%rax)
movq 0x8(%rsp), %rax
cmpl $0x1c4f, 0x18(%rax)     # imm = 0x1C4F
jne 0xcd01f
movq 0x8(%rsp), %rax
cmpl $0x1, 0x44(%rax)
jne 0xcd01f
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rax
addq 0x20(%rsp), %rax
cmpq $0x0, %rax
jl 0xcd01f
movq 0x8(%rsp), %rax
movl 0x1c(%rax), %edi
movq 0x20(%rsp), %rsi
movq 0x8(%rsp), %rax
movl (%rax), %eax
subq %rax, %rsi
movl $0x1, %edx
callq 0xb550
movq %rax, 0x10(%rsp)
cmpq $-0x1, 0x10(%rsp)
jne 0xccfac
movq $-0x1, 0x30(%rsp)
jmp 0xcd145
movq 0x8(%rsp), %rax
movl $0x0, (%rax)
movq 0x8(%rsp), %rax
movl $0x0, 0x50(%rax)
movq 0x8(%rsp), %rax
movl $0x0, 0x54(%rax)
movq 0x8(%rsp), %rax
movl $0x0, 0x70(%rax)
movq 0x8(%rsp), %rdi
xorl %esi, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0xcd150
movq 0x8(%rsp), %rax
movl $0x0, 0x88(%rax)
movq 0x20(%rsp), %rcx
movq 0x8(%rsp), %rax
addq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x30(%rsp)
jmp 0xcd145
cmpq $0x0, 0x20(%rsp)
jge 0xcd08b
movq 0x8(%rsp), %rax
cmpl $0x1c4f, 0x18(%rax)     # imm = 0x1C4F
je 0xcd043
movq $-0x1, 0x30(%rsp)
jmp 0xcd145
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rax
addq 0x20(%rsp), %rax
movq %rax, 0x20(%rsp)
cmpq $0x0, 0x20(%rsp)
jge 0xcd06c
movq $-0x1, 0x30(%rsp)
jmp 0xcd145
movq 0x28(%rsp), %rdi
callq 0xccd40
cmpl $-0x1, %eax
jne 0xcd089
movq $-0x1, 0x30(%rsp)
jmp 0xcd145
jmp 0xcd08b
movq 0x8(%rsp), %rax
cmpl $0x1c4f, 0x18(%rax)     # imm = 0x1C4F
jne 0xcd110
movq 0x8(%rsp), %rax
movl (%rax), %eax
cmpq 0x20(%rsp), %rax
jle 0xcd0b2
movq 0x20(%rsp), %rax
movl %eax, 0x4(%rsp)
jmp 0xcd0bd
movq 0x8(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x4(%rsp)
movl 0x4(%rsp), %eax
movl %eax, 0x18(%rsp)
movl 0x18(%rsp), %edx
movq 0x8(%rsp), %rax
movl (%rax), %ecx
subl %edx, %ecx
movl %ecx, (%rax)
movl 0x18(%rsp), %edx
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rcx
movl %edx, %edx
addq %rdx, %rcx
movq %rcx, 0x8(%rax)
movl 0x18(%rsp), %eax
movl %eax, %ecx
movq 0x8(%rsp), %rax
addq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
movl 0x18(%rsp), %eax
movl %eax, %ecx
movq 0x20(%rsp), %rax
subq %rcx, %rax
movq %rax, 0x20(%rsp)
cmpq $0x0, 0x20(%rsp)
je 0xcd132
movq 0x8(%rsp), %rax
movl $0x1, 0x70(%rax)
movq 0x20(%rsp), %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x68(%rax)
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rax
addq 0x20(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rax
addq $0x38, %rsp
retq
nop