static void fill_coding_method_array (sb_int8_array tone_level_idx, sb_int8_array tone_level_idx_temp,
                sb_int8_array coding_method, int nb_channels,
                int c, int superblocktype_2_3, int cm_table_select)
{
    int ch, sb, j;
    int tmp, acc, esp_40, comp;
    int add1, add2, add3, add4;
    int64_t multres;
    if (nb_channels <= 0)
        return;
    if (!superblocktype_2_3) {
        SAMPLES_NEEDED
        for (ch = 0; ch < nb_channels; ch++)
            for (sb = 0; sb < 30; sb++) {
                for (j = 1; j < 64; j++) {
                    add1 = tone_level_idx[ch][sb][j] - 10;
                    if (add1 < 0)
                        add1 = 0;
                    add2 = add3 = add4 = 0;
                    if (sb > 1) {
                        add2 = tone_level_idx[ch][sb - 2][j] + tone_level_idx_offset_table[sb][0] - 6;
                        if (add2 < 0)
                            add2 = 0;
                    }
                    if (sb > 0) {
                        add3 = tone_level_idx[ch][sb - 1][j] + tone_level_idx_offset_table[sb][1] - 6;
                        if (add3 < 0)
                            add3 = 0;
                    }
                    if (sb < 29) {
                        add4 = tone_level_idx[ch][sb + 1][j] + tone_level_idx_offset_table[sb][3] - 6;
                        if (add4 < 0)
                            add4 = 0;
                    }
                    tmp = tone_level_idx[ch][sb][j + 1] * 2 - add4 - add3 - add2 - add1;
                    if (tmp < 0)
                        tmp = 0;
                    tone_level_idx_temp[ch][sb][j + 1] = tmp & 0xff;
                }
                tone_level_idx_temp[ch][sb][0] = tone_level_idx_temp[ch][sb][1];
            }
            acc = 0;
            for (ch = 0; ch < nb_channels; ch++)
                for (sb = 0; sb < 30; sb++)
                    for (j = 0; j < 64; j++)
                        acc += tone_level_idx_temp[ch][sb][j];
            if (acc)
                tmp = c * 256 / (acc & 0xffff);
            multres = 0x66666667 * (acc * 10);
            esp_40 = (multres >> 32) / 8 + ((multres & 0xffffffff) >> 31);
            for (ch = 0;  ch < nb_channels; ch++)
                for (sb = 0; sb < 30; sb++)
                    for (j = 0; j < 64; j++) {
                        comp = tone_level_idx_temp[ch][sb][j]* esp_40 * 10;
                        if (comp < 0)
                            comp += 0xff;
                        comp /= 256;
                        switch(sb) {
                            case 0:
                                if (comp < 30)
                                    comp = 30;
                                comp += 15;
                                break;
                            case 1:
                                if (comp < 24)
                                    comp = 24;
                                comp += 10;
                                break;
                            case 2:
                            case 3:
                            case 4:
                                if (comp < 16)
                                    comp = 16;
                        }
                        if (comp <= 5)
                            tmp = 0;
                        else if (comp <= 10)
                            tmp = 10;
                        else if (comp <= 16)
                            tmp = 16;
                        else if (comp <= 24)
                            tmp = -1;
                        else
                            tmp = 0;
                        coding_method[ch][sb][j] = ((tmp & 0xfffa) + 30 )& 0xff;
                    }
            for (sb = 0; sb < 30; sb++)
                fix_coding_method_array(sb, nb_channels, coding_method);
            for (ch = 0; ch < nb_channels; ch++)
                for (sb = 0; sb < 30; sb++)
                    for (j = 0; j < 64; j++)
                        if (sb >= 10) {
                            if (coding_method[ch][sb][j] < 10)
                                coding_method[ch][sb][j] = 10;
                        } else {
                            if (sb >= 2) {
                                if (coding_method[ch][sb][j] < 16)
                                    coding_method[ch][sb][j] = 16;
                            } else {
                                if (coding_method[ch][sb][j] < 30)
                                    coding_method[ch][sb][j] = 30;
                            }
                        }
    } else {
        for (ch = 0; ch < nb_channels; ch++)
            for (sb = 0; sb < 30; sb++)
                for (j = 0; j < 64; j++)
                    coding_method[ch][sb][j] = coding_method_table[cm_table_select][sb];
    }
    return;
}
['static void fill_coding_method_array (sb_int8_array tone_level_idx, sb_int8_array tone_level_idx_temp,\n                sb_int8_array coding_method, int nb_channels,\n                int c, int superblocktype_2_3, int cm_table_select)\n{\n    int ch, sb, j;\n    int tmp, acc, esp_40, comp;\n    int add1, add2, add3, add4;\n    int64_t multres;\n    if (nb_channels <= 0)\n        return;\n    if (!superblocktype_2_3) {\n        SAMPLES_NEEDED\n        for (ch = 0; ch < nb_channels; ch++)\n            for (sb = 0; sb < 30; sb++) {\n                for (j = 1; j < 64; j++) {\n                    add1 = tone_level_idx[ch][sb][j] - 10;\n                    if (add1 < 0)\n                        add1 = 0;\n                    add2 = add3 = add4 = 0;\n                    if (sb > 1) {\n                        add2 = tone_level_idx[ch][sb - 2][j] + tone_level_idx_offset_table[sb][0] - 6;\n                        if (add2 < 0)\n                            add2 = 0;\n                    }\n                    if (sb > 0) {\n                        add3 = tone_level_idx[ch][sb - 1][j] + tone_level_idx_offset_table[sb][1] - 6;\n                        if (add3 < 0)\n                            add3 = 0;\n                    }\n                    if (sb < 29) {\n                        add4 = tone_level_idx[ch][sb + 1][j] + tone_level_idx_offset_table[sb][3] - 6;\n                        if (add4 < 0)\n                            add4 = 0;\n                    }\n                    tmp = tone_level_idx[ch][sb][j + 1] * 2 - add4 - add3 - add2 - add1;\n                    if (tmp < 0)\n                        tmp = 0;\n                    tone_level_idx_temp[ch][sb][j + 1] = tmp & 0xff;\n                }\n                tone_level_idx_temp[ch][sb][0] = tone_level_idx_temp[ch][sb][1];\n            }\n            acc = 0;\n            for (ch = 0; ch < nb_channels; ch++)\n                for (sb = 0; sb < 30; sb++)\n                    for (j = 0; j < 64; j++)\n                        acc += tone_level_idx_temp[ch][sb][j];\n            if (acc)\n                tmp = c * 256 / (acc & 0xffff);\n            multres = 0x66666667 * (acc * 10);\n            esp_40 = (multres >> 32) / 8 + ((multres & 0xffffffff) >> 31);\n            for (ch = 0;  ch < nb_channels; ch++)\n                for (sb = 0; sb < 30; sb++)\n                    for (j = 0; j < 64; j++) {\n                        comp = tone_level_idx_temp[ch][sb][j]* esp_40 * 10;\n                        if (comp < 0)\n                            comp += 0xff;\n                        comp /= 256;\n                        switch(sb) {\n                            case 0:\n                                if (comp < 30)\n                                    comp = 30;\n                                comp += 15;\n                                break;\n                            case 1:\n                                if (comp < 24)\n                                    comp = 24;\n                                comp += 10;\n                                break;\n                            case 2:\n                            case 3:\n                            case 4:\n                                if (comp < 16)\n                                    comp = 16;\n                        }\n                        if (comp <= 5)\n                            tmp = 0;\n                        else if (comp <= 10)\n                            tmp = 10;\n                        else if (comp <= 16)\n                            tmp = 16;\n                        else if (comp <= 24)\n                            tmp = -1;\n                        else\n                            tmp = 0;\n                        coding_method[ch][sb][j] = ((tmp & 0xfffa) + 30 )& 0xff;\n                    }\n            for (sb = 0; sb < 30; sb++)\n                fix_coding_method_array(sb, nb_channels, coding_method);\n            for (ch = 0; ch < nb_channels; ch++)\n                for (sb = 0; sb < 30; sb++)\n                    for (j = 0; j < 64; j++)\n                        if (sb >= 10) {\n                            if (coding_method[ch][sb][j] < 10)\n                                coding_method[ch][sb][j] = 10;\n                        } else {\n                            if (sb >= 2) {\n                                if (coding_method[ch][sb][j] < 16)\n                                    coding_method[ch][sb][j] = 16;\n                            } else {\n                                if (coding_method[ch][sb][j] < 30)\n                                    coding_method[ch][sb][j] = 30;\n                            }\n                        }\n    } else {\n        for (ch = 0; ch < nb_channels; ch++)\n            for (sb = 0; sb < 30; sb++)\n                for (j = 0; j < 64; j++)\n                    coding_method[ch][sb][j] = coding_method_table[cm_table_select][sb];\n    }\n    return;\n}']