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|   258k|    {
  104|   258k|        return next_;
  105|   258k|    }

_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|   258k|{
   19|   258k|}
_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 + 1), "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|   258k|    while (len >= left) {
  ------------------
  |  Branch (76:12): [True: 257k, False: 175]
  ------------------
   77|       |        // finish off current row
   78|   257k|        memcpy(cur_row + pos, data + offset, left);
   79|   257k|        offset += left;
   80|   257k|        len -= left;
   81|       |
   82|   257k|        processRow();
   83|       |
   84|       |        // Swap rows
   85|   257k|        unsigned char* t = prev_row;
   86|   257k|        prev_row = cur_row;
   87|   257k|        cur_row = t ? t : buf2.get();
  ------------------
  |  Branch (87:19): [True: 257k, False: 0]
  ------------------
   88|   257k|        memset(cur_row, 0, bytes_per_row + 1);
   89|   257k|        left = incoming;
   90|   257k|        pos = 0;
   91|   257k|    }
   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|   258k|{
  101|   258k|    if (action == a_encode) {
  ------------------
  |  Branch (101:9): [True: 0, False: 258k]
  ------------------
  102|      0|        encodeRow();
  103|   258k|    } else {
  104|   258k|        decodeRow();
  105|   258k|    }
  106|   258k|}
_ZN12Pl_PNGFilter9decodeRowEv:
  110|   258k|{
  111|   258k|    int filter = cur_row[0];
  112|   258k|    if (prev_row) {
  ------------------
  |  Branch (112:9): [True: 258k, False: 0]
  ------------------
  113|   258k|        switch (filter) {
  114|   120k|        case 0:
  ------------------
  |  Branch (114:9): [True: 120k, False: 137k]
  ------------------
  115|   120k|            break;
  116|  10.8k|        case 1:
  ------------------
  |  Branch (116:9): [True: 10.8k, False: 247k]
  ------------------
  117|  10.8k|            decodeSub();
  118|  10.8k|            break;
  119|  2.12k|        case 2:
  ------------------
  |  Branch (119:9): [True: 2.12k, False: 256k]
  ------------------
  120|  2.12k|            decodeUp();
  121|  2.12k|            break;
  122|  6.07k|        case 3:
  ------------------
  |  Branch (122:9): [True: 6.07k, False: 252k]
  ------------------
  123|  6.07k|            decodeAverage();
  124|  6.07k|            break;
  125|  7.33k|        case 4:
  ------------------
  |  Branch (125:9): [True: 7.33k, False: 250k]
  ------------------
  126|  7.33k|            decodePaeth();
  127|  7.33k|            break;
  128|   111k|        default:
  ------------------
  |  Branch (128:9): [True: 111k, False: 146k]
  ------------------
  129|       |            // ignore
  130|   111k|            break;
  131|   258k|        }
  132|   258k|    }
  133|       |
  134|   258k|    next()->write(cur_row + 1, bytes_per_row);
  135|   258k|}
_ZN12Pl_PNGFilter9decodeSubEv:
  139|  10.8k|{
  140|  10.8k|    unsigned char* buffer = cur_row + 1;
  141|  10.8k|    unsigned int bpp = bytes_per_pixel;
  142|       |
  143|   356k|    for (unsigned int i = 0; i < bytes_per_row; ++i) {
  ------------------
  |  Branch (143:30): [True: 345k, False: 10.8k]
  ------------------
  144|   345k|        unsigned char left = 0;
  145|       |
  146|   345k|        if (i >= bpp) {
  ------------------
  |  Branch (146:13): [True: 335k, False: 10.8k]
  ------------------
  147|   335k|            left = buffer[i - bpp];
  148|   335k|        }
  149|       |
  150|   345k|        buffer[i] = static_cast<unsigned char>(buffer[i] + left);
  151|   345k|    }
  152|  10.8k|}
