// File: tomfunkhouser[P]gaps/pkgs/png/deflate.c
// Function: deflateParams
int ZEXPORT deflateParams(strm, level, strategy)
    z_streamp strm;
    int level;
    int strategy;
{
    deflate_state *s;
    compress_func func;
    int err = Z_OK;

    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
    s = strm->state;

#ifdef FASTEST
    if (level != 0) level = 1;
#else
    if (level == Z_DEFAULT_COMPRESSION) level = 6;
#endif
    if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) {
        return Z_STREAM_ERROR;
    }
    func = configuration_table[s->level].func;

    if ((strategy != s->strategy || func != configuration_table[level].func) &&
        strm->total_in != 0) {
        /* Flush the last buffer: */
        err = deflate(strm, Z_BLOCK);
    }
    if (s->level != level) {
        s->level = level;
        s->max_lazy_match   = configuration_table[level].max_lazy;
        s->good_match       = configuration_table[level].good_length;
        s->nice_match       = configuration_table[level].nice_length;
        s->max_chain_length = configuration_table[level].max_chain;
    }
    s->strategy = strategy;
    return err;
}

// Assembly:
subq $0x38, %rsp
movq %rdi, 0x28(%rsp)
movl %esi, 0x24(%rsp)
movl %edx, 0x20(%rsp)
movl $0x0, 0xc(%rsp)
cmpq $0x0, 0x28(%rsp)
je 0x115aed
movq 0x28(%rsp), %rax
cmpq $0x0, 0x38(%rax)
jne 0x115afa
movl $0xfffffffe, 0x34(%rsp) # imm = 0xFFFFFFFE
jmp 0x115c73
movq 0x28(%rsp), %rax
movq 0x38(%rax), %rax
movq %rax, 0x18(%rsp)
cmpl $-0x1, 0x24(%rsp)
jne 0x115b17
movl $0x6, 0x24(%rsp)
cmpl $0x0, 0x24(%rsp)
jl 0x115b33
cmpl $0x9, 0x24(%rsp)
jg 0x115b33
cmpl $0x0, 0x20(%rsp)
jl 0x115b33
cmpl $0x4, 0x20(%rsp)
jle 0x115b40
movl $0xfffffffe, 0x34(%rsp) # imm = 0xFFFFFFFE
jmp 0x115c73
movq 0x18(%rsp), %rax
movslq 0xb4(%rax), %rcx
leaq 0x590fd(%rip), %rax     # 0x16ec50
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, 0x10(%rsp)
movl 0x20(%rsp), %eax
movq 0x18(%rsp), %rcx
cmpl 0xb8(%rcx), %eax
jne 0x115b92
movq 0x10(%rsp), %rax
movslq 0x24(%rsp), %rdx
leaq 0x590cb(%rip), %rcx     # 0x16ec50
shlq $0x4, %rdx
addq %rdx, %rcx
cmpq 0x8(%rcx), %rax
je 0x115bb1
movq 0x28(%rsp), %rax
cmpq $0x0, 0x10(%rax)
je 0x115bb1
movq 0x28(%rsp), %rdi
movl $0x5, %esi
callq 0x115c80
movl %eax, 0xc(%rsp)
movq 0x18(%rsp), %rax
movl 0xb4(%rax), %eax
cmpl 0x24(%rsp), %eax
je 0x115c5c
movl 0x24(%rsp), %ecx
movq 0x18(%rsp), %rax
movl %ecx, 0xb4(%rax)
movslq 0x24(%rsp), %rcx
leaq 0x5906f(%rip), %rax     # 0x16ec50
shlq $0x4, %rcx
addq %rcx, %rax
movzwl 0x2(%rax), %ecx
movq 0x18(%rsp), %rax
movl %ecx, 0xb0(%rax)
movslq 0x24(%rsp), %rcx
leaq 0x5904d(%rip), %rax     # 0x16ec50
shlq $0x4, %rcx
addq %rcx, %rax
movzwl (%rax), %ecx
movq 0x18(%rsp), %rax
movl %ecx, 0xbc(%rax)
movslq 0x24(%rsp), %rcx
leaq 0x5902c(%rip), %rax     # 0x16ec50
shlq $0x4, %rcx
addq %rcx, %rax
movzwl 0x4(%rax), %ecx
movq 0x18(%rsp), %rax
movl %ecx, 0xc0(%rax)
movslq 0x24(%rsp), %rcx
leaq 0x5900a(%rip), %rax     # 0x16ec50
shlq $0x4, %rcx
addq %rcx, %rax
movzwl 0x6(%rax), %ecx
movq 0x18(%rsp), %rax
movl %ecx, 0xac(%rax)
movl 0x20(%rsp), %ecx
movq 0x18(%rsp), %rax
movl %ecx, 0xb8(%rax)
movl 0xc(%rsp), %eax
movl %eax, 0x34(%rsp)
movl 0x34(%rsp), %eax
addq $0x38, %rsp
retq
nopl (%rax)