// File: /workspace/github_c_makefile_star2_O2/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 0x7c0ae
movl %eax, %ecx
pushq $-0x2
popq %rax
testq %r15, %r15
je 0x7c09f
testl %ecx, %ecx
jne 0x7c09f
movq 0x38(%rbx), %r14
movl 0x30(%r14), %ebp
cmpl $0x2, %ebp
je 0x7c09f
cmpl $0x1, %ebp
jne 0x7bf51
cmpl $0x2a, 0x8(%r14)
jne 0x7c09f
cmpl $0x0, 0xb4(%r14)
jne 0x7c09f
movq 0x60(%rbx), %rdi
movq %r15, %rsi
movl %r12d, %edx
callq 0x9a764
movq %rax, 0x60(%rbx)
jmp 0x7bf5f
cmpl $0x0, 0xb4(%r14)
jne 0x7c09f
andl $0x0, 0x30(%r14)
movl 0x50(%r14), %eax
cmpl %r12d, %eax
ja 0x7bfb2
testl %ebp, %ebp
jne 0x7bfa9
movq 0x78(%r14), %rdi
movl 0x84(%r14), %edx
decl %edx
andw $0x0, (%rdi,%rdx,2)
addq %rdx, %rdx
xorl %esi, %esi
callq 0xb2f0
andl $0x0, 0xac(%r14)
andq $0x0, 0x98(%r14)
andl $0x0, 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 0x7c100
movl 0xac(%r14), %eax
movl 0xb4(%r14), %edx
cmpl $0x3, %edx
jb 0x7c054
addl $-0x2, %edx
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(%rax), %r15d
movzbl (%rsi,%r15), %r15d
xorl %r11d, %r15d
andl %edi, %r15d
movl %r15d, 0x80(%r14)
movzwl (%r8,%r15,2), %r11d
movl %r10d, %r12d
andl %eax, %r12d
movw %r11w, (%r9,%r12,2)
movw %ax, (%r8,%r15,2)
incl %eax
movl %r15d, %r11d
decl %edx
jne 0x7c006
movl %eax, 0xac(%r14)
movl $0x2, 0xb4(%r14)
jmp 0x7bfc3
addl %edx, %eax
movl %eax, 0xac(%r14)
movq %rax, 0x98(%r14)
movl %edx, 0x172c(%r14)
movabsq $0x200000000, %rax      # imm = 0x200000000
movq %rax, 0xb4(%r14)
movl $0x2, 0xa0(%r14)
andl $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