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

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

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

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

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

_ZN12Pl_PNGFilterC2EPKcP8PipelineNS_8action_eEjjj:
   30|    175|    Pipeline(identifier, next),
   31|    175|    action(action)
   32|    175|{
   33|    175|    util::assertion(next, "Attempt to create Pl_PNGFilter with nullptr as next");
   34|    175|    util::no_ci_rt_error_if(
   35|    175|        samples_per_pixel < 1, "PNGFilter created with invalid samples_per_pixel");
   36|    175|    util::no_ci_rt_error_if(
   37|    175|        !(bits_per_sample == 1 || bits_per_sample == 2 || bits_per_sample == 4 ||
  ------------------
  |  Branch (37:11): [True: 0, False: 175]
  |  Branch (37:35): [True: 0, False: 175]
  |  Branch (37:59): [True: 0, False: 175]
  ------------------
   38|    175|          bits_per_sample == 8 || bits_per_sample == 16),
  ------------------
  |  Branch (38:11): [True: 175, False: 0]
  |  Branch (38:35): [True: 0, False: 0]
  ------------------
   39|    175|        "PNGFilter created with invalid bits_per_sample not 1, 2, 4, 8, or 16");
   40|    175|    auto bits_per_pixel = 1ULL * bits_per_sample * samples_per_pixel;
   41|    175|    util::no_ci_rt_error_if(
   42|    175|        !util::fits<uint32_t>(bits_per_pixel + 7),
   43|    175|        "PNGFilter created with bits_per_sample and samples_per_pixel values that cause overflow");
   44|    175|    util::no_ci_rt_error_if(
   45|    175|        !util::fits<uint32_t>(columns),
   46|    175|        "PNGFilter created with columns value that causes overflow");
   47|    175|    bytes_per_pixel = static_cast<uint32_t>((bits_per_pixel + 7) / 8);
   48|    175|    auto bpr = ((columns * bits_per_pixel) + 7) / 8;
   49|    175|    util::no_ci_rt_error_if(
   50|    175|        bpr == 0 || !util::fits<uint32_t>(bpr), "PNGFilter created with invalid columns value");
  ------------------
  |  Branch (50:9): [True: 0, False: 175]
  |  Branch (50:21): [True: 0, False: 175]
  ------------------
   51|    175|    util::no_ci_rt_error_if(
   52|    175|        memory_limit > 0 && bpr > (memory_limit / 2U), "PNGFilter memory limit exceeded");
  ------------------
  |  Branch (52:9): [True: 0, False: 175]
  |  Branch (52:29): [True: 0, False: 0]
  ------------------
   53|    175|    bytes_per_row = static_cast<uint32_t>(bpr);
   54|    175|    buf1 = QUtil::make_shared_array<unsigned char>(bytes_per_row + 1);
   55|    175|    buf2 = QUtil::make_shared_array<unsigned char>(bytes_per_row + 1);
   56|    175|    memset(buf1.get(), 0, bytes_per_row + 1);
   57|    175|    memset(buf2.get(), 0, bytes_per_row + 1);
   58|    175|    cur_row = buf1.get();
   59|    175|    prev_row = buf2.get();
   60|       |
   61|       |    // number of bytes per incoming row
   62|    175|    incoming = (action == a_encode ? bytes_per_row : bytes_per_row + 1);
  ------------------
  |  Branch (62:17): [True: 0, False: 175]
  ------------------
   63|    175|}
