static int write_l2_entries(BlockDriverState *bs, uint64_t *l2_table,

    uint64_t l2_offset, int l2_index, int num)

{

    int l2_start_index = l2_index & ~(L1_ENTRIES_PER_SECTOR - 1);

    int start_offset = (8 * l2_index) & ~511;

    int end_offset = (8 * (l2_index + num) + 511) & ~511;

    size_t len = end_offset - start_offset;

    int ret;



    BLKDBG_EVENT(bs->file, BLKDBG_L2_UPDATE);

    ret = bdrv_pwrite(bs->file, l2_offset + start_offset,

        &l2_table[l2_start_index], len);

    if (ret < 0) {

        return ret;

    }



    return 0;

}

static int write_l2_entries(BlockDriverState *bs, uint64_t *l2_table,

    uint64_t l2_offset, int l2_index, int num)

{

    int l2_start_index = l2_index & ~(L1_ENTRIES_PER_SECTOR - 1);

    int start_offset = (8 * l2_index) & ~511;

    int end_offset = (8 * (l2_index + num) + 511) & ~511;

    size_t len = end_offset - start_offset;

    int ret;



    BLKDBG_EVENT(bs->file, BLKDBG_L2_UPDATE);

    ret = bdrv_pwrite(bs->file, l2_offset + start_offset,

        &l2_table[l2_start_index], len);

    if (ret < 0) {

        return ret;

    }



    return 0;

}

    ret = bdrv_pwrite(bs->file, l2_offset + start_offset,
static int FUNC_0(BlockDriverState *VAR_0, uint64_t *VAR_1,

    uint64_t VAR_2, int VAR_3, int VAR_4)

{

    int VAR_5 = VAR_3 & ~(L1_ENTRIES_PER_SECTOR - 1);

    int VAR_6 = (8 * VAR_3) & ~511;

    int VAR_7 = (8 * (VAR_3 + VAR_4) + 511) & ~511;

    size_t len = VAR_7 - VAR_6;

    int VAR_8;



    BLKDBG_EVENT(VAR_0->file, BLKDBG_L2_UPDATE);

    VAR_8 = bdrv_pwrite(VAR_0->file, VAR_2 + VAR_6,

        &VAR_1[VAR_5], len);

    if (VAR_8 < 0) {

        return VAR_8;

    }



    return 0;

}

static int FUNC_0(BlockDriverState *VAR_0, uint64_t *VAR_1,
uint64_t VAR_2, int VAR_3, int VAR_4)
{ int VAR_5 = VAR_3 & ~(L1_ENTRIES_PER_SECTOR - 1); int VAR_6 = (8 * VAR_3) & ~511; int VAR_7 = (8 * (VAR_3 + VAR_4) + 511) & ~511; size_t len = VAR_7 - VAR_6; int VAR_8; BLKDBG_EVENT(VAR_0->file, BLKDBG_L2_UPDATE); VAR_8 = bdrv_pwrite(VAR_0->file, VAR_2 + VAR_6,
&VAR_1[VAR_5], len); if (VAR_8 < 0) { return VAR_8; } return 0; }