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

                void *src)

{

    int result = 0;

    if (secn > 0) {

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

        uint8_t *dp = 0, *dpp = 0;

        if (s->blk_cur) {

            dp = g_malloc(512);

            if (!dp

                || blk_read(s->blk_cur, s->secs_cur + (sec >> 5), dp, 1) < 0) {

                result = 1;

            } else {

                dpp = dp + ((sec & 31) << 4);

            }

        } else {

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

                result = 1;

            } else {

                dpp = s->current + (s->secs_cur << 9) + (sec << 4);

            }

        }

        if (!result) {

            uint32_t i;

            for (i = 0; i < (secn << 4); i++) {

                dpp[i] &= sp[i];

            }

            if (s->blk_cur) {

                result = blk_write(s->blk_cur, s->secs_cur + (sec >> 5),

                                   dp, 1) < 0;

            }

        }

        g_free(dp);

    }

    return result;

}

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

                void *src)

{

    int result = 0;

    if (secn > 0) {

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

        uint8_t *dp = 0, *dpp = 0;

        if (s->blk_cur) {

            dp = g_malloc(512);

            if (!dp

                || blk_read(s->blk_cur, s->secs_cur + (sec >> 5), dp, 1) < 0) {

                result = 1;

            } else {

                dpp = dp + ((sec & 31) << 4);

            }

        } else {

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

                result = 1;

            } else {

                dpp = s->current + (s->secs_cur << 9) + (sec << 4);

            }

        }

        if (!result) {

            uint32_t i;

            for (i = 0; i < (secn << 4); i++) {

                dpp[i] &= sp[i];

            }

            if (s->blk_cur) {

                result = blk_write(s->blk_cur, s->secs_cur + (sec >> 5),

                                   dp, 1) < 0;

            }

        }

        g_free(dp);

    }

    return result;

}

                || blk_read(s->blk_cur, s->secs_cur + (sec >> 5), dp, 1) < 0) {                 result = blk_write(s->blk_cur, s->secs_cur + (sec >> 5),                                    dp, 1) < 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) {

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

        uint8_t *dp = 0, *dpp = 0;

        if (VAR_0->blk_cur) {

            dp = g_malloc(512);

            if (!dp

                || blk_read(VAR_0->blk_cur, VAR_0->secs_cur + (VAR_1 >> 5), dp, 1) < 0) {

                VAR_4 = 1;

            } else {

                dpp = dp + ((VAR_1 & 31) << 4);

            }

        } else {

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

                VAR_4 = 1;

            } else {

                dpp = VAR_0->current + (VAR_0->secs_cur << 9) + (VAR_1 << 4);

            }

        }

        if (!VAR_4) {

            uint32_t i;

            for (i = 0; i < (VAR_2 << 4); i++) {

                dpp[i] &= VAR_5[i];

            }

            if (VAR_0->blk_cur) {

                VAR_4 = blk_write(VAR_0->blk_cur, VAR_0->secs_cur + (VAR_1 >> 5),

                                   dp, 1) < 0;

            }

        }

        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) { const uint8_t *VAR_5 = (const uint8_t *)VAR_3; uint8_t *dp = 0, *dpp = 0; if (VAR_0->blk_cur) { dp = g_malloc(512); if (!dp
|| blk_read(VAR_0->blk_cur, VAR_0->secs_cur + (VAR_1 >> 5), dp, 1) < 0) { VAR_4 = 1; } else { dpp = dp + ((VAR_1 & 31) << 4); } } else { if (VAR_1 + VAR_2 > VAR_0->secs_cur) { VAR_4 = 1; } else { dpp = VAR_0->current + (VAR_0->secs_cur << 9) + (VAR_1 << 4); } } if (!VAR_4) { uint32_t i; for (i = 0; i < (VAR_2 << 4); i++) { dpp[i] &= VAR_5[i]; } if (VAR_0->blk_cur) { VAR_4 = blk_write(VAR_0->blk_cur, VAR_0->secs_cur + (VAR_1 >> 5),
dp, 1) < 0; } } g_free(dp); } return VAR_4; }