LLVMFuzzerTestOneInput:
   35|    177|{
   36|    177|    FuzzHelper f(data, size);
   37|    177|    f.run();
   38|    177|    return 0;
   39|    177|}
_ZN10FuzzHelperC2EPKhm:
   10|    177|        data(data),
   11|    177|        size(size)
   12|    177|    {
   13|    177|    }
_ZN10FuzzHelper3runEv:
   17|    177|    {
   18|    177|        Pl_Discard discard;
   19|    177|        Pl_PNGFilter p("decode", &discard, Pl_PNGFilter::a_decode, 32, 1, 8);
   20|    177|        try {
   21|    177|            p.write(data, size);
   22|    177|            p.finish();
   23|    177|        } catch (std::runtime_error const& e) {
   24|      0|            std::cerr << "runtime_error: " << e.what() << '\n';
   25|      0|        }
   26|    177|    }

_ZN8PipelineD2Ev:
   52|    354|    virtual ~Pipeline() = default;
_ZNK8Pipeline4nextEv:
  103|   258k|    {
  104|   258k|        return next_;
  105|   258k|    }

_ZN5QUtil17make_shared_arrayIhEENSt3__110shared_ptrIT_EEm:
  183|    354|    {
  184|    354|        return std::shared_ptr<T>(new T[n], std::default_delete<T[]>());
  185|    354|    }

_ZN8PipelineC2EPKcPS_:
   11|    354|    identifier(identifier),
   12|    354|    next_(next)
   13|    354|{
   14|    354|}

_ZN10Pl_DiscardC2Ev:
    9|    177|    Pipeline("discard", nullptr)
   10|    177|{
   11|    177|}
_ZN10Pl_DiscardD2Ev:
   14|    177|Pl_Discard::~Pl_Discard() = default;
_ZN10Pl_Discard5writeEPKhm:
   18|   258k|{
   19|   258k|}
_ZN10Pl_Discard6finishEv:
   23|    177|{
   24|    177|}

_ZN12Pl_PNGFilterC2EPKcP8PipelineNS_8action_eEjjj:
   30|    177|    Pipeline(identifier, next),
   31|    177|    action(action)
   32|    177|{
   33|    177|    util::assertion(next, "Attempt to create Pl_PNGFilter with nullptr as next");
   34|    177|    util::no_ci_rt_error_if(
   35|    177|        samples_per_pixel < 1, "PNGFilter created with invalid samples_per_pixel");
   36|    177|    util::no_ci_rt_error_if(
   37|    177|        !(bits_per_sample == 1 || bits_per_sample == 2 || bits_per_sample == 4 ||
  ------------------
  |  Branch (37:11): [True: 0, False: 177]
  |  Branch (37:35): [True: 0, False: 177]
  |  Branch (37:59): [True: 0, False: 177]
  ------------------
   38|    177|          bits_per_sample == 8 || bits_per_sample == 16),
  ------------------
  |  Branch (38:11): [True: 177, False: 0]
  |  Branch (38:35): [True: 0, False: 0]
  ------------------
   39|    177|        "PNGFilter created with invalid bits_per_sample not 1, 2, 4, 8, or 16");
   40|    177|    auto bits_per_pixel = 1ULL * bits_per_sample * samples_per_pixel;
   41|    177|    util::no_ci_rt_error_if(
   42|    177|        !util::fits<uint32_t>(bits_per_pixel + 7),
   43|    177|        "PNGFilter created with bits_per_sample and samples_per_pixel values that cause overflow");
   44|    177|    bytes_per_pixel = static_cast<uint32_t>((bits_per_pixel + 7) / 8);
   45|    177|    auto bpr = ((columns * bits_per_pixel) + 7) / 8;
   46|    177|    util::no_ci_rt_error_if(
   47|    177|        bpr == 0 || !util::fits<uint32_t>(bpr), "PNGFilter created with invalid columns value");
  ------------------
  |  Branch (47:9): [True: 0, False: 177]
  |  Branch (47:21): [True: 0, False: 177]
  ------------------
   48|    177|    util::no_ci_rt_error_if(
   49|    177|        memory_limit > 0 && bpr > (memory_limit / 2U), "PNGFilter memory limit exceeded");
  ------------------
  |  Branch (49:9): [True: 0, False: 177]
  |  Branch (49:29): [True: 0, False: 0]
  ------------------
   50|    177|    bytes_per_row = static_cast<uint32_t>(bpr);
   51|    177|    buf1 = QUtil::make_shared_array<unsigned char>(bytes_per_row + 1);
   52|    177|    buf2 = QUtil::make_shared_array<unsigned char>(bytes_per_row + 1);
   53|    177|    memset(buf1.get(), 0, bytes_per_row + 1);
   54|    177|    memset(buf2.get(), 0, bytes_per_row + 1);
   55|    177|    cur_row = buf1.get();
   56|    177|    prev_row = buf2.get();
   57|       |
   58|       |    // number of bytes per incoming row
   59|    177|    incoming = (action == a_encode ? bytes_per_row : bytes_per_row + 1);
  ------------------
  |  Branch (59:17): [True: 0, False: 177]
  ------------------
   60|    177|}
