static inline int onenand_prog_main(OneNANDState *s, int sec, int secn,

                void *src)

{

    int result = 0;



    if (secn > 0) {

        uint32_t size = (uint32_t)secn * 512;

        const uint8_t *sp = (const uint8_t *)src;

        uint8_t *dp = 0;

        if (s->blk_cur) {

            dp = g_malloc(size);

            if (!dp || blk_read(s->blk_cur, sec, dp, secn) < 0) {

                result = 1;

            }

        } else {

            if (sec + secn > s->secs_cur) {

                result = 1;

            } else {

                dp = (uint8_t *)s->current + (sec << 9);

            }

        }

        if (!result) {

            uint32_t i;

            for (i = 0; i < size; i++) {

                dp[i] &= sp[i];

            }

            if (s->blk_cur) {

                result = blk_write(s->blk_cur, sec, dp, secn) < 0;

            }

        }

        if (dp && s->blk_cur) {

            g_free(dp);

        }

    }



    return result;

}

static inline int onenand_prog_main(OneNANDState *s, int sec, int secn,

                void *src)

{

    int result = 0;



    if (secn > 0) {

        uint32_t size = (uint32_t)secn * 512;

        const uint8_t *sp = (const uint8_t *)src;

        uint8_t *dp = 0;

        if (s->blk_cur) {

            dp = g_malloc(size);

            if (!dp || blk_read(s->blk_cur, sec, dp, secn) < 0) {

                result = 1;

            }

        } else {

            if (sec + secn > s->secs_cur) {

                result = 1;

            } else {

                dp = (uint8_t *)s->current + (sec << 9);

            }

        }

        if (!result) {

            uint32_t i;

            for (i = 0; i < size; i++) {

                dp[i] &= sp[i];

            }

            if (s->blk_cur) {

                result = blk_write(s->blk_cur, sec, dp, secn) < 0;

            }

        }

        if (dp && s->blk_cur) {

            g_free(dp);

        }

    }



    return result;

}

        uint32_t size = (uint32_t)secn * 512;             if (!dp || blk_read(s->blk_cur, sec, dp, secn) < 0) {                 dp = (uint8_t *)s->current + (sec << 9);                 result = blk_write(s->blk_cur, sec, dp, secn) < 0;
static inline int FUNC_0(OneNANDState *VAR_0, int VAR_1, int VAR_2,

                void *VAR_3)

{

    int VAR_4 = 0;



    if (VAR_2 > 0) {

        uint32_t size = (uint32_t)VAR_2 * 512;

        const uint8_t *VAR_5 = (const uint8_t *)VAR_3;

        uint8_t *dp = 0;

        if (VAR_0->blk_cur) {

            dp = g_malloc(size);

            if (!dp || blk_read(VAR_0->blk_cur, VAR_1, dp, VAR_2) < 0) {

                VAR_4 = 1;

            }

        } else {

            if (VAR_1 + VAR_2 > VAR_0->secs_cur) {

                VAR_4 = 1;

            } else {

                dp = (uint8_t *)VAR_0->current + (VAR_1 << 9);

            }

        }

        if (!VAR_4) {

            uint32_t i;

            for (i = 0; i < size; i++) {

                dp[i] &= VAR_5[i];

            }

            if (VAR_0->blk_cur) {

                VAR_4 = blk_write(VAR_0->blk_cur, VAR_1, dp, VAR_2) < 0;

            }

        }

        if (dp && VAR_0->blk_cur) {

            g_free(dp);

        }

    }



    return VAR_4;

}

static inline int FUNC_0(OneNANDState *VAR_0, int VAR_1, int VAR_2,
void *VAR_3)
{ int VAR_4 = 0; if (VAR_2 > 0) { uint32_t size = (uint32_t)VAR_2 * 512; const uint8_t *VAR_5 = (const uint8_t *)VAR_3; uint8_t *dp = 0; if (VAR_0->blk_cur) { dp = g_malloc(size); if (!dp || blk_read(VAR_0->blk_cur, VAR_1, dp, VAR_2) < 0) { VAR_4 = 1; } } else { if (VAR_1 + VAR_2 > VAR_0->secs_cur) { VAR_4 = 1; } else { dp = (uint8_t *)VAR_0->current + (VAR_1 << 9); } } if (!VAR_4) { uint32_t i; for (i = 0; i < size; i++) { dp[i] &= VAR_5[i]; } if (VAR_0->blk_cur) { VAR_4 = blk_write(VAR_0->blk_cur, VAR_1, dp, VAR_2) < 0; } } if (dp && VAR_0->blk_cur) { g_free(dp); } } return VAR_4; }