_Z30lodepng_compress_settings_initP23LodePNGCompressSettings:
 2327|  4.35k|void lodepng_compress_settings_init(LodePNGCompressSettings* settings) {
 2328|       |  /*compress with dynamic huffman tree (not in the mathematical sense, just not the predefined one)*/
 2329|  4.35k|  settings->btype = 2;
 2330|  4.35k|  settings->use_lz77 = 1;
 2331|  4.35k|  settings->windowsize = DEFAULT_WINDOWSIZE;
  ------------------
  |  | 2325|  4.35k|#define DEFAULT_WINDOWSIZE 2048
  ------------------
 2332|  4.35k|  settings->minmatch = 3;
 2333|  4.35k|  settings->nicematch = 128;
 2334|  4.35k|  settings->lazymatching = 1;
 2335|       |
 2336|  4.35k|  settings->custom_zlib = 0;
 2337|  4.35k|  settings->custom_deflate = 0;
 2338|  4.35k|  settings->custom_context = 0;
 2339|  4.35k|}
_Z32lodepng_decompress_settings_initP25LodePNGDecompressSettings:
 2348|  4.35k|void lodepng_decompress_settings_init(LodePNGDecompressSettings* settings) {
 2349|  4.35k|  settings->ignore_adler32 = 0;
 2350|  4.35k|  settings->ignore_nlen = 0;
 2351|  4.35k|  settings->max_output_size = 0;
 2352|       |
 2353|  4.35k|  settings->custom_zlib = 0;
 2354|  4.35k|  settings->custom_inflate = 0;
 2355|  4.35k|  settings->custom_context = 0;
 2356|  4.35k|}
_Z20lodepng_chunk_lengthPKh:
 2736|   433k|unsigned lodepng_chunk_length(const unsigned char* chunk) {
 2737|   433k|  return lodepng_read32bitInt(chunk);
 2738|   433k|}
_Z25lodepng_chunk_type_equalsPKhPKc:
 2746|  1.54M|unsigned char lodepng_chunk_type_equals(const unsigned char* chunk, const char* type) {
 2747|  1.54M|  if(lodepng_strlen(type) != 4) return 0;
  ------------------
  |  Branch (2747:6): [True: 0, False: 1.54M]
  ------------------
 2748|  1.54M|  return (chunk[4] == type[0] && chunk[5] == type[1] && chunk[6] == type[2] && chunk[7] == type[3]);
  ------------------
  |  Branch (2748:11): [True: 332k, False: 1.21M]
  |  Branch (2748:34): [True: 214k, False: 117k]
  |  Branch (2748:57): [True: 209k, False: 5.58k]
  |  Branch (2748:80): [True: 206k, False: 2.15k]
  ------------------
 2749|  1.54M|}
_Z23lodepng_chunk_ancillaryPKh:
 2751|  14.0k|unsigned char lodepng_chunk_ancillary(const unsigned char* chunk) {
 2752|  14.0k|  return((chunk[4] & 32) != 0);
 2753|  14.0k|}
_Z24lodepng_chunk_data_constPKh:
 2767|   213k|const unsigned char* lodepng_chunk_data_const(const unsigned char* chunk) {
 2768|   213k|  return &chunk[8];
 2769|   213k|}
_Z24lodepng_chunk_next_constPKhS0_:
 2801|   212k|const unsigned char* lodepng_chunk_next_const(const unsigned char* chunk, const unsigned char* end) {
 2802|   212k|  size_t available_size = (size_t)(end - chunk);
 2803|   212k|  if(chunk >= end || available_size < 12) return end; /*too small to contain a chunk*/
  ------------------
  |  Branch (2803:6): [True: 0, False: 212k]
  |  Branch (2803:22): [True: 0, False: 212k]
  ------------------
 2804|   212k|  if(chunk[0] == 0x89 && chunk[1] == 0x50 && chunk[2] == 0x4e && chunk[3] == 0x47
  ------------------
  |  Branch (2804:6): [True: 0, False: 212k]
  |  Branch (2804:26): [True: 0, False: 0]
  |  Branch (2804:46): [True: 0, False: 0]
  |  Branch (2804:66): [True: 0, False: 0]
  ------------------
 2805|   212k|    && chunk[4] == 0x0d && chunk[5] == 0x0a && chunk[6] == 0x1a && chunk[7] == 0x0a) {
  ------------------
  |  Branch (2805:8): [True: 0, False: 0]
  |  Branch (2805:28): [True: 0, False: 0]
  |  Branch (2805:48): [True: 0, False: 0]
  |  Branch (2805:68): [True: 0, False: 0]
  ------------------
 2806|       |    /* Is PNG magic header at start of PNG file. Jump to first actual chunk. */
 2807|      0|    return chunk + 8;
 2808|   212k|  } else {
 2809|   212k|    size_t total_chunk_length;
 2810|   212k|    if(lodepng_addofl(lodepng_chunk_length(chunk), 12, &total_chunk_length)) return end;
  ------------------
  |  Branch (2810:8): [True: 0, False: 212k]
  ------------------
 2811|   212k|    if(total_chunk_length > available_size) return end; /*outside of range*/
  ------------------
  |  Branch (2811:8): [True: 0, False: 212k]
  ------------------
 2812|   212k|    return chunk + total_chunk_length;
 2813|   212k|  }
 2814|   212k|}
_Z23lodepng_color_mode_initP16LodePNGColorMode:
 2935|  16.3k|void lodepng_color_mode_init(LodePNGColorMode* info) {
 2936|  16.3k|  info->key_defined = 0;
 2937|  16.3k|  info->key_r = info->key_g = info->key_b = 0;
 2938|  16.3k|  info->colortype = LCT_RGBA;
 2939|  16.3k|  info->bitdepth = 8;
 2940|  16.3k|  info->palette = 0;
 2941|  16.3k|  info->palettesize = 0;
 2942|  16.3k|}
_Z26lodepng_color_mode_cleanupP16LodePNGColorMode:
 2962|  17.9k|void lodepng_color_mode_cleanup(LodePNGColorMode* info) {
 2963|  17.9k|  lodepng_palette_clear(info);
 2964|  17.9k|}
_Z23lodepng_color_mode_copyP16LodePNGColorModePKS_:
 2966|  1.63k|unsigned lodepng_color_mode_copy(LodePNGColorMode* dest, const LodePNGColorMode* source) {
 2967|  1.63k|  lodepng_color_mode_cleanup(dest);
 2968|  1.63k|  lodepng_memcpy(dest, source, sizeof(LodePNGColorMode));
 2969|  1.63k|  if(source->palette) {
  ------------------
  |  Branch (2969:6): [True: 175, False: 1.46k]
  ------------------
 2970|    175|    dest->palette = (unsigned char*)lodepng_malloc(1024);
 2971|    175|    if(!dest->palette && source->palettesize) return 83; /*alloc fail*/
  ------------------
  |  Branch (2971:8): [True: 0, False: 175]
  |  Branch (2971:26): [True: 0, False: 0]
  ------------------
 2972|    175|    lodepng_memcpy(dest->palette, source->palette, source->palettesize * 4);
 2973|    175|  }
 2974|  1.63k|  return 0;
 2975|  1.63k|}
_Z21lodepng_palette_clearP16LodePNGColorMode:
 3002|  17.9k|void lodepng_palette_clear(LodePNGColorMode* info) {
 3003|  17.9k|  if(info->palette) lodepng_free(info->palette);
  ------------------
  |  Branch (3003:6): [True: 767, False: 17.2k]
  ------------------
 3004|  17.9k|  info->palette = 0;
 3005|  17.9k|  info->palettesize = 0;
 3006|  17.9k|}
_Z15lodepng_get_bppPK16LodePNGColorMode:
 3026|  33.5k|unsigned lodepng_get_bpp(const LodePNGColorMode* info) {
 3027|  33.5k|  return lodepng_get_bpp_lct(info->colortype, info->bitdepth);
 3028|  33.5k|}
_Z20lodepng_get_raw_sizejjPK16LodePNGColorMode:
 3066|  11.1k|size_t lodepng_get_raw_size(unsigned w, unsigned h, const LodePNGColorMode* color) {
 3067|  11.1k|  return lodepng_get_raw_size_lct(w, h, color->colortype, color->bitdepth);
 3068|  11.1k|}
_Z16lodepng_add_textP11LodePNGInfoPKcS2_:
 3190|  96.5k|unsigned lodepng_add_text(LodePNGInfo* info, const char* key, const char* str) {
 3191|  96.5k|  return lodepng_add_text_sized(info, key, str, lodepng_strlen(str));
 3192|  96.5k|}
_Z17lodepng_clear_iccP11LodePNGInfo:
 3291|  12.6k|void lodepng_clear_icc(LodePNGInfo* info) {
 3292|  12.6k|  string_cleanup(&info->iccp_name);
 3293|  12.6k|  lodepng_free(info->iccp_profile);
 3294|  12.6k|  info->iccp_profile = NULL;
 3295|  12.6k|  info->iccp_profile_size = 0;
 3296|  12.6k|  info->iccp_defined = 0;
 3297|  12.6k|}
_Z17lodepng_info_initP11LodePNGInfo:
 3300|  11.9k|void lodepng_info_init(LodePNGInfo* info) {
 3301|  11.9k|  lodepng_color_mode_init(&info->color);
 3302|  11.9k|  info->interlace_method = 0;
 3303|  11.9k|  info->compression_method = 0;
 3304|  11.9k|  info->filter_method = 0;
 3305|  11.9k|#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
 3306|  11.9k|  info->background_defined = 0;
 3307|  11.9k|  info->background_r = info->background_g = info->background_b = 0;
 3308|       |
 3309|  11.9k|  LodePNGText_init(info);
 3310|  11.9k|  LodePNGIText_init(info);
 3311|       |
 3312|  11.9k|  info->time_defined = 0;
 3313|  11.9k|  info->phys_defined = 0;
 3314|       |
 3315|  11.9k|  info->gama_defined = 0;
 3316|  11.9k|  info->chrm_defined = 0;
 3317|  11.9k|  info->srgb_defined = 0;
 3318|  11.9k|  info->iccp_defined = 0;
 3319|  11.9k|  info->iccp_name = NULL;
 3320|  11.9k|  info->iccp_profile = NULL;
 3321|       |
 3322|  11.9k|  info->sbit_defined = 0;
 3323|  11.9k|  info->sbit_r = info->sbit_g = info->sbit_b = info->sbit_a = 0;
 3324|       |
 3325|  11.9k|  LodePNGUnknownChunks_init(info);
 3326|  11.9k|#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
 3327|  11.9k|}
_Z20lodepng_info_cleanupP11LodePNGInfo:
 3329|  11.9k|void lodepng_info_cleanup(LodePNGInfo* info) {
 3330|  11.9k|  lodepng_color_mode_cleanup(&info->color);
 3331|  11.9k|#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
 3332|  11.9k|  LodePNGText_cleanup(info);
 3333|  11.9k|  LodePNGIText_cleanup(info);
 3334|       |
 3335|  11.9k|  lodepng_clear_icc(info);
 3336|       |
 3337|  11.9k|  LodePNGUnknownChunks_cleanup(info);
 3338|  11.9k|#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
 3339|  11.9k|}
_Z15lodepng_convertPhPKhPK16LodePNGColorModeS4_jj:
 3797|  1.39k|                         unsigned w, unsigned h) {
 3798|  1.39k|  size_t i;
 3799|  1.39k|  ColorTree tree;
 3800|  1.39k|  size_t numpixels = (size_t)w * (size_t)h;
 3801|  1.39k|  unsigned error = 0;
 3802|       |
 3803|  1.39k|  if(mode_in->colortype == LCT_PALETTE && !mode_in->palette) {
  ------------------
  |  Branch (3803:6): [True: 117, False: 1.28k]
  |  Branch (3803:43): [True: 0, False: 117]
  ------------------
 3804|      0|    return 107; /* error: must provide palette if input mode is palette */
 3805|      0|  }
 3806|       |
 3807|  1.39k|  if(lodepng_color_mode_equal(mode_out, mode_in)) {
  ------------------
  |  Branch (3807:6): [True: 0, False: 1.39k]
  ------------------
 3808|      0|    size_t numbytes = lodepng_get_raw_size(w, h, mode_in);
 3809|      0|    lodepng_memcpy(out, in, numbytes);
 3810|      0|    return 0;
 3811|      0|  }
 3812|       |
 3813|  1.39k|  if(mode_out->colortype == LCT_PALETTE) {
  ------------------
  |  Branch (3813:6): [True: 138, False: 1.26k]
  ------------------
 3814|    138|    size_t palettesize = mode_out->palettesize;
 3815|    138|    const unsigned char* palette = mode_out->palette;
 3816|    138|    size_t palsize = (size_t)1u << mode_out->bitdepth;
 3817|       |    /*if the user specified output palette but did not give the values, assume
 3818|       |    they want the values of the input color type (assuming that one is palette).
 3819|       |    Note that we never create a new palette ourselves.*/
 3820|    138|    if(palettesize == 0) {
  ------------------
  |  Branch (3820:8): [True: 78, False: 60]
  ------------------
 3821|     78|      palettesize = mode_in->palettesize;
 3822|     78|      palette = mode_in->palette;
 3823|       |      /*if the input was also palette with same bitdepth, then the color types are also
 3824|       |      equal, so copy literally. This to preserve the exact indices that were in the PNG
 3825|       |      even in case there are duplicate colors in the palette.*/
 3826|     78|      if(mode_in->colortype == LCT_PALETTE && mode_in->bitdepth == mode_out->bitdepth) {
  ------------------
  |  Branch (3826:10): [True: 0, False: 78]
  |  Branch (3826:47): [True: 0, False: 0]
  ------------------
 3827|      0|        size_t numbytes = lodepng_get_raw_size(w, h, mode_in);
 3828|      0|        lodepng_memcpy(out, in, numbytes);
 3829|      0|        return 0;
 3830|      0|      }
 3831|     78|    }
 3832|    138|    if(palettesize < palsize) palsize = palettesize;
  ------------------
  |  Branch (3832:8): [True: 135, False: 3]
  ------------------
 3833|    138|    color_tree_init(&tree);
 3834|  2.65k|    for(i = 0; i != palsize; ++i) {
  ------------------
  |  Branch (3834:16): [True: 2.51k, False: 138]
  ------------------
 3835|  2.51k|      const unsigned char* p = &palette[i * 4];
 3836|  2.51k|      error = color_tree_add(&tree, p[0], p[1], p[2], p[3], (unsigned)i);
 3837|  2.51k|      if(error) break;
  ------------------
  |  Branch (3837:10): [True: 0, False: 2.51k]
  ------------------
 3838|  2.51k|    }
 3839|    138|  }
 3840|       |
 3841|  1.39k|  if(!error) {
  ------------------
  |  Branch (3841:6): [True: 1.39k, False: 0]
  ------------------
 3842|  1.39k|    if(mode_in->bitdepth == 16 && mode_out->bitdepth == 16) {
  ------------------
  |  Branch (3842:8): [True: 611, False: 788]
  |  Branch (3842:35): [True: 166, False: 445]
  ------------------
 3843|   203k|      for(i = 0; i != numpixels; ++i) {
  ------------------
  |  Branch (3843:18): [True: 203k, False: 166]
  ------------------
 3844|   203k|        unsigned short r = 0, g = 0, b = 0, a = 0;
 3845|   203k|        getPixelColorRGBA16(&r, &g, &b, &a, in, i, mode_in);
 3846|   203k|        rgba16ToPixel(out, i, mode_out, r, g, b, a);
 3847|   203k|      }
 3848|  1.23k|    } else if(mode_out->bitdepth == 8 && mode_out->colortype == LCT_RGBA) {
  ------------------
  |  Branch (3848:15): [True: 1.08k, False: 145]
  |  Branch (3848:42): [True: 428, False: 660]
  ------------------
 3849|    428|      getPixelColorsRGBA8(out, numpixels, in, mode_in);
 3850|    805|    } else if(mode_out->bitdepth == 8 && mode_out->colortype == LCT_RGB) {
  ------------------
  |  Branch (3850:15): [True: 660, False: 145]
  |  Branch (3850:42): [True: 195, False: 465]
  ------------------
 3851|    195|      getPixelColorsRGB8(out, numpixels, in, mode_in);
 3852|    610|    } else {
 3853|    610|      unsigned char r = 0, g = 0, b = 0, a = 0;
 3854|  42.2M|      for(i = 0; i != numpixels; ++i) {
  ------------------
  |  Branch (3854:18): [True: 42.2M, False: 501]
  ------------------
 3855|  42.2M|        getPixelColorRGBA8(&r, &g, &b, &a, in, i, mode_in);
 3856|  42.2M|        error = rgba8ToPixel(out, i, mode_out, &tree, r, g, b, a);
 3857|  42.2M|        if(error) break;
  ------------------
  |  Branch (3857:12): [True: 109, False: 42.2M]
  ------------------
 3858|  42.2M|      }
 3859|    610|    }
 3860|  1.39k|  }
 3861|       |
 3862|  1.39k|  if(mode_out->colortype == LCT_PALETTE) {
  ------------------
  |  Branch (3862:6): [True: 138, False: 1.26k]
  ------------------
 3863|    138|    color_tree_cleanup(&tree);
 3864|    138|  }
 3865|       |
 3866|  1.39k|  return error;
 3867|  1.39k|}
_Z15lodepng_inspectPjS_P12LodePNGStatePKhm:
 4308|  7.63k|                         const unsigned char* in, size_t insize) {
 4309|  7.63k|  unsigned width, height;
 4310|  7.63k|  LodePNGInfo* info = &state->info_png;
 4311|  7.63k|  if(insize == 0 || in == 0) {
  ------------------
  |  Branch (4311:6): [True: 0, False: 7.63k]
  |  Branch (4311:21): [True: 0, False: 7.63k]
  ------------------
 4312|      0|    CERROR_RETURN_ERROR(state->error, 48); /*error: the given data is empty*/
  ------------------
  |  |  188|      0|#define CERROR_RETURN_ERROR(errorvar, code){\
  |  |  189|      0|  errorvar = code;\
  |  |  190|      0|  return code;\
  |  |  191|      0|}
  ------------------
 4313|      0|  }
 4314|  7.63k|  if(insize < 33) {
  ------------------
  |  Branch (4314:6): [True: 10, False: 7.62k]
  ------------------
 4315|     10|    CERROR_RETURN_ERROR(state->error, 27); /*error: the data length is smaller than the length of a PNG header*/
  ------------------
  |  |  188|     10|#define CERROR_RETURN_ERROR(errorvar, code){\
  |  |  189|     10|  errorvar = code;\
  |  |  190|     10|  return code;\
  |  |  191|     10|}
  ------------------
 4316|      0|  }
 4317|       |
 4318|       |  /*when decoding a new PNG image, make sure all parameters created after previous decoding are reset*/
 4319|       |  /* TODO: remove this. One should use a new LodePNGState for new sessions */
 4320|  7.62k|  lodepng_info_cleanup(info);
 4321|  7.62k|  lodepng_info_init(info);
 4322|       |
 4323|  7.62k|  if(in[0] != 137 || in[1] != 80 || in[2] != 78 || in[3] != 71
  ------------------
  |  Branch (4323:6): [True: 12, False: 7.61k]
  |  Branch (4323:22): [True: 11, False: 7.60k]
  |  Branch (4323:37): [True: 11, False: 7.59k]
  |  Branch (4323:52): [True: 9, False: 7.58k]
  ------------------
 4324|  7.62k|     || in[4] != 13 || in[5] != 10 || in[6] != 26 || in[7] != 10) {
  ------------------
  |  Branch (4324:9): [True: 11, False: 7.57k]
  |  Branch (4324:24): [True: 9, False: 7.56k]
  |  Branch (4324:39): [True: 10, False: 7.55k]
  |  Branch (4324:54): [True: 10, False: 7.54k]
  ------------------
 4325|     83|    CERROR_RETURN_ERROR(state->error, 28); /*error: the first 8 bytes are not the correct PNG signature*/
  ------------------
  |  |  188|     83|#define CERROR_RETURN_ERROR(errorvar, code){\
  |  |  189|     83|  errorvar = code;\
  |  |  190|     83|  return code;\
  |  |  191|     83|}
  ------------------
 4326|      0|  }
 4327|  7.54k|  if(lodepng_chunk_length(in + 8) != 13) {
  ------------------
  |  Branch (4327:6): [True: 47, False: 7.49k]
  ------------------
 4328|     47|    CERROR_RETURN_ERROR(state->error, 94); /*error: header size must be 13 bytes*/
  ------------------
  |  |  188|     47|#define CERROR_RETURN_ERROR(errorvar, code){\
  |  |  189|     47|  errorvar = code;\
  |  |  190|     47|  return code;\
  |  |  191|     47|}
  ------------------
 4329|      0|  }
 4330|  7.49k|  if(!lodepng_chunk_type_equals(in + 8, "IHDR")) {
  ------------------
  |  Branch (4330:6): [True: 47, False: 7.44k]
  ------------------
 4331|     47|    CERROR_RETURN_ERROR(state->error, 29); /*error: it doesn't start with a IHDR chunk!*/
  ------------------
  |  |  188|     47|#define CERROR_RETURN_ERROR(errorvar, code){\
  |  |  189|     47|  errorvar = code;\
  |  |  190|     47|  return code;\
  |  |  191|     47|}
  ------------------
 4332|      0|  }
 4333|       |
 4334|       |  /*read the values given in the header*/
 4335|  7.44k|  width = lodepng_read32bitInt(&in[16]);
 4336|  7.44k|  height = lodepng_read32bitInt(&in[20]);
 4337|       |  /*TODO: remove the undocumented feature that allows to give null pointers to width or height*/
 4338|  7.44k|  if(w) *w = width;
  ------------------
  |  Branch (4338:6): [True: 7.44k, False: 0]
  ------------------
 4339|  7.44k|  if(h) *h = height;
  ------------------
  |  Branch (4339:6): [True: 7.44k, False: 0]
  ------------------
 4340|  7.44k|  info->color.bitdepth = in[24];
 4341|  7.44k|  info->color.colortype = (LodePNGColorType)in[25];
 4342|  7.44k|  info->compression_method = in[26];
 4343|  7.44k|  info->filter_method = in[27];
 4344|  7.44k|  info->interlace_method = in[28];
 4345|       |
 4346|       |  /*errors returned only after the parsing so other values are still output*/
 4347|       |
 4348|       |  /*error: invalid image size*/
 4349|  7.44k|  if(width == 0 || height == 0) CERROR_RETURN_ERROR(state->error, 93);
  ------------------
  |  |  188|      4|#define CERROR_RETURN_ERROR(errorvar, code){\
  |  |  189|      4|  errorvar = code;\
  |  |  190|      4|  return code;\
  |  |  191|      4|}
  ------------------
  |  Branch (4349:6): [True: 1, False: 7.44k]
  |  Branch (4349:20): [True: 3, False: 7.44k]
  ------------------
 4350|       |  /*error: invalid colortype or bitdepth combination*/
 4351|  7.44k|  state->error = checkColorValidity(info->color.colortype, info->color.bitdepth);
 4352|  7.44k|  if(state->error) return state->error;
  ------------------
  |  Branch (4352:6): [True: 73, False: 7.37k]
  ------------------
 4353|       |  /*error: only compression method 0 is allowed in the specification*/
 4354|  7.37k|  if(info->compression_method != 0) CERROR_RETURN_ERROR(state->error, 32);
  ------------------
  |  |  188|      8|#define CERROR_RETURN_ERROR(errorvar, code){\
  |  |  189|      8|  errorvar = code;\
  |  |  190|      8|  return code;\
  |  |  191|      8|}
  ------------------
  |  Branch (4354:6): [True: 8, False: 7.36k]
  ------------------
 4355|       |  /*error: only filter method 0 is allowed in the specification*/
 4356|  7.36k|  if(info->filter_method != 0) CERROR_RETURN_ERROR(state->error, 33);
  ------------------
  |  |  188|      5|#define CERROR_RETURN_ERROR(errorvar, code){\
  |  |  189|      5|  errorvar = code;\
  |  |  190|      5|  return code;\
  |  |  191|      5|}
  ------------------
  |  Branch (4356:6): [True: 5, False: 7.35k]
  ------------------
 4357|       |  /*error: only interlace methods 0 and 1 exist in the specification*/
 4358|  7.35k|  if(info->interlace_method > 1) CERROR_RETURN_ERROR(state->error, 34);
  ------------------
  |  |  188|      7|#define CERROR_RETURN_ERROR(errorvar, code){\
  |  |  189|      7|  errorvar = code;\
  |  |  190|      7|  return code;\
  |  |  191|      7|}
  ------------------
  |  Branch (4358:6): [True: 7, False: 7.35k]
  ------------------
 4359|       |
 4360|  7.35k|  if(!state->decoder.ignore_crc) {
  ------------------
  |  Branch (4360:6): [True: 0, False: 7.35k]
  ------------------
 4361|      0|    unsigned CRC = lodepng_read32bitInt(&in[29]);
 4362|      0|    unsigned checksum = lodepng_crc32(&in[12], 17);
 4363|      0|    if(CRC != checksum) {
  ------------------
  |  Branch (4363:8): [True: 0, False: 0]
  ------------------
 4364|      0|      CERROR_RETURN_ERROR(state->error, 57); /*invalid CRC*/
  ------------------
  |  |  188|      0|#define CERROR_RETURN_ERROR(errorvar, code){\
  |  |  189|      0|  errorvar = code;\
  |  |  190|      0|  return code;\
  |  |  191|      0|}
  ------------------
 4365|      0|    }
 4366|      0|  }
 4367|       |
 4368|  7.35k|  return state->error;
 4369|  7.35k|}
_Z14lodepng_decodePPhPjS1_P12LodePNGStatePKhm:
 5364|  7.63k|                        const unsigned char* in, size_t insize) {
 5365|  7.63k|  *out = 0;
 5366|  7.63k|  decodeGeneric(out, w, h, state, in, insize);
 5367|  7.63k|  if(state->error) return state->error;
  ------------------
  |  Branch (5367:6): [True: 2.71k, False: 4.91k]
  ------------------
 5368|  4.91k|  if(!state->decoder.color_convert || lodepng_color_mode_equal(&state->info_raw, &state->info_png.color)) {
  ------------------
  |  Branch (5368:6): [True: 1.63k, False: 3.27k]
  |  Branch (5368:39): [True: 1.69k, False: 1.58k]
  ------------------
 5369|       |    /*same color type, no copying or converting of data needed*/
 5370|       |    /*store the info_png color settings on the info_raw so that the info_raw still reflects what colortype
 5371|       |    the raw image has to the end user*/
 5372|  3.33k|    if(!state->decoder.color_convert) {
  ------------------
  |  Branch (5372:8): [True: 1.63k, False: 1.69k]
  ------------------
 5373|  1.63k|      state->error = lodepng_color_mode_copy(&state->info_raw, &state->info_png.color);
 5374|  1.63k|      if(state->error) return state->error;
  ------------------
  |  Branch (5374:10): [True: 0, False: 1.63k]
  ------------------
 5375|  1.63k|    }
 5376|  3.33k|  } else { /*color conversion needed*/
 5377|  1.58k|    unsigned char* data = *out;
 5378|  1.58k|    size_t outsize;
 5379|       |
 5380|       |    /*TODO: check if this works according to the statement in the documentation: "The converter can convert
 5381|       |    from grayscale input color type, to 8-bit grayscale or grayscale with alpha"*/
 5382|  1.58k|    if(!(state->info_raw.colortype == LCT_RGB || state->info_raw.colortype == LCT_RGBA)
  ------------------
  |  Branch (5382:10): [True: 348, False: 1.23k]
  |  Branch (5382:50): [True: 586, False: 653]
  ------------------
 5383|  1.58k|       && !(state->info_raw.bitdepth == 8)) {
  ------------------
  |  Branch (5383:11): [True: 188, False: 465]
  ------------------
 5384|    188|      return 56; /*unsupported color mode conversion*/
 5385|    188|    }
 5386|       |
 5387|  1.39k|    outsize = lodepng_get_raw_size(*w, *h, &state->info_raw);
 5388|  1.39k|    *out = (unsigned char*)lodepng_malloc(outsize);
 5389|  1.39k|    if(!(*out)) {
  ------------------
  |  Branch (5389:8): [True: 0, False: 1.39k]
  ------------------
 5390|      0|      state->error = 83; /*alloc fail*/
 5391|      0|    }
 5392|  1.39k|    else state->error = lodepng_convert(*out, data, &state->info_raw,
 5393|  1.39k|                                        &state->info_png.color, *w, *h);
 5394|  1.39k|    lodepng_free(data);
 5395|  1.39k|  }
 5396|  4.72k|  return state->error;
 5397|  4.91k|}
_Z29lodepng_decoder_settings_initP22LodePNGDecoderSettings:
 5448|  4.35k|void lodepng_decoder_settings_init(LodePNGDecoderSettings* settings) {
 5449|  4.35k|  settings->color_convert = 1;
 5450|  4.35k|#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
 5451|  4.35k|  settings->read_text_chunks = 1;
 5452|  4.35k|  settings->remember_unknown_chunks = 0;
 5453|  4.35k|  settings->max_text_size = 16777216;
 5454|  4.35k|  settings->max_icc_size = 16777216; /* 16MB is much more than enough for any reasonable ICC profile */
 5455|  4.35k|#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
 5456|  4.35k|  settings->ignore_crc = 0;
 5457|  4.35k|  settings->ignore_critical = 0;
 5458|  4.35k|  settings->ignore_end = 0;
 5459|  4.35k|  lodepng_decompress_settings_init(&settings->zlibsettings);
 5460|  4.35k|}
_Z18lodepng_state_initP12LodePNGState:
 5466|  4.35k|void lodepng_state_init(LodePNGState* state) {
 5467|  4.35k|#ifdef LODEPNG_COMPILE_DECODER
 5468|  4.35k|  lodepng_decoder_settings_init(&state->decoder);
 5469|  4.35k|#endif /*LODEPNG_COMPILE_DECODER*/
 5470|  4.35k|#ifdef LODEPNG_COMPILE_ENCODER
 5471|  4.35k|  lodepng_encoder_settings_init(&state->encoder);
 5472|  4.35k|#endif /*LODEPNG_COMPILE_ENCODER*/
 5473|  4.35k|  lodepng_color_mode_init(&state->info_raw);
 5474|  4.35k|  lodepng_info_init(&state->info_png);
 5475|  4.35k|  state->error = 1;
 5476|  4.35k|}
_Z21lodepng_state_cleanupP12LodePNGState:
 5478|  4.35k|void lodepng_state_cleanup(LodePNGState* state) {
 5479|  4.35k|  lodepng_color_mode_cleanup(&state->info_raw);
 5480|  4.35k|  lodepng_info_cleanup(&state->info_png);
 5481|  4.35k|}
_Z29lodepng_encoder_settings_initP22LodePNGEncoderSettings:
 6643|  4.35k|void lodepng_encoder_settings_init(LodePNGEncoderSettings* settings) {
 6644|  4.35k|  lodepng_compress_settings_init(&settings->zlibsettings);
 6645|  4.35k|  settings->filter_palette_zero = 1;
 6646|  4.35k|  settings->filter_strategy = LFS_MINSUM;
 6647|  4.35k|  settings->auto_convert = 1;
 6648|  4.35k|  settings->force_palette = 0;
 6649|  4.35k|  settings->predefined_filters = 0;
 6650|  4.35k|#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
 6651|  4.35k|  settings->add_id = 0;
 6652|  4.35k|  settings->text_compression = 1;
 6653|  4.35k|#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
 6654|  4.35k|}
_ZN7lodepng5StateC2Ev:
 6859|  4.35k|State::State() {
 6860|  4.35k|  lodepng_state_init(this);
 6861|  4.35k|}
_ZN7lodepng5StateD2Ev:
 6868|  4.35k|State::~State() {
 6869|  4.35k|  lodepng_state_cleanup(this);
 6870|  4.35k|}
_ZN7lodepng6decodeERNSt3__16vectorIhNS0_9allocatorIhEEEERjS6_RNS_5StateEPKhm:
 6901|  7.63k|                const unsigned char* in, size_t insize) {
 6902|  7.63k|  unsigned char* buffer = NULL;
 6903|  7.63k|  unsigned error = lodepng_decode(&buffer, &w, &h, &state, in, insize);
 6904|  7.63k|  if(buffer && !error) {
  ------------------
  |  Branch (6904:6): [True: 5.12k, False: 2.50k]
  |  Branch (6904:16): [True: 4.62k, False: 508]
  ------------------
 6905|  4.62k|    size_t buffersize = lodepng_get_raw_size(w, h, &state.info_raw);
 6906|  4.62k|    out.insert(out.end(), buffer, &buffer[buffersize]);
 6907|  4.62k|  }
 6908|  7.63k|  lodepng_free(buffer);
 6909|  7.63k|  return error;
 6910|  7.63k|}
lodepng.cpp:_ZL14lodepng_mallocm:
   74|  1.23M|static void* lodepng_malloc(size_t size) {
   75|  1.23M|#ifdef LODEPNG_MAX_ALLOC
   76|  1.23M|  if(size > LODEPNG_MAX_ALLOC) return 0;
  ------------------
  |  Branch (76:6): [True: 0, False: 1.23M]
  ------------------
   77|  1.23M|#endif
   78|  1.23M|  return malloc(size);
   79|  1.23M|}