_ZN12Pl_PNGFilter5writeEPKhm:
   70|    177|{
   71|    177|    size_t left = incoming - pos;
   72|    177|    size_t offset = 0;
   73|   258k|    while (len >= left) {
  ------------------
  |  Branch (73:12): [True: 257k, False: 177]
  ------------------
   74|       |        // finish off current row
   75|   257k|        memcpy(cur_row + pos, data + offset, left);
   76|   257k|        offset += left;
   77|   257k|        len -= left;
   78|       |
   79|   257k|        processRow();
   80|       |
   81|       |        // Swap rows
   82|   257k|        unsigned char* t = prev_row;
   83|   257k|        prev_row = cur_row;
   84|   257k|        cur_row = t ? t : buf2.get();
  ------------------
  |  Branch (84:19): [True: 257k, False: 0]
  ------------------
   85|   257k|        memset(cur_row, 0, bytes_per_row + 1);
   86|   257k|        left = incoming;
   87|   257k|        pos = 0;
   88|   257k|    }
   89|    177|    if (len) {
  ------------------
  |  Branch (89:9): [True: 162, False: 15]
  ------------------
   90|    162|        memcpy(cur_row + pos, data + offset, len);
   91|    162|    }
   92|    177|    pos += len;
   93|    177|}
_ZN12Pl_PNGFilter10processRowEv:
   97|   258k|{
   98|   258k|    if (action == a_encode) {
  ------------------
  |  Branch (98:9): [True: 0, False: 258k]
  ------------------
   99|      0|        encodeRow();
  100|   258k|    } else {
  101|   258k|        decodeRow();
  102|   258k|    }
  103|   258k|}
_ZN12Pl_PNGFilter9decodeRowEv:
  107|   258k|{
  108|   258k|    int filter = cur_row[0];
  109|   258k|    if (prev_row) {
  ------------------
  |  Branch (109:9): [True: 258k, False: 0]
  ------------------
  110|   258k|        switch (filter) {
  111|   115k|        case 0:
  ------------------
  |  Branch (111:9): [True: 115k, False: 142k]
  ------------------
  112|   115k|            break;
  113|  14.3k|        case 1:
  ------------------
  |  Branch (113:9): [True: 14.3k, False: 243k]
  ------------------
  114|  14.3k|            decodeSub();
  115|  14.3k|            break;
  116|  1.69k|        case 2:
  ------------------
  |  Branch (116:9): [True: 1.69k, False: 256k]
  ------------------
  117|  1.69k|            decodeUp();
  118|  1.69k|            break;
  119|  6.80k|        case 3:
  ------------------
  |  Branch (119:9): [True: 6.80k, False: 251k]
  ------------------
  120|  6.80k|            decodeAverage();
  121|  6.80k|            break;
  122|  8.95k|        case 4:
  ------------------
  |  Branch (122:9): [True: 8.95k, False: 249k]
  ------------------
  123|  8.95k|            decodePaeth();
  124|  8.95k|            break;
  125|   110k|        default:
  ------------------
  |  Branch (125:9): [True: 110k, False: 147k]
  ------------------
  126|       |            // ignore
  127|   110k|            break;
  128|   258k|        }
  129|   258k|    }
  130|       |
  131|   258k|    next()->write(cur_row + 1, bytes_per_row);
  132|   258k|}