_ZN12Pl_PNGFilter5writeEPKhm:
   73|    175|{
   74|    175|    size_t left = incoming - pos;
   75|    175|    size_t offset = 0;
   76|   226k|    while (len >= left) {
  ------------------
  |  Branch (76:12): [True: 226k, False: 175]
  ------------------
   77|       |        // finish off current row
   78|   226k|        memcpy(cur_row + pos, data + offset, left);
   79|   226k|        offset += left;
   80|   226k|        len -= left;
   81|       |
   82|   226k|        processRow();
   83|       |
   84|       |        // Swap rows
   85|   226k|        unsigned char* t = prev_row;
   86|   226k|        prev_row = cur_row;
   87|   226k|        cur_row = t ? t : buf2.get();
  ------------------
  |  Branch (87:19): [True: 226k, False: 0]
  ------------------
   88|   226k|        memset(cur_row, 0, bytes_per_row + 1);
   89|   226k|        left = incoming;
   90|   226k|        pos = 0;
   91|   226k|    }
   92|    175|    if (len) {
  ------------------
  |  Branch (92:9): [True: 160, False: 15]
  ------------------
   93|    160|        memcpy(cur_row + pos, data + offset, len);
   94|    160|    }
   95|    175|    pos += len;
   96|    175|}
_ZN12Pl_PNGFilter10processRowEv:
  100|   226k|{
  101|   226k|    if (action == a_encode) {
  ------------------
  |  Branch (101:9): [True: 0, False: 226k]
  ------------------
  102|      0|        encodeRow();
  103|   226k|    } else {
  104|   226k|        decodeRow();
  105|   226k|    }
  106|   226k|}
_ZN12Pl_PNGFilter9decodeRowEv:
  110|   226k|{
  111|   226k|    int filter = cur_row[0];
  112|   226k|    if (prev_row) {
  ------------------
  |  Branch (112:9): [True: 226k, False: 0]
  ------------------
  113|   226k|        switch (filter) {
  114|   144k|        case 0:
  ------------------
  |  Branch (114:9): [True: 144k, False: 81.7k]
  ------------------
  115|   144k|            break;
  116|  6.79k|        case 1:
  ------------------
  |  Branch (116:9): [True: 6.79k, False: 219k]
  ------------------
  117|  6.79k|            decodeSub();
  118|  6.79k|            break;
  119|  1.88k|        case 2:
  ------------------
  |  Branch (119:9): [True: 1.88k, False: 224k]
  ------------------
  120|  1.88k|            decodeUp();
  121|  1.88k|            break;
  122|  5.42k|        case 3:
  ------------------
  |  Branch (122:9): [True: 5.42k, False: 220k]
  ------------------
  123|  5.42k|            decodeAverage();
  124|  5.42k|            break;
  125|  4.44k|        case 4:
  ------------------
  |  Branch (125:9): [True: 4.44k, False: 221k]
  ------------------
  126|  4.44k|            decodePaeth();
  127|  4.44k|            break;
  128|  63.1k|        default:
  ------------------
  |  Branch (128:9): [True: 63.1k, False: 163k]
  ------------------
  129|       |            // ignore
  130|  63.1k|            break;
  131|   226k|        }
  132|   226k|    }
  133|       |
  134|   226k|    next()->write(cur_row + 1, bytes_per_row);
  135|   226k|}
_ZN12Pl_PNGFilter9decodeSubEv:
  139|  6.79k|{
  140|  6.79k|    unsigned char* buffer = cur_row + 1;
  141|  6.79k|    unsigned int bpp = bytes_per_pixel;
  142|       |
  143|   224k|    for (unsigned int i = 0; i < bytes_per_row; ++i) {
  ------------------
  |  Branch (143:30): [True: 217k, False: 6.79k]
  ------------------
  144|   217k|        unsigned char left = 0;
  145|       |
  146|   217k|        if (i >= bpp) {
  ------------------
  |  Branch (146:13): [True: 210k, False: 6.79k]
  ------------------
  147|   210k|            left = buffer[i - bpp];
  148|   210k|        }
  149|       |
  150|   217k|        buffer[i] = static_cast<unsigned char>(buffer[i] + left);
  151|   217k|    }
  152|  6.79k|}