lodepng.cpp:_ZL14lodepng_memsetPvim:
  127|  50.2k|                           int value, size_t num) {
  128|  50.2k|  size_t i;
  129|  94.6M|  for(i = 0; i < num; i++) ((char*)dst)[i] = (char)value;
  ------------------
  |  Branch (129:14): [True: 94.6M, False: 50.2k]
  ------------------
  130|  50.2k|}
lodepng.cpp:_ZL12lodepng_freePv:
   89|  1.38M|static void lodepng_free(void* ptr) {
   90|  1.38M|  free(ptr);
   91|  1.38M|}
lodepng.cpp:_ZL13ucvector_initPhm:
  288|  8.97k|static ucvector ucvector_init(unsigned char* buffer, size_t size) {
  289|  8.97k|  ucvector v;
  290|  8.97k|  v.data = buffer;
  291|  8.97k|  v.allocsize = v.size = size;
  292|  8.97k|  return v;
  293|  8.97k|}
lodepng.cpp:_ZL16lodepng_inflatevP8ucvectorPKhmPK25LodePNGDecompressSettings:
 1383|  8.36k|                                 const LodePNGDecompressSettings* settings) {
 1384|  8.36k|  unsigned BFINAL = 0;
 1385|  8.36k|  LodePNGBitReader reader;
 1386|  8.36k|  unsigned error = LodePNGBitReader_init(&reader, in, insize);
 1387|       |
 1388|  8.36k|  if(error) return error;
  ------------------
  |  Branch (1388:6): [True: 0, False: 8.36k]
  ------------------
 1389|       |
 1390|  27.7k|  while(!BFINAL) {
  ------------------
  |  Branch (1390:9): [True: 20.1k, False: 7.55k]
  ------------------
 1391|  20.1k|    unsigned BTYPE;
 1392|  20.1k|    if(reader.bitsize - reader.bp < 3) return 52; /*error, bit pointer will jump past memory*/
  ------------------
  |  Branch (1392:8): [True: 12, False: 20.1k]
  ------------------
 1393|  20.1k|    ensureBits9(&reader, 3);
 1394|  20.1k|    BFINAL = readBits(&reader, 1);
 1395|  20.1k|    BTYPE = readBits(&reader, 2);
 1396|       |
 1397|  20.1k|    if(BTYPE == 3) return 20; /*error: invalid BTYPE*/
  ------------------
  |  Branch (1397:8): [True: 15, False: 20.1k]
  ------------------
 1398|  20.1k|    else if(BTYPE == 0) error = inflateNoCompression(out, &reader, settings); /*no compression*/
  ------------------
  |  Branch (1398:13): [True: 6.87k, False: 13.2k]
  ------------------
 1399|  13.2k|    else error = inflateHuffmanBlock(out, &reader, BTYPE, settings->max_output_size); /*compression, BTYPE 01 or 10*/
 1400|  20.1k|    if(!error && settings->max_output_size && out->size > settings->max_output_size) error = 109;
  ------------------
  |  Branch (1400:8): [True: 19.3k, False: 774]
  |  Branch (1400:18): [True: 10.3k, False: 9.02k]
  |  Branch (1400:47): [True: 9, False: 10.3k]
  ------------------
 1401|  20.1k|    if(error) break;
  ------------------
  |  Branch (1401:8): [True: 783, False: 19.3k]
  ------------------
 1402|  20.1k|  }
 1403|       |
 1404|  8.33k|  return error;
 1405|  8.36k|}
lodepng.cpp:_ZL21LodePNGBitReader_initP16LodePNGBitReaderPKhm:
  469|  8.36k|static unsigned LodePNGBitReader_init(LodePNGBitReader* reader, const unsigned char* data, size_t size) {
  470|  8.36k|  size_t temp;
  471|  8.36k|  reader->data = data;
  472|  8.36k|  reader->size = size;
  473|       |  /* size in bits, return error if overflow (if size_t is 32 bit this supports up to 500MB)  */
  474|  8.36k|  if(lodepng_mulofl(size, 8u, &reader->bitsize)) return 105;
  ------------------
  |  Branch (474:6): [True: 0, False: 8.36k]
  ------------------
  475|       |  /*ensure incremented bp can be compared to bitsize without overflow even when it would be incremented 32 too much and
  476|       |  trying to ensure 32 more bits*/
  477|  8.36k|  if(lodepng_addofl(reader->bitsize, 64u, &temp)) return 105;
  ------------------
  |  Branch (477:6): [True: 0, False: 8.36k]
  ------------------
  478|  8.36k|  reader->bp = 0;
  479|  8.36k|  reader->buffer = 0;
  480|  8.36k|  return 0; /*ok*/
  481|  8.36k|}
lodepng.cpp:_ZL14lodepng_muloflmmPm:
  156|  37.6k|static int lodepng_mulofl(size_t a, size_t b, size_t* result) {
  157|  37.6k|  *result = a * b; /* Unsigned multiplication is well defined and safe in C90 */
  158|  37.6k|  return (a != 0 && *result / a != b);
  ------------------
  |  Branch (158:11): [True: 33.3k, False: 4.37k]
  |  Branch (158:21): [True: 59, False: 33.2k]
  ------------------
  159|  37.6k|}
lodepng.cpp:_ZL11ensureBits9P16LodePNGBitReaderm:
  492|  60.2k|static LODEPNG_INLINE void ensureBits9(LodePNGBitReader* reader, size_t nbits) {
  493|  60.2k|  size_t start = reader->bp >> 3u;
  494|  60.2k|  size_t size = reader->size;
  495|  60.2k|  if(start + 1u < size) {
  ------------------
  |  Branch (495:6): [True: 60.1k, False: 140]
  ------------------
  496|  60.1k|    reader->buffer = (unsigned)reader->data[start + 0] | ((unsigned)reader->data[start + 1] << 8u);
  497|  60.1k|    reader->buffer >>= (reader->bp & 7u);
  498|  60.1k|  } else {
  499|    140|    reader->buffer = 0;
  500|    140|    if(start + 0u < size) reader->buffer = reader->data[start + 0];
  ------------------
  |  Branch (500:8): [True: 140, False: 0]
  ------------------
  501|    140|    reader->buffer >>= (reader->bp & 7u);
  502|    140|  }
  503|  60.2k|  (void)nbits;
  504|  60.2k|}
lodepng.cpp:_ZL8readBitsP16LodePNGBitReaderm:
  574|  3.69M|static LODEPNG_INLINE unsigned readBits(LodePNGBitReader* reader, size_t nbits) {
  575|  3.69M|  unsigned result = peekBits(reader, nbits);
  576|  3.69M|  advanceBits(reader, nbits);
  577|  3.69M|  return result;
  578|  3.69M|}
lodepng.cpp:_ZL8peekBitsP16LodePNGBitReaderm:
  562|  36.8M|static LODEPNG_INLINE unsigned peekBits(LodePNGBitReader* reader, size_t nbits) {
  563|       |  /* The shift allows nbits to be only up to 31. */
  564|  36.8M|  return reader->buffer & ((1u << nbits) - 1u);
  565|  36.8M|}
lodepng.cpp:_ZL11advanceBitsP16LodePNGBitReaderm:
  568|  36.8M|static LODEPNG_INLINE void advanceBits(LodePNGBitReader* reader, size_t nbits) {
  569|  36.8M|  reader->buffer >>= nbits;
  570|  36.8M|  reader->bp += nbits;
  571|  36.8M|}
lodepng.cpp:_ZL20inflateNoCompressionP8ucvectorP16LodePNGBitReaderPK25LodePNGDecompressSettings:
 1347|  6.87k|                                     const LodePNGDecompressSettings* settings) {
 1348|  6.87k|  size_t bytepos;
 1349|  6.87k|  size_t size = reader->size;
 1350|  6.87k|  unsigned LEN, NLEN, error = 0;
 1351|       |
 1352|       |  /*go to first boundary of byte*/
 1353|  6.87k|  bytepos = (reader->bp + 7u) >> 3u;
 1354|       |
 1355|       |  /*read LEN (2 bytes) and NLEN (2 bytes)*/
 1356|  6.87k|  if(bytepos + 4 >= size) return 52; /*error, bit pointer will jump past memory*/
  ------------------
  |  Branch (1356:6): [True: 30, False: 6.84k]
  ------------------
 1357|  6.84k|  LEN = (unsigned)reader->data[bytepos] + ((unsigned)reader->data[bytepos + 1] << 8u); bytepos += 2;
 1358|  6.84k|  NLEN = (unsigned)reader->data[bytepos] + ((unsigned)reader->data[bytepos + 1] << 8u); bytepos += 2;
 1359|       |
 1360|       |  /*check if 16-bit NLEN is really the one's complement of LEN*/
 1361|  6.84k|  if(!settings->ignore_nlen && LEN + NLEN != 65535) {
  ------------------
  |  Branch (1361:6): [True: 0, False: 6.84k]
  |  Branch (1361:32): [True: 0, False: 0]
  ------------------
 1362|      0|    return 21; /*error: NLEN is not one's complement of LEN*/
 1363|      0|  }
 1364|       |
 1365|  6.84k|  if(!ucvector_resize(out, out->size + LEN)) return 83; /*alloc fail*/
  ------------------
  |  Branch (1365:6): [True: 0, False: 6.84k]
  ------------------
 1366|       |
 1367|       |  /*read the literal data: LEN bytes are now stored in the out buffer*/
 1368|  6.84k|  if(bytepos + LEN > size) return 23; /*error: reading outside of in buffer*/
  ------------------
  |  Branch (1368:6): [True: 95, False: 6.75k]
  ------------------
 1369|       |
 1370|       |  /*out->data can be NULL (when LEN is zero), and arithmetics on NULL ptr is undefined*/
 1371|  6.75k|  if (LEN) {
  ------------------
  |  Branch (1371:7): [True: 660, False: 6.09k]
  ------------------
 1372|    660|    lodepng_memcpy(out->data + out->size - LEN, reader->data + bytepos, LEN);
 1373|    660|    bytepos += LEN;
 1374|    660|  }
 1375|       |
 1376|  6.75k|  reader->bp = bytepos << 3u;
 1377|       |
 1378|  6.75k|  return error;
 1379|  6.84k|}
lodepng.cpp:_ZL15ucvector_resizeP8ucvectorm:
  283|  13.2k|static unsigned ucvector_resize(ucvector* p, size_t size) {
  284|  13.2k|  p->size = size;
  285|  13.2k|  return ucvector_reserve(p, size);
  286|  13.2k|}
lodepng.cpp:_ZL16ucvector_reserveP8ucvectorm:
  269|  40.6k|static unsigned ucvector_reserve(ucvector* p, size_t size) {
  270|  40.6k|  if(size > p->allocsize) {
  ------------------
  |  Branch (270:6): [True: 27.7k, False: 12.9k]
  ------------------
  271|  27.7k|    size_t newsize = size + (p->allocsize >> 1u);
  272|  27.7k|    void* data = lodepng_realloc(p->data, newsize);
  273|  27.7k|    if(data) {
  ------------------
  |  Branch (273:8): [True: 26.9k, False: 754]
  ------------------
  274|  26.9k|      p->allocsize = newsize;
  275|  26.9k|      p->data = (unsigned char*)data;
  276|  26.9k|    }
  277|    754|    else return 0; /*error: not enough memory*/
  278|  27.7k|  }
  279|  39.8k|  return 1; /*success*/
  280|  40.6k|}
lodepng.cpp:_ZL19inflateHuffmanBlockP8ucvectorP16LodePNGBitReaderjm:
 1239|  13.2k|                                    unsigned btype, size_t max_output_size) {
 1240|  13.2k|  unsigned error = 0;
 1241|  13.2k|  HuffmanTree tree_ll; /*the huffman tree for literal and length codes*/
 1242|  13.2k|  HuffmanTree tree_d; /*the huffman tree for distance codes*/
 1243|  13.2k|  const size_t reserved_size = 260; /* must be at least 258 for max length, and a few extra for adding a few extra literals */
 1244|  13.2k|  int done = 0;
 1245|       |
 1246|  13.2k|  if(!ucvector_reserve(out, out->size + reserved_size)) return 83; /*alloc fail*/
  ------------------
  |  Branch (1246:6): [True: 0, False: 13.2k]
  ------------------
 1247|       |
 1248|  13.2k|  HuffmanTree_init(&tree_ll);
 1249|  13.2k|  HuffmanTree_init(&tree_d);
 1250|       |
 1251|  13.2k|  if(btype == 1) error = getTreeInflateFixed(&tree_ll, &tree_d);
  ------------------
  |  Branch (1251:6): [True: 10.3k, False: 2.85k]
  ------------------
 1252|  2.85k|  else /*if(btype == 2)*/ error = getTreeInflateDynamic(&tree_ll, &tree_d, reader);
 1253|       |
 1254|       |
 1255|  15.4M|  while(!error && !done) /*decode all symbols until end reached, breaks at end code*/ {
  ------------------
  |  Branch (1255:9): [True: 15.4M, False: 341]
  |  Branch (1255:19): [True: 15.4M, False: 12.5k]
  ------------------
 1256|       |    /*code_ll is literal, length or end code*/
 1257|  15.4M|    unsigned code_ll;
 1258|       |    /* ensure enough bits for 2 huffman code reads (15 bits each): if the first is a literal, a second literal is read at once. This
 1259|       |    appears to be slightly faster, than ensuring 20 bits here for 1 huffman symbol and the potential 5 extra bits for the length symbol.*/
 1260|  15.4M|    ensureBits32(reader, 30);
 1261|  15.4M|    code_ll = huffmanDecodeSymbol(reader, &tree_ll);
 1262|  15.4M|    if(code_ll <= 255) {
  ------------------
  |  Branch (1262:8): [True: 5.08M, False: 10.3M]
  ------------------
 1263|       |      /*slightly faster code path if multiple literals in a row*/
 1264|  5.08M|      out->data[out->size++] = (unsigned char)code_ll;
 1265|  5.08M|      code_ll = huffmanDecodeSymbol(reader, &tree_ll);
 1266|  5.08M|    }
 1267|  15.4M|    if(code_ll <= 255) /*literal symbol*/ {
  ------------------
  |  Branch (1267:8): [True: 3.18M, False: 12.2M]
  ------------------
 1268|  3.18M|      out->data[out->size++] = (unsigned char)code_ll;
 1269|  12.2M|    } else if(code_ll >= FIRST_LENGTH_CODE_INDEX && code_ll <= LAST_LENGTH_CODE_INDEX) /*length code*/ {
  ------------------
  |  |  592|  24.5M|#define FIRST_LENGTH_CODE_INDEX 257
  ------------------
                  } else if(code_ll >= FIRST_LENGTH_CODE_INDEX && code_ll <= LAST_LENGTH_CODE_INDEX) /*length code*/ {
  ------------------
  |  |  593|  12.2M|#define LAST_LENGTH_CODE_INDEX 285
  ------------------
  |  Branch (1269:15): [True: 12.2M, False: 12.6k]
  |  Branch (1269:53): [True: 12.2M, False: 8]
  ------------------
 1270|  12.2M|      unsigned code_d, distance;
 1271|  12.2M|      unsigned numextrabits_l, numextrabits_d; /*extra bits for length and distance*/
 1272|  12.2M|      size_t start, backward, length;
 1273|       |
 1274|       |      /*part 1: get length base*/
 1275|  12.2M|      length = LENGTHBASE[code_ll - FIRST_LENGTH_CODE_INDEX];
  ------------------
  |  |  592|  12.2M|#define FIRST_LENGTH_CODE_INDEX 257
  ------------------
 1276|       |
 1277|       |      /*part 2: get extra bits and add the value of that to length*/
 1278|  12.2M|      numextrabits_l = LENGTHEXTRA[code_ll - FIRST_LENGTH_CODE_INDEX];
  ------------------
  |  |  592|  12.2M|#define FIRST_LENGTH_CODE_INDEX 257
  ------------------
 1279|  12.2M|      if(numextrabits_l != 0) {
  ------------------
  |  Branch (1279:10): [True: 405k, False: 11.8M]
  ------------------
 1280|       |        /* bits already ensured above */
 1281|   405k|        ensureBits25(reader, 5);
 1282|   405k|        length += readBits(reader, numextrabits_l);
 1283|   405k|      }
 1284|       |
 1285|       |      /*part 3: get distance code*/
 1286|  12.2M|      ensureBits32(reader, 28); /* up to 15 for the huffman symbol, up to 13 for the extra bits */
 1287|  12.2M|      code_d = huffmanDecodeSymbol(reader, &tree_d);
 1288|  12.2M|      if(code_d > 29) {
  ------------------
  |  Branch (1288:10): [True: 11, False: 12.2M]
  ------------------
 1289|     11|        if(code_d <= 31) {
  ------------------
  |  Branch (1289:12): [True: 5, False: 6]
  ------------------
 1290|      5|          ERROR_BREAK(18); /*error: invalid distance code (30-31 are never used)*/
  ------------------
  |  |  185|      5|#define ERROR_BREAK(code) CERROR_BREAK(error, code)
  |  |  ------------------
  |  |  |  |  179|      5|#define CERROR_BREAK(errorvar, code){\
  |  |  |  |  180|      5|  errorvar = code;\
  |  |  |  |  181|      5|  break;\
  |  |  |  |  182|      5|}
  |  |  ------------------
  ------------------
 1291|      6|        } else /* if(code_d == INVALIDSYMBOL) */{
 1292|      6|          ERROR_BREAK(16); /*error: tried to read disallowed huffman symbol*/
  ------------------
  |  |  185|      6|#define ERROR_BREAK(code) CERROR_BREAK(error, code)
  |  |  ------------------
  |  |  |  |  179|      6|#define CERROR_BREAK(errorvar, code){\
  |  |  |  |  180|      6|  errorvar = code;\
  |  |  |  |  181|      6|  break;\
  |  |  |  |  182|      6|}
  |  |  ------------------
  ------------------
 1293|      0|        }
 1294|     11|      }
 1295|  12.2M|      distance = DISTANCEBASE[code_d];
 1296|       |
 1297|       |      /*part 4: get extra bits from distance*/
 1298|  12.2M|      numextrabits_d = DISTANCEEXTRA[code_d];
 1299|  12.2M|      if(numextrabits_d != 0) {
  ------------------
  |  Branch (1299:10): [True: 3.17M, False: 9.10M]
  ------------------
 1300|       |        /* bits already ensured above */
 1301|  3.17M|        distance += readBits(reader, numextrabits_d);
 1302|  3.17M|      }
 1303|       |
 1304|       |      /*part 5: fill in all the out[n] values based on the length and dist*/
 1305|  12.2M|      start = out->size;
 1306|  12.2M|      if(distance > start) ERROR_BREAK(52); /*too long backward distance*/
  ------------------
  |  |  185|     44|#define ERROR_BREAK(code) CERROR_BREAK(error, code)
  |  |  ------------------
  |  |  |  |  179|     44|#define CERROR_BREAK(errorvar, code){\
  |  |  |  |  180|     44|  errorvar = code;\
  |  |  |  |  181|     44|  break;\
  |  |  |  |  182|     44|}
  |  |  ------------------
  ------------------
  |  Branch (1306:10): [True: 44, False: 12.2M]
  ------------------
 1307|  12.2M|      backward = start - distance;
 1308|       |
 1309|  12.2M|      out->size += length;
 1310|  12.2M|      if(distance < length) {
  ------------------
  |  Branch (1310:10): [True: 9.19M, False: 3.08M]
  ------------------
 1311|  9.19M|        size_t forward;
 1312|  9.19M|        lodepng_memcpy(out->data + start, out->data + backward, distance);
 1313|  9.19M|        start += distance;
 1314|  2.34G|        for(forward = distance; forward < length; ++forward) {
  ------------------
  |  Branch (1314:33): [True: 2.33G, False: 9.19M]
  ------------------
 1315|  2.33G|          out->data[start++] = out->data[backward++];
 1316|  2.33G|        }
 1317|  9.19M|      } else {
 1318|  3.08M|        lodepng_memcpy(out->data + start, out->data + backward, length);
 1319|  3.08M|      }
 1320|  12.2M|    } else if(code_ll == 256) {
  ------------------
  |  Branch (1320:15): [True: 12.6k, False: 8]
  ------------------
 1321|  12.6k|      done = 1; /*end code, finish the loop*/
 1322|  12.6k|    } else /*if(code_ll == INVALIDSYMBOL)*/ {
 1323|      8|      ERROR_BREAK(16); /*error: tried to read disallowed huffman symbol*/
  ------------------
  |  |  185|      8|#define ERROR_BREAK(code) CERROR_BREAK(error, code)
  |  |  ------------------
  |  |  |  |  179|      8|#define CERROR_BREAK(errorvar, code){\
  |  |  |  |  180|      8|  errorvar = code;\
  |  |  |  |  181|      8|  break;\
  |  |  |  |  182|      8|}
  |  |  ------------------
  ------------------
 1324|      0|    }
 1325|  15.4M|    if(out->allocsize - out->size < reserved_size) {
  ------------------
  |  Branch (1325:8): [True: 14.1k, False: 15.4M]
  ------------------
 1326|  14.1k|      if(!ucvector_reserve(out, out->size + reserved_size)) ERROR_BREAK(83); /*alloc fail*/
  ------------------
  |  |  185|      4|#define ERROR_BREAK(code) CERROR_BREAK(error, code)
  |  |  ------------------
  |  |  |  |  179|      4|#define CERROR_BREAK(errorvar, code){\
  |  |  |  |  180|      4|  errorvar = code;\
  |  |  |  |  181|      4|  break;\
  |  |  |  |  182|      4|}
  |  |  ------------------
  ------------------
  |  Branch (1326:10): [True: 4, False: 14.1k]
  ------------------
 1327|  14.1k|    }
 1328|       |    /*check if any of the ensureBits above went out of bounds*/
 1329|  15.4M|    if(reader->bp > reader->bitsize) {
  ------------------
  |  Branch (1329:8): [True: 221, False: 15.4M]
  ------------------
 1330|       |      /*return error code 10 or 11 depending on the situation that happened in huffmanDecodeSymbol
 1331|       |      (10=no endcode, 11=wrong jump outside of tree)*/
 1332|       |      /* TODO: revise error codes 10,11,50: the above comment is no longer valid */
 1333|    221|      ERROR_BREAK(51); /*error, bit pointer jumps past memory*/
  ------------------
  |  |  185|    221|#define ERROR_BREAK(code) CERROR_BREAK(error, code)
  |  |  ------------------
  |  |  |  |  179|    221|#define CERROR_BREAK(errorvar, code){\
  |  |  |  |  180|    221|  errorvar = code;\
  |  |  |  |  181|    221|  break;\
  |  |  |  |  182|    221|}
  |  |  ------------------
  ------------------
 1334|      0|    }
 1335|  15.4M|    if(max_output_size && out->size > max_output_size) {
  ------------------
  |  Branch (1335:8): [True: 6.08M, False: 9.39M]
  |  Branch (1335:27): [True: 20, False: 6.08M]
  ------------------
 1336|     20|      ERROR_BREAK(109); /*error, larger than max size*/
  ------------------
  |  |  185|     20|#define ERROR_BREAK(code) CERROR_BREAK(error, code)
  |  |  ------------------
  |  |  |  |  179|     20|#define CERROR_BREAK(errorvar, code){\
  |  |  |  |  180|     20|  errorvar = code;\
  |  |  |  |  181|     20|  break;\
  |  |  |  |  182|     20|}
  |  |  ------------------
  ------------------
 1337|      0|    }
 1338|  15.4M|  }
 1339|       |
 1340|  13.2k|  HuffmanTree_cleanup(&tree_ll);
 1341|  13.2k|  HuffmanTree_cleanup(&tree_d);
 1342|       |
 1343|  13.2k|  return error;
 1344|  13.2k|}
lodepng.cpp:_ZL16HuffmanTree_initP11HuffmanTree:
  641|  29.3k|static void HuffmanTree_init(HuffmanTree* tree) {
  642|  29.3k|  tree->codes = 0;
  643|  29.3k|  tree->lengths = 0;
  644|  29.3k|  tree->table_len = 0;
  645|  29.3k|  tree->table_value = 0;
  646|  29.3k|}
lodepng.cpp:_ZL19getTreeInflateFixedP11HuffmanTreeS0_:
 1097|  10.3k|static unsigned getTreeInflateFixed(HuffmanTree* tree_ll, HuffmanTree* tree_d) {
 1098|  10.3k|  unsigned error = generateFixedLitLenTree(tree_ll);
 1099|  10.3k|  if(error) return error;
  ------------------
  |  Branch (1099:6): [True: 0, False: 10.3k]
  ------------------
 1100|  10.3k|  return generateFixedDistanceTree(tree_d);
 1101|  10.3k|}
lodepng.cpp:_ZL23generateFixedLitLenTreeP11HuffmanTree:
 1037|  10.3k|static unsigned generateFixedLitLenTree(HuffmanTree* tree) {
 1038|  10.3k|  unsigned i, error = 0;
 1039|  10.3k|  unsigned* bitlen = (unsigned*)lodepng_malloc(NUM_DEFLATE_CODE_SYMBOLS * sizeof(unsigned));
  ------------------
  |  |  595|  10.3k|#define NUM_DEFLATE_CODE_SYMBOLS 288
  ------------------
 1040|  10.3k|  if(!bitlen) return 83; /*alloc fail*/
  ------------------
  |  Branch (1040:6): [True: 0, False: 10.3k]
  ------------------
 1041|       |
 1042|       |  /*288 possible codes: 0-255=literals, 256=endcode, 257-285=lengthcodes, 286-287=unused*/
 1043|  1.50M|  for(i =   0; i <= 143; ++i) bitlen[i] = 8;
  ------------------
  |  Branch (1043:16): [True: 1.49M, False: 10.3k]
  ------------------
 1044|  1.17M|  for(i = 144; i <= 255; ++i) bitlen[i] = 9;
  ------------------
  |  Branch (1044:16): [True: 1.16M, False: 10.3k]
  ------------------
 1045|   259k|  for(i = 256; i <= 279; ++i) bitlen[i] = 7;
  ------------------
  |  Branch (1045:16): [True: 249k, False: 10.3k]
  ------------------
 1046|  93.5k|  for(i = 280; i <= 287; ++i) bitlen[i] = 8;
  ------------------
  |  Branch (1046:16): [True: 83.1k, False: 10.3k]
  ------------------
 1047|       |
 1048|  10.3k|  error = HuffmanTree_makeFromLengths(tree, bitlen, NUM_DEFLATE_CODE_SYMBOLS, 15);
  ------------------
  |  |  595|  10.3k|#define NUM_DEFLATE_CODE_SYMBOLS 288
  ------------------
 1049|       |
 1050|  10.3k|  lodepng_free(bitlen);
 1051|  10.3k|  return error;
 1052|  10.3k|}
lodepng.cpp:_ZL27HuffmanTree_makeFromLengthsP11HuffmanTreePKjmj:
  827|  28.6k|                                            size_t numcodes, unsigned maxbitlen) {
  828|  28.6k|  unsigned i;
  829|  28.6k|  tree->lengths = (unsigned*)lodepng_malloc(numcodes * sizeof(unsigned));
  830|  28.6k|  if(!tree->lengths) return 83; /*alloc fail*/
  ------------------
  |  Branch (830:6): [True: 0, False: 28.6k]
  ------------------
  831|  4.22M|  for(i = 0; i != numcodes; ++i) tree->lengths[i] = bitlen[i];
  ------------------
  |  Branch (831:14): [True: 4.19M, False: 28.6k]
  ------------------
  832|  28.6k|  tree->numcodes = (unsigned)numcodes; /*number of symbols*/
  833|  28.6k|  tree->maxbitlen = maxbitlen;
  834|  28.6k|  return HuffmanTree_makeFromLengths2(tree);
  835|  28.6k|}
lodepng.cpp:_ZL28HuffmanTree_makeFromLengths2P11HuffmanTree:
  785|  28.6k|static unsigned HuffmanTree_makeFromLengths2(HuffmanTree* tree) {
  786|  28.6k|  unsigned* blcount;
  787|  28.6k|  unsigned* nextcode;
  788|  28.6k|  unsigned error = 0;
  789|  28.6k|  unsigned bits, n;
  790|       |
  791|  28.6k|  tree->codes = (unsigned*)lodepng_malloc(tree->numcodes * sizeof(unsigned));
  792|  28.6k|  blcount = (unsigned*)lodepng_malloc((tree->maxbitlen + 1) * sizeof(unsigned));
  793|  28.6k|  nextcode = (unsigned*)lodepng_malloc((tree->maxbitlen + 1) * sizeof(unsigned));
  794|  28.6k|  if(!tree->codes || !blcount || !nextcode) error = 83; /*alloc fail*/
  ------------------
  |  Branch (794:6): [True: 0, False: 28.6k]
  |  Branch (794:22): [True: 0, False: 28.6k]
  |  Branch (794:34): [True: 0, False: 28.6k]
  ------------------
  795|       |
  796|  28.6k|  if(!error) {
  ------------------
  |  Branch (796:6): [True: 28.6k, False: 0]
  ------------------
  797|   464k|    for(n = 0; n != tree->maxbitlen + 1; n++) blcount[n] = nextcode[n] = 0;
  ------------------
  |  Branch (797:16): [True: 436k, False: 28.6k]
  ------------------
  798|       |    /*step 1: count number of instances of each code length*/
  799|  4.22M|    for(bits = 0; bits != tree->numcodes; ++bits) ++blcount[tree->lengths[bits]];
  ------------------
  |  Branch (799:19): [True: 4.19M, False: 28.6k]
  ------------------
  800|       |    /*step 2: generate the nextcode values*/
  801|   436k|    for(bits = 1; bits <= tree->maxbitlen; ++bits) {
  ------------------
  |  Branch (801:19): [True: 407k, False: 28.6k]
  ------------------
  802|   407k|      nextcode[bits] = (nextcode[bits - 1] + blcount[bits - 1]) << 1u;
  803|   407k|    }
  804|       |    /*step 3: generate all the codes*/
  805|  4.22M|    for(n = 0; n != tree->numcodes; ++n) {
  ------------------
  |  Branch (805:16): [True: 4.19M, False: 28.6k]
  ------------------
  806|  4.19M|      if(tree->lengths[n] != 0) {
  ------------------
  |  Branch (806:10): [True: 3.44M, False: 752k]
  ------------------
  807|  3.44M|        tree->codes[n] = nextcode[tree->lengths[n]]++;
  808|       |        /*remove superfluous bits from the code*/
  809|  3.44M|        tree->codes[n] &= ((1u << tree->lengths[n]) - 1u);
  810|  3.44M|      }
  811|  4.19M|    }
  812|  28.6k|  }
  813|       |
  814|  28.6k|  lodepng_free(blcount);
  815|  28.6k|  lodepng_free(nextcode);
  816|       |
  817|  28.6k|  if(!error) error = HuffmanTree_makeTable(tree);
  ------------------
  |  Branch (817:6): [True: 28.6k, False: 0]
  ------------------
  818|  28.6k|  return error;
  819|  28.6k|}
