// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/zlib-1.3.0.1/compress.c
// Function: compress2
int ZEXPORT compress2(Bytef *dest, uLongf *destLen, const Bytef *source,
                      uLong sourceLen, int level) {
    z_stream stream;
    int err;
    const uInt max = (uInt)-1;
    uLong left;

    left = *destLen;
    *destLen = 0;

    stream.zalloc = (alloc_func)0;
    stream.zfree = (free_func)0;
    stream.opaque = (voidpf)0;

    err = deflateInit(&stream, level);
    if (err != Z_OK) return err;

    stream.next_out = dest;
    stream.avail_out = 0;
    stream.next_in = (z_const Bytef *)source;
    stream.avail_in = 0;

    do {
        if (stream.avail_out == 0) {
            stream.avail_out = left > (uLong)max ? max : (uInt)left;
            left -= stream.avail_out;
        }
        if (stream.avail_in == 0) {
            stream.avail_in = sourceLen > (uLong)max ? max : (uInt)sourceLen;
            sourceLen -= stream.avail_in;
        }
        err = deflate(&stream, sourceLen ? Z_NO_FLUSH : Z_FINISH);
    } while (err == Z_OK);

    *destLen = stream.total_out;
    deflateEnd(&stream);
    return err == Z_STREAM_END ? Z_OK : err;
}

// Assembly:
subq $0xc8, %rsp
movq %rdi, 0xb8(%rsp)
movq %rsi, 0xb0(%rsp)
movq %rdx, 0xa8(%rsp)
movq %rcx, 0xa0(%rsp)
movl %r8d, 0x9c(%rsp)
movl $0xffffffff, 0x20(%rsp) # imm = 0xFFFFFFFF
movq 0xb0(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x18(%rsp)
movq 0xb0(%rsp), %rax
movq $0x0, (%rax)
movq $0x0, 0x68(%rsp)
movq $0x0, 0x70(%rsp)
movq $0x0, 0x78(%rsp)
movl 0x9c(%rsp), %esi
leaq 0x28(%rsp), %rdi
leaq 0xa0187(%rip), %rdx     # 0x5799bb
movl $0x70, %ecx
callq 0x4de480
movl %eax, 0x24(%rsp)
cmpl $0x0, 0x24(%rsp)
je 0x4d9859
movl 0x24(%rsp), %eax
movl %eax, 0xc4(%rsp)
jmp 0x4d997e
movq 0xb8(%rsp), %rax
movq %rax, 0x40(%rsp)
movl $0x0, 0x48(%rsp)
movq 0xa8(%rsp), %rax
movq %rax, 0x28(%rsp)
movl $0x0, 0x30(%rsp)
cmpl $0x0, 0x48(%rsp)
jne 0x4d98c5
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, 0x18(%rsp)
jbe 0x4d98a1
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0x14(%rsp)
jmp 0x4d98aa
movq 0x18(%rsp), %rax
movl %eax, 0x14(%rsp)
movl 0x14(%rsp), %eax
movl %eax, 0x48(%rsp)
movl 0x48(%rsp), %eax
movl %eax, %ecx
movq 0x18(%rsp), %rax
subq %rcx, %rax
movq %rax, 0x18(%rsp)
cmpl $0x0, 0x30(%rsp)
jne 0x4d9913
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, 0xa0(%rsp)
jbe 0x4d98e6
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0x10(%rsp)
jmp 0x4d98f2
movq 0xa0(%rsp), %rax
movl %eax, 0x10(%rsp)
movl 0x10(%rsp), %eax
movl %eax, 0x30(%rsp)
movl 0x30(%rsp), %eax
movl %eax, %ecx
movq 0xa0(%rsp), %rax
subq %rcx, %rax
movq %rax, 0xa0(%rsp)
movq 0xa0(%rsp), %rcx
movl $0x4, %esi
xorl %eax, %eax
cmpq $0x0, %rcx
cmovnel %eax, %esi
leaq 0x28(%rsp), %rdi
callq 0x4dfc50
movl %eax, 0x24(%rsp)
cmpl $0x0, 0x24(%rsp)
je 0x4d9883
movq 0x50(%rsp), %rcx
movq 0xb0(%rsp), %rax
movq %rcx, (%rax)
leaq 0x28(%rsp), %rdi
callq 0x4de970
cmpl $0x1, 0x24(%rsp)
jne 0x4d996b
xorl %eax, %eax
movl %eax, 0xc(%rsp)
jmp 0x4d9973
movl 0x24(%rsp), %eax
movl %eax, 0xc(%rsp)
movl 0xc(%rsp), %eax
movl %eax, 0xc4(%rsp)
movl 0xc4(%rsp), %eax
addq $0xc8, %rsp
retq
nopl (%rax)