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

_ZN4dnnl4impl5graph5utils4json13json_reader_tC2EPNSt3__113basic_istreamIcNS5_11char_traitsIcEEEE:
  120|    425|    explicit json_reader_t(std::istream *is) : is_(is) {}
_ZN4dnnl4impl5graph5utils4json13read_helper_t11read_fieldsEPNS3_13json_reader_tE:
  559|    425|inline bool read_helper_t::read_fields(json_reader_t *reader) {
  560|    425|    reader->begin_object();
  561|    425|    std::map<std::string, int> visited;
  562|    425|    std::string key;
  563|   529k|    while (reader->next_object_item(&key)) {
  ------------------
  |  Branch (563:12): [True: 528k, False: 425]
  ------------------
  564|   528k|        if (map_.count(key) != 0) {
  ------------------
  |  Branch (564:13): [True: 0, False: 528k]
  ------------------
  565|      0|            entry_t e = map_[key];
  566|      0|            (*e.func)(reader, e.addr);
  567|      0|            visited[key] = 0;
  568|      0|        }
  569|   528k|    }
  570|    425|    if (visited.size() != map_.size()) {
  ------------------
  |  Branch (570:9): [True: 0, False: 425]
  ------------------
  571|      0|        for (std::map<std::string, entry_t>::iterator it = map_.begin();
  572|      0|                it != map_.end(); ++it) {
  ------------------
  |  Branch (572:17): [True: 0, False: 0]
  ------------------
  573|      0|            if (visited.count(it->first) != 1) { return false; }
  ------------------
  |  Branch (573:17): [True: 0, False: 0]
  ------------------
  574|      0|        }
  575|      0|    }
  576|    425|    return true;
  577|    425|}
_ZN4dnnl4impl5graph5utils4json13json_reader_t12begin_objectEv:
  486|    425|inline void json_reader_t::begin_object() {
  487|    425|    int ch = next_nonspace();
  488|    425|    if (ch == '{') { scope_count_.push_back(0); }
  ------------------
  |  Branch (488:9): [True: 392, False: 33]
  ------------------
  489|    425|}
_ZN4dnnl4impl5graph5utils4json13json_reader_t13next_nonspaceEv:
  434|  1.58M|inline int json_reader_t::next_nonspace() {
  435|  1.58M|    int ch;
  436|  1.60M|    do {
  437|  1.60M|        ch = next_char();
  438|  1.60M|    } while (isspace(ch));
  ------------------
  |  Branch (438:14): [True: 13.1k, False: 1.58M]
  ------------------
  439|  1.58M|    return ch;
  440|  1.58M|}
_ZN4dnnl4impl5graph5utils4json13json_reader_t9next_charEv:
  426|  12.3M|inline int json_reader_t::next_char() {
  427|  12.3M|    return is_->get();
  428|  12.3M|}
_ZN4dnnl4impl5graph5utils4json13json_reader_t16next_object_itemEPNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEE:
  496|   529k|inline bool json_reader_t::next_object_item(std::string *out_key) {
  497|   529k|    bool next = true;
  498|   529k|    if (scope_count_.empty()) { return false; }
  ------------------
  |  Branch (498:9): [True: 33, False: 529k]
  ------------------
  499|   529k|    if (scope_count_.back() != 0) {
  ------------------
  |  Branch (499:9): [True: 528k, False: 392]
  ------------------
  500|   528k|        int ch = next_nonspace();
  501|   528k|        if (ch == EOF) {
  ------------------
  |  Branch (501:13): [True: 29, False: 528k]
  ------------------
  502|     29|            next = false;
  503|   528k|        } else if (ch == '}') {
  ------------------
  |  Branch (503:20): [True: 1, False: 528k]
  ------------------
  504|      1|            next = false;
  505|   528k|        } else {
  506|   528k|            if (ch != ',') { return false; }
  ------------------
  |  Branch (506:17): [True: 24, False: 528k]
  ------------------
  507|   528k|        }
  508|   528k|    } else {
  509|    392|        int ch = peeknext_nonspace();
  510|    392|        if (ch == '}') {
  ------------------
  |  Branch (510:13): [True: 1, False: 391]
  ------------------
  511|      1|            next_char();
  512|      1|            next = false;
  513|      1|        }
  514|    392|    }
  515|   529k|    if (!next) {
  ------------------
  |  Branch (515:9): [True: 31, False: 529k]
  ------------------
  516|     31|        scope_count_.pop_back();
  517|     31|        return false;
  518|   529k|    } else {
  519|   529k|        scope_count_.back() += 1;
  520|   529k|        read_string(out_key);
  521|   529k|        int ch = next_nonspace();
  522|   529k|        return (ch == ':');
  523|   529k|    }
  524|   529k|}