lodepng.cpp:_ZL21HuffmanTree_makeTableP11HuffmanTree:
  664|  28.6k|static unsigned HuffmanTree_makeTable(HuffmanTree* tree) {
  665|  28.6k|  static const unsigned headsize = 1u << FIRSTBITS; /*size of the first table*/
  ------------------
  |  |  657|  28.6k|#define FIRSTBITS 9u
  ------------------
  666|  28.6k|  static const unsigned mask = (1u << FIRSTBITS) /*headsize*/ - 1u;
  ------------------
  |  |  657|  28.6k|#define FIRSTBITS 9u
  ------------------
  667|  28.6k|  size_t i, numpresent, pointer, size; /*total table size*/
  668|  28.6k|  unsigned* maxlens = (unsigned*)lodepng_malloc(headsize * sizeof(unsigned));
  669|  28.6k|  if(!maxlens) return 83; /*alloc fail*/
  ------------------
  |  Branch (669:6): [True: 0, False: 28.6k]
  ------------------
  670|       |
  671|       |  /* compute maxlens: max total bit length of symbols sharing prefix in the first table*/
  672|  28.6k|  lodepng_memset(maxlens, 0, headsize * sizeof(*maxlens));
  673|  4.22M|  for(i = 0; i < tree->numcodes; i++) {
  ------------------
  |  Branch (673:14): [True: 4.19M, False: 28.6k]
  ------------------
  674|  4.19M|    unsigned symbol = tree->codes[i];
  675|  4.19M|    unsigned l = tree->lengths[i];
  676|  4.19M|    unsigned index;
  677|  4.19M|    if(l <= FIRSTBITS) continue; /*symbols that fit in first table don't increase secondary table size*/
  ------------------
  |  |  657|  4.19M|#define FIRSTBITS 9u
  ------------------
  |  Branch (677:8): [True: 4.16M, False: 36.5k]
  ------------------
  678|       |    /*get the FIRSTBITS MSBs, the MSBs of the symbol are encoded first. See later comment about the reversing*/
  679|  36.5k|    index = reverseBits(symbol >> (l - FIRSTBITS), FIRSTBITS);
  ------------------
  |  |  657|  36.5k|#define FIRSTBITS 9u
  ------------------
                  index = reverseBits(symbol >> (l - FIRSTBITS), FIRSTBITS);
  ------------------
  |  |  657|  36.5k|#define FIRSTBITS 9u
  ------------------
  680|  36.5k|    maxlens[index] = LODEPNG_MAX(maxlens[index], l);
  ------------------
  |  |  141|  36.5k|#define LODEPNG_MAX(a, b) (((a) > (b)) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (141:28): [True: 4.33k, False: 32.2k]
  |  |  ------------------
  ------------------
  681|  36.5k|  }
  682|       |  /* compute total table size: size of first table plus all secondary tables for symbols longer than FIRSTBITS */
  683|  28.6k|  size = headsize;
  684|  14.6M|  for(i = 0; i < headsize; ++i) {
  ------------------
  |  Branch (684:14): [True: 14.6M, False: 28.6k]
  ------------------
  685|  14.6M|    unsigned l = maxlens[i];
  686|  14.6M|    if(l > FIRSTBITS) size += (1u << (l - FIRSTBITS));
  ------------------
  |  |  657|  14.6M|#define FIRSTBITS 9u
  ------------------
                  if(l > FIRSTBITS) size += (1u << (l - FIRSTBITS));
  ------------------
  |  |  657|  11.0k|#define FIRSTBITS 9u
  ------------------
  |  Branch (686:8): [True: 11.0k, False: 14.6M]
  ------------------
  687|  14.6M|  }
  688|  28.6k|  tree->table_len = (unsigned char*)lodepng_malloc(size * sizeof(*tree->table_len));
  689|  28.6k|  tree->table_value = (unsigned short*)lodepng_malloc(size * sizeof(*tree->table_value));
  690|  28.6k|  if(!tree->table_len || !tree->table_value) {
  ------------------
  |  Branch (690:6): [True: 0, False: 28.6k]
  |  Branch (690:26): [True: 0, False: 28.6k]
  ------------------
  691|      0|    lodepng_free(maxlens);
  692|       |    /* freeing tree->table values is done at a higher scope */
  693|      0|    return 83; /*alloc fail*/
  694|      0|  }
  695|       |  /*initialize with an invalid length to indicate unused entries*/
  696|  14.7M|  for(i = 0; i < size; ++i) tree->table_len[i] = 16;
  ------------------
  |  Branch (696:14): [True: 14.7M, False: 28.6k]
  ------------------
  697|       |
  698|       |  /*fill in the first table for long symbols: max prefix size and pointer to secondary tables*/
  699|  28.6k|  pointer = headsize;
  700|  14.6M|  for(i = 0; i < headsize; ++i) {
  ------------------
  |  Branch (700:14): [True: 14.6M, False: 28.6k]
  ------------------
  701|  14.6M|    unsigned l = maxlens[i];
  702|  14.6M|    if(l <= FIRSTBITS) continue;
  ------------------
  |  |  657|  14.6M|#define FIRSTBITS 9u
  ------------------
  |  Branch (702:8): [True: 14.6M, False: 11.0k]
  ------------------
  703|  11.0k|    tree->table_len[i] = l;
  704|  11.0k|    tree->table_value[i] = pointer;
  705|  11.0k|    pointer += (1u << (l - FIRSTBITS));
  ------------------
  |  |  657|  11.0k|#define FIRSTBITS 9u
  ------------------
  706|  11.0k|  }
  707|  28.6k|  lodepng_free(maxlens);
  708|       |
  709|       |  /*fill in the first table for short symbols, or secondary table for long symbols*/
  710|  28.6k|  numpresent = 0;
  711|  4.22M|  for(i = 0; i < tree->numcodes; ++i) {
  ------------------
  |  Branch (711:14): [True: 4.19M, False: 28.6k]
  ------------------
  712|  4.19M|    unsigned l = tree->lengths[i];
  713|  4.19M|    unsigned symbol, reverse;
  714|  4.19M|    if(l == 0) continue;
  ------------------
  |  Branch (714:8): [True: 751k, False: 3.44M]
  ------------------
  715|  3.44M|    symbol = tree->codes[i]; /*the huffman bit pattern. i itself is the value.*/
  716|       |    /*reverse bits, because the huffman bits are given in MSB first order but the bit reader reads LSB first*/
  717|  3.44M|    reverse = reverseBits(symbol, l);
  718|  3.44M|    numpresent++;
  719|       |
  720|  3.44M|    if(l <= FIRSTBITS) {
  ------------------
  |  |  657|  3.44M|#define FIRSTBITS 9u
  ------------------
  |  Branch (720:8): [True: 3.40M, False: 36.0k]
  ------------------
  721|       |      /*short symbol, fully in first table, replicated num times if l < FIRSTBITS*/
  722|  3.40M|      unsigned num = 1u << (FIRSTBITS - l);
  ------------------
  |  |  657|  3.40M|#define FIRSTBITS 9u
  ------------------
  723|  3.40M|      unsigned j;
  724|  16.7M|      for(j = 0; j < num; ++j) {
  ------------------
  |  Branch (724:18): [True: 13.3M, False: 3.40M]
  ------------------
  725|       |        /*bit reader will read the l bits of symbol first, the remaining FIRSTBITS - l bits go to the MSB's*/
  726|  13.3M|        unsigned index = reverse | (j << l);
  727|  13.3M|        if(tree->table_len[index] != 16) return 55; /*invalid tree: long symbol shares prefix with short symbol*/
  ------------------
  |  Branch (727:12): [True: 49, False: 13.3M]
  ------------------
  728|  13.3M|        tree->table_len[index] = l;
  729|  13.3M|        tree->table_value[index] = i;
  730|  13.3M|      }
  731|  3.40M|    } else {
  732|       |      /*long symbol, shares prefix with other long symbols in first lookup table, needs second lookup*/
  733|       |      /*the FIRSTBITS MSBs of the symbol are the first table index*/
  734|  36.0k|      unsigned index = reverse & mask;
  735|  36.0k|      unsigned maxlen = tree->table_len[index];
  736|       |      /*log2 of secondary table length, should be >= l - FIRSTBITS*/
  737|  36.0k|      unsigned tablelen = maxlen - FIRSTBITS;
  ------------------
  |  |  657|  36.0k|#define FIRSTBITS 9u
  ------------------
  738|  36.0k|      unsigned start = tree->table_value[index]; /*starting index in secondary table*/
  739|  36.0k|      unsigned num = 1u << (tablelen - (l - FIRSTBITS)); /*amount of entries of this symbol in secondary table*/
  ------------------
  |  |  657|  36.0k|#define FIRSTBITS 9u
  ------------------
  740|  36.0k|      unsigned j;
  741|  36.0k|      if(maxlen < l) return 55; /*invalid tree: long symbol shares prefix with short symbol*/
  ------------------
  |  Branch (741:10): [True: 0, False: 36.0k]
  ------------------
  742|  76.7k|      for(j = 0; j < num; ++j) {
  ------------------
  |  Branch (742:18): [True: 40.7k, False: 36.0k]
  ------------------
  743|  40.7k|        unsigned reverse2 = reverse >> FIRSTBITS; /* l - FIRSTBITS bits */
  ------------------
  |  |  657|  40.7k|#define FIRSTBITS 9u
  ------------------
  744|  40.7k|        unsigned index2 = start + (reverse2 | (j << (l - FIRSTBITS)));
  ------------------
  |  |  657|  40.7k|#define FIRSTBITS 9u
  ------------------
  745|  40.7k|        tree->table_len[index2] = l;
  746|  40.7k|        tree->table_value[index2] = i;
  747|  40.7k|      }
  748|  36.0k|    }
  749|  3.44M|  }
  750|       |
  751|  28.6k|  if(numpresent < 2) {
  ------------------
  |  Branch (751:6): [True: 2.50k, False: 26.1k]
  ------------------
  752|       |    /* In case of exactly 1 symbol, in theory the huffman symbol needs 0 bits,
  753|       |    but deflate uses 1 bit instead. In case of 0 symbols, no symbols can
  754|       |    appear at all, but such huffman tree could still exist (e.g. if distance
  755|       |    codes are never used). In both cases, not all symbols of the table will be
  756|       |    filled in. Fill them in with an invalid symbol value so returning them from
  757|       |    huffmanDecodeSymbol will cause error. */
  758|  1.29M|    for(i = 0; i < size; ++i) {
  ------------------
  |  Branch (758:16): [True: 1.29M, False: 2.50k]
  ------------------
  759|  1.29M|      if(tree->table_len[i] == 16) {
  ------------------
  |  Branch (759:10): [True: 1.23M, False: 57.7k]
  ------------------
  760|       |        /* As length, use a value smaller than FIRSTBITS for the head table,
  761|       |        and a value larger than FIRSTBITS for the secondary table, to ensure
  762|       |        valid behavior for advanceBits when reading this symbol. */
  763|  1.23M|        tree->table_len[i] = (i < headsize) ? 1 : (FIRSTBITS + 1);
  ------------------
  |  |  657|  7.61k|#define FIRSTBITS 9u
  ------------------
  |  Branch (763:30): [True: 1.22M, False: 7.61k]
  ------------------
  764|  1.23M|        tree->table_value[i] = INVALIDSYMBOL;
  ------------------
  |  |  661|  1.23M|#define INVALIDSYMBOL 65535u
  ------------------
  765|  1.23M|      }
  766|  1.29M|    }
  767|  26.1k|  } else {
  768|       |    /* A good huffman tree has N * 2 - 1 nodes, of which N - 1 are internal nodes.
  769|       |    If that is not the case (due to too long length codes), the table will not
  770|       |    have been fully used, and this is an error (not all bit combinations can be
  771|       |    decoded): an oversubscribed huffman tree, indicated by error 55. */
  772|  13.3M|    for(i = 0; i < size; ++i) {
  ------------------
  |  Branch (772:16): [True: 13.3M, False: 26.0k]
  ------------------
  773|  13.3M|      if(tree->table_len[i] == 16) return 55;
  ------------------
  |  Branch (773:10): [True: 79, False: 13.3M]
  ------------------
  774|  13.3M|    }
  775|  26.1k|  }
  776|       |
  777|  28.5k|  return 0;
  778|  28.6k|}
lodepng.cpp:_ZL11reverseBitsjj:
  581|  3.47M|static unsigned reverseBits(unsigned bits, unsigned num) {
  582|       |  /*TODO: implement faster lookup table based version when needed*/
  583|  3.47M|  unsigned i, result = 0;
  584|  31.2M|  for(i = 0; i < num; i++) result |= ((bits >> (num - i - 1u)) & 1u) << i;
  ------------------
  |  Branch (584:14): [True: 27.7M, False: 3.47M]
  ------------------
  585|  3.47M|  return result;
  586|  3.47M|}
lodepng.cpp:_ZL25generateFixedDistanceTreeP11HuffmanTree:
 1055|  10.3k|static unsigned generateFixedDistanceTree(HuffmanTree* tree) {
 1056|  10.3k|  unsigned i, error = 0;
 1057|  10.3k|  unsigned* bitlen = (unsigned*)lodepng_malloc(NUM_DISTANCE_SYMBOLS * sizeof(unsigned));
  ------------------
  |  |  597|  10.3k|#define NUM_DISTANCE_SYMBOLS 32
  ------------------
 1058|  10.3k|  if(!bitlen) return 83; /*alloc fail*/
  ------------------
  |  Branch (1058:6): [True: 0, False: 10.3k]
  ------------------
 1059|       |
 1060|       |  /*there are 32 distance codes, but 30-31 are unused*/
 1061|   342k|  for(i = 0; i != NUM_DISTANCE_SYMBOLS; ++i) bitlen[i] = 5;
  ------------------
  |  |  597|   342k|#define NUM_DISTANCE_SYMBOLS 32
  ------------------
  |  Branch (1061:14): [True: 332k, False: 10.3k]
  ------------------
 1062|  10.3k|  error = HuffmanTree_makeFromLengths(tree, bitlen, NUM_DISTANCE_SYMBOLS, 15);
  ------------------
  |  |  597|  10.3k|#define NUM_DISTANCE_SYMBOLS 32
  ------------------
 1063|       |
 1064|  10.3k|  lodepng_free(bitlen);
 1065|  10.3k|  return error;
 1066|  10.3k|}
lodepng.cpp:_ZL21getTreeInflateDynamicP11HuffmanTreeS0_P16LodePNGBitReader:
 1105|  2.85k|                                      LodePNGBitReader* reader) {
 1106|       |  /*make sure that length values that aren't filled in will be 0, or a wrong tree will be generated*/
 1107|  2.85k|  unsigned error = 0;
 1108|  2.85k|  unsigned n, HLIT, HDIST, HCLEN, i;
 1109|       |
 1110|       |  /*see comments in deflateDynamic for explanation of the context and these variables, it is analogous*/
 1111|  2.85k|  unsigned* bitlen_ll = 0; /*lit,len code lengths*/
 1112|  2.85k|  unsigned* bitlen_d = 0; /*dist code lengths*/
 1113|       |  /*code length code lengths ("clcl"), the bit lengths of the huffman tree used to compress bitlen_ll and bitlen_d*/
 1114|  2.85k|  unsigned* bitlen_cl = 0;
 1115|  2.85k|  HuffmanTree tree_cl; /*the code tree for code length codes (the huffman tree for compressed huffman trees)*/
 1116|       |
 1117|  2.85k|  if(reader->bitsize - reader->bp < 14) return 49; /*error: the bit pointer is or will go past the memory*/
  ------------------
  |  Branch (1117:6): [True: 15, False: 2.83k]
  ------------------
 1118|  2.83k|  ensureBits17(reader, 14);
 1119|       |
 1120|       |  /*number of literal/length codes + 257. Unlike the spec, the value 257 is added to it here already*/
 1121|  2.83k|  HLIT =  readBits(reader, 5) + 257;
 1122|       |  /*number of distance codes. Unlike the spec, the value 1 is added to it here already*/
 1123|  2.83k|  HDIST = readBits(reader, 5) + 1;
 1124|       |  /*number of code length codes. Unlike the spec, the value 4 is added to it here already*/
 1125|  2.83k|  HCLEN = readBits(reader, 4) + 4;
 1126|       |
 1127|  2.83k|  bitlen_cl = (unsigned*)lodepng_malloc(NUM_CODE_LENGTH_CODES * sizeof(unsigned));
  ------------------
  |  |  599|  2.83k|#define NUM_CODE_LENGTH_CODES 19
  ------------------
 1128|  2.83k|  if(!bitlen_cl) return 83 /*alloc fail*/;
  ------------------
  |  Branch (1128:6): [True: 0, False: 2.83k]
  ------------------
 1129|       |
 1130|  2.83k|  HuffmanTree_init(&tree_cl);
 1131|       |
 1132|  2.83k|  while(!error) {
  ------------------
  |  Branch (1132:9): [True: 2.83k, False: 0]
  ------------------
 1133|       |    /*read the code length codes out of 3 * (amount of code length codes) bits*/
 1134|  2.83k|    if(lodepng_gtofl(reader->bp, HCLEN * 3, reader->bitsize)) {
  ------------------
  |  Branch (1134:8): [True: 47, False: 2.79k]
  ------------------
 1135|     47|      ERROR_BREAK(50); /*error: the bit pointer is or will go past the memory*/
  ------------------
  |  |  185|     47|#define ERROR_BREAK(code) CERROR_BREAK(error, code)
  |  |  ------------------
  |  |  |  |  179|     47|#define CERROR_BREAK(errorvar, code){\
  |  |  |  |  180|     47|  errorvar = code;\
  |  |  |  |  181|     47|  break;\
  |  |  |  |  182|     47|}
  |  |  ------------------
  ------------------
 1136|      0|    }
 1137|  42.9k|    for(i = 0; i != HCLEN; ++i) {
  ------------------
  |  Branch (1137:16): [True: 40.1k, False: 2.79k]
  ------------------
 1138|  40.1k|      ensureBits9(reader, 3); /*out of bounds already checked above */
 1139|  40.1k|      bitlen_cl[CLCL_ORDER[i]] = readBits(reader, 3);
 1140|  40.1k|    }
 1141|  15.6k|    for(i = HCLEN; i != NUM_CODE_LENGTH_CODES; ++i) {
  ------------------
  |  |  599|  15.6k|#define NUM_CODE_LENGTH_CODES 19
  ------------------
  |  Branch (1141:20): [True: 12.9k, False: 2.79k]
  ------------------
 1142|  12.9k|      bitlen_cl[CLCL_ORDER[i]] = 0;
 1143|  12.9k|    }
 1144|       |
 1145|  2.79k|    error = HuffmanTree_makeFromLengths(&tree_cl, bitlen_cl, NUM_CODE_LENGTH_CODES, 7);
  ------------------
  |  |  599|  2.79k|#define NUM_CODE_LENGTH_CODES 19
  ------------------
 1146|  2.79k|    if(error) break;
  ------------------
  |  Branch (1146:8): [True: 74, False: 2.71k]
  ------------------
 1147|       |
 1148|       |    /*now we can use this tree to read the lengths for the tree that this function will return*/
 1149|  2.71k|    bitlen_ll = (unsigned*)lodepng_malloc(NUM_DEFLATE_CODE_SYMBOLS * sizeof(unsigned));
  ------------------
  |  |  595|  2.71k|#define NUM_DEFLATE_CODE_SYMBOLS 288
  ------------------
 1150|  2.71k|    bitlen_d = (unsigned*)lodepng_malloc(NUM_DISTANCE_SYMBOLS * sizeof(unsigned));
  ------------------
  |  |  597|  2.71k|#define NUM_DISTANCE_SYMBOLS 32
  ------------------
 1151|  2.71k|    if(!bitlen_ll || !bitlen_d) ERROR_BREAK(83 /*alloc fail*/);
  ------------------
  |  |  185|      0|#define ERROR_BREAK(code) CERROR_BREAK(error, code)
  |  |  ------------------
  |  |  |  |  179|      0|#define CERROR_BREAK(errorvar, code){\
  |  |  |  |  180|      0|  errorvar = code;\
  |  |  |  |  181|      0|  break;\
  |  |  |  |  182|      0|}
  |  |  ------------------
  ------------------
  |  Branch (1151:8): [True: 0, False: 2.71k]
  |  Branch (1151:22): [True: 0, False: 2.71k]
  ------------------
 1152|  2.71k|    lodepng_memset(bitlen_ll, 0, NUM_DEFLATE_CODE_SYMBOLS * sizeof(*bitlen_ll));
  ------------------
  |  |  595|  2.71k|#define NUM_DEFLATE_CODE_SYMBOLS 288
  ------------------
 1153|  2.71k|    lodepng_memset(bitlen_d, 0, NUM_DISTANCE_SYMBOLS * sizeof(*bitlen_d));
  ------------------
  |  |  597|  2.71k|#define NUM_DISTANCE_SYMBOLS 32
  ------------------
 1154|       |
 1155|       |    /*i is the current symbol we're reading in the part that contains the code lengths of lit/len and dist codes*/
 1156|  2.71k|    i = 0;
 1157|   118k|    while(i < HLIT + HDIST) {
  ------------------
  |  Branch (1157:11): [True: 115k, False: 2.58k]
  ------------------
 1158|   115k|      unsigned code;
 1159|   115k|      ensureBits25(reader, 22); /* up to 15 bits for huffman code, up to 7 extra bits below*/
 1160|   115k|      code = huffmanDecodeSymbol(reader, &tree_cl);
 1161|   115k|      if(code <= 15) /*a length code*/ {
  ------------------
  |  Branch (1161:10): [True: 89.4k, False: 26.4k]
  ------------------
 1162|  89.4k|        if(i < HLIT) bitlen_ll[i] = code;
  ------------------
  |  Branch (1162:12): [True: 73.0k, False: 16.3k]
  ------------------
 1163|  16.3k|        else bitlen_d[i - HLIT] = code;
 1164|  89.4k|        ++i;
 1165|  89.4k|      } else if(code == 16) /*repeat previous*/ {
  ------------------
  |  Branch (1165:17): [True: 10.0k, False: 16.3k]
  ------------------
 1166|  10.0k|        unsigned replength = 3; /*read in the 2 bits that indicate repeat length (3-6)*/
 1167|  10.0k|        unsigned value; /*set value to the previous code*/
 1168|       |
 1169|  10.0k|        if(i == 0) ERROR_BREAK(54); /*can't repeat previous if i is 0*/
  ------------------
  |  |  185|      4|#define ERROR_BREAK(code) CERROR_BREAK(error, code)
  |  |  ------------------
  |  |  |  |  179|      4|#define CERROR_BREAK(errorvar, code){\
  |  |  |  |  180|      4|  errorvar = code;\
  |  |  |  |  181|      4|  break;\
  |  |  |  |  182|      4|}
  |  |  ------------------
  ------------------
  |  Branch (1169:12): [True: 4, False: 10.0k]
  ------------------
 1170|       |
 1171|  10.0k|        replength += readBits(reader, 2);
 1172|       |
 1173|  10.0k|        if(i < HLIT + 1) value = bitlen_ll[i - 1];
  ------------------
  |  Branch (1173:12): [True: 7.42k, False: 2.66k]
  ------------------
 1174|  2.66k|        else value = bitlen_d[i - HLIT - 1];
 1175|       |        /*repeat this value in the next lengths*/
 1176|  49.2k|        for(n = 0; n < replength; ++n) {
  ------------------
  |  Branch (1176:20): [True: 39.1k, False: 10.0k]
  ------------------
 1177|  39.1k|          if(i >= HLIT + HDIST) ERROR_BREAK(13); /*error: i is larger than the amount of codes*/
  ------------------
  |  |  185|     10|#define ERROR_BREAK(code) CERROR_BREAK(error, code)
  |  |  ------------------
  |  |  |  |  179|     10|#define CERROR_BREAK(errorvar, code){\
  |  |  |  |  180|     10|  errorvar = code;\
  |  |  |  |  181|     10|  break;\
  |  |  |  |  182|     10|}
  |  |  ------------------
  ------------------
  |  Branch (1177:14): [True: 10, False: 39.1k]
  ------------------
 1178|  39.1k|          if(i < HLIT) bitlen_ll[i] = value;
  ------------------
  |  Branch (1178:14): [True: 30.5k, False: 8.64k]
  ------------------
 1179|  8.64k|          else bitlen_d[i - HLIT] = value;
 1180|  39.1k|          ++i;
 1181|  39.1k|        }
 1182|  16.3k|      } else if(code == 17) /*repeat "0" 3-10 times*/ {
  ------------------
  |  Branch (1182:17): [True: 8.89k, False: 7.45k]
  ------------------
 1183|  8.89k|        unsigned replength = 3; /*read in the bits that indicate repeat length*/
 1184|  8.89k|        replength += readBits(reader, 3);
 1185|       |
 1186|       |        /*repeat this value in the next lengths*/
 1187|  64.5k|        for(n = 0; n < replength; ++n) {
  ------------------
  |  Branch (1187:20): [True: 55.6k, False: 8.89k]
  ------------------
 1188|  55.6k|          if(i >= HLIT + HDIST) ERROR_BREAK(14); /*error: i is larger than the amount of codes*/
  ------------------
  |  |  185|      2|#define ERROR_BREAK(code) CERROR_BREAK(error, code)
  |  |  ------------------
  |  |  |  |  179|      2|#define CERROR_BREAK(errorvar, code){\
  |  |  |  |  180|      2|  errorvar = code;\
  |  |  |  |  181|      2|  break;\
  |  |  |  |  182|      2|}
  |  |  ------------------
  ------------------
  |  Branch (1188:14): [True: 2, False: 55.6k]
  ------------------
 1189|       |
 1190|  55.6k|          if(i < HLIT) bitlen_ll[i] = 0;
  ------------------
  |  Branch (1190:14): [True: 54.0k, False: 1.64k]
  ------------------
 1191|  1.64k|          else bitlen_d[i - HLIT] = 0;
 1192|  55.6k|          ++i;
 1193|  55.6k|        }
 1194|  8.89k|      } else if(code == 18) /*repeat "0" 11-138 times*/ {
  ------------------
  |  Branch (1194:17): [True: 7.42k, False: 25]
  ------------------
 1195|  7.42k|        unsigned replength = 11; /*read in the bits that indicate repeat length*/
 1196|  7.42k|        replength += readBits(reader, 7);
 1197|       |
 1198|       |        /*repeat this value in the next lengths*/
 1199|   610k|        for(n = 0; n < replength; ++n) {
  ------------------
  |  Branch (1199:20): [True: 603k, False: 7.42k]
  ------------------
 1200|   603k|          if(i >= HLIT + HDIST) ERROR_BREAK(15); /*error: i is larger than the amount of codes*/
  ------------------
  |  |  185|      5|#define ERROR_BREAK(code) CERROR_BREAK(error, code)
  |  |  ------------------
  |  |  |  |  179|      5|#define CERROR_BREAK(errorvar, code){\
  |  |  |  |  180|      5|  errorvar = code;\
  |  |  |  |  181|      5|  break;\
  |  |  |  |  182|      5|}
  |  |  ------------------
  ------------------
  |  Branch (1200:14): [True: 5, False: 603k]
  ------------------
 1201|       |
 1202|   603k|          if(i < HLIT) bitlen_ll[i] = 0;
  ------------------
  |  Branch (1202:14): [True: 574k, False: 28.6k]
  ------------------
 1203|  28.6k|          else bitlen_d[i - HLIT] = 0;
 1204|   603k|          ++i;
 1205|   603k|        }
 1206|  7.42k|      } else /*if(code == INVALIDSYMBOL)*/ {
 1207|     25|        ERROR_BREAK(16); /*error: tried to read disallowed huffman symbol*/
  ------------------
  |  |  185|     25|#define ERROR_BREAK(code) CERROR_BREAK(error, code)
  |  |  ------------------
  |  |  |  |  179|     25|#define CERROR_BREAK(errorvar, code){\
  |  |  |  |  180|     25|  errorvar = code;\
  |  |  |  |  181|     25|  break;\
  |  |  |  |  182|     25|}
  |  |  ------------------
  ------------------
 1208|      0|      }
 1209|       |      /*check if any of the ensureBits above went out of bounds*/
 1210|   115k|      if(reader->bp > reader->bitsize) {
  ------------------
  |  Branch (1210:10): [True: 106, False: 115k]
  ------------------
 1211|       |        /*return error code 10 or 11 depending on the situation that happened in huffmanDecodeSymbol
 1212|       |        (10=no endcode, 11=wrong jump outside of tree)*/
 1213|       |        /* TODO: revise error codes 10,11,50: the above comment is no longer valid */
 1214|    106|        ERROR_BREAK(50); /*error, bit pointer jumps past memory*/
  ------------------
  |  |  185|    106|#define ERROR_BREAK(code) CERROR_BREAK(error, code)
  |  |  ------------------
  |  |  |  |  179|    106|#define CERROR_BREAK(errorvar, code){\
  |  |  |  |  180|    106|  errorvar = code;\
  |  |  |  |  181|    106|  break;\
  |  |  |  |  182|    106|}
  |  |  ------------------
  ------------------
 1215|      0|      }
 1216|   115k|    }
 1217|  2.71k|    if(error) break;
  ------------------
  |  Branch (1217:8): [True: 146, False: 2.57k]
  ------------------
 1218|       |
 1219|  2.57k|    if(bitlen_ll[256] == 0) ERROR_BREAK(64); /*the length of the end code 256 must be larger than 0*/
  ------------------
  |  |  185|      5|#define ERROR_BREAK(code) CERROR_BREAK(error, code)
  |  |  ------------------
  |  |  |  |  179|      5|#define CERROR_BREAK(errorvar, code){\
  |  |  |  |  180|      5|  errorvar = code;\
  |  |  |  |  181|      5|  break;\
  |  |  |  |  182|      5|}
  |  |  ------------------
  ------------------
  |  Branch (1219:8): [True: 5, False: 2.56k]
  ------------------
 1220|       |
 1221|       |    /*now we've finally got HLIT and HDIST, so generate the code trees, and the function is done*/
 1222|  2.56k|    error = HuffmanTree_makeFromLengths(tree_ll, bitlen_ll, NUM_DEFLATE_CODE_SYMBOLS, 15);
  ------------------
  |  |  595|  2.56k|#define NUM_DEFLATE_CODE_SYMBOLS 288
  ------------------
 1223|  2.56k|    if(error) break;
  ------------------
  |  Branch (1223:8): [True: 50, False: 2.51k]
  ------------------
 1224|  2.51k|    error = HuffmanTree_makeFromLengths(tree_d, bitlen_d, NUM_DISTANCE_SYMBOLS, 15);
  ------------------
  |  |  597|  2.51k|#define NUM_DISTANCE_SYMBOLS 32
  ------------------
 1225|       |
 1226|  2.51k|    break; /*end of error-while*/
 1227|  2.56k|  }
 1228|       |
 1229|  2.83k|  lodepng_free(bitlen_cl);
 1230|  2.83k|  lodepng_free(bitlen_ll);
 1231|  2.83k|  lodepng_free(bitlen_d);
 1232|  2.83k|  HuffmanTree_cleanup(&tree_cl);
 1233|       |
 1234|  2.83k|  return error;
 1235|  2.83k|}
lodepng.cpp:_ZL12ensureBits17P16LodePNGBitReaderm:
  507|  2.83k|static LODEPNG_INLINE void ensureBits17(LodePNGBitReader* reader, size_t nbits) {
  508|  2.83k|  size_t start = reader->bp >> 3u;
  509|  2.83k|  size_t size = reader->size;
  510|  2.83k|  if(start + 2u < size) {
  ------------------
  |  Branch (510:6): [True: 2.82k, False: 16]
  ------------------
  511|  2.82k|    reader->buffer = (unsigned)reader->data[start + 0] | ((unsigned)reader->data[start + 1] << 8u) |
  512|  2.82k|                     ((unsigned)reader->data[start + 2] << 16u);
  513|  2.82k|    reader->buffer >>= (reader->bp & 7u);
  514|  2.82k|  } else {
  515|     16|    reader->buffer = 0;
  516|     16|    if(start + 0u < size) reader->buffer |= reader->data[start + 0];
  ------------------
  |  Branch (516:8): [True: 16, False: 0]
  ------------------
  517|     16|    if(start + 1u < size) reader->buffer |= ((unsigned)reader->data[start + 1] << 8u);
  ------------------
  |  Branch (517:8): [True: 16, False: 0]
  ------------------
  518|     16|    reader->buffer >>= (reader->bp & 7u);
  519|     16|  }
  520|  2.83k|  (void)nbits;
  521|  2.83k|}
lodepng.cpp:_ZL13lodepng_gtoflmmm:
  163|  2.83k|static int lodepng_gtofl(size_t a, size_t b, size_t c) {
  164|  2.83k|  size_t d;
  165|  2.83k|  if(lodepng_addofl(a, b, &d)) return 1;
  ------------------
  |  Branch (165:6): [True: 0, False: 2.83k]
  ------------------
  166|  2.83k|  return d > c;
  167|  2.83k|}
lodepng.cpp:_ZL12ensureBits32P16LodePNGBitReaderm:
  542|  27.7M|static LODEPNG_INLINE void ensureBits32(LodePNGBitReader* reader, size_t nbits) {
  543|  27.7M|  size_t start = reader->bp >> 3u;
  544|  27.7M|  size_t size = reader->size;
  545|  27.7M|  if(start + 4u < size) {
  ------------------
  |  Branch (545:6): [True: 27.7M, False: 27.8k]
  ------------------
  546|  27.7M|    reader->buffer = (unsigned)reader->data[start + 0] | ((unsigned)reader->data[start + 1] << 8u) |
  547|  27.7M|                     ((unsigned)reader->data[start + 2] << 16u) | ((unsigned)reader->data[start + 3] << 24u);
  548|  27.7M|    reader->buffer >>= (reader->bp & 7u);
  549|  27.7M|    reader->buffer |= (((unsigned)reader->data[start + 4] << 24u) << (8u - (reader->bp & 7u)));
  550|  27.7M|  } else {
  551|  27.8k|    reader->buffer = 0;
  552|  27.8k|    if(start + 0u < size) reader->buffer |= reader->data[start + 0];
  ------------------
  |  Branch (552:8): [True: 27.7k, False: 141]
  ------------------
  553|  27.8k|    if(start + 1u < size) reader->buffer |= ((unsigned)reader->data[start + 1] << 8u);
  ------------------
  |  Branch (553:8): [True: 21.5k, False: 6.30k]
  ------------------
  554|  27.8k|    if(start + 2u < size) reader->buffer |= ((unsigned)reader->data[start + 2] << 16u);
  ------------------
  |  Branch (554:8): [True: 12.7k, False: 15.1k]
  ------------------
  555|  27.8k|    if(start + 3u < size) reader->buffer |= ((unsigned)reader->data[start + 3] << 24u);
  ------------------
  |  Branch (555:8): [True: 7.56k, False: 20.2k]
  ------------------
  556|  27.8k|    reader->buffer >>= (reader->bp & 7u);
  557|  27.8k|  }
  558|  27.7M|  (void)nbits;
  559|  27.7M|}
lodepng.cpp:_ZL19huffmanDecodeSymbolP16LodePNGBitReaderPK11HuffmanTree:
 1073|  32.9M|static unsigned huffmanDecodeSymbol(LodePNGBitReader* reader, const HuffmanTree* codetree) {
 1074|  32.9M|  unsigned short code = peekBits(reader, FIRSTBITS);
  ------------------
  |  |  657|  32.9M|#define FIRSTBITS 9u
  ------------------
 1075|  32.9M|  unsigned short l = codetree->table_len[code];
 1076|  32.9M|  unsigned short value = codetree->table_value[code];
 1077|  32.9M|  if(l <= FIRSTBITS) {
  ------------------
  |  |  657|  32.9M|#define FIRSTBITS 9u
  ------------------
  |  Branch (1077:6): [True: 32.8M, False: 149k]
  ------------------
 1078|  32.8M|    advanceBits(reader, l);
 1079|  32.8M|    return value;
 1080|  32.8M|  } else {
 1081|   149k|    advanceBits(reader, FIRSTBITS);
  ------------------
  |  |  657|   149k|#define FIRSTBITS 9u
  ------------------
 1082|   149k|    value += peekBits(reader, l - FIRSTBITS);
  ------------------
  |  |  657|   149k|#define FIRSTBITS 9u
  ------------------
 1083|   149k|    advanceBits(reader, codetree->table_len[value] - FIRSTBITS);
  ------------------
  |  |  657|   149k|#define FIRSTBITS 9u
  ------------------
 1084|   149k|    return codetree->table_value[value];
 1085|   149k|  }
 1086|  32.9M|}