_ZN12Pl_PNGFilter8decodeUpEv:
  156|  1.88k|{
  157|  1.88k|    unsigned char* buffer = cur_row + 1;
  158|  1.88k|    unsigned char* above_buffer = prev_row + 1;
  159|       |
  160|  62.1k|    for (unsigned int i = 0; i < bytes_per_row; ++i) {
  ------------------
  |  Branch (160:30): [True: 60.2k, False: 1.88k]
  ------------------
  161|  60.2k|        unsigned char up = above_buffer[i];
  162|  60.2k|        buffer[i] = static_cast<unsigned char>(buffer[i] + up);
  163|  60.2k|    }
  164|  1.88k|}
_ZN12Pl_PNGFilter13decodeAverageEv:
  168|  5.42k|{
  169|  5.42k|    unsigned char* buffer = cur_row + 1;
  170|  5.42k|    unsigned char* above_buffer = prev_row + 1;
  171|  5.42k|    auto bpp = bytes_per_pixel;
  172|       |
  173|   178k|    for (unsigned int i = 0; i < bytes_per_row; ++i) {
  ------------------
  |  Branch (173:30): [True: 173k, False: 5.42k]
  ------------------
  174|   173k|        int left = 0;
  175|   173k|        int up = 0;
  176|       |
  177|   173k|        if (i >= bpp) {
  ------------------
  |  Branch (177:13): [True: 168k, False: 5.42k]
  ------------------
  178|   168k|            left = buffer[i - bpp];
  179|   168k|        }
  180|       |
  181|   173k|        up = above_buffer[i];
  182|   173k|        buffer[i] = static_cast<unsigned char>(buffer[i] + (left + up) / 2);
  183|   173k|    }
  184|  5.42k|}
_ZN12Pl_PNGFilter11decodePaethEv:
  188|  4.44k|{
  189|  4.44k|    unsigned char* buffer = cur_row + 1;
  190|  4.44k|    unsigned char* above_buffer = prev_row + 1;
  191|  4.44k|    auto bpp = bytes_per_pixel;
  192|       |
  193|   146k|    for (unsigned int i = 0; i < bytes_per_row; ++i) {
  ------------------
  |  Branch (193:30): [True: 142k, False: 4.44k]
  ------------------
  194|   142k|        int left = 0;
  195|   142k|        int up = above_buffer[i];
  196|   142k|        int upper_left = 0;
  197|       |
  198|   142k|        if (i >= bpp) {
  ------------------
  |  Branch (198:13): [True: 137k, False: 4.44k]
  ------------------
  199|   137k|            left = buffer[i - bpp];
  200|   137k|            upper_left = above_buffer[i - bpp];
  201|   137k|        }
  202|       |
  203|   142k|        buffer[i] = static_cast<unsigned char>(buffer[i] + PaethPredictor(left, up, upper_left));
  204|   142k|    }
  205|  4.44k|}
_ZN12Pl_PNGFilter14PaethPredictorEiii:
  209|   142k|{
  210|   142k|    int p = a + b - c;
  211|   142k|    int pa = abs_diff(p, a);
  212|   142k|    int pb = abs_diff(p, b);
  213|   142k|    int pc = abs_diff(p, c);
  214|       |
  215|   142k|    if (pa <= pb && pa <= pc) {
  ------------------
  |  Branch (215:9): [True: 102k, False: 39.3k]
  |  Branch (215:21): [True: 99.7k, False: 3.13k]
  ------------------
  216|  99.7k|        return a;
  217|  99.7k|    }
  218|  42.5k|    if (pb <= pc) {
  ------------------
  |  Branch (218:9): [True: 36.7k, False: 5.74k]
  ------------------
  219|  36.7k|        return b;
  220|  36.7k|    }
  221|  5.74k|    return c;
  222|  42.5k|}
_ZN12Pl_PNGFilter6finishEv:
  242|    175|{
  243|    175|    if (pos) {
  ------------------
  |  Branch (243:9): [True: 160, False: 15]
  ------------------
  244|       |        // write partial row
  245|    160|        processRow();
  246|    160|    }
  247|    175|    prev_row = nullptr;
  248|    175|    cur_row = buf1.get();
  249|    175|    pos = 0;
  250|    175|    memset(cur_row, 0, bytes_per_row + 1);
  251|       |
  252|    175|    next()->finish();
  253|    175|}