_ZN12Pl_PNGFilter9decodeSubEv:
  136|  14.3k|{
  137|  14.3k|    unsigned char* buffer = cur_row + 1;
  138|  14.3k|    unsigned int bpp = bytes_per_pixel;
  139|       |
  140|   472k|    for (unsigned int i = 0; i < bytes_per_row; ++i) {
  ------------------
  |  Branch (140:30): [True: 457k, False: 14.3k]
  ------------------
  141|   457k|        unsigned char left = 0;
  142|       |
  143|   457k|        if (i >= bpp) {
  ------------------
  |  Branch (143:13): [True: 443k, False: 14.3k]
  ------------------
  144|   443k|            left = buffer[i - bpp];
  145|   443k|        }
  146|       |
  147|   457k|        buffer[i] = static_cast<unsigned char>(buffer[i] + left);
  148|   457k|    }
  149|  14.3k|}
_ZN12Pl_PNGFilter8decodeUpEv:
  153|  1.69k|{
  154|  1.69k|    unsigned char* buffer = cur_row + 1;
  155|  1.69k|    unsigned char* above_buffer = prev_row + 1;
  156|       |
  157|  56.0k|    for (unsigned int i = 0; i < bytes_per_row; ++i) {
  ------------------
  |  Branch (157:30): [True: 54.3k, False: 1.69k]
  ------------------
  158|  54.3k|        unsigned char up = above_buffer[i];
  159|  54.3k|        buffer[i] = static_cast<unsigned char>(buffer[i] + up);
  160|  54.3k|    }
  161|  1.69k|}
_ZN12Pl_PNGFilter13decodeAverageEv:
  165|  6.80k|{
  166|  6.80k|    unsigned char* buffer = cur_row + 1;
  167|  6.80k|    unsigned char* above_buffer = prev_row + 1;
  168|  6.80k|    auto bpp = bytes_per_pixel;
  169|       |
  170|   224k|    for (unsigned int i = 0; i < bytes_per_row; ++i) {
  ------------------
  |  Branch (170:30): [True: 217k, False: 6.80k]
  ------------------
  171|   217k|        int left = 0;
  172|   217k|        int up = 0;
  173|       |
  174|   217k|        if (i >= bpp) {
  ------------------
  |  Branch (174:13): [True: 211k, False: 6.80k]
  ------------------
  175|   211k|            left = buffer[i - bpp];
  176|   211k|        }
  177|       |
  178|   217k|        up = above_buffer[i];
  179|   217k|        buffer[i] = static_cast<unsigned char>(buffer[i] + (left + up) / 2);
  180|   217k|    }
  181|  6.80k|}
_ZN12Pl_PNGFilter11decodePaethEv:
  185|  8.95k|{
  186|  8.95k|    unsigned char* buffer = cur_row + 1;
  187|  8.95k|    unsigned char* above_buffer = prev_row + 1;
  188|  8.95k|    auto bpp = bytes_per_pixel;
  189|       |
  190|   295k|    for (unsigned int i = 0; i < bytes_per_row; ++i) {
  ------------------
  |  Branch (190:30): [True: 286k, False: 8.95k]
  ------------------
  191|   286k|        int left = 0;
  192|   286k|        int up = above_buffer[i];
  193|   286k|        int upper_left = 0;
  194|       |
  195|   286k|        if (i >= bpp) {
  ------------------
  |  Branch (195:13): [True: 277k, False: 8.95k]
  ------------------
  196|   277k|            left = buffer[i - bpp];
  197|   277k|            upper_left = above_buffer[i - bpp];
  198|   277k|        }
  199|       |
  200|   286k|        buffer[i] = static_cast<unsigned char>(buffer[i] + PaethPredictor(left, up, upper_left));
  201|   286k|    }
  202|  8.95k|}
_ZN12Pl_PNGFilter14PaethPredictorEiii:
  206|   286k|{
  207|   286k|    int p = a + b - c;
  208|   286k|    int pa = abs_diff(p, a);
  209|   286k|    int pb = abs_diff(p, b);
  210|   286k|    int pc = abs_diff(p, c);
  211|       |
  212|   286k|    if (pa <= pb && pa <= pc) {
  ------------------
  |  Branch (212:9): [True: 223k, False: 63.1k]
  |  Branch (212:21): [True: 217k, False: 5.47k]
  ------------------
  213|   217k|        return a;
  214|   217k|    }
  215|  68.6k|    if (pb <= pc) {
  ------------------
  |  Branch (215:9): [True: 59.5k, False: 9.11k]
  ------------------
  216|  59.5k|        return b;
  217|  59.5k|    }
  218|  9.11k|    return c;
  219|  68.6k|}