lodepng.cpp:_ZL12ensureBits25P16LodePNGBitReaderm:
  524|   521k|static LODEPNG_INLINE void ensureBits25(LodePNGBitReader* reader, size_t nbits) {
  525|   521k|  size_t start = reader->bp >> 3u;
  526|   521k|  size_t size = reader->size;
  527|   521k|  if(start + 3u < size) {
  ------------------
  |  Branch (527:6): [True: 515k, False: 6.42k]
  ------------------
  528|   515k|    reader->buffer = (unsigned)reader->data[start + 0] | ((unsigned)reader->data[start + 1] << 8u) |
  529|   515k|                     ((unsigned)reader->data[start + 2] << 16u) | ((unsigned)reader->data[start + 3] << 24u);
  530|   515k|    reader->buffer >>= (reader->bp & 7u);
  531|   515k|  } else {
  532|  6.42k|    reader->buffer = 0;
  533|  6.42k|    if(start + 0u < size) reader->buffer |= reader->data[start + 0];
  ------------------
  |  Branch (533:8): [True: 6.34k, False: 78]
  ------------------
  534|  6.42k|    if(start + 1u < size) reader->buffer |= ((unsigned)reader->data[start + 1] << 8u);
  ------------------
  |  Branch (534:8): [True: 5.22k, False: 1.20k]
  ------------------
  535|  6.42k|    if(start + 2u < size) reader->buffer |= ((unsigned)reader->data[start + 2] << 16u);
  ------------------
  |  Branch (535:8): [True: 2.15k, False: 4.27k]
  ------------------
  536|  6.42k|    reader->buffer >>= (reader->bp & 7u);
  537|  6.42k|  }
  538|   521k|  (void)nbits;
  539|   521k|}
lodepng.cpp:_ZL19HuffmanTree_cleanupP11HuffmanTree:
  648|  29.3k|static void HuffmanTree_cleanup(HuffmanTree* tree) {
  649|  29.3k|  lodepng_free(tree->codes);
  650|  29.3k|  lodepng_free(tree->lengths);
  651|  29.3k|  lodepng_free(tree->table_len);
  652|  29.3k|  lodepng_free(tree->table_value);
  653|  29.3k|}
lodepng.cpp:_ZL24lodepng_zlib_decompressvP8ucvectorPKhmPK25LodePNGDecompressSettings:
 2170|  8.97k|                                         const LodePNGDecompressSettings* settings) {
 2171|  8.97k|  unsigned error = 0;
 2172|  8.97k|  unsigned CM, CINFO, FDICT;
 2173|       |
 2174|  8.97k|  if(insize < 2) return 53; /*error, size of zlib data too small*/
  ------------------
  |  Branch (2174:6): [True: 565, False: 8.40k]
  ------------------
 2175|       |  /*read information from zlib header*/
 2176|  8.40k|  if((in[0] * 256 + in[1]) % 31 != 0) {
  ------------------
  |  Branch (2176:6): [True: 22, False: 8.38k]
  ------------------
 2177|       |    /*error: 256 * in[0] + in[1] must be a multiple of 31, the FCHECK value is supposed to be made that way*/
 2178|     22|    return 24;
 2179|     22|  }
 2180|       |
 2181|  8.38k|  CM = in[0] & 15;
 2182|  8.38k|  CINFO = (in[0] >> 4) & 15;
 2183|       |  /*FCHECK = in[1] & 31;*/ /*FCHECK is already tested above*/
 2184|  8.38k|  FDICT = (in[1] >> 5) & 1;
 2185|       |  /*FLEVEL = (in[1] >> 6) & 3;*/ /*FLEVEL is not used here*/
 2186|       |
 2187|  8.38k|  if(CM != 8 || CINFO > 7) {
  ------------------
  |  Branch (2187:6): [True: 15, False: 8.36k]
  |  Branch (2187:17): [True: 2, False: 8.36k]
  ------------------
 2188|       |    /*error: only compression method 8: inflate with sliding window of 32k is supported by the PNG spec*/
 2189|     17|    return 25;
 2190|     17|  }
 2191|  8.36k|  if(FDICT != 0) {
  ------------------
  |  Branch (2191:6): [True: 1, False: 8.36k]
  ------------------
 2192|       |    /*error: the specification of PNG says about the zlib stream:
 2193|       |      "The additional flags shall not specify a preset dictionary."*/
 2194|      1|    return 26;
 2195|      1|  }
 2196|       |
 2197|  8.36k|  error = inflatev(out, in + 2, insize - 2, settings);
 2198|  8.36k|  if(error) return error;
  ------------------
  |  Branch (2198:6): [True: 810, False: 7.55k]
  ------------------
 2199|       |
 2200|  7.55k|  if(!settings->ignore_adler32) {
  ------------------
  |  Branch (2200:6): [True: 0, False: 7.55k]
  ------------------
 2201|      0|    unsigned ADLER32 = lodepng_read32bitInt(&in[insize - 4]);
 2202|      0|    unsigned checksum = adler32(out->data, (unsigned)(out->size));
 2203|      0|    if(checksum != ADLER32) return 58; /*error, adler checksum not correct, data must be corrupted*/
  ------------------
  |  Branch (2203:8): [True: 0, False: 0]
  ------------------
 2204|      0|  }
 2205|       |
 2206|  7.55k|  return 0; /*no error*/
 2207|  7.55k|}
lodepng.cpp:_ZL8inflatevP8ucvectorPKhmPK25LodePNGDecompressSettings:
 1418|  8.36k|                        const LodePNGDecompressSettings* settings) {
 1419|  8.36k|  if(settings->custom_inflate) {
  ------------------
  |  Branch (1419:6): [True: 0, False: 8.36k]
  ------------------
 1420|      0|    unsigned error = settings->custom_inflate(&out->data, &out->size, in, insize, settings);
 1421|      0|    out->allocsize = out->size;
 1422|      0|    if(error) {
  ------------------
  |  Branch (1422:8): [True: 0, False: 0]
  ------------------
 1423|       |      /*the custom inflate is allowed to have its own error codes, however, we translate it to code 110*/
 1424|      0|      error = 110;
 1425|       |      /*if there's a max output size, and the custom zlib returned error, then indicate that error instead*/
 1426|      0|      if(settings->max_output_size && out->size > settings->max_output_size) error = 109;
  ------------------
  |  Branch (1426:10): [True: 0, False: 0]
  |  Branch (1426:39): [True: 0, False: 0]
  ------------------
 1427|      0|    }
 1428|      0|    return error;
 1429|  8.36k|  } else {
 1430|  8.36k|    return lodepng_inflatev(out, in, insize, settings);
 1431|  8.36k|  }
 1432|  8.36k|}
lodepng.cpp:_ZL20lodepng_read32bitIntPKh:
  326|   448k|static unsigned lodepng_read32bitInt(const unsigned char* buffer) {
  327|   448k|  return (((unsigned)buffer[0] << 24u) | ((unsigned)buffer[1] << 16u) |
  328|   448k|         ((unsigned)buffer[2] << 8u) | (unsigned)buffer[3]);
  329|   448k|}
lodepng.cpp:_ZL14lodepng_strlenPKc:
  133|  1.99M|static size_t lodepng_strlen(const char* a) {
  134|  1.99M|  const char* orig = a;
  135|       |  /* avoid warning about unused function in case of disabled COMPILE... macros */
  136|  1.99M|  (void)(&lodepng_strlen);
  137|  11.6M|  while(*a) a++;
  ------------------
  |  Branch (137:9): [True: 9.68M, False: 1.99M]
  ------------------
  138|  1.99M|  return (size_t)(a - orig);
  139|  1.99M|}
lodepng.cpp:_ZL14lodepng_addoflmmPm:
  147|   247k|static int lodepng_addofl(size_t a, size_t b, size_t* result) {
  148|   247k|  *result = a + b; /* Unsigned addition is well defined and safe in C90 */
  149|   247k|  return *result < a;
  150|   247k|}
lodepng.cpp:_ZL15lodepng_reallocPvm:
   82|   560k|static void* lodepng_realloc(void* ptr, size_t new_size) {
   83|   560k|#ifdef LODEPNG_MAX_ALLOC
   84|   560k|  if(new_size > LODEPNG_MAX_ALLOC) return 0;
  ------------------
  |  Branch (84:6): [True: 754, False: 559k]
  ------------------
   85|   559k|#endif
   86|   559k|  return realloc(ptr, new_size);
   87|   560k|}
lodepng.cpp:_ZL14lodepng_memcpyPvPKvm:
  121|  13.2M|                           const void* LODEPNG_RESTRICT src, size_t size) {
  122|  13.2M|  size_t i;
  123|   334M|  for(i = 0; i < size; i++) ((char*)dst)[i] = ((const char*)src)[i];
  ------------------
  |  Branch (123:14): [True: 321M, False: 13.2M]
  ------------------
  124|  13.2M|}
lodepng.cpp:_ZL32lodepng_color_mode_alloc_paletteP16LodePNGColorMode:
 2945|  2.52k|static void lodepng_color_mode_alloc_palette(LodePNGColorMode* info) {
 2946|  2.52k|  size_t i;
 2947|       |  /*if the palette is already allocated, it will have size 1024 so no reallocation needed in that case*/
 2948|       |  /*the palette must have room for up to 256 colors with 4 bytes each.*/
 2949|  2.52k|  if(!info->palette) info->palette = (unsigned char*)lodepng_malloc(1024);
  ------------------
  |  Branch (2949:6): [True: 592, False: 1.93k]
  ------------------
 2950|  2.52k|  if(!info->palette) return; /*alloc fail*/
  ------------------
  |  Branch (2950:6): [True: 0, False: 2.52k]
  ------------------
 2951|   649k|  for(i = 0; i != 256; ++i) {
  ------------------
  |  Branch (2951:14): [True: 646k, False: 2.52k]
  ------------------
 2952|       |    /*Initialize all unused colors with black, the value used for invalid palette indices.
 2953|       |    This is an error according to the PNG spec, but common PNG decoders make it black instead.
 2954|       |    That makes color conversion slightly faster due to no error handling needed.*/
 2955|   646k|    info->palette[i * 4 + 0] = 0;
 2956|   646k|    info->palette[i * 4 + 1] = 0;
 2957|   646k|    info->palette[i * 4 + 2] = 0;
 2958|   646k|    info->palette[i * 4 + 3] = 255;
 2959|   646k|  }
 2960|  2.52k|}
lodepng.cpp:_ZL19lodepng_get_bpp_lct16LodePNGColorTypej:
 2928|  44.6k|static unsigned lodepng_get_bpp_lct(LodePNGColorType colortype, unsigned bitdepth) {
 2929|       |  /*bits per pixel is amount of channels * bits per channel*/
 2930|  44.6k|  return getNumColorChannels(colortype) * bitdepth;
 2931|  44.6k|}
lodepng.cpp:_ZL19getNumColorChannels16LodePNGColorType:
 2916|  44.6k|static unsigned getNumColorChannels(LodePNGColorType colortype) {
 2917|  44.6k|  switch(colortype) {
 2918|  11.4k|    case LCT_GREY: return 1;
  ------------------
  |  Branch (2918:5): [True: 11.4k, False: 33.2k]
  ------------------
 2919|  14.4k|    case LCT_RGB: return 3;
  ------------------
  |  Branch (2919:5): [True: 14.4k, False: 30.2k]
  ------------------
 2920|  2.75k|    case LCT_PALETTE: return 1;
  ------------------
  |  Branch (2920:5): [True: 2.75k, False: 41.9k]
  ------------------
 2921|  2.96k|    case LCT_GREY_ALPHA: return 2;
  ------------------
  |  Branch (2921:5): [True: 2.96k, False: 41.7k]
  ------------------
 2922|  13.1k|    case LCT_RGBA: return 4;
  ------------------
  |  Branch (2922:5): [True: 13.1k, False: 31.5k]
  ------------------
 2923|      0|    case LCT_MAX_OCTET_VALUE: return 0; /* invalid color type */
  ------------------
  |  Branch (2923:5): [True: 0, False: 44.6k]
  ------------------
 2924|      0|    default: return 0; /*invalid color type*/
  ------------------
  |  Branch (2924:5): [True: 0, False: 44.6k]
  ------------------
 2925|  44.6k|  }
 2926|  44.6k|}
lodepng.cpp:_ZL24lodepng_get_raw_size_lctjj16LodePNGColorTypej:
 3060|  11.1k|static size_t lodepng_get_raw_size_lct(unsigned w, unsigned h, LodePNGColorType colortype, unsigned bitdepth) {
 3061|  11.1k|  size_t bpp = lodepng_get_bpp_lct(colortype, bitdepth);
 3062|  11.1k|  size_t n = (size_t)w * (size_t)h;
 3063|  11.1k|  return ((n / 8u) * bpp) + ((n & 7u) * bpp + 7u) / 8u;
 3064|  11.1k|}
lodepng.cpp:_ZL22lodepng_add_text_sizedP11LodePNGInfoPKcS2_m:
 3173|  97.7k|static unsigned lodepng_add_text_sized(LodePNGInfo* info, const char* key, const char* str, size_t size) {
 3174|  97.7k|  char** new_keys = (char**)(lodepng_realloc(info->text_keys, sizeof(char*) * (info->text_num + 1)));
 3175|  97.7k|  char** new_strings = (char**)(lodepng_realloc(info->text_strings, sizeof(char*) * (info->text_num + 1)));
 3176|       |
 3177|  97.7k|  if(new_keys) info->text_keys = new_keys;
  ------------------
  |  Branch (3177:6): [True: 97.7k, False: 0]
  ------------------
 3178|  97.7k|  if(new_strings) info->text_strings = new_strings;
  ------------------
  |  Branch (3178:6): [True: 97.7k, False: 0]
  ------------------
 3179|       |
 3180|  97.7k|  if(!new_keys || !new_strings) return 83; /*alloc fail*/
  ------------------
  |  Branch (3180:6): [True: 0, False: 97.7k]
  |  Branch (3180:19): [True: 0, False: 97.7k]
  ------------------
 3181|       |
 3182|  97.7k|  ++info->text_num;
 3183|  97.7k|  info->text_keys[info->text_num - 1] = alloc_string(key);
 3184|  97.7k|  info->text_strings[info->text_num - 1] = alloc_string_sized(str, size);
 3185|  97.7k|  if(!info->text_keys[info->text_num - 1] || !info->text_strings[info->text_num - 1]) return 83; /*alloc fail*/
  ------------------
  |  Branch (3185:6): [True: 0, False: 97.7k]
  |  Branch (3185:46): [True: 0, False: 97.7k]
  ------------------
 3186|       |
 3187|  97.7k|  return 0;
 3188|  97.7k|}
lodepng.cpp:_ZL12alloc_stringPKc:
  317|   350k|static char* alloc_string(const char* in) {
  318|   350k|  return alloc_string_sized(in, lodepng_strlen(in));
  319|   350k|}
lodepng.cpp:_ZL18alloc_string_sizedPKcm:
  307|   532k|static char* alloc_string_sized(const char* in, size_t insize) {
  308|   532k|  char* out = (char*)lodepng_malloc(insize + 1);
  309|   532k|  if(out) {
  ------------------
  |  Branch (309:6): [True: 532k, False: 0]
  ------------------
  310|   532k|    lodepng_memcpy(out, in, insize);
  311|   532k|    out[insize] = 0;
  312|   532k|  }
  313|   532k|  return out;
  314|   532k|}
lodepng.cpp:_ZL19LodePNGText_cleanupP11LodePNGInfo:
 3152|  11.9k|static void LodePNGText_cleanup(LodePNGInfo* info) {
 3153|  11.9k|  size_t i;
 3154|   109k|  for(i = 0; i != info->text_num; ++i) {
  ------------------
  |  Branch (3154:14): [True: 97.7k, False: 11.9k]
  ------------------
 3155|  97.7k|    string_cleanup(&info->text_keys[i]);
 3156|  97.7k|    string_cleanup(&info->text_strings[i]);
 3157|  97.7k|  }
 3158|  11.9k|  lodepng_free(info->text_keys);
 3159|  11.9k|  lodepng_free(info->text_strings);
 3160|  11.9k|}
lodepng.cpp:_ZL20LodePNGIText_cleanupP11LodePNGInfo:
 3208|  11.9k|static void LodePNGIText_cleanup(LodePNGInfo* info) {
 3209|  11.9k|  size_t i;
 3210|  96.2k|  for(i = 0; i != info->itext_num; ++i) {
  ------------------
  |  Branch (3210:14): [True: 84.2k, False: 11.9k]
  ------------------
 3211|  84.2k|    string_cleanup(&info->itext_keys[i]);
 3212|  84.2k|    string_cleanup(&info->itext_langtags[i]);
 3213|  84.2k|    string_cleanup(&info->itext_transkeys[i]);
 3214|  84.2k|    string_cleanup(&info->itext_strings[i]);
 3215|  84.2k|  }
 3216|  11.9k|  lodepng_free(info->itext_keys);
 3217|  11.9k|  lodepng_free(info->itext_langtags);
 3218|  11.9k|  lodepng_free(info->itext_transkeys);
 3219|  11.9k|  lodepng_free(info->itext_strings);
 3220|  11.9k|}
lodepng.cpp:_ZL23lodepng_add_itext_sizedP11LodePNGInfoPKcS2_S2_S2_m:
 3241|  84.2k|                                        const char* transkey, const char* str, size_t size) {
 3242|  84.2k|  char** new_keys = (char**)(lodepng_realloc(info->itext_keys, sizeof(char*) * (info->itext_num + 1)));
 3243|  84.2k|  char** new_langtags = (char**)(lodepng_realloc(info->itext_langtags, sizeof(char*) * (info->itext_num + 1)));
 3244|  84.2k|  char** new_transkeys = (char**)(lodepng_realloc(info->itext_transkeys, sizeof(char*) * (info->itext_num + 1)));
 3245|  84.2k|  char** new_strings = (char**)(lodepng_realloc(info->itext_strings, sizeof(char*) * (info->itext_num + 1)));
 3246|       |
 3247|  84.2k|  if(new_keys) info->itext_keys = new_keys;
  ------------------
  |  Branch (3247:6): [True: 84.2k, False: 0]
  ------------------
 3248|  84.2k|  if(new_langtags) info->itext_langtags = new_langtags;
  ------------------
  |  Branch (3248:6): [True: 84.2k, False: 0]
  ------------------
 3249|  84.2k|  if(new_transkeys) info->itext_transkeys = new_transkeys;
  ------------------
  |  Branch (3249:6): [True: 84.2k, False: 0]
  ------------------
 3250|  84.2k|  if(new_strings) info->itext_strings = new_strings;
  ------------------
  |  Branch (3250:6): [True: 84.2k, False: 0]
  ------------------
 3251|       |
 3252|  84.2k|  if(!new_keys || !new_langtags || !new_transkeys || !new_strings) return 83; /*alloc fail*/
  ------------------
  |  Branch (3252:6): [True: 0, False: 84.2k]
  |  Branch (3252:19): [True: 0, False: 84.2k]
  |  Branch (3252:36): [True: 0, False: 84.2k]
  |  Branch (3252:54): [True: 0, False: 84.2k]
  ------------------
 3253|       |
 3254|  84.2k|  ++info->itext_num;
 3255|       |
 3256|  84.2k|  info->itext_keys[info->itext_num - 1] = alloc_string(key);
 3257|  84.2k|  info->itext_langtags[info->itext_num - 1] = alloc_string(langtag);
 3258|  84.2k|  info->itext_transkeys[info->itext_num - 1] = alloc_string(transkey);
 3259|  84.2k|  info->itext_strings[info->itext_num - 1] = alloc_string_sized(str, size);
 3260|       |
 3261|  84.2k|  return 0;
 3262|  84.2k|}
lodepng.cpp:_ZL14string_cleanupPPc:
  301|   545k|static void string_cleanup(char** out) {
  302|   545k|  lodepng_free(*out);
  303|   545k|  *out = NULL;
  304|   545k|}
lodepng.cpp:_ZL16LodePNGText_initP11LodePNGInfo:
 3146|  11.9k|static void LodePNGText_init(LodePNGInfo* info) {
 3147|  11.9k|  info->text_num = 0;
 3148|  11.9k|  info->text_keys = NULL;
 3149|  11.9k|  info->text_strings = NULL;
 3150|  11.9k|}
lodepng.cpp:_ZL17LodePNGIText_initP11LodePNGInfo:
 3200|  11.9k|static void LodePNGIText_init(LodePNGInfo* info) {
 3201|  11.9k|  info->itext_num = 0;
 3202|  11.9k|  info->itext_keys = NULL;
 3203|  11.9k|  info->itext_langtags = NULL;
 3204|  11.9k|  info->itext_transkeys = NULL;
 3205|  11.9k|  info->itext_strings = NULL;
 3206|  11.9k|}
lodepng.cpp:_ZL25LodePNGUnknownChunks_initP11LodePNGInfo:
 3115|  11.9k|static void LodePNGUnknownChunks_init(LodePNGInfo* info) {
 3116|  11.9k|  unsigned i;
 3117|  47.9k|  for(i = 0; i != 3; ++i) info->unknown_chunks_data[i] = 0;
  ------------------
  |  Branch (3117:14): [True: 35.9k, False: 11.9k]
  ------------------
 3118|  47.9k|  for(i = 0; i != 3; ++i) info->unknown_chunks_size[i] = 0;
  ------------------
  |  Branch (3118:14): [True: 35.9k, False: 11.9k]
  ------------------
 3119|  11.9k|}
lodepng.cpp:_ZL28LodePNGUnknownChunks_cleanupP11LodePNGInfo:
 3121|  11.9k|static void LodePNGUnknownChunks_cleanup(LodePNGInfo* info) {
 3122|  11.9k|  unsigned i;
 3123|  47.9k|  for(i = 0; i != 3; ++i) lodepng_free(info->unknown_chunks_data[i]);
  ------------------
  |  Branch (3123:14): [True: 35.9k, False: 11.9k]
  ------------------
 3124|  11.9k|}
lodepng.cpp:_ZL24lodepng_color_mode_equalPK16LodePNGColorModeS1_:
 2985|  4.67k|static int lodepng_color_mode_equal(const LodePNGColorMode* a, const LodePNGColorMode* b) {
 2986|  4.67k|  size_t i;
 2987|  4.67k|  if(a->colortype != b->colortype) return 0;
  ------------------
  |  Branch (2987:6): [True: 2.62k, False: 2.05k]
  ------------------
 2988|  2.05k|  if(a->bitdepth != b->bitdepth) return 0;
  ------------------
  |  Branch (2988:6): [True: 360, False: 1.69k]
  ------------------
 2989|  1.69k|  if(a->key_defined != b->key_defined) return 0;
  ------------------
  |  Branch (2989:6): [True: 0, False: 1.69k]
  ------------------
 2990|  1.69k|  if(a->key_defined) {
  ------------------
  |  Branch (2990:6): [True: 483, False: 1.20k]
  ------------------
 2991|    483|    if(a->key_r != b->key_r) return 0;
  ------------------
  |  Branch (2991:8): [True: 0, False: 483]
  ------------------
 2992|    483|    if(a->key_g != b->key_g) return 0;
  ------------------
  |  Branch (2992:8): [True: 0, False: 483]
  ------------------
 2993|    483|    if(a->key_b != b->key_b) return 0;
  ------------------
  |  Branch (2993:8): [True: 0, False: 483]
  ------------------
 2994|    483|  }
 2995|  1.69k|  if(a->palettesize != b->palettesize) return 0;
  ------------------
  |  Branch (2995:6): [True: 0, False: 1.69k]
  ------------------
 2996|  15.2k|  for(i = 0; i != a->palettesize * 4; ++i) {
  ------------------
  |  Branch (2996:14): [True: 13.5k, False: 1.69k]
  ------------------
 2997|  13.5k|    if(a->palette[i] != b->palette[i]) return 0;
  ------------------
  |  Branch (2997:8): [True: 0, False: 13.5k]
  ------------------
 2998|  13.5k|  }
 2999|  1.69k|  return 1;
 3000|  1.69k|}
lodepng.cpp:_ZL15color_tree_initP9ColorTree:
 3386|  11.0k|static void color_tree_init(ColorTree* tree) {
 3387|  11.0k|  lodepng_memset(tree->children, 0, 16 * sizeof(*tree->children));
 3388|  11.0k|  tree->index = -1;
 3389|  11.0k|}
lodepng.cpp:_ZL14color_tree_addP9ColorTreehhhhj:
 3422|  2.51k|                               unsigned char r, unsigned char g, unsigned char b, unsigned char a, unsigned index) {
 3423|  2.51k|  int bit;
 3424|  22.6k|  for(bit = 0; bit < 8; ++bit) {
  ------------------
  |  Branch (3424:16): [True: 20.1k, False: 2.51k]
  ------------------
 3425|  20.1k|    int i = 8 * ((r >> bit) & 1) + 4 * ((g >> bit) & 1) + 2 * ((b >> bit) & 1) + 1 * ((a >> bit) & 1);
 3426|  20.1k|    if(!tree->children[i]) {
  ------------------
  |  Branch (3426:8): [True: 10.9k, False: 9.20k]
  ------------------
 3427|  10.9k|      tree->children[i] = (ColorTree*)lodepng_malloc(sizeof(ColorTree));
 3428|  10.9k|      if(!tree->children[i]) return 83; /*alloc fail*/
  ------------------
  |  Branch (3428:10): [True: 0, False: 10.9k]
  ------------------
 3429|  10.9k|      color_tree_init(tree->children[i]);
 3430|  10.9k|    }
 3431|  20.1k|    tree = tree->children[i];
 3432|  20.1k|  }
 3433|  2.51k|  tree->index = (int)index;
 3434|  2.51k|  return 0;
 3435|  2.51k|}
lodepng.cpp:_ZL19getPixelColorRGBA16PtS_S_S_PKhmPK16LodePNGColorMode:
 3770|   203k|                                const unsigned char* in, size_t i, const LodePNGColorMode* mode) {
 3771|   203k|  if(mode->colortype == LCT_GREY) {
  ------------------
  |  Branch (3771:6): [True: 35.9k, False: 167k]
  ------------------
 3772|  35.9k|    *r = *g = *b = 256 * in[i * 2 + 0] + in[i * 2 + 1];
 3773|  35.9k|    if(mode->key_defined && 256U * in[i * 2 + 0] + in[i * 2 + 1] == mode->key_r) *a = 0;
  ------------------
  |  Branch (3773:8): [True: 1.20k, False: 34.6k]
  |  Branch (3773:29): [True: 298, False: 909]
  ------------------
 3774|  35.6k|    else *a = 65535;
 3775|   167k|  } else if(mode->colortype == LCT_RGB) {
  ------------------
  |  Branch (3775:13): [True: 3.14k, False: 164k]
  ------------------
 3776|  3.14k|    *r = 256u * in[i * 6 + 0] + in[i * 6 + 1];
 3777|  3.14k|    *g = 256u * in[i * 6 + 2] + in[i * 6 + 3];
 3778|  3.14k|    *b = 256u * in[i * 6 + 4] + in[i * 6 + 5];
 3779|  3.14k|    if(mode->key_defined
  ------------------
  |  Branch (3779:8): [True: 2.62k, False: 525]
  ------------------
 3780|  3.14k|       && 256u * in[i * 6 + 0] + in[i * 6 + 1] == mode->key_r
  ------------------
  |  Branch (3780:11): [True: 959, False: 1.66k]
  ------------------
 3781|  3.14k|       && 256u * in[i * 6 + 2] + in[i * 6 + 3] == mode->key_g
  ------------------
  |  Branch (3781:11): [True: 548, False: 411]
  ------------------
 3782|  3.14k|       && 256u * in[i * 6 + 4] + in[i * 6 + 5] == mode->key_b) *a = 0;
  ------------------
  |  Branch (3782:11): [True: 215, False: 333]
  ------------------
 3783|  2.93k|    else *a = 65535;
 3784|   164k|  } else if(mode->colortype == LCT_GREY_ALPHA) {
  ------------------
  |  Branch (3784:13): [True: 164k, False: 403]
  ------------------
 3785|   164k|    *r = *g = *b = 256u * in[i * 4 + 0] + in[i * 4 + 1];
 3786|   164k|    *a = 256u * in[i * 4 + 2] + in[i * 4 + 3];
 3787|   164k|  } else if(mode->colortype == LCT_RGBA) {
  ------------------
  |  Branch (3787:13): [True: 403, False: 0]
  ------------------
 3788|    403|    *r = 256u * in[i * 8 + 0] + in[i * 8 + 1];
 3789|    403|    *g = 256u * in[i * 8 + 2] + in[i * 8 + 3];
 3790|    403|    *b = 256u * in[i * 8 + 4] + in[i * 8 + 5];
 3791|    403|    *a = 256u * in[i * 8 + 6] + in[i * 8 + 7];
 3792|    403|  }
 3793|   203k|}
lodepng.cpp:_ZL13rgba16ToPixelPhmPK16LodePNGColorModetttt:
 3494|   203k|                         unsigned short r, unsigned short g, unsigned short b, unsigned short a) {
 3495|   203k|  if(mode->colortype == LCT_GREY) {
  ------------------
  |  Branch (3495:6): [True: 0, False: 203k]
  ------------------
 3496|      0|    unsigned short gray = r; /*((unsigned)r + g + b) / 3u;*/
 3497|      0|    out[i * 2 + 0] = (gray >> 8) & 255;
 3498|      0|    out[i * 2 + 1] = gray & 255;
 3499|   203k|  } else if(mode->colortype == LCT_RGB) {
  ------------------
  |  Branch (3499:13): [True: 134k, False: 69.7k]
  ------------------
 3500|   134k|    out[i * 6 + 0] = (r >> 8) & 255;
 3501|   134k|    out[i * 6 + 1] = r & 255;
 3502|   134k|    out[i * 6 + 2] = (g >> 8) & 255;
 3503|   134k|    out[i * 6 + 3] = g & 255;
 3504|   134k|    out[i * 6 + 4] = (b >> 8) & 255;
 3505|   134k|    out[i * 6 + 5] = b & 255;
 3506|   134k|  } else if(mode->colortype == LCT_GREY_ALPHA) {
  ------------------
  |  Branch (3506:13): [True: 0, False: 69.7k]
  ------------------
 3507|      0|    unsigned short gray = r; /*((unsigned)r + g + b) / 3u;*/
 3508|      0|    out[i * 4 + 0] = (gray >> 8) & 255;
 3509|      0|    out[i * 4 + 1] = gray & 255;
 3510|      0|    out[i * 4 + 2] = (a >> 8) & 255;
 3511|      0|    out[i * 4 + 3] = a & 255;
 3512|  69.7k|  } else if(mode->colortype == LCT_RGBA) {
  ------------------
  |  Branch (3512:13): [True: 69.7k, False: 0]
  ------------------
 3513|  69.7k|    out[i * 8 + 0] = (r >> 8) & 255;
 3514|  69.7k|    out[i * 8 + 1] = r & 255;
 3515|  69.7k|    out[i * 8 + 2] = (g >> 8) & 255;
 3516|  69.7k|    out[i * 8 + 3] = g & 255;
 3517|  69.7k|    out[i * 8 + 4] = (b >> 8) & 255;
 3518|  69.7k|    out[i * 8 + 5] = b & 255;
 3519|  69.7k|    out[i * 8 + 6] = (a >> 8) & 255;
 3520|  69.7k|    out[i * 8 + 7] = a & 255;
 3521|  69.7k|  }
 3522|   203k|}
