// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/external/zlib-1.3.0.1/deflate.c
// Function: deflateSetDictionary
int ZEXPORT deflateSetDictionary(z_streamp strm, const Bytef *dictionary,
                                 uInt  dictLength) {
    deflate_state *s;
    uInt str, n;
    int wrap;
    unsigned avail;
    z_const unsigned char *next;

    if (deflateStateCheck(strm) || dictionary == Z_NULL)
        return Z_STREAM_ERROR;
    s = strm->state;
    wrap = s->wrap;
    if (wrap == 2 || (wrap == 1 && s->status != INIT_STATE) || s->lookahead)
        return Z_STREAM_ERROR;

    /* when using zlib wrappers, compute Adler-32 for provided dictionary */
    if (wrap == 1)
        strm->adler = adler32(strm->adler, dictionary, dictLength);
    s->wrap = 0;                    /* avoid computing Adler-32 in read_buf */

    /* if dictionary would fill window, just replace the history */
    if (dictLength >= s->w_size) {
        if (wrap == 0) {            /* already empty otherwise */
            CLEAR_HASH(s);
            s->strstart = 0;
            s->block_start = 0L;
            s->insert = 0;
        }
        dictionary += dictLength - s->w_size;  /* use the tail */
        dictLength = s->w_size;
    }

    /* insert dictionary into window and hash */
    avail = strm->avail_in;
    next = strm->next_in;
    strm->avail_in = dictLength;
    strm->next_in = (z_const Bytef *)dictionary;
    fill_window(s);
    while (s->lookahead >= MIN_MATCH) {
        str = s->strstart;
        n = s->lookahead - (MIN_MATCH-1);
        do {
            UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]);
#ifndef FASTEST
            s->prev[str & s->w_mask] = s->head[s->ins_h];
#endif
            s->head[s->ins_h] = (Pos)str;
            str++;
        } while (--n);
        s->strstart = str;
        s->lookahead = MIN_MATCH-1;
        fill_window(s);
    }
    s->strstart += s->lookahead;
    s->block_start = (long)s->strstart;
    s->insert = s->lookahead;
    s->lookahead = 0;
    s->match_length = s->prev_length = MIN_MATCH-1;
    s->match_available = 0;
    strm->next_in = next;
    strm->avail_in = avail;
    s->wrap = wrap;
    return Z_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %r12d
movq %rsi, %r15
movq %rdi, %rbx
callq 0x9c4be
movl %eax, %ecx
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
testq %r15, %r15
je 0x9c4af
testl %ecx, %ecx
jne 0x9c4af
movq 0x38(%rbx), %r14
movl 0x30(%r14), %ebp
cmpl $0x2, %ebp
je 0x9c4af
cmpl $0x1, %ebp
jne 0x9c323
cmpl $0x2a, 0x8(%r14)
jne 0x9c4af
cmpl $0x0, 0xb4(%r14)
jne 0x9c4af
cmpl $0x1, %ebp
jne 0x9c349
movq 0x60(%rbx), %rdi
movq %r15, %rsi
movl %r12d, %edx
callq 0xb88a4
movq %rax, 0x60(%rbx)
movl $0x0, 0x30(%r14)
cmpl %r12d, 0x50(%r14)
ja 0x9c3a1
testl %ebp, %ebp
jne 0x9c394
movq 0x78(%r14), %rdi
movl 0x84(%r14), %edx
decl %edx
movw $0x0, (%rdi,%rdx,2)
addq %rdx, %rdx
xorl %r13d, %r13d
xorl %esi, %esi
callq 0xb2f0
movl %r13d, 0xac(%r14)
movq $0x0, 0x98(%r14)
movl %r13d, 0x172c(%r14)
movl 0x50(%r14), %eax
subl %eax, %r12d
addq %r12, %r15
movl %eax, %r12d
movl 0x8(%rbx), %eax
movl %eax, 0x4(%rsp)
movq (%rbx), %r13
movl %r12d, 0x8(%rbx)
movq %r15, (%rbx)
movq %r14, %rdi
callq 0x9c512
movl 0xb4(%r14), %eax
cmpl $0x3, %eax
jb 0x9c45a
movl 0xac(%r14), %edx
addl $-0x2, %eax
movl 0x90(%r14), %ecx
movq 0x60(%r14), %rsi
movl 0x8c(%r14), %edi
movq 0x78(%r14), %r8
movq 0x70(%r14), %r9
movl 0x58(%r14), %r10d
movl 0x80(%r14), %r11d
shll %cl, %r11d
leal 0x2(%rdx), %r15d
movzbl (%rsi,%r15), %r15d
xorl %r11d, %r15d
andl %edi, %r15d
movl %r15d, 0x80(%r14)
movzwl (%r8,%r15,2), %r11d
movl %r10d, %r12d
andl %edx, %r12d
movw %r11w, (%r9,%r12,2)
movw %dx, (%r8,%r15,2)
incl %edx
movl %r15d, %r11d
decl %eax
jne 0x9c3f9
movl %edx, 0xac(%r14)
movl $0x2, 0xb4(%r14)
movq %r14, %rdi
callq 0x9c512
movl 0xb4(%r14), %eax
cmpl $0x2, %eax
ja 0x9c3ca
movl 0xac(%r14), %ecx
addl %eax, %ecx
movl %ecx, 0xac(%r14)
movq %rcx, 0x98(%r14)
movl %eax, 0x172c(%r14)
movabsq $0x200000000, %rax      # imm = 0x200000000
movq %rax, 0xb4(%r14)
movl $0x2, 0xa0(%r14)
movl $0x0, 0xa8(%r14)
movq %r13, (%rbx)
movl 0x4(%rsp), %eax
movl %eax, 0x8(%rbx)
movl %ebp, 0x30(%r14)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq