static void fill_buffer(AVIOContext *s)

{

    int max_buffer_size = s->max_packet_size ?

                          s->max_packet_size : IO_BUFFER_SIZE;

    uint8_t *dst        = s->buf_end - s->buffer + max_buffer_size < s->buffer_size ?

                          s->buf_end : s->buffer;

    int len             = s->buffer_size - (dst - s->buffer);



    /* can't fill the buffer without read_packet, just set EOF if appropriate */

    if (!s->read_packet && s->buf_ptr >= s->buf_end)

        s->eof_reached = 1;



    /* no need to do anything if EOF already reached */

    if (s->eof_reached)

        return;



    if (s->update_checksum && dst == s->buffer) {

        if (s->buf_end > s->checksum_ptr)

            s->checksum = s->update_checksum(s->checksum, s->checksum_ptr,

                                             s->buf_end - s->checksum_ptr);

        s->checksum_ptr = s->buffer;

    }



    /* make buffer smaller in case it ended up large after probing */

    if (s->read_packet && s->orig_buffer_size && s->buffer_size > s->orig_buffer_size) {

        if (dst == s->buffer) {

            ffio_set_buf_size(s, s->orig_buffer_size);



            s->checksum_ptr = dst = s->buffer;

        }

        av_assert0(len >= s->orig_buffer_size);

        len = s->orig_buffer_size;

    }



    if (s->read_packet)

        len = s->read_packet(s->opaque, dst, len);

    else

        len = 0;

    if (len <= 0) {

        /* do not modify buffer if EOF reached so that a seek back can

           be done without rereading data */

        s->eof_reached = 1;

        if (len < 0)

            s->error = len;

    } else {

        s->pos += len;

        s->buf_ptr = dst;

        s->buf_end = dst + len;

        s->bytes_read += len;

    }

}

static void fill_buffer(AVIOContext *s)

{

    int max_buffer_size = s->max_packet_size ?

                          s->max_packet_size : IO_BUFFER_SIZE;

    uint8_t *dst        = s->buf_end - s->buffer + max_buffer_size < s->buffer_size ?

                          s->buf_end : s->buffer;

    int len             = s->buffer_size - (dst - s->buffer);



    

    if (!s->read_packet && s->buf_ptr >= s->buf_end)

        s->eof_reached = 1;



    

    if (s->eof_reached)

        return;



    if (s->update_checksum && dst == s->buffer) {

        if (s->buf_end > s->checksum_ptr)

            s->checksum = s->update_checksum(s->checksum, s->checksum_ptr,

                                             s->buf_end - s->checksum_ptr);

        s->checksum_ptr = s->buffer;

    }



    

    if (s->read_packet && s->orig_buffer_size && s->buffer_size > s->orig_buffer_size) {

        if (dst == s->buffer) {

            ffio_set_buf_size(s, s->orig_buffer_size);



            s->checksum_ptr = dst = s->buffer;

        }

        av_assert0(len >= s->orig_buffer_size);

        len = s->orig_buffer_size;

    }



    if (s->read_packet)

        len = s->read_packet(s->opaque, dst, len);

    else

        len = 0;

    if (len <= 0) {

        



        s->eof_reached = 1;

        if (len < 0)

            s->error = len;

    } else {

        s->pos += len;

        s->buf_ptr = dst;

        s->buf_end = dst + len;

        s->bytes_read += len;

    }

}

            ffio_set_buf_size(s, s->orig_buffer_size);
static void FUNC_0(AVIOContext *VAR_0)

{

    int VAR_1 = VAR_0->max_packet_size ?

                          VAR_0->max_packet_size : IO_BUFFER_SIZE;

    uint8_t *dst        = VAR_0->buf_end - VAR_0->buffer + VAR_1 < VAR_0->buffer_size ?

                          VAR_0->buf_end : VAR_0->buffer;

    int VAR_2             = VAR_0->buffer_size - (dst - VAR_0->buffer);



    

    if (!VAR_0->read_packet && VAR_0->buf_ptr >= VAR_0->buf_end)

        VAR_0->eof_reached = 1;



    

    if (VAR_0->eof_reached)

        return;



    if (VAR_0->update_checksum && dst == VAR_0->buffer) {

        if (VAR_0->buf_end > VAR_0->checksum_ptr)

            VAR_0->checksum = VAR_0->update_checksum(VAR_0->checksum, VAR_0->checksum_ptr,

                                             VAR_0->buf_end - VAR_0->checksum_ptr);

        VAR_0->checksum_ptr = VAR_0->buffer;

    }



    

    if (VAR_0->read_packet && VAR_0->orig_buffer_size && VAR_0->buffer_size > VAR_0->orig_buffer_size) {

        if (dst == VAR_0->buffer) {

            ffio_set_buf_size(VAR_0, VAR_0->orig_buffer_size);



            VAR_0->checksum_ptr = dst = VAR_0->buffer;

        }

        av_assert0(VAR_2 >= VAR_0->orig_buffer_size);

        VAR_2 = VAR_0->orig_buffer_size;

    }



    if (VAR_0->read_packet)

        VAR_2 = VAR_0->read_packet(VAR_0->opaque, dst, VAR_2);

    else

        VAR_2 = 0;

    if (VAR_2 <= 0) {

        



        VAR_0->eof_reached = 1;

        if (VAR_2 < 0)

            VAR_0->error = VAR_2;

    } else {

        VAR_0->pos += VAR_2;

        VAR_0->buf_ptr = dst;

        VAR_0->buf_end = dst + VAR_2;

        VAR_0->bytes_read += VAR_2;

    }

}

static void FUNC_0(AVIOContext *VAR_0)
{ int VAR_1 = VAR_0->max_packet_size ?
VAR_0->max_packet_size : IO_BUFFER_SIZE; uint8_t *dst        = VAR_0->buf_end - VAR_0->buffer + VAR_1 < VAR_0->buffer_size ?
VAR_0->buf_end : VAR_0->buffer; int VAR_2             = VAR_0->buffer_size - (dst - VAR_0->buffer); if (!VAR_0->read_packet && VAR_0->buf_ptr >= VAR_0->buf_end)
VAR_0->eof_reached = 1; if (VAR_0->eof_reached)
return; if (VAR_0->update_checksum && dst == VAR_0->buffer) { if (VAR_0->buf_end > VAR_0->checksum_ptr)
VAR_0->checksum = VAR_0->update_checksum(VAR_0->checksum, VAR_0->checksum_ptr,
VAR_0->buf_end - VAR_0->checksum_ptr); VAR_0->checksum_ptr = VAR_0->buffer; } if (VAR_0->read_packet && VAR_0->orig_buffer_size && VAR_0->buffer_size > VAR_0->orig_buffer_size) { if (dst == VAR_0->buffer) { ffio_set_buf_size(VAR_0, VAR_0->orig_buffer_size); VAR_0->checksum_ptr = dst = VAR_0->buffer; } av_assert0(VAR_2 >= VAR_0->orig_buffer_size); VAR_2 = VAR_0->orig_buffer_size; } if (VAR_0->read_packet)
VAR_2 = VAR_0->read_packet(VAR_0->opaque, dst, VAR_2); else
VAR_2 = 0; if (VAR_2 <= 0) { VAR_0->eof_reached = 1; if (VAR_2 < 0)
VAR_0->error = VAR_2; } else { VAR_0->pos += VAR_2; VAR_0->buf_ptr = dst; VAR_0->buf_end = dst + VAR_2; VAR_0->bytes_read += VAR_2; } }