lodepng.cpp:_ZL19getPixelColorsRGBA8PhmPKhPK16LodePNGColorMode:
 3601|    428|                                const LodePNGColorMode* mode) {
 3602|    428|  unsigned num_channels = 4;
 3603|    428|  size_t i;
 3604|    428|  if(mode->colortype == LCT_GREY) {
  ------------------
  |  Branch (3604:6): [True: 134, False: 294]
  ------------------
 3605|    134|    if(mode->bitdepth == 8) {
  ------------------
  |  Branch (3605:8): [True: 46, False: 88]
  ------------------
 3606|   232k|      for(i = 0; i != numpixels; ++i, buffer += num_channels) {
  ------------------
  |  Branch (3606:18): [True: 232k, False: 46]
  ------------------
 3607|   232k|        buffer[0] = buffer[1] = buffer[2] = in[i];
 3608|   232k|        buffer[3] = 255;
 3609|   232k|      }
 3610|     46|      if(mode->key_defined) {
  ------------------
  |  Branch (3610:10): [True: 22, False: 24]
  ------------------
 3611|     22|        buffer -= numpixels * num_channels;
 3612|  67.5k|        for(i = 0; i != numpixels; ++i, buffer += num_channels) {
  ------------------
  |  Branch (3612:20): [True: 67.5k, False: 22]
  ------------------
 3613|  67.5k|          if(buffer[0] == mode->key_r) buffer[3] = 0;
  ------------------
  |  Branch (3613:14): [True: 21.0k, False: 46.4k]
  ------------------
 3614|  67.5k|        }
 3615|     22|      }
 3616|     88|    } else if(mode->bitdepth == 16) {
  ------------------
  |  Branch (3616:15): [True: 33, False: 55]
  ------------------
 3617|  67.5k|      for(i = 0; i != numpixels; ++i, buffer += num_channels) {
  ------------------
  |  Branch (3617:18): [True: 67.4k, False: 33]
  ------------------
 3618|  67.4k|        buffer[0] = buffer[1] = buffer[2] = in[i * 2];
 3619|  67.4k|        buffer[3] = mode->key_defined && 256U * in[i * 2 + 0] + in[i * 2 + 1] == mode->key_r ? 0 : 255;
  ------------------
  |  Branch (3619:21): [True: 519, False: 66.9k]
  |  Branch (3619:42): [True: 0, False: 519]
  ------------------
 3620|  67.4k|      }
 3621|     55|    } else {
 3622|     55|      unsigned highest = ((1U << mode->bitdepth) - 1U); /*highest possible value for this bit depth*/
 3623|     55|      size_t j = 0;
 3624|  14.6M|      for(i = 0; i != numpixels; ++i, buffer += num_channels) {
  ------------------
  |  Branch (3624:18): [True: 14.6M, False: 55]
  ------------------
 3625|  14.6M|        unsigned value = readBitsFromReversedStream(&j, in, mode->bitdepth);
 3626|  14.6M|        buffer[0] = buffer[1] = buffer[2] = (value * 255) / highest;
 3627|  14.6M|        buffer[3] = mode->key_defined && value == mode->key_r ? 0 : 255;
  ------------------
  |  Branch (3627:21): [True: 673, False: 14.6M]
  |  Branch (3627:42): [True: 18, False: 655]
  ------------------
 3628|  14.6M|      }
 3629|     55|    }
 3630|    294|  } else if(mode->colortype == LCT_RGB) {
  ------------------
  |  Branch (3630:13): [True: 204, False: 90]
  ------------------
 3631|    204|    if(mode->bitdepth == 8) {
  ------------------
  |  Branch (3631:8): [True: 109, False: 95]
  ------------------
 3632|  4.90k|      for(i = 0; i != numpixels; ++i, buffer += num_channels) {
  ------------------
  |  Branch (3632:18): [True: 4.79k, False: 109]
  ------------------
 3633|  4.79k|        lodepng_memcpy(buffer, &in[i * 3], 3);
 3634|  4.79k|        buffer[3] = 255;
 3635|  4.79k|      }
 3636|    109|      if(mode->key_defined) {
  ------------------
  |  Branch (3636:10): [True: 81, False: 28]
  ------------------
 3637|     81|        buffer -= numpixels * num_channels;
 3638|  2.87k|        for(i = 0; i != numpixels; ++i, buffer += num_channels) {
  ------------------
  |  Branch (3638:20): [True: 2.79k, False: 81]
  ------------------
 3639|  2.79k|          if(buffer[0] == mode->key_r && buffer[1]== mode->key_g && buffer[2] == mode->key_b) buffer[3] = 0;
  ------------------
  |  Branch (3639:14): [True: 1.52k, False: 1.27k]
  |  Branch (3639:42): [True: 813, False: 709]
  |  Branch (3639:69): [True: 270, False: 543]
  ------------------
 3640|  2.79k|        }
 3641|     81|      }
 3642|    109|    } else {
 3643|  7.90k|      for(i = 0; i != numpixels; ++i, buffer += num_channels) {
  ------------------
  |  Branch (3643:18): [True: 7.80k, False: 95]
  ------------------
 3644|  7.80k|        buffer[0] = in[i * 6 + 0];
 3645|  7.80k|        buffer[1] = in[i * 6 + 2];
 3646|  7.80k|        buffer[2] = in[i * 6 + 4];
 3647|  7.80k|        buffer[3] = mode->key_defined
  ------------------
  |  Branch (3647:21): [True: 2.59k, False: 5.21k]
  ------------------
 3648|  7.80k|           && 256U * in[i * 6 + 0] + in[i * 6 + 1] == mode->key_r
  ------------------
  |  Branch (3648:15): [True: 657, False: 1.93k]
  ------------------
 3649|  7.80k|           && 256U * in[i * 6 + 2] + in[i * 6 + 3] == mode->key_g
  ------------------
  |  Branch (3649:15): [True: 296, False: 361]
  ------------------
 3650|  7.80k|           && 256U * in[i * 6 + 4] + in[i * 6 + 5] == mode->key_b ? 0 : 255;
  ------------------
  |  Branch (3650:15): [True: 13, False: 283]
  ------------------
 3651|  7.80k|      }
 3652|     95|    }
 3653|    204|  } else if(mode->colortype == LCT_PALETTE) {
  ------------------
  |  Branch (3653:13): [True: 34, False: 56]
  ------------------
 3654|     34|    if(mode->bitdepth == 8) {
  ------------------
  |  Branch (3654:8): [True: 12, False: 22]
  ------------------
 3655|    682|      for(i = 0; i != numpixels; ++i, buffer += num_channels) {
  ------------------
  |  Branch (3655:18): [True: 670, False: 12]
  ------------------
 3656|    670|        unsigned index = in[i];
 3657|       |        /*out of bounds of palette not checked: see lodepng_color_mode_alloc_palette.*/
 3658|    670|        lodepng_memcpy(buffer, &mode->palette[index * 4], 4);
 3659|    670|      }
 3660|     22|    } else {
 3661|     22|      size_t j = 0;
 3662|  1.00k|      for(i = 0; i != numpixels; ++i, buffer += num_channels) {
  ------------------
  |  Branch (3662:18): [True: 985, False: 22]
  ------------------
 3663|    985|        unsigned index = readBitsFromReversedStream(&j, in, mode->bitdepth);
 3664|       |        /*out of bounds of palette not checked: see lodepng_color_mode_alloc_palette.*/
 3665|    985|        lodepng_memcpy(buffer, &mode->palette[index * 4], 4);
 3666|    985|      }
 3667|     22|    }
 3668|     56|  } else if(mode->colortype == LCT_GREY_ALPHA) {
  ------------------
  |  Branch (3668:13): [True: 36, False: 20]
  ------------------
 3669|     36|    if(mode->bitdepth == 8) {
  ------------------
  |  Branch (3669:8): [True: 13, False: 23]
  ------------------
 3670|    968|      for(i = 0; i != numpixels; ++i, buffer += num_channels) {
  ------------------
  |  Branch (3670:18): [True: 955, False: 13]
  ------------------
 3671|    955|        buffer[0] = buffer[1] = buffer[2] = in[i * 2 + 0];
 3672|    955|        buffer[3] = in[i * 2 + 1];
 3673|    955|      }
 3674|     23|    } else {
 3675|   160k|      for(i = 0; i != numpixels; ++i, buffer += num_channels) {
  ------------------
  |  Branch (3675:18): [True: 160k, False: 23]
  ------------------
 3676|   160k|        buffer[0] = buffer[1] = buffer[2] = in[i * 4 + 0];
 3677|   160k|        buffer[3] = in[i * 4 + 2];
 3678|   160k|      }
 3679|     23|    }
 3680|     36|  } else if(mode->colortype == LCT_RGBA) {
  ------------------
  |  Branch (3680:13): [True: 20, False: 0]
  ------------------
 3681|     20|    if(mode->bitdepth == 8) {
  ------------------
  |  Branch (3681:8): [True: 0, False: 20]
  ------------------
 3682|      0|      lodepng_memcpy(buffer, in, numpixels * 4);
 3683|     20|    } else {
 3684|    823|      for(i = 0; i != numpixels; ++i, buffer += num_channels) {
  ------------------
  |  Branch (3684:18): [True: 803, False: 20]
  ------------------
 3685|    803|        buffer[0] = in[i * 8 + 0];
 3686|    803|        buffer[1] = in[i * 8 + 2];
 3687|    803|        buffer[2] = in[i * 8 + 4];
 3688|    803|        buffer[3] = in[i * 8 + 6];
 3689|    803|      }
 3690|     20|    }
 3691|     20|  }
 3692|    428|}
lodepng.cpp:_ZL26readBitsFromReversedStreamPmPKhm:
 2715|  57.7M|static unsigned readBitsFromReversedStream(size_t* bitpointer, const unsigned char* bitstream, size_t nbits) {
 2716|  57.7M|  unsigned result = 0;
 2717|  57.7M|  size_t i;
 2718|   116M|  for(i = 0 ; i < nbits; ++i) {
  ------------------
  |  Branch (2718:15): [True: 58.4M, False: 57.7M]
  ------------------
 2719|  58.4M|    result <<= 1u;
 2720|  58.4M|    result |= (unsigned)readBitFromReversedStream(bitpointer, bitstream);
 2721|  58.4M|  }
 2722|  57.7M|  return result;
 2723|  57.7M|}
lodepng.cpp:_ZL25readBitFromReversedStreamPmPKh:
 2708|  72.0M|static unsigned char readBitFromReversedStream(size_t* bitpointer, const unsigned char* bitstream) {
 2709|  72.0M|  unsigned char result = (unsigned char)((bitstream[(*bitpointer) >> 3] >> (7 - ((*bitpointer) & 0x7))) & 1);
 2710|  72.0M|  ++(*bitpointer);
 2711|  72.0M|  return result;
 2712|  72.0M|}
lodepng.cpp:_ZL18getPixelColorsRGB8PhmPKhPK16LodePNGColorMode:
 3697|    195|                               const LodePNGColorMode* mode) {
 3698|    195|  const unsigned num_channels = 3;
 3699|    195|  size_t i;
 3700|    195|  if(mode->colortype == LCT_GREY) {
  ------------------
  |  Branch (3700:6): [True: 89, False: 106]
  ------------------
 3701|     89|    if(mode->bitdepth == 8) {
  ------------------
  |  Branch (3701:8): [True: 20, False: 69]
  ------------------
 3702|   165k|      for(i = 0; i != numpixels; ++i, buffer += num_channels) {
  ------------------
  |  Branch (3702:18): [True: 165k, False: 20]
  ------------------
 3703|   165k|        buffer[0] = buffer[1] = buffer[2] = in[i];
 3704|   165k|      }
 3705|     69|    } else if(mode->bitdepth == 16) {
  ------------------
  |  Branch (3705:15): [True: 23, False: 46]
  ------------------
 3706|  67.3k|      for(i = 0; i != numpixels; ++i, buffer += num_channels) {
  ------------------
  |  Branch (3706:18): [True: 67.2k, False: 23]
  ------------------
 3707|  67.2k|        buffer[0] = buffer[1] = buffer[2] = in[i * 2];
 3708|  67.2k|      }
 3709|     46|    } else {
 3710|     46|      unsigned highest = ((1U << mode->bitdepth) - 1U); /*highest possible value for this bit depth*/
 3711|     46|      size_t j = 0;
 3712|   885k|      for(i = 0; i != numpixels; ++i, buffer += num_channels) {
  ------------------
  |  Branch (3712:18): [True: 885k, False: 46]
  ------------------
 3713|   885k|        unsigned value = readBitsFromReversedStream(&j, in, mode->bitdepth);
 3714|   885k|        buffer[0] = buffer[1] = buffer[2] = (value * 255) / highest;
 3715|   885k|      }
 3716|     46|    }
 3717|    106|  } else if(mode->colortype == LCT_RGB) {
  ------------------
  |  Branch (3717:13): [True: 22, False: 84]
  ------------------
 3718|     22|    if(mode->bitdepth == 8) {
  ------------------
  |  Branch (3718:8): [True: 0, False: 22]
  ------------------
 3719|      0|      lodepng_memcpy(buffer, in, numpixels * 3);
 3720|     22|    } else {
 3721|  1.27k|      for(i = 0; i != numpixels; ++i, buffer += num_channels) {
  ------------------
  |  Branch (3721:18): [True: 1.25k, False: 22]
  ------------------
 3722|  1.25k|        buffer[0] = in[i * 6 + 0];
 3723|  1.25k|        buffer[1] = in[i * 6 + 2];
 3724|  1.25k|        buffer[2] = in[i * 6 + 4];
 3725|  1.25k|      }
 3726|     22|    }
 3727|     84|  } else if(mode->colortype == LCT_PALETTE) {
  ------------------
  |  Branch (3727:13): [True: 29, False: 55]
  ------------------
 3728|     29|    if(mode->bitdepth == 8) {
  ------------------
  |  Branch (3728:8): [True: 9, False: 20]
  ------------------
 3729|    604|      for(i = 0; i != numpixels; ++i, buffer += num_channels) {
  ------------------
  |  Branch (3729:18): [True: 595, False: 9]
  ------------------
 3730|    595|        unsigned index = in[i];
 3731|       |        /*out of bounds of palette not checked: see lodepng_color_mode_alloc_palette.*/
 3732|    595|        lodepng_memcpy(buffer, &mode->palette[index * 4], 3);
 3733|    595|      }
 3734|     20|    } else {
 3735|     20|      size_t j = 0;
 3736|    583|      for(i = 0; i != numpixels; ++i, buffer += num_channels) {
  ------------------
  |  Branch (3736:18): [True: 563, False: 20]
  ------------------
 3737|    563|        unsigned index = readBitsFromReversedStream(&j, in, mode->bitdepth);
 3738|       |        /*out of bounds of palette not checked: see lodepng_color_mode_alloc_palette.*/
 3739|    563|        lodepng_memcpy(buffer, &mode->palette[index * 4], 3);
 3740|    563|      }
 3741|     20|    }
 3742|     55|  } else if(mode->colortype == LCT_GREY_ALPHA) {
  ------------------
  |  Branch (3742:13): [True: 25, False: 30]
  ------------------
 3743|     25|    if(mode->bitdepth == 8) {
  ------------------
  |  Branch (3743:8): [True: 8, False: 17]
  ------------------
 3744|    276|      for(i = 0; i != numpixels; ++i, buffer += num_channels) {
  ------------------
  |  Branch (3744:18): [True: 268, False: 8]
  ------------------
 3745|    268|        buffer[0] = buffer[1] = buffer[2] = in[i * 2 + 0];
 3746|    268|      }
 3747|     17|    } else {
 3748|   187k|      for(i = 0; i != numpixels; ++i, buffer += num_channels) {
  ------------------
  |  Branch (3748:18): [True: 187k, False: 17]
  ------------------
 3749|   187k|        buffer[0] = buffer[1] = buffer[2] = in[i * 4 + 0];
 3750|   187k|      }
 3751|     17|    }
 3752|     30|  } else if(mode->colortype == LCT_RGBA) {
  ------------------
  |  Branch (3752:13): [True: 30, False: 0]
  ------------------
 3753|     30|    if(mode->bitdepth == 8) {
  ------------------
  |  Branch (3753:8): [True: 12, False: 18]
  ------------------
 3754|    529|      for(i = 0; i != numpixels; ++i, buffer += num_channels) {
  ------------------
  |  Branch (3754:18): [True: 517, False: 12]
  ------------------
 3755|    517|        lodepng_memcpy(buffer, &in[i * 4], 3);
 3756|    517|      }
 3757|     18|    } else {
 3758|    788|      for(i = 0; i != numpixels; ++i, buffer += num_channels) {
  ------------------
  |  Branch (3758:18): [True: 770, False: 18]
  ------------------
 3759|    770|        buffer[0] = in[i * 8 + 0];
 3760|    770|        buffer[1] = in[i * 8 + 2];
 3761|    770|        buffer[2] = in[i * 8 + 4];
 3762|    770|      }
 3763|     18|    }
 3764|     30|  }
 3765|    195|}
lodepng.cpp:_ZL18getPixelColorRGBA8PhS_S_S_PKhmPK16LodePNGColorMode:
 3528|  42.2M|                               const LodePNGColorMode* mode) {
 3529|  42.2M|  if(mode->colortype == LCT_GREY) {
  ------------------
  |  Branch (3529:6): [True: 42.2M, False: 16.3k]
  ------------------
 3530|  42.2M|    if(mode->bitdepth == 8) {
  ------------------
  |  Branch (3530:8): [True: 3.12k, False: 42.2M]
  ------------------
 3531|  3.12k|      *r = *g = *b = in[i];
 3532|  3.12k|      if(mode->key_defined && *r == mode->key_r) *a = 0;
  ------------------
  |  Branch (3532:10): [True: 1.67k, False: 1.44k]
  |  Branch (3532:31): [True: 327, False: 1.34k]
  ------------------
 3533|  2.79k|      else *a = 255;
 3534|  42.2M|    } else if(mode->bitdepth == 16) {
  ------------------
  |  Branch (3534:15): [True: 2.47k, False: 42.2M]
  ------------------
 3535|  2.47k|      *r = *g = *b = in[i * 2 + 0];
 3536|  2.47k|      if(mode->key_defined && 256U * in[i * 2 + 0] + in[i * 2 + 1] == mode->key_r) *a = 0;
  ------------------
  |  Branch (3536:10): [True: 795, False: 1.67k]
  |  Branch (3536:31): [True: 264, False: 531]
  ------------------
 3537|  2.20k|      else *a = 255;
 3538|  42.2M|    } else {
 3539|  42.2M|      unsigned highest = ((1U << mode->bitdepth) - 1U); /*highest possible value for this bit depth*/
 3540|  42.2M|      size_t j = i * mode->bitdepth;
 3541|  42.2M|      unsigned value = readBitsFromReversedStream(&j, in, mode->bitdepth);
 3542|  42.2M|      *r = *g = *b = (value * 255) / highest;
 3543|  42.2M|      if(mode->key_defined && value == mode->key_r) *a = 0;
  ------------------
  |  Branch (3543:10): [True: 983, False: 42.2M]
  |  Branch (3543:31): [True: 288, False: 695]
  ------------------
 3544|  42.2M|      else *a = 255;
 3545|  42.2M|    }
 3546|  42.2M|  } else if(mode->colortype == LCT_RGB) {
  ------------------
  |  Branch (3546:13): [True: 7.69k, False: 8.69k]
  ------------------
 3547|  7.69k|    if(mode->bitdepth == 8) {
  ------------------
  |  Branch (3547:8): [True: 4.31k, False: 3.38k]
  ------------------
 3548|  4.31k|      *r = in[i * 3 + 0]; *g = in[i * 3 + 1]; *b = in[i * 3 + 2];
 3549|  4.31k|      if(mode->key_defined && *r == mode->key_r && *g == mode->key_g && *b == mode->key_b) *a = 0;
  ------------------
  |  Branch (3549:10): [True: 2.25k, False: 2.05k]
  |  Branch (3549:31): [True: 1.20k, False: 1.04k]
  |  Branch (3549:52): [True: 678, False: 530]
  |  Branch (3549:73): [True: 248, False: 430]
  ------------------
 3550|  4.06k|      else *a = 255;
 3551|  4.31k|    } else {
 3552|  3.38k|      *r = in[i * 6 + 0];
 3553|  3.38k|      *g = in[i * 6 + 2];
 3554|  3.38k|      *b = in[i * 6 + 4];
 3555|  3.38k|      if(mode->key_defined && 256U * in[i * 6 + 0] + in[i * 6 + 1] == mode->key_r
  ------------------
  |  Branch (3555:10): [True: 2.78k, False: 596]
  |  Branch (3555:31): [True: 974, False: 1.81k]
  ------------------
 3556|  3.38k|         && 256U * in[i * 6 + 2] + in[i * 6 + 3] == mode->key_g
  ------------------
  |  Branch (3556:13): [True: 576, False: 398]
  ------------------
 3557|  3.38k|         && 256U * in[i * 6 + 4] + in[i * 6 + 5] == mode->key_b) *a = 0;
  ------------------
  |  Branch (3557:13): [True: 215, False: 361]
  ------------------
 3558|  3.16k|      else *a = 255;
 3559|  3.38k|    }
 3560|  8.69k|  } else if(mode->colortype == LCT_PALETTE) {
  ------------------
  |  Branch (3560:13): [True: 1.93k, False: 6.76k]
  ------------------
 3561|  1.93k|    unsigned index;
 3562|  1.93k|    if(mode->bitdepth == 8) index = in[i];
  ------------------
  |  Branch (3562:8): [True: 345, False: 1.59k]
  ------------------
 3563|  1.59k|    else {
 3564|  1.59k|      size_t j = i * mode->bitdepth;
 3565|  1.59k|      index = readBitsFromReversedStream(&j, in, mode->bitdepth);
 3566|  1.59k|    }
 3567|       |    /*out of bounds of palette not checked: see lodepng_color_mode_alloc_palette.*/
 3568|  1.93k|    *r = mode->palette[index * 4 + 0];
 3569|  1.93k|    *g = mode->palette[index * 4 + 1];
 3570|  1.93k|    *b = mode->palette[index * 4 + 2];
 3571|  1.93k|    *a = mode->palette[index * 4 + 3];
 3572|  6.76k|  } else if(mode->colortype == LCT_GREY_ALPHA) {
  ------------------
  |  Branch (3572:13): [True: 943, False: 5.81k]
  ------------------
 3573|    943|    if(mode->bitdepth == 8) {
  ------------------
  |  Branch (3573:8): [True: 393, False: 550]
  ------------------
 3574|    393|      *r = *g = *b = in[i * 2 + 0];
 3575|    393|      *a = in[i * 2 + 1];
 3576|    550|    } else {
 3577|    550|      *r = *g = *b = in[i * 4 + 0];
 3578|    550|      *a = in[i * 4 + 2];
 3579|    550|    }
 3580|  5.81k|  } else if(mode->colortype == LCT_RGBA) {
  ------------------
  |  Branch (3580:13): [True: 5.81k, False: 0]
  ------------------
 3581|  5.81k|    if(mode->bitdepth == 8) {
  ------------------
  |  Branch (3581:8): [True: 714, False: 5.10k]
  ------------------
 3582|    714|      *r = in[i * 4 + 0];
 3583|    714|      *g = in[i * 4 + 1];
 3584|    714|      *b = in[i * 4 + 2];
 3585|    714|      *a = in[i * 4 + 3];
 3586|  5.10k|    } else {
 3587|  5.10k|      *r = in[i * 8 + 0];
 3588|  5.10k|      *g = in[i * 8 + 2];
 3589|  5.10k|      *b = in[i * 8 + 4];
 3590|  5.10k|      *a = in[i * 8 + 6];
 3591|  5.10k|    }
 3592|  5.81k|  }
 3593|  42.2M|}
lodepng.cpp:_ZL12rgba8ToPixelPhmPK16LodePNGColorModeP9ColorTreehhhh:
 3440|  42.2M|                             unsigned char r, unsigned char g, unsigned char b, unsigned char a) {
 3441|  42.2M|  if(mode->colortype == LCT_GREY) {
  ------------------
  |  Branch (3441:6): [True: 13.9M, False: 28.2M]
  ------------------
 3442|  13.9M|    unsigned char gray = r; /*((unsigned short)r + g + b) / 3u;*/
 3443|  13.9M|    if(mode->bitdepth == 8) out[i] = gray;
  ------------------
  |  Branch (3443:8): [True: 13.9M, False: 0]
  ------------------
 3444|      0|    else if(mode->bitdepth == 16) out[i * 2 + 0] = out[i * 2 + 1] = gray;
  ------------------
  |  Branch (3444:13): [True: 0, False: 0]
  ------------------
 3445|      0|    else {
 3446|       |      /*take the most significant bits of gray*/
 3447|      0|      gray = ((unsigned)gray >> (8u - mode->bitdepth)) & ((1u << mode->bitdepth) - 1u);
 3448|      0|      addColorBits(out, i, mode->bitdepth, gray);
 3449|      0|    }
 3450|  28.2M|  } else if(mode->colortype == LCT_RGB) {
  ------------------
  |  Branch (3450:13): [True: 14.1M, False: 14.1M]
  ------------------
 3451|  14.1M|    if(mode->bitdepth == 8) {
  ------------------
  |  Branch (3451:8): [True: 0, False: 14.1M]
  ------------------
 3452|      0|      out[i * 3 + 0] = r;
 3453|      0|      out[i * 3 + 1] = g;
 3454|      0|      out[i * 3 + 2] = b;
 3455|  14.1M|    } else {
 3456|  14.1M|      out[i * 6 + 0] = out[i * 6 + 1] = r;
 3457|  14.1M|      out[i * 6 + 2] = out[i * 6 + 3] = g;
 3458|  14.1M|      out[i * 6 + 4] = out[i * 6 + 5] = b;
 3459|  14.1M|    }
 3460|  14.1M|  } else if(mode->colortype == LCT_PALETTE) {
  ------------------
  |  Branch (3460:13): [True: 1.61k, False: 14.1M]
  ------------------
 3461|  1.61k|    int index = color_tree_get(tree, r, g, b, a);
 3462|  1.61k|    if(index < 0) return 82; /*color not in palette*/
  ------------------
  |  Branch (3462:8): [True: 109, False: 1.50k]
  ------------------
 3463|  1.50k|    if(mode->bitdepth == 8) out[i] = index;
  ------------------
  |  Branch (3463:8): [True: 1.50k, False: 0]
  ------------------
 3464|      0|    else addColorBits(out, i, mode->bitdepth, (unsigned)index);
 3465|  14.1M|  } else if(mode->colortype == LCT_GREY_ALPHA) {
  ------------------
  |  Branch (3465:13): [True: 13.9M, False: 136k]
  ------------------
 3466|  13.9M|    unsigned char gray = r; /*((unsigned short)r + g + b) / 3u;*/
 3467|  13.9M|    if(mode->bitdepth == 8) {
  ------------------
  |  Branch (3467:8): [True: 13.9M, False: 0]
  ------------------
 3468|  13.9M|      out[i * 2 + 0] = gray;
 3469|  13.9M|      out[i * 2 + 1] = a;
 3470|  13.9M|    } else if(mode->bitdepth == 16) {
  ------------------
  |  Branch (3470:15): [True: 0, False: 0]
  ------------------
 3471|      0|      out[i * 4 + 0] = out[i * 4 + 1] = gray;
 3472|      0|      out[i * 4 + 2] = out[i * 4 + 3] = a;
 3473|      0|    }
 3474|  13.9M|  } else if(mode->colortype == LCT_RGBA) {
  ------------------
  |  Branch (3474:13): [True: 136k, False: 0]
  ------------------
 3475|   136k|    if(mode->bitdepth == 8) {
  ------------------
  |  Branch (3475:8): [True: 0, False: 136k]
  ------------------
 3476|      0|      out[i * 4 + 0] = r;
 3477|      0|      out[i * 4 + 1] = g;
 3478|      0|      out[i * 4 + 2] = b;
 3479|      0|      out[i * 4 + 3] = a;
 3480|   136k|    } else {
 3481|   136k|      out[i * 8 + 0] = out[i * 8 + 1] = r;
 3482|   136k|      out[i * 8 + 2] = out[i * 8 + 3] = g;
 3483|   136k|      out[i * 8 + 4] = out[i * 8 + 5] = b;
 3484|   136k|      out[i * 8 + 6] = out[i * 8 + 7] = a;
 3485|   136k|    }
 3486|   136k|  }
 3487|       |
 3488|  42.2M|  return 0; /*no error*/
 3489|  42.2M|}
lodepng.cpp:_ZL14color_tree_getP9ColorTreehhhh:
 3402|  1.61k|static int color_tree_get(ColorTree* tree, unsigned char r, unsigned char g, unsigned char b, unsigned char a) {
 3403|  1.61k|  int bit = 0;
 3404|  13.6k|  for(bit = 0; bit < 8; ++bit) {
  ------------------
  |  Branch (3404:16): [True: 12.1k, False: 1.50k]
  ------------------
 3405|  12.1k|    int i = 8 * ((r >> bit) & 1) + 4 * ((g >> bit) & 1) + 2 * ((b >> bit) & 1) + 1 * ((a >> bit) & 1);
 3406|  12.1k|    if(!tree->children[i]) return -1;
  ------------------
  |  Branch (3406:8): [True: 109, False: 12.0k]
  ------------------
 3407|  12.0k|    else tree = tree->children[i];
 3408|  12.1k|  }
 3409|  1.50k|  return tree ? tree->index : -1;
  ------------------
  |  Branch (3409:10): [True: 1.50k, False: 0]
  ------------------
 3410|  1.61k|}
lodepng.cpp:_ZL18color_tree_cleanupP9ColorTree:
 3391|  11.0k|static void color_tree_cleanup(ColorTree* tree) {
 3392|  11.0k|  int i;
 3393|   188k|  for(i = 0; i != 16; ++i) {
  ------------------
  |  Branch (3393:14): [True: 177k, False: 11.0k]
  ------------------
 3394|   177k|    if(tree->children[i]) {
  ------------------
  |  Branch (3394:8): [True: 10.9k, False: 166k]
  ------------------
 3395|  10.9k|      color_tree_cleanup(tree->children[i]);
 3396|  10.9k|      lodepng_free(tree->children[i]);
 3397|  10.9k|    }
 3398|   177k|  }
 3399|  11.0k|}
lodepng.cpp:_ZL18checkColorValidity16LodePNGColorTypej:
 2903|  7.44k|static unsigned checkColorValidity(LodePNGColorType colortype, unsigned bd) {
 2904|  7.44k|  switch(colortype) {
 2905|  2.64k|    case LCT_GREY:       if(!(bd == 1 || bd == 2 || bd == 4 || bd == 8 || bd == 16)) return 37; break;
  ------------------
  |  Branch (2905:5): [True: 2.64k, False: 4.80k]
  |  Branch (2905:31): [True: 843, False: 1.79k]
  |  Branch (2905:42): [True: 278, False: 1.52k]
  |  Branch (2905:53): [True: 310, False: 1.21k]
  |  Branch (2905:64): [True: 426, False: 785]
  |  Branch (2905:75): [True: 765, False: 20]
  ------------------
 2906|  2.74k|    case LCT_RGB:        if(!(                                 bd == 8 || bd == 16)) return 37; break;
  ------------------
  |  Branch (2906:5): [True: 2.74k, False: 4.70k]
  |  Branch (2906:64): [True: 1.24k, False: 1.49k]
  |  Branch (2906:75): [True: 1.48k, False: 12]
  ------------------
 2907|  2.72k|    case LCT_PALETTE:    if(!(bd == 1 || bd == 2 || bd == 4 || bd == 8            )) return 37; break;
  ------------------
  |  Branch (2907:5): [True: 552, False: 6.89k]
  |  Branch (2907:31): [True: 180, False: 372]
  |  Branch (2907:42): [True: 164, False: 208]
  |  Branch (2907:53): [True: 70, False: 138]
  |  Branch (2907:64): [True: 124, False: 14]
  ------------------
 2908|    549|    case LCT_GREY_ALPHA: if(!(                                 bd == 8 || bd == 16)) return 37; break;
  ------------------
  |  Branch (2908:5): [True: 549, False: 6.89k]
  |  Branch (2908:64): [True: 200, False: 349]
  |  Branch (2908:75): [True: 338, False: 11]
  ------------------
 2909|    958|    case LCT_RGBA:       if(!(                                 bd == 8 || bd == 16)) return 37; break;
  ------------------
  |  Branch (2909:5): [True: 958, False: 6.48k]
  |  Branch (2909:64): [True: 266, False: 692]
  |  Branch (2909:75): [True: 680, False: 12]
  ------------------
 2910|    946|    case LCT_MAX_OCTET_VALUE: return 31; /* invalid color type */
  ------------------
  |  Branch (2910:5): [True: 0, False: 7.44k]
  ------------------
 2911|      4|    default: return 31; /* invalid color type */
  ------------------
  |  Branch (2911:5): [True: 4, False: 7.44k]
  ------------------
 2912|  7.44k|  }
 2913|  7.37k|  return 0; /*allowed color type / bits combination*/
 2914|  7.44k|}
lodepng.cpp:_ZL14readChunk_PLTEP16LodePNGColorModePKhm:
 4713|  2.53k|static unsigned readChunk_PLTE(LodePNGColorMode* color, const unsigned char* data, size_t chunkLength) {
 4714|  2.53k|  unsigned pos = 0, i;
 4715|  2.53k|  color->palettesize = chunkLength / 3u;
 4716|  2.53k|  if(color->palettesize == 0 || color->palettesize > 256) return 38; /*error: palette too small or big*/
  ------------------
  |  Branch (4716:6): [True: 3, False: 2.53k]
  |  Branch (4716:33): [True: 7, False: 2.52k]
  ------------------
 4717|  2.52k|  lodepng_color_mode_alloc_palette(color);
 4718|  2.52k|  if(!color->palette && color->palettesize) {
  ------------------
  |  Branch (4718:6): [True: 0, False: 2.52k]
  |  Branch (4718:25): [True: 0, False: 0]
  ------------------
 4719|      0|    color->palettesize = 0;
 4720|      0|    return 83; /*alloc fail*/
 4721|      0|  }
 4722|       |
 4723|  19.7k|  for(i = 0; i != color->palettesize; ++i) {
  ------------------
  |  Branch (4723:14): [True: 17.1k, False: 2.52k]
  ------------------
 4724|  17.1k|    color->palette[4 * i + 0] = data[pos++]; /*R*/
 4725|  17.1k|    color->palette[4 * i + 1] = data[pos++]; /*G*/
 4726|  17.1k|    color->palette[4 * i + 2] = data[pos++]; /*B*/
 4727|  17.1k|    color->palette[4 * i + 3] = 255; /*alpha*/
 4728|  17.1k|  }
 4729|       |
 4730|  2.52k|  return 0; /* OK */
 4731|  2.52k|}
