Using C library 'miniz' I have two helper C++ functions for streaming compression and decompression. They work incredibly slow, can you fix them?

void ZipMiniCompress(
        std::function<std::pair<uint64_t, bool>(uint8_t * dst, uint64_t size)> stream_in,
        std::function<void(uint8_t const * dst, uint64_t size)> stream_out,
        uint64_t compression_level) {
    using namespace zip_mini_internal;
    
    std::vector<uint8_t> s_inbuf(BUF_SIZE);
    std::vector<uint8_t> s_outbuf(BUF_SIZE);

    mz_stream stream;

    // Init stream.
    MEMZERO(stream);
    stream.next_in = s_inbuf.data();
    stream.avail_in = 0;
    stream.next_out = s_outbuf.data();
    stream.avail_out = BUF_SIZE;

    MZ_CHECK(mz_deflateInit(&stream, compression_level));

    uint64_t readed_size = 0;
    bool finished = false;
    
    while (true) {
        int status = 0;

        if (!stream.avail_in) {
            std::tie(readed_size, finished) = stream_in(s_inbuf.data(), BUF_SIZE);
            stream.next_in = s_inbuf.data();
            stream.avail_in = readed_size;
            ASSERT(readed_size > 0 || finished);
        }
        
        status = mz_deflate(&stream, finished ? MZ_FINISH : MZ_NO_FLUSH);
        
        if ((status == MZ_STREAM_END) || (!stream.avail_out)) {
            // Output buffer is full, or compression is done, so write buffer to output file.
            uint32_t n = BUF_SIZE - stream.avail_out;
            stream_out(s_outbuf.data(), n);
            stream.next_out = s_outbuf.data();
            stream.avail_out = BUF_SIZE;
        }

        if (status == MZ_STREAM_END)
            break;
        else { MZ_CHECK(status); }
    }

    MZ_CHECK(mz_deflateEnd(&stream));
}

void ZipMiniDeCompress(
        std::function<std::pair<uint64_t, bool>(uint8_t * dst, uint64_t size)> stream_in,
        std::function<void(uint8_t const * dst, uint64_t size)> stream_out,
        uint64_t * compressed_size) {
    using namespace zip_mini_internal;
    
    std::vector<uint8_t> s_inbuf(BUF_SIZE);
    std::vector<uint8_t> s_outbuf(BUF_SIZE);

    mz_stream stream;

    // Init stream.
    MEMZERO(stream);
    stream.next_in = s_inbuf.data();
    stream.avail_in = 0;
    stream.next_out = s_outbuf.data();
    stream.avail_out = BUF_SIZE;
    
    MZ_CHECK(mz_inflateInit(&stream));

    uint64_t readed_size = 0, total_readed_size = 0;
    bool finished = false;
    
    while (true) {
        int status = 0;

        if (!stream.avail_in) {
            std::tie(readed_size, finished) = stream_in(s_inbuf.data(), BUF_SIZE);
            total_readed_size += readed_size;
            stream.next_in = s_inbuf.data();
            stream.avail_in = readed_size;
            ASSERT(readed_size > 0 || finished);
        }

        status = mz_inflate(&stream, MZ_SYNC_FLUSH);

        if ((status == MZ_STREAM_END) || (!stream.avail_out)) {
            // Output buffer is full, or compression is done, so write buffer to output file.
            uint32_t n = BUF_SIZE - stream.avail_out;
            stream_out(s_outbuf.data(), n);
            stream.next_out = s_outbuf.data();
            stream.avail_out = BUF_SIZE;
        }
        
        if (finished)
            { ASSERT(status == MZ_STREAM_END); }

        if (status == MZ_STREAM_END) {
            if (compressed_size)
                *compressed_size = total_readed_size - stream.avail_in;
            break;
        } else { MZ_CHECK(status); }
    }
    
    MZ_CHECK(mz_inflateEnd(&stream));
}