int qemu_peek_buffer(QEMUFile *f, uint8_t *buf, int size, size_t offset)

{

    int pending;

    int index;



    assert(!qemu_file_is_writable(f));



    index = f->buf_index + offset;

    pending = f->buf_size - index;

    if (pending < size) {

        qemu_fill_buffer(f);

        index = f->buf_index + offset;

        pending = f->buf_size - index;

    }



    if (pending <= 0) {

        return 0;

    }

    if (size > pending) {

        size = pending;

    }



    memcpy(buf, f->buf + index, size);

    return size;

}

int qemu_peek_buffer(QEMUFile *f, uint8_t *buf, int size, size_t offset)

{

    int pending;

    int index;



    assert(!qemu_file_is_writable(f));



    index = f->buf_index + offset;

    pending = f->buf_size - index;

    if (pending < size) {

        qemu_fill_buffer(f);

        index = f->buf_index + offset;

        pending = f->buf_size - index;

    }



    if (pending <= 0) {

        return 0;

    }

    if (size > pending) {

        size = pending;

    }



    memcpy(buf, f->buf + index, size);

    return size;

}

    if (pending < size) {         qemu_fill_buffer(f);
int FUNC_0(QEMUFile *VAR_0, uint8_t *VAR_1, int VAR_2, size_t VAR_3)

{

    int VAR_4;

    int VAR_5;



    assert(!qemu_file_is_writable(VAR_0));



    VAR_5 = VAR_0->buf_index + VAR_3;

    VAR_4 = VAR_0->buf_size - VAR_5;

    if (VAR_4 < VAR_2) {

        qemu_fill_buffer(VAR_0);

        VAR_5 = VAR_0->buf_index + VAR_3;

        VAR_4 = VAR_0->buf_size - VAR_5;

    }



    if (VAR_4 <= 0) {

        return 0;

    }

    if (VAR_2 > VAR_4) {

        VAR_2 = VAR_4;

    }



    memcpy(VAR_1, VAR_0->VAR_1 + VAR_5, VAR_2);

    return VAR_2;

}

int FUNC_0(QEMUFile *VAR_0, uint8_t *VAR_1, int VAR_2, size_t VAR_3)
{ int VAR_4; int VAR_5; assert(!qemu_file_is_writable(VAR_0)); VAR_5 = VAR_0->buf_index + VAR_3; VAR_4 = VAR_0->buf_size - VAR_5; if (VAR_4 < VAR_2) { qemu_fill_buffer(VAR_0); VAR_5 = VAR_0->buf_index + VAR_3; VAR_4 = VAR_0->buf_size - VAR_5; } if (VAR_4 <= 0) { return 0; } if (VAR_2 > VAR_4) { VAR_2 = VAR_4; } memcpy(VAR_1, VAR_0->VAR_1 + VAR_5, VAR_2); return VAR_2; }