Pl_PNGFilter.cc:_ZL8abs_diffii:
   19|   426k|{
   20|   426k|    return a > b ? a - b : b - a;
  ------------------
  |  Branch (20:12): [True: 278k, False: 148k]
  ------------------
   21|   426k|}

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

_ZN4qpdf4util4fitsIjTkNSt3__18integralEyQsr3stdE8integralIT_EEEbT0_:
   63|    350|    {
   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|    350|                          std::numeric_limits<T>::max())) {
   74|    350|            if (std::cmp_greater(val, std::numeric_limits<T>::max())) {
  ------------------
  |  Branch (74:17): [True: 0, False: 350]
  ------------------
   75|      0|                return false;
   76|      0|            }
   77|    350|        }
   78|    350|        return true;
   79|    350|    }
_ZN4qpdf4util9assertionIRA52_KcEEvbOT_:
   27|    175|    {
   28|    175|        if (!cond) {
  ------------------
  |  Branch (28:13): [True: 0, False: 175]
  ------------------
   29|      0|            throw std::logic_error(std::forward<T>(msg));
   30|      0|        }
   31|    175|    }
_ZN4qpdf4util17no_ci_rt_error_ifIRA49_KcEEvbOT_:
   48|    175|    {
   49|    175|        if (cond) {
  ------------------
  |  Branch (49:13): [True: 0, False: 175]
  ------------------
   50|      0|            throw std::runtime_error(std::forward<T>(msg));
   51|      0|        }
   52|    175|    }
_ZN4qpdf4util17no_ci_rt_error_ifIRA69_KcEEvbOT_:
   48|    175|    {
   49|    175|        if (cond) {
  ------------------
  |  Branch (49:13): [True: 0, False: 175]
  ------------------
   50|      0|            throw std::runtime_error(std::forward<T>(msg));
   51|      0|        }
   52|    175|    }
_ZN4qpdf4util17no_ci_rt_error_ifIRA88_KcEEvbOT_:
   48|    175|    {
   49|    175|        if (cond) {
  ------------------
  |  Branch (49:13): [True: 0, False: 175]
  ------------------
   50|      0|            throw std::runtime_error(std::forward<T>(msg));
   51|      0|        }
   52|    175|    }
_ZN4qpdf4util4fitsIjTkNSt3__18integralEjQsr3stdE8integralIT_EEEbT0_:
   63|    175|    {
   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|       |                          std::numeric_limits<T>::max())) {
   74|       |            if (std::cmp_greater(val, std::numeric_limits<T>::max())) {
   75|       |                return false;
   76|       |            }
   77|       |        }
   78|    175|        return true;
   79|    175|    }
_ZN4qpdf4util17no_ci_rt_error_ifIRA58_KcEEvbOT_:
   48|    175|    {
   49|    175|        if (cond) {
  ------------------
  |  Branch (49:13): [True: 0, False: 175]
  ------------------
   50|      0|            throw std::runtime_error(std::forward<T>(msg));
   51|      0|        }
   52|    175|    }
_ZN4qpdf4util17no_ci_rt_error_ifIRA45_KcEEvbOT_:
   48|    175|    {
   49|    175|        if (cond) {
  ------------------
  |  Branch (49:13): [True: 0, False: 175]
  ------------------
   50|      0|            throw std::runtime_error(std::forward<T>(msg));
   51|      0|        }
   52|    175|    }
_ZN4qpdf4util17no_ci_rt_error_ifIRA32_KcEEvbOT_:
   48|    175|    {
   49|    175|        if (cond) {
  ------------------
  |  Branch (49:13): [True: 0, False: 175]
  ------------------
   50|      0|            throw std::runtime_error(std::forward<T>(msg));
   51|      0|        }
   52|    175|    }

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