lodepng.cpp:_ZL14readChunk_tRNSP16LodePNGColorModePKhm:
 4733|  2.11k|static unsigned readChunk_tRNS(LodePNGColorMode* color, const unsigned char* data, size_t chunkLength) {
 4734|  2.11k|  unsigned i;
 4735|  2.11k|  if(color->colortype == LCT_PALETTE) {
  ------------------
  |  Branch (4735:6): [True: 255, False: 1.85k]
  ------------------
 4736|       |    /*error: more alpha values given than there are palette entries*/
 4737|    255|    if(chunkLength > color->palettesize) return 39;
  ------------------
  |  Branch (4737:8): [True: 4, False: 251]
  ------------------
 4738|       |
 4739|  2.26k|    for(i = 0; i != chunkLength; ++i) color->palette[4 * i + 3] = data[i];
  ------------------
  |  Branch (4739:16): [True: 2.01k, False: 251]
  ------------------
 4740|  1.85k|  } else if(color->colortype == LCT_GREY) {
  ------------------
  |  Branch (4740:13): [True: 591, False: 1.26k]
  ------------------
 4741|       |    /*error: this chunk must be 2 bytes for grayscale image*/
 4742|    591|    if(chunkLength != 2) return 30;
  ------------------
  |  Branch (4742:8): [True: 12, False: 579]
  ------------------
 4743|       |
 4744|    579|    color->key_defined = 1;
 4745|    579|    color->key_r = color->key_g = color->key_b = 256u * data[0] + data[1];
 4746|  1.26k|  } else if(color->colortype == LCT_RGB) {
  ------------------
  |  Branch (4746:13): [True: 1.26k, False: 2]
  ------------------
 4747|       |    /*error: this chunk must be 6 bytes for RGB image*/
 4748|  1.26k|    if(chunkLength != 6) return 41;
  ------------------
  |  Branch (4748:8): [True: 11, False: 1.25k]
  ------------------
 4749|       |
 4750|  1.25k|    color->key_defined = 1;
 4751|  1.25k|    color->key_r = 256u * data[0] + data[1];
 4752|  1.25k|    color->key_g = 256u * data[2] + data[3];
 4753|  1.25k|    color->key_b = 256u * data[4] + data[5];
 4754|  1.25k|  }
 4755|      2|  else return 42; /*error: tRNS chunk not allowed for other color models*/
 4756|       |
 4757|  2.08k|  return 0; /* OK */
 4758|  2.11k|}
lodepng.cpp:_ZL14readChunk_bKGDP11LodePNGInfoPKhm:
 4763|  1.04k|static unsigned readChunk_bKGD(LodePNGInfo* info, const unsigned char* data, size_t chunkLength) {
 4764|  1.04k|  if(info->color.colortype == LCT_PALETTE) {
  ------------------
  |  Branch (4764:6): [True: 241, False: 803]
  ------------------
 4765|       |    /*error: this chunk must be 1 byte for indexed color image*/
 4766|    241|    if(chunkLength != 1) return 43;
  ------------------
  |  Branch (4766:8): [True: 14, False: 227]
  ------------------
 4767|       |
 4768|       |    /*error: invalid palette index, or maybe this chunk appeared before PLTE*/
 4769|    227|    if(data[0] >= info->color.palettesize) return 103;
  ------------------
  |  Branch (4769:8): [True: 7, False: 220]
  ------------------
 4770|       |
 4771|    220|    info->background_defined = 1;
 4772|    220|    info->background_r = info->background_g = info->background_b = data[0];
 4773|    803|  } else if(info->color.colortype == LCT_GREY || info->color.colortype == LCT_GREY_ALPHA) {
  ------------------
  |  Branch (4773:13): [True: 208, False: 595]
  |  Branch (4773:50): [True: 205, False: 390]
  ------------------
 4774|       |    /*error: this chunk must be 2 bytes for grayscale image*/
 4775|    413|    if(chunkLength != 2) return 44;
  ------------------
  |  Branch (4775:8): [True: 10, False: 403]
  ------------------
 4776|       |
 4777|       |    /*the values are truncated to bitdepth in the PNG file*/
 4778|    403|    info->background_defined = 1;
 4779|    403|    info->background_r = info->background_g = info->background_b = 256u * data[0] + data[1];
 4780|    403|  } else if(info->color.colortype == LCT_RGB || info->color.colortype == LCT_RGBA) {
  ------------------
  |  Branch (4780:13): [True: 77, False: 313]
  |  Branch (4780:49): [True: 313, False: 0]
  ------------------
 4781|       |    /*error: this chunk must be 6 bytes for grayscale image*/
 4782|    390|    if(chunkLength != 6) return 45;
  ------------------
  |  Branch (4782:8): [True: 17, False: 373]
  ------------------
 4783|       |
 4784|       |    /*the values are truncated to bitdepth in the PNG file*/
 4785|    373|    info->background_defined = 1;
 4786|    373|    info->background_r = 256u * data[0] + data[1];
 4787|    373|    info->background_g = 256u * data[2] + data[3];
 4788|    373|    info->background_b = 256u * data[4] + data[5];
 4789|    373|  }
 4790|       |
 4791|    996|  return 0; /* OK */
 4792|  1.04k|}
lodepng.cpp:_ZL14readChunk_tEXtP11LodePNGInfoPKhm:
 4795|  96.5k|static unsigned readChunk_tEXt(LodePNGInfo* info, const unsigned char* data, size_t chunkLength) {
 4796|  96.5k|  unsigned error = 0;
 4797|  96.5k|  char *key = 0, *str = 0;
 4798|       |
 4799|  96.5k|  while(!error) /*not really a while loop, only used to break on error*/ {
  ------------------
  |  Branch (4799:9): [True: 96.5k, False: 0]
  ------------------
 4800|  96.5k|    unsigned length, string2_begin;
 4801|       |
 4802|  96.5k|    length = 0;
 4803|   970k|    while(length < chunkLength && data[length] != 0) ++length;
  ------------------
  |  Branch (4803:11): [True: 875k, False: 94.3k]
  |  Branch (4803:35): [True: 873k, False: 2.20k]
  ------------------
 4804|       |    /*even though it's not allowed by the standard, no error is thrown if
 4805|       |    there's no null termination char, if the text is empty*/
 4806|  96.5k|    if(length < 1 || length > 79) CERROR_BREAK(error, 89); /*keyword too short or long*/
  ------------------
  |  |  179|     24|#define CERROR_BREAK(errorvar, code){\
  |  |  180|     24|  errorvar = code;\
  |  |  181|     24|  break;\
  |  |  182|     24|}
  ------------------
  |  Branch (4806:8): [True: 4, False: 96.5k]
  |  Branch (4806:22): [True: 20, False: 96.5k]
  ------------------
 4807|       |
 4808|  96.5k|    key = (char*)lodepng_malloc(length + 1);
 4809|  96.5k|    if(!key) CERROR_BREAK(error, 83); /*alloc fail*/
  ------------------
  |  |  179|      0|#define CERROR_BREAK(errorvar, code){\
  |  |  180|      0|  errorvar = code;\
  |  |  181|      0|  break;\
  |  |  182|      0|}
  ------------------
  |  Branch (4809:8): [True: 0, False: 96.5k]
  ------------------
 4810|       |
 4811|  96.5k|    lodepng_memcpy(key, data, length);
 4812|  96.5k|    key[length] = 0;
 4813|       |
 4814|  96.5k|    string2_begin = length + 1; /*skip keyword null terminator*/
 4815|       |
 4816|  96.5k|    length = (unsigned)(chunkLength < string2_begin ? 0 : chunkLength - string2_begin);
  ------------------
  |  Branch (4816:25): [True: 94.3k, False: 2.19k]
  ------------------
 4817|  96.5k|    str = (char*)lodepng_malloc(length + 1);
 4818|  96.5k|    if(!str) CERROR_BREAK(error, 83); /*alloc fail*/
  ------------------
  |  |  179|      0|#define CERROR_BREAK(errorvar, code){\
  |  |  180|      0|  errorvar = code;\
  |  |  181|      0|  break;\
  |  |  182|      0|}
  ------------------
  |  Branch (4818:8): [True: 0, False: 96.5k]
  ------------------
 4819|       |
 4820|  96.5k|    lodepng_memcpy(str, data + string2_begin, length);
 4821|  96.5k|    str[length] = 0;
 4822|       |
 4823|  96.5k|    error = lodepng_add_text(info, key, str);
 4824|       |
 4825|  96.5k|    break;
 4826|  96.5k|  }
 4827|       |
 4828|  96.5k|  lodepng_free(key);
 4829|  96.5k|  lodepng_free(str);
 4830|       |
 4831|  96.5k|  return error;
 4832|  96.5k|}
lodepng.cpp:_ZL14readChunk_zTXtP11LodePNGInfoPK22LodePNGDecoderSettingsPKhm:
 4836|  1.40k|                               const unsigned char* data, size_t chunkLength) {
 4837|  1.40k|  unsigned error = 0;
 4838|       |
 4839|       |  /*copy the object to change parameters in it*/
 4840|  1.40k|  LodePNGDecompressSettings zlibsettings = decoder->zlibsettings;
 4841|       |
 4842|  1.40k|  unsigned length, string2_begin;
 4843|  1.40k|  char *key = 0;
 4844|  1.40k|  unsigned char* str = 0;
 4845|  1.40k|  size_t size = 0;
 4846|       |
 4847|  1.40k|  while(!error) /*not really a while loop, only used to break on error*/ {
  ------------------
  |  Branch (4847:9): [True: 1.40k, False: 0]
  ------------------
 4848|  2.89M|    for(length = 0; length < chunkLength && data[length] != 0; ++length) ;
  ------------------
  |  Branch (4848:21): [True: 2.89M, False: 11]
  |  Branch (4848:45): [True: 2.89M, False: 1.39k]
  ------------------
 4849|  1.40k|    if(length + 2 >= chunkLength) CERROR_BREAK(error, 75); /*no null termination, corrupt?*/
  ------------------
  |  |  179|     15|#define CERROR_BREAK(errorvar, code){\
  |  |  180|     15|  errorvar = code;\
  |  |  181|     15|  break;\
  |  |  182|     15|}
  ------------------
  |  Branch (4849:8): [True: 15, False: 1.39k]
  ------------------
 4850|  1.39k|    if(length < 1 || length > 79) CERROR_BREAK(error, 89); /*keyword too short or long*/
  ------------------
  |  |  179|     36|#define CERROR_BREAK(errorvar, code){\
  |  |  180|     36|  errorvar = code;\
  |  |  181|     36|  break;\
  |  |  182|     36|}
  ------------------
  |  Branch (4850:8): [True: 1, False: 1.39k]
  |  Branch (4850:22): [True: 35, False: 1.35k]
  ------------------
 4851|       |
 4852|  1.35k|    key = (char*)lodepng_malloc(length + 1);
 4853|  1.35k|    if(!key) CERROR_BREAK(error, 83); /*alloc fail*/
  ------------------
  |  |  179|      0|#define CERROR_BREAK(errorvar, code){\
  |  |  180|      0|  errorvar = code;\
  |  |  181|      0|  break;\
  |  |  182|      0|}
  ------------------
  |  Branch (4853:8): [True: 0, False: 1.35k]
  ------------------
 4854|       |
 4855|  1.35k|    lodepng_memcpy(key, data, length);
 4856|  1.35k|    key[length] = 0;
 4857|       |
 4858|  1.35k|    if(data[length + 1] != 0) CERROR_BREAK(error, 72); /*the 0 byte indicating compression must be 0*/
  ------------------
  |  |  179|     10|#define CERROR_BREAK(errorvar, code){\
  |  |  180|     10|  errorvar = code;\
  |  |  181|     10|  break;\
  |  |  182|     10|}
  ------------------
  |  Branch (4858:8): [True: 10, False: 1.34k]
  ------------------
 4859|       |
 4860|  1.34k|    string2_begin = length + 2;
 4861|  1.34k|    if(string2_begin > chunkLength) CERROR_BREAK(error, 75); /*no null termination, corrupt?*/
  ------------------
  |  |  179|      0|#define CERROR_BREAK(errorvar, code){\
  |  |  180|      0|  errorvar = code;\
  |  |  181|      0|  break;\
  |  |  182|      0|}
  ------------------
  |  Branch (4861:8): [True: 0, False: 1.34k]
  ------------------
 4862|       |
 4863|  1.34k|    length = (unsigned)chunkLength - string2_begin;
 4864|  1.34k|    zlibsettings.max_output_size = decoder->max_text_size;
 4865|       |    /*will fail if zlib error, e.g. if length is too small*/
 4866|  1.34k|    error = zlib_decompress(&str, &size, 0, &data[string2_begin],
 4867|  1.34k|                            length, &zlibsettings);
 4868|       |    /*error: compressed text larger than  decoder->max_text_size*/
 4869|  1.34k|    if(error && size > zlibsettings.max_output_size) error = 112;
  ------------------
  |  Branch (4869:8): [True: 83, False: 1.26k]
  |  Branch (4869:17): [True: 9, False: 74]
  ------------------
 4870|  1.34k|    if(error) break;
  ------------------
  |  Branch (4870:8): [True: 83, False: 1.26k]
  ------------------
 4871|  1.26k|    error = lodepng_add_text_sized(info, key, (char*)str, size);
 4872|  1.26k|    break;
 4873|  1.34k|  }
 4874|       |
 4875|  1.40k|  lodepng_free(key);
 4876|  1.40k|  lodepng_free(str);
 4877|       |
 4878|  1.40k|  return error;
 4879|  1.40k|}
lodepng.cpp:_ZL14readChunk_iTXtP11LodePNGInfoPK22LodePNGDecoderSettingsPKhm:
 4883|  84.3k|                               const unsigned char* data, size_t chunkLength) {
 4884|  84.3k|  unsigned error = 0;
 4885|  84.3k|  unsigned i;
 4886|       |
 4887|       |  /*copy the object to change parameters in it*/
 4888|  84.3k|  LodePNGDecompressSettings zlibsettings = decoder->zlibsettings;
 4889|       |
 4890|  84.3k|  unsigned length, begin, compressed;
 4891|  84.3k|  char *key = 0, *langtag = 0, *transkey = 0;
 4892|       |
 4893|  84.3k|  while(!error) /*not really a while loop, only used to break on error*/ {
  ------------------
  |  Branch (4893:9): [True: 84.3k, False: 0]
  ------------------
 4894|       |    /*Quick check if the chunk length isn't too small. Even without check
 4895|       |    it'd still fail with other error checks below if it's too short. This just gives a different error code.*/
 4896|  84.3k|    if(chunkLength < 5) CERROR_BREAK(error, 30); /*iTXt chunk too short*/
  ------------------
  |  |  179|      5|#define CERROR_BREAK(errorvar, code){\
  |  |  180|      5|  errorvar = code;\
  |  |  181|      5|  break;\
  |  |  182|      5|}
  ------------------
  |  Branch (4896:8): [True: 5, False: 84.3k]
  ------------------
 4897|       |
 4898|       |    /*read the key*/
 4899|  1.74M|    for(length = 0; length < chunkLength && data[length] != 0; ++length) ;
  ------------------
  |  Branch (4899:21): [True: 1.74M, False: 9]
  |  Branch (4899:45): [True: 1.66M, False: 84.3k]
  ------------------
 4900|  84.3k|    if(length + 3 >= chunkLength) CERROR_BREAK(error, 75); /*no null termination char, corrupt?*/
  ------------------
  |  |  179|     11|#define CERROR_BREAK(errorvar, code){\
  |  |  180|     11|  errorvar = code;\
  |  |  181|     11|  break;\
  |  |  182|     11|}
  ------------------
  |  Branch (4900:8): [True: 11, False: 84.3k]
  ------------------
 4901|  84.3k|    if(length < 1 || length > 79) CERROR_BREAK(error, 89); /*keyword too short or long*/
  ------------------
  |  |  179|     32|#define CERROR_BREAK(errorvar, code){\
  |  |  180|     32|  errorvar = code;\
  |  |  181|     32|  break;\
  |  |  182|     32|}
  ------------------
  |  Branch (4901:8): [True: 3, False: 84.3k]
  |  Branch (4901:22): [True: 29, False: 84.2k]
  ------------------
 4902|       |
 4903|  84.2k|    key = (char*)lodepng_malloc(length + 1);
 4904|  84.2k|    if(!key) CERROR_BREAK(error, 83); /*alloc fail*/
  ------------------
  |  |  179|      0|#define CERROR_BREAK(errorvar, code){\
  |  |  180|      0|  errorvar = code;\
  |  |  181|      0|  break;\
  |  |  182|      0|}
  ------------------
  |  Branch (4904:8): [True: 0, False: 84.2k]
  ------------------
 4905|       |
 4906|  84.2k|    lodepng_memcpy(key, data, length);
 4907|  84.2k|    key[length] = 0;
 4908|       |
 4909|       |    /*read the compression method*/
 4910|  84.2k|    compressed = data[length + 1];
 4911|  84.2k|    if(data[length + 2] != 0) CERROR_BREAK(error, 72); /*the 0 byte indicating compression must be 0*/
  ------------------
  |  |  179|     16|#define CERROR_BREAK(errorvar, code){\
  |  |  180|     16|  errorvar = code;\
  |  |  181|     16|  break;\
  |  |  182|     16|}
  ------------------
  |  Branch (4911:8): [True: 16, False: 84.2k]
  ------------------
 4912|       |
 4913|       |    /*even though it's not allowed by the standard, no error is thrown if
 4914|       |    there's no null termination char, if the text is empty for the next 3 texts*/
 4915|       |
 4916|       |    /*read the langtag*/
 4917|  84.2k|    begin = length + 3;
 4918|  84.2k|    length = 0;
 4919|   824k|    for(i = begin; i < chunkLength && data[i] != 0; ++i) ++length;
  ------------------
  |  Branch (4919:20): [True: 823k, False: 657]
  |  Branch (4919:39): [True: 739k, False: 83.6k]
  ------------------
 4920|       |
 4921|  84.2k|    langtag = (char*)lodepng_malloc(length + 1);
 4922|  84.2k|    if(!langtag) CERROR_BREAK(error, 83); /*alloc fail*/
  ------------------
  |  |  179|      0|#define CERROR_BREAK(errorvar, code){\
  |  |  180|      0|  errorvar = code;\
  |  |  181|      0|  break;\
  |  |  182|      0|}
  ------------------
  |  Branch (4922:8): [True: 0, False: 84.2k]
  ------------------
 4923|       |
 4924|  84.2k|    lodepng_memcpy(langtag, data + begin, length);
 4925|  84.2k|    langtag[length] = 0;
 4926|       |
 4927|       |    /*read the transkey*/
 4928|  84.2k|    begin += length + 1;
 4929|  84.2k|    length = 0;
 4930|  2.44M|    for(i = begin; i < chunkLength && data[i] != 0; ++i) ++length;
  ------------------
  |  Branch (4930:20): [True: 2.43M, False: 9.64k]
  |  Branch (4930:39): [True: 2.35M, False: 74.6k]
  ------------------
 4931|       |
 4932|  84.2k|    transkey = (char*)lodepng_malloc(length + 1);
 4933|  84.2k|    if(!transkey) CERROR_BREAK(error, 83); /*alloc fail*/
  ------------------
  |  |  179|      0|#define CERROR_BREAK(errorvar, code){\
  |  |  180|      0|  errorvar = code;\
  |  |  181|      0|  break;\
  |  |  182|      0|}
  ------------------
  |  Branch (4933:8): [True: 0, False: 84.2k]
  ------------------
 4934|       |
 4935|  84.2k|    lodepng_memcpy(transkey, data + begin, length);
 4936|  84.2k|    transkey[length] = 0;
 4937|       |
 4938|       |    /*read the actual text*/
 4939|  84.2k|    begin += length + 1;
 4940|       |
 4941|  84.2k|    length = (unsigned)chunkLength < begin ? 0 : (unsigned)chunkLength - begin;
  ------------------
  |  Branch (4941:14): [True: 9.64k, False: 74.6k]
  ------------------
 4942|       |
 4943|  84.2k|    if(compressed) {
  ------------------
  |  Branch (4943:8): [True: 349, False: 83.9k]
  ------------------
 4944|    349|      unsigned char* str = 0;
 4945|    349|      size_t size = 0;
 4946|    349|      zlibsettings.max_output_size = decoder->max_text_size;
 4947|       |      /*will fail if zlib error, e.g. if length is too small*/
 4948|    349|      error = zlib_decompress(&str, &size, 0, &data[begin],
 4949|    349|                              length, &zlibsettings);
 4950|       |      /*error: compressed text larger than  decoder->max_text_size*/
 4951|    349|      if(error && size > zlibsettings.max_output_size) error = 112;
  ------------------
  |  Branch (4951:10): [True: 62, False: 287]
  |  Branch (4951:19): [True: 16, False: 46]
  ------------------
 4952|    349|      if(!error) error = lodepng_add_itext_sized(info, key, langtag, transkey, (char*)str, size);
  ------------------
  |  Branch (4952:10): [True: 287, False: 62]
  ------------------
 4953|    349|      lodepng_free(str);
 4954|  83.9k|    } else {
 4955|  83.9k|      error = lodepng_add_itext_sized(info, key, langtag, transkey, (char*)(data + begin), length);
 4956|  83.9k|    }
 4957|       |
 4958|  84.2k|    break;
 4959|  84.2k|  }
 4960|       |
 4961|  84.3k|  lodepng_free(key);
 4962|  84.3k|  lodepng_free(langtag);
 4963|  84.3k|  lodepng_free(transkey);
 4964|       |
 4965|  84.3k|  return error;
 4966|  84.3k|}
lodepng.cpp:_ZL14readChunk_tIMEP11LodePNGInfoPKhm:
 4968|     83|static unsigned readChunk_tIME(LodePNGInfo* info, const unsigned char* data, size_t chunkLength) {
 4969|     83|  if(chunkLength != 7) return 73; /*invalid tIME chunk size*/
  ------------------
  |  Branch (4969:6): [True: 10, False: 73]
  ------------------
 4970|       |
 4971|     73|  info->time_defined = 1;
 4972|     73|  info->time.year = 256u * data[0] + data[1];
 4973|     73|  info->time.month = data[2];
 4974|     73|  info->time.day = data[3];
 4975|     73|  info->time.hour = data[4];
 4976|     73|  info->time.minute = data[5];
 4977|     73|  info->time.second = data[6];
 4978|       |
 4979|     73|  return 0; /* OK */
 4980|     83|}
lodepng.cpp:_ZL14readChunk_pHYsP11LodePNGInfoPKhm:
 4982|    218|static unsigned readChunk_pHYs(LodePNGInfo* info, const unsigned char* data, size_t chunkLength) {
 4983|    218|  if(chunkLength != 9) return 74; /*invalid pHYs chunk size*/
  ------------------
  |  Branch (4983:6): [True: 15, False: 203]
  ------------------
 4984|       |
 4985|    203|  info->phys_defined = 1;
 4986|    203|  info->phys_x = 16777216u * data[0] + 65536u * data[1] + 256u * data[2] + data[3];
 4987|    203|  info->phys_y = 16777216u * data[4] + 65536u * data[5] + 256u * data[6] + data[7];
 4988|    203|  info->phys_unit = data[8];
 4989|       |
 4990|    203|  return 0; /* OK */
 4991|    218|}
lodepng.cpp:_ZL14readChunk_gAMAP11LodePNGInfoPKhm:
 4993|    206|static unsigned readChunk_gAMA(LodePNGInfo* info, const unsigned char* data, size_t chunkLength) {
 4994|    206|  if(chunkLength != 4) return 96; /*invalid gAMA chunk size*/
  ------------------
  |  Branch (4994:6): [True: 4, False: 202]
  ------------------
 4995|       |
 4996|    202|  info->gama_defined = 1;
 4997|    202|  info->gama_gamma = 16777216u * data[0] + 65536u * data[1] + 256u * data[2] + data[3];
 4998|       |
 4999|    202|  return 0; /* OK */
 5000|    206|}
lodepng.cpp:_ZL14readChunk_cHRMP11LodePNGInfoPKhm:
 5002|     72|static unsigned readChunk_cHRM(LodePNGInfo* info, const unsigned char* data, size_t chunkLength) {
 5003|     72|  if(chunkLength != 32) return 97; /*invalid cHRM chunk size*/
  ------------------
  |  Branch (5003:6): [True: 7, False: 65]
  ------------------
 5004|       |
 5005|     65|  info->chrm_defined = 1;
 5006|     65|  info->chrm_white_x = 16777216u * data[ 0] + 65536u * data[ 1] + 256u * data[ 2] + data[ 3];
 5007|     65|  info->chrm_white_y = 16777216u * data[ 4] + 65536u * data[ 5] + 256u * data[ 6] + data[ 7];
 5008|     65|  info->chrm_red_x   = 16777216u * data[ 8] + 65536u * data[ 9] + 256u * data[10] + data[11];
 5009|     65|  info->chrm_red_y   = 16777216u * data[12] + 65536u * data[13] + 256u * data[14] + data[15];
 5010|     65|  info->chrm_green_x = 16777216u * data[16] + 65536u * data[17] + 256u * data[18] + data[19];
 5011|     65|  info->chrm_green_y = 16777216u * data[20] + 65536u * data[21] + 256u * data[22] + data[23];
 5012|     65|  info->chrm_blue_x  = 16777216u * data[24] + 65536u * data[25] + 256u * data[26] + data[27];
 5013|     65|  info->chrm_blue_y  = 16777216u * data[28] + 65536u * data[29] + 256u * data[30] + data[31];
 5014|       |
 5015|     65|  return 0; /* OK */
 5016|     72|}
lodepng.cpp:_ZL14readChunk_sRGBP11LodePNGInfoPKhm:
 5018|    206|static unsigned readChunk_sRGB(LodePNGInfo* info, const unsigned char* data, size_t chunkLength) {
 5019|    206|  if(chunkLength != 1) return 98; /*invalid sRGB chunk size (this one is never ignored)*/
  ------------------
  |  Branch (5019:6): [True: 5, False: 201]
  ------------------
 5020|       |
 5021|    201|  info->srgb_defined = 1;
 5022|    201|  info->srgb_intent = data[0];
 5023|       |
 5024|    201|  return 0; /* OK */
 5025|    206|}
lodepng.cpp:_ZL14readChunk_iCCPP11LodePNGInfoPK22LodePNGDecoderSettingsPKhm:
 5028|    979|                               const unsigned char* data, size_t chunkLength) {
 5029|    979|  unsigned error = 0;
 5030|    979|  unsigned i;
 5031|    979|  size_t size = 0;
 5032|       |  /*copy the object to change parameters in it*/
 5033|    979|  LodePNGDecompressSettings zlibsettings = decoder->zlibsettings;
 5034|       |
 5035|    979|  unsigned length, string2_begin;
 5036|       |
 5037|    979|  info->iccp_defined = 1;
 5038|    979|  if(info->iccp_name) lodepng_clear_icc(info);
  ------------------
  |  Branch (5038:6): [True: 633, False: 346]
  ------------------
 5039|       |
 5040|  1.78M|  for(length = 0; length < chunkLength && data[length] != 0; ++length) ;
  ------------------
  |  Branch (5040:19): [True: 1.78M, False: 19]
  |  Branch (5040:43): [True: 1.78M, False: 960]
  ------------------
 5041|    979|  if(length + 2 >= chunkLength) return 75; /*no null termination, corrupt?*/
  ------------------
  |  Branch (5041:6): [True: 25, False: 954]
  ------------------
 5042|    954|  if(length < 1 || length > 79) return 89; /*keyword too short or long*/
  ------------------
  |  Branch (5042:6): [True: 2, False: 952]
  |  Branch (5042:20): [True: 22, False: 930]
  ------------------
 5043|       |
 5044|    930|  info->iccp_name = (char*)lodepng_malloc(length + 1);
 5045|    930|  if(!info->iccp_name) return 83; /*alloc fail*/
  ------------------
  |  Branch (5045:6): [True: 0, False: 930]
  ------------------
 5046|       |
 5047|    930|  info->iccp_name[length] = 0;
 5048|  3.91k|  for(i = 0; i != length; ++i) info->iccp_name[i] = (char)data[i];
  ------------------
  |  Branch (5048:14): [True: 2.98k, False: 930]
  ------------------
 5049|       |
 5050|    930|  if(data[length + 1] != 0) return 72; /*the 0 byte indicating compression must be 0*/
  ------------------
  |  Branch (5050:6): [True: 18, False: 912]
  ------------------
 5051|       |
 5052|    912|  string2_begin = length + 2;
 5053|    912|  if(string2_begin > chunkLength) return 75; /*no null termination, corrupt?*/
  ------------------
  |  Branch (5053:6): [True: 0, False: 912]
  ------------------
 5054|       |
 5055|    912|  length = (unsigned)chunkLength - string2_begin;
 5056|    912|  zlibsettings.max_output_size = decoder->max_icc_size;
 5057|    912|  error = zlib_decompress(&info->iccp_profile, &size, 0,
 5058|    912|                          &data[string2_begin],
 5059|    912|                          length, &zlibsettings);
 5060|       |  /*error: ICC profile larger than  decoder->max_icc_size*/
 5061|    912|  if(error && size > zlibsettings.max_output_size) error = 113;
  ------------------
  |  Branch (5061:6): [True: 145, False: 767]
  |  Branch (5061:15): [True: 18, False: 127]
  ------------------
 5062|    912|  info->iccp_profile_size = size;
 5063|    912|  if(!error && !info->iccp_profile_size) error = 100; /*invalid ICC profile size*/
  ------------------
  |  Branch (5063:6): [True: 767, False: 145]
  |  Branch (5063:16): [True: 1, False: 766]
  ------------------
 5064|    912|  return error;
 5065|    912|}
lodepng.cpp:_ZL14readChunk_sBITP11LodePNGInfoPKhm:
 5068|    618|static unsigned readChunk_sBIT(LodePNGInfo* info, const unsigned char* data, size_t chunkLength) {
 5069|    618|  unsigned bitdepth = (info->color.colortype == LCT_PALETTE) ? 8 : info->color.bitdepth;
  ------------------
  |  Branch (5069:23): [True: 87, False: 531]
  ------------------
 5070|    618|  if(info->color.colortype == LCT_GREY) {
  ------------------
  |  Branch (5070:6): [True: 99, False: 519]
  ------------------
 5071|       |    /*error: this chunk must be 1 bytes for grayscale image*/
 5072|     99|    if(chunkLength != 1) return 114;
  ------------------
  |  Branch (5072:8): [True: 15, False: 84]
  ------------------
 5073|     84|    if(data[0] == 0 || data[0] > bitdepth) return 115;
  ------------------
  |  Branch (5073:8): [True: 1, False: 83]
  |  Branch (5073:24): [True: 7, False: 76]
  ------------------
 5074|     76|    info->sbit_defined = 1;
 5075|     76|    info->sbit_r = info->sbit_g = info->sbit_b = data[0]; /*setting g and b is not required, but sensible*/
 5076|    519|  } else if(info->color.colortype == LCT_RGB || info->color.colortype == LCT_PALETTE) {
  ------------------
  |  Branch (5076:13): [True: 82, False: 437]
  |  Branch (5076:49): [True: 87, False: 350]
  ------------------
 5077|       |    /*error: this chunk must be 3 bytes for RGB and palette image*/
 5078|    169|    if(chunkLength != 3) return 114;
  ------------------
  |  Branch (5078:8): [True: 9, False: 160]
  ------------------
 5079|    160|    if(data[0] == 0 || data[1] == 0 || data[2] == 0) return 115;
  ------------------
  |  Branch (5079:8): [True: 1, False: 159]
  |  Branch (5079:24): [True: 1, False: 158]
  |  Branch (5079:40): [True: 2, False: 156]
  ------------------
 5080|    156|    if(data[0] > bitdepth || data[1] > bitdepth || data[2] > bitdepth) return 115;
  ------------------
  |  Branch (5080:8): [True: 8, False: 148]
  |  Branch (5080:30): [True: 9, False: 139]
  |  Branch (5080:52): [True: 5, False: 134]
  ------------------
 5081|    134|    info->sbit_defined = 1;
 5082|    134|    info->sbit_r = data[0];
 5083|    134|    info->sbit_g = data[1];
 5084|    134|    info->sbit_b = data[2];
 5085|    350|  } else if(info->color.colortype == LCT_GREY_ALPHA) {
  ------------------
  |  Branch (5085:13): [True: 103, False: 247]
  ------------------
 5086|       |    /*error: this chunk must be 2 byte for grayscale with alpha image*/
 5087|    103|    if(chunkLength != 2) return 114;
  ------------------
  |  Branch (5087:8): [True: 10, False: 93]
  ------------------
 5088|     93|    if(data[0] == 0 || data[1] == 0) return 115;
  ------------------
  |  Branch (5088:8): [True: 1, False: 92]
  |  Branch (5088:24): [True: 1, False: 91]
  ------------------
 5089|     91|    if(data[0] > bitdepth || data[1] > bitdepth) return 115;
  ------------------
  |  Branch (5089:8): [True: 6, False: 85]
  |  Branch (5089:30): [True: 7, False: 78]
  ------------------
 5090|     78|    info->sbit_defined = 1;
 5091|     78|    info->sbit_r = info->sbit_g = info->sbit_b = data[0]; /*setting g and b is not required, but sensible*/
 5092|     78|    info->sbit_a = data[1];
 5093|    247|  } else if(info->color.colortype == LCT_RGBA) {
  ------------------
  |  Branch (5093:13): [True: 247, False: 0]
  ------------------
 5094|       |    /*error: this chunk must be 4 bytes for grayscale image*/
 5095|    247|    if(chunkLength != 4) return 114;
  ------------------
  |  Branch (5095:8): [True: 13, False: 234]
  ------------------
 5096|    234|    if(data[0] == 0 || data[1] == 0 || data[2] == 0 || data[3] == 0) return 115;
  ------------------
  |  Branch (5096:8): [True: 1, False: 233]
  |  Branch (5096:24): [True: 1, False: 232]
  |  Branch (5096:40): [True: 2, False: 230]
  |  Branch (5096:56): [True: 1, False: 229]
  ------------------
 5097|    229|    if(data[0] > bitdepth || data[1] > bitdepth || data[2] > bitdepth || data[3] > bitdepth) return 115;
  ------------------
  |  Branch (5097:8): [True: 6, False: 223]
  |  Branch (5097:30): [True: 8, False: 215]
  |  Branch (5097:52): [True: 3, False: 212]
  |  Branch (5097:74): [True: 6, False: 206]
  ------------------
 5098|    206|    info->sbit_defined = 1;
 5099|    206|    info->sbit_r = data[0];
 5100|    206|    info->sbit_g = data[1];
 5101|    206|    info->sbit_b = data[2];
 5102|    206|    info->sbit_a = data[3];
 5103|    206|  }
 5104|       |
 5105|    494|  return 0; /* OK */
 5106|    618|}
