static int tight_palette_insert(QDict *palette, uint32_t rgb, int bpp, int max)

{

    uint8_t key[6];

    int idx = qdict_size(palette);

    bool present;



    tight_palette_rgb2buf(rgb, bpp, key);

    present = qdict_haskey(palette, (char *)key);

    if (idx >= max && !present) {

        return 0;

    }

    if (!present) {

        qdict_put(palette, (char *)key, qint_from_int(idx));

    }

    return qdict_size(palette);

}

static int tight_palette_insert(QDict *palette, uint32_t rgb, int bpp, int max)

{

    uint8_t key[6];

    int idx = qdict_size(palette);

    bool present;



    tight_palette_rgb2buf(rgb, bpp, key);

    present = qdict_haskey(palette, (char *)key);

    if (idx >= max && !present) {

        return 0;

    }

    if (!present) {

        qdict_put(palette, (char *)key, qint_from_int(idx));

    }

    return qdict_size(palette);

}

static int FUNC_0(QDict *VAR_0, uint32_t VAR_1, int VAR_2, int VAR_3)

{

    uint8_t key[6];

    int VAR_4 = qdict_size(VAR_0);

    bool present;



    tight_palette_rgb2buf(VAR_1, VAR_2, key);

    present = qdict_haskey(VAR_0, (char *)key);

    if (VAR_4 >= VAR_3 && !present) {

        return 0;

    }

    if (!present) {

        qdict_put(VAR_0, (char *)key, qint_from_int(VAR_4));

    }

    return qdict_size(VAR_0);

}

static int FUNC_0(QDict *VAR_0, uint32_t VAR_1, int VAR_2, int VAR_3)
{ uint8_t key[6]; int VAR_4 = qdict_size(VAR_0); bool present; tight_palette_rgb2buf(VAR_1, VAR_2, key); present = qdict_haskey(VAR_0, (char *)key); if (VAR_4 >= VAR_3 && !present) { return 0; } if (!present) { qdict_put(VAR_0, (char *)key, qint_from_int(VAR_4)); } return qdict_size(VAR_0); }