LLVMFuzzerTestOneInput:
   23|    323|extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
   24|    323|  std::string input(reinterpret_cast<const char *>(data), size);
   25|       |
   26|    323|  char *fuzz_filename = "/tmp/fuzz.json";
   27|    323|  std::ofstream(fuzz_filename, std::ios::binary).write(input.c_str(), size);
   28|       |
   29|    323|  std::ifstream fs(fuzz_filename);
   30|    323|  dnnl::impl::graph::utils::json::json_reader_t read(&fs);
   31|    323|  dnnl::impl::graph::utils::json::read_helper_t helper;
   32|    323|  try {
   33|    323|    helper.read_fields(&read);
   34|    323|  } catch (...) {
   35|    115|  }
   36|       |
   37|    323|  return 0;
   38|    323|}

_ZN4dnnl4impl5graph5utils4json13json_reader_tC2EPNSt3__113basic_istreamIcNS5_11char_traitsIcEEEE:
  122|    323|    explicit json_reader_t(std::istream *is) : is_(is) {}
_ZN4dnnl4impl5graph5utils4json13read_helper_t11read_fieldsEPNS3_13json_reader_tE:
  565|    323|inline bool read_helper_t::read_fields(json_reader_t *reader) {
  566|    323|    reader->begin_object();
  567|    323|    std::map<std::string, int> visited;
  568|    323|    std::string key;
  569|   527k|    while (reader->next_object_item(&key)) {
  ------------------
  |  Branch (569:12): [True: 526k, False: 323]
  ------------------
  570|   526k|        if (map_.count(key) != 0) {
  ------------------
  |  Branch (570:13): [True: 0, False: 526k]
  ------------------
  571|      0|            entry_t e = map_[key];
  572|      0|            (*e.func)(reader, e.addr);
  573|      0|            visited[key] = 0;
  574|      0|        }
  575|   526k|    }
  576|    323|    if (visited.size() != map_.size()) {
  ------------------
  |  Branch (576:9): [True: 0, False: 323]
  ------------------
  577|      0|        for (std::map<std::string, entry_t>::iterator it = map_.begin();
  578|      0|                it != map_.end(); ++it) {
  ------------------
  |  Branch (578:17): [True: 0, False: 0]
  ------------------
  579|      0|            if (visited.count(it->first) != 1) { return false; }
  ------------------
  |  Branch (579:17): [True: 0, False: 0]
  ------------------
  580|      0|        }
  581|      0|    }
  582|    323|    return true;
  583|    323|}
_ZN4dnnl4impl5graph5utils4json13json_reader_t12begin_objectEv:
  492|    323|inline void json_reader_t::begin_object() {
  493|    323|    int ch = next_nonspace();
  494|    323|    if (ch == '{') { scope_count_.push_back(0); }
  ------------------
  |  Branch (494:9): [True: 287, False: 36]
  ------------------
  495|    323|}
_ZN4dnnl4impl5graph5utils4json13json_reader_t13next_nonspaceEv:
  440|  1.58M|inline int json_reader_t::next_nonspace() {
  441|  1.58M|    int ch;
  442|  1.58M|    do {
  443|  1.58M|        ch = next_char();
  444|  1.58M|    } while (isspace(ch));
  ------------------
  |  Branch (444:14): [True: 2.54k, False: 1.58M]
  ------------------
  445|  1.58M|    return ch;
  446|  1.58M|}
_ZN4dnnl4impl5graph5utils4json13json_reader_t9next_charEv:
  432|  1.94M|inline int json_reader_t::next_char() {
  433|  1.94M|    return is_->get();
  434|  1.94M|}