lodepng.cpp:_ZL13decodeGenericPPhPjS1_P12LodePNGStatePKhm:
 5166|  7.63k|                          const unsigned char* in, size_t insize) {
 5167|  7.63k|  unsigned char IEND = 0;
 5168|  7.63k|  const unsigned char* chunk; /*points to beginning of next chunk*/
 5169|  7.63k|  unsigned char* idat; /*the data from idat chunks, zlib compressed*/
 5170|  7.63k|  size_t idatsize = 0;
 5171|  7.63k|  unsigned char* scanlines = 0;
 5172|  7.63k|  size_t scanlines_size = 0, expected_size = 0;
 5173|  7.63k|  size_t outsize = 0;
 5174|       |
 5175|       |  /*for unknown chunk order*/
 5176|  7.63k|  unsigned unknown = 0;
 5177|  7.63k|#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
 5178|  7.63k|  unsigned critical_pos = 1; /*1 = after IHDR, 2 = after PLTE, 3 = after IDAT*/
 5179|  7.63k|#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
 5180|       |
 5181|       |
 5182|       |  /* safe output values in case error happens */
 5183|  7.63k|  *out = 0;
 5184|  7.63k|  *w = *h = 0;
 5185|       |
 5186|  7.63k|  state->error = lodepng_inspect(w, h, state, in, insize); /*reads header and resets other parameters in state->info_png*/
 5187|  7.63k|  if(state->error) return;
  ------------------
  |  Branch (5187:6): [True: 284, False: 7.35k]
  ------------------
 5188|       |
 5189|  7.35k|  if(lodepng_pixel_overflow(*w, *h, &state->info_png.color, &state->info_raw)) {
  ------------------
  |  Branch (5189:6): [True: 59, False: 7.29k]
  ------------------
 5190|     59|    CERROR_RETURN(state->error, 92); /*overflow possible due to amount of pixels*/
  ------------------
  |  |  200|     59|#define CERROR_RETURN(errorvar, code){\
  |  |  201|     59|  errorvar = code;\
  |  |  202|     59|  return;\
  |  |  203|     59|}
  ------------------
 5191|      0|  }
 5192|       |
 5193|       |  /*the input filesize is a safe upper bound for the sum of idat chunks size*/
 5194|  7.29k|  idat = (unsigned char*)lodepng_malloc(insize);
 5195|  7.29k|  if(!idat) CERROR_RETURN(state->error, 83); /*alloc fail*/
  ------------------
  |  |  200|      0|#define CERROR_RETURN(errorvar, code){\
  |  |  201|      0|  errorvar = code;\
  |  |  202|      0|  return;\
  |  |  203|      0|}
  ------------------
  |  Branch (5195:6): [True: 0, False: 7.29k]
  ------------------
 5196|       |
 5197|  7.29k|  chunk = &in[33]; /*first byte of the first chunk after the header*/
 5198|       |
 5199|       |  /*loop through the chunks, ignoring unknown chunks and stopping at IEND chunk.
 5200|       |  IDAT data is put at the start of the in buffer*/
 5201|   219k|  while(!IEND && !state->error) {
  ------------------
  |  Branch (5201:9): [True: 219k, False: 7]
  |  Branch (5201:18): [True: 219k, False: 0]
  ------------------
 5202|   219k|    unsigned chunkLength;
 5203|   219k|    const unsigned char* data; /*the data in the chunk*/
 5204|   219k|    size_t pos = (size_t)(chunk - in);
 5205|       |
 5206|       |    /*error: next chunk out of bounds of the in buffer*/
 5207|   219k|    if(chunk < in || pos + 12 > insize) {
  ------------------
  |  Branch (5207:8): [True: 0, False: 219k]
  |  Branch (5207:22): [True: 6.28k, False: 213k]
  ------------------
 5208|  6.28k|      if(state->decoder.ignore_end) break; /*other errors may still happen though*/
  ------------------
  |  Branch (5208:10): [True: 6.28k, False: 0]
  ------------------
 5209|  6.28k|      CERROR_BREAK(state->error, 30);
  ------------------
  |  |  179|      0|#define CERROR_BREAK(errorvar, code){\
  |  |  180|      0|  errorvar = code;\
  |  |  181|      0|  break;\
  |  |  182|      0|}
  ------------------
 5210|      0|    }
 5211|       |
 5212|       |    /*length of the data of the chunk, excluding the 12 bytes for length, chunk type and CRC*/
 5213|   213k|    chunkLength = lodepng_chunk_length(chunk);
 5214|       |    /*error: chunk length larger than the max PNG chunk size*/
 5215|   213k|    if(chunkLength > 2147483647) {
  ------------------
  |  Branch (5215:8): [True: 101, False: 213k]
  ------------------
 5216|    101|      if(state->decoder.ignore_end) break; /*other errors may still happen though*/
  ------------------
  |  Branch (5216:10): [True: 101, False: 0]
  ------------------
 5217|    101|      CERROR_BREAK(state->error, 63);
  ------------------
  |  |  179|      0|#define CERROR_BREAK(errorvar, code){\
  |  |  180|      0|  errorvar = code;\
  |  |  181|      0|  break;\
  |  |  182|      0|}
  ------------------
 5218|      0|    }
 5219|       |
 5220|   213k|    if(pos + (size_t)chunkLength + 12 > insize || pos + (size_t)chunkLength + 12 < pos) {
  ------------------
  |  Branch (5220:8): [True: 93, False: 213k]
  |  Branch (5220:51): [True: 0, False: 213k]
  ------------------
 5221|     93|      CERROR_BREAK(state->error, 64); /*error: size of the in buffer too small to contain next chunk (or int overflow)*/
  ------------------
  |  |  179|     93|#define CERROR_BREAK(errorvar, code){\
  |  |  180|     93|  errorvar = code;\
  |  |  181|     93|  break;\
  |  |  182|     93|}
  ------------------
 5222|      0|    }
 5223|       |
 5224|   213k|    data = lodepng_chunk_data_const(chunk);
 5225|       |
 5226|   213k|    unknown = 0;
 5227|       |
 5228|       |    /*IDAT chunk, containing compressed image data*/
 5229|   213k|    if(lodepng_chunk_type_equals(chunk, "IDAT")) {
  ------------------
  |  Branch (5229:8): [True: 9.09k, False: 204k]
  ------------------
 5230|  9.09k|      size_t newsize;
 5231|  9.09k|      if(lodepng_addofl(idatsize, chunkLength, &newsize)) CERROR_BREAK(state->error, 95);
  ------------------
  |  |  179|      0|#define CERROR_BREAK(errorvar, code){\
  |  |  180|      0|  errorvar = code;\
  |  |  181|      0|  break;\
  |  |  182|      0|}
  ------------------
  |  Branch (5231:10): [True: 0, False: 9.09k]
  ------------------
 5232|  9.09k|      if(newsize > insize) CERROR_BREAK(state->error, 95);
  ------------------
  |  |  179|      0|#define CERROR_BREAK(errorvar, code){\
  |  |  180|      0|  errorvar = code;\
  |  |  181|      0|  break;\
  |  |  182|      0|}
  ------------------
  |  Branch (5232:10): [True: 0, False: 9.09k]
  ------------------
 5233|  9.09k|      lodepng_memcpy(idat + idatsize, data, chunkLength);
 5234|  9.09k|      idatsize += chunkLength;
 5235|  9.09k|#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
 5236|  9.09k|      critical_pos = 3;
 5237|  9.09k|#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
 5238|   204k|    } else if(lodepng_chunk_type_equals(chunk, "IEND")) {
  ------------------
  |  Branch (5238:15): [True: 7, False: 204k]
  ------------------
 5239|       |      /*IEND chunk*/
 5240|      7|      IEND = 1;
 5241|   204k|    } else if(lodepng_chunk_type_equals(chunk, "PLTE")) {
  ------------------
  |  Branch (5241:15): [True: 2.53k, False: 201k]
  ------------------
 5242|       |      /*palette chunk (PLTE)*/
 5243|  2.53k|      state->error = readChunk_PLTE(&state->info_png.color, data, chunkLength);
 5244|  2.53k|      if(state->error) break;
  ------------------
  |  Branch (5244:10): [True: 10, False: 2.52k]
  ------------------
 5245|  2.52k|#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
 5246|  2.52k|      critical_pos = 2;
 5247|  2.52k|#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
 5248|   201k|    } else if(lodepng_chunk_type_equals(chunk, "tRNS")) {
  ------------------
  |  Branch (5248:15): [True: 2.11k, False: 199k]
  ------------------
 5249|       |      /*palette transparency chunk (tRNS). Even though this one is an ancillary chunk , it is still compiled
 5250|       |      in without 'LODEPNG_COMPILE_ANCILLARY_CHUNKS' because it contains essential color information that
 5251|       |      affects the alpha channel of pixels. */
 5252|  2.11k|      state->error = readChunk_tRNS(&state->info_png.color, data, chunkLength);
 5253|  2.11k|      if(state->error) break;
  ------------------
  |  Branch (5253:10): [True: 29, False: 2.08k]
  ------------------
 5254|  2.11k|#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
 5255|       |      /*background color chunk (bKGD)*/
 5256|   199k|    } else if(lodepng_chunk_type_equals(chunk, "bKGD")) {
  ------------------
  |  Branch (5256:15): [True: 1.04k, False: 198k]
  ------------------
 5257|  1.04k|      state->error = readChunk_bKGD(&state->info_png, data, chunkLength);
 5258|  1.04k|      if(state->error) break;
  ------------------
  |  Branch (5258:10): [True: 48, False: 996]
  ------------------
 5259|   198k|    } else if(lodepng_chunk_type_equals(chunk, "tEXt")) {
  ------------------
  |  Branch (5259:15): [True: 96.5k, False: 102k]
  ------------------
 5260|       |      /*text chunk (tEXt)*/
 5261|  96.5k|      if(state->decoder.read_text_chunks) {
  ------------------
  |  Branch (5261:10): [True: 96.5k, False: 0]
  ------------------
 5262|  96.5k|        state->error = readChunk_tEXt(&state->info_png, data, chunkLength);
 5263|  96.5k|        if(state->error) break;
  ------------------
  |  Branch (5263:12): [True: 24, False: 96.5k]
  ------------------
 5264|  96.5k|      }
 5265|   102k|    } else if(lodepng_chunk_type_equals(chunk, "zTXt")) {
  ------------------
  |  Branch (5265:15): [True: 1.40k, False: 100k]
  ------------------
 5266|       |      /*compressed text chunk (zTXt)*/
 5267|  1.40k|      if(state->decoder.read_text_chunks) {
  ------------------
  |  Branch (5267:10): [True: 1.40k, False: 0]
  ------------------
 5268|  1.40k|        state->error = readChunk_zTXt(&state->info_png, &state->decoder, data, chunkLength);
 5269|  1.40k|        if(state->error) break;
  ------------------
  |  Branch (5269:12): [True: 144, False: 1.26k]
  ------------------
 5270|  1.40k|      }
 5271|   100k|    } else if(lodepng_chunk_type_equals(chunk, "iTXt")) {
  ------------------
  |  Branch (5271:15): [True: 84.3k, False: 16.4k]
  ------------------
 5272|       |      /*international text chunk (iTXt)*/
 5273|  84.3k|      if(state->decoder.read_text_chunks) {
  ------------------
  |  Branch (5273:10): [True: 84.3k, False: 0]
  ------------------
 5274|  84.3k|        state->error = readChunk_iTXt(&state->info_png, &state->decoder, data, chunkLength);
 5275|  84.3k|        if(state->error) break;
  ------------------
  |  Branch (5275:12): [True: 126, False: 84.2k]
  ------------------
 5276|  84.3k|      }
 5277|  84.3k|    } else if(lodepng_chunk_type_equals(chunk, "tIME")) {
  ------------------
  |  Branch (5277:15): [True: 83, False: 16.3k]
  ------------------
 5278|     83|      state->error = readChunk_tIME(&state->info_png, data, chunkLength);
 5279|     83|      if(state->error) break;
  ------------------
  |  Branch (5279:10): [True: 10, False: 73]
  ------------------
 5280|  16.3k|    } else if(lodepng_chunk_type_equals(chunk, "pHYs")) {
  ------------------
  |  Branch (5280:15): [True: 218, False: 16.1k]
  ------------------
 5281|    218|      state->error = readChunk_pHYs(&state->info_png, data, chunkLength);
 5282|    218|      if(state->error) break;
  ------------------
  |  Branch (5282:10): [True: 15, False: 203]
  ------------------
 5283|  16.1k|    } else if(lodepng_chunk_type_equals(chunk, "gAMA")) {
  ------------------
  |  Branch (5283:15): [True: 206, False: 15.9k]
  ------------------
 5284|    206|      state->error = readChunk_gAMA(&state->info_png, data, chunkLength);
 5285|    206|      if(state->error) break;
  ------------------
  |  Branch (5285:10): [True: 4, False: 202]
  ------------------
 5286|  15.9k|    } else if(lodepng_chunk_type_equals(chunk, "cHRM")) {
  ------------------
  |  Branch (5286:15): [True: 72, False: 15.8k]
  ------------------
 5287|     72|      state->error = readChunk_cHRM(&state->info_png, data, chunkLength);
 5288|     72|      if(state->error) break;
  ------------------
  |  Branch (5288:10): [True: 7, False: 65]
  ------------------
 5289|  15.8k|    } else if(lodepng_chunk_type_equals(chunk, "sRGB")) {
  ------------------
  |  Branch (5289:15): [True: 206, False: 15.6k]
  ------------------
 5290|    206|      state->error = readChunk_sRGB(&state->info_png, data, chunkLength);
 5291|    206|      if(state->error) break;
  ------------------
  |  Branch (5291:10): [True: 5, False: 201]
  ------------------
 5292|  15.6k|    } else if(lodepng_chunk_type_equals(chunk, "iCCP")) {
  ------------------
  |  Branch (5292:15): [True: 979, False: 14.6k]
  ------------------
 5293|    979|      state->error = readChunk_iCCP(&state->info_png, &state->decoder, data, chunkLength);
 5294|    979|      if(state->error) break;
  ------------------
  |  Branch (5294:10): [True: 213, False: 766]
  ------------------
 5295|  14.6k|    } else if(lodepng_chunk_type_equals(chunk, "sBIT")) {
  ------------------
  |  Branch (5295:15): [True: 618, False: 14.0k]
  ------------------
 5296|    618|      state->error = readChunk_sBIT(&state->info_png, data, chunkLength);
 5297|    618|      if(state->error) break;
  ------------------
  |  Branch (5297:10): [True: 124, False: 494]
  ------------------
 5298|    618|#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
 5299|  14.0k|    } else /*it's not an implemented chunk type, so ignore it: skip over the data*/ {
 5300|       |      /*error: unknown critical chunk (5th bit of first byte of chunk type is 0)*/
 5301|  14.0k|      if(!state->decoder.ignore_critical && !lodepng_chunk_ancillary(chunk)) {
  ------------------
  |  Branch (5301:10): [True: 14.0k, False: 0]
  |  Branch (5301:45): [True: 49, False: 13.9k]
  ------------------
 5302|     49|        CERROR_BREAK(state->error, 69);
  ------------------
  |  |  179|     49|#define CERROR_BREAK(errorvar, code){\
  |  |  180|     49|  errorvar = code;\
  |  |  181|     49|  break;\
  |  |  182|     49|}
  ------------------
 5303|      0|      }
 5304|       |
 5305|  13.9k|      unknown = 1;
 5306|  13.9k|#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
 5307|  13.9k|      if(state->decoder.remember_unknown_chunks) {
  ------------------
  |  Branch (5307:10): [True: 0, False: 13.9k]
  ------------------
 5308|      0|        state->error = lodepng_chunk_append(&state->info_png.unknown_chunks_data[critical_pos - 1],
 5309|      0|                                            &state->info_png.unknown_chunks_size[critical_pos - 1], chunk);
 5310|      0|        if(state->error) break;
  ------------------
  |  Branch (5310:12): [True: 0, False: 0]
  ------------------
 5311|      0|      }
 5312|  13.9k|#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
 5313|  13.9k|    }
 5314|       |
 5315|   212k|    if(!state->decoder.ignore_crc && !unknown) /*check CRC if wanted, only on known chunk types*/ {
  ------------------
  |  Branch (5315:8): [True: 0, False: 212k]
  |  Branch (5315:38): [True: 0, False: 0]
  ------------------
 5316|      0|      if(lodepng_chunk_check_crc(chunk)) CERROR_BREAK(state->error, 57); /*invalid CRC*/
  ------------------
  |  |  179|      0|#define CERROR_BREAK(errorvar, code){\
  |  |  180|      0|  errorvar = code;\
  |  |  181|      0|  break;\
  |  |  182|      0|}
  ------------------
  |  Branch (5316:10): [True: 0, False: 0]
  ------------------
 5317|      0|    }
 5318|       |
 5319|   212k|    if(!IEND) chunk = lodepng_chunk_next_const(chunk, in + insize);
  ------------------
  |  Branch (5319:8): [True: 212k, False: 7]
  ------------------
 5320|   212k|  }
 5321|       |
 5322|  7.29k|  if(!state->error && state->info_png.color.colortype == LCT_PALETTE && !state->info_png.color.palette) {
  ------------------
  |  Branch (5322:6): [True: 6.39k, False: 901]
  |  Branch (5322:23): [True: 451, False: 5.94k]
  |  Branch (5322:73): [True: 28, False: 423]
  ------------------
 5323|     28|    state->error = 106; /* error: PNG file must have PLTE chunk if color type is palette */
 5324|     28|  }
 5325|       |
 5326|  7.29k|  if(!state->error) {
  ------------------
  |  Branch (5326:6): [True: 6.36k, False: 929]
  ------------------
 5327|       |    /*predict output size, to allocate exact size for output buffer to avoid more dynamic allocation.
 5328|       |    If the decompressed size does not match the prediction, the image must be corrupt.*/
 5329|  6.36k|    if(state->info_png.interlace_method == 0) {
  ------------------
  |  Branch (5329:8): [True: 4.86k, False: 1.50k]
  ------------------
 5330|  4.86k|      size_t bpp = lodepng_get_bpp(&state->info_png.color);
 5331|  4.86k|      expected_size = lodepng_get_raw_size_idat(*w, *h, bpp);
 5332|  4.86k|    } else {
 5333|  1.50k|      size_t bpp = lodepng_get_bpp(&state->info_png.color);
 5334|       |      /*Adam-7 interlaced: expected size is the sum of the 7 sub-images sizes*/
 5335|  1.50k|      expected_size = 0;
 5336|  1.50k|      expected_size += lodepng_get_raw_size_idat((*w + 7) >> 3, (*h + 7) >> 3, bpp);
 5337|  1.50k|      if(*w > 4) expected_size += lodepng_get_raw_size_idat((*w + 3) >> 3, (*h + 7) >> 3, bpp);
  ------------------
  |  Branch (5337:10): [True: 620, False: 883]
  ------------------
 5338|  1.50k|      expected_size += lodepng_get_raw_size_idat((*w + 3) >> 2, (*h + 3) >> 3, bpp);
 5339|  1.50k|      if(*w > 2) expected_size += lodepng_get_raw_size_idat((*w + 1) >> 2, (*h + 3) >> 2, bpp);
  ------------------
  |  Branch (5339:10): [True: 792, False: 711]
  ------------------
 5340|  1.50k|      expected_size += lodepng_get_raw_size_idat((*w + 1) >> 1, (*h + 1) >> 2, bpp);
 5341|  1.50k|      if(*w > 1) expected_size += lodepng_get_raw_size_idat((*w + 0) >> 1, (*h + 1) >> 1, bpp);
  ------------------
  |  Branch (5341:10): [True: 903, False: 600]
  ------------------
 5342|  1.50k|      expected_size += lodepng_get_raw_size_idat((*w + 0), (*h + 0) >> 1, bpp);
 5343|  1.50k|    }
 5344|       |
 5345|  6.36k|    state->error = zlib_decompress(&scanlines, &scanlines_size, expected_size, idat, idatsize, &state->decoder.zlibsettings);
 5346|  6.36k|  }
 5347|  7.29k|  if(!state->error && scanlines_size != expected_size) state->error = 91; /*decompressed size doesn't match prediction*/
  ------------------
  |  Branch (5347:6): [True: 5.23k, False: 2.05k]
  |  Branch (5347:23): [True: 111, False: 5.12k]
  ------------------
 5348|  7.29k|  lodepng_free(idat);
 5349|       |
 5350|  7.29k|  if(!state->error) {
  ------------------
  |  Branch (5350:6): [True: 5.12k, False: 2.16k]
  ------------------
 5351|  5.12k|    outsize = lodepng_get_raw_size(*w, *h, &state->info_png.color);
 5352|  5.12k|    *out = (unsigned char*)lodepng_malloc(outsize);
 5353|  5.12k|    if(!*out) state->error = 83; /*alloc fail*/
  ------------------
  |  Branch (5353:8): [True: 0, False: 5.12k]
  ------------------
 5354|  5.12k|  }
 5355|  7.29k|  if(!state->error) {
  ------------------
  |  Branch (5355:6): [True: 5.12k, False: 2.16k]
  ------------------
 5356|  5.12k|    lodepng_memset(*out, 0, outsize);
 5357|  5.12k|    state->error = postProcessScanlines(*out, scanlines, *w, *h, &state->info_png);
 5358|  5.12k|  }
 5359|  7.29k|  lodepng_free(scanlines);
 5360|  7.29k|}
lodepng.cpp:_ZL22lodepng_pixel_overflowjjPK16LodePNGColorModeS1_:
 3093|  7.35k|                                  const LodePNGColorMode* pngcolor, const LodePNGColorMode* rawcolor) {
 3094|  7.35k|  size_t bpp = LODEPNG_MAX(lodepng_get_bpp(pngcolor), lodepng_get_bpp(rawcolor));
  ------------------
  |  |  141|  7.35k|#define LODEPNG_MAX(a, b) (((a) > (b)) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (141:28): [True: 1.91k, False: 5.43k]
  |  |  ------------------
  ------------------
 3095|  7.35k|  size_t numpixels, total;
 3096|  7.35k|  size_t line; /* bytes per line in worst case */
 3097|       |
 3098|  7.35k|  if(lodepng_mulofl((size_t)w, (size_t)h, &numpixels)) return 1;
  ------------------
  |  Branch (3098:6): [True: 0, False: 7.35k]
  ------------------
 3099|  7.35k|  if(lodepng_mulofl(numpixels, 8, &total)) return 1; /* bit pointer with 8-bit color, or 8 bytes per channel color */
  ------------------
  |  Branch (3099:6): [True: 43, False: 7.30k]
  ------------------
 3100|       |
 3101|       |  /* Bytes per scanline with the expression "(w / 8u) * bpp) + ((w & 7u) * bpp + 7u) / 8u" */
 3102|  7.30k|  if(lodepng_mulofl((size_t)(w / 8u), bpp, &line)) return 1;
  ------------------
  |  Branch (3102:6): [True: 0, False: 7.30k]
  ------------------
 3103|  7.30k|  if(lodepng_addofl(line, ((w & 7u) * bpp + 7u) / 8u, &line)) return 1;
  ------------------
  |  Branch (3103:6): [True: 0, False: 7.30k]
  ------------------
 3104|       |
 3105|  7.30k|  if(lodepng_addofl(line, 5, &line)) return 1; /* 5 bytes overhead per line: 1 filterbyte, 4 for Adam7 worst case */
  ------------------
  |  Branch (3105:6): [True: 0, False: 7.30k]
  ------------------
 3106|  7.30k|  if(lodepng_mulofl(line, h, &total)) return 1; /* Total bytes in worst case */
  ------------------
  |  Branch (3106:6): [True: 16, False: 7.29k]
  ------------------
 3107|       |
 3108|  7.29k|  return 0; /* no overflow */
 3109|  7.30k|}
lodepng.cpp:_ZL25lodepng_get_raw_size_idatjjj:
 3076|  25.5k|static size_t lodepng_get_raw_size_idat(unsigned w, unsigned h, unsigned bpp) {
 3077|       |  /* + 1 for the filter byte, and possibly plus padding bits per line. */
 3078|       |  /* Ignoring casts, the expression is equal to (w * bpp + 7) / 8 + 1, but avoids overflow of w * bpp */
 3079|  25.5k|  size_t line = ((size_t)(w / 8u) * bpp) + 1u + ((w & 7u) * bpp + 7u) / 8u;
 3080|  25.5k|  return (size_t)h * line;
 3081|  25.5k|}
lodepng.cpp:_ZL20postProcessScanlinesPhS_jjPK11LodePNGInfo:
 4671|  5.12k|                                     unsigned w, unsigned h, const LodePNGInfo* info_png) {
 4672|       |  /*
 4673|       |  This function converts the filtered-padded-interlaced data into pure 2D image buffer with the PNG's colortype.
 4674|       |  Steps:
 4675|       |  *) if no Adam7: 1) unfilter 2) remove padding bits (= possible extra bits per scanline if bpp < 8)
 4676|       |  *) if adam7: 1) 7x unfilter 2) 7x remove padding bits 3) Adam7_deinterlace
 4677|       |  NOTE: the in buffer will be overwritten with intermediate data!
 4678|       |  */
 4679|  5.12k|  unsigned bpp = lodepng_get_bpp(&info_png->color);
 4680|  5.12k|  if(bpp == 0) return 31; /*error: invalid colortype*/
  ------------------
  |  Branch (4680:6): [True: 0, False: 5.12k]
  ------------------
 4681|       |
 4682|  5.12k|  if(info_png->interlace_method == 0) {
  ------------------
  |  Branch (4682:6): [True: 3.90k, False: 1.22k]
  ------------------
 4683|  3.90k|    if(bpp < 8 && w * bpp != ((w * bpp + 7u) / 8u) * 8u) {
  ------------------
  |  Branch (4683:8): [True: 952, False: 2.94k]
  |  Branch (4683:19): [True: 691, False: 261]
  ------------------
 4684|    691|      CERROR_TRY_RETURN(unfilter(in, in, w, h, bpp));
  ------------------
  |  |  194|    691|#define CERROR_TRY_RETURN(call){\
  |  |  195|    691|  unsigned error = call;\
  |  |  196|    691|  if(error) return error;\
  |  |  ------------------
  |  |  |  Branch (196:6): [True: 7, False: 684]
  |  |  ------------------
  |  |  197|    691|}
  ------------------
 4685|    684|      removePaddingBits(out, in, w * bpp, ((w * bpp + 7u) / 8u) * 8u, h);
 4686|    684|    }
 4687|       |    /*we can immediately filter into the out buffer, no other steps needed*/
 4688|  3.73k|    else CERROR_TRY_RETURN(unfilter(out, in, w, h, bpp));
  ------------------
  |  |  194|  3.21k|#define CERROR_TRY_RETURN(call){\
  |  |  195|  3.21k|  unsigned error = call;\
  |  |  196|  3.21k|  if(error) return error;\
  |  |  ------------------
  |  |  |  Branch (196:6): [True: 156, False: 3.05k]
  |  |  ------------------
  |  |  197|  3.21k|}
  ------------------
 4689|  3.73k|  } else /*interlace_method is 1 (Adam7)*/ {
 4690|  1.22k|    unsigned passw[7], passh[7]; size_t filter_passstart[8], padded_passstart[8], passstart[8];
 4691|  1.22k|    unsigned i;
 4692|       |
 4693|  1.22k|    Adam7_getpassvalues(passw, passh, filter_passstart, padded_passstart, passstart, w, h, bpp);
 4694|       |
 4695|  9.64k|    for(i = 0; i != 7; ++i) {
  ------------------
  |  Branch (4695:16): [True: 8.46k, False: 1.17k]
  ------------------
 4696|  8.46k|      CERROR_TRY_RETURN(unfilter(&in[padded_passstart[i]], &in[filter_passstart[i]], passw[i], passh[i], bpp));
  ------------------
  |  |  194|  8.46k|#define CERROR_TRY_RETURN(call){\
  |  |  195|  8.46k|  unsigned error = call;\
  |  |  196|  8.46k|  if(error) return error;\
  |  |  ------------------
  |  |  |  Branch (196:6): [True: 48, False: 8.41k]
  |  |  ------------------
  |  |  197|  8.46k|}
  ------------------
 4697|       |      /*TODO: possible efficiency improvement: if in this reduced image the bits fit nicely in 1 scanline,
 4698|       |      move bytes instead of bits or move not at all*/
 4699|  8.41k|      if(bpp < 8) {
  ------------------
  |  Branch (4699:10): [True: 1.70k, False: 6.71k]
  ------------------
 4700|       |        /*remove padding bits in scanlines; after this there still may be padding
 4701|       |        bits between the different reduced images: each reduced image still starts nicely at a byte*/
 4702|  1.70k|        removePaddingBits(&in[passstart[i]], &in[padded_passstart[i]], passw[i] * bpp,
 4703|  1.70k|                          ((passw[i] * bpp + 7u) / 8u) * 8u, passh[i]);
 4704|  1.70k|      }
 4705|  8.41k|    }
 4706|       |
 4707|  1.17k|    Adam7_deinterlace(out, in, w, h, bpp);
 4708|  1.17k|  }
 4709|       |
 4710|  4.91k|  return 0;
 4711|  5.12k|}
lodepng.cpp:_ZL8unfilterPhPKhjjj:
 4562|  12.3k|static unsigned unfilter(unsigned char* out, const unsigned char* in, unsigned w, unsigned h, unsigned bpp) {
 4563|       |  /*
 4564|       |  For PNG filter method 0
 4565|       |  this function unfilters a single image (e.g. without interlacing this is called once, with Adam7 seven times)
 4566|       |  out must have enough bytes allocated already, in must have the scanlines + 1 filtertype byte per scanline
 4567|       |  w and h are image dimensions or dimensions of reduced image, bpp is bits per pixel
 4568|       |  in and out are allowed to be the same memory address (but aren't the same size since in has the extra filter bytes)
 4569|       |  */
 4570|       |
 4571|  12.3k|  unsigned y;
 4572|  12.3k|  unsigned char* prevline = 0;
 4573|       |
 4574|       |  /*bytewidth is used for filtering, is 1 when bpp < 8, number of bytes per pixel otherwise*/
 4575|  12.3k|  size_t bytewidth = (bpp + 7u) / 8u;
 4576|       |  /*the width of a scanline in bytes, not including the filter type*/
 4577|  12.3k|  size_t linebytes = lodepng_get_raw_size_idat(w, 1, bpp) - 1u;
 4578|       |
 4579|  79.8k|  for(y = 0; y < h; ++y) {
  ------------------
  |  Branch (4579:14): [True: 67.7k, False: 12.1k]
  ------------------
 4580|  67.7k|    size_t outindex = linebytes * y;
 4581|  67.7k|    size_t inindex = (1 + linebytes) * y; /*the extra filterbyte added to each row*/
 4582|  67.7k|    unsigned char filterType = in[inindex];
 4583|       |
 4584|  67.7k|    CERROR_TRY_RETURN(unfilterScanline(&out[outindex], &in[inindex + 1], prevline, bytewidth, filterType, linebytes));
  ------------------
  |  |  194|  67.7k|#define CERROR_TRY_RETURN(call){\
  |  |  195|  67.7k|  unsigned error = call;\
  |  |  196|  67.7k|  if(error) return error;\
  |  |  ------------------
  |  |  |  Branch (196:6): [True: 211, False: 67.5k]
  |  |  ------------------
  |  |  197|  67.7k|}
  ------------------
 4585|       |
 4586|  67.5k|    prevline = &out[outindex];
 4587|  67.5k|  }
 4588|       |
 4589|  12.1k|  return 0;
 4590|  12.3k|}