_ZN12Pl_PNGFilter8decodeUpEv:
  156|  2.12k|{
  157|  2.12k|    unsigned char* buffer = cur_row + 1;
  158|  2.12k|    unsigned char* above_buffer = prev_row + 1;
  159|       |
  160|  70.2k|    for (unsigned int i = 0; i < bytes_per_row; ++i) {
  ------------------
  |  Branch (160:30): [True: 68.0k, False: 2.12k]
  ------------------
  161|  68.0k|        unsigned char up = above_buffer[i];
  162|  68.0k|        buffer[i] = static_cast<unsigned char>(buffer[i] + up);
  163|  68.0k|    }
  164|  2.12k|}
_ZN12Pl_PNGFilter13decodeAverageEv:
  168|  6.07k|{
  169|  6.07k|    unsigned char* buffer = cur_row + 1;
  170|  6.07k|    unsigned char* above_buffer = prev_row + 1;
  171|  6.07k|    auto bpp = bytes_per_pixel;
  172|       |
  173|   200k|    for (unsigned int i = 0; i < bytes_per_row; ++i) {
  ------------------
  |  Branch (173:30): [True: 194k, False: 6.07k]
  ------------------
  174|   194k|        int left = 0;
  175|   194k|        int up = 0;
  176|       |
  177|   194k|        if (i >= bpp) {
  ------------------
  |  Branch (177:13): [True: 188k, False: 6.07k]
  ------------------
  178|   188k|            left = buffer[i - bpp];
  179|   188k|        }
  180|       |
  181|   194k|        up = above_buffer[i];
  182|   194k|        buffer[i] = static_cast<unsigned char>(buffer[i] + (left + up) / 2);
  183|   194k|    }
  184|  6.07k|}
_ZN12Pl_PNGFilter11decodePaethEv:
  188|  7.33k|{
  189|  7.33k|    unsigned char* buffer = cur_row + 1;
  190|  7.33k|    unsigned char* above_buffer = prev_row + 1;
  191|  7.33k|    auto bpp = bytes_per_pixel;
  192|       |
  193|   241k|    for (unsigned int i = 0; i < bytes_per_row; ++i) {
  ------------------
  |  Branch (193:30): [True: 234k, False: 7.33k]
  ------------------
  194|   234k|        int left = 0;
  195|   234k|        int up = above_buffer[i];
  196|   234k|        int upper_left = 0;
  197|       |
  198|   234k|        if (i >= bpp) {
  ------------------
  |  Branch (198:13): [True: 227k, False: 7.33k]
  ------------------
  199|   227k|            left = buffer[i - bpp];
  200|   227k|            upper_left = above_buffer[i - bpp];
  201|   227k|        }
  202|       |
  203|   234k|        buffer[i] = static_cast<unsigned char>(buffer[i] + PaethPredictor(left, up, upper_left));
  204|   234k|    }
  205|  7.33k|}
_ZN12Pl_PNGFilter14PaethPredictorEiii:
  209|   234k|{
  210|   234k|    int p = a + b - c;
  211|   234k|    int pa = abs_diff(p, a);
  212|   234k|    int pb = abs_diff(p, b);
  213|   234k|    int pc = abs_diff(p, c);
  214|       |
  215|   234k|    if (pa <= pb && pa <= pc) {
  ------------------
  |  Branch (215:9): [True: 169k, False: 65.0k]
  |  Branch (215:21): [True: 164k, False: 4.55k]
  ------------------
  216|   164k|        return a;
  217|   164k|    }
  218|  69.6k|    if (pb <= pc) {
  ------------------
  |  Branch (218:9): [True: 60.3k, False: 9.28k]
  ------------------
  219|  60.3k|        return b;
  220|  60.3k|    }
  221|  9.28k|    return c;
  222|  69.6k|}
_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|   703k|{
   20|   703k|    return a > b ? a - b : b - a;
  ------------------
  |  Branch (20:12): [True: 452k, False: 251k]
  ------------------
   21|   703k|}

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