_ZN4dnnl4impl5graph5utils4json13json_reader_t17peeknext_nonspaceEv:
  442|    392|inline int json_reader_t::peeknext_nonspace() {
  443|    392|    int ch;
  444|    602|    while (true) {
  ------------------
  |  Branch (444:12): [Folded - Ignored]
  ------------------
  445|    602|        ch = peeknext_char();
  446|    602|        if (!isspace(ch)) break;
  ------------------
  |  Branch (446:13): [True: 392, False: 210]
  ------------------
  447|    210|        next_char();
  448|    210|    }
  449|    392|    return ch;
  450|    392|}
_ZN4dnnl4impl5graph5utils4json13json_reader_t13peeknext_charEv:
  430|    602|inline int json_reader_t::peeknext_char() {
  431|    602|    return is_->peek();
  432|    602|}
_ZN4dnnl4impl5graph5utils4json13json_reader_t11read_stringEPNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEE:
  452|   529k|inline void json_reader_t::read_string(std::string *out_str) {
  453|   529k|    int ch = next_nonspace();
  454|   529k|    if (ch == '\"') {
  ------------------
  |  Branch (454:9): [True: 3.97k, False: 525k]
  ------------------
  455|  3.97k|        std::ostringstream output;
  456|  10.7M|        while (true) {
  ------------------
  |  Branch (456:16): [Folded - Ignored]
  ------------------
  457|  10.7M|            ch = next_char();
  458|  10.7M|            if (ch == '\\') {
  ------------------
  |  Branch (458:17): [True: 6.21k, False: 10.7M]
  ------------------
  459|  6.21k|                char sch = static_cast<char>(next_char());
  460|  6.21k|                switch (sch) {
  461|  1.96k|                    case 'r': output << "\r"; break;
  ------------------
  |  Branch (461:21): [True: 1.96k, False: 4.25k]
  ------------------
  462|    529|                    case 'n': output << "\r"; break;
  ------------------
  |  Branch (462:21): [True: 529, False: 5.68k]
  ------------------
  463|    956|                    case '\\': output << "\r"; break;
  ------------------
  |  Branch (463:21): [True: 956, False: 5.25k]
  ------------------
  464|  1.92k|                    case 't': output << "\r"; break;
  ------------------
  |  Branch (464:21): [True: 1.92k, False: 4.29k]
  ------------------
  465|    842|                    case '\"': output << "\r"; break;
  ------------------
  |  Branch (465:21): [True: 842, False: 5.37k]
  ------------------
  466|      4|                    default: throw("unknown string escape.");
  ------------------
  |  Branch (466:21): [True: 4, False: 6.21k]
  ------------------
  467|  6.21k|                }
  468|  10.7M|            } else {
  469|  10.7M|                if (ch == '\"') break;
  ------------------
  |  Branch (469:21): [True: 3.83k, False: 10.7M]
  ------------------
  470|  10.7M|                output << static_cast<char>(ch);
  471|  10.7M|            }
  472|  10.7M|            if (ch == EOF || ch == '\r' || ch == '\n') {
  ------------------
  |  Branch (472:17): [True: 125, False: 10.7M]
  |  Branch (472:30): [True: 5, False: 10.7M]
  |  Branch (472:44): [True: 2, False: 10.7M]
  ------------------
  473|    132|                throw("error at!");
  474|      0|                return;
  475|    132|            }
  476|  10.7M|        }
  477|  3.83k|        *out_str = output.str();
  478|  3.83k|    }
  479|   529k|}

