static void sd_blk_read(SDState *sd, uint64_t addr, uint32_t len)

{

    uint64_t end = addr + len;



    DPRINTF("sd_blk_read: addr = 0x%08llx, len = %d\n",

            (unsigned long long) addr, len);

    if (!sd->bdrv || bdrv_read(sd->bdrv, addr >> 9, sd->buf, 1) < 0) {

        fprintf(stderr, "sd_blk_read: read error on host side\n");

        return;

    }



    if (end > (addr & ~511) + 512) {

        memcpy(sd->data, sd->buf + (addr & 511), 512 - (addr & 511));



        if (bdrv_read(sd->bdrv, end >> 9, sd->buf, 1) < 0) {

            fprintf(stderr, "sd_blk_read: read error on host side\n");

            return;

        }

        memcpy(sd->data + 512 - (addr & 511), sd->buf, end & 511);

    } else

        memcpy(sd->data, sd->buf + (addr & 511), len);

}

static void sd_blk_read(SDState *sd, uint64_t addr, uint32_t len)

{

    uint64_t end = addr + len;



    DPRINTF("sd_blk_read: addr = 0x%08llx, len = %d\n",

            (unsigned long long) addr, len);

    if (!sd->bdrv || bdrv_read(sd->bdrv, addr >> 9, sd->buf, 1) < 0) {

        fprintf(stderr, "sd_blk_read: read error on host side\n");

        return;

    }



    if (end > (addr & ~511) + 512) {

        memcpy(sd->data, sd->buf + (addr & 511), 512 - (addr & 511));



        if (bdrv_read(sd->bdrv, end >> 9, sd->buf, 1) < 0) {

            fprintf(stderr, "sd_blk_read: read error on host side\n");

            return;

        }

        memcpy(sd->data + 512 - (addr & 511), sd->buf, end & 511);

    } else

        memcpy(sd->data, sd->buf + (addr & 511), len);

}

static void FUNC_0(SDState *VAR_0, uint64_t VAR_1, uint32_t VAR_2)

{

    uint64_t end = VAR_1 + VAR_2;



    DPRINTF("FUNC_0: VAR_1 = 0x%08llx, VAR_2 = %d\n",

            (unsigned long long) VAR_1, VAR_2);

    if (!VAR_0->bdrv || bdrv_read(VAR_0->bdrv, VAR_1 >> 9, VAR_0->buf, 1) < 0) {

        fprintf(stderr, "FUNC_0: read error on host side\n");

        return;

    }



    if (end > (VAR_1 & ~511) + 512) {

        memcpy(VAR_0->data, VAR_0->buf + (VAR_1 & 511), 512 - (VAR_1 & 511));



        if (bdrv_read(VAR_0->bdrv, end >> 9, VAR_0->buf, 1) < 0) {

            fprintf(stderr, "FUNC_0: read error on host side\n");

            return;

        }

        memcpy(VAR_0->data + 512 - (VAR_1 & 511), VAR_0->buf, end & 511);

    } else

        memcpy(VAR_0->data, VAR_0->buf + (VAR_1 & 511), VAR_2);

}

static void FUNC_0(SDState *VAR_0, uint64_t VAR_1, uint32_t VAR_2)
{ uint64_t end = VAR_1 + VAR_2; DPRINTF("FUNC_0: VAR_1 = 0x%08llx, VAR_2 = %d\n",
(unsigned long long) VAR_1, VAR_2); if (!VAR_0->bdrv || bdrv_read(VAR_0->bdrv, VAR_1 >> 9, VAR_0->buf, 1) < 0) { fprintf(stderr, "FUNC_0: read error on host side\n"); return; } if (end > (VAR_1 & ~511) + 512) { memcpy(VAR_0->data, VAR_0->buf + (VAR_1 & 511), 512 - (VAR_1 & 511)); if (bdrv_read(VAR_0->bdrv, end >> 9, VAR_0->buf, 1) < 0) { fprintf(stderr, "FUNC_0: read error on host side\n"); return; } memcpy(VAR_0->data + 512 - (VAR_1 & 511), VAR_0->buf, end & 511); } else memcpy(VAR_0->data, VAR_0->buf + (VAR_1 & 511), VAR_2); }