_ZN4qpdf4util4fitsIjTkNSt3__18integralEyQsr3stdE8integralIT_EEEbT0_:
   65|    350|    {
   66|       |        if constexpr (std::cmp_less(
   67|       |                          std::numeric_limits<decltype(val)>::min(),
   68|       |                          std::numeric_limits<T>::min())) {
   69|       |            if (std::cmp_less(val, std::numeric_limits<T>::min())) {
   70|       |                return false;
   71|       |            }
   72|       |        }
   73|       |        if constexpr (std::cmp_greater(
   74|       |                          std::numeric_limits<decltype(val)>::max(),
   75|    350|                          std::numeric_limits<T>::max())) {
   76|    350|            if (std::cmp_greater(val, std::numeric_limits<T>::max())) {
  ------------------
  |  Branch (76:17): [True: 0, False: 350]
  ------------------
   77|      0|                return false;
   78|      0|            }
   79|    350|        }
   80|    350|        return true;
   81|    350|    }
_ZN4qpdf4util9assertionIRA52_KcEEvbOT_:
   29|    175|    {
   30|    175|        if (!cond) {
  ------------------
  |  Branch (30:13): [True: 0, False: 175]
  ------------------
   31|      0|            throw std::logic_error(std::forward<T>(msg));
   32|      0|        }
   33|    175|    }
_ZN4qpdf4util17no_ci_rt_error_ifIRA49_KcEEvbOT_:
   50|    175|    {
   51|    175|        if (cond) {
  ------------------
  |  Branch (51:13): [True: 0, False: 175]
  ------------------
   52|      0|            throw std::runtime_error(std::forward<T>(msg));
   53|      0|        }
   54|    175|    }
_ZN4qpdf4util17no_ci_rt_error_ifIRA69_KcEEvbOT_:
   50|    175|    {
   51|    175|        if (cond) {
  ------------------
  |  Branch (51:13): [True: 0, False: 175]
  ------------------
   52|      0|            throw std::runtime_error(std::forward<T>(msg));
   53|      0|        }
   54|    175|    }
_ZN4qpdf4util17no_ci_rt_error_ifIRA88_KcEEvbOT_:
   50|    175|    {
   51|    175|        if (cond) {
  ------------------
  |  Branch (51:13): [True: 0, False: 175]
  ------------------
   52|      0|            throw std::runtime_error(std::forward<T>(msg));
   53|      0|        }
   54|    175|    }
_ZN4qpdf4util4fitsIjTkNSt3__18integralEjQsr3stdE8integralIT_EEEbT0_:
   65|    175|    {
   66|       |        if constexpr (std::cmp_less(
   67|       |                          std::numeric_limits<decltype(val)>::min(),
   68|       |                          std::numeric_limits<T>::min())) {
   69|       |            if (std::cmp_less(val, std::numeric_limits<T>::min())) {
   70|       |                return false;
   71|       |            }
   72|       |        }
   73|       |        if constexpr (std::cmp_greater(
   74|       |                          std::numeric_limits<decltype(val)>::max(),
   75|       |                          std::numeric_limits<T>::max())) {
   76|       |            if (std::cmp_greater(val, std::numeric_limits<T>::max())) {
   77|       |                return false;
   78|       |            }
   79|       |        }
   80|    175|        return true;
   81|    175|    }
_ZN4qpdf4util17no_ci_rt_error_ifIRA58_KcEEvbOT_:
   50|    175|    {
   51|    175|        if (cond) {
  ------------------
  |  Branch (51:13): [True: 0, False: 175]
  ------------------
   52|      0|            throw std::runtime_error(std::forward<T>(msg));
   53|      0|        }
   54|    175|    }
_ZN4qpdf4util17no_ci_rt_error_ifIRA45_KcEEvbOT_:
   50|    175|    {
   51|    175|        if (cond) {
  ------------------
  |  Branch (51:13): [True: 0, False: 175]
  ------------------
   52|      0|            throw std::runtime_error(std::forward<T>(msg));
   53|      0|        }
   54|    175|    }
_ZN4qpdf4util17no_ci_rt_error_ifIRA32_KcEEvbOT_:
   50|    175|    {
   51|    175|        if (cond) {
  ------------------
  |  Branch (51:13): [True: 0, False: 175]
  ------------------
   52|      0|            throw std::runtime_error(std::forward<T>(msg));
   53|      0|        }
   54|    175|    }

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