_ZN4dnnl4impl5graph5utils4json13json_reader_t16next_object_itemEPNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEE:
  502|   527k|inline bool json_reader_t::next_object_item(std::string *out_key) {
  503|   527k|    bool next = true;
  504|   527k|    if (scope_count_.empty()) { return false; }
  ------------------
  |  Branch (504:9): [True: 36, False: 527k]
  ------------------
  505|   527k|    if (scope_count_.back() != 0) {
  ------------------
  |  Branch (505:9): [True: 526k, False: 287]
  ------------------
  506|   526k|        int ch = next_nonspace();
  507|   526k|        if (ch == EOF) {
  ------------------
  |  Branch (507:13): [True: 29, False: 526k]
  ------------------
  508|     29|            next = false;
  509|   526k|        } else if (ch == '}') {
  ------------------
  |  Branch (509:20): [True: 1, False: 526k]
  ------------------
  510|      1|            next = false;
  511|   526k|        } else {
  512|   526k|            if (ch != ',') { return false; }
  ------------------
  |  Branch (512:17): [True: 33, False: 526k]
  ------------------
  513|   526k|        }
  514|   526k|    } else {
  515|    287|        int ch = peeknext_nonspace();
  516|    287|        if (ch == '}') {
  ------------------
  |  Branch (516:13): [True: 1, False: 286]
  ------------------
  517|      1|            next_char();
  518|      1|            next = false;
  519|      1|        }
  520|    287|    }
  521|   527k|    if (!next) {
  ------------------
  |  Branch (521:9): [True: 31, False: 527k]
  ------------------
  522|     31|        scope_count_.pop_back();
  523|     31|        return false;
  524|   527k|    } else {
  525|   527k|        scope_count_.back() += 1;
  526|   527k|        read_string(out_key);
  527|   527k|        int ch = next_nonspace();
  528|   527k|        return (ch == ':');
  529|   527k|    }
  530|   527k|}
_ZN4dnnl4impl5graph5utils4json13json_reader_t17peeknext_nonspaceEv:
  448|    287|inline int json_reader_t::peeknext_nonspace() {
  449|    287|    int ch;
  450|    490|    while (true) {
  ------------------
  |  Branch (450:12): [Folded - Ignored]
  ------------------
  451|    490|        ch = peeknext_char();
  452|    490|        if (!isspace(ch)) break;
  ------------------
  |  Branch (452:13): [True: 287, False: 203]
  ------------------
  453|    203|        next_char();
  454|    203|    }
  455|    287|    return ch;
  456|    287|}
_ZN4dnnl4impl5graph5utils4json13json_reader_t13peeknext_charEv:
  436|    490|inline int json_reader_t::peeknext_char() {
  437|    490|    return is_->peek();
  438|    490|}
_ZN4dnnl4impl5graph5utils4json13json_reader_t11read_stringEPNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEE:
  458|   527k|inline void json_reader_t::read_string(std::string *out_str) {
  459|   527k|    int ch = next_nonspace();
  460|   527k|    if (ch == '\"') {
  ------------------
  |  Branch (460:9): [True: 2.06k, False: 524k]
  ------------------
  461|  2.06k|        std::ostringstream output;
  462|   359k|        while (true) {
  ------------------
  |  Branch (462:16): [Folded - Ignored]
  ------------------
  463|   359k|            ch = next_char();
  464|   359k|            if (ch == '\\') {
  ------------------
  |  Branch (464:17): [True: 4.33k, False: 355k]
  ------------------
  465|  4.33k|                char sch = static_cast<char>(next_char());
  466|  4.33k|                switch (sch) {
  467|  1.14k|                    case 'r': output << "\r"; break;
  ------------------
  |  Branch (467:21): [True: 1.14k, False: 3.18k]
  ------------------
  468|    546|                    case 'n': output << "\r"; break;
  ------------------
  |  Branch (468:21): [True: 546, False: 3.78k]
  ------------------
  469|    980|                    case '\\': output << "\r"; break;
  ------------------
  |  Branch (469:21): [True: 980, False: 3.35k]
  ------------------
  470|  1.17k|                    case 't': output << "\r"; break;
  ------------------
  |  Branch (470:21): [True: 1.17k, False: 3.16k]
  ------------------
  471|    481|                    case '\"': output << "\r"; break;
  ------------------
  |  Branch (471:21): [True: 481, False: 3.85k]
  ------------------
  472|      6|                    default: throw("unknown string escape.");
  ------------------
  |  Branch (472:21): [True: 6, False: 4.32k]
  ------------------
  473|  4.33k|                }
  474|   355k|            } else {
  475|   355k|                if (ch == '\"') break;
  ------------------
  |  Branch (475:21): [True: 1.95k, False: 353k]
  ------------------
  476|   353k|                output << static_cast<char>(ch);
  477|   353k|            }
  478|   357k|            if (ch == EOF || ch == '\r' || ch == '\n') {
  ------------------
  |  Branch (478:17): [True: 101, False: 357k]
  |  Branch (478:30): [True: 2, False: 357k]
  |  Branch (478:44): [True: 6, False: 357k]
  ------------------
  479|    109|                throw("error at!");
  480|      0|                return;
  481|    109|            }
  482|   357k|        }
  483|  1.95k|        *out_str = output.str();
  484|  1.95k|    }
  485|   527k|}

