libavcodec/imc.c:874: error: Integer Overflow L2
  ([0, +oo] - 1):unsigned32 by call to `bitstream_read_bit`.

libavcodec/imc.c:861:26: Call
859.         return AVERROR_INVALIDDATA;
860.     }
861.     stream_format_code = bitstream_read(&q->bc, 3);
                              ^
862. 
863.     if (stream_format_code & 0x04)

libavcodec/bitstream.h:183:1: Parameter `bc->bits_left`
  181. 
  182. /* Return n bits from the buffer. n has to be in the 0-32 range. */
  183. static inline uint32_t bitstream_read(BitstreamContext *bc, unsigned n)
       ^
  184. {
  185.     if (!n)

libavcodec/imc.c:874:12: Call
872.     }
873. 
874.     flag = bitstream_read_bit(&q->bc);
                ^
875.     if (stream_format_code & 0x1)
876.         imc_read_level_coeffs_raw(q, stream_format_code, chctx->levlCoeffBuf);

libavcodec/bitstream.h:145:1: Parameter `bc->bits_left`
  143. 
  144. /* Return one bit from the buffer. */
  145. static inline unsigned bitstream_read_bit(BitstreamContext *bc)
       ^
  146. {
  147.     if (!bc->bits_left)

libavcodec/bitstream.h:150:12: Call
  148.         refill_64(bc);
  149. 
  150.     return get_val(bc, 1);
                  ^
  151. }
  152. 

libavcodec/bitstream.h:130:1: <LHS trace>
128. }
129. 
130. static inline uint64_t get_val(BitstreamContext *bc, unsigned n)
     ^
131. {
132. #ifdef BITSTREAM_READER_LE

libavcodec/bitstream.h:130:1: Parameter `bc->bits_left`
    128. }
    129. 
    130. static inline uint64_t get_val(BitstreamContext *bc, unsigned n)
         ^
    131. {
    132. #ifdef BITSTREAM_READER_LE

libavcodec/bitstream.h:130:1: <RHS trace>
128. }
129. 
130. static inline uint64_t get_val(BitstreamContext *bc, unsigned n)
     ^