_ZN12Pl_PNGFilter6finishEv:
  239|    177|{
  240|    177|    if (pos) {
  ------------------
  |  Branch (240:9): [True: 162, False: 15]
  ------------------
  241|       |        // write partial row
  242|    162|        processRow();
  243|    162|    }
  244|    177|    prev_row = nullptr;
  245|    177|    cur_row = buf1.get();
  246|    177|    pos = 0;
  247|    177|    memset(cur_row, 0, bytes_per_row + 1);
  248|       |
  249|    177|    next()->finish();
  250|    177|}
Pl_PNGFilter.cc:_ZL8abs_diffii:
   19|   859k|{
   20|   859k|    return a > b ? a - b : b - a;
  ------------------
  |  Branch (20:12): [True: 556k, False: 303k]
  ------------------
   21|   859k|}

_ZN12Pl_PNGFilterD2Ev:
   26|    177|    ~Pl_PNGFilter() final = default;

_ZN4qpdf4util4fitsIjTkNSt3__18integralEyQsr3stdE8integralIT_EEEbT0_:
   63|    354|    {
   64|       |        if constexpr (std::cmp_less(
   65|       |                          std::numeric_limits<decltype(val)>::min(),
   66|       |                          std::numeric_limits<T>::min())) {
   67|       |            if (std::cmp_less(val, std::numeric_limits<T>::min())) {
   68|       |                return false;
   69|       |            }
   70|       |        }
   71|       |        if constexpr (std::cmp_greater(
   72|       |                          std::numeric_limits<decltype(val)>::max(),
   73|    354|                          std::numeric_limits<T>::max())) {
   74|    354|            if (std::cmp_greater(val, std::numeric_limits<T>::max())) {
  ------------------
  |  Branch (74:17): [True: 0, False: 354]
  ------------------
   75|      0|                return false;
   76|      0|            }
   77|    354|        }
   78|    354|        return true;
   79|    354|    }
_ZN4qpdf4util9assertionIRA52_KcEEvbOT_:
   27|    177|    {
   28|    177|        if (!cond) {
  ------------------
  |  Branch (28:13): [True: 0, False: 177]
  ------------------
   29|      0|            throw std::logic_error(std::forward<T>(msg));
   30|      0|        }
   31|    177|    }
_ZN4qpdf4util17no_ci_rt_error_ifIRA49_KcEEvbOT_:
   48|    177|    {
   49|    177|        if (cond) {
  ------------------
  |  Branch (49:13): [True: 0, False: 177]
  ------------------
   50|      0|            throw std::runtime_error(std::forward<T>(msg));
   51|      0|        }
   52|    177|    }
_ZN4qpdf4util17no_ci_rt_error_ifIRA69_KcEEvbOT_:
   48|    177|    {
   49|    177|        if (cond) {
  ------------------
  |  Branch (49:13): [True: 0, False: 177]
  ------------------
   50|      0|            throw std::runtime_error(std::forward<T>(msg));
   51|      0|        }
   52|    177|    }
_ZN4qpdf4util17no_ci_rt_error_ifIRA88_KcEEvbOT_:
   48|    177|    {
   49|    177|        if (cond) {
  ------------------
  |  Branch (49:13): [True: 0, False: 177]
  ------------------
   50|      0|            throw std::runtime_error(std::forward<T>(msg));
   51|      0|        }
   52|    177|    }
_ZN4qpdf4util17no_ci_rt_error_ifIRA45_KcEEvbOT_:
   48|    177|    {
   49|    177|        if (cond) {
  ------------------
  |  Branch (49:13): [True: 0, False: 177]
  ------------------
   50|      0|            throw std::runtime_error(std::forward<T>(msg));
   51|      0|        }
   52|    177|    }
_ZN4qpdf4util17no_ci_rt_error_ifIRA32_KcEEvbOT_:
   48|    177|    {
   49|    177|        if (cond) {
  ------------------
  |  Branch (49:13): [True: 0, False: 177]
  ------------------
   50|      0|            throw std::runtime_error(std::forward<T>(msg));
   51|      0|        }
   52|    177|    }

_ZN4qpdf6global6Limits14png_max_memoryEv:
  116|      2|        {
  117|      2|            return l.png_max_memory_;
  118|      2|        }

