// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/zlib-1.3.0.1/gzwrite.c
// Function: gzvprintf
int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) {
    int len;
    unsigned left;
    char *next;
    gz_statep state;
    z_streamp strm;

    /* get internal structure */
    if (file == NULL)
        return Z_STREAM_ERROR;
    state = (gz_statep)file;
    strm = &(state->strm);

    /* check that we're writing and that there's no error */
    if (state->mode != GZ_WRITE || state->err != Z_OK)
        return Z_STREAM_ERROR;

    /* make sure we have some buffer space */
    if (state->size == 0 && gz_init(state) == -1)
        return state->err;

    /* check for seek request */
    if (state->seek) {
        state->seek = 0;
        if (gz_zero(state, state->skip) == -1)
            return state->err;
    }

    /* do the printf() into the input buffer, put length in len -- the input
       buffer is double-sized just for this function, so there is guaranteed to
       be state->size bytes available after the current contents */
    if (strm->avail_in == 0)
        strm->next_in = state->in;
    next = (char *)(state->in + (strm->next_in - state->in) + strm->avail_in);
    next[state->size - 1] = 0;
#ifdef NO_vsnprintf
#  ifdef HAS_vsprintf_void
    (void)vsprintf(next, format, va);
    for (len = 0; len < state->size; len++)
        if (next[len] == 0) break;
#  else
    len = vsprintf(next, format, va);
#  endif
#else
#  ifdef HAS_vsnprintf_void
    (void)vsnprintf(next, state->size, format, va);
    len = strlen(next);
#  else
    len = vsnprintf(next, state->size, format, va);
#  endif
#endif

    /* check that printf() results fit in buffer */
    if (len == 0 || (unsigned)len >= state->size || next[state->size - 1] != 0)
        return 0;

    /* update buffer and position, compress first half if past that */
    strm->avail_in += (unsigned)len;
    state->x.pos += len;
    if (strm->avail_in >= state->size) {
        left = strm->avail_in - state->size;
        strm->avail_in = state->size;
        if (gz_comp(state, Z_NO_FLUSH) == -1)
            return state->err;
        memmove(state->in, state->in + state->size, left);
        strm->next_in = state->in;
        strm->avail_in = left;
    }
    return len;
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x38(%rsp)
movq %rsi, 0x30(%rsp)
movq %rdx, 0x28(%rsp)
cmpq $0x0, 0x38(%rsp)
jne 0xcf368
movl $0xfffffffe, 0x44(%rsp) # imm = 0xFFFFFFFE
jmp 0xcf59d
movq 0x38(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
addq $0x80, %rax
movq %rax, 0x8(%rsp)
movq 0x10(%rsp), %rax
cmpl $0x79b1, 0x18(%rax)     # imm = 0x79B1
jne 0xcf39b
movq 0x10(%rsp), %rax
cmpl $0x0, 0x74(%rax)
je 0xcf3a8
movl $0xfffffffe, 0x44(%rsp) # imm = 0xFFFFFFFE
jmp 0xcf59d
movq 0x10(%rsp), %rax
cmpl $0x0, 0x28(%rax)
jne 0xcf3d3
movq 0x10(%rsp), %rdi
callq 0xcf5b0
cmpl $-0x1, %eax
jne 0xcf3d3
movq 0x10(%rsp), %rax
movl 0x74(%rax), %eax
movl %eax, 0x44(%rsp)
jmp 0xcf59d
movq 0x10(%rsp), %rax
cmpl $0x0, 0x70(%rax)
je 0xcf415
movq 0x10(%rsp), %rax
movl $0x0, 0x70(%rax)
movq 0x10(%rsp), %rdi
movq 0x10(%rsp), %rax
movq 0x68(%rax), %rsi
callq 0xcf120
cmpl $-0x1, %eax
jne 0xcf413
movq 0x10(%rsp), %rax
movl 0x74(%rax), %eax
movl %eax, 0x44(%rsp)
jmp 0xcf59d
jmp 0xcf415
movq 0x8(%rsp), %rax
cmpl $0x0, 0x8(%rax)
jne 0xcf431
movq 0x10(%rsp), %rax
movq 0x30(%rax), %rcx
movq 0x8(%rsp), %rax
movq %rcx, (%rax)
movq 0x10(%rsp), %rax
movq 0x30(%rax), %rax
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
movq 0x10(%rsp), %rdx
movq 0x30(%rdx), %rdx
subq %rdx, %rcx
addq %rcx, %rax
movq 0x8(%rsp), %rcx
movl 0x8(%rcx), %ecx
addq %rcx, %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
movq 0x10(%rsp), %rcx
movl 0x28(%rcx), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rax
movl 0x28(%rax), %eax
movl %eax, %esi
movq 0x30(%rsp), %rdx
movq 0x28(%rsp), %rcx
callq 0xb390
movl %eax, 0x24(%rsp)
cmpl $0x0, 0x24(%rsp)
je 0xcf4c9
movl 0x24(%rsp), %eax
movq 0x10(%rsp), %rcx
cmpl 0x28(%rcx), %eax
jae 0xcf4c9
movq 0x18(%rsp), %rax
movq 0x10(%rsp), %rcx
movl 0x28(%rcx), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0xcf4d6
movl $0x0, 0x44(%rsp)
jmp 0xcf59d
movl 0x24(%rsp), %ecx
movq 0x8(%rsp), %rax
addl 0x8(%rax), %ecx
movl %ecx, 0x8(%rax)
movslq 0x24(%rsp), %rcx
movq 0x10(%rsp), %rax
addq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
movq 0x8(%rsp), %rax
movl 0x8(%rax), %eax
movq 0x10(%rsp), %rcx
cmpl 0x28(%rcx), %eax
jb 0xcf595
movq 0x8(%rsp), %rax
movl 0x8(%rax), %eax
movq 0x10(%rsp), %rcx
subl 0x28(%rcx), %eax
movl %eax, 0x20(%rsp)
movq 0x10(%rsp), %rax
movl 0x28(%rax), %ecx
movq 0x8(%rsp), %rax
movl %ecx, 0x8(%rax)
movq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0xcf7a0
cmpl $-0x1, %eax
jne 0xcf550
movq 0x10(%rsp), %rax
movl 0x74(%rax), %eax
movl %eax, 0x44(%rsp)
jmp 0xcf59d
movq 0x10(%rsp), %rax
movq 0x30(%rax), %rdi
movq 0x10(%rsp), %rax
movq 0x30(%rax), %rsi
movq 0x10(%rsp), %rax
movl 0x28(%rax), %eax
addq %rax, %rsi
movl 0x20(%rsp), %eax
movl %eax, %edx
callq 0xba20
movq 0x10(%rsp), %rax
movq 0x30(%rax), %rcx
movq 0x8(%rsp), %rax
movq %rcx, (%rax)
movl 0x20(%rsp), %ecx
movq 0x8(%rsp), %rax
movl %ecx, 0x8(%rax)
movl 0x24(%rsp), %eax
movl %eax, 0x44(%rsp)
movl 0x44(%rsp), %eax
addq $0x48, %rsp
retq
nopw %cs:(%rax,%rax)