131. {
132. #ifdef BITSTREAM_READER_LE

libavcodec/bitstream.h:130:1: Parameter `n`
    128. }
    129. 
    130. static inline uint64_t get_val(BitstreamContext *bc, unsigned n)
         ^
    131. {
    132. #ifdef BITSTREAM_READER_LE

libavcodec/bitstream.h:139:5: Binary operation: ([0, +oo] - 1):unsigned32 by call to `bitstream_read_bit` 
    137.     bc->bits <<= n;
    138. #endif
    139.     bc->bits_left -= n;
             ^
    140. 
    141.     return ret;

static inline uint64_t get_val(BitstreamContext *bc, unsigned n)
{
#ifdef BITSTREAM_READER_LE
    uint64_t ret = bc->bits & ((UINT64_C(1) << n) - 1);
    bc->bits >>= n;
#else
    uint64_t ret = bc->bits >> (64 - n);
    bc->bits <<= n;
#endif
    bc->bits_left -= n;
    return ret;
}
['static int imc_decode_block(AVCodecContext *avctx, IMCContext *q, int ch)\n{\n    int stream_format_code;\n    int imc_hdr, i, j, ret;\n    int flag;\n    int bits;\n    int counter, bitscount;\n    IMCChannel *chctx = q->chctx + ch;\n    imc_hdr = bitstream_read(&q->bc, 9);\n    if (imc_hdr & 0x18) {\n        av_log(avctx, AV_LOG_ERROR, "frame header check failed!\\n");\n        av_log(avctx, AV_LOG_ERROR, "got %X.\\n", imc_hdr);\n        return AVERROR_INVALIDDATA;\n    }\n    stream_format_code = bitstream_read(&q->bc, 3);\n    if (stream_format_code & 0x04)\n        chctx->decoder_reset = 1;\n    if (chctx->decoder_reset) {\n        for (i = 0; i < BANDS; i++)\n            chctx->old_floor[i] = 1.0;\n        for (i = 0; i < COEFFS; i++)\n            chctx->CWdecoded[i] = 0;\n        chctx->decoder_reset = 0;\n    }\n    flag = bitstream_read_bit(&q->bc);\n    if (stream_format_code & 0x1)\n        imc_read_level_coeffs_raw(q, stream_format_code, chctx->levlCoeffBuf);\n    else\n        imc_read_level_coeffs(q, stream_format_code, chctx->levlCoeffBuf);\n    if (stream_format_code & 0x1)\n        imc_decode_level_coefficients_raw(q, chctx->levlCoeffBuf,\n                                          chctx->flcoeffs1, chctx->flcoeffs2);\n    else if (stream_format_code & 0x4)\n        imc_decode_level_coefficients(q, chctx->levlCoeffBuf,\n                                      chctx->flcoeffs1, chctx->flcoeffs2);\n    else\n        imc_decode_level_coefficients2(q, chctx->levlCoeffBuf, chctx->old_floor,\n                                       chctx->flcoeffs1, chctx->flcoeffs2);\n    memcpy(chctx->old_floor, chctx->flcoeffs1, 32 * sizeof(float));\n    counter = 0;\n    if (stream_format_code & 0x1) {\n        for (i = 0; i < BANDS; i++) {\n            chctx->bandWidthT[i]   = band_tab[i + 1] - band_tab[i];\n            chctx->bandFlagsBuf[i] = 0;\n            chctx->flcoeffs3[i]    = chctx->flcoeffs2[i] * 2;\n            chctx->flcoeffs5[i]    = 1.0;\n        }\n    } else {\n        for (i = 0; i < BANDS; i++) {\n            if (chctx->levlCoeffBuf[i] == 16) {\n                chctx->bandWidthT[i] = 0;\n                counter++;\n            } else\n                chctx->bandWidthT[i] = band_tab[i + 1] - band_tab[i];\n        }\n        memset(chctx->bandFlagsBuf, 0, BANDS * sizeof(int));\n        for (i = 0; i < BANDS - 1; i++)\n            if (chctx->bandWidthT[i])\n                chctx->bandFlagsBuf[i] = bitstream_read_bit(&q->bc);\n        imc_calculate_coeffs(q, chctx->flcoeffs1, chctx->flcoeffs2,\n                             chctx->bandWidthT, chctx->flcoeffs3,\n                             chctx->flcoeffs5);\n    }\n    bitscount = 0;\n    if (stream_format_code & 0x2) {\n        bitscount += 15;\n        chctx->bitsBandT[0] = 5;\n        chctx->CWlengthT[0] = 5;\n        chctx->CWlengthT[1] = 5;\n        chctx->CWlengthT[2] = 5;\n        for (i = 1; i < 4; i++) {\n            if (stream_format_code & 0x1)\n                bits = 5;\n            else\n                bits = (chctx->levlCoeffBuf[i] == 16) ? 0 : 5;\n            chctx->bitsBandT[i] = bits;\n            for (j = band_tab[i]; j < band_tab[i + 1]; j++) {\n                chctx->CWlengthT[j] = bits;\n                bitscount      += bits;\n            }\n        }\n    }\n    if (avctx->codec_id == AV_CODEC_ID_IAC) {\n        bitscount += !!chctx->bandWidthT[BANDS - 1];\n        if (!(stream_format_code & 0x2))\n            bitscount += 16;\n    }\n    if ((ret = bit_allocation(q, chctx, stream_format_code,\n                              512 - bitscount - bitstream_tell(&q->bc),\n                              flag)) < 0) {\n        av_log(avctx, AV_LOG_ERROR, "Bit allocations failed\\n");\n        chctx->decoder_reset = 1;\n        return ret;\n    }\n    if (stream_format_code & 0x1) {\n        for (i = 0; i < BANDS; i++)\n            chctx->skipFlags[i] = 0;\n    } else {\n        imc_refine_bit_allocation(q, chctx);\n    }\n    for (i = 0; i < BANDS; i++) {\n        chctx->sumLenArr[i] = 0;\n        for (j = band_tab[i]; j < band_tab[i + 1]; j++)\n            if (!chctx->skipFlags[j])\n                chctx->sumLenArr[i] += chctx->CWlengthT[j];\n    }\n    memset(chctx->codewords, 0, sizeof(chctx->codewords));\n    if (imc_get_coeffs(q, chctx) < 0) {\n        av_log(avctx, AV_LOG_ERROR, "Read coefficients failed\\n");\n        chctx->decoder_reset = 1;\n        return AVERROR_INVALIDDATA;\n    }\n    if (inverse_quant_coeff(q, chctx, stream_format_code) < 0) {\n        av_log(avctx, AV_LOG_ERROR, "Inverse quantization of coefficients failed\\n");\n        chctx->decoder_reset = 1;\n        return AVERROR_INVALIDDATA;\n    }\n    memset(chctx->skipFlags, 0, sizeof(chctx->skipFlags));\n    imc_imdct256(q, chctx, avctx->channels);\n    return 0;\n}', 'static inline uint32_t bitstream_read(BitstreamContext *bc, unsigned n)\n{\n    if (!n)\n        return 0;\n    if (n > bc->bits_left) {\n        refill_32(bc);\n        if (bc->bits_left < 32)\n            bc->bits_left = n;\n    }\n    return get_val(bc, n);\n}', 'static inline unsigned bitstream_read_bit(BitstreamContext *bc)\n{\n    if (!bc->bits_left)\n        refill_64(bc);\n    return get_val(bc, 1);\n}', 'static inline uint64_t get_val(BitstreamContext *bc, unsigned n)\n{\n#ifdef BITSTREAM_READER_LE\n    uint64_t ret = bc->bits & ((UINT64_C(1) << n) - 1);\n    bc->bits >>= n;\n#else\n    uint64_t ret = bc->bits >> (64 - n);\n    bc->bits <<= n;\n#endif\n    bc->bits_left -= n;\n    return ret;\n}']