// File: /workspace/github_cpp_makefile_star2_O1/sisong[P]ApkDiffPatch/zlib1.3.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, %r14
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), %rbx
addq $0x4, %rbx
movq %rsi, %rax
shrq $0x5, %rax
movq %rsi, %rcx
shrq $0x7, %rcx
movq %rsi, %rdx
shrq $0xb, %rdx
addq %rsi, %rax
addq %rcx, %rax
leaq (%rdx,%rax), %r12
addq $0x7, %r12
callq 0x4b13a
testl %eax, %eax
je 0x4c376
cmpq %r12, %rbx
cmovaq %rbx, %r12
addq $0x6, %r12
movq %r12, %rbx
jmp 0x4c45b
movq 0x38(%r15), %rax
movl 0x30(%rax), %edx
testq %rdx, %rdx
je 0x4c40b
cmpl $0x2, %edx
je 0x4c3a6
cmpl $0x1, %edx
jne 0x4c3c2
xorl %ecx, %ecx
cmpl $0x0, 0xac(%rax)
setne %cl
leaq 0x6(,%rcx,4), %rdx
jmp 0x4c40b
movq 0x38(%rax), %rcx
testq %rcx, %rcx
je 0x4c3c9
cmpq $0x0, 0x18(%rcx)
je 0x4c3d0
movl 0x20(%rcx), %esi
addl $0x2, %esi
addq $0x12, %rsi
jmp 0x4c3d5
movl $0x6, %edx
jmp 0x4c40b
movl $0x12, %edx
jmp 0x4c40b
movl $0x12, %esi
movq 0x28(%rcx), %rdx
testq %rdx, %rdx
je 0x4c3ea
incq %rsi
cmpb $0x0, (%rdx)
leaq 0x1(%rdx), %rdx
jne 0x4c3de
movq 0x38(%rcx), %rdx
testq %rdx, %rdx
je 0x4c3ff
incq %rsi
cmpb $0x0, (%rdx)
leaq 0x1(%rdx), %rdx
jne 0x4c3f3
leaq 0x2(%rsi), %rdx
cmpl $0x0, 0x44(%rcx)
cmoveq %rsi, %rdx
movl 0x54(%rax), %ecx
cmpl $0xf, %ecx
jne 0x4c444
cmpl $0xf, 0x88(%rax)
jne 0x4c444
movq %r14, %rax
shrq $0xc, %rax
movq %r14, %rcx
shrq $0xe, %rcx
movq %r14, %rsi
shrq $0x19, %rsi
addq %rcx, %rsi
addq %r14, %rax
addq %rsi, %rax
leaq (%rdx,%rax), %rbx
addq $0x7, %rbx
jmp 0x4c45b
cmpl 0x88(%rax), %ecx
ja 0x4c455
cmpl $0x0, 0xc4(%rax)
jne 0x4c458
movq %r12, %rbx
addq %rdx, %rbx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq