// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/zlib-1.3.0.1/deflate.c
// Function: deflateBound
uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen) {
    deflate_state *s;
    uLong fixedlen, storelen, wraplen;

    /* upper bound for fixed blocks with 9-bit literals and length 255
       (memLevel == 2, which is the lowest that may not use stored blocks) --
       ~13% overhead plus a small constant */
    fixedlen = sourceLen + (sourceLen >> 3) + (sourceLen >> 8) +
               (sourceLen >> 9) + 4;

    /* upper bound for stored blocks with length 127 (memLevel == 1) --
       ~4% overhead plus a small constant */
    storelen = sourceLen + (sourceLen >> 5) + (sourceLen >> 7) +
               (sourceLen >> 11) + 7;

    /* if can't get parameters, return larger bound plus a zlib wrapper */
    if (deflateStateCheck(strm))
        return (fixedlen > storelen ? fixedlen : storelen) + 6;

    /* compute wrapper length */
    s = strm->state;
    switch (s->wrap) {
    case 0:                                 /* raw deflate */
        wraplen = 0;
        break;
    case 1:                                 /* zlib wrapper */
        wraplen = 6 + (s->strstart ? 4 : 0);
        break;
#ifdef GZIP
    case 2:                                 /* gzip wrapper */
        wraplen = 18;
        if (s->gzhead != Z_NULL) {          /* user-supplied gzip header */
            Bytef *str;
            if (s->gzhead->extra != Z_NULL)
                wraplen += 2 + s->gzhead->extra_len;
            str = s->gzhead->name;
            if (str != Z_NULL)
                do {
                    wraplen++;
                } while (*str++);
            str = s->gzhead->comment;
            if (str != Z_NULL)
                do {
                    wraplen++;
                } while (*str++);
            if (s->gzhead->hcrc)
                wraplen += 2;
        }
        break;
#endif
    default:                                /* for compiler happiness */
        wraplen = 6;
    }

    /* if not default parameters, return one of the conservative bounds */
    if (s->w_bits != 15 || s->hash_bits != 8 + 7)
        return (s->w_bits <= s->hash_bits && s->level ? fixedlen : storelen) +
               wraplen;

    /* default settings: return tight bound for that case -- ~0.03% overhead
       plus a small constant */
    return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
           (sourceLen >> 25) + 13 - 6 + wraplen;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r15
movq %rsi, %rax
shrq $0x3, %rax
movq %rsi, %rcx
shrq $0x8, %rcx
movq %rsi, %rdx
shrq $0x9, %rdx
addq %rsi, %rax
addq %rcx, %rax
leaq (%rdx,%rax), %r14
addq $0x4, %r14
movq %rsi, %rax
shrq $0x5, %rax
movq %rsi, %rcx
shrq $0x7, %rcx
movq %rsi, %rdx
shrq $0xb, %rdx
addq %rcx, %rdx
leaq (%rsi,%rax), %r12
addq $0x7, %r12
addq %rdx, %r12
callq 0x7c0ae
testl %eax, %eax
je 0x7d6e2
cmpq %r12, %r14
cmovaq %r14, %r12
addq $0x6, %r12
movq %r12, %r14
jmp 0x7d7c0
movq 0x38(%r15), %rax
movl 0x30(%rax), %edx
testq %rdx, %rdx
je 0x7d76c
cmpl $0x2, %edx
je 0x7d70e
cmpl $0x1, %edx
jne 0x7d72a
xorl %ecx, %ecx
cmpl $0x0, 0xac(%rax)
setne %cl
leaq 0x6(,%rcx,4), %rdx
jmp 0x7d76c
movq 0x38(%rax), %rcx
testq %rcx, %rcx
je 0x7d72e
cmpq $0x0, 0x18(%rcx)
je 0x7d733
movl 0x20(%rcx), %esi
addl $0x2, %esi
addq $0x12, %rsi
jmp 0x7d736
pushq $0x6
jmp 0x7d730
pushq $0x12
popq %rdx
jmp 0x7d76c
pushq $0x12
popq %rsi
movq 0x28(%rcx), %rdx
testq %rdx, %rdx
je 0x7d74b
incq %rsi
cmpb $0x0, (%rdx)
leaq 0x1(%rdx), %rdx
jne 0x7d73f
movq 0x38(%rcx), %rdx
testq %rdx, %rdx
je 0x7d760
incq %rsi
cmpb $0x0, (%rdx)
leaq 0x1(%rdx), %rdx
jne 0x7d754
leaq 0x2(%rsi), %rdx
cmpl $0x0, 0x44(%rcx)
cmoveq %rsi, %rdx
movl 0x54(%rax), %ecx
movl 0x88(%rax), %esi
movl %ecx, %edi
xorl $0xf, %edi
movl %esi, %r8d
xorl $0xf, %r8d
orl %edi, %r8d
jne 0x7d7ad
leaq 0x7(%rbx), %rax
movq %rbx, %rcx
shrq $0xc, %rcx
addq %rax, %rcx
movq %rbx, %rax
shrq $0xe, %rax
shrq $0x19, %rbx
addq %rax, %rbx
addq %rcx, %rbx
addq %rdx, %rbx
movq %rbx, %r14
jmp 0x7d7c0
cmpl %esi, %ecx
ja 0x7d7ba
cmpl $0x0, 0xc4(%rax)
jne 0x7d7bd
movq %r12, %r14
addq %rdx, %r14
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq