static inline int retry_transfer_wrapper(URLContext *h, unsigned char *buf, int size, int size_min,

                                         int (*transfer_func)(URLContext *h, unsigned char *buf, int size))

{

    int ret, len;

    int fast_retries = 5;

    int64_t wait_since = 0;



    len = 0;

    while (len < size_min) {

        ret = transfer_func(h, buf+len, size-len);

        if (ret == AVERROR(EINTR))

            continue;

        if (h->flags & AVIO_FLAG_NONBLOCK)

            return ret;

        if (ret == AVERROR(EAGAIN)) {

            ret = 0;

            if (fast_retries) {

                fast_retries--;

            } else {

                if (h->rw_timeout) {

                    if (!wait_since)

                        wait_since = av_gettime();

                    else if (av_gettime() > wait_since + h->rw_timeout)

                        return AVERROR(EIO);

                }

                av_usleep(1000);

            }

        } else if (ret < 1)

            return (ret < 0 && ret != AVERROR_EOF) ? ret : len;

        if (ret)

           fast_retries = FFMAX(fast_retries, 2);

        len += ret;

        if (len < size && ff_check_interrupt(&h->interrupt_callback))

            return AVERROR_EXIT;

    }

    return len;

}

static inline int retry_transfer_wrapper(URLContext *h, unsigned char *buf, int size, int size_min,

                                         int (*transfer_func)(URLContext *h, unsigned char *buf, int size))

{

    int ret, len;

    int fast_retries = 5;

    int64_t wait_since = 0;



    len = 0;

    while (len < size_min) {

        ret = transfer_func(h, buf+len, size-len);

        if (ret == AVERROR(EINTR))

            continue;

        if (h->flags & AVIO_FLAG_NONBLOCK)

            return ret;

        if (ret == AVERROR(EAGAIN)) {

            ret = 0;

            if (fast_retries) {

                fast_retries--;

            } else {

                if (h->rw_timeout) {

                    if (!wait_since)

                        wait_since = av_gettime();

                    else if (av_gettime() > wait_since + h->rw_timeout)

                        return AVERROR(EIO);

                }

                av_usleep(1000);

            }

        } else if (ret < 1)

            return (ret < 0 && ret != AVERROR_EOF) ? ret : len;

        if (ret)

           fast_retries = FFMAX(fast_retries, 2);

        len += ret;

        if (len < size && ff_check_interrupt(&h->interrupt_callback))

            return AVERROR_EXIT;

    }

    return len;

}

static inline int FUNC_0(URLContext *VAR_5, unsigned char *VAR_5, int VAR_5, int VAR_3,

                                         int (*VAR_4)(URLContext *VAR_5, unsigned char *VAR_5, int VAR_5))

{

    int VAR_5, VAR_6;

    int VAR_7 = 5;

    int64_t wait_since = 0;



    VAR_6 = 0;

    while (VAR_6 < VAR_3) {

        VAR_5 = VAR_4(VAR_5, VAR_5+VAR_6, VAR_5-VAR_6);

        if (VAR_5 == AVERROR(EINTR))

            continue;

        if (VAR_5->flags & AVIO_FLAG_NONBLOCK)

            return VAR_5;

        if (VAR_5 == AVERROR(EAGAIN)) {

            VAR_5 = 0;

            if (VAR_7) {

                VAR_7--;

            } else {

                if (VAR_5->rw_timeout) {

                    if (!wait_since)

                        wait_since = av_gettime();

                    else if (av_gettime() > wait_since + VAR_5->rw_timeout)

                        return AVERROR(EIO);

                }

                av_usleep(1000);

            }

        } else if (VAR_5 < 1)

            return (VAR_5 < 0 && VAR_5 != AVERROR_EOF) ? VAR_5 : VAR_6;

        if (VAR_5)

           VAR_7 = FFMAX(VAR_7, 2);

        VAR_6 += VAR_5;

        if (VAR_6 < VAR_5 && ff_check_interrupt(&VAR_5->interrupt_callback))

            return AVERROR_EXIT;

    }

    return VAR_6;

}

static inline int FUNC_0(URLContext *VAR_5, unsigned char *VAR_5, int VAR_5, int VAR_3,
int (*VAR_4)(URLContext *VAR_5, unsigned char *VAR_5, int VAR_5))
{ int VAR_5, VAR_6; int VAR_7 = 5; int64_t wait_since = 0; VAR_6 = 0; while (VAR_6 < VAR_3) { VAR_5 = VAR_4(VAR_5, VAR_5+VAR_6, VAR_5-VAR_6); if (VAR_5 == AVERROR(EINTR))
continue; if (VAR_5->flags & AVIO_FLAG_NONBLOCK)
return VAR_5; if (VAR_5 == AVERROR(EAGAIN)) { VAR_5 = 0; if (VAR_7) { VAR_7--; } else { if (VAR_5->rw_timeout) { if (!wait_since)
wait_since = av_gettime(); else if (av_gettime() > wait_since + VAR_5->rw_timeout)
return AVERROR(EIO); } av_usleep(1000); } } else if (VAR_5 < 1) return (VAR_5 < 0 && VAR_5 != AVERROR_EOF) ? VAR_5 : VAR_6; if (VAR_5)
VAR_7 = FFMAX(VAR_7, 2); VAR_6 += VAR_5; if (VAR_6 < VAR_5 && ff_check_interrupt(&VAR_5->interrupt_callback))
return AVERROR_EXIT; } return VAR_6; }