lodepng.cpp:_ZL16unfilterScanlinePhPKhS1_mhm:
 4372|  67.7k|                                 size_t bytewidth, unsigned char filterType, size_t length) {
 4373|       |  /*
 4374|       |  For PNG filter method 0
 4375|       |  unfilter a PNG image scanline by scanline. when the pixels are smaller than 1 byte,
 4376|       |  the filter works byte per byte (bytewidth = 1)
 4377|       |  precon is the previous unfiltered scanline, recon the result, scanline the current one
 4378|       |  the incoming scanlines do NOT include the filtertype byte, that one is given in the parameter filterType instead
 4379|       |  recon and scanline MAY be the same memory address! precon must be disjoint.
 4380|       |  */
 4381|       |
 4382|  67.7k|  size_t i;
 4383|  67.7k|  switch(filterType) {
 4384|  10.9k|    case 0:
  ------------------
  |  Branch (4384:5): [True: 10.9k, False: 56.7k]
  ------------------
 4385|  12.9M|      for(i = 0; i != length; ++i) recon[i] = scanline[i];
  ------------------
  |  Branch (4385:18): [True: 12.9M, False: 10.9k]
  ------------------
 4386|  10.9k|      break;
 4387|  3.70k|    case 1: {
  ------------------
  |  Branch (4387:5): [True: 3.70k, False: 64.0k]
  ------------------
 4388|  3.70k|      size_t j = 0;
 4389|  13.1k|      for(i = 0; i != bytewidth; ++i) recon[i] = scanline[i];
  ------------------
  |  Branch (4389:18): [True: 9.46k, False: 3.70k]
  ------------------
 4390|  17.3M|      for(i = bytewidth; i != length; ++i, ++j) recon[i] = scanline[i] + recon[j];
  ------------------
  |  Branch (4390:26): [True: 17.3M, False: 3.70k]
  ------------------
 4391|  3.70k|      break;
 4392|      0|    }
 4393|  5.12k|    case 2:
  ------------------
  |  Branch (4393:5): [True: 5.12k, False: 62.5k]
  ------------------
 4394|  5.12k|      if(precon) {
  ------------------
  |  Branch (4394:10): [True: 4.02k, False: 1.10k]
  ------------------
 4395|  43.4k|        for(i = 0; i != length; ++i) recon[i] = scanline[i] + precon[i];
  ------------------
  |  Branch (4395:20): [True: 39.4k, False: 4.02k]
  ------------------
 4396|  4.02k|      } else {
 4397|  32.9k|        for(i = 0; i != length; ++i) recon[i] = scanline[i];
  ------------------
  |  Branch (4397:20): [True: 31.8k, False: 1.10k]
  ------------------
 4398|  1.10k|      }
 4399|  5.12k|      break;
 4400|  14.7k|    case 3:
  ------------------
  |  Branch (4400:5): [True: 14.7k, False: 53.0k]
  ------------------
 4401|  14.7k|      if(precon) {
  ------------------
  |  Branch (4401:10): [True: 12.5k, False: 2.16k]
  ------------------
 4402|  12.5k|        size_t j = 0;
 4403|  60.1k|        for(i = 0; i != bytewidth; ++i) recon[i] = scanline[i] + (precon[i] >> 1u);
  ------------------
  |  Branch (4403:20): [True: 47.5k, False: 12.5k]
  ------------------
 4404|       |        /* Unroll independent paths of this predictor. A 6x and 8x version is also possible but that adds
 4405|       |        too much code. Whether this speeds up anything depends on compiler and settings. */
 4406|  12.5k|        if(bytewidth >= 4) {
  ------------------
  |  Branch (4406:12): [True: 6.30k, False: 6.23k]
  ------------------
 4407|  13.4k|          for(; i + 3 < length; i += 4, j += 4) {
  ------------------
  |  Branch (4407:17): [True: 7.15k, False: 6.30k]
  ------------------
 4408|  7.15k|            unsigned char s0 = scanline[i + 0], s1 = scanline[i + 1], s2 = scanline[i + 2], s3 = scanline[i + 3];
 4409|  7.15k|            unsigned char r0 = recon[j + 0], r1 = recon[j + 1], r2 = recon[j + 2], r3 = recon[j + 3];
 4410|  7.15k|            unsigned char p0 = precon[i + 0], p1 = precon[i + 1], p2 = precon[i + 2], p3 = precon[i + 3];
 4411|  7.15k|            recon[i + 0] = s0 + ((r0 + p0) >> 1u);
 4412|  7.15k|            recon[i + 1] = s1 + ((r1 + p1) >> 1u);
 4413|  7.15k|            recon[i + 2] = s2 + ((r2 + p2) >> 1u);
 4414|  7.15k|            recon[i + 3] = s3 + ((r3 + p3) >> 1u);
 4415|  7.15k|          }
 4416|  6.30k|        } else if(bytewidth >= 3) {
  ------------------
  |  Branch (4416:19): [True: 1.05k, False: 5.18k]
  ------------------
 4417|  3.80k|          for(; i + 2 < length; i += 3, j += 3) {
  ------------------
  |  Branch (4417:17): [True: 2.75k, False: 1.05k]
  ------------------
 4418|  2.75k|            unsigned char s0 = scanline[i + 0], s1 = scanline[i + 1], s2 = scanline[i + 2];
 4419|  2.75k|            unsigned char r0 = recon[j + 0], r1 = recon[j + 1], r2 = recon[j + 2];
 4420|  2.75k|            unsigned char p0 = precon[i + 0], p1 = precon[i + 1], p2 = precon[i + 2];
 4421|  2.75k|            recon[i + 0] = s0 + ((r0 + p0) >> 1u);
 4422|  2.75k|            recon[i + 1] = s1 + ((r1 + p1) >> 1u);
 4423|  2.75k|            recon[i + 2] = s2 + ((r2 + p2) >> 1u);
 4424|  2.75k|          }
 4425|  5.18k|        } else if(bytewidth >= 2) {
  ------------------
  |  Branch (4425:19): [True: 1.36k, False: 3.81k]
  ------------------
 4426|  3.20k|          for(; i + 1 < length; i += 2, j += 2) {
  ------------------
  |  Branch (4426:17): [True: 1.83k, False: 1.36k]
  ------------------
 4427|  1.83k|            unsigned char s0 = scanline[i + 0], s1 = scanline[i + 1];
 4428|  1.83k|            unsigned char r0 = recon[j + 0], r1 = recon[j + 1];
 4429|  1.83k|            unsigned char p0 = precon[i + 0], p1 = precon[i + 1];
 4430|  1.83k|            recon[i + 0] = s0 + ((r0 + p0) >> 1u);
 4431|  1.83k|            recon[i + 1] = s1 + ((r1 + p1) >> 1u);
 4432|  1.83k|          }
 4433|  1.36k|        }
 4434|  19.8k|        for(; i != length; ++i, ++j) recon[i] = scanline[i] + ((recon[j] + precon[i]) >> 1u);
  ------------------
  |  Branch (4434:15): [True: 7.28k, False: 12.5k]
  ------------------
 4435|  12.5k|      } else {
 4436|  2.16k|        size_t j = 0;
 4437|  9.00k|        for(i = 0; i != bytewidth; ++i) recon[i] = scanline[i];
  ------------------
  |  Branch (4437:20): [True: 6.83k, False: 2.16k]
  ------------------
 4438|  43.0k|        for(i = bytewidth; i != length; ++i, ++j) recon[i] = scanline[i] + (recon[j] >> 1u);
  ------------------
  |  Branch (4438:28): [True: 40.8k, False: 2.16k]
  ------------------
 4439|  2.16k|      }
 4440|  14.7k|      break;
 4441|  33.0k|    case 4:
  ------------------
  |  Branch (4441:5): [True: 33.0k, False: 34.6k]
  ------------------
 4442|  33.0k|      if(precon) {
  ------------------
  |  Branch (4442:10): [True: 30.0k, False: 3.03k]
  ------------------
 4443|       |        /* Unroll independent paths of this predictor. Whether this speeds up
 4444|       |        anything depends on compiler and settings. */
 4445|  30.0k|        if(bytewidth == 8) {
  ------------------
  |  Branch (4445:12): [True: 3.11k, False: 26.9k]
  ------------------
 4446|  3.11k|          unsigned char a0, b0 = 0, c0, d0 = 0, a1, b1 = 0, c1, d1 = 0;
 4447|  3.11k|          unsigned char a2, b2 = 0, c2, d2 = 0, a3, b3 = 0, c3, d3 = 0;
 4448|  3.11k|          unsigned char a4, b4 = 0, c4, d4 = 0, a5, b5 = 0, c5, d5 = 0;
 4449|  3.11k|          unsigned char a6, b6 = 0, c6, d6 = 0, a7, b7 = 0, c7, d7 = 0;
 4450|  23.1k|          for(i = 0; i + 7 < length; i += 8) {
  ------------------
  |  Branch (4450:22): [True: 20.0k, False: 3.11k]
  ------------------
 4451|  20.0k|            c0 = b0; c1 = b1; c2 = b2; c3 = b3;
 4452|  20.0k|            c4 = b4; c5 = b5; c6 = b6; c7 = b7;
 4453|  20.0k|            b0 = precon[i + 0]; b1 = precon[i + 1]; b2 = precon[i + 2]; b3 = precon[i + 3];
 4454|  20.0k|            b4 = precon[i + 4]; b5 = precon[i + 5]; b6 = precon[i + 6]; b7 = precon[i + 7];
 4455|  20.0k|            a0 = d0; a1 = d1; a2 = d2; a3 = d3;
 4456|  20.0k|            a4 = d4; a5 = d5; a6 = d6; a7 = d7;
 4457|  20.0k|            d0 = scanline[i + 0] + paethPredictor(a0, b0, c0);
 4458|  20.0k|            d1 = scanline[i + 1] + paethPredictor(a1, b1, c1);
 4459|  20.0k|            d2 = scanline[i + 2] + paethPredictor(a2, b2, c2);
 4460|  20.0k|            d3 = scanline[i + 3] + paethPredictor(a3, b3, c3);
 4461|  20.0k|            d4 = scanline[i + 4] + paethPredictor(a4, b4, c4);
 4462|  20.0k|            d5 = scanline[i + 5] + paethPredictor(a5, b5, c5);
 4463|  20.0k|            d6 = scanline[i + 6] + paethPredictor(a6, b6, c6);
 4464|  20.0k|            d7 = scanline[i + 7] + paethPredictor(a7, b7, c7);
 4465|  20.0k|            recon[i + 0] = d0; recon[i + 1] = d1; recon[i + 2] = d2; recon[i + 3] = d3;
 4466|  20.0k|            recon[i + 4] = d4; recon[i + 5] = d5; recon[i + 6] = d6; recon[i + 7] = d7;
 4467|  20.0k|          }
 4468|  26.9k|        } else if(bytewidth == 6) {
  ------------------
  |  Branch (4468:19): [True: 9.74k, False: 17.1k]
  ------------------
 4469|  9.74k|          unsigned char a0, b0 = 0, c0, d0 = 0, a1, b1 = 0, c1, d1 = 0;
 4470|  9.74k|          unsigned char a2, b2 = 0, c2, d2 = 0, a3, b3 = 0, c3, d3 = 0;
 4471|  9.74k|          unsigned char a4, b4 = 0, c4, d4 = 0, a5, b5 = 0, c5, d5 = 0;
 4472|  35.4k|          for(i = 0; i + 5 < length; i += 6) {
  ------------------
  |  Branch (4472:22): [True: 25.7k, False: 9.74k]
  ------------------
 4473|  25.7k|            c0 = b0; c1 = b1; c2 = b2;
 4474|  25.7k|            c3 = b3; c4 = b4; c5 = b5;
 4475|  25.7k|            b0 = precon[i + 0]; b1 = precon[i + 1]; b2 = precon[i + 2];
 4476|  25.7k|            b3 = precon[i + 3]; b4 = precon[i + 4]; b5 = precon[i + 5];
 4477|  25.7k|            a0 = d0; a1 = d1; a2 = d2;
 4478|  25.7k|            a3 = d3; a4 = d4; a5 = d5;
 4479|  25.7k|            d0 = scanline[i + 0] + paethPredictor(a0, b0, c0);
 4480|  25.7k|            d1 = scanline[i + 1] + paethPredictor(a1, b1, c1);
 4481|  25.7k|            d2 = scanline[i + 2] + paethPredictor(a2, b2, c2);
 4482|  25.7k|            d3 = scanline[i + 3] + paethPredictor(a3, b3, c3);
 4483|  25.7k|            d4 = scanline[i + 4] + paethPredictor(a4, b4, c4);
 4484|  25.7k|            d5 = scanline[i + 5] + paethPredictor(a5, b5, c5);
 4485|  25.7k|            recon[i + 0] = d0; recon[i + 1] = d1; recon[i + 2] = d2;
 4486|  25.7k|            recon[i + 3] = d3; recon[i + 4] = d4; recon[i + 5] = d5;
 4487|  25.7k|          }
 4488|  17.1k|        } else if(bytewidth == 4) {
  ------------------
  |  Branch (4488:19): [True: 4.63k, False: 12.5k]
  ------------------
 4489|  4.63k|          unsigned char a0, b0 = 0, c0, d0 = 0, a1, b1 = 0, c1, d1 = 0;
 4490|  4.63k|          unsigned char a2, b2 = 0, c2, d2 = 0, a3, b3 = 0, c3, d3 = 0;
 4491|  15.7k|          for(i = 0; i + 3 < length; i += 4) {
  ------------------
  |  Branch (4491:22): [True: 11.0k, False: 4.63k]
  ------------------
 4492|  11.0k|            c0 = b0; c1 = b1; c2 = b2; c3 = b3;
 4493|  11.0k|            b0 = precon[i + 0]; b1 = precon[i + 1]; b2 = precon[i + 2]; b3 = precon[i + 3];
 4494|  11.0k|            a0 = d0; a1 = d1; a2 = d2; a3 = d3;
 4495|  11.0k|            d0 = scanline[i + 0] + paethPredictor(a0, b0, c0);
 4496|  11.0k|            d1 = scanline[i + 1] + paethPredictor(a1, b1, c1);
 4497|  11.0k|            d2 = scanline[i + 2] + paethPredictor(a2, b2, c2);
 4498|  11.0k|            d3 = scanline[i + 3] + paethPredictor(a3, b3, c3);
 4499|  11.0k|            recon[i + 0] = d0; recon[i + 1] = d1; recon[i + 2] = d2; recon[i + 3] = d3;
 4500|  11.0k|          }
 4501|  12.5k|        } else if(bytewidth == 3) {
  ------------------
  |  Branch (4501:19): [True: 1.46k, False: 11.0k]
  ------------------
 4502|  1.46k|          unsigned char a0, b0 = 0, c0, d0 = 0;
 4503|  1.46k|          unsigned char a1, b1 = 0, c1, d1 = 0;
 4504|  1.46k|          unsigned char a2, b2 = 0, c2, d2 = 0;
 4505|  10.0k|          for(i = 0; i + 2 < length; i += 3) {
  ------------------
  |  Branch (4505:22): [True: 8.53k, False: 1.46k]
  ------------------
 4506|  8.53k|            c0 = b0; c1 = b1; c2 = b2;
 4507|  8.53k|            b0 = precon[i + 0]; b1 = precon[i + 1]; b2 = precon[i + 2];
 4508|  8.53k|            a0 = d0; a1 = d1; a2 = d2;
 4509|  8.53k|            d0 = scanline[i + 0] + paethPredictor(a0, b0, c0);
 4510|  8.53k|            d1 = scanline[i + 1] + paethPredictor(a1, b1, c1);
 4511|  8.53k|            d2 = scanline[i + 2] + paethPredictor(a2, b2, c2);
 4512|  8.53k|            recon[i + 0] = d0; recon[i + 1] = d1; recon[i + 2] = d2;
 4513|  8.53k|          }
 4514|  11.0k|        } else if(bytewidth == 2) {
  ------------------
  |  Branch (4514:19): [True: 4.35k, False: 6.70k]
  ------------------
 4515|  4.35k|          unsigned char a0, b0 = 0, c0, d0 = 0;
 4516|  4.35k|          unsigned char a1, b1 = 0, c1, d1 = 0;
 4517|  18.2k|          for(i = 0; i + 1 < length; i += 2) {
  ------------------
  |  Branch (4517:22): [True: 13.9k, False: 4.35k]
  ------------------
 4518|  13.9k|            c0 = b0; c1 = b1;
 4519|  13.9k|            b0 = precon[i + 0];
 4520|  13.9k|            b1 = precon[i + 1];
 4521|  13.9k|            a0 = d0; a1 = d1;
 4522|  13.9k|            d0 = scanline[i + 0] + paethPredictor(a0, b0, c0);
 4523|  13.9k|            d1 = scanline[i + 1] + paethPredictor(a1, b1, c1);
 4524|  13.9k|            recon[i + 0] = d0;
 4525|  13.9k|            recon[i + 1] = d1;
 4526|  13.9k|          }
 4527|  6.70k|        } else if(bytewidth == 1) {
  ------------------
  |  Branch (4527:19): [True: 6.70k, False: 0]
  ------------------
 4528|  6.70k|          unsigned char a, b = 0, c, d = 0;
 4529|  31.5k|          for(i = 0; i != length; ++i) {
  ------------------
  |  Branch (4529:22): [True: 24.8k, False: 6.70k]
  ------------------
 4530|  24.8k|            c = b;
 4531|  24.8k|            b = precon[i];
 4532|  24.8k|            a = d;
 4533|  24.8k|            d = scanline[i] + paethPredictor(a, b, c);
 4534|  24.8k|            recon[i] = d;
 4535|  24.8k|          }
 4536|  6.70k|        } else {
 4537|       |          /* Normally not a possible case, but this would handle it correctly */
 4538|      0|          for(i = 0; i != bytewidth; ++i) {
  ------------------
  |  Branch (4538:22): [True: 0, False: 0]
  ------------------
 4539|      0|            recon[i] = (scanline[i] + precon[i]); /*paethPredictor(0, precon[i], 0) is always precon[i]*/
 4540|      0|          }
 4541|      0|        }
 4542|       |        /* finish any remaining bytes */
 4543|  30.0k|        for(; i != length; ++i) {
  ------------------
  |  Branch (4543:15): [True: 0, False: 30.0k]
  ------------------
 4544|      0|          recon[i] = (scanline[i] + paethPredictor(recon[i - bytewidth], precon[i], precon[i - bytewidth]));
 4545|      0|        }
 4546|  30.0k|      } else {
 4547|  3.03k|        size_t j = 0;
 4548|  13.2k|        for(i = 0; i != bytewidth; ++i) {
  ------------------
  |  Branch (4548:20): [True: 10.2k, False: 3.03k]
  ------------------
 4549|  10.2k|          recon[i] = scanline[i];
 4550|  10.2k|        }
 4551|  51.9k|        for(i = bytewidth; i != length; ++i, ++j) {
  ------------------
  |  Branch (4551:28): [True: 48.9k, False: 3.03k]
  ------------------
 4552|       |          /*paethPredictor(recon[i - bytewidth], 0, 0) is always recon[i - bytewidth]*/
 4553|  48.9k|          recon[i] = (scanline[i] + recon[j]);
 4554|  48.9k|        }
 4555|  3.03k|      }
 4556|  33.0k|      break;
 4557|    211|    default: return 36; /*error: invalid filter type given*/
  ------------------
  |  Branch (4557:5): [True: 211, False: 67.5k]
  ------------------
 4558|  67.7k|  }
 4559|  67.5k|  return 0;
 4560|  67.7k|}
lodepng.cpp:_ZL14paethPredictorhhh:
 4241|   437k|static unsigned char paethPredictor(unsigned char a, unsigned char b, unsigned char c) {
 4242|       |  /* the subtractions of unsigned char cast it to a signed type.
 4243|       |  With gcc, short is faster than int, with clang int is as fast (as of april 2023)*/
 4244|   437k|  short pa = (b - c) < 0 ? -(b - c) : (b - c);
  ------------------
  |  Branch (4244:14): [True: 68.5k, False: 368k]
  ------------------
 4245|   437k|  short pb = (a - c) < 0 ? -(a - c) : (a - c);
  ------------------
  |  Branch (4245:14): [True: 67.4k, False: 369k]
  ------------------
 4246|       |  /* writing it out like this compiles to something faster than introducing a temp variable*/
 4247|   437k|  short pc = (a + b - c - c) < 0 ? -(a + b - c - c) : (a + b - c - c);
  ------------------
  |  Branch (4247:14): [True: 89.9k, False: 347k]
  ------------------
 4248|       |  /* return input value associated with smallest of pa, pb, pc (with certain priority if equal) */
 4249|   437k|  if(pb < pa) { a = b; pa = pb; }
  ------------------
  |  Branch (4249:6): [True: 224k, False: 212k]
  ------------------
 4250|   437k|  return (pc < pa) ? c : a;
  ------------------
  |  Branch (4250:10): [True: 17.7k, False: 419k]
  ------------------
 4251|   437k|}
lodepng.cpp:_ZL17removePaddingBitsPhPKhmmj:
 4644|  2.38k|                              size_t olinebits, size_t ilinebits, unsigned h) {
 4645|       |  /*
 4646|       |  After filtering there are still padding bits if scanlines have non multiple of 8 bit amounts. They need
 4647|       |  to be removed (except at last scanline of (Adam7-reduced) image) before working with pure image buffers
 4648|       |  for the Adam7 code, the color convert code and the output to the user.
 4649|       |  in and out are allowed to be the same buffer, in may also be higher but still overlapping; in must
 4650|       |  have >= ilinebits*h bits, out must have >= olinebits*h bits, olinebits must be <= ilinebits
 4651|       |  also used to move bits after earlier such operations happened, e.g. in a sequence of reduced images from Adam7
 4652|       |  only useful if (ilinebits - olinebits) is a value in the range 1..7
 4653|       |  */
 4654|  2.38k|  unsigned y;
 4655|  2.38k|  size_t diff = ilinebits - olinebits;
 4656|  2.38k|  size_t ibp = 0, obp = 0; /*input and output bit pointers*/
 4657|  15.8k|  for(y = 0; y < h; ++y) {
  ------------------
  |  Branch (4657:14): [True: 13.4k, False: 2.38k]
  ------------------
 4658|  13.4k|    size_t x;
 4659|  9.60M|    for(x = 0; x < olinebits; ++x) {
  ------------------
  |  Branch (4659:16): [True: 9.58M, False: 13.4k]
  ------------------
 4660|  9.58M|      unsigned char bit = readBitFromReversedStream(&ibp, in);
 4661|  9.58M|      setBitOfReversedStream(&obp, out, bit);
 4662|  9.58M|    }
 4663|  13.4k|    ibp += diff;
 4664|  13.4k|  }
 4665|  2.38k|}
lodepng.cpp:_ZL22setBitOfReversedStreamPmPhh:
 2725|  13.6M|static void setBitOfReversedStream(size_t* bitpointer, unsigned char* bitstream, unsigned char bit) {
 2726|       |  /*the current bit in bitstream may be 0 or 1 for this to work*/
 2727|  13.6M|  if(bit == 0) bitstream[(*bitpointer) >> 3u] &=  (unsigned char)(~(1u << (7u - ((*bitpointer) & 7u))));
  ------------------
  |  Branch (2727:6): [True: 11.2M, False: 2.36M]
  ------------------
 2728|  2.36M|  else         bitstream[(*bitpointer) >> 3u] |=  (1u << (7u - ((*bitpointer) & 7u)));
 2729|  13.6M|  ++(*bitpointer);
 2730|  13.6M|}
lodepng.cpp:_ZL19Adam7_getpassvaluesPjS_PmS0_S0_jjj:
 4276|  2.40k|                                size_t padded_passstart[8], size_t passstart[8], unsigned w, unsigned h, unsigned bpp) {
 4277|       |  /*the passstart values have 8 values: the 8th one indicates the byte after the end of the 7th (= last) pass*/
 4278|  2.40k|  unsigned i;
 4279|       |
 4280|       |  /*calculate width and height in pixels of each pass*/
 4281|  19.2k|  for(i = 0; i != 7; ++i) {
  ------------------
  |  Branch (4281:14): [True: 16.8k, False: 2.40k]
  ------------------
 4282|  16.8k|    passw[i] = (w + ADAM7_DX[i] - ADAM7_IX[i] - 1) / ADAM7_DX[i];
 4283|  16.8k|    passh[i] = (h + ADAM7_DY[i] - ADAM7_IY[i] - 1) / ADAM7_DY[i];
 4284|  16.8k|    if(passw[i] == 0) passh[i] = 0;
  ------------------
  |  Branch (4284:8): [True: 4.06k, False: 12.7k]
  ------------------
 4285|  16.8k|    if(passh[i] == 0) passw[i] = 0;
  ------------------
  |  Branch (4285:8): [True: 6.93k, False: 9.91k]
  ------------------
 4286|  16.8k|  }
 4287|       |
 4288|  2.40k|  filter_passstart[0] = padded_passstart[0] = passstart[0] = 0;
 4289|  19.2k|  for(i = 0; i != 7; ++i) {
  ------------------
  |  Branch (4289:14): [True: 16.8k, False: 2.40k]
  ------------------
 4290|       |    /*if passw[i] is 0, it's 0 bytes, not 1 (no filtertype-byte)*/
 4291|  16.8k|    filter_passstart[i + 1] = filter_passstart[i]
 4292|  16.8k|                            + ((passw[i] && passh[i]) ? passh[i] * (1u + (passw[i] * bpp + 7u) / 8u) : 0);
  ------------------
  |  Branch (4292:33): [True: 9.91k, False: 6.93k]
  |  Branch (4292:45): [True: 9.91k, False: 0]
  ------------------
 4293|       |    /*bits padded if needed to fill full byte at end of each scanline*/
 4294|  16.8k|    padded_passstart[i + 1] = padded_passstart[i] + passh[i] * ((passw[i] * bpp + 7u) / 8u);
 4295|       |    /*only padded at end of reduced image*/
 4296|  16.8k|    passstart[i + 1] = passstart[i] + (passh[i] * passw[i] * bpp + 7u) / 8u;
 4297|  16.8k|  }
 4298|  2.40k|}
lodepng.cpp:_ZL17Adam7_deinterlacePhPKhjjj:
 4603|  1.17k|static void Adam7_deinterlace(unsigned char* out, const unsigned char* in, unsigned w, unsigned h, unsigned bpp) {
 4604|  1.17k|  unsigned passw[7], passh[7];
 4605|  1.17k|  size_t filter_passstart[8], padded_passstart[8], passstart[8];
 4606|  1.17k|  unsigned i;
 4607|       |
 4608|  1.17k|  Adam7_getpassvalues(passw, passh, filter_passstart, padded_passstart, passstart, w, h, bpp);
 4609|       |
 4610|  1.17k|  if(bpp >= 8) {
  ------------------
  |  Branch (4610:6): [True: 942, False: 237]
  ------------------
 4611|  7.53k|    for(i = 0; i != 7; ++i) {
  ------------------
  |  Branch (4611:16): [True: 6.59k, False: 942]
  ------------------
 4612|  6.59k|      unsigned x, y, b;
 4613|  6.59k|      size_t bytewidth = bpp / 8u;
 4614|  21.8k|      for(y = 0; y < passh[i]; ++y)
  ------------------
  |  Branch (4614:18): [True: 15.2k, False: 6.59k]
  ------------------
 4615|   164k|      for(x = 0; x < passw[i]; ++x) {
  ------------------
  |  Branch (4615:18): [True: 149k, False: 15.2k]
  ------------------
 4616|   149k|        size_t pixelinstart = passstart[i] + (y * passw[i] + x) * bytewidth;
 4617|   149k|        size_t pixeloutstart = ((ADAM7_IY[i] + (size_t)y * ADAM7_DY[i]) * (size_t)w
 4618|   149k|                             + ADAM7_IX[i] + (size_t)x * ADAM7_DX[i]) * bytewidth;
 4619|   650k|        for(b = 0; b < bytewidth; ++b) {
  ------------------
  |  Branch (4619:20): [True: 501k, False: 149k]
  ------------------
 4620|   501k|          out[pixeloutstart + b] = in[pixelinstart + b];
 4621|   501k|        }
 4622|   149k|      }
 4623|  6.59k|    }
 4624|    942|  } else /*bpp < 8: Adam7 with pixels < 8 bit is a bit trickier: with bit pointers*/ {
 4625|  1.89k|    for(i = 0; i != 7; ++i) {
  ------------------
  |  Branch (4625:16): [True: 1.65k, False: 237]
  ------------------
 4626|  1.65k|      unsigned x, y, b;
 4627|  1.65k|      unsigned ilinebits = bpp * passw[i];
 4628|  1.65k|      unsigned olinebits = bpp * w;
 4629|  1.65k|      size_t obp, ibp; /*bit pointers (for out and in buffer)*/
 4630|  5.22k|      for(y = 0; y < passh[i]; ++y)
  ------------------
  |  Branch (4630:18): [True: 3.56k, False: 1.65k]
  ------------------
 4631|  2.05M|      for(x = 0; x < passw[i]; ++x) {
  ------------------
  |  Branch (4631:18): [True: 2.05M, False: 3.56k]
  ------------------
 4632|  2.05M|        ibp = (8 * passstart[i]) + (y * ilinebits + x * bpp);
 4633|  2.05M|        obp = (ADAM7_IY[i] + (size_t)y * ADAM7_DY[i]) * olinebits + (ADAM7_IX[i] + (size_t)x * ADAM7_DX[i]) * bpp;
 4634|  6.08M|        for(b = 0; b < bpp; ++b) {
  ------------------
  |  Branch (4634:20): [True: 4.03M, False: 2.05M]
  ------------------
 4635|  4.03M|          unsigned char bit = readBitFromReversedStream(&ibp, in);
 4636|  4.03M|          setBitOfReversedStream(&obp, out, bit);
 4637|  4.03M|        }
 4638|  2.05M|      }
 4639|  1.65k|    }
 4640|    237|  }
 4641|  1.17k|}
lodepng.cpp:_ZL15zlib_decompressPPhPmmPKhmPK25LodePNGDecompressSettings:
 2221|  8.97k|                                const unsigned char* in, size_t insize, const LodePNGDecompressSettings* settings) {
 2222|  8.97k|  unsigned error;
 2223|  8.97k|  if(settings->custom_zlib) {
  ------------------
  |  Branch (2223:6): [True: 0, False: 8.97k]
  ------------------
 2224|      0|    error = settings->custom_zlib(out, outsize, in, insize, settings);
 2225|      0|    if(error) {
  ------------------
  |  Branch (2225:8): [True: 0, False: 0]
  ------------------
 2226|       |      /*the custom zlib is allowed to have its own error codes, however, we translate it to code 110*/
 2227|      0|      error = 110;
 2228|       |      /*if there's a max output size, and the custom zlib returned error, then indicate that error instead*/
 2229|      0|      if(settings->max_output_size && *outsize > settings->max_output_size) error = 109;
  ------------------
  |  Branch (2229:10): [True: 0, False: 0]
  |  Branch (2229:39): [True: 0, False: 0]
  ------------------
 2230|      0|    }
 2231|  8.97k|  } else {
 2232|  8.97k|    ucvector v = ucvector_init(*out, *outsize);
 2233|  8.97k|    if(expected_size) {
  ------------------
  |  Branch (2233:8): [True: 6.36k, False: 2.60k]
  ------------------
 2234|       |      /*reserve the memory to avoid intermediate reallocations*/
 2235|  6.36k|      ucvector_resize(&v, *outsize + expected_size);
 2236|  6.36k|      v.size = *outsize;
 2237|  6.36k|    }
 2238|  8.97k|    error = lodepng_zlib_decompressv(&v, in, insize, settings);
 2239|  8.97k|    *out = v.data;
 2240|  8.97k|    *outsize = v.size;
 2241|  8.97k|  }
 2242|  8.97k|  return error;
 2243|  8.97k|}

LLVMFuzzerTestOneInput:
   59|  4.35k|extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
   60|  4.35k|  if(size == 0) return 0;
  ------------------
  |  Branch (60:6): [True: 0, False: 4.35k]
  ------------------
   61|       |  
   62|       |  // Setting last byte of input as random_color_type
   63|       |  // Fuzzer will still be able to mutate the data accordingly as
   64|       |  // last byte of png file can be changed and file will still remain valid.
   65|  4.35k|  size_t random_color_type = data[size-1] % num_combinations;
   66|       |
   67|  4.35k|  lodepng::State state;
   68|       |
   69|       |  // Make the decoder ignore three types of checksums the PNG/zlib format have
   70|       |  // built-in, because they are less likely to be correct in the random input
   71|       |  // data, and if invalid make the decoder return an error before much gets ran.
   72|  4.35k|  state.decoder.zlibsettings.ignore_adler32 = 1;
   73|  4.35k|  state.decoder.zlibsettings.ignore_nlen = 1;
   74|  4.35k|  state.decoder.ignore_crc = 1;
   75|       |  // Also make decoder attempt to support partial files with missing ending to
   76|       |  // go further with parsing.
   77|  4.35k|  state.decoder.ignore_end = 1;
   78|       |
   79|       |  // First test without color conversion (keep color type of the PNG)
   80|  4.35k|  state.decoder.color_convert = 0;
   81|       |
   82|  4.35k|  unsigned error = testDecode(state, data, size);
   83|       |
   84|       |  // If valid PNG found, try decoding with color conversion to the most common
   85|       |  // default color type, and to the randomly chosen type.
   86|  4.35k|  if(error == 0) {
  ------------------
  |  Branch (86:6): [True: 1.63k, False: 2.71k]
  ------------------
   87|  1.63k|    state.decoder.color_convert = 1;
   88|  1.63k|    testDecode(state, data, size);
   89|       |
   90|  1.63k|    state.info_raw.colortype = colortypes[random_color_type];
   91|  1.63k|    state.info_raw.bitdepth = bitdepths[random_color_type];
   92|  1.63k|    testDecode(state, data, size);
   93|  1.63k|  }
   94|       |
   95|  4.35k|  return 0;
   96|  4.35k|}
lodepng_fuzzer.cpp:_ZN12_GLOBAL__N_110testDecodeERN7lodepng5StateEPKhm:
   52|  7.63k|unsigned testDecode(lodepng::State& state, const uint8_t* data, size_t size) {
   53|  7.63k|  unsigned w, h;
   54|  7.63k|  std::vector<unsigned char> image;
   55|  7.63k|  return lodepng::decode(image, w, h, state, (const unsigned char*)data, size);
   56|  7.63k|}

