// File: /workspace/github_cpp_makefile_star2_O2/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, %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 0x40c8e
testl %eax, %eax
je 0x422e8
cmpq %r12, %r14
cmovaq %r14, %r12
addq $0x6, %r12
movq %r12, %r14
jmp 0x423c6
movq 0x38(%r15), %rax
movl 0x30(%rax), %edx
testq %rdx, %rdx
je 0x42372
cmpl $0x2, %edx
je 0x42314
cmpl $0x1, %edx
jne 0x42330
xorl %ecx, %ecx
cmpl $0x0, 0xac(%rax)
setne %cl
leaq 0x6(,%rcx,4), %rdx
jmp 0x42372
movq 0x38(%rax), %rcx
testq %rcx, %rcx
je 0x42334
cmpq $0x0, 0x18(%rcx)
je 0x42339
movl 0x20(%rcx), %esi
addl $0x2, %esi
addq $0x12, %rsi
jmp 0x4233c
pushq $0x6
jmp 0x42336
pushq $0x12
popq %rdx
jmp 0x42372
pushq $0x12
popq %rsi
movq 0x28(%rcx), %rdx
testq %rdx, %rdx
je 0x42351
incq %rsi
cmpb $0x0, (%rdx)
leaq 0x1(%rdx), %rdx
jne 0x42345
movq 0x38(%rcx), %rdx
testq %rdx, %rdx
je 0x42366
incq %rsi
cmpb $0x0, (%rdx)
leaq 0x1(%rdx), %rdx
jne 0x4235a
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 0x423b3
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 0x423c6
cmpl %esi, %ecx
ja 0x423c0
cmpl $0x0, 0xc4(%rax)
jne 0x423c3
movq %r12, %r14
addq %rdx, %r14
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq