_ZN7roaring7RoaringC2EmPKj:
   85|  12.9k|    Roaring(size_t n, const uint32_t *data) : Roaring() {
   86|  12.9k|        api::roaring_bitmap_add_many(&roaring, n, data);
   87|  12.9k|    }
_ZN7roaring7RoaringC2Ev:
   76|  19.4k|    Roaring() : roaring{} {
   77|       |        // The empty constructor roaring{} silences warnings from pedantic
   78|       |        // static analyzers.
   79|  19.4k|        api::roaring_bitmap_init_cleared(&roaring);
   80|  19.4k|    }
_ZN7roaring7RoaringD2Ev:
  913|  58.3k|    ~Roaring() {
  914|  58.3k|        if (!(roaring.high_low_container.flags & ROARING_FLAG_FROZEN)) {
  ------------------
  |  |   47|  58.3k|#define ROARING_FLAG_FROZEN UINT8_C(0x2)
  ------------------
  |  Branch (914:13): [True: 58.3k, False: 0]
  ------------------
  915|  58.3k|            api::roaring_bitmap_clear(&roaring);
  916|  58.3k|        } else {
  917|       |            // The roaring member variable copies the `roaring_bitmap_t` and
  918|       |            // nested `roaring_array_t` structures by value and is freed in the
  919|       |            // constructor, however the underlying memory arena used for the
  920|       |            // container data is not freed with it. Here we derive the arena
  921|       |            // pointer from the second arena allocation in
  922|       |            // `roaring_bitmap_frozen_view` and free it as well.
  923|      0|            roaring_bitmap_free(
  924|      0|                (roaring_bitmap_t *)((char *)
  925|      0|                                         roaring.high_low_container.containers -
  926|      0|                                     sizeof(roaring_bitmap_t)));
  927|      0|        }
  928|  58.3k|    }
_ZN7roaring7Roaring11runOptimizeEv:
  493|  12.9k|    bool runOptimize() noexcept {
  494|  12.9k|        return api::roaring_bitmap_run_optimize(&roaring);
  495|  12.9k|    }
_ZN7roaring7Roaring11shrinkToFitEv:
  501|  6.48k|    size_t shrinkToFit() noexcept {
  502|  6.48k|        return api::roaring_bitmap_shrink_to_fit(&roaring);
  503|  6.48k|    }
_ZN7roaring7Roaring3addEj:
  198|  6.48k|    void add(uint32_t x) noexcept { api::roaring_bitmap_add(&roaring, x); }
_ZN7roaring7Roaring10addCheckedEj:
  205|  6.48k|    bool addChecked(uint32_t x) noexcept {
  206|  6.48k|        return api::roaring_bitmap_add_checked(&roaring, x);
  207|  6.48k|    }
_ZN7roaring7Roaring8addRangeEmm:
  212|  6.48k|    void addRange(const uint64_t min, const uint64_t max) noexcept {
  213|  6.48k|        return api::roaring_bitmap_add_range(&roaring, min, max);
  214|  6.48k|    }
_ZN7roaring7Roaring7addManyEmPKj:
  226|  6.48k|    void addMany(size_t n_args, const uint32_t *vals) noexcept {
  227|  6.48k|        api::roaring_bitmap_add_many(&roaring, n_args, vals);
  228|  6.48k|    }
_ZN7roaring7Roaring6removeEj:
  258|  6.48k|    void remove(uint32_t x) noexcept {
  259|  6.48k|        api::roaring_bitmap_remove(&roaring, x);
  260|  6.48k|    }
_ZN7roaring7Roaring13removeCheckedEj:
  267|  6.48k|    bool removeChecked(uint32_t x) noexcept {
  268|  6.48k|        return api::roaring_bitmap_remove_checked(&roaring, x);
  269|  6.48k|    }
_ZN7roaring7Roaring11removeRangeEmm:
  274|  6.48k|    void removeRange(uint64_t min, uint64_t max) noexcept {
  275|  6.48k|        return api::roaring_bitmap_remove_range(&roaring, min, max);
  276|  6.48k|    }
_ZN7roaring7Roaring17removeRangeClosedEjj:
  281|  6.48k|    void removeRangeClosed(uint32_t min, uint32_t max) noexcept {
  282|  6.48k|        return api::roaring_bitmap_remove_range_closed(&roaring, min, max);
  283|  6.48k|    }
_ZNK7roaring7Roaring7maximumEv:
  315|  6.48k|    uint32_t maximum() const noexcept {
  316|  6.48k|        return api::roaring_bitmap_maximum(&roaring);
  317|  6.48k|    }
_ZNK7roaring7Roaring7minimumEv:
  322|  6.48k|    uint32_t minimum() const noexcept {
  323|  6.48k|        return api::roaring_bitmap_minimum(&roaring);
  324|  6.48k|    }
_ZNK7roaring7Roaring8containsEj:
  329|  6.48k|    bool contains(uint32_t x) const noexcept {
  330|  6.48k|        return api::roaring_bitmap_contains(&roaring, x);
  331|  6.48k|    }
_ZNK7roaring7Roaring13containsRangeEmm:
  336|  6.48k|    bool containsRange(const uint64_t x, const uint64_t y) const noexcept {
  337|  6.48k|        return api::roaring_bitmap_contains_range(&roaring, x, y);
  338|  6.48k|    }
_ZNK7roaring7Roaring6selectEjPj:
  526|  6.48k|    bool select(uint32_t rnk, uint32_t *element) const noexcept {
  527|  6.48k|        return api::roaring_bitmap_select(&roaring, rnk, element);
  528|  6.48k|    }
_ZNK7roaring7Roaring9intersectERKS0_:
  540|  6.48k|    bool intersect(const Roaring &r) const noexcept {
  541|  6.48k|        return api::roaring_bitmap_intersect(&roaring, &r.roaring);
  542|  6.48k|    }
_ZNK7roaring7Roaring13jaccard_indexERKS0_:
  551|  6.48k|    double jaccard_index(const Roaring &r) const noexcept {
  552|  6.48k|        return api::roaring_bitmap_jaccard_index(&roaring, &r.roaring);
  553|  6.48k|    }
_ZNK7roaring7Roaring14or_cardinalityERKS0_:
  558|  6.48k|    uint64_t or_cardinality(const Roaring &r) const noexcept {
  559|  6.48k|        return api::roaring_bitmap_or_cardinality(&roaring, &r.roaring);
  560|  6.48k|    }
_ZNK7roaring7Roaring18andnot_cardinalityERKS0_:
  565|  6.48k|    uint64_t andnot_cardinality(const Roaring &r) const noexcept {
  566|  6.48k|        return api::roaring_bitmap_andnot_cardinality(&roaring, &r.roaring);
  567|  6.48k|    }
_ZNK7roaring7Roaring15xor_cardinalityERKS0_:
  573|  6.48k|    uint64_t xor_cardinality(const Roaring &r) const noexcept {
  574|  6.48k|        return api::roaring_bitmap_xor_cardinality(&roaring, &r.roaring);
  575|  6.48k|    }
_ZNK7roaring7Roaring4rankEj:
  585|  6.48k|    uint64_t rank(uint32_t x) const noexcept {
  586|  6.48k|        return api::roaring_bitmap_rank(&roaring, x);
  587|  6.48k|    }
_ZNK7roaring7Roaring14getSizeInBytesEb:
  732|  12.9k|    size_t getSizeInBytes(bool portable = true) const noexcept {
  733|  12.9k|        if (portable) {
  ------------------
  |  Branch (733:13): [True: 12.9k, False: 0]
  ------------------
  734|  12.9k|            return api::roaring_bitmap_portable_size_in_bytes(&roaring);
  735|  12.9k|        } else {
  736|      0|            return api::roaring_bitmap_size_in_bytes(&roaring);
  737|      0|        }
  738|  12.9k|    }
_ZNK7roaring7RoaringanERKS0_:
  794|  6.48k|    Roaring operator&(const Roaring &o) const {
  795|  6.48k|        roaring_bitmap_t *r = api::roaring_bitmap_and(&roaring, &o.roaring);
  796|  6.48k|        if (r == NULL) {
  ------------------
  |  Branch (796:13): [True: 0, False: 6.48k]
  ------------------
  797|      0|            ROARING_TERMINATE("failed materialization in and");
  ------------------
  |  |   27|      0|#define ROARING_TERMINATE(_s) throw std::runtime_error(_s)
  ------------------
  798|      0|        }
  799|  6.48k|        return Roaring(r);
  800|  6.48k|    }
_ZN7roaring7RoaringC2EPNS_3api16roaring_bitmap_sE:
  102|  32.4k|    explicit Roaring(roaring_bitmap_t *s) noexcept : roaring(*s) {
  103|  32.4k|        roaring_free(s);  // deallocate the passed-in pointer
  104|  32.4k|    }
_ZNK7roaring7RoaringmiERKS0_:
  807|  6.48k|    Roaring operator-(const Roaring &o) const {
  808|  6.48k|        roaring_bitmap_t *r = api::roaring_bitmap_andnot(&roaring, &o.roaring);
  809|  6.48k|        if (r == NULL) {
  ------------------
  |  Branch (809:13): [True: 0, False: 6.48k]
  ------------------
  810|      0|            ROARING_TERMINATE("failed materialization in andnot");
  ------------------
  |  |   27|      0|#define ROARING_TERMINATE(_s) throw std::runtime_error(_s)
  ------------------
  811|      0|        }
  812|  6.48k|        return Roaring(r);
  813|  6.48k|    }
_ZNK7roaring7RoaringorERKS0_:
  820|  6.48k|    Roaring operator|(const Roaring &o) const {
  821|  6.48k|        roaring_bitmap_t *r = api::roaring_bitmap_or(&roaring, &o.roaring);
  822|  6.48k|        if (r == NULL) {
  ------------------
  |  Branch (822:13): [True: 0, False: 6.48k]
  ------------------
  823|      0|            ROARING_TERMINATE("failed materialization in or");
  ------------------
  |  |   27|      0|#define ROARING_TERMINATE(_s) throw std::runtime_error(_s)
  ------------------
  824|      0|        }
  825|  6.48k|        return Roaring(r);
  826|  6.48k|    }
_ZNK7roaring7RoaringeoERKS0_:
  833|  6.48k|    Roaring operator^(const Roaring &o) const {
  834|  6.48k|        roaring_bitmap_t *r = api::roaring_bitmap_xor(&roaring, &o.roaring);
  835|  6.48k|        if (r == NULL) {
  ------------------
  |  Branch (835:13): [True: 0, False: 6.48k]
  ------------------
  836|      0|            ROARING_TERMINATE("failed materialization in xor");
  ------------------
  |  |   27|      0|#define ROARING_TERMINATE(_s) throw std::runtime_error(_s)
  ------------------
  837|      0|        }
  838|  6.48k|        return Roaring(r);
  839|  6.48k|    }
_ZN7roaring7RoaringoRERKS0_:
  378|  6.48k|    Roaring &operator|=(const Roaring &r) noexcept {
  379|  6.48k|        api::roaring_bitmap_or_inplace(&roaring, &r.roaring);
  380|  6.48k|        return *this;
  381|  6.48k|    }
_ZN7roaring7RoaringaNERKS0_:
  356|  6.48k|    Roaring &operator&=(const Roaring &r) noexcept {
  357|  6.48k|        api::roaring_bitmap_and_inplace(&roaring, &r.roaring);
  358|  6.48k|        return *this;
  359|  6.48k|    }
_ZN7roaring7RoaringmIERKS0_:
  366|  6.48k|    Roaring &operator-=(const Roaring &r) noexcept {
  367|  6.48k|        api::roaring_bitmap_andnot_inplace(&roaring, &r.roaring);
  368|  6.48k|        return *this;
  369|  6.48k|    }
_ZN7roaring7RoaringeOERKS0_:
  388|  6.48k|    Roaring &operator^=(const Roaring &r) noexcept {
  389|  6.48k|        api::roaring_bitmap_xor_inplace(&roaring, &r.roaring);
  390|  6.48k|        return *this;
  391|  6.48k|    }
_ZNK7roaring7RoaringeqERKS0_:
  458|  12.9k|    bool operator==(const Roaring &r) const noexcept {
  459|  12.9k|        return api::roaring_bitmap_equals(&roaring, &r.roaring);
  460|  12.9k|    }
_ZNK7roaring7Roaring11cardinalityEv:
  401|  6.48k|    uint64_t cardinality() const noexcept {
  402|  6.48k|        return api::roaring_bitmap_get_cardinality(&roaring);
  403|  6.48k|    }
_ZNK7roaring7Roaring7isEmptyEv:
  408|  12.9k|    bool isEmpty() const noexcept {
  409|  12.9k|        return api::roaring_bitmap_is_empty(&roaring);
  410|  12.9k|    }
_ZNK7roaring7Roaring13toUint32ArrayEPj:
  441|  6.48k|    void toUint32Array(uint32_t *ans) const noexcept {
  442|  6.48k|        api::roaring_bitmap_to_uint32_array(&roaring, ans);
  443|  6.48k|    }
_ZNK7roaring7Roaring8isSubsetERKS0_:
  425|  6.48k|    bool isSubset(const Roaring &r) const noexcept {
  426|  6.48k|        return api::roaring_bitmap_is_subset(&roaring, &r.roaring);
  427|  6.48k|    }
_ZNK7roaring7Roaring14isStrictSubsetERKS0_:
  432|  6.48k|    bool isStrictSubset(const Roaring &r) const noexcept {
  433|  6.48k|        return api::roaring_bitmap_is_strict_subset(&roaring, &r.roaring);
  434|  6.48k|    }
_ZN7roaring7Roaring4flipEmm:
  466|  6.48k|    void flip(uint64_t range_start, uint64_t range_end) noexcept {
  467|  6.48k|        api::roaring_bitmap_flip_inplace(&roaring, range_start, range_end);
  468|  6.48k|    }
_ZN7roaring7Roaring10flipClosedEjj:
  474|  6.48k|    void flipClosed(uint32_t range_start, uint32_t range_end) noexcept {
  475|  6.48k|        api::roaring_bitmap_flip_inplace_closed(&roaring, range_start,
  476|  6.48k|                                                range_end);
  477|  6.48k|    }
_ZN7roaring7Roaring20removeRunCompressionEv:
  483|  6.48k|    bool removeRunCompression() noexcept {
  484|  6.48k|        return api::roaring_bitmap_remove_run_compression(&roaring);
  485|  6.48k|    }
_ZN7roaring7RoaringC2ERKS0_:
  110|  6.48k|    Roaring(const Roaring &r) : Roaring() {
  111|  6.48k|        if (!api::roaring_bitmap_overwrite(&roaring, &r.roaring)) {
  ------------------
  |  Branch (111:13): [True: 0, False: 6.48k]
  ------------------
  112|      0|            ROARING_TERMINATE("failed roaring_bitmap_overwrite in constructor");
  ------------------
  |  |   27|      0|#define ROARING_TERMINATE(_s) throw std::runtime_error(_s)
  ------------------
  113|      0|        }
  114|  6.48k|        api::roaring_bitmap_set_copy_on_write(
  115|  6.48k|            &roaring, api::roaring_bitmap_get_copy_on_write(&r.roaring));
  116|  6.48k|    }
_ZN7roaring7RoaringC2EOS0_:
  122|  6.48k|    Roaring(Roaring &&r) noexcept : roaring(r.roaring) {
  123|       |        //
  124|       |        // !!! This clones the bits of the roaring structure to a new location
  125|       |        // and then overwrites the old bits...assuming that this will still
  126|       |        // work.  There are scenarios where this could break; e.g. if some of
  127|       |        // those bits were pointers into the structure memory itself.  If such
  128|       |        // things were possible, a roaring_bitmap_move() API would be needed.
  129|       |        //
  130|  6.48k|        api::roaring_bitmap_init_cleared(&r.roaring);
  131|  6.48k|    }
_ZN7roaring7RoaringaSERKS0_:
  152|  6.48k|    Roaring &operator=(const Roaring &r) {
  153|  6.48k|        if (!api::roaring_bitmap_overwrite(&roaring, &r.roaring)) {
  ------------------
  |  Branch (153:13): [True: 0, False: 6.48k]
  ------------------
  154|      0|            ROARING_TERMINATE("failed memory alloc in assignment");
  ------------------
  |  |   27|      0|#define ROARING_TERMINATE(_s) throw std::runtime_error(_s)
  ------------------
  155|      0|        }
  156|  6.48k|        api::roaring_bitmap_set_copy_on_write(
  157|  6.48k|            &roaring, api::roaring_bitmap_get_copy_on_write(&r.roaring));
  158|  6.48k|        return *this;
  159|  6.48k|    }
_ZN7roaring7RoaringaSEOS0_:
  165|  6.48k|    Roaring &operator=(Roaring &&r) noexcept {
  166|  6.48k|        api::roaring_bitmap_clear(&roaring);  // free this class's allocations
  167|       |
  168|       |        // !!! See notes in the Move Constructor regarding roaring_bitmap_move()
  169|       |        //
  170|  6.48k|        roaring = r.roaring;
  171|  6.48k|        api::roaring_bitmap_init_cleared(&r.roaring);
  172|       |
  173|  6.48k|        return *this;
  174|  6.48k|    }
_ZN7roaring7Roaring8readSafeEPKcm:
  706|  12.9k|    static Roaring readSafe(const char *buf, size_t maxbytes) {
  707|  12.9k|        roaring_bitmap_t *r =
  708|  12.9k|            api::roaring_bitmap_portable_deserialize_safe(buf, maxbytes);
  709|  12.9k|        if (r == NULL) {
  ------------------
  |  Branch (709:13): [True: 6.46k, False: 6.49k]
  ------------------
  710|  6.46k|            ROARING_TERMINATE("failed alloc while reading");
  ------------------
  |  |   27|  6.46k|#define ROARING_TERMINATE(_s) throw std::runtime_error(_s)
  ------------------
  711|  6.46k|        }
  712|  6.49k|        return Roaring(r);
  713|  12.9k|    }
_ZNK7roaring7Roaring5writeEPcb:
  649|  6.48k|    size_t write(char *buf, bool portable = true) const noexcept {
  650|  6.48k|        if (portable) {
  ------------------
  |  Branch (650:13): [True: 6.48k, False: 0]
  ------------------
  651|  6.48k|            return api::roaring_bitmap_portable_serialize(&roaring, buf);
  652|  6.48k|        } else {
  653|      0|            return api::roaring_bitmap_serialize(&roaring, buf);
  654|      0|        }
  655|  6.48k|    }
_ZNK7roaring7Roaring8toStringEv:
  856|  6.48k|    std::string toString() const noexcept {
  857|  6.48k|        struct iter_data {
  858|  6.48k|            std::string str{};  // The empty constructor silences warnings from
  859|       |                                // pedantic static analyzers.
  860|  6.48k|            char first_char = '{';
  861|  6.48k|        } outer_iter_data;
  862|  6.48k|        if (!isEmpty()) {
  ------------------
  |  Branch (862:13): [True: 6.46k, False: 15]
  ------------------
  863|  6.46k|            iterate(
  864|  6.46k|                [](uint32_t value, void *inner_iter_data) -> bool {
  865|  6.46k|                    ((iter_data *)inner_iter_data)->str +=
  866|  6.46k|                        ((iter_data *)inner_iter_data)->first_char;
  867|  6.46k|                    ((iter_data *)inner_iter_data)->str +=
  868|  6.46k|                        std::to_string(value);
  869|  6.46k|                    ((iter_data *)inner_iter_data)->first_char = ',';
  870|  6.46k|                    return true;
  871|  6.46k|                },
  872|  6.46k|                (void *)&outer_iter_data);
  873|  6.46k|        } else
  874|     15|            outer_iter_data.str = '{';
  875|  6.48k|        outer_iter_data.str += '}';
  876|  6.48k|        return outer_iter_data.str;
  877|  6.48k|    }
_ZNK7roaring7Roaring7iterateEPFbjPvES1_:
  514|  6.46k|    void iterate(api::roaring_iterator iterator, void *ptr) const {
  515|  6.46k|        api::roaring_iterate(&roaring, iterator, ptr);
  516|  6.46k|    }
_ZZNK7roaring7Roaring8toStringEvENKUljPvE_clEjS1_:
  864|  3.98G|                [](uint32_t value, void *inner_iter_data) -> bool {
  865|  3.98G|                    ((iter_data *)inner_iter_data)->str +=
  866|  3.98G|                        ((iter_data *)inner_iter_data)->first_char;
  867|  3.98G|                    ((iter_data *)inner_iter_data)->str +=
  868|  3.98G|                        std::to_string(value);
  869|  3.98G|                    ((iter_data *)inner_iter_data)->first_char = ',';
  870|  3.98G|                    return true;
  871|  3.98G|                },
_ZNK7roaring7Roaring5beginEv:
 1073|  12.9k|inline RoaringSetBitBiDirectionalIterator Roaring::begin() const {
 1074|  12.9k|    return RoaringSetBitBiDirectionalIterator(*this);
 1075|  12.9k|}
_ZN7roaring34RoaringSetBitBiDirectionalIteratorC2ERKNS_7RoaringEb:
  967|  12.9k|                                                bool exhausted = false) {
  968|  12.9k|        if (exhausted) {
  ------------------
  |  Branch (968:13): [True: 1, False: 12.9k]
  ------------------
  969|      1|            i.parent = &parent.roaring;
  970|      1|            i.container_index = INT32_MAX;
  971|      1|            i.has_value = false;
  972|      1|            i.current_value = UINT32_MAX;
  973|  12.9k|        } else {
  974|  12.9k|            api::roaring_iterator_init(&parent.roaring, &i);
  975|  12.9k|        }
  976|  12.9k|    }
_ZNK7roaring34RoaringSetBitBiDirectionalIteratorneERKS0_:
 1064|   342k|    bool operator!=(const RoaringSetBitBiDirectionalIterator &o) const {
 1065|   342k|        return i.current_value != *o || i.has_value != o.i.has_value;
  ------------------
  |  Branch (1065:16): [True: 335k, False: 6.48k]
  |  Branch (1065:41): [True: 0, False: 6.48k]
  ------------------
 1066|   342k|    }
_ZNK7roaring34RoaringSetBitBiDirectionalIteratordeEv:
  981|   342k|    value_type operator*() const { return i.current_value; }
_ZNK7roaring7Roaring3endEv:
 1077|   342k|inline RoaringSetBitBiDirectionalIterator &Roaring::end() const {
 1078|   342k|    static RoaringSetBitBiDirectionalIterator e(*this, true);
 1079|   342k|    return e;
 1080|   342k|}
_ZN7roaring34RoaringSetBitBiDirectionalIteratorppEi:
 1012|   335k|    type_of_iterator operator++(int) {  // i++, must return orig. value
 1013|   335k|        RoaringSetBitBiDirectionalIterator orig(*this);
 1014|   335k|        api::roaring_uint32_iterator_advance(&i);
 1015|   335k|        return orig;
 1016|   335k|    }
_ZN7roaring34RoaringSetBitBiDirectionalIterator13equalorlargerEj:
 1027|  6.48k|    CROARING_DEPRECATED void equalorlarger(uint32_t val) {
 1028|  6.48k|        api::roaring_uint32_iterator_move_equalorlarger(&i, val);
 1029|  6.48k|    }

binarySearch:
   52|  7.41M|                            uint16_t ikey) {
   53|  7.41M|    const int32_t gap = 16;
   54|  7.41M|    if (lenarray < gap) {
  ------------------
  |  Branch (54:9): [True: 2.82M, False: 4.58M]
  ------------------
   55|  4.32M|        for (int32_t j = 0; j < lenarray; j++) {
  ------------------
  |  Branch (55:29): [True: 4.31M, False: 7.53k]
  ------------------
   56|  4.31M|            if (array[j] >= ikey) {
  ------------------
  |  Branch (56:17): [True: 2.81M, False: 1.49M]
  ------------------
   57|  2.81M|                return (array[j] == ikey) ? j : -(j + 1);
  ------------------
  |  Branch (57:24): [True: 2.66M, False: 153k]
  ------------------
   58|  2.81M|            }
   59|  4.31M|        }
   60|  7.53k|        return -(lenarray + 1);
   61|  2.82M|    }
   62|  4.58M|    const int32_t num_blocks = lenarray / gap;
   63|  4.58M|    int32_t base = 0;
   64|  4.58M|    int32_t n = num_blocks;
   65|  9.25M|    while (n > 3) {
  ------------------
  |  Branch (65:12): [True: 4.66M, False: 4.58M]
  ------------------
   66|  4.66M|        int32_t quarter = n >> 2;
   67|       |
   68|  4.66M|        int32_t k1 = array[(base + quarter + 1) * gap - 1];
   69|  4.66M|        int32_t k2 = array[(base + 2 * quarter + 1) * gap - 1];
   70|  4.66M|        int32_t k3 = array[(base + 3 * quarter + 1) * gap - 1];
   71|       |
   72|  4.66M|        int32_t c1 = (k1 < ikey);
   73|  4.66M|        int32_t c2 = (k2 < ikey);
   74|  4.66M|        int32_t c3 = (k3 < ikey);
   75|       |
   76|  4.66M|        base += (c1 + c2 + c3) * quarter;
   77|  4.66M|        n -= 3 * quarter;
   78|  4.66M|    }
   79|  8.50M|    while (n > 1) {
  ------------------
  |  Branch (79:12): [True: 3.92M, False: 4.58M]
  ------------------
   80|  3.92M|        int32_t half = n >> 1;
   81|  3.92M|        base = (array[(base + half + 1) * gap - 1] < ikey) ? base + half : base;
  ------------------
  |  Branch (81:16): [True: 550k, False: 3.37M]
  ------------------
   82|  3.92M|        n -= half;
   83|  3.92M|    }
   84|  4.58M|    int32_t lo = (array[(base + 1) * gap - 1] < ikey) ? base + 1 : base;
  ------------------
  |  Branch (84:18): [True: 2.14M, False: 2.43M]
  ------------------
   85|       |
   86|  4.58M|    if (lo < num_blocks) {
  ------------------
  |  Branch (86:9): [True: 4.25M, False: 325k]
  ------------------
   87|  4.25M|        const int32_t start = lo * gap;
   88|  4.25M|#if defined(CROARING_IS_X64)
   89|       |        // SSE2: subs_epu16 yields zero where lane >= ikey. movemask of an
   90|       |        // epi16 compare gives 2 bits per lane; ctz>>1 = lane index. Scan
   91|       |        // the first 8 lanes first and exit early when they contain the
   92|       |        // answer; otherwise the block-narrowing invariant guarantees the
   93|       |        // second-half mask is non-zero.
   94|  4.25M|        __m128i needle = _mm_set1_epi16((short)ikey);
   95|  4.25M|        __m128i zero = _mm_setzero_si128();
   96|  4.25M|        __m128i v0 = _mm_loadu_si128((const __m128i *)(array + start));
   97|  4.25M|        __m128i ge0 = _mm_cmpeq_epi16(_mm_subs_epu16(needle, v0), zero);
   98|  4.25M|        unsigned m0 = (unsigned)_mm_movemask_epi8(ge0);
   99|  4.25M|        if (m0 != 0) {
  ------------------
  |  Branch (99:13): [True: 3.02M, False: 1.23M]
  ------------------
  100|  3.02M|            int32_t j = start + (int32_t)(roaring_trailing_zeroes(m0) >> 1);
  101|  3.02M|            return (array[j] == ikey) ? j : -(j + 1);
  ------------------
  |  Branch (101:20): [True: 2.24M, False: 786k]
  ------------------
  102|  3.02M|        }
  103|  1.23M|        __m128i v1 = _mm_loadu_si128((const __m128i *)(array + start + 8));
  104|  1.23M|        __m128i ge1 = _mm_cmpeq_epi16(_mm_subs_epu16(needle, v1), zero);
  105|  1.23M|        unsigned m1 = (unsigned)_mm_movemask_epi8(ge1);
  106|  1.23M|        int32_t j = start + 8 + (int32_t)(roaring_trailing_zeroes(m1) >> 1);
  107|  1.23M|        return (array[j] == ikey) ? j : -(j + 1);
  ------------------
  |  Branch (107:16): [True: 533k, False: 698k]
  ------------------
  108|       |#else
  109|       |        const int32_t end = start + gap;
  110|       |        for (int32_t j = start; j < end; j++) {
  111|       |            if (array[j] >= ikey) {
  112|       |                return (array[j] == ikey) ? j : -(j + 1);
  113|       |            }
  114|       |        }
  115|       |        // Unreachable: the narrowing guarantees the last element of the
  116|       |        // selected block is >= ikey.
  117|       |        return -(end + 1);
  118|       |#endif
  119|  4.25M|    }
  120|       |
  121|  1.86M|    for (int32_t j = num_blocks * gap; j < lenarray; j++) {
  ------------------
  |  Branch (121:40): [True: 1.85M, False: 11.0k]
  ------------------
  122|  1.85M|        if (array[j] >= ikey) {
  ------------------
  |  Branch (122:13): [True: 314k, False: 1.54M]
  ------------------
  123|   314k|            return (array[j] == ikey) ? j : -(j + 1);
  ------------------
  |  Branch (123:20): [True: 172k, False: 141k]
  ------------------
  124|   314k|        }
  125|  1.85M|    }
  126|  11.0k|    return -(lenarray + 1);
  127|   325k|}
roaring.c:advanceUntil:
  137|    518|                                   int32_t length, uint16_t min) {
  138|    518|    int32_t lower = pos + 1;
  139|       |
  140|    518|    if ((lower >= length) || (array[lower] >= min)) {
  ------------------
  |  Branch (140:9): [True: 518, False: 0]
  |  Branch (140:30): [True: 0, False: 0]
  ------------------
  141|    518|        return lower;
  142|    518|    }
  143|       |
  144|      0|    int32_t spansize = 1;
  145|       |
  146|      0|    while ((lower + spansize < length) && (array[lower + spansize] < min)) {
  ------------------
  |  Branch (146:12): [True: 0, False: 0]
  |  Branch (146:43): [True: 0, False: 0]
  ------------------
  147|      0|        spansize <<= 1;
  148|      0|    }
  149|      0|    int32_t upper = (lower + spansize < length) ? lower + spansize : length - 1;
  ------------------
  |  Branch (149:21): [True: 0, False: 0]
  ------------------
  150|       |
  151|      0|    if (array[upper] == min) {
  ------------------
  |  Branch (151:9): [True: 0, False: 0]
  ------------------
  152|      0|        return upper;
  153|      0|    }
  154|      0|    if (array[upper] < min) {
  ------------------
  |  Branch (154:9): [True: 0, False: 0]
  ------------------
  155|       |        // means
  156|       |        // array
  157|       |        // has no
  158|       |        // item
  159|       |        // >= min
  160|       |        // pos = array.length;
  161|      0|        return length;
  162|      0|    }
  163|       |
  164|       |    // we know that the next-smallest span was too small
  165|      0|    lower += (spansize >> 1);
  166|       |
  167|      0|    int32_t mid = 0;
  168|      0|    while (lower + 1 != upper) {
  ------------------
  |  Branch (168:12): [True: 0, False: 0]
  ------------------
  169|      0|        mid = (lower + upper) >> 1;
  170|      0|        if (array[mid] == min) {
  ------------------
  |  Branch (170:13): [True: 0, False: 0]
  ------------------
  171|      0|            return mid;
  172|      0|        } else if (array[mid] < min) {
  ------------------
  |  Branch (172:20): [True: 0, False: 0]
  ------------------
  173|      0|            lower = mid;
  174|      0|        } else {
  175|      0|            upper = mid;
  176|      0|        }
  177|      0|    }
  178|      0|    return upper;
  179|      0|}
roaring.c:count_greater:
  197|  9.36k|                                    uint16_t ikey) {
  198|  9.36k|    if (lenarray == 0) return 0;
  ------------------
  |  Branch (198:9): [True: 0, False: 9.36k]
  ------------------
  199|  9.36k|    int32_t pos = binarySearch(array, lenarray, ikey);
  200|  9.36k|    if (pos >= 0) {
  ------------------
  |  Branch (200:9): [True: 2.04k, False: 7.31k]
  ------------------
  201|  2.04k|        return lenarray - (pos + 1);
  202|  7.31k|    } else {
  203|  7.31k|        return lenarray - (-pos - 1);
  204|  7.31k|    }
  205|  9.36k|}
roaring.c:count_less:
  186|  15.9k|                                 uint16_t ikey) {
  187|  15.9k|    if (lenarray == 0) return 0;
  ------------------
  |  Branch (187:9): [True: 3.07k, False: 12.8k]
  ------------------
  188|  12.8k|    int32_t pos = binarySearch(array, lenarray, ikey);
  189|  12.8k|    return pos >= 0 ? pos : -(pos + 1);
  ------------------
  |  Branch (189:12): [True: 9.72k, False: 3.12k]
  ------------------
  190|  15.9k|}
array_util.c:advanceUntil:
  137|  20.3k|                                   int32_t length, uint16_t min) {
  138|  20.3k|    int32_t lower = pos + 1;
  139|       |
  140|  20.3k|    if ((lower >= length) || (array[lower] >= min)) {
  ------------------
  |  Branch (140:9): [True: 25, False: 20.3k]
  |  Branch (140:30): [True: 6.97k, False: 13.3k]
  ------------------
  141|  7.00k|        return lower;
  142|  7.00k|    }
  143|       |
  144|  13.3k|    int32_t spansize = 1;
  145|       |
  146|  58.1k|    while ((lower + spansize < length) && (array[lower + spansize] < min)) {
  ------------------
  |  Branch (146:12): [True: 56.7k, False: 1.41k]
  |  Branch (146:43): [True: 44.7k, False: 11.9k]
  ------------------
  147|  44.7k|        spansize <<= 1;
  148|  44.7k|    }
  149|  13.3k|    int32_t upper = (lower + spansize < length) ? lower + spansize : length - 1;
  ------------------
  |  Branch (149:21): [True: 11.9k, False: 1.41k]
  ------------------
  150|       |
  151|  13.3k|    if (array[upper] == min) {
  ------------------
  |  Branch (151:9): [True: 3.06k, False: 10.3k]
  ------------------
  152|  3.06k|        return upper;
  153|  3.06k|    }
  154|  10.3k|    if (array[upper] < min) {
  ------------------
  |  Branch (154:9): [True: 213, False: 10.0k]
  ------------------
  155|       |        // means
  156|       |        // array
  157|       |        // has no
  158|       |        // item
  159|       |        // >= min
  160|       |        // pos = array.length;
  161|    213|        return length;
  162|    213|    }
  163|       |
  164|       |    // we know that the next-smallest span was too small
  165|  10.0k|    lower += (spansize >> 1);
  166|       |
  167|  10.0k|    int32_t mid = 0;
  168|  31.9k|    while (lower + 1 != upper) {
  ------------------
  |  Branch (168:12): [True: 27.0k, False: 4.92k]
  ------------------
  169|  27.0k|        mid = (lower + upper) >> 1;
  170|  27.0k|        if (array[mid] == min) {
  ------------------
  |  Branch (170:13): [True: 5.17k, False: 21.8k]
  ------------------
  171|  5.17k|            return mid;
  172|  21.8k|        } else if (array[mid] < min) {
  ------------------
  |  Branch (172:20): [True: 11.0k, False: 10.8k]
  ------------------
  173|  11.0k|            lower = mid;
  174|  11.0k|        } else {
  175|  10.8k|            upper = mid;
  176|  10.8k|        }
  177|  27.0k|    }
  178|  4.92k|    return upper;
  179|  10.0k|}
mixed_intersection.c:advanceUntil:
  137|   142k|                                   int32_t length, uint16_t min) {
  138|   142k|    int32_t lower = pos + 1;
  139|       |
  140|   142k|    if ((lower >= length) || (array[lower] >= min)) {
  ------------------
  |  Branch (140:9): [True: 520, False: 142k]
  |  Branch (140:30): [True: 80.7k, False: 61.4k]
  ------------------
  141|  81.2k|        return lower;
  142|  81.2k|    }
  143|       |
  144|  61.4k|    int32_t spansize = 1;
  145|       |
  146|   147k|    while ((lower + spansize < length) && (array[lower + spansize] < min)) {
  ------------------
  |  Branch (146:12): [True: 145k, False: 1.27k]
  |  Branch (146:43): [True: 85.5k, False: 60.2k]
  ------------------
  147|  85.5k|        spansize <<= 1;
  148|  85.5k|    }
  149|  61.4k|    int32_t upper = (lower + spansize < length) ? lower + spansize : length - 1;
  ------------------
  |  Branch (149:21): [True: 60.2k, False: 1.27k]
  ------------------
  150|       |
  151|  61.4k|    if (array[upper] == min) {
  ------------------
  |  Branch (151:9): [True: 28.7k, False: 32.7k]
  ------------------
  152|  28.7k|        return upper;
  153|  28.7k|    }
  154|  32.7k|    if (array[upper] < min) {
  ------------------
  |  Branch (154:9): [True: 611, False: 32.1k]
  ------------------
  155|       |        // means
  156|       |        // array
  157|       |        // has no
  158|       |        // item
  159|       |        // >= min
  160|       |        // pos = array.length;
  161|    611|        return length;
  162|    611|    }
  163|       |
  164|       |    // we know that the next-smallest span was too small
  165|  32.1k|    lower += (spansize >> 1);
  166|       |
  167|  32.1k|    int32_t mid = 0;
  168|  55.4k|    while (lower + 1 != upper) {
  ------------------
  |  Branch (168:12): [True: 37.4k, False: 18.0k]
  ------------------
  169|  37.4k|        mid = (lower + upper) >> 1;
  170|  37.4k|        if (array[mid] == min) {
  ------------------
  |  Branch (170:13): [True: 14.0k, False: 23.3k]
  ------------------
  171|  14.0k|            return mid;
  172|  23.3k|        } else if (array[mid] < min) {
  ------------------
  |  Branch (172:20): [True: 8.64k, False: 14.7k]
  ------------------
  173|  8.64k|            lower = mid;
  174|  14.7k|        } else {
  175|  14.7k|            upper = mid;
  176|  14.7k|        }
  177|  37.4k|    }
  178|  18.0k|    return upper;
  179|  32.1k|}
mixed_subset.c:advanceUntil:
  137|    504|                                   int32_t length, uint16_t min) {
  138|    504|    int32_t lower = pos + 1;
  139|       |
  140|    504|    if ((lower >= length) || (array[lower] >= min)) {
  ------------------
  |  Branch (140:9): [True: 0, False: 504]
  |  Branch (140:30): [True: 262, False: 242]
  ------------------
  141|    262|        return lower;
  142|    262|    }
  143|       |
  144|    242|    int32_t spansize = 1;
  145|       |
  146|  1.18k|    while ((lower + spansize < length) && (array[lower + spansize] < min)) {
  ------------------
  |  Branch (146:12): [True: 1.08k, False: 94]
  |  Branch (146:43): [True: 940, False: 148]
  ------------------
  147|    940|        spansize <<= 1;
  148|    940|    }
  149|    242|    int32_t upper = (lower + spansize < length) ? lower + spansize : length - 1;
  ------------------
  |  Branch (149:21): [True: 148, False: 94]
  ------------------
  150|       |
  151|    242|    if (array[upper] == min) {
  ------------------
  |  Branch (151:9): [True: 0, False: 242]
  ------------------
  152|      0|        return upper;
  153|      0|    }
  154|    242|    if (array[upper] < min) {
  ------------------
  |  Branch (154:9): [True: 10, False: 232]
  ------------------
  155|       |        // means
  156|       |        // array
  157|       |        // has no
  158|       |        // item
  159|       |        // >= min
  160|       |        // pos = array.length;
  161|     10|        return length;
  162|     10|    }
  163|       |
  164|       |    // we know that the next-smallest span was too small
  165|    232|    lower += (spansize >> 1);
  166|       |
  167|    232|    int32_t mid = 0;
  168|    842|    while (lower + 1 != upper) {
  ------------------
  |  Branch (168:12): [True: 610, False: 232]
  ------------------
  169|    610|        mid = (lower + upper) >> 1;
  170|    610|        if (array[mid] == min) {
  ------------------
  |  Branch (170:13): [True: 0, False: 610]
  ------------------
  171|      0|            return mid;
  172|    610|        } else if (array[mid] < min) {
  ------------------
  |  Branch (172:20): [True: 320, False: 290]
  ------------------
  173|    320|            lower = mid;
  174|    320|        } else {
  175|    290|            upper = mid;
  176|    290|        }
  177|    610|    }
  178|    232|    return upper;
  179|    232|}
mixed_andnot.c:advanceUntil:
  137|   101k|                                   int32_t length, uint16_t min) {
  138|   101k|    int32_t lower = pos + 1;
  139|       |
  140|   101k|    if ((lower >= length) || (array[lower] >= min)) {
  ------------------
  |  Branch (140:9): [True: 4.56k, False: 97.1k]
  |  Branch (140:30): [True: 82.6k, False: 14.5k]
  ------------------
  141|  87.2k|        return lower;
  142|  87.2k|    }
  143|       |
  144|  14.5k|    int32_t spansize = 1;
  145|       |
  146|  29.3k|    while ((lower + spansize < length) && (array[lower + spansize] < min)) {
  ------------------
  |  Branch (146:12): [True: 28.8k, False: 490]
  |  Branch (146:43): [True: 14.8k, False: 14.0k]
  ------------------
  147|  14.8k|        spansize <<= 1;
  148|  14.8k|    }
  149|  14.5k|    int32_t upper = (lower + spansize < length) ? lower + spansize : length - 1;
  ------------------
  |  Branch (149:21): [True: 14.0k, False: 490]
  ------------------
  150|       |
  151|  14.5k|    if (array[upper] == min) {
  ------------------
  |  Branch (151:9): [True: 7.12k, False: 7.39k]
  ------------------
  152|  7.12k|        return upper;
  153|  7.12k|    }
  154|  7.39k|    if (array[upper] < min) {
  ------------------
  |  Branch (154:9): [True: 441, False: 6.94k]
  ------------------
  155|       |        // means
  156|       |        // array
  157|       |        // has no
  158|       |        // item
  159|       |        // >= min
  160|       |        // pos = array.length;
  161|    441|        return length;
  162|    441|    }
  163|       |
  164|       |    // we know that the next-smallest span was too small
  165|  6.94k|    lower += (spansize >> 1);
  166|       |
  167|  6.94k|    int32_t mid = 0;
  168|  10.7k|    while (lower + 1 != upper) {
  ------------------
  |  Branch (168:12): [True: 6.26k, False: 4.45k]
  ------------------
  169|  6.26k|        mid = (lower + upper) >> 1;
  170|  6.26k|        if (array[mid] == min) {
  ------------------
  |  Branch (170:13): [True: 2.49k, False: 3.77k]
  ------------------
  171|  2.49k|            return mid;
  172|  3.77k|        } else if (array[mid] < min) {
  ------------------
  |  Branch (172:20): [True: 1.30k, False: 2.47k]
  ------------------
  173|  1.30k|            lower = mid;
  174|  2.47k|        } else {
  175|  2.47k|            upper = mid;
  176|  2.47k|        }
  177|  6.26k|    }
  178|  4.45k|    return upper;
  179|  6.94k|}

roaring.c:bitset_lenrange_cardinality:
   63|  1.31k|                                              uint32_t lenminusone) {
   64|  1.31k|    uint32_t firstword = start / 64;
   65|  1.31k|    uint32_t endword = (start + lenminusone) / 64;
   66|  1.31k|    if (firstword == endword) {
  ------------------
  |  Branch (66:9): [True: 967, False: 349]
  ------------------
   67|    967|        return roaring_hamming(words[firstword] &
   68|    967|                               ((~UINT64_C(0)) >> ((63 - lenminusone) % 64))
   69|    967|                                   << (start % 64));
   70|    967|    }
   71|    349|    int answer =
   72|    349|        roaring_hamming(words[firstword] & ((~UINT64_C(0)) << (start % 64)));
   73|   151k|    for (uint32_t i = firstword + 1; i < endword; i++) {
  ------------------
  |  Branch (73:38): [True: 151k, False: 349]
  ------------------
   74|   151k|        answer += roaring_hamming(words[i]);
   75|   151k|    }
   76|    349|    answer += roaring_hamming(words[endword] &
   77|       |                              (~UINT64_C(0)) >>
   78|    349|                                  (((~start + 1) - lenminusone - 1) % 64));
   79|    349|    return answer;
   80|  1.31k|}
roaring.c:bitset_reset_range:
  147|  1.28k|                                      uint32_t end) {
  148|  1.28k|    if (start == end) return;
  ------------------
  |  Branch (148:9): [True: 0, False: 1.28k]
  ------------------
  149|  1.28k|    uint32_t firstword = start / 64;
  150|  1.28k|    uint32_t endword = (end - 1) / 64;
  151|  1.28k|    if (firstword == endword) {
  ------------------
  |  Branch (151:9): [True: 967, False: 317]
  ------------------
  152|    967|        words[firstword] &= ~(((~UINT64_C(0)) << (start % 64)) &
  153|    967|                              ((~UINT64_C(0)) >> ((~end + 1) % 64)));
  154|    967|        return;
  155|    967|    }
  156|    317|    words[firstword] &= ~((~UINT64_C(0)) << (start % 64));
  157|   125k|    for (uint32_t i = firstword + 1; i < endword; i++) {
  ------------------
  |  Branch (157:38): [True: 124k, False: 317]
  ------------------
  158|   124k|        words[i] = UINT64_C(0);
  159|   124k|    }
  160|       |    words[endword] &= ~((~UINT64_C(0)) >> ((~end + 1) % 64));
  161|    317|}
roaring.c:bitset_set_lenrange:
  112|  1.54k|                                       uint32_t lenminusone) {
  113|  1.54k|    uint32_t firstword = start / 64;
  114|  1.54k|    uint32_t endword = (start + lenminusone) / 64;
  115|  1.54k|    if (firstword == endword) {
  ------------------
  |  Branch (115:9): [True: 0, False: 1.54k]
  ------------------
  116|      0|        words[firstword] |= ((~UINT64_C(0)) >> ((63 - lenminusone) % 64))
  117|      0|                            << (start % 64);
  118|      0|        return;
  119|      0|    }
  120|  1.54k|    uint64_t temp = words[endword];
  121|  1.54k|    words[firstword] |= (~UINT64_C(0)) << (start % 64);
  122|   452k|    for (uint32_t i = firstword + 1; i < endword; i += 2)
  ------------------
  |  Branch (122:38): [True: 451k, False: 1.54k]
  ------------------
  123|   451k|        words[i] = words[i + 1] = ~UINT64_C(0);
  124|  1.54k|    words[endword] =
  125|       |        temp | (~UINT64_C(0)) >> (((~start + 1) - lenminusone - 1) % 64);
  126|  1.54k|}
bitset.c:avx2_harley_seal_popcount256:
  340|  3.60k|                                                    const uint64_t size) {
  341|  3.60k|    __m256i total = _mm256_setzero_si256();
  342|  3.60k|    __m256i ones = _mm256_setzero_si256();
  343|  3.60k|    __m256i twos = _mm256_setzero_si256();
  344|  3.60k|    __m256i fours = _mm256_setzero_si256();
  345|  3.60k|    __m256i eights = _mm256_setzero_si256();
  346|  3.60k|    __m256i sixteens = _mm256_setzero_si256();
  347|  3.60k|    __m256i twosA, twosB, foursA, foursB, eightsA, eightsB;
  348|       |
  349|  3.60k|    const uint64_t limit = size - size % 16;
  350|  3.60k|    uint64_t i = 0;
  351|       |
  352|  61.3k|    for (; i < limit; i += 16) {
  ------------------
  |  Branch (352:12): [True: 57.7k, False: 3.60k]
  ------------------
  353|  57.7k|        CSA(&twosA, &ones, ones, _mm256_lddqu_si256(data + i),
  354|  57.7k|            _mm256_lddqu_si256(data + i + 1));
  355|  57.7k|        CSA(&twosB, &ones, ones, _mm256_lddqu_si256(data + i + 2),
  356|  57.7k|            _mm256_lddqu_si256(data + i + 3));
  357|  57.7k|        CSA(&foursA, &twos, twos, twosA, twosB);
  358|  57.7k|        CSA(&twosA, &ones, ones, _mm256_lddqu_si256(data + i + 4),
  359|  57.7k|            _mm256_lddqu_si256(data + i + 5));
  360|  57.7k|        CSA(&twosB, &ones, ones, _mm256_lddqu_si256(data + i + 6),
  361|  57.7k|            _mm256_lddqu_si256(data + i + 7));
  362|  57.7k|        CSA(&foursB, &twos, twos, twosA, twosB);
  363|  57.7k|        CSA(&eightsA, &fours, fours, foursA, foursB);
  364|  57.7k|        CSA(&twosA, &ones, ones, _mm256_lddqu_si256(data + i + 8),
  365|  57.7k|            _mm256_lddqu_si256(data + i + 9));
  366|  57.7k|        CSA(&twosB, &ones, ones, _mm256_lddqu_si256(data + i + 10),
  367|  57.7k|            _mm256_lddqu_si256(data + i + 11));
  368|  57.7k|        CSA(&foursA, &twos, twos, twosA, twosB);
  369|  57.7k|        CSA(&twosA, &ones, ones, _mm256_lddqu_si256(data + i + 12),
  370|  57.7k|            _mm256_lddqu_si256(data + i + 13));
  371|  57.7k|        CSA(&twosB, &ones, ones, _mm256_lddqu_si256(data + i + 14),
  372|  57.7k|            _mm256_lddqu_si256(data + i + 15));
  373|  57.7k|        CSA(&foursB, &twos, twos, twosA, twosB);
  374|  57.7k|        CSA(&eightsB, &fours, fours, foursA, foursB);
  375|  57.7k|        CSA(&sixteens, &eights, eights, eightsA, eightsB);
  376|       |
  377|  57.7k|        total = _mm256_add_epi64(total, popcount256(sixteens));
  378|  57.7k|    }
  379|       |
  380|  3.60k|    total = _mm256_slli_epi64(total, 4);  // * 16
  381|  3.60k|    total = _mm256_add_epi64(
  382|  3.60k|        total, _mm256_slli_epi64(popcount256(eights), 3));  // += 8 * ...
  383|  3.60k|    total = _mm256_add_epi64(
  384|  3.60k|        total, _mm256_slli_epi64(popcount256(fours), 2));  // += 4 * ...
  385|  3.60k|    total = _mm256_add_epi64(
  386|  3.60k|        total, _mm256_slli_epi64(popcount256(twos), 1));  // += 2 * ...
  387|  3.60k|    total = _mm256_add_epi64(total, popcount256(ones));
  388|  3.60k|    for (; i < size; i++)
  ------------------
  |  Branch (388:12): [True: 0, False: 3.60k]
  ------------------
  389|      0|        total =
  390|      0|            _mm256_add_epi64(total, popcount256(_mm256_lddqu_si256(data + i)));
  391|       |
  392|  3.60k|    return (uint64_t)(_mm256_extract_epi64(total, 0)) +
  393|  3.60k|           (uint64_t)(_mm256_extract_epi64(total, 1)) +
  394|  3.60k|           (uint64_t)(_mm256_extract_epi64(total, 2)) +
  395|       |           (uint64_t)(_mm256_extract_epi64(total, 3));
  396|  3.60k|}
bitset.c:CSA:
  328|  1.60M|                       __m256i c) {
  329|  1.60M|    const __m256i u = _mm256_xor_si256(a, b);
  330|  1.60M|    *h = _mm256_or_si256(_mm256_and_si256(a, b), _mm256_and_si256(u, c));
  331|  1.60M|    *l = _mm256_xor_si256(u, c);
  332|  1.60M|}
bitset.c:popcount256:
  292|   134k|static inline __m256i popcount256(__m256i v) {
  293|   134k|    const __m256i lookuppos = _mm256_setr_epi8(
  294|   134k|        /* 0 */ 4 + 0, /* 1 */ 4 + 1, /* 2 */ 4 + 1, /* 3 */ 4 + 2,
  295|   134k|        /* 4 */ 4 + 1, /* 5 */ 4 + 2, /* 6 */ 4 + 2, /* 7 */ 4 + 3,
  296|   134k|        /* 8 */ 4 + 1, /* 9 */ 4 + 2, /* a */ 4 + 2, /* b */ 4 + 3,
  297|   134k|        /* c */ 4 + 2, /* d */ 4 + 3, /* e */ 4 + 3, /* f */ 4 + 4,
  298|       |
  299|       |        /* 0 */ 4 + 0, /* 1 */ 4 + 1, /* 2 */ 4 + 1, /* 3 */ 4 + 2,
  300|   134k|        /* 4 */ 4 + 1, /* 5 */ 4 + 2, /* 6 */ 4 + 2, /* 7 */ 4 + 3,
  301|   134k|        /* 8 */ 4 + 1, /* 9 */ 4 + 2, /* a */ 4 + 2, /* b */ 4 + 3,
  302|   134k|        /* c */ 4 + 2, /* d */ 4 + 3, /* e */ 4 + 3, /* f */ 4 + 4);
  303|   134k|    const __m256i lookupneg = _mm256_setr_epi8(
  304|   134k|        /* 0 */ 4 - 0, /* 1 */ 4 - 1, /* 2 */ 4 - 1, /* 3 */ 4 - 2,
  305|   134k|        /* 4 */ 4 - 1, /* 5 */ 4 - 2, /* 6 */ 4 - 2, /* 7 */ 4 - 3,
  306|   134k|        /* 8 */ 4 - 1, /* 9 */ 4 - 2, /* a */ 4 - 2, /* b */ 4 - 3,
  307|   134k|        /* c */ 4 - 2, /* d */ 4 - 3, /* e */ 4 - 3, /* f */ 4 - 4,
  308|       |
  309|       |        /* 0 */ 4 - 0, /* 1 */ 4 - 1, /* 2 */ 4 - 1, /* 3 */ 4 - 2,
  310|   134k|        /* 4 */ 4 - 1, /* 5 */ 4 - 2, /* 6 */ 4 - 2, /* 7 */ 4 - 3,
  311|   134k|        /* 8 */ 4 - 1, /* 9 */ 4 - 2, /* a */ 4 - 2, /* b */ 4 - 3,
  312|   134k|        /* c */ 4 - 2, /* d */ 4 - 3, /* e */ 4 - 3, /* f */ 4 - 4);
  313|   134k|    const __m256i low_mask = _mm256_set1_epi8(0x0f);
  314|       |
  315|   134k|    const __m256i lo = _mm256_and_si256(v, low_mask);
  316|   134k|    const __m256i hi = _mm256_and_si256(_mm256_srli_epi16(v, 4), low_mask);
  317|   134k|    const __m256i popcnt1 = _mm256_shuffle_epi8(lookuppos, lo);
  318|   134k|    const __m256i popcnt2 = _mm256_shuffle_epi8(lookupneg, hi);
  319|   134k|    return _mm256_sad_epu8(popcnt1, popcnt2);
  320|   134k|}
convert.c:bitset_set_lenrange:
  112|   112k|                                       uint32_t lenminusone) {
  113|   112k|    uint32_t firstword = start / 64;
  114|   112k|    uint32_t endword = (start + lenminusone) / 64;
  115|   112k|    if (firstword == endword) {
  ------------------
  |  Branch (115:9): [True: 37.7k, False: 74.6k]
  ------------------
  116|  37.7k|        words[firstword] |= ((~UINT64_C(0)) >> ((63 - lenminusone) % 64))
  117|  37.7k|                            << (start % 64);
  118|  37.7k|        return;
  119|  37.7k|    }
  120|  74.6k|    uint64_t temp = words[endword];
  121|  74.6k|    words[firstword] |= (~UINT64_C(0)) << (start % 64);
  122|  36.8M|    for (uint32_t i = firstword + 1; i < endword; i += 2)
  ------------------
  |  Branch (122:38): [True: 36.7M, False: 74.6k]
  ------------------
  123|  36.7M|        words[i] = words[i + 1] = ~UINT64_C(0);
  124|  74.6k|    words[endword] =
  125|       |        temp | (~UINT64_C(0)) >> (((~start + 1) - lenminusone - 1) % 64);
  126|  74.6k|}
mixed_intersection.c:bitset_lenrange_cardinality:
   63|   225k|                                              uint32_t lenminusone) {
   64|   225k|    uint32_t firstword = start / 64;
   65|   225k|    uint32_t endword = (start + lenminusone) / 64;
   66|   225k|    if (firstword == endword) {
  ------------------
  |  Branch (66:9): [True: 219k, False: 6.15k]
  ------------------
   67|   219k|        return roaring_hamming(words[firstword] &
   68|   219k|                               ((~UINT64_C(0)) >> ((63 - lenminusone) % 64))
   69|   219k|                                   << (start % 64));
   70|   219k|    }
   71|  6.15k|    int answer =
   72|  6.15k|        roaring_hamming(words[firstword] & ((~UINT64_C(0)) << (start % 64)));
   73|  6.44k|    for (uint32_t i = firstword + 1; i < endword; i++) {
  ------------------
  |  Branch (73:38): [True: 288, False: 6.15k]
  ------------------
   74|    288|        answer += roaring_hamming(words[i]);
   75|    288|    }
   76|  6.15k|    answer += roaring_hamming(words[endword] &
   77|       |                              (~UINT64_C(0)) >>
   78|  6.15k|                                  (((~start + 1) - lenminusone - 1) % 64));
   79|  6.15k|    return answer;
   80|   225k|}
mixed_intersection.c:bitset_lenrange_empty:
   86|  4.12k|                                         uint32_t lenminusone) {
   87|  4.12k|    uint32_t firstword = start / 64;
   88|  4.12k|    uint32_t endword = (start + lenminusone) / 64;
   89|  4.12k|    if (firstword == endword) {
  ------------------
  |  Branch (89:9): [True: 3.80k, False: 319]
  ------------------
   90|  3.80k|        return (words[firstword] & ((~UINT64_C(0)) >> ((63 - lenminusone) % 64))
   91|  3.80k|                                       << (start % 64)) == 0;
   92|  3.80k|    }
   93|    319|    if (((words[firstword] & ((~UINT64_C(0)) << (start % 64)))) != 0) {
  ------------------
  |  Branch (93:9): [True: 108, False: 211]
  ------------------
   94|    108|        return false;
   95|    108|    }
   96|    221|    for (uint32_t i = firstword + 1; i < endword; i++) {
  ------------------
  |  Branch (96:38): [True: 11, False: 210]
  ------------------
   97|     11|        if (words[i] != 0) {
  ------------------
  |  Branch (97:13): [True: 1, False: 10]
  ------------------
   98|      1|            return false;
   99|      1|        }
  100|     11|    }
  101|    210|    if ((words[endword] &
  ------------------
  |  Branch (101:9): [True: 119, False: 91]
  ------------------
  102|    210|         (~UINT64_C(0)) >> (((~start + 1) - lenminusone - 1) % 64)) != 0) {
  103|    119|        return false;
  104|    119|    }
  105|     91|    return true;
  106|    210|}
mixed_union.c:bitset_set_lenrange:
  112|   112k|                                       uint32_t lenminusone) {
  113|   112k|    uint32_t firstword = start / 64;
  114|   112k|    uint32_t endword = (start + lenminusone) / 64;
  115|   112k|    if (firstword == endword) {
  ------------------
  |  Branch (115:9): [True: 109k, False: 3.07k]
  ------------------
  116|   109k|        words[firstword] |= ((~UINT64_C(0)) >> ((63 - lenminusone) % 64))
  117|   109k|                            << (start % 64);
  118|   109k|        return;
  119|   109k|    }
  120|  3.07k|    uint64_t temp = words[endword];
  121|  3.07k|    words[firstword] |= (~UINT64_C(0)) << (start % 64);
  122|  3.18k|    for (uint32_t i = firstword + 1; i < endword; i += 2)
  ------------------
  |  Branch (122:38): [True: 106, False: 3.07k]
  ------------------
  123|    106|        words[i] = words[i + 1] = ~UINT64_C(0);
  124|  3.07k|    words[endword] =
  125|       |        temp | (~UINT64_C(0)) >> (((~start + 1) - lenminusone - 1) % 64);
  126|  3.07k|}
mixed_negation.c:bitset_flip_range:
  132|  1.57k|                                     uint32_t end) {
  133|  1.57k|    if (start == end) return;
  ------------------
  |  Branch (133:9): [True: 0, False: 1.57k]
  ------------------
  134|  1.57k|    uint32_t firstword = start / 64;
  135|  1.57k|    uint32_t endword = (end - 1) / 64;
  136|  1.57k|    words[firstword] ^= ~((~UINT64_C(0)) << (start % 64));
  137|   208k|    for (uint32_t i = firstword; i < endword; i++) {
  ------------------
  |  Branch (137:34): [True: 207k, False: 1.57k]
  ------------------
  138|   207k|        words[i] = ~words[i];
  139|   207k|    }
  140|       |    words[endword] ^= ((~UINT64_C(0)) >> ((~end + 1) % 64));
  141|  1.57k|}
mixed_xor.c:bitset_flip_range:
  132|  59.8k|                                     uint32_t end) {
  133|  59.8k|    if (start == end) return;
  ------------------
  |  Branch (133:9): [True: 0, False: 59.8k]
  ------------------
  134|  59.8k|    uint32_t firstword = start / 64;
  135|  59.8k|    uint32_t endword = (end - 1) / 64;
  136|  59.8k|    words[firstword] ^= ~((~UINT64_C(0)) << (start % 64));
  137|   127k|    for (uint32_t i = firstword; i < endword; i++) {
  ------------------
  |  Branch (137:34): [True: 67.5k, False: 59.8k]
  ------------------
  138|  67.5k|        words[i] = ~words[i];
  139|  67.5k|    }
  140|       |    words[endword] ^= ((~UINT64_C(0)) >> ((~end + 1) % 64));
  141|  59.8k|}

array_container_contains:
  343|  3.36k|                                     uint16_t pos) {
  344|       |    /**
  345|       |     * SIMD Quad algorithm
  346|       |     * Daniel Lemire, "You can beat the binary search," in Daniel Lemire's blog,
  347|       |     *  April 27, 2026,
  348|       |     * https://lemire.me/blog/2026/04/27/you-can-beat-the-binary-search/.
  349|       |     */
  350|  3.36k|    const int32_t gap = 16;
  351|  3.36k|    const uint16_t *carr = arr->array;
  352|  3.36k|    int32_t cardinality = arr->cardinality;
  353|  3.36k|    if (cardinality < gap) {
  ------------------
  |  Branch (353:9): [True: 946, False: 2.42k]
  ------------------
  354|  1.06k|        for (int32_t j = 0; j < cardinality; j++) {
  ------------------
  |  Branch (354:29): [True: 1.03k, False: 31]
  ------------------
  355|  1.03k|            if (carr[j] >= pos) return carr[j] == pos;
  ------------------
  |  Branch (355:17): [True: 915, False: 122]
  ------------------
  356|  1.03k|        }
  357|     31|        return false;
  358|    946|    }
  359|  2.42k|    int32_t num_blocks = cardinality / gap;
  360|  2.42k|    int32_t base = 0;
  361|  2.42k|    int32_t n = num_blocks;
  362|  5.65k|    while (n > 3) {
  ------------------
  |  Branch (362:12): [True: 3.23k, False: 2.42k]
  ------------------
  363|  3.23k|        int32_t quarter = n >> 2;
  364|       |
  365|  3.23k|        int32_t k1 = carr[(base + quarter + 1) * gap - 1];
  366|  3.23k|        int32_t k2 = carr[(base + 2 * quarter + 1) * gap - 1];
  367|  3.23k|        int32_t k3 = carr[(base + 3 * quarter + 1) * gap - 1];
  368|       |
  369|  3.23k|        int32_t c1 = (k1 < pos);
  370|  3.23k|        int32_t c2 = (k2 < pos);
  371|  3.23k|        int32_t c3 = (k3 < pos);
  372|       |
  373|  3.23k|        base += (c1 + c2 + c3) * quarter;
  374|  3.23k|        n -= 3 * quarter;
  375|  3.23k|    }
  376|  4.28k|    while (n > 1) {
  ------------------
  |  Branch (376:12): [True: 1.86k, False: 2.42k]
  ------------------
  377|  1.86k|        int32_t half = n >> 1;
  378|  1.86k|        base = (carr[(base + half + 1) * gap - 1] < pos) ? base + half : base;
  ------------------
  |  Branch (378:16): [True: 72, False: 1.79k]
  ------------------
  379|  1.86k|        n -= half;
  380|  1.86k|    }
  381|  2.42k|    int32_t lo = (carr[(base + 1) * gap - 1] < pos) ? base + 1 : base;
  ------------------
  |  Branch (381:18): [True: 112, False: 2.30k]
  ------------------
  382|       |
  383|  2.42k|    if (lo < num_blocks) {
  ------------------
  |  Branch (383:9): [True: 2.34k, False: 78]
  ------------------
  384|  2.34k|        const uint16_t *blk = carr + lo * gap;
  385|       |#ifdef CROARING_USENEON
  386|       |        uint16x8_t needle = vdupq_n_u16(pos);
  387|       |        uint16x8_t v0 = vld1q_u16(blk);
  388|       |        uint16x8_t v1 = vld1q_u16(blk + 8);
  389|       |        uint16x8_t hit =
  390|       |            vorrq_u16(vceqq_u16(v0, needle), vceqq_u16(v1, needle));
  391|       |        return vmaxvq_u16(hit) != 0;
  392|       |#elif defined(CROARING_IS_X64)
  393|       |        __m128i needle = _mm_set1_epi16((short)pos);
  394|  2.34k|        __m128i v0 = _mm_loadu_si128((const __m128i *)blk);
  395|  2.34k|        __m128i v1 = _mm_loadu_si128((const __m128i *)(blk + 8));
  396|  2.34k|        __m128i hit = _mm_or_si128(_mm_cmpeq_epi16(v0, needle),
  397|  2.34k|                                   _mm_cmpeq_epi16(v1, needle));
  398|  2.34k|        return _mm_movemask_epi8(hit) != 0;
  399|       |#else
  400|       |        for (int32_t j = 0; j < gap; j++) {
  401|       |            if (blk[j] >= pos) return blk[j] == pos;
  402|       |        }
  403|       |        return false;
  404|       |#endif
  405|  2.34k|    }
  406|       |
  407|    606|    for (int32_t j = num_blocks * gap; j < cardinality; j++) {
  ------------------
  |  Branch (407:40): [True: 556, False: 50]
  ------------------
  408|    556|        uint16_t v = carr[j];
  409|    556|        if (v >= pos) return (v == pos);
  ------------------
  |  Branch (409:13): [True: 28, False: 528]
  ------------------
  410|    556|    }
  411|     50|    return false;
  412|     78|}
array_container_minimum:
  445|  3.63k|inline uint16_t array_container_minimum(const array_container_t *arr) {
  446|  3.63k|    if (arr->cardinality == 0) return 0;
  ------------------
  |  Branch (446:9): [True: 0, False: 3.63k]
  ------------------
  447|  3.63k|    return arr->array[0];
  448|  3.63k|}
array_container_maximum:
  451|  13.3k|inline uint16_t array_container_maximum(const array_container_t *arr) {
  452|  13.3k|    if (arr->cardinality == 0) return 0;
  ------------------
  |  Branch (452:9): [True: 0, False: 13.3k]
  ------------------
  453|  13.3k|    return arr->array[arr->cardinality - 1];
  454|  13.3k|}
array_container_rank:
  457|  3.80k|inline int array_container_rank(const array_container_t *arr, uint16_t x) {
  458|  3.80k|    const int32_t idx = binarySearch(arr->array, arr->cardinality, x);
  459|  3.80k|    const bool is_present = idx >= 0;
  460|  3.80k|    if (is_present) {
  ------------------
  |  Branch (460:9): [True: 3.25k, False: 553]
  ------------------
  461|  3.25k|        return idx + 1;
  462|  3.25k|    } else {
  463|    553|        return -idx - 1;
  464|    553|    }
  465|  3.80k|}
array_container_index_equalorlarger:
  507|  4.46k|                                               uint16_t x) {
  508|  4.46k|    const int32_t idx = binarySearch(arr->array, arr->cardinality, x);
  509|  4.46k|    const bool is_present = idx >= 0;
  510|  4.46k|    if (is_present) {
  ------------------
  |  Branch (510:9): [True: 4.06k, False: 407]
  ------------------
  511|  4.06k|        return idx;
  512|  4.06k|    } else {
  513|    407|        int32_t candidate = -idx - 1;
  514|    407|        if (candidate < arr->cardinality) return candidate;
  ------------------
  |  Branch (514:13): [True: 407, False: 0]
  ------------------
  515|      0|        return -1;
  516|    407|    }
  517|  4.46k|}
roaring.c:array_container_add_range_nvals:
  527|    645|                                                   int32_t nvals_greater) {
  528|    645|    int32_t union_cardinality = nvals_less + (max - min + 1) + nvals_greater;
  529|    645|    if (union_cardinality > array->capacity) {
  ------------------
  |  Branch (529:9): [True: 599, False: 46]
  ------------------
  530|    599|        array_container_grow(array, union_cardinality, true);
  531|    599|    }
  532|    645|    memmove(&(array->array[union_cardinality - nvals_greater]),
  533|    645|            &(array->array[array->cardinality - nvals_greater]),
  534|    645|            nvals_greater * sizeof(uint16_t));
  535|  1.56M|    for (uint32_t i = 0; i <= max - min; i++) {
  ------------------
  |  Branch (535:26): [True: 1.56M, False: 645]
  ------------------
  536|  1.56M|        array->array[nvals_less + i] = (uint16_t)(min + i);
  537|  1.56M|    }
  538|    645|    array->cardinality = union_cardinality;
  539|    645|}
roaring.c:array_container_remove_range:
  557|  3.23k|                                                uint32_t pos, uint32_t count) {
  558|  3.23k|    if (count != 0) {
  ------------------
  |  Branch (558:9): [True: 314, False: 2.92k]
  ------------------
  559|    314|        memmove(&(array->array[pos]), &(array->array[pos + count]),
  560|    314|                (array->cardinality - pos - count) * sizeof(uint16_t));
  561|    314|        array->cardinality -= count;
  562|    314|    }
  563|  3.23k|}
roaring.c:array_container_cardinality:
   82|  72.4k|static inline int array_container_cardinality(const array_container_t *array) {
   83|  72.4k|    return array->cardinality;
   84|  72.4k|}
roaring.c:array_container_try_add:
  293|  7.39M|                                          int32_t max_cardinality) {
  294|  7.39M|    const int32_t cardinality = arr->cardinality;
  295|       |
  296|       |    // best case, we can append.
  297|  7.39M|    if ((array_container_empty(arr) || arr->array[cardinality - 1] < value) &&
  ------------------
  |  Branch (297:10): [True: 16.3k, False: 7.37M]
  |  Branch (297:40): [True: 52.4k, False: 7.32M]
  ------------------
  298|  68.8k|        cardinality < max_cardinality) {
  ------------------
  |  Branch (298:9): [True: 68.8k, False: 0]
  ------------------
  299|  68.8k|        array_container_append(arr, value);
  300|  68.8k|        return 1;
  301|  68.8k|    }
  302|       |
  303|  7.32M|    const int32_t loc = binarySearch(arr->array, cardinality, value);
  304|       |
  305|  7.32M|    if (loc >= 0) {
  ------------------
  |  Branch (305:9): [True: 5.56M, False: 1.75M]
  ------------------
  306|  5.56M|        return 0;
  307|  5.56M|    } else if (cardinality < max_cardinality) {
  ------------------
  |  Branch (307:16): [True: 1.75M, False: 131]
  ------------------
  308|  1.75M|        if (array_container_full(arr)) {
  ------------------
  |  Branch (308:13): [True: 78.1k, False: 1.67M]
  ------------------
  309|  78.1k|            array_container_grow(arr, arr->capacity + 1, true);
  310|  78.1k|        }
  311|  1.75M|        const int32_t insert_idx = -loc - 1;
  312|  1.75M|        memmove(arr->array + insert_idx + 1, arr->array + insert_idx,
  313|  1.75M|                (cardinality - insert_idx) * sizeof(uint16_t));
  314|  1.75M|        arr->array[insert_idx] = value;
  315|  1.75M|        arr->cardinality++;
  316|  1.75M|        return 1;
  317|  1.75M|    } else {
  318|    131|        return -1;
  319|    131|    }
  320|  7.32M|}
roaring.c:array_container_empty:
  100|  7.39M|static inline bool array_container_empty(const array_container_t *array) {
  101|  7.39M|    return array->cardinality == 0;
  102|  7.39M|}
roaring.c:array_container_append:
  274|  68.8k|                                          uint16_t pos) {
  275|  68.8k|    const int32_t capacity = arr->capacity;
  276|       |
  277|  68.8k|    if (array_container_full(arr)) {
  ------------------
  |  Branch (277:9): [True: 32.9k, False: 35.9k]
  ------------------
  278|  32.9k|        array_container_grow(arr, capacity + 1, true);
  279|  32.9k|    }
  280|       |
  281|  68.8k|    arr->array[arr->cardinality++] = pos;
  282|  68.8k|}
roaring.c:array_container_full:
  106|  1.82M|static inline bool array_container_full(const array_container_t *array) {
  107|  1.82M|    return array->cardinality == array->capacity;
  108|  1.82M|}
roaring.c:array_container_remove:
  329|  6.21k|                                          uint16_t pos) {
  330|  6.21k|    const int32_t idx = binarySearch(arr->array, arr->cardinality, pos);
  331|  6.21k|    const bool is_present = idx >= 0;
  332|  6.21k|    if (is_present) {
  ------------------
  |  Branch (332:9): [True: 3.11k, False: 3.09k]
  ------------------
  333|  3.11k|        memmove(arr->array + idx, arr->array + idx + 1,
  334|  3.11k|                (arr->cardinality - idx - 1) * sizeof(uint16_t));
  335|  3.11k|        arr->cardinality--;
  336|  3.11k|    }
  337|       |
  338|  6.21k|    return is_present;
  339|  6.21k|}
roaring.c:array_container_nonzero_cardinality:
   87|   107k|    const array_container_t *array) {
   88|   107k|    return array->cardinality > 0;
   89|   107k|}
roaring.c:array_container_equals:
  230|  9.61k|                                          const array_container_t *container2) {
  231|  9.61k|    if (container1->cardinality != container2->cardinality) {
  ------------------
  |  Branch (231:9): [True: 2.26k, False: 7.34k]
  ------------------
  232|  2.26k|        return false;
  233|  2.26k|    }
  234|  7.34k|    return memequals(container1->array, container2->array,
  235|  7.34k|                     container1->cardinality * 2);
  236|  9.61k|}
roaring.c:array_container_select:
  252|  3.80k|                                          uint32_t *element) {
  253|  3.80k|    int card = array_container_cardinality(container);
  254|  3.80k|    if (*start_rank + card <= rank) {
  ------------------
  |  Branch (254:9): [True: 321, False: 3.48k]
  ------------------
  255|    321|        *start_rank += card;
  256|    321|        return false;
  257|  3.48k|    } else {
  258|  3.48k|        *element = container->array[rank - *start_rank];
  259|       |        return true;
  260|  3.48k|    }
  261|  3.80k|}
roaring.c:array_container_contains_range:
  421|    122|                                                  uint32_t range_end) {
  422|    122|    const int32_t range_count = range_end - range_start;
  423|    122|    const uint16_t rs_included = (uint16_t)range_start;
  424|    122|    const uint16_t re_included = (uint16_t)(range_end - 1);
  425|       |
  426|       |    // Empty range is always included
  427|    122|    if (range_count <= 0) {
  ------------------
  |  Branch (427:9): [True: 0, False: 122]
  ------------------
  428|      0|        return true;
  429|      0|    }
  430|    122|    if (range_count > arr->cardinality) {
  ------------------
  |  Branch (430:9): [True: 53, False: 69]
  ------------------
  431|     53|        return false;
  432|     53|    }
  433|       |
  434|     69|    const int32_t start =
  435|     69|        binarySearch(arr->array, arr->cardinality, rs_included);
  436|       |    // If this sorted array contains all items in the range:
  437|       |    // * the start item must be found
  438|       |    // * the last item in range range_count must exist, and be the expected end
  439|       |    // value
  440|     69|    return (start >= 0) && (arr->cardinality >= start + range_count) &&
  ------------------
  |  Branch (440:12): [True: 45, False: 24]
  |  Branch (440:28): [True: 40, False: 5]
  ------------------
  441|     40|           (arr->array[start + range_count - 1] == re_included);
  ------------------
  |  Branch (441:12): [True: 12, False: 28]
  ------------------
  442|    122|}
roaring_array.c:array_container_size_in_bytes:
  221|  18.2k|    const array_container_t *container) {
  222|  18.2k|    return container->cardinality * sizeof(uint16_t);
  223|  18.2k|}
roaring_array.c:array_container_cardinality:
   82|  7.20k|static inline int array_container_cardinality(const array_container_t *array) {
   83|  7.20k|    return array->cardinality;
   84|  7.20k|}
array.c:array_container_size_in_bytes:
  221|  14.4k|    const array_container_t *container) {
  222|  14.4k|    return container->cardinality * sizeof(uint16_t);
  223|  14.4k|}
convert.c:array_container_cardinality:
   82|  15.3k|static inline int array_container_cardinality(const array_container_t *array) {
   83|  15.3k|    return array->cardinality;
   84|  15.3k|}
convert.c:array_container_serialized_size_in_bytes:
  173|   154k|static inline int32_t array_container_serialized_size_in_bytes(int32_t card) {
  174|   154k|    return card * sizeof(uint16_t);
  175|   154k|}
mixed_intersection.c:array_container_empty:
  100|     34|static inline bool array_container_empty(const array_container_t *array) {
  101|     34|    return array->cardinality == 0;
  102|     34|}
mixed_andnot.c:array_container_cardinality:
   82|    381|static inline int array_container_cardinality(const array_container_t *array) {
   83|    381|    return array->cardinality;
   84|    381|}

bitset_container_get:
  193|  1.12M|                                 uint16_t pos) {
  194|  1.12M|    const uint64_t word = bitset->words[pos >> 6];
  195|  1.12M|    return (word >> (pos & 63)) & 1;
  196|  1.12M|}
bitset_container_contains:
  232|   974k|                                      uint16_t pos) {
  233|   974k|    return bitset_container_get(bitset, pos);
  234|   974k|}
roaring.c:bitset_container_cardinality:
  248|  11.3k|    const bitset_container_t *bitset) {
  249|  11.3k|    return bitset->cardinality;
  250|  11.3k|}
roaring.c:bitset_container_set:
  147|   326k|                                        uint16_t pos) {
  148|   326k|    const uint64_t old_word = bitset->words[pos >> 6];
  149|   326k|    const int index = pos & 63;
  150|       |    const uint64_t new_word = old_word | (UINT64_C(1) << index);
  151|   326k|    bitset->cardinality += (uint32_t)((old_word ^ new_word) >> index);
  152|   326k|    bitset->words[pos >> 6] = new_word;
  153|   326k|}
roaring.c:bitset_container_add:
  168|    131|                                        uint16_t pos) {
  169|    131|    const uint64_t old_word = bitset->words[pos >> 6];
  170|    131|    const int index = pos & 63;
  171|       |    const uint64_t new_word = old_word | (UINT64_C(1) << index);
  172|    131|    const uint64_t increment = (old_word ^ new_word) >> index;
  173|    131|    bitset->cardinality += (uint32_t)increment;
  174|    131|    bitset->words[pos >> 6] = new_word;
  175|    131|    return increment > 0;
  176|    131|}
roaring.c:bitset_container_remove:
  181|  2.32k|                                           uint16_t pos) {
  182|  2.32k|    const uint64_t old_word = bitset->words[pos >> 6];
  183|  2.32k|    const int index = pos & 63;
  184|       |    const uint64_t new_word = old_word & (~(UINT64_C(1) << index));
  185|  2.32k|    const uint64_t increment = (old_word ^ new_word) >> index;
  186|  2.32k|    bitset->cardinality -= (uint32_t)increment;
  187|  2.32k|    bitset->words[pos >> 6] = new_word;
  188|  2.32k|    return increment > 0;
  189|  2.32k|}
roaring.c:bitset_container_const_nonzero_cardinality:
  281|  7.16k|    const bitset_container_t *bitset) {
  282|  7.16k|    return !bitset_container_empty(bitset);
  283|  7.16k|}
roaring.c:bitset_container_empty:
  268|  7.16k|static inline bool bitset_container_empty(const bitset_container_t *bitset) {
  269|  7.16k|    if (bitset->cardinality == BITSET_UNKNOWN_CARDINALITY) {
  ------------------
  |  Branch (269:9): [True: 0, False: 7.16k]
  ------------------
  270|      0|        for (int i = 0; i < BITSET_CONTAINER_SIZE_IN_WORDS; i++) {
  ------------------
  |  Branch (270:25): [True: 0, False: 0]
  ------------------
  271|      0|            if ((bitset->words[i]) != 0) return false;
  ------------------
  |  Branch (271:17): [True: 0, False: 0]
  ------------------
  272|      0|        }
  273|      0|        return true;
  274|      0|    }
  275|  7.16k|    return bitset->cardinality == 0;
  276|  7.16k|}
roaring.c:bitset_container_get_range:
  206|    263|                                              uint32_t pos_end) {
  207|    263|    const uint32_t start = pos_start >> 6;
  208|    263|    const uint32_t end = pos_end >> 6;
  209|       |
  210|    263|    const uint64_t first = ~((1ULL << (pos_start & 0x3F)) - 1);
  211|    263|    const uint64_t last = (1ULL << (pos_end & 0x3F)) - 1;
  212|       |
  213|    263|    if (start == end)
  ------------------
  |  Branch (213:9): [True: 60, False: 203]
  ------------------
  214|     60|        return ((bitset->words[end] & first & last) == (first & last));
  215|    203|    if ((bitset->words[start] & first) != first) return false;
  ------------------
  |  Branch (215:9): [True: 75, False: 128]
  ------------------
  216|       |
  217|    128|    if ((end < BITSET_CONTAINER_SIZE_IN_WORDS) &&
  ------------------
  |  Branch (217:9): [True: 113, False: 15]
  ------------------
  218|    113|        ((bitset->words[end] & last) != last)) {
  ------------------
  |  Branch (218:9): [True: 96, False: 17]
  ------------------
  219|     96|        return false;
  220|     96|    }
  221|       |
  222|     32|    for (uint32_t i = start + 1;
  223|  9.23k|         (i < BITSET_CONTAINER_SIZE_IN_WORDS) && (i < end); ++i) {
  ------------------
  |  Branch (223:10): [True: 9.23k, False: 7]
  |  Branch (223:50): [True: 9.21k, False: 14]
  ------------------
  224|  9.21k|        if (bitset->words[i] != UINT64_C(0xFFFFFFFFFFFFFFFF)) return false;
  ------------------
  |  Branch (224:13): [True: 11, False: 9.20k]
  ------------------
  225|  9.21k|    }
  226|       |
  227|     21|    return true;
  228|     32|}
roaring_array.c:bitset_container_size_in_bytes:
  468|   147k|    const bitset_container_t *container) {
  469|   147k|    (void)container;
  470|   147k|    return BITSET_CONTAINER_SIZE_IN_WORDS * sizeof(uint64_t);
  471|   147k|}
roaring_array.c:bitset_container_cardinality:
  248|  73.9k|    const bitset_container_t *bitset) {
  249|  73.9k|    return bitset->cardinality;
  250|  73.9k|}
bitset.c:bitset_container_size_in_bytes:
  468|   147k|    const bitset_container_t *container) {
  469|   147k|    (void)container;
  470|   147k|    return BITSET_CONTAINER_SIZE_IN_WORDS * sizeof(uint64_t);
  471|   147k|}
convert.c:bitset_container_set:
  147|  2.46M|                                        uint16_t pos) {
  148|  2.46M|    const uint64_t old_word = bitset->words[pos >> 6];
  149|  2.46M|    const int index = pos & 63;
  150|       |    const uint64_t new_word = old_word | (UINT64_C(1) << index);
  151|  2.46M|    bitset->cardinality += (uint32_t)((old_word ^ new_word) >> index);
  152|  2.46M|    bitset->words[pos >> 6] = new_word;
  153|  2.46M|}
convert.c:bitset_container_serialized_size_in_bytes:
  427|   141k|static inline int32_t bitset_container_serialized_size_in_bytes(void) {
  428|   141k|    return BITSET_CONTAINER_SIZE_IN_WORDS * 8;
  429|   141k|}

container_iterator_next:
 2456|   335k|                                    uint16_t *value) {
 2457|   335k|    switch (typecode) {
 2458|      0|        case BITSET_CONTAINER_TYPE: {
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2458:9): [True: 0, False: 335k]
  ------------------
 2459|      0|            const bitset_container_t *bc = const_CAST_bitset(c);
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2460|      0|            it->index++;
 2461|       |
 2462|      0|            uint32_t wordindex = it->index / 64;
 2463|      0|            if (wordindex >= BITSET_CONTAINER_SIZE_IN_WORDS) {
  ------------------
  |  Branch (2463:17): [True: 0, False: 0]
  ------------------
 2464|      0|                return false;
 2465|      0|            }
 2466|       |
 2467|      0|            uint64_t word =
 2468|      0|                bc->words[wordindex] & (UINT64_MAX << (it->index % 64));
 2469|       |            // next part could be optimized/simplified
 2470|      0|            while (word == 0 &&
  ------------------
  |  Branch (2470:20): [True: 0, False: 0]
  ------------------
 2471|      0|                   (wordindex + 1 < BITSET_CONTAINER_SIZE_IN_WORDS)) {
  ------------------
  |  Branch (2471:20): [True: 0, False: 0]
  ------------------
 2472|      0|                wordindex++;
 2473|      0|                word = bc->words[wordindex];
 2474|      0|            }
 2475|      0|            if (word != 0) {
  ------------------
  |  Branch (2475:17): [True: 0, False: 0]
  ------------------
 2476|      0|                it->index = wordindex * 64 + roaring_trailing_zeroes(word);
 2477|      0|                *value = it->index;
 2478|      0|                return true;
 2479|      0|            }
 2480|      0|            return false;
 2481|      0|        }
 2482|   293k|        case ARRAY_CONTAINER_TYPE: {
  ------------------
  |  |   49|   293k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2482:9): [True: 293k, False: 42.2k]
  ------------------
 2483|   293k|            const array_container_t *ac = const_CAST_array(c);
  ------------------
  |  |   55|   293k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|   293k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2484|   293k|            it->index++;
 2485|   293k|            if (it->index < ac->cardinality) {
  ------------------
  |  Branch (2485:17): [True: 287k, False: 5.72k]
  ------------------
 2486|   287k|                *value = ac->array[it->index];
 2487|   287k|                return true;
 2488|   287k|            }
 2489|  5.72k|            return false;
 2490|   293k|        }
 2491|  42.2k|        case RUN_CONTAINER_TYPE: {
  ------------------
  |  |   50|  42.2k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2491:9): [True: 42.2k, False: 293k]
  ------------------
 2492|  42.2k|            if (*value == UINT16_MAX) {  // Avoid overflow to zero
  ------------------
  |  Branch (2492:17): [True: 0, False: 42.2k]
  ------------------
 2493|      0|                return false;
 2494|      0|            }
 2495|       |
 2496|  42.2k|            const run_container_t *rc = const_CAST_run(c);
  ------------------
  |  |   78|  42.2k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  42.2k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2497|  42.2k|            uint32_t limit =
 2498|  42.2k|                rc->runs[it->index].value + rc->runs[it->index].length;
 2499|  42.2k|            if (*value < limit) {
  ------------------
  |  Branch (2499:17): [True: 26.9k, False: 15.3k]
  ------------------
 2500|  26.9k|                (*value)++;
 2501|  26.9k|                return true;
 2502|  26.9k|            }
 2503|       |
 2504|  15.3k|            it->index++;
 2505|  15.3k|            if (it->index < rc->n_runs) {
  ------------------
  |  Branch (2505:17): [True: 14.8k, False: 503]
  ------------------
 2506|  14.8k|                *value = rc->runs[it->index].value;
 2507|  14.8k|                return true;
 2508|  14.8k|            }
 2509|    503|            return false;
 2510|  15.3k|        }
 2511|      0|        default:
  ------------------
  |  Branch (2511:9): [True: 0, False: 335k]
  ------------------
 2512|      0|            assert(false);
 2513|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2514|      0|            return false;
 2515|   335k|    }
 2516|   335k|}
roaring.c:container_from_range:
  317|  73.2k|                                                uint32_t max, uint16_t step) {
  318|  73.2k|    if (step == 0) return NULL;  // being paranoid
  ------------------
  |  Branch (318:9): [True: 0, False: 73.2k]
  ------------------
  319|  73.2k|    if (step == 1) {
  ------------------
  |  Branch (319:9): [True: 73.2k, False: 0]
  ------------------
  320|  73.2k|        return container_range_of_ones(min, max, type);
  321|       |        // Note: the result is not always a run (need to check the cardinality)
  322|       |        //*type = RUN_CONTAINER_TYPE;
  323|       |        // return run_container_create_range(min, max);
  324|  73.2k|    }
  325|      0|    int size = (max - min + step - 1) / step;
  326|      0|    if (size <= DEFAULT_MAX_SIZE) {  // array container
  ------------------
  |  Branch (326:9): [True: 0, False: 0]
  ------------------
  327|      0|        *type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  328|      0|        array_container_t *array = array_container_create_given_capacity(size);
  329|      0|        array_container_add_from_range(array, min, max, step);
  330|      0|        assert(array->cardinality == size);
  331|      0|        return array;
  332|      0|    } else {  // bitset container
  333|      0|        *type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  334|      0|        bitset_container_t *bitset = bitset_container_create();
  335|      0|        bitset_container_add_from_range(bitset, min, max, step);
  336|       |        assert(bitset->cardinality == size);
  337|      0|        return bitset;
  338|      0|    }
  339|      0|}
roaring.c:container_range_of_ones:
  302|  91.5k|                                                   uint8_t *result_type) {
  303|  91.5k|    assert(range_end >= range_start);
  304|  91.5k|    uint64_t cardinality = range_end - range_start + 1;
  305|  91.5k|    if (cardinality <= 2) {
  ------------------
  |  Branch (305:9): [True: 144, False: 91.3k]
  ------------------
  306|    144|        *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    144|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  307|    144|        return array_container_create_range(range_start, range_end);
  308|  91.3k|    } else {
  309|  91.3k|        *result_type = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|  91.3k|#define RUN_CONTAINER_TYPE 3
  ------------------
  310|  91.3k|        return run_container_create_range(range_start, range_end);
  311|  91.3k|    }
  312|  91.5k|}
roaring.c:container_add_range:
 2282|  3.34k|                                               uint8_t *result_type) {
 2283|       |    // NB: when selecting new container type, we perform only inexpensive checks
 2284|  3.34k|    switch (type) {
 2285|      0|        case BITSET_CONTAINER_TYPE: {
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2285:9): [True: 0, False: 3.34k]
  ------------------
 2286|      0|            bitset_container_t *bitset = CAST_bitset(c);
  ------------------
  |  |   52|      0|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2287|       |
 2288|      0|            int32_t union_cardinality = 0;
 2289|      0|            union_cardinality += bitset->cardinality;
 2290|      0|            union_cardinality += max - min + 1;
 2291|      0|            union_cardinality -=
 2292|      0|                bitset_lenrange_cardinality(bitset->words, min, max - min);
 2293|       |
 2294|      0|            if (union_cardinality == INT32_C(0x10000)) {
  ------------------
  |  Branch (2294:17): [True: 0, False: 0]
  ------------------
 2295|      0|                *result_type = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
 2296|      0|                return run_container_create_range(0, INT32_C(0x10000));
 2297|      0|            } else {
 2298|      0|                *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 2299|      0|                bitset_set_lenrange(bitset->words, min, max - min);
 2300|      0|                bitset->cardinality = union_cardinality;
 2301|      0|                return bitset;
 2302|      0|            }
 2303|      0|        }
 2304|  2.88k|        case ARRAY_CONTAINER_TYPE: {
  ------------------
  |  |   49|  2.88k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2304:9): [True: 2.88k, False: 462]
  ------------------
 2305|  2.88k|            array_container_t *array = CAST_array(c);
  ------------------
  |  |   54|  2.88k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  2.88k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2306|       |
 2307|  2.88k|            int32_t nvals_greater =
 2308|  2.88k|                count_greater(array->array, array->cardinality, (uint16_t)max);
 2309|  2.88k|            int32_t nvals_less =
 2310|  2.88k|                count_less(array->array, array->cardinality - nvals_greater,
 2311|  2.88k|                           (uint16_t)min);
 2312|  2.88k|            int32_t union_cardinality =
 2313|  2.88k|                nvals_less + (max - min + 1) + nvals_greater;
 2314|       |
 2315|  2.88k|            if (union_cardinality == INT32_C(0x10000)) {
  ------------------
  |  Branch (2315:17): [True: 696, False: 2.18k]
  ------------------
 2316|    696|                *result_type = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|    696|#define RUN_CONTAINER_TYPE 3
  ------------------
 2317|    696|                return run_container_create_range(0, INT32_C(0x10000));
 2318|  2.18k|            } else if (union_cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (2318:24): [True: 645, False: 1.54k]
  ------------------
 2319|    645|                *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    645|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 2320|    645|                array_container_add_range_nvals(array, min, max, nvals_less,
 2321|    645|                                                nvals_greater);
 2322|    645|                return array;
 2323|  1.54k|            } else {
 2324|  1.54k|                *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|  1.54k|#define BITSET_CONTAINER_TYPE 1
  ------------------
 2325|  1.54k|                bitset_container_t *bitset = bitset_container_from_array(array);
 2326|  1.54k|                bitset_set_lenrange(bitset->words, min, max - min);
 2327|  1.54k|                bitset->cardinality = union_cardinality;
 2328|  1.54k|                return bitset;
 2329|  1.54k|            }
 2330|  2.88k|        }
 2331|    462|        case RUN_CONTAINER_TYPE: {
  ------------------
  |  |   50|    462|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2331:9): [True: 462, False: 2.88k]
  ------------------
 2332|    462|            run_container_t *run = CAST_run(c);
  ------------------
  |  |   77|    462|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    462|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2333|       |
 2334|    462|            int32_t nruns_greater =
 2335|    462|                rle16_count_greater(run->runs, run->n_runs, (uint16_t)max);
 2336|    462|            int32_t nruns_less = rle16_count_less(
 2337|    462|                run->runs, run->n_runs - nruns_greater, (uint16_t)min);
 2338|       |
 2339|    462|            int32_t run_size_bytes =
 2340|    462|                (nruns_less + 1 + nruns_greater) * sizeof(rle16_t);
 2341|    462|            int32_t bitset_size_bytes =
 2342|    462|                BITSET_CONTAINER_SIZE_IN_WORDS * sizeof(uint64_t);
 2343|       |
 2344|    462|            if (run_size_bytes <= bitset_size_bytes) {
  ------------------
  |  Branch (2344:17): [True: 462, False: 0]
  ------------------
 2345|    462|                run_container_add_range_nruns(run, min, max, nruns_less,
 2346|    462|                                              nruns_greater);
 2347|    462|                *result_type = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|    462|#define RUN_CONTAINER_TYPE 3
  ------------------
 2348|    462|                return run;
 2349|    462|            } else {
 2350|      0|                return container_from_run_range(run, min, max, result_type);
 2351|      0|            }
 2352|    462|        }
 2353|      0|        default:
  ------------------
  |  Branch (2353:9): [True: 0, False: 3.34k]
  ------------------
 2354|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2355|  3.34k|    }
 2356|  3.34k|}
roaring.c:container_remove_range:
 2371|  20.0k|                                                  uint8_t *result_type) {
 2372|  20.0k|    switch (type) {
 2373|  1.31k|        case BITSET_CONTAINER_TYPE: {
  ------------------
  |  |   48|  1.31k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2373:9): [True: 1.31k, False: 18.7k]
  ------------------
 2374|  1.31k|            bitset_container_t *bitset = CAST_bitset(c);
  ------------------
  |  |   52|  1.31k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.31k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2375|       |
 2376|  1.31k|            int32_t result_cardinality =
 2377|  1.31k|                bitset->cardinality -
 2378|  1.31k|                bitset_lenrange_cardinality(bitset->words, min, max - min);
 2379|       |
 2380|  1.31k|            if (result_cardinality == 0) {
  ------------------
  |  Branch (2380:17): [True: 32, False: 1.28k]
  ------------------
 2381|     32|                return NULL;
 2382|  1.28k|            } else if (result_cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (2382:24): [True: 110, False: 1.17k]
  ------------------
 2383|    110|                *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    110|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 2384|    110|                bitset_reset_range(bitset->words, min, max + 1);
 2385|    110|                bitset->cardinality = result_cardinality;
 2386|    110|                return array_container_from_bitset(bitset);
 2387|  1.17k|            } else {
 2388|  1.17k|                *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|  1.17k|#define BITSET_CONTAINER_TYPE 1
  ------------------
 2389|  1.17k|                bitset_reset_range(bitset->words, min, max + 1);
 2390|  1.17k|                bitset->cardinality = result_cardinality;
 2391|  1.17k|                return bitset;
 2392|  1.17k|            }
 2393|  1.31k|        }
 2394|  3.59k|        case ARRAY_CONTAINER_TYPE: {
  ------------------
  |  |   49|  3.59k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2394:9): [True: 3.59k, False: 16.4k]
  ------------------
 2395|  3.59k|            array_container_t *array = CAST_array(c);
  ------------------
  |  |   54|  3.59k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  3.59k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2396|       |
 2397|  3.59k|            int32_t nvals_greater =
 2398|  3.59k|                count_greater(array->array, array->cardinality, (uint16_t)max);
 2399|  3.59k|            int32_t nvals_less =
 2400|  3.59k|                count_less(array->array, array->cardinality - nvals_greater,
 2401|  3.59k|                           (uint16_t)min);
 2402|  3.59k|            int32_t result_cardinality = nvals_less + nvals_greater;
 2403|       |
 2404|  3.59k|            if (result_cardinality == 0) {
  ------------------
  |  Branch (2404:17): [True: 360, False: 3.23k]
  ------------------
 2405|    360|                return NULL;
 2406|  3.23k|            } else {
 2407|  3.23k|                *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  3.23k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 2408|  3.23k|                array_container_remove_range(
 2409|  3.23k|                    array, nvals_less, array->cardinality - result_cardinality);
 2410|  3.23k|                return array;
 2411|  3.23k|            }
 2412|  3.59k|        }
 2413|  15.1k|        case RUN_CONTAINER_TYPE: {
  ------------------
  |  |   50|  15.1k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2413:9): [True: 15.1k, False: 4.91k]
  ------------------
 2414|  15.1k|            run_container_t *run = CAST_run(c);
  ------------------
  |  |   77|  15.1k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  15.1k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2415|       |
 2416|  15.1k|            if (run->n_runs == 0) {
  ------------------
  |  Branch (2416:17): [True: 0, False: 15.1k]
  ------------------
 2417|      0|                return NULL;
 2418|      0|            }
 2419|  15.1k|            if (min <= run_container_minimum(run) &&
  ------------------
  |  Branch (2419:17): [True: 14.8k, False: 367]
  ------------------
 2420|  14.8k|                max >= run_container_maximum(run)) {
  ------------------
  |  Branch (2420:17): [True: 13.4k, False: 1.39k]
  ------------------
 2421|  13.4k|                return NULL;
 2422|  13.4k|            }
 2423|       |
 2424|  1.75k|            run_container_remove_range(run, min, max);
 2425|  1.75k|            return convert_run_to_efficient_container(run, result_type);
 2426|  15.1k|        }
 2427|      0|        default:
  ------------------
  |  Branch (2427:9): [True: 0, False: 20.0k]
  ------------------
 2428|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2429|  20.0k|    }
 2430|  20.0k|}
roaring.c:container_get_cardinality:
  244|   399k|                                            uint8_t typecode) {
  245|   399k|    c = container_unwrap_shared(c, &typecode);
  246|   399k|    switch (typecode) {
  ------------------
  |  Branch (246:13): [True: 399k, False: 0]
  ------------------
  247|  9.90k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  9.90k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (247:9): [True: 9.90k, False: 390k]
  ------------------
  248|  9.90k|            return bitset_container_cardinality(const_CAST_bitset(c));
  ------------------
  |  |   53|  9.90k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  9.90k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  249|  64.7k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  64.7k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (249:9): [True: 64.7k, False: 335k]
  ------------------
  250|  64.7k|            return array_container_cardinality(const_CAST_array(c));
  ------------------
  |  |   55|  64.7k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  64.7k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  251|   325k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|   325k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (251:9): [True: 325k, False: 74.7k]
  ------------------
  252|   325k|            return run_container_cardinality(const_CAST_run(c));
  ------------------
  |  |   78|   325k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|   325k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  253|   399k|    }
  254|   399k|    assert(false);
  255|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  256|      0|    return 0;  // unreached
  257|   399k|}
roaring.c:get_container_type:
  129|  81.1k|static inline uint8_t get_container_type(const container_t *c, uint8_t type) {
  130|  81.1k|    if (type == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|  81.1k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (130:9): [True: 0, False: 81.1k]
  ------------------
  131|      0|        return const_CAST_shared(c)->typecode;
  ------------------
  |  |   80|      0|#define const_CAST_shared(c) CAST(const shared_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  132|  81.1k|    } else {
  133|  81.1k|        return type;
  134|  81.1k|    }
  135|  81.1k|}
roaring.c:get_writable_copy_if_shared:
  146|  8.37M|                                                       uint8_t *type) {
  147|  8.37M|    if (*type == SHARED_CONTAINER_TYPE) {  // shared, return enclosed container
  ------------------
  |  |   51|  8.37M|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (147:9): [True: 0, False: 8.37M]
  ------------------
  148|      0|        return shared_container_extract_copy(CAST_shared(c), type);
  ------------------
  |  |   79|      0|#define CAST_shared(c) CAST(shared_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  149|  8.37M|    } else {
  150|  8.37M|        return c;  // not shared, so return as-is
  151|  8.37M|    }
  152|  8.37M|}
roaring.c:container_add:
  492|  8.13M|    uint8_t *new_typecode) {
  493|  8.13M|    c = get_writable_copy_if_shared(c, &typecode);
  494|  8.13M|    switch (typecode) {
  495|   326k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|   326k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (495:9): [True: 326k, False: 7.80M]
  ------------------
  496|   326k|            bitset_container_set(CAST_bitset(c), val);
  ------------------
  |  |   52|   326k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|   326k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  497|   326k|            *new_typecode = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|   326k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  498|   326k|            return c;
  499|  7.39M|        case ARRAY_CONTAINER_TYPE: {
  ------------------
  |  |   49|  7.39M|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (499:9): [True: 7.39M, False: 740k]
  ------------------
  500|  7.39M|            array_container_t *ac = CAST_array(c);
  ------------------
  |  |   54|  7.39M|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  7.39M|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  501|  7.39M|            if (array_container_try_add(ac, val, DEFAULT_MAX_SIZE) != -1) {
  ------------------
  |  Branch (501:17): [True: 7.39M, False: 131]
  ------------------
  502|  7.39M|                *new_typecode = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  7.39M|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  503|  7.39M|                return ac;
  504|  7.39M|            } else {
  505|    131|                bitset_container_t *bitset = bitset_container_from_array(ac);
  506|    131|                bitset_container_add(bitset, val);
  507|    131|                *new_typecode = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|    131|#define BITSET_CONTAINER_TYPE 1
  ------------------
  508|    131|                return bitset;
  509|    131|            }
  510|  7.39M|        } break;
  511|   413k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|   413k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (511:9): [True: 413k, False: 7.71M]
  ------------------
  512|       |            // per Java, no container type adjustments are done (revisit?)
  513|   413k|            run_container_add(CAST_run(c), val);
  ------------------
  |  |   77|   413k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|   413k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  514|   413k|            *new_typecode = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|   413k|#define RUN_CONTAINER_TYPE 3
  ------------------
  515|   413k|            return c;
  516|      0|        default:
  ------------------
  |  Branch (516:9): [True: 0, False: 8.13M]
  ------------------
  517|      0|            assert(false);
  518|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  519|      0|            return NULL;
  520|  8.13M|    }
  521|  8.13M|}
roaring.c:container_remove:
  533|  11.6k|    uint8_t *new_typecode) {
  534|  11.6k|    c = get_writable_copy_if_shared(c, &typecode);
  535|  11.6k|    switch (typecode) {
  536|  2.32k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  2.32k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (536:9): [True: 2.32k, False: 9.35k]
  ------------------
  537|  2.32k|            if (bitset_container_remove(CAST_bitset(c), val)) {
  ------------------
  |  |   52|  2.32k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  2.32k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (537:17): [True: 1.41k, False: 911]
  ------------------
  538|  1.41k|                int card = bitset_container_cardinality(CAST_bitset(c));
  ------------------
  |  |   52|  1.41k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.41k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  539|  1.41k|                if (card <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (539:21): [True: 14, False: 1.40k]
  ------------------
  540|     14|                    *new_typecode = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|     14|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  541|     14|                    return array_container_from_bitset(CAST_bitset(c));
  ------------------
  |  |   52|     14|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     14|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  542|     14|                }
  543|  1.41k|            }
  544|  2.31k|            *new_typecode = typecode;
  545|  2.31k|            return c;
  546|  6.21k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  6.21k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (546:9): [True: 6.21k, False: 5.46k]
  ------------------
  547|  6.21k|            *new_typecode = typecode;
  548|  6.21k|            array_container_remove(CAST_array(c), val);
  ------------------
  |  |   54|  6.21k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  6.21k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  549|  6.21k|            return c;
  550|  3.14k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  3.14k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (550:9): [True: 3.14k, False: 8.53k]
  ------------------
  551|       |            // per Java, no container type adjustments are done (revisit?)
  552|  3.14k|            run_container_remove(CAST_run(c), val);
  ------------------
  |  |   77|  3.14k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  3.14k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  553|  3.14k|            *new_typecode = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|  3.14k|#define RUN_CONTAINER_TYPE 3
  ------------------
  554|  3.14k|            return c;
  555|      0|        default:
  ------------------
  |  Branch (555:9): [True: 0, False: 11.6k]
  ------------------
  556|      0|            assert(false);
  557|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  558|      0|            return NULL;
  559|  11.6k|    }
  560|  11.6k|}
roaring.c:container_nonzero_cardinality:
  437|   181k|                                                 uint8_t typecode) {
  438|   181k|    c = container_unwrap_shared(c, &typecode);
  439|   181k|    switch (typecode) {
  ------------------
  |  Branch (439:13): [True: 181k, False: 0]
  ------------------
  440|  7.16k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  7.16k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (440:9): [True: 7.16k, False: 174k]
  ------------------
  441|  7.16k|            return bitset_container_const_nonzero_cardinality(
  442|  7.16k|                const_CAST_bitset(c));
  ------------------
  |  |   53|  7.16k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  7.16k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  443|   107k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|   107k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (443:9): [True: 107k, False: 74.2k]
  ------------------
  444|   107k|            return array_container_nonzero_cardinality(const_CAST_array(c));
  ------------------
  |  |   55|   107k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|   107k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  445|  67.0k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  67.0k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (445:9): [True: 67.0k, False: 114k]
  ------------------
  446|  67.0k|            return run_container_nonzero_cardinality(const_CAST_run(c));
  ------------------
  |  |   78|  67.0k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  67.0k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  447|   181k|    }
  448|   181k|    assert(false);
  449|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  450|      0|    return 0;  // unreached
  451|   181k|}
roaring.c:container_and:
  728|  6.36k|                                         uint8_t *result_type) {
  729|  6.36k|    c1 = container_unwrap_shared(c1, &type1);
  730|  6.36k|    c2 = container_unwrap_shared(c2, &type2);
  731|  6.36k|    container_t *result = NULL;
  732|  6.36k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  6.36k|#define PAIR_CONTAINER_TYPES(type1, type2) (4 * (type1) + (type2))
  ------------------
  733|      0|        case CONTAINER_PAIR(BITSET, BITSET):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (733:9): [True: 0, False: 6.36k]
  ------------------
  734|      0|            *result_type =
  735|      0|                bitset_bitset_container_intersection(
  ------------------
  |  Branch (735:17): [True: 0, False: 0]
  ------------------
  736|      0|                    const_CAST_bitset(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                  const_CAST_bitset(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  737|      0|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  738|      0|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  739|      0|            return result;
  740|       |
  741|  2.32k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  2.32k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.32k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.32k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (741:9): [True: 2.32k, False: 4.03k]
  ------------------
  742|  2.32k|            result = array_container_create();
  743|  2.32k|            array_container_intersection(
  744|  2.32k|                const_CAST_array(c1), const_CAST_array(c2), CAST_array(result));
  ------------------
  |  |   55|  2.32k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.32k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_array(c2), CAST_array(result));
  ------------------
  |  |   55|  2.32k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.32k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_array(c2), CAST_array(result));
  ------------------
  |  |   54|  2.32k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  2.32k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  745|  2.32k|            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
  ------------------
  |  |   49|  2.32k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  746|  2.32k|            return result;
  747|       |
  748|    680|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    680|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    680|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    680|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (748:9): [True: 680, False: 5.68k]
  ------------------
  749|    680|            result = run_container_create();
  750|    680|            run_container_intersection(const_CAST_run(c1), const_CAST_run(c2),
  ------------------
  |  |   78|    680|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    680|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          run_container_intersection(const_CAST_run(c1), const_CAST_run(c2),
  ------------------
  |  |   78|    680|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    680|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  751|    680|                                       CAST_run(result));
  ------------------
  |  |   77|    680|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    680|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  752|    680|            return convert_run_to_efficient_container_and_free(CAST_run(result),
  ------------------
  |  |   77|    680|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    680|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  753|    680|                                                               result_type);
  754|       |
  755|      0|        case CONTAINER_PAIR(BITSET, ARRAY):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (755:9): [True: 0, False: 6.36k]
  ------------------
  756|      0|            result = array_container_create();
  757|      0|            array_bitset_container_intersection(const_CAST_array(c2),
  ------------------
  |  |   55|      0|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  758|      0|                                                const_CAST_bitset(c1),
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  759|      0|                                                CAST_array(result));
  ------------------
  |  |   54|      0|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  760|      0|            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  761|      0|            return result;
  762|       |
  763|    575|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|    575|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    575|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    575|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (763:9): [True: 575, False: 5.78k]
  ------------------
  764|    575|            result = array_container_create();
  765|    575|            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
  ------------------
  |  |   49|    575|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  766|    575|            array_bitset_container_intersection(const_CAST_array(c1),
  ------------------
  |  |   55|    575|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    575|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  767|    575|                                                const_CAST_bitset(c2),
  ------------------
  |  |   53|    575|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    575|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  768|    575|                                                CAST_array(result));
  ------------------
  |  |   54|    575|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    575|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  769|    575|            return result;
  770|       |
  771|      0|        case CONTAINER_PAIR(BITSET, RUN):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (771:9): [True: 0, False: 6.36k]
  ------------------
  772|      0|            *result_type =
  773|      0|                run_bitset_container_intersection(
  ------------------
  |  Branch (773:17): [True: 0, False: 0]
  ------------------
  774|      0|                    const_CAST_run(c2), const_CAST_bitset(c1), &result)
  ------------------
  |  |   78|      0|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                  const_CAST_run(c2), const_CAST_bitset(c1), &result)
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  775|      0|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  776|      0|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  777|      0|            return result;
  778|       |
  779|    691|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|    691|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    691|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    691|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (779:9): [True: 691, False: 5.66k]
  ------------------
  780|    691|            *result_type =
  781|    691|                run_bitset_container_intersection(
  ------------------
  |  Branch (781:17): [True: 0, False: 691]
  ------------------
  782|    691|                    const_CAST_run(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   78|    691|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    691|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                  const_CAST_run(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|    691|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    691|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  783|    691|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  784|    691|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  1.38k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  785|    691|            return result;
  786|       |
  787|    814|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    814|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    814|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    814|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (787:9): [True: 814, False: 5.54k]
  ------------------
  788|    814|            result = array_container_create();
  789|    814|            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
  ------------------
  |  |   49|    814|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  790|    814|            array_run_container_intersection(
  791|    814|                const_CAST_array(c1), const_CAST_run(c2), CAST_array(result));
  ------------------
  |  |   55|    814|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    814|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_run(c2), CAST_array(result));
  ------------------
  |  |   78|    814|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    814|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_run(c2), CAST_array(result));
  ------------------
  |  |   54|    814|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    814|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  792|    814|            return result;
  793|       |
  794|  1.27k|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|  1.27k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  1.27k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  1.27k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (794:9): [True: 1.27k, False: 5.08k]
  ------------------
  795|  1.27k|            result = array_container_create();
  796|  1.27k|            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
  ------------------
  |  |   49|  1.27k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  797|  1.27k|            array_run_container_intersection(
  798|  1.27k|                const_CAST_array(c2), const_CAST_run(c1), CAST_array(result));
  ------------------
  |  |   55|  1.27k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.27k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c2), const_CAST_run(c1), CAST_array(result));
  ------------------
  |  |   78|  1.27k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.27k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c2), const_CAST_run(c1), CAST_array(result));
  ------------------
  |  |   54|  1.27k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.27k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  799|  1.27k|            return result;
  800|       |
  801|      0|        default:
  ------------------
  |  Branch (801:9): [True: 0, False: 6.36k]
  ------------------
  802|      0|            assert(false);
  803|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  804|      0|            return NULL;
  805|  6.36k|    }
  806|  6.36k|}
roaring.c:container_iand:
  923|  69.2k|                                          uint8_t *result_type) {
  924|  69.2k|    c1 = get_writable_copy_if_shared(c1, &type1);
  925|  69.2k|    c2 = container_unwrap_shared(c2, &type2);
  926|  69.2k|    container_t *result = NULL;
  927|  69.2k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  69.2k|#define PAIR_CONTAINER_TYPES(type1, type2) (4 * (type1) + (type2))
  ------------------
  928|  1.51k|        case CONTAINER_PAIR(BITSET, BITSET):
  ------------------
  |  |   65|  1.51k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  1.51k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  1.51k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (928:9): [True: 1.51k, False: 67.7k]
  ------------------
  929|  1.51k|            *result_type = bitset_bitset_container_intersection_inplace(
  ------------------
  |  Branch (929:28): [True: 1.51k, False: 0]
  ------------------
  930|  1.51k|                               CAST_bitset(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   52|  1.51k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.51k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_bitset(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|  1.51k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.51k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  931|  1.51k|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|  1.51k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  932|  1.51k|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  1.51k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  933|  1.51k|            return result;
  934|       |
  935|  4.86k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  4.86k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  4.86k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  4.86k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (935:9): [True: 4.86k, False: 64.4k]
  ------------------
  936|  4.86k|            array_container_intersection_inplace(CAST_array(c1),
  ------------------
  |  |   54|  4.86k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  4.86k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  937|  4.86k|                                                 const_CAST_array(c2));
  ------------------
  |  |   55|  4.86k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  4.86k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  938|  4.86k|            *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  4.86k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  939|  4.86k|            return c1;
  940|       |
  941|  61.5k|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|  61.5k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  61.5k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  61.5k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (941:9): [True: 61.5k, False: 7.69k]
  ------------------
  942|  61.5k|            result = run_container_create();
  943|  61.5k|            run_container_intersection(const_CAST_run(c1), const_CAST_run(c2),
  ------------------
  |  |   78|  61.5k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  61.5k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          run_container_intersection(const_CAST_run(c1), const_CAST_run(c2),
  ------------------
  |  |   78|  61.5k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  61.5k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  944|  61.5k|                                       CAST_run(result));
  ------------------
  |  |   77|  61.5k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  61.5k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  945|       |            // as of January 2016, Java code used non-in-place intersection for
  946|       |            // two runcontainers
  947|  61.5k|            return convert_run_to_efficient_container_and_free(CAST_run(result),
  ------------------
  |  |   77|  61.5k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  61.5k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  948|  61.5k|                                                               result_type);
  949|       |
  950|     52|        case CONTAINER_PAIR(BITSET, ARRAY):
  ------------------
  |  |   65|     52|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|     52|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|     52|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (950:9): [True: 52, False: 69.2k]
  ------------------
  951|       |            // c1 is a bitmap so no inplace possible
  952|     52|            result = array_container_create();
  953|     52|            array_bitset_container_intersection(const_CAST_array(c2),
  ------------------
  |  |   55|     52|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|     52|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  954|     52|                                                const_CAST_bitset(c1),
  ------------------
  |  |   53|     52|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|     52|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  955|     52|                                                CAST_array(result));
  ------------------
  |  |   54|     52|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     52|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  956|     52|            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
  ------------------
  |  |   49|     52|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  957|     52|            return result;
  958|       |
  959|      0|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (959:9): [True: 0, False: 69.2k]
  ------------------
  960|      0|            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  961|      0|            array_bitset_container_intersection(
  962|      0|                const_CAST_array(c1), const_CAST_bitset(c2),
  ------------------
  |  |   55|      0|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_bitset(c2),
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  963|      0|                CAST_array(c1));  // result is allowed to be same as c1
  ------------------
  |  |   54|      0|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  964|      0|            return c1;
  965|       |
  966|      0|        case CONTAINER_PAIR(BITSET, RUN):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (966:9): [True: 0, False: 69.2k]
  ------------------
  967|       |            // will attempt in-place computation
  968|      0|            *result_type = run_bitset_container_intersection(
  ------------------
  |  Branch (968:28): [True: 0, False: 0]
  ------------------
  969|      0|                               const_CAST_run(c2), const_CAST_bitset(c1), &c1)
  ------------------
  |  |   78|      0|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             const_CAST_run(c2), const_CAST_bitset(c1), &c1)
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  970|      0|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  971|      0|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  972|      0|            return c1;
  973|       |
  974|      0|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (974:9): [True: 0, False: 69.2k]
  ------------------
  975|      0|            *result_type =
  976|      0|                run_bitset_container_intersection(
  ------------------
  |  Branch (976:17): [True: 0, False: 0]
  ------------------
  977|      0|                    const_CAST_run(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   78|      0|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                  const_CAST_run(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  978|      0|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  979|      0|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  980|      0|            return result;
  981|       |
  982|    193|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    193|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    193|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    193|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (982:9): [True: 193, False: 69.0k]
  ------------------
  983|    193|            result = array_container_create();
  984|    193|            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
  ------------------
  |  |   49|    193|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  985|    193|            array_run_container_intersection(
  986|    193|                const_CAST_array(c1), const_CAST_run(c2), CAST_array(result));
  ------------------
  |  |   55|    193|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    193|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_run(c2), CAST_array(result));
  ------------------
  |  |   78|    193|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    193|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_run(c2), CAST_array(result));
  ------------------
  |  |   54|    193|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    193|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  987|    193|            return result;
  988|       |
  989|  1.07k|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|  1.07k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  1.07k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  1.07k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (989:9): [True: 1.07k, False: 68.2k]
  ------------------
  990|  1.07k|            result = array_container_create();
  991|  1.07k|            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
  ------------------
  |  |   49|  1.07k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  992|  1.07k|            array_run_container_intersection(
  993|  1.07k|                const_CAST_array(c2), const_CAST_run(c1), CAST_array(result));
  ------------------
  |  |   55|  1.07k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.07k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c2), const_CAST_run(c1), CAST_array(result));
  ------------------
  |  |   78|  1.07k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.07k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c2), const_CAST_run(c1), CAST_array(result));
  ------------------
  |  |   54|  1.07k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.07k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  994|  1.07k|            return result;
  995|       |
  996|      0|        default:
  ------------------
  |  Branch (996:9): [True: 0, False: 69.2k]
  ------------------
  997|      0|            assert(false);
  998|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  999|      0|            return NULL;
 1000|  69.2k|    }
 1001|  69.2k|}
roaring.c:container_or:
 1010|  6.36k|                                        uint8_t *result_type) {
 1011|  6.36k|    c1 = container_unwrap_shared(c1, &type1);
 1012|  6.36k|    c2 = container_unwrap_shared(c2, &type2);
 1013|  6.36k|    container_t *result = NULL;
 1014|  6.36k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  6.36k|#define PAIR_CONTAINER_TYPES(type1, type2) (4 * (type1) + (type2))
  ------------------
 1015|      0|        case CONTAINER_PAIR(BITSET, BITSET):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1015:9): [True: 0, False: 6.36k]
  ------------------
 1016|      0|            result = bitset_container_create();
 1017|      0|            bitset_container_or(const_CAST_bitset(c1), const_CAST_bitset(c2),
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          bitset_container_or(const_CAST_bitset(c1), const_CAST_bitset(c2),
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1018|      0|                                CAST_bitset(result));
  ------------------
  |  |   52|      0|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1019|      0|            *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1020|      0|            return result;
 1021|       |
 1022|  2.32k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  2.32k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.32k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.32k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1022:9): [True: 2.32k, False: 4.03k]
  ------------------
 1023|  2.32k|            *result_type =
 1024|  2.32k|                array_array_container_union(const_CAST_array(c1),
  ------------------
  |  |   55|  2.32k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.32k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1024:17): [True: 52, False: 2.27k]
  ------------------
 1025|  2.32k|                                            const_CAST_array(c2), &result)
  ------------------
  |  |   55|  2.32k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.32k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1026|  2.32k|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|     52|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1027|  2.32k|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  4.59k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1028|  2.32k|            return result;
 1029|       |
 1030|    680|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    680|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    680|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    680|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1030:9): [True: 680, False: 5.68k]
  ------------------
 1031|    680|            result = run_container_create();
 1032|    680|            run_container_union(const_CAST_run(c1), const_CAST_run(c2),
  ------------------
  |  |   78|    680|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    680|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          run_container_union(const_CAST_run(c1), const_CAST_run(c2),
  ------------------
  |  |   78|    680|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    680|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1033|    680|                                CAST_run(result));
  ------------------
  |  |   77|    680|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    680|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1034|    680|            *result_type = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|    680|#define RUN_CONTAINER_TYPE 3
  ------------------
 1035|       |            // todo: could be optimized since will never convert to array
 1036|    680|            result = convert_run_to_efficient_container_and_free(
 1037|    680|                CAST_run(result), result_type);
  ------------------
  |  |   77|    680|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    680|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1038|    680|            return result;
 1039|       |
 1040|      0|        case CONTAINER_PAIR(BITSET, ARRAY):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1040:9): [True: 0, False: 6.36k]
  ------------------
 1041|      0|            result = bitset_container_create();
 1042|      0|            array_bitset_container_union(const_CAST_array(c2),
  ------------------
  |  |   55|      0|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1043|      0|                                         const_CAST_bitset(c1),
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1044|      0|                                         CAST_bitset(result));
  ------------------
  |  |   52|      0|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1045|      0|            *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1046|      0|            return result;
 1047|       |
 1048|    575|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|    575|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    575|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    575|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1048:9): [True: 575, False: 5.78k]
  ------------------
 1049|    575|            result = bitset_container_create();
 1050|    575|            array_bitset_container_union(const_CAST_array(c1),
  ------------------
  |  |   55|    575|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    575|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1051|    575|                                         const_CAST_bitset(c2),
  ------------------
  |  |   53|    575|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    575|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1052|    575|                                         CAST_bitset(result));
  ------------------
  |  |   52|    575|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    575|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1053|    575|            *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|    575|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1054|    575|            return result;
 1055|       |
 1056|      0|        case CONTAINER_PAIR(BITSET, RUN):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1056:9): [True: 0, False: 6.36k]
  ------------------
 1057|      0|            if (run_container_is_full(const_CAST_run(c2))) {
  ------------------
  |  |   78|      0|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1057:17): [True: 0, False: 0]
  ------------------
 1058|      0|                result = run_container_create();
 1059|      0|                *result_type = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
 1060|      0|                run_container_copy(const_CAST_run(c2), CAST_run(result));
  ------------------
  |  |   78|      0|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              run_container_copy(const_CAST_run(c2), CAST_run(result));
  ------------------
  |  |   77|      0|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1061|      0|                return result;
 1062|      0|            }
 1063|      0|            result = bitset_container_create();
 1064|      0|            run_bitset_container_union(
 1065|      0|                const_CAST_run(c2), const_CAST_bitset(c1), CAST_bitset(result));
  ------------------
  |  |   78|      0|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c2), const_CAST_bitset(c1), CAST_bitset(result));
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c2), const_CAST_bitset(c1), CAST_bitset(result));
  ------------------
  |  |   52|      0|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1066|      0|            *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1067|      0|            return result;
 1068|       |
 1069|    691|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|    691|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    691|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    691|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1069:9): [True: 691, False: 5.66k]
  ------------------
 1070|    691|            if (run_container_is_full(const_CAST_run(c1))) {
  ------------------
  |  |   78|    691|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    691|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1070:17): [True: 0, False: 691]
  ------------------
 1071|      0|                result = run_container_create();
 1072|      0|                *result_type = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
 1073|      0|                run_container_copy(const_CAST_run(c1), CAST_run(result));
  ------------------
  |  |   78|      0|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              run_container_copy(const_CAST_run(c1), CAST_run(result));
  ------------------
  |  |   77|      0|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1074|      0|                return result;
 1075|      0|            }
 1076|    691|            result = bitset_container_create();
 1077|    691|            run_bitset_container_union(
 1078|    691|                const_CAST_run(c1), const_CAST_bitset(c2), CAST_bitset(result));
  ------------------
  |  |   78|    691|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    691|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c1), const_CAST_bitset(c2), CAST_bitset(result));
  ------------------
  |  |   53|    691|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    691|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c1), const_CAST_bitset(c2), CAST_bitset(result));
  ------------------
  |  |   52|    691|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    691|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1079|    691|            *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|    691|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1080|    691|            return result;
 1081|       |
 1082|    814|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    814|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    814|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    814|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1082:9): [True: 814, False: 5.54k]
  ------------------
 1083|    814|            result = run_container_create();
 1084|    814|            array_run_container_union(const_CAST_array(c1), const_CAST_run(c2),
  ------------------
  |  |   55|    814|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    814|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          array_run_container_union(const_CAST_array(c1), const_CAST_run(c2),
  ------------------
  |  |   78|    814|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    814|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1085|    814|                                      CAST_run(result));
  ------------------
  |  |   77|    814|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    814|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1086|    814|            result = convert_run_to_efficient_container_and_free(
 1087|    814|                CAST_run(result), result_type);
  ------------------
  |  |   77|    814|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    814|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1088|    814|            return result;
 1089|       |
 1090|  1.27k|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|  1.27k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  1.27k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  1.27k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1090:9): [True: 1.27k, False: 5.08k]
  ------------------
 1091|  1.27k|            result = run_container_create();
 1092|  1.27k|            array_run_container_union(const_CAST_array(c2), const_CAST_run(c1),
  ------------------
  |  |   55|  1.27k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.27k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          array_run_container_union(const_CAST_array(c2), const_CAST_run(c1),
  ------------------
  |  |   78|  1.27k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.27k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1093|  1.27k|                                      CAST_run(result));
  ------------------
  |  |   77|  1.27k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.27k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1094|  1.27k|            result = convert_run_to_efficient_container_and_free(
 1095|  1.27k|                CAST_run(result), result_type);
  ------------------
  |  |   77|  1.27k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.27k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1096|  1.27k|            return result;
 1097|       |
 1098|      0|        default:
  ------------------
  |  Branch (1098:9): [True: 0, False: 6.36k]
  ------------------
 1099|      0|            assert(false);
 1100|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1101|      0|            return NULL;  // unreached
 1102|  6.36k|    }
 1103|  6.36k|}
roaring.c:container_is_full:
  262|  7.34k|static inline bool container_is_full(const container_t *c, uint8_t typecode) {
  263|  7.34k|    c = container_unwrap_shared(c, &typecode);
  264|  7.34k|    switch (typecode) {
  ------------------
  |  Branch (264:13): [True: 7.34k, False: 0]
  ------------------
  265|      0|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (265:9): [True: 0, False: 7.34k]
  ------------------
  266|      0|            return bitset_container_cardinality(const_CAST_bitset(c)) ==
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  267|      0|                   (1 << 16);
  268|  3.80k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  3.80k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (268:9): [True: 3.80k, False: 3.53k]
  ------------------
  269|  3.80k|            return array_container_cardinality(const_CAST_array(c)) ==
  ------------------
  |  |   55|  3.80k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.80k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  270|  3.80k|                   (1 << 16);
  271|  3.53k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  3.53k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (271:9): [True: 3.53k, False: 3.80k]
  ------------------
  272|  3.53k|            return run_container_is_full(const_CAST_run(c));
  ------------------
  |  |   78|  3.53k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.53k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  273|  7.34k|    }
  274|  7.34k|    assert(false);
  275|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  276|      0|    return 0;  // unreached
  277|  7.34k|}
roaring.c:container_ior:
 1228|  6.48k|                                         uint8_t *result_type) {
 1229|  6.48k|    c1 = get_writable_copy_if_shared(c1, &type1);
 1230|  6.48k|    c2 = container_unwrap_shared(c2, &type2);
 1231|  6.48k|    container_t *result = NULL;
 1232|  6.48k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  6.48k|#define PAIR_CONTAINER_TYPES(type1, type2) (4 * (type1) + (type2))
  ------------------
 1233|      0|        case CONTAINER_PAIR(BITSET, BITSET):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1233:9): [True: 0, False: 6.48k]
  ------------------
 1234|      0|            bitset_container_or(const_CAST_bitset(c1), const_CAST_bitset(c2),
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          bitset_container_or(const_CAST_bitset(c1), const_CAST_bitset(c2),
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1235|      0|                                CAST_bitset(c1));
  ------------------
  |  |   52|      0|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1236|      0|#ifdef OR_BITSET_CONVERSION_TO_FULL
 1237|      0|            if (CAST_bitset(c1)->cardinality == (1 << 16)) {  // we convert
  ------------------
  |  |   52|      0|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1237:17): [True: 0, False: 0]
  ------------------
 1238|      0|                result = run_container_create_range(0, (1 << 16));
 1239|      0|                *result_type = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
 1240|      0|                return result;
 1241|      0|            }
 1242|      0|#endif
 1243|      0|            *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1244|      0|            return c1;
 1245|       |
 1246|  2.51k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  2.51k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.51k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.51k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1246:9): [True: 2.51k, False: 3.96k]
  ------------------
 1247|  2.51k|            *result_type = array_array_container_inplace_union(
  ------------------
  |  Branch (1247:28): [True: 0, False: 2.51k]
  ------------------
 1248|  2.51k|                               CAST_array(c1), const_CAST_array(c2), &result)
  ------------------
  |  |   54|  2.51k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  2.51k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_array(c1), const_CAST_array(c2), &result)
  ------------------
  |  |   55|  2.51k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.51k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1249|  2.51k|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1250|  2.51k|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  5.02k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1251|  2.51k|            if ((result == NULL) && (*result_type == ARRAY_CONTAINER_TYPE)) {
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (1251:17): [True: 0, False: 2.51k]
  |  Branch (1251:37): [True: 0, False: 0]
  ------------------
 1252|      0|                return c1;  // the computation was done in-place!
 1253|      0|            }
 1254|  2.51k|            return result;
 1255|       |
 1256|  1.73k|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|  1.73k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  1.73k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  1.73k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1256:9): [True: 1.73k, False: 4.74k]
  ------------------
 1257|  1.73k|            run_container_union_inplace(CAST_run(c1), const_CAST_run(c2));
  ------------------
  |  |   77|  1.73k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.73k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          run_container_union_inplace(CAST_run(c1), const_CAST_run(c2));
  ------------------
  |  |   78|  1.73k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.73k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1258|  1.73k|            return convert_run_to_efficient_container(CAST_run(c1),
  ------------------
  |  |   77|  1.73k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.73k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1259|  1.73k|                                                      result_type);
 1260|       |
 1261|      0|        case CONTAINER_PAIR(BITSET, ARRAY):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1261:9): [True: 0, False: 6.48k]
  ------------------
 1262|      0|            array_bitset_container_union(
 1263|      0|                const_CAST_array(c2), const_CAST_bitset(c1), CAST_bitset(c1));
  ------------------
  |  |   55|      0|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c2), const_CAST_bitset(c1), CAST_bitset(c1));
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c2), const_CAST_bitset(c1), CAST_bitset(c1));
  ------------------
  |  |   52|      0|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1264|      0|            *result_type = BITSET_CONTAINER_TYPE;  // never array
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1265|      0|            return c1;
 1266|       |
 1267|    627|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|    627|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    627|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    627|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1267:9): [True: 627, False: 5.85k]
  ------------------
 1268|       |            // c1 is an array, so no in-place possible
 1269|    627|            result = bitset_container_create();
 1270|    627|            *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|    627|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1271|    627|            array_bitset_container_union(const_CAST_array(c1),
  ------------------
  |  |   55|    627|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    627|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1272|    627|                                         const_CAST_bitset(c2),
  ------------------
  |  |   53|    627|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    627|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1273|    627|                                         CAST_bitset(result));
  ------------------
  |  |   52|    627|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    627|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1274|    627|            return result;
 1275|       |
 1276|      0|        case CONTAINER_PAIR(BITSET, RUN):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1276:9): [True: 0, False: 6.48k]
  ------------------
 1277|      0|            if (run_container_is_full(const_CAST_run(c2))) {
  ------------------
  |  |   78|      0|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1277:17): [True: 0, False: 0]
  ------------------
 1278|      0|                result = run_container_create();
 1279|      0|                *result_type = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
 1280|      0|                run_container_copy(const_CAST_run(c2), CAST_run(result));
  ------------------
  |  |   78|      0|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              run_container_copy(const_CAST_run(c2), CAST_run(result));
  ------------------
  |  |   77|      0|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1281|      0|                return result;
 1282|      0|            }
 1283|      0|            run_bitset_container_union(const_CAST_run(c2),
  ------------------
  |  |   78|      0|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1284|      0|                                       const_CAST_bitset(c1),
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1285|      0|                                       CAST_bitset(c1));  // allowed
  ------------------
  |  |   52|      0|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1286|      0|            *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1287|      0|            return c1;
 1288|       |
 1289|    691|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|    691|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    691|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    691|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1289:9): [True: 691, False: 5.78k]
  ------------------
 1290|    691|            if (run_container_is_full(const_CAST_run(c1))) {
  ------------------
  |  |   78|    691|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    691|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1290:17): [True: 0, False: 691]
  ------------------
 1291|      0|                *result_type = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
 1292|      0|                return c1;
 1293|      0|            }
 1294|    691|            result = bitset_container_create();
 1295|    691|            run_bitset_container_union(
 1296|    691|                const_CAST_run(c1), const_CAST_bitset(c2), CAST_bitset(result));
  ------------------
  |  |   78|    691|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    691|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c1), const_CAST_bitset(c2), CAST_bitset(result));
  ------------------
  |  |   53|    691|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    691|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c1), const_CAST_bitset(c2), CAST_bitset(result));
  ------------------
  |  |   52|    691|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    691|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1297|    691|            *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|    691|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1298|    691|            return result;
 1299|       |
 1300|    665|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    665|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    665|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    665|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1300:9): [True: 665, False: 5.81k]
  ------------------
 1301|    665|            result = run_container_create();
 1302|    665|            array_run_container_union(const_CAST_array(c1), const_CAST_run(c2),
  ------------------
  |  |   55|    665|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    665|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          array_run_container_union(const_CAST_array(c1), const_CAST_run(c2),
  ------------------
  |  |   78|    665|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    665|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1303|    665|                                      CAST_run(result));
  ------------------
  |  |   77|    665|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    665|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1304|    665|            result = convert_run_to_efficient_container_and_free(
 1305|    665|                CAST_run(result), result_type);
  ------------------
  |  |   77|    665|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    665|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1306|    665|            return result;
 1307|       |
 1308|    248|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|    248|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    248|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    248|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1308:9): [True: 248, False: 6.23k]
  ------------------
 1309|    248|            array_run_container_inplace_union(const_CAST_array(c2),
  ------------------
  |  |   55|    248|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    248|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1310|    248|                                              CAST_run(c1));
  ------------------
  |  |   77|    248|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    248|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1311|    248|            c1 = convert_run_to_efficient_container(CAST_run(c1), result_type);
  ------------------
  |  |   77|    248|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    248|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1312|    248|            return c1;
 1313|       |
 1314|      0|        default:
  ------------------
  |  Branch (1314:9): [True: 0, False: 6.48k]
  ------------------
 1315|      0|            assert(false);
 1316|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1317|      0|            return NULL;
 1318|  6.48k|    }
 1319|  6.48k|}
roaring.c:container_xor:
 1451|  6.36k|                                         uint8_t *result_type) {
 1452|  6.36k|    c1 = container_unwrap_shared(c1, &type1);
 1453|  6.36k|    c2 = container_unwrap_shared(c2, &type2);
 1454|  6.36k|    container_t *result = NULL;
 1455|  6.36k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  6.36k|#define PAIR_CONTAINER_TYPES(type1, type2) (4 * (type1) + (type2))
  ------------------
 1456|      0|        case CONTAINER_PAIR(BITSET, BITSET):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1456:9): [True: 0, False: 6.36k]
  ------------------
 1457|      0|            *result_type =
 1458|      0|                bitset_bitset_container_xor(const_CAST_bitset(c1),
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1458:17): [True: 0, False: 0]
  ------------------
 1459|      0|                                            const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1460|      0|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1461|      0|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1462|      0|            return result;
 1463|       |
 1464|  2.32k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  2.32k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.32k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.32k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1464:9): [True: 2.32k, False: 4.03k]
  ------------------
 1465|  2.32k|            *result_type =
 1466|  2.32k|                array_array_container_xor(const_CAST_array(c1),
  ------------------
  |  |   55|  2.32k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.32k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1466:17): [True: 8, False: 2.31k]
  ------------------
 1467|  2.32k|                                          const_CAST_array(c2), &result)
  ------------------
  |  |   55|  2.32k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.32k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1468|  2.32k|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      8|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1469|  2.32k|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  4.63k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1470|  2.32k|            return result;
 1471|       |
 1472|    680|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    680|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    680|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    680|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1472:9): [True: 680, False: 5.68k]
  ------------------
 1473|    680|            *result_type = (uint8_t)run_run_container_xor(
 1474|    680|                const_CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|    680|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    680|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|    680|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    680|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1475|    680|            return result;
 1476|       |
 1477|      0|        case CONTAINER_PAIR(BITSET, ARRAY):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1477:9): [True: 0, False: 6.36k]
  ------------------
 1478|      0|            *result_type =
 1479|      0|                array_bitset_container_xor(const_CAST_array(c2),
  ------------------
  |  |   55|      0|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1479:17): [True: 0, False: 0]
  ------------------
 1480|      0|                                           const_CAST_bitset(c1), &result)
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1481|      0|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1482|      0|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1483|      0|            return result;
 1484|       |
 1485|    575|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|    575|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    575|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    575|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1485:9): [True: 575, False: 5.78k]
  ------------------
 1486|    575|            *result_type =
 1487|    575|                array_bitset_container_xor(const_CAST_array(c1),
  ------------------
  |  |   55|    575|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    575|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1487:17): [True: 520, False: 55]
  ------------------
 1488|    575|                                           const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|    575|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    575|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1489|    575|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|    520|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1490|    575|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    630|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1491|    575|            return result;
 1492|       |
 1493|      0|        case CONTAINER_PAIR(BITSET, RUN):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1493:9): [True: 0, False: 6.36k]
  ------------------
 1494|      0|            *result_type =
 1495|      0|                run_bitset_container_xor(const_CAST_run(c2),
  ------------------
  |  |   78|      0|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1495:17): [True: 0, False: 0]
  ------------------
 1496|      0|                                         const_CAST_bitset(c1), &result)
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1497|      0|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1498|      0|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1499|      0|            return result;
 1500|       |
 1501|    691|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|    691|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    691|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    691|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1501:9): [True: 691, False: 5.66k]
  ------------------
 1502|    691|            *result_type =
 1503|    691|                run_bitset_container_xor(const_CAST_run(c1),
  ------------------
  |  |   78|    691|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    691|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1503:17): [True: 645, False: 46]
  ------------------
 1504|    691|                                         const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|    691|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    691|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1505|    691|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|    645|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1506|    691|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    737|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1507|    691|            return result;
 1508|       |
 1509|    814|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    814|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    814|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    814|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1509:9): [True: 814, False: 5.54k]
  ------------------
 1510|    814|            *result_type = (uint8_t)array_run_container_xor(
 1511|    814|                const_CAST_array(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   55|    814|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    814|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|    814|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    814|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1512|    814|            return result;
 1513|       |
 1514|  1.27k|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|  1.27k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  1.27k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  1.27k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1514:9): [True: 1.27k, False: 5.08k]
  ------------------
 1515|  1.27k|            *result_type = (uint8_t)array_run_container_xor(
 1516|  1.27k|                const_CAST_array(c2), const_CAST_run(c1), &result);
  ------------------
  |  |   55|  1.27k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.27k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c2), const_CAST_run(c1), &result);
  ------------------
  |  |   78|  1.27k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.27k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1517|  1.27k|            return result;
 1518|       |
 1519|      0|        default:
  ------------------
  |  Branch (1519:9): [True: 0, False: 6.36k]
  ------------------
 1520|      0|            assert(false);
 1521|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1522|      0|            return NULL;  // unreached
 1523|  6.36k|    }
 1524|  6.36k|}
roaring.c:container_ixor:
 1667|  67.7k|                                          uint8_t *result_type) {
 1668|  67.7k|    c1 = get_writable_copy_if_shared(c1, &type1);
 1669|  67.7k|    c2 = container_unwrap_shared(c2, &type2);
 1670|  67.7k|    container_t *result = NULL;
 1671|  67.7k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  67.7k|#define PAIR_CONTAINER_TYPES(type1, type2) (4 * (type1) + (type2))
  ------------------
 1672|  1.57k|        case CONTAINER_PAIR(BITSET, BITSET):
  ------------------
  |  |   65|  1.57k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  1.57k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  1.57k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1672:9): [True: 1.57k, False: 66.1k]
  ------------------
 1673|  1.57k|            *result_type = bitset_bitset_container_ixor(
  ------------------
  |  Branch (1673:28): [True: 0, False: 1.57k]
  ------------------
 1674|  1.57k|                               CAST_bitset(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   52|  1.57k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.57k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_bitset(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|  1.57k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.57k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1675|  1.57k|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1676|  1.57k|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  3.15k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1677|  1.57k|            return result;
 1678|       |
 1679|  5.11k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  5.11k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  5.11k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  5.11k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1679:9): [True: 5.11k, False: 62.6k]
  ------------------
 1680|  5.11k|            *result_type = array_array_container_ixor(
  ------------------
  |  Branch (1680:28): [True: 0, False: 5.11k]
  ------------------
 1681|  5.11k|                               CAST_array(c1), const_CAST_array(c2), &result)
  ------------------
  |  |   54|  5.11k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  5.11k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_array(c1), const_CAST_array(c2), &result)
  ------------------
  |  |   55|  5.11k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  5.11k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1682|  5.11k|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1683|  5.11k|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  10.2k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1684|  5.11k|            return result;
 1685|       |
 1686|  60.5k|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|  60.5k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  60.5k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  60.5k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1686:9): [True: 60.5k, False: 7.20k]
  ------------------
 1687|  60.5k|            *result_type = (uint8_t)run_run_container_ixor(
 1688|  60.5k|                CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   77|  60.5k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  60.5k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|  60.5k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  60.5k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1689|  60.5k|            return result;
 1690|       |
 1691|      0|        case CONTAINER_PAIR(BITSET, ARRAY):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1691:9): [True: 0, False: 67.7k]
  ------------------
 1692|      0|            *result_type = bitset_array_container_ixor(
  ------------------
  |  Branch (1692:28): [True: 0, False: 0]
  ------------------
 1693|      0|                               CAST_bitset(c1), const_CAST_array(c2), &result)
  ------------------
  |  |   52|      0|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_bitset(c1), const_CAST_array(c2), &result)
  ------------------
  |  |   55|      0|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1694|      0|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1695|      0|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1696|      0|            return result;
 1697|       |
 1698|     98|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|     98|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|     98|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|     98|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1698:9): [True: 98, False: 67.6k]
  ------------------
 1699|     98|            *result_type = array_bitset_container_ixor(
  ------------------
  |  Branch (1699:28): [True: 0, False: 98]
  ------------------
 1700|     98|                               CAST_array(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   54|     98|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     98|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_array(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|     98|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|     98|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1701|     98|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1702|     98|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    196|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1703|     98|            return result;
 1704|       |
 1705|     73|        case CONTAINER_PAIR(BITSET, RUN):
  ------------------
  |  |   65|     73|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|     73|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|     73|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1705:9): [True: 73, False: 67.6k]
  ------------------
 1706|     73|            *result_type = bitset_run_container_ixor(
  ------------------
  |  Branch (1706:28): [True: 0, False: 73]
  ------------------
 1707|     73|                               CAST_bitset(c1), const_CAST_run(c2), &result)
  ------------------
  |  |   52|     73|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     73|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_bitset(c1), const_CAST_run(c2), &result)
  ------------------
  |  |   78|     73|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|     73|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1708|     73|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1709|     73|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    146|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1710|       |
 1711|     73|            return result;
 1712|       |
 1713|     18|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|     18|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|     18|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|     18|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1713:9): [True: 18, False: 67.7k]
  ------------------
 1714|     18|            *result_type = run_bitset_container_ixor(
  ------------------
  |  Branch (1714:28): [True: 0, False: 18]
  ------------------
 1715|     18|                               CAST_run(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   77|     18|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     18|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_run(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|     18|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|     18|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1716|     18|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1717|     18|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|     36|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1718|     18|            return result;
 1719|       |
 1720|    269|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    269|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    269|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    269|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1720:9): [True: 269, False: 67.4k]
  ------------------
 1721|    269|            *result_type = (uint8_t)array_run_container_ixor(
 1722|    269|                CAST_array(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   54|    269|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    269|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              CAST_array(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|    269|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    269|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1723|    269|            return result;
 1724|       |
 1725|     53|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|     53|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|     53|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|     53|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1725:9): [True: 53, False: 67.6k]
  ------------------
 1726|     53|            *result_type = (uint8_t)run_array_container_ixor(
 1727|     53|                CAST_run(c1), const_CAST_array(c2), &result);
  ------------------
  |  |   77|     53|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     53|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              CAST_run(c1), const_CAST_array(c2), &result);
  ------------------
  |  |   55|     53|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|     53|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1728|     53|            return result;
 1729|       |
 1730|      0|        default:
  ------------------
  |  Branch (1730:9): [True: 0, False: 67.7k]
  ------------------
 1731|      0|            assert(false);
 1732|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1733|      0|            return NULL;
 1734|  67.7k|    }
 1735|  67.7k|}
roaring.c:container_andnot:
 1787|  6.36k|                                            uint8_t *result_type) {
 1788|  6.36k|    c1 = container_unwrap_shared(c1, &type1);
 1789|  6.36k|    c2 = container_unwrap_shared(c2, &type2);
 1790|  6.36k|    container_t *result = NULL;
 1791|  6.36k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  6.36k|#define PAIR_CONTAINER_TYPES(type1, type2) (4 * (type1) + (type2))
  ------------------
 1792|      0|        case CONTAINER_PAIR(BITSET, BITSET):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1792:9): [True: 0, False: 6.36k]
  ------------------
 1793|      0|            *result_type =
 1794|      0|                bitset_bitset_container_andnot(const_CAST_bitset(c1),
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1794:17): [True: 0, False: 0]
  ------------------
 1795|      0|                                               const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1796|      0|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1797|      0|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1798|      0|            return result;
 1799|       |
 1800|  2.32k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  2.32k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.32k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.32k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1800:9): [True: 2.32k, False: 4.03k]
  ------------------
 1801|  2.32k|            result = array_container_create();
 1802|  2.32k|            array_array_container_andnot(
 1803|  2.32k|                const_CAST_array(c1), const_CAST_array(c2), CAST_array(result));
  ------------------
  |  |   55|  2.32k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.32k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_array(c2), CAST_array(result));
  ------------------
  |  |   55|  2.32k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.32k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_array(c2), CAST_array(result));
  ------------------
  |  |   54|  2.32k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  2.32k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1804|  2.32k|            *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  2.32k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1805|  2.32k|            return result;
 1806|       |
 1807|    680|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    680|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    680|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    680|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1807:9): [True: 680, False: 5.68k]
  ------------------
 1808|    680|            if (run_container_is_full(const_CAST_run(c2))) {
  ------------------
  |  |   78|    680|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    680|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1808:17): [True: 16, False: 664]
  ------------------
 1809|     16|                result = array_container_create();
 1810|     16|                *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|     16|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1811|     16|                return result;
 1812|     16|            }
 1813|    664|            *result_type = (uint8_t)run_run_container_andnot(
 1814|    664|                const_CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|    664|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    664|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|    664|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    664|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1815|    664|            return result;
 1816|       |
 1817|      0|        case CONTAINER_PAIR(BITSET, ARRAY):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1817:9): [True: 0, False: 6.36k]
  ------------------
 1818|      0|            *result_type =
 1819|      0|                bitset_array_container_andnot(const_CAST_bitset(c1),
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1819:17): [True: 0, False: 0]
  ------------------
 1820|      0|                                              const_CAST_array(c2), &result)
  ------------------
  |  |   55|      0|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1821|      0|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1822|      0|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1823|      0|            return result;
 1824|       |
 1825|    575|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|    575|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    575|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    575|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1825:9): [True: 575, False: 5.78k]
  ------------------
 1826|    575|            result = array_container_create();
 1827|    575|            array_bitset_container_andnot(const_CAST_array(c1),
  ------------------
  |  |   55|    575|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    575|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1828|    575|                                          const_CAST_bitset(c2),
  ------------------
  |  |   53|    575|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    575|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1829|    575|                                          CAST_array(result));
  ------------------
  |  |   54|    575|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    575|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1830|    575|            *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    575|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1831|    575|            return result;
 1832|       |
 1833|      0|        case CONTAINER_PAIR(BITSET, RUN):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1833:9): [True: 0, False: 6.36k]
  ------------------
 1834|      0|            if (run_container_is_full(const_CAST_run(c2))) {
  ------------------
  |  |   78|      0|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1834:17): [True: 0, False: 0]
  ------------------
 1835|      0|                result = array_container_create();
 1836|      0|                *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1837|      0|                return result;
 1838|      0|            }
 1839|      0|            *result_type =
 1840|      0|                bitset_run_container_andnot(const_CAST_bitset(c1),
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1840:17): [True: 0, False: 0]
  ------------------
 1841|      0|                                            const_CAST_run(c2), &result)
  ------------------
  |  |   78|      0|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1842|      0|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1843|      0|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1844|      0|            return result;
 1845|       |
 1846|    691|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|    691|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    691|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    691|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1846:9): [True: 691, False: 5.66k]
  ------------------
 1847|    691|            *result_type =
 1848|    691|                run_bitset_container_andnot(const_CAST_run(c1),
  ------------------
  |  |   78|    691|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    691|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1848:17): [True: 0, False: 691]
  ------------------
 1849|    691|                                            const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|    691|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    691|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1850|    691|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1851|    691|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  1.38k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1852|    691|            return result;
 1853|       |
 1854|    814|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    814|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    814|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    814|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1854:9): [True: 814, False: 5.54k]
  ------------------
 1855|    814|            if (run_container_is_full(const_CAST_run(c2))) {
  ------------------
  |  |   78|    814|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    814|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1855:17): [True: 34, False: 780]
  ------------------
 1856|     34|                result = array_container_create();
 1857|     34|                *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|     34|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1858|     34|                return result;
 1859|     34|            }
 1860|    780|            result = array_container_create();
 1861|    780|            array_run_container_andnot(const_CAST_array(c1), const_CAST_run(c2),
  ------------------
  |  |   55|    780|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    780|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          array_run_container_andnot(const_CAST_array(c1), const_CAST_run(c2),
  ------------------
  |  |   78|    780|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    780|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1862|    780|                                       CAST_array(result));
  ------------------
  |  |   54|    780|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    780|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1863|    780|            *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    780|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1864|    780|            return result;
 1865|       |
 1866|  1.27k|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|  1.27k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  1.27k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  1.27k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1866:9): [True: 1.27k, False: 5.08k]
  ------------------
 1867|  1.27k|            *result_type = (uint8_t)run_array_container_andnot(
 1868|  1.27k|                const_CAST_run(c1), const_CAST_array(c2), &result);
  ------------------
  |  |   78|  1.27k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.27k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c1), const_CAST_array(c2), &result);
  ------------------
  |  |   55|  1.27k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.27k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1869|  1.27k|            return result;
 1870|       |
 1871|      0|        default:
  ------------------
  |  Branch (1871:9): [True: 0, False: 6.36k]
  ------------------
 1872|      0|            assert(false);
 1873|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1874|      0|            return NULL;  // unreached
 1875|  6.36k|    }
 1876|  6.36k|}
roaring.c:container_iandnot:
 1891|  6.05k|                                             uint8_t *result_type) {
 1892|  6.05k|    c1 = get_writable_copy_if_shared(c1, &type1);
 1893|  6.05k|    c2 = container_unwrap_shared(c2, &type2);
 1894|  6.05k|    container_t *result = NULL;
 1895|  6.05k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  6.05k|#define PAIR_CONTAINER_TYPES(type1, type2) (4 * (type1) + (type2))
  ------------------
 1896|      0|        case CONTAINER_PAIR(BITSET, BITSET):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1896:9): [True: 0, False: 6.05k]
  ------------------
 1897|      0|            *result_type = bitset_bitset_container_iandnot(
  ------------------
  |  Branch (1897:28): [True: 0, False: 0]
  ------------------
 1898|      0|                               CAST_bitset(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   52|      0|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_bitset(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1899|      0|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1900|      0|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1901|      0|            return result;
 1902|       |
 1903|  3.54k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  3.54k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  3.54k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  3.54k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1903:9): [True: 3.54k, False: 2.51k]
  ------------------
 1904|  3.54k|            array_array_container_iandnot(CAST_array(c1), const_CAST_array(c2));
  ------------------
  |  |   54|  3.54k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  3.54k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          array_array_container_iandnot(CAST_array(c1), const_CAST_array(c2));
  ------------------
  |  |   55|  3.54k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.54k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1905|  3.54k|            *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  3.54k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1906|  3.54k|            return c1;
 1907|       |
 1908|    432|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    432|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    432|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    432|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1908:9): [True: 432, False: 5.62k]
  ------------------
 1909|    432|            *result_type = (uint8_t)run_run_container_iandnot(
 1910|    432|                CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   77|    432|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    432|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|    432|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    432|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1911|    432|            return result;
 1912|       |
 1913|  1.23k|        case CONTAINER_PAIR(BITSET, ARRAY):
  ------------------
  |  |   65|  1.23k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  1.23k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  1.23k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1913:9): [True: 1.23k, False: 4.81k]
  ------------------
 1914|  1.23k|            *result_type = bitset_array_container_iandnot(
  ------------------
  |  Branch (1914:28): [True: 1.05k, False: 183]
  ------------------
 1915|  1.23k|                               CAST_bitset(c1), const_CAST_array(c2), &result)
  ------------------
  |  |   52|  1.23k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.23k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_bitset(c1), const_CAST_array(c2), &result)
  ------------------
  |  |   55|  1.23k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.23k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1916|  1.23k|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|  1.05k|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1917|  1.23k|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  1.42k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1918|  1.23k|            return result;
 1919|       |
 1920|      0|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1920:9): [True: 0, False: 6.05k]
  ------------------
 1921|      0|            *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1922|      0|            array_bitset_container_iandnot(CAST_array(c1),
  ------------------
  |  |   54|      0|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1923|      0|                                           const_CAST_bitset(c2));
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1924|      0|            return c1;
 1925|       |
 1926|      0|        case CONTAINER_PAIR(BITSET, RUN):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1926:9): [True: 0, False: 6.05k]
  ------------------
 1927|      0|            *result_type = bitset_run_container_iandnot(
  ------------------
  |  Branch (1927:28): [True: 0, False: 0]
  ------------------
 1928|      0|                               CAST_bitset(c1), const_CAST_run(c2), &result)
  ------------------
  |  |   52|      0|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_bitset(c1), const_CAST_run(c2), &result)
  ------------------
  |  |   78|      0|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1929|      0|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1930|      0|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1931|      0|            return result;
 1932|       |
 1933|      0|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1933:9): [True: 0, False: 6.05k]
  ------------------
 1934|      0|            *result_type = run_bitset_container_iandnot(
  ------------------
  |  Branch (1934:28): [True: 0, False: 0]
  ------------------
 1935|      0|                               CAST_run(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   77|      0|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_run(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1936|      0|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1937|      0|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1938|      0|            return result;
 1939|       |
 1940|     45|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|     45|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|     45|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|     45|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1940:9): [True: 45, False: 6.01k]
  ------------------
 1941|     45|            *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|     45|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1942|     45|            array_run_container_iandnot(CAST_array(c1), const_CAST_run(c2));
  ------------------
  |  |   54|     45|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     45|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          array_run_container_iandnot(CAST_array(c1), const_CAST_run(c2));
  ------------------
  |  |   78|     45|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|     45|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1943|     45|            return c1;
 1944|       |
 1945|    801|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|    801|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    801|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    801|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1945:9): [True: 801, False: 5.25k]
  ------------------
 1946|    801|            *result_type = (uint8_t)run_array_container_iandnot(
 1947|    801|                CAST_run(c1), const_CAST_array(c2), &result);
  ------------------
  |  |   77|    801|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    801|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              CAST_run(c1), const_CAST_array(c2), &result);
  ------------------
  |  |   55|    801|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    801|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1948|    801|            return result;
 1949|       |
 1950|      0|        default:
  ------------------
  |  Branch (1950:9): [True: 0, False: 6.05k]
  ------------------
 1951|      0|            assert(false);
 1952|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1953|      0|            return NULL;
 1954|  6.05k|    }
 1955|  6.05k|}
roaring.c:container_rank:
 2209|  6.48k|                                 uint16_t x) {
 2210|  6.48k|    c = container_unwrap_shared(c, &type);
 2211|  6.48k|    switch (type) {
 2212|      0|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2212:9): [True: 0, False: 6.48k]
  ------------------
 2213|      0|            return bitset_container_rank(const_CAST_bitset(c), x);
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2214|  3.80k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  3.80k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2214:9): [True: 3.80k, False: 2.67k]
  ------------------
 2215|  3.80k|            return array_container_rank(const_CAST_array(c), x);
  ------------------
  |  |   55|  3.80k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.80k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2216|  2.67k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  2.67k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2216:9): [True: 2.67k, False: 3.80k]
  ------------------
 2217|  2.67k|            return run_container_rank(const_CAST_run(c), x);
  ------------------
  |  |   78|  2.67k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.67k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2218|      0|        default:
  ------------------
  |  Branch (2218:9): [True: 0, False: 6.48k]
  ------------------
 2219|      0|            assert(false);
 2220|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2221|  6.48k|    }
 2222|  6.48k|    assert(false);
 2223|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2224|      0|    return false;
 2225|  6.48k|}
roaring.c:container_shrink_to_fit:
  279|  6.48k|static inline int container_shrink_to_fit(container_t *c, uint8_t type) {
  280|  6.48k|    c = container_mutable_unwrap_shared(c, &type);
  281|  6.48k|    switch (type) {
  ------------------
  |  Branch (281:13): [True: 6.48k, False: 0]
  ------------------
  282|      0|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (282:9): [True: 0, False: 6.48k]
  ------------------
  283|      0|            return 0;  // no shrinking possible
  284|  3.80k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  3.80k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (284:9): [True: 3.80k, False: 2.67k]
  ------------------
  285|  3.80k|            return array_container_shrink_to_fit(CAST_array(c));
  ------------------
  |  |   54|  3.80k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  3.80k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  286|  2.67k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  2.67k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (286:9): [True: 2.67k, False: 3.80k]
  ------------------
  287|  2.67k|            return run_container_shrink_to_fit(CAST_run(c));
  ------------------
  |  |   77|  2.67k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  2.67k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  288|  6.48k|    }
  289|  6.48k|    assert(false);
  290|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  291|      0|    return 0;  // unreached
  292|  6.48k|}
roaring.c:container_iterate:
 1964|  69.3k|                                     void *ptr) {
 1965|  69.3k|    c = container_unwrap_shared(c, &type);
 1966|  69.3k|    switch (type) {
 1967|  1.69k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  1.69k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (1967:9): [True: 1.69k, False: 67.6k]
  ------------------
 1968|  1.69k|            return bitset_container_iterate(const_CAST_bitset(c), base,
  ------------------
  |  |   53|  1.69k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.69k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1969|  1.69k|                                            iterator, ptr);
 1970|  6.58k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  6.58k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (1970:9): [True: 6.58k, False: 62.8k]
  ------------------
 1971|  6.58k|            return array_container_iterate(const_CAST_array(c), base, iterator,
  ------------------
  |  |   55|  6.58k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  6.58k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1972|  6.58k|                                           ptr);
 1973|  61.1k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  61.1k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (1973:9): [True: 61.1k, False: 8.27k]
  ------------------
 1974|  61.1k|            return run_container_iterate(const_CAST_run(c), base, iterator,
  ------------------
  |  |   78|  61.1k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  61.1k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1975|  61.1k|                                         ptr);
 1976|      0|        default:
  ------------------
  |  Branch (1976:9): [True: 0, False: 69.3k]
  ------------------
 1977|      0|            assert(false);
 1978|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1979|  69.3k|    }
 1980|  69.3k|    assert(false);
 1981|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1982|      0|    return false;
 1983|  69.3k|}
roaring.c:container_maximum:
 2171|  12.8k|static inline uint16_t container_maximum(const container_t *c, uint8_t type) {
 2172|  12.8k|    c = container_unwrap_shared(c, &type);
 2173|  12.8k|    switch (type) {
 2174|  2.58k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  2.58k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2174:9): [True: 2.58k, False: 10.2k]
  ------------------
 2175|  2.58k|            return bitset_container_maximum(const_CAST_bitset(c));
  ------------------
  |  |   53|  2.58k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.58k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2176|  8.88k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  8.88k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2176:9): [True: 8.88k, False: 3.95k]
  ------------------
 2177|  8.88k|            return array_container_maximum(const_CAST_array(c));
  ------------------
  |  |   55|  8.88k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  8.88k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2178|  1.37k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  1.37k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2178:9): [True: 1.37k, False: 11.4k]
  ------------------
 2179|  1.37k|            return run_container_maximum(const_CAST_run(c));
  ------------------
  |  |   78|  1.37k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.37k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2180|      0|        default:
  ------------------
  |  Branch (2180:9): [True: 0, False: 12.8k]
  ------------------
 2181|      0|            assert(false);
 2182|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2183|  12.8k|    }
 2184|  12.8k|    assert(false);
 2185|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2186|      0|    return false;
 2187|  12.8k|}
roaring.c:container_equals:
  620|  85.0k|                                    const container_t *c2, uint8_t type2) {
  621|  85.0k|    c1 = container_unwrap_shared(c1, &type1);
  622|  85.0k|    c2 = container_unwrap_shared(c2, &type2);
  623|  85.0k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  85.0k|#define PAIR_CONTAINER_TYPES(type1, type2) (4 * (type1) + (type2))
  ------------------
  624|  73.9k|        case CONTAINER_PAIR(BITSET, BITSET):
  ------------------
  |  |   65|  73.9k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  73.9k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  73.9k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (624:9): [True: 73.9k, False: 11.1k]
  ------------------
  625|  73.9k|            return bitset_container_equals(const_CAST_bitset(c1),
  ------------------
  |  |   53|  73.9k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  73.9k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  626|  73.9k|                                           const_CAST_bitset(c2));
  ------------------
  |  |   53|  73.9k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  73.9k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  627|       |
  628|      0|        case CONTAINER_PAIR(BITSET, RUN):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (628:9): [True: 0, False: 85.0k]
  ------------------
  629|      0|            return run_container_equals_bitset(const_CAST_run(c2),
  ------------------
  |  |   78|      0|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  630|      0|                                               const_CAST_bitset(c1));
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  631|       |
  632|      0|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (632:9): [True: 0, False: 85.0k]
  ------------------
  633|      0|            return run_container_equals_bitset(const_CAST_run(c1),
  ------------------
  |  |   78|      0|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  634|      0|                                               const_CAST_bitset(c2));
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  635|       |
  636|      0|        case CONTAINER_PAIR(BITSET, ARRAY):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (636:9): [True: 0, False: 85.0k]
  ------------------
  637|       |            // java would always return false?
  638|      0|            return array_container_equal_bitset(const_CAST_array(c2),
  ------------------
  |  |   55|      0|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  639|      0|                                                const_CAST_bitset(c1));
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  640|       |
  641|    469|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|    469|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    469|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    469|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (641:9): [True: 469, False: 84.6k]
  ------------------
  642|       |            // java would always return false?
  643|    469|            return array_container_equal_bitset(const_CAST_array(c1),
  ------------------
  |  |   55|    469|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    469|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  644|    469|                                                const_CAST_bitset(c2));
  ------------------
  |  |   53|    469|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    469|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  645|       |
  646|    609|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    609|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    609|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    609|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (646:9): [True: 609, False: 84.4k]
  ------------------
  647|    609|            return run_container_equals_array(const_CAST_run(c2),
  ------------------
  |  |   78|    609|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    609|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  648|    609|                                              const_CAST_array(c1));
  ------------------
  |  |   55|    609|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    609|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  649|       |
  650|    277|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|    277|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    277|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    277|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (650:9): [True: 277, False: 84.8k]
  ------------------
  651|    277|            return run_container_equals_array(const_CAST_run(c1),
  ------------------
  |  |   78|    277|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    277|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  652|    277|                                              const_CAST_array(c2));
  ------------------
  |  |   55|    277|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    277|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  653|       |
  654|  9.61k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  9.61k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  9.61k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  9.61k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (654:9): [True: 9.61k, False: 75.4k]
  ------------------
  655|  9.61k|            return array_container_equals(const_CAST_array(c1),
  ------------------
  |  |   55|  9.61k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  9.61k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  656|  9.61k|                                          const_CAST_array(c2));
  ------------------
  |  |   55|  9.61k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  9.61k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  657|       |
  658|    133|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    133|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    133|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    133|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (658:9): [True: 133, False: 84.9k]
  ------------------
  659|    133|            return run_container_equals(const_CAST_run(c1), const_CAST_run(c2));
  ------------------
  |  |   78|    133|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    133|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          return run_container_equals(const_CAST_run(c1), const_CAST_run(c2));
  ------------------
  |  |   78|    133|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    133|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  660|       |
  661|      0|        default:
  ------------------
  |  Branch (661:9): [True: 0, False: 85.0k]
  ------------------
  662|      0|            assert(false);
  663|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  664|      0|            return false;
  665|  85.0k|    }
  666|  85.0k|}
roaring.c:container_is_subset:
  673|  11.1k|                                       const container_t *c2, uint8_t type2) {
  674|  11.1k|    c1 = container_unwrap_shared(c1, &type1);
  675|  11.1k|    c2 = container_unwrap_shared(c2, &type2);
  676|  11.1k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  11.1k|#define PAIR_CONTAINER_TYPES(type1, type2) (4 * (type1) + (type2))
  ------------------
  677|      0|        case CONTAINER_PAIR(BITSET, BITSET):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (677:9): [True: 0, False: 11.1k]
  ------------------
  678|      0|            return bitset_container_is_subset(const_CAST_bitset(c1),
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  679|      0|                                              const_CAST_bitset(c2));
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  680|       |
  681|      0|        case CONTAINER_PAIR(BITSET, RUN):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (681:9): [True: 0, False: 11.1k]
  ------------------
  682|      0|            return bitset_container_is_subset_run(const_CAST_bitset(c1),
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  683|      0|                                                  const_CAST_run(c2));
  ------------------
  |  |   78|      0|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  684|       |
  685|      0|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (685:9): [True: 0, False: 11.1k]
  ------------------
  686|      0|            return run_container_is_subset_bitset(const_CAST_run(c1),
  ------------------
  |  |   78|      0|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  687|      0|                                                  const_CAST_bitset(c2));
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  688|       |
  689|      0|        case CONTAINER_PAIR(BITSET, ARRAY):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (689:9): [True: 0, False: 11.1k]
  ------------------
  690|      0|            return false;  // by construction, size(c1) > size(c2)
  691|       |
  692|  2.45k|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|  2.45k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.45k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  2.45k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (692:9): [True: 2.45k, False: 8.68k]
  ------------------
  693|  2.45k|            return array_container_is_subset_bitset(const_CAST_array(c1),
  ------------------
  |  |   55|  2.45k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.45k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  694|  2.45k|                                                    const_CAST_bitset(c2));
  ------------------
  |  |   53|  2.45k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.45k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  695|       |
  696|  2.25k|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|  2.25k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.25k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  2.25k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (696:9): [True: 2.25k, False: 8.87k]
  ------------------
  697|  2.25k|            return array_container_is_subset_run(const_CAST_array(c1),
  ------------------
  |  |   55|  2.25k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.25k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  698|  2.25k|                                                 const_CAST_run(c2));
  ------------------
  |  |   78|  2.25k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.25k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  699|       |
  700|    423|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|    423|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    423|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    423|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (700:9): [True: 423, False: 10.7k]
  ------------------
  701|    423|            return run_container_is_subset_array(const_CAST_run(c1),
  ------------------
  |  |   78|    423|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    423|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  702|    423|                                                 const_CAST_array(c2));
  ------------------
  |  |   55|    423|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    423|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  703|       |
  704|  5.75k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  5.75k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  5.75k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  5.75k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (704:9): [True: 5.75k, False: 5.37k]
  ------------------
  705|  5.75k|            return array_container_is_subset(const_CAST_array(c1),
  ------------------
  |  |   55|  5.75k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  5.75k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  706|  5.75k|                                             const_CAST_array(c2));
  ------------------
  |  |   55|  5.75k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  5.75k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  707|       |
  708|    244|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    244|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    244|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    244|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (708:9): [True: 244, False: 10.8k]
  ------------------
  709|    244|            return run_container_is_subset(const_CAST_run(c1),
  ------------------
  |  |   78|    244|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    244|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  710|    244|                                           const_CAST_run(c2));
  ------------------
  |  |   78|    244|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    244|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  711|       |
  712|      0|        default:
  ------------------
  |  Branch (712:9): [True: 0, False: 11.1k]
  ------------------
  713|      0|            assert(false);
  714|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  715|      0|            return false;
  716|  11.1k|    }
  717|  11.1k|}
roaring.c:container_inot_range:
 2110|  6.62k|                                                uint8_t *result_type) {
 2111|  6.62k|    c = get_writable_copy_if_shared(c, &type);
 2112|  6.62k|    container_t *result = NULL;
 2113|  6.62k|    switch (type) {
 2114|  1.35k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  1.35k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2114:9): [True: 1.35k, False: 5.27k]
  ------------------
 2115|  1.35k|            *result_type = bitset_container_negation_range_inplace(
  ------------------
  |  Branch (2115:28): [True: 1.33k, False: 22]
  ------------------
 2116|  1.35k|                               CAST_bitset(c), range_start, range_end, &result)
  ------------------
  |  |   52|  1.35k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.35k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2117|  1.35k|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|  1.33k|#define BITSET_CONTAINER_TYPE 1
  ------------------
 2118|  1.35k|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  1.37k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 2119|  1.35k|            return result;
 2120|  3.57k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  3.57k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2120:9): [True: 3.57k, False: 3.05k]
  ------------------
 2121|  3.57k|            *result_type = array_container_negation_range_inplace(
  ------------------
  |  Branch (2121:28): [True: 130, False: 3.44k]
  ------------------
 2122|  3.57k|                               CAST_array(c), range_start, range_end, &result)
  ------------------
  |  |   54|  3.57k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  3.57k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2123|  3.57k|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|    130|#define BITSET_CONTAINER_TYPE 1
  ------------------
 2124|  3.57k|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  7.02k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 2125|  3.57k|            return result;
 2126|  1.69k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  1.69k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2126:9): [True: 1.69k, False: 4.93k]
  ------------------
 2127|  1.69k|            *result_type = (uint8_t)run_container_negation_range_inplace(
 2128|  1.69k|                CAST_run(c), range_start, range_end, &result);
  ------------------
  |  |   77|  1.69k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.69k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2129|  1.69k|            return result;
 2130|       |
 2131|      0|        default:
  ------------------
  |  Branch (2131:9): [True: 0, False: 6.62k]
  ------------------
 2132|      0|            assert(false);
 2133|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2134|  6.62k|    }
 2135|  6.62k|    assert(false);
 2136|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2137|      0|    return NULL;
 2138|  6.62k|}
roaring.c:container_inot:
 2076|  6.85k|                                          uint8_t *result_type) {
 2077|  6.85k|    c = get_writable_copy_if_shared(c, &type);
 2078|  6.85k|    container_t *result = NULL;
 2079|  6.85k|    switch (type) {
 2080|     87|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|     87|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2080:9): [True: 87, False: 6.76k]
  ------------------
 2081|     87|            *result_type =
 2082|     87|                bitset_container_negation_inplace(CAST_bitset(c), &result)
  ------------------
  |  |   52|     87|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     87|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (2082:17): [True: 34, False: 53]
  ------------------
 2083|     87|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|     34|#define BITSET_CONTAINER_TYPE 1
  ------------------
 2084|     87|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    140|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 2085|     87|            return result;
 2086|    185|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|    185|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2086:9): [True: 185, False: 6.67k]
  ------------------
 2087|       |            // will never be inplace
 2088|    185|            result = bitset_container_create();
 2089|    185|            *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|    185|#define BITSET_CONTAINER_TYPE 1
  ------------------
 2090|    185|            array_container_negation(CAST_array(c), CAST_bitset(result));
  ------------------
  |  |   54|    185|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    185|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          array_container_negation(CAST_array(c), CAST_bitset(result));
  ------------------
  |  |   52|    185|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    185|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2091|    185|            array_container_free(CAST_array(c));
  ------------------
  |  |   54|    185|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    185|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2092|    185|            return result;
 2093|  6.58k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  6.58k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2093:9): [True: 6.58k, False: 272]
  ------------------
 2094|  6.58k|            *result_type =
 2095|  6.58k|                (uint8_t)run_container_negation_inplace(CAST_run(c), &result);
  ------------------
  |  |   77|  6.58k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  6.58k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2096|  6.58k|            return result;
 2097|       |
 2098|      0|        default:
  ------------------
  |  Branch (2098:9): [True: 0, False: 6.85k]
  ------------------
 2099|      0|            assert(false);
 2100|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2101|  6.85k|    }
 2102|  6.85k|    assert(false);
 2103|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2104|      0|    return NULL;
 2105|  6.85k|}
roaring.c:container_unwrap_shared:
  106|  1.16M|    const container_t *candidate_shared_container, uint8_t *type) {
  107|  1.16M|    if (*type == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|  1.16M|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (107:9): [True: 0, False: 1.16M]
  ------------------
  108|      0|        *type = const_CAST_shared(candidate_shared_container)->typecode;
  ------------------
  |  |   80|      0|#define const_CAST_shared(c) CAST(const shared_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  109|      0|        assert(*type != SHARED_CONTAINER_TYPE);
  110|      0|        return const_CAST_shared(candidate_shared_container)->container;
  ------------------
  |  |   80|      0|#define const_CAST_shared(c) CAST(const shared_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  111|  1.16M|    } else {
  112|  1.16M|        return candidate_shared_container;
  113|  1.16M|    }
  114|  1.16M|}
roaring.c:container_mutable_unwrap_shared:
  118|  6.48k|                                                           uint8_t *type) {
  119|  6.48k|    if (*type == SHARED_CONTAINER_TYPE) {  // the passed in container is shared
  ------------------
  |  |   51|  6.48k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (119:9): [True: 0, False: 6.48k]
  ------------------
  120|      0|        *type = CAST_shared(c)->typecode;
  ------------------
  |  |   79|      0|#define CAST_shared(c) CAST(shared_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  121|      0|        assert(*type != SHARED_CONTAINER_TYPE);
  122|      0|        return CAST_shared(c)->container;  // return the enclosed container
  ------------------
  |  |   79|      0|#define CAST_shared(c) CAST(shared_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  123|  6.48k|    } else {
  124|  6.48k|        return c;  // wasn't shared, so return as-is
  125|  6.48k|    }
  126|  6.48k|}
roaring.c:container_minimum:
 2189|  6.43k|static inline uint16_t container_minimum(const container_t *c, uint8_t type) {
 2190|  6.43k|    c = container_unwrap_shared(c, &type);
 2191|  6.43k|    switch (type) {
 2192|  1.27k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  1.27k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2192:9): [True: 1.27k, False: 5.15k]
  ------------------
 2193|  1.27k|            return bitset_container_minimum(const_CAST_bitset(c));
  ------------------
  |  |   53|  1.27k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.27k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2194|  3.63k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  3.63k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2194:9): [True: 3.63k, False: 2.79k]
  ------------------
 2195|  3.63k|            return array_container_minimum(const_CAST_array(c));
  ------------------
  |  |   55|  3.63k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.63k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2196|  1.51k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  1.51k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2196:9): [True: 1.51k, False: 4.91k]
  ------------------
 2197|  1.51k|            return run_container_minimum(const_CAST_run(c));
  ------------------
  |  |   78|  1.51k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.51k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2198|      0|        default:
  ------------------
  |  Branch (2198:9): [True: 0, False: 6.43k]
  ------------------
 2199|      0|            assert(false);
 2200|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2201|  6.43k|    }
 2202|  6.43k|    assert(false);
 2203|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2204|      0|    return false;
 2205|  6.43k|}
roaring.c:container_select:
 2150|  6.48k|                                    uint32_t *element) {
 2151|  6.48k|    c = container_unwrap_shared(c, &type);
 2152|  6.48k|    switch (type) {
 2153|      0|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2153:9): [True: 0, False: 6.48k]
  ------------------
 2154|      0|            return bitset_container_select(const_CAST_bitset(c), start_rank,
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2155|      0|                                           rank, element);
 2156|  3.80k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  3.80k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2156:9): [True: 3.80k, False: 2.67k]
  ------------------
 2157|  3.80k|            return array_container_select(const_CAST_array(c), start_rank, rank,
  ------------------
  |  |   55|  3.80k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.80k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2158|  3.80k|                                          element);
 2159|  2.67k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  2.67k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2159:9): [True: 2.67k, False: 3.80k]
  ------------------
 2160|  2.67k|            return run_container_select(const_CAST_run(c), start_rank, rank,
  ------------------
  |  |   78|  2.67k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.67k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2161|  2.67k|                                        element);
 2162|      0|        default:
  ------------------
  |  Branch (2162:9): [True: 0, False: 6.48k]
  ------------------
 2163|      0|            assert(false);
 2164|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2165|  6.48k|    }
 2166|  6.48k|    assert(false);
 2167|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2168|      0|    return false;
 2169|  6.48k|}
roaring.c:container_intersect:
  865|  6.36k|                                       const container_t *c2, uint8_t type2) {
  866|  6.36k|    c1 = container_unwrap_shared(c1, &type1);
  867|  6.36k|    c2 = container_unwrap_shared(c2, &type2);
  868|  6.36k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  6.36k|#define PAIR_CONTAINER_TYPES(type1, type2) (4 * (type1) + (type2))
  ------------------
  869|      0|        case CONTAINER_PAIR(BITSET, BITSET):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (869:9): [True: 0, False: 6.36k]
  ------------------
  870|      0|            return bitset_container_intersect(const_CAST_bitset(c1),
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  871|      0|                                              const_CAST_bitset(c2));
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  872|       |
  873|  2.32k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  2.32k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.32k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.32k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (873:9): [True: 2.32k, False: 4.03k]
  ------------------
  874|  2.32k|            return array_container_intersect(const_CAST_array(c1),
  ------------------
  |  |   55|  2.32k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.32k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  875|  2.32k|                                             const_CAST_array(c2));
  ------------------
  |  |   55|  2.32k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.32k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  876|       |
  877|    680|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    680|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    680|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    680|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (877:9): [True: 680, False: 5.68k]
  ------------------
  878|    680|            return run_container_intersect(const_CAST_run(c1),
  ------------------
  |  |   78|    680|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    680|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  879|    680|                                           const_CAST_run(c2));
  ------------------
  |  |   78|    680|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    680|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  880|       |
  881|      0|        case CONTAINER_PAIR(BITSET, ARRAY):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (881:9): [True: 0, False: 6.36k]
  ------------------
  882|      0|            return array_bitset_container_intersect(const_CAST_array(c2),
  ------------------
  |  |   55|      0|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  883|      0|                                                    const_CAST_bitset(c1));
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  884|       |
  885|    575|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|    575|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    575|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    575|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (885:9): [True: 575, False: 5.78k]
  ------------------
  886|    575|            return array_bitset_container_intersect(const_CAST_array(c1),
  ------------------
  |  |   55|    575|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    575|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  887|    575|                                                    const_CAST_bitset(c2));
  ------------------
  |  |   53|    575|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    575|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  888|       |
  889|      0|        case CONTAINER_PAIR(BITSET, RUN):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (889:9): [True: 0, False: 6.36k]
  ------------------
  890|      0|            return run_bitset_container_intersect(const_CAST_run(c2),
  ------------------
  |  |   78|      0|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  891|      0|                                                  const_CAST_bitset(c1));
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  892|       |
  893|    691|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|    691|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    691|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    691|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (893:9): [True: 691, False: 5.66k]
  ------------------
  894|    691|            return run_bitset_container_intersect(const_CAST_run(c1),
  ------------------
  |  |   78|    691|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    691|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  895|    691|                                                  const_CAST_bitset(c2));
  ------------------
  |  |   53|    691|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    691|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  896|       |
  897|    814|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    814|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    814|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    814|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (897:9): [True: 814, False: 5.54k]
  ------------------
  898|    814|            return array_run_container_intersect(const_CAST_array(c1),
  ------------------
  |  |   55|    814|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    814|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  899|    814|                                                 const_CAST_run(c2));
  ------------------
  |  |   78|    814|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    814|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  900|       |
  901|  1.27k|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|  1.27k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  1.27k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  1.27k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (901:9): [True: 1.27k, False: 5.08k]
  ------------------
  902|  1.27k|            return array_run_container_intersect(const_CAST_array(c2),
  ------------------
  |  |   55|  1.27k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.27k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  903|  1.27k|                                                 const_CAST_run(c1));
  ------------------
  |  |   78|  1.27k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.27k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  904|       |
  905|      0|        default:
  ------------------
  |  Branch (905:9): [True: 0, False: 6.36k]
  ------------------
  906|      0|            assert(false);
  907|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  908|      0|            return 0;
  909|  6.36k|    }
  910|  6.36k|}
roaring.c:container_and_cardinality:
  814|  25.4k|                                            uint8_t type2) {
  815|  25.4k|    c1 = container_unwrap_shared(c1, &type1);
  816|  25.4k|    c2 = container_unwrap_shared(c2, &type2);
  817|  25.4k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  25.4k|#define PAIR_CONTAINER_TYPES(type1, type2) (4 * (type1) + (type2))
  ------------------
  818|      0|        case CONTAINER_PAIR(BITSET, BITSET):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (818:9): [True: 0, False: 25.4k]
  ------------------
  819|      0|            return bitset_container_and_justcard(const_CAST_bitset(c1),
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  820|      0|                                                 const_CAST_bitset(c2));
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  821|       |
  822|  9.29k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  9.29k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  9.29k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  9.29k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (822:9): [True: 9.29k, False: 16.1k]
  ------------------
  823|  9.29k|            return array_container_intersection_cardinality(
  824|  9.29k|                const_CAST_array(c1), const_CAST_array(c2));
  ------------------
  |  |   55|  9.29k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  9.29k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_array(c2));
  ------------------
  |  |   55|  9.29k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  9.29k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  825|       |
  826|  2.72k|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|  2.72k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  2.72k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  2.72k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (826:9): [True: 2.72k, False: 22.7k]
  ------------------
  827|  2.72k|            return run_container_intersection_cardinality(const_CAST_run(c1),
  ------------------
  |  |   78|  2.72k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.72k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  828|  2.72k|                                                          const_CAST_run(c2));
  ------------------
  |  |   78|  2.72k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.72k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  829|       |
  830|      0|        case CONTAINER_PAIR(BITSET, ARRAY):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (830:9): [True: 0, False: 25.4k]
  ------------------
  831|      0|            return array_bitset_container_intersection_cardinality(
  832|      0|                const_CAST_array(c2), const_CAST_bitset(c1));
  ------------------
  |  |   55|      0|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c2), const_CAST_bitset(c1));
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  833|       |
  834|  2.30k|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|  2.30k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.30k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  2.30k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (834:9): [True: 2.30k, False: 23.1k]
  ------------------
  835|  2.30k|            return array_bitset_container_intersection_cardinality(
  836|  2.30k|                const_CAST_array(c1), const_CAST_bitset(c2));
  ------------------
  |  |   55|  2.30k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.30k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_bitset(c2));
  ------------------
  |  |   53|  2.30k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.30k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  837|       |
  838|      0|        case CONTAINER_PAIR(BITSET, RUN):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (838:9): [True: 0, False: 25.4k]
  ------------------
  839|      0|            return run_bitset_container_intersection_cardinality(
  840|      0|                const_CAST_run(c2), const_CAST_bitset(c1));
  ------------------
  |  |   78|      0|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c2), const_CAST_bitset(c1));
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  841|       |
  842|  2.76k|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|  2.76k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  2.76k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  2.76k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (842:9): [True: 2.76k, False: 22.6k]
  ------------------
  843|  2.76k|            return run_bitset_container_intersection_cardinality(
  844|  2.76k|                const_CAST_run(c1), const_CAST_bitset(c2));
  ------------------
  |  |   78|  2.76k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.76k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c1), const_CAST_bitset(c2));
  ------------------
  |  |   53|  2.76k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.76k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  845|       |
  846|  3.25k|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|  3.25k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  3.25k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  3.25k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (846:9): [True: 3.25k, False: 22.1k]
  ------------------
  847|  3.25k|            return array_run_container_intersection_cardinality(
  848|  3.25k|                const_CAST_array(c1), const_CAST_run(c2));
  ------------------
  |  |   55|  3.25k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.25k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_run(c2));
  ------------------
  |  |   78|  3.25k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.25k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  849|       |
  850|  5.10k|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|  5.10k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  5.10k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  5.10k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (850:9): [True: 5.10k, False: 20.3k]
  ------------------
  851|  5.10k|            return array_run_container_intersection_cardinality(
  852|  5.10k|                const_CAST_array(c2), const_CAST_run(c1));
  ------------------
  |  |   55|  5.10k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  5.10k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c2), const_CAST_run(c1));
  ------------------
  |  |   78|  5.10k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  5.10k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  853|       |
  854|      0|        default:
  ------------------
  |  Branch (854:9): [True: 0, False: 25.4k]
  ------------------
  855|      0|            assert(false);
  856|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  857|      0|            return 0;
  858|  25.4k|    }
  859|  25.4k|}
roaring.c:container_contains_range:
  596|    583|) {
  597|    583|    c = container_unwrap_shared(c, &typecode);
  598|    583|    switch (typecode) {
  599|    263|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|    263|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (599:9): [True: 263, False: 320]
  ------------------
  600|    263|            return bitset_container_get_range(const_CAST_bitset(c), range_start,
  ------------------
  |  |   53|    263|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    263|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  601|    263|                                              range_end);
  602|    122|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|    122|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (602:9): [True: 122, False: 461]
  ------------------
  603|    122|            return array_container_contains_range(const_CAST_array(c),
  ------------------
  |  |   55|    122|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    122|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  604|    122|                                                  range_start, range_end);
  605|    198|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|    198|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (605:9): [True: 198, False: 385]
  ------------------
  606|    198|            return run_container_contains_range(const_CAST_run(c), range_start,
  ------------------
  |  |   78|    198|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    198|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  607|    198|                                                range_end);
  608|      0|        default:
  ------------------
  |  Branch (608:9): [True: 0, False: 583]
  ------------------
  609|      0|            assert(false);
  610|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  611|      0|            return false;
  612|    583|    }
  613|    583|}
roaring_array.c:container_to_uint32_array:
  465|  69.2k|                                            uint8_t typecode, uint32_t base) {
  466|  69.2k|    c = container_unwrap_shared(c, &typecode);
  467|  69.2k|    switch (typecode) {
  ------------------
  |  Branch (467:13): [True: 69.2k, False: 0]
  ------------------
  468|  1.51k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  1.51k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (468:9): [True: 1.51k, False: 67.7k]
  ------------------
  469|  1.51k|            return bitset_container_to_uint32_array(output,
  470|  1.51k|                                                    const_CAST_bitset(c), base);
  ------------------
  |  |   53|  1.51k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.51k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  471|  5.98k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  5.98k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (471:9): [True: 5.98k, False: 63.2k]
  ------------------
  472|  5.98k|            return array_container_to_uint32_array(output, const_CAST_array(c),
  ------------------
  |  |   55|  5.98k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  5.98k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  473|  5.98k|                                                   base);
  474|  61.7k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  61.7k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (474:9): [True: 61.7k, False: 7.50k]
  ------------------
  475|  61.7k|            return run_container_to_uint32_array(output, const_CAST_run(c),
  ------------------
  |  |   78|  61.7k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  61.7k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  476|  61.7k|                                                 base);
  477|  69.2k|    }
  478|  69.2k|    assert(false);
  479|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  480|      0|    return 0;  // unreached
  481|  69.2k|}
roaring_array.c:container_unwrap_shared:
  106|   400k|    const container_t *candidate_shared_container, uint8_t *type) {
  107|   400k|    if (*type == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|   400k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (107:9): [True: 0, False: 400k]
  ------------------
  108|      0|        *type = const_CAST_shared(candidate_shared_container)->typecode;
  ------------------
  |  |   80|      0|#define const_CAST_shared(c) CAST(const shared_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  109|      0|        assert(*type != SHARED_CONTAINER_TYPE);
  110|      0|        return const_CAST_shared(candidate_shared_container)->container;
  ------------------
  |  |   80|      0|#define const_CAST_shared(c) CAST(const shared_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  111|   400k|    } else {
  112|   400k|        return candidate_shared_container;
  113|   400k|    }
  114|   400k|}
roaring_array.c:get_container_type:
  129|   168k|static inline uint8_t get_container_type(const container_t *c, uint8_t type) {
  130|   168k|    if (type == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|   168k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (130:9): [True: 0, False: 168k]
  ------------------
  131|      0|        return const_CAST_shared(c)->typecode;
  ------------------
  |  |   80|      0|#define const_CAST_shared(c) CAST(const shared_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  132|   168k|    } else {
  133|   168k|        return type;
  134|   168k|    }
  135|   168k|}
roaring_array.c:container_size_in_bytes:
  403|   168k|                                              uint8_t typecode) {
  404|   168k|    c = container_unwrap_shared(c, &typecode);
  405|   168k|    switch (typecode) {
  ------------------
  |  Branch (405:13): [True: 168k, False: 0]
  ------------------
  406|   147k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|   147k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (406:9): [True: 147k, False: 20.8k]
  ------------------
  407|   147k|            return bitset_container_size_in_bytes(const_CAST_bitset(c));
  ------------------
  |  |   53|   147k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|   147k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  408|  18.2k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  18.2k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (408:9): [True: 18.2k, False: 150k]
  ------------------
  409|  18.2k|            return array_container_size_in_bytes(const_CAST_array(c));
  ------------------
  |  |   55|  18.2k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  18.2k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  410|  2.67k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  2.67k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (410:9): [True: 2.67k, False: 166k]
  ------------------
  411|  2.67k|            return run_container_size_in_bytes(const_CAST_run(c));
  ------------------
  |  |   78|  2.67k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.67k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  412|   168k|    }
  413|   168k|    assert(false);
  414|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  415|      0|    return 0;  // unreached
  416|   168k|}
roaring_array.c:container_get_cardinality:
  244|  81.1k|                                            uint8_t typecode) {
  245|  81.1k|    c = container_unwrap_shared(c, &typecode);
  246|  81.1k|    switch (typecode) {
  ------------------
  |  Branch (246:13): [True: 81.1k, False: 0]
  ------------------
  247|  73.9k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  73.9k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (247:9): [True: 73.9k, False: 7.20k]
  ------------------
  248|  73.9k|            return bitset_container_cardinality(const_CAST_bitset(c));
  ------------------
  |  |   53|  73.9k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  73.9k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  249|  7.20k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  7.20k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (249:9): [True: 7.20k, False: 73.9k]
  ------------------
  250|  7.20k|            return array_container_cardinality(const_CAST_array(c));
  ------------------
  |  |   55|  7.20k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  7.20k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  251|      0|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (251:9): [True: 0, False: 81.1k]
  ------------------
  252|      0|            return run_container_cardinality(const_CAST_run(c));
  ------------------
  |  |   78|      0|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  253|  81.1k|    }
  254|  81.1k|    assert(false);
  255|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  256|      0|    return 0;  // unreached
  257|  81.1k|}
roaring_array.c:container_write:
  382|  81.1k|                                      char *buf) {
  383|  81.1k|    c = container_unwrap_shared(c, &typecode);
  384|  81.1k|    switch (typecode) {
  ------------------
  |  Branch (384:13): [True: 81.1k, False: 0]
  ------------------
  385|  73.9k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  73.9k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (385:9): [True: 73.9k, False: 7.20k]
  ------------------
  386|  73.9k|            return bitset_container_write(const_CAST_bitset(c), buf);
  ------------------
  |  |   53|  73.9k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  73.9k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  387|  7.20k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  7.20k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (387:9): [True: 7.20k, False: 73.9k]
  ------------------
  388|  7.20k|            return array_container_write(const_CAST_array(c), buf);
  ------------------
  |  |   55|  7.20k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  7.20k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  389|      0|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (389:9): [True: 0, False: 81.1k]
  ------------------
  390|      0|            return run_container_write(const_CAST_run(c), buf);
  ------------------
  |  |   78|      0|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  391|  81.1k|    }
  392|  81.1k|    assert(false);
  393|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  394|      0|    return 0;  // unreached
  395|  81.1k|}
containers.c:container_unwrap_shared:
  106|  6.64k|    const container_t *candidate_shared_container, uint8_t *type) {
  107|  6.64k|    if (*type == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|  6.64k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (107:9): [True: 0, False: 6.64k]
  ------------------
  108|      0|        *type = const_CAST_shared(candidate_shared_container)->typecode;
  ------------------
  |  |   80|      0|#define const_CAST_shared(c) CAST(const shared_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  109|      0|        assert(*type != SHARED_CONTAINER_TYPE);
  110|      0|        return const_CAST_shared(candidate_shared_container)->container;
  ------------------
  |  |   80|      0|#define const_CAST_shared(c) CAST(const shared_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  111|  6.64k|    } else {
  112|  6.64k|        return candidate_shared_container;
  113|  6.64k|    }
  114|  6.64k|}
containers.c:container_maximum:
 2171|  6.38k|static inline uint16_t container_maximum(const container_t *c, uint8_t type) {
 2172|  6.38k|    c = container_unwrap_shared(c, &type);
 2173|  6.38k|    switch (type) {
 2174|  1.91k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  1.91k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2174:9): [True: 1.91k, False: 4.46k]
  ------------------
 2175|  1.91k|            return bitset_container_maximum(const_CAST_bitset(c));
  ------------------
  |  |   53|  1.91k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.91k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2176|  4.46k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  4.46k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2176:9): [True: 4.46k, False: 1.91k]
  ------------------
 2177|  4.46k|            return array_container_maximum(const_CAST_array(c));
  ------------------
  |  |   55|  4.46k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  4.46k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2178|      0|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2178:9): [True: 0, False: 6.38k]
  ------------------
 2179|      0|            return run_container_maximum(const_CAST_run(c));
  ------------------
  |  |   78|      0|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2180|      0|        default:
  ------------------
  |  Branch (2180:9): [True: 0, False: 6.38k]
  ------------------
 2181|      0|            assert(false);
 2182|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2183|  6.38k|    }
 2184|  6.38k|    assert(false);
 2185|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2186|      0|    return false;
 2187|  6.38k|}

run_container_contains:
  260|  9.49k|inline bool run_container_contains(const run_container_t *run, uint16_t pos) {
  261|  9.49k|    int32_t index = interleavedBinarySearch(run->runs, run->n_runs, pos);
  262|  9.49k|    if (index >= 0) return true;
  ------------------
  |  Branch (262:9): [True: 7.00k, False: 2.49k]
  ------------------
  263|  2.49k|    index = -index - 2;  // points to preceding value, possibly -1
  264|  2.49k|    if (index != -1) {   // possible match
  ------------------
  |  Branch (264:9): [True: 861, False: 1.63k]
  ------------------
  265|    861|        int32_t offset = pos - run->runs[index].value;
  266|    861|        int32_t le = run->runs[index].length;
  267|    861|        if (offset <= le) return true;
  ------------------
  |  Branch (267:13): [True: 573, False: 288]
  ------------------
  268|    861|    }
  269|  1.92k|    return false;
  270|  2.49k|}
interleavedBinarySearch:
  112|   426k|                                       uint16_t ikey) {
  113|   426k|    int32_t low = 0;
  114|   426k|    int32_t high = lenarray - 1;
  115|  1.95M|    while (low <= high) {
  ------------------
  |  Branch (115:12): [True: 1.72M, False: 234k]
  ------------------
  116|  1.72M|        int32_t middleIndex = (low + high) >> 1;
  117|  1.72M|        uint16_t middleValue = array[middleIndex].value;
  118|  1.72M|        if (middleValue < ikey) {
  ------------------
  |  Branch (118:13): [True: 682k, False: 1.03M]
  ------------------
  119|   682k|            low = middleIndex + 1;
  120|  1.03M|        } else if (middleValue > ikey) {
  ------------------
  |  Branch (120:20): [True: 846k, False: 192k]
  ------------------
  121|   846k|            high = middleIndex - 1;
  122|   846k|        } else {
  123|   192k|            return middleIndex;
  124|   192k|        }
  125|  1.72M|    }
  126|   234k|    return -(low + 1);
  127|   426k|}
run_container_minimum:
  563|  16.6k|inline uint16_t run_container_minimum(const run_container_t *run) {
  564|  16.6k|    if (run->n_runs == 0) return 0;
  ------------------
  |  Branch (564:9): [True: 0, False: 16.6k]
  ------------------
  565|  16.6k|    return run->runs[0].value;
  566|  16.6k|}
run_container_maximum:
  569|  16.1k|inline uint16_t run_container_maximum(const run_container_t *run) {
  570|  16.1k|    if (run->n_runs == 0) return 0;
  ------------------
  |  Branch (570:9): [True: 0, False: 16.1k]
  ------------------
  571|  16.1k|    return run->runs[run->n_runs - 1].value + run->runs[run->n_runs - 1].length;
  572|  16.1k|}
roaring.c:run_container_create_range:
  532|  92.0k|                                                          uint32_t stop) {
  533|  92.0k|    run_container_t *rc = run_container_create_given_capacity(1);
  534|  92.0k|    if (rc) {
  ------------------
  |  Branch (534:9): [True: 92.0k, False: 0]
  ------------------
  535|  92.0k|        rle16_t r;
  536|  92.0k|        r.value = (uint16_t)start;
  537|  92.0k|        r.length = (uint16_t)(stop - start - 1);
  538|  92.0k|        run_container_append_first(rc, r);
  539|  92.0k|    }
  540|  92.0k|    return rc;
  541|  92.0k|}
roaring.c:run_container_append_first:
  351|  92.0k|                                                 rle16_t vl) {
  352|  92.0k|    run->runs[run->n_runs] = vl;
  353|  92.0k|    run->n_runs++;
  354|  92.0k|    return vl;
  355|  92.0k|}
roaring.c:rle16_count_greater:
  178|    462|                                          int32_t lenarray, uint16_t key) {
  179|    462|    if (lenarray == 0) return 0;
  ------------------
  |  Branch (179:9): [True: 0, False: 462]
  ------------------
  180|    462|    int32_t low = 0;
  181|    462|    int32_t high = lenarray - 1;
  182|  3.55k|    while (low <= high) {
  ------------------
  |  Branch (182:12): [True: 3.12k, False: 439]
  ------------------
  183|  3.12k|        int32_t middleIndex = (low + high) >> 1;
  184|  3.12k|        uint16_t min_value = array[middleIndex].value;
  185|  3.12k|        uint16_t max_value =
  186|  3.12k|            array[middleIndex].value + array[middleIndex].length;
  187|  3.12k|        if (max_value < key) {
  ------------------
  |  Branch (187:13): [True: 2.91k, False: 208]
  ------------------
  188|  2.91k|            low = middleIndex + 1;
  189|  2.91k|        } else if (key + UINT32_C(1) < min_value) {  // uint32 arithmetic
  ------------------
  |  Branch (189:20): [True: 185, False: 23]
  ------------------
  190|    185|            high = middleIndex - 1;
  191|    185|        } else {
  192|     23|            return lenarray - (middleIndex + 1);
  193|     23|        }
  194|  3.12k|    }
  195|    439|    return lenarray - low;
  196|    462|}
roaring.c:rle16_count_less:
  157|    462|                                       uint16_t key) {
  158|    462|    if (lenarray == 0) return 0;
  ------------------
  |  Branch (158:9): [True: 1, False: 461]
  ------------------
  159|    461|    int32_t low = 0;
  160|    461|    int32_t high = lenarray - 1;
  161|  2.98k|    while (low <= high) {
  ------------------
  |  Branch (161:12): [True: 2.77k, False: 207]
  ------------------
  162|  2.77k|        int32_t middleIndex = (low + high) >> 1;
  163|  2.77k|        uint16_t min_value = array[middleIndex].value;
  164|  2.77k|        uint16_t max_value =
  165|  2.77k|            array[middleIndex].value + array[middleIndex].length;
  166|  2.77k|        if (max_value + UINT32_C(1) < key) {  // uint32 arithmetic
  ------------------
  |  Branch (166:13): [True: 1.28k, False: 1.48k]
  ------------------
  167|  1.28k|            low = middleIndex + 1;
  168|  1.48k|        } else if (key < min_value) {
  ------------------
  |  Branch (168:20): [True: 1.23k, False: 254]
  ------------------
  169|  1.23k|            high = middleIndex - 1;
  170|  1.23k|        } else {
  171|    254|            return middleIndex;
  172|    254|        }
  173|  2.77k|    }
  174|    207|    return low;
  175|    461|}
roaring.c:run_container_add_range_nruns:
  610|    462|                                                 int32_t nruns_greater) {
  611|    462|    int32_t nruns_common = run->n_runs - nruns_less - nruns_greater;
  612|    462|    if (nruns_common == 0) {
  ------------------
  |  Branch (612:9): [True: 139, False: 323]
  ------------------
  613|    139|        makeRoomAtIndex(run, (uint16_t)nruns_less);
  614|    139|        run->runs[nruns_less].value = (uint16_t)min;
  615|    139|        run->runs[nruns_less].length = (uint16_t)(max - min);
  616|    323|    } else {
  617|    323|        uint32_t common_min = run->runs[nruns_less].value;
  618|    323|        uint32_t common_max = run->runs[nruns_less + nruns_common - 1].value +
  619|    323|                              run->runs[nruns_less + nruns_common - 1].length;
  620|    323|        uint32_t result_min = (common_min < min) ? common_min : min;
  ------------------
  |  Branch (620:31): [True: 68, False: 255]
  ------------------
  621|    323|        uint32_t result_max = (common_max > max) ? common_max : max;
  ------------------
  |  Branch (621:31): [True: 14, False: 309]
  ------------------
  622|       |
  623|    323|        run->runs[nruns_less].value = (uint16_t)result_min;
  624|    323|        run->runs[nruns_less].length = (uint16_t)(result_max - result_min);
  625|       |
  626|    323|        memmove(&(run->runs[nruns_less + 1]),
  627|    323|                &(run->runs[run->n_runs - nruns_greater]),
  628|    323|                nruns_greater * sizeof(rle16_t));
  629|    323|        run->n_runs = nruns_less + 1 + nruns_greater;
  630|    323|    }
  631|    462|}
roaring.c:makeRoomAtIndex:
  208|    888|static inline void makeRoomAtIndex(run_container_t *run, uint16_t index) {
  209|       |    /* This function calls realloc + memmove sequentially to move by one index.
  210|       |     * Potentially copying twice the array.
  211|       |     */
  212|    888|    if (run->n_runs + 1 > run->capacity)
  ------------------
  |  Branch (212:9): [True: 736, False: 152]
  ------------------
  213|    736|        run_container_grow(run, run->n_runs + 1, true);
  214|    888|    memmove(run->runs + 1 + index, run->runs + index,
  215|    888|            (run->n_runs - index) * sizeof(rle16_t));
  216|    888|    run->n_runs++;
  217|    888|}
roaring.c:run_container_remove_range:
  667|  1.75k|                                              uint32_t min, uint32_t max) {
  668|  1.75k|    int32_t first = rle16_find_run(run->runs, run->n_runs, (uint16_t)min);
  669|  1.75k|    int32_t last = rle16_find_run(run->runs, run->n_runs, (uint16_t)max);
  670|       |
  671|  1.75k|    if (first >= 0 && min > run->runs[first].value &&
  ------------------
  |  Branch (671:9): [True: 621, False: 1.13k]
  |  Branch (671:23): [True: 276, False: 345]
  ------------------
  672|    276|        max < ((uint32_t)run->runs[first].value +
  ------------------
  |  Branch (672:9): [True: 35, False: 241]
  ------------------
  673|    276|               (uint32_t)run->runs[first].length)) {
  674|       |        // split this run into two adjacent runs
  675|       |
  676|       |        // right subinterval
  677|     35|        makeRoomAtIndex(run, (uint16_t)(first + 1));
  678|     35|        run->runs[first + 1].value = (uint16_t)(max + 1);
  679|     35|        run->runs[first + 1].length =
  680|     35|            (uint16_t)((run->runs[first].value + run->runs[first].length) -
  681|     35|                       (max + 1));
  682|       |
  683|       |        // left subinterval
  684|     35|        run->runs[first].length =
  685|     35|            (uint16_t)((min - 1) - run->runs[first].value);
  686|       |
  687|     35|        return;
  688|     35|    }
  689|       |
  690|       |    // update left-most partial run
  691|  1.72k|    if (first >= 0) {
  ------------------
  |  Branch (691:9): [True: 586, False: 1.13k]
  ------------------
  692|    586|        if (min > run->runs[first].value) {
  ------------------
  |  Branch (692:13): [True: 241, False: 345]
  ------------------
  693|    241|            run->runs[first].length =
  694|    241|                (uint16_t)((min - 1) - run->runs[first].value);
  695|    241|            first++;
  696|    241|        }
  697|  1.13k|    } else {
  698|  1.13k|        first = -first - 1;
  699|  1.13k|    }
  700|       |
  701|       |    // update right-most run
  702|  1.72k|    if (last >= 0) {
  ------------------
  |  Branch (702:9): [True: 557, False: 1.16k]
  ------------------
  703|    557|        uint16_t run_max = run->runs[last].value + run->runs[last].length;
  704|    557|        if (run_max > max) {
  ------------------
  |  Branch (704:13): [True: 332, False: 225]
  ------------------
  705|    332|            run->runs[last].value = (uint16_t)(max + 1);
  706|    332|            run->runs[last].length = (uint16_t)(run_max - (max + 1));
  707|    332|            last--;
  708|    332|        }
  709|  1.16k|    } else {
  710|  1.16k|        last = (-last - 1) - 1;
  711|  1.16k|    }
  712|       |
  713|       |    // remove intermediate runs
  714|  1.72k|    if (first <= last) {
  ------------------
  |  Branch (714:9): [True: 157, False: 1.56k]
  ------------------
  715|    157|        run_container_shift_tail(run, run->n_runs - (last + 1),
  716|    157|                                 -(last - first + 1));
  717|    157|    }
  718|  1.72k|}
roaring.c:rle16_find_run:
  133|  3.51k|                                     uint16_t ikey) {
  134|  3.51k|    int32_t low = 0;
  135|  3.51k|    int32_t high = lenarray - 1;
  136|  14.9k|    while (low <= high) {
  ------------------
  |  Branch (136:12): [True: 12.6k, False: 2.30k]
  ------------------
  137|  12.6k|        int32_t middleIndex = (low + high) >> 1;
  138|  12.6k|        uint16_t min = array[middleIndex].value;
  139|  12.6k|        uint16_t max = array[middleIndex].value + array[middleIndex].length;
  140|  12.6k|        if (ikey > max) {
  ------------------
  |  Branch (140:13): [True: 1.52k, False: 11.1k]
  ------------------
  141|  1.52k|            low = middleIndex + 1;
  142|  11.1k|        } else if (ikey < min) {
  ------------------
  |  Branch (142:20): [True: 9.88k, False: 1.21k]
  ------------------
  143|  9.88k|            high = middleIndex - 1;
  144|  9.88k|        } else {
  145|  1.21k|            return middleIndex;
  146|  1.21k|        }
  147|  12.6k|    }
  148|  2.30k|    return -(low + 1);
  149|  3.51k|}
roaring.c:run_container_shift_tail:
  650|    157|                                            int32_t distance) {
  651|    157|    if (distance > 0) {
  ------------------
  |  Branch (651:9): [True: 0, False: 157]
  ------------------
  652|      0|        if (run->capacity < count + distance) {
  ------------------
  |  Branch (652:13): [True: 0, False: 0]
  ------------------
  653|       |            run_container_grow(run, count + distance, true);
  654|      0|        }
  655|      0|    }
  656|    157|    int32_t srcpos = run->n_runs - count;
  657|    157|    int32_t dstpos = srcpos + distance;
  658|    157|    memmove(&(run->runs[dstpos]), &(run->runs[srcpos]),
  659|    157|            sizeof(rle16_t) * count);
  660|    157|    run->n_runs += distance;
  661|    157|}
roaring.c:run_container_remove:
  223|  3.14k|static inline bool run_container_remove(run_container_t *run, uint16_t pos) {
  224|  3.14k|    int32_t index = interleavedBinarySearch(run->runs, run->n_runs, pos);
  225|  3.14k|    if (index >= 0) {
  ------------------
  |  Branch (225:9): [True: 1.19k, False: 1.94k]
  ------------------
  226|  1.19k|        int32_t le = run->runs[index].length;
  227|  1.19k|        if (le == 0) {
  ------------------
  |  Branch (227:13): [True: 238, False: 958]
  ------------------
  228|    238|            recoverRoomAtIndex(run, (uint16_t)index);
  229|    958|        } else {
  230|    958|            run->runs[index].value++;
  231|    958|            run->runs[index].length--;
  232|    958|        }
  233|  1.19k|        return true;
  234|  1.19k|    }
  235|  1.94k|    index = -index - 2;  // points to preceding value, possibly -1
  236|  1.94k|    if (index >= 0) {    // possible match
  ------------------
  |  Branch (236:9): [True: 960, False: 985]
  ------------------
  237|    960|        int32_t offset = pos - run->runs[index].value;
  238|    960|        int32_t le = run->runs[index].length;
  239|    960|        if (offset < le) {
  ------------------
  |  Branch (239:13): [True: 714, False: 246]
  ------------------
  240|       |            // need to break in two
  241|    714|            run->runs[index].length = (uint16_t)(offset - 1);
  242|       |            // need to insert
  243|    714|            uint16_t newvalue = pos + 1;
  244|    714|            int32_t newlength = le - offset - 1;
  245|    714|            makeRoomAtIndex(run, (uint16_t)(index + 1));
  246|    714|            run->runs[index + 1].value = newvalue;
  247|    714|            run->runs[index + 1].length = (uint16_t)newlength;
  248|    714|            return true;
  249|       |
  250|    714|        } else if (offset == le) {
  ------------------
  |  Branch (250:20): [True: 38, False: 208]
  ------------------
  251|     38|            run->runs[index].length--;
  252|     38|            return true;
  253|     38|        }
  254|    960|    }
  255|       |    // no match
  256|  1.19k|    return false;
  257|  1.94k|}
roaring.c:recoverRoomAtIndex:
  102|    238|static inline void recoverRoomAtIndex(run_container_t *run, uint16_t index) {
  103|    238|    memmove(run->runs + index, run->runs + (1 + index),
  104|    238|            (run->n_runs - index - 1) * sizeof(rle16_t));
  105|    238|    run->n_runs--;
  106|    238|}
roaring.c:run_container_nonzero_cardinality:
  309|  67.0k|    const run_container_t *run) {
  310|  67.0k|    return run->n_runs > 0;  // runs never empty
  311|  67.0k|}
roaring.c:run_container_is_full:
  394|  6.41k|static inline bool run_container_is_full(const run_container_t *run) {
  395|  6.41k|    rle16_t vl = run->runs[0];
  396|  6.41k|    return (run->n_runs == 1) && (vl.value == 0) && (vl.length == 0xFFFF);
  ------------------
  |  Branch (396:12): [True: 1.26k, False: 5.14k]
  |  Branch (396:34): [True: 1.01k, False: 251]
  |  Branch (396:53): [True: 896, False: 121]
  ------------------
  397|  6.41k|}
roaring.c:run_container_equals:
  502|    133|                                        const run_container_t *container2) {
  503|    133|    if (container1->n_runs != container2->n_runs) {
  ------------------
  |  Branch (503:9): [True: 100, False: 33]
  ------------------
  504|    100|        return false;
  505|    100|    }
  506|     33|    return memequals(container1->runs, container2->runs,
  507|     33|                     container1->n_runs * sizeof(rle16_t));
  508|    133|}
roaring.c:run_container_contains_range:
  278|    198|                                                uint32_t pos_end) {
  279|    198|    uint32_t count = 0;
  280|    198|    int32_t index =
  281|    198|        interleavedBinarySearch(run->runs, run->n_runs, (uint16_t)pos_start);
  282|    198|    if (index < 0) {
  ------------------
  |  Branch (282:9): [True: 127, False: 71]
  ------------------
  283|    127|        index = -index - 2;
  284|    127|        if ((index == -1) ||
  ------------------
  |  Branch (284:13): [True: 16, False: 111]
  ------------------
  285|    111|            ((pos_start - run->runs[index].value) > run->runs[index].length)) {
  ------------------
  |  Branch (285:13): [True: 31, False: 80]
  ------------------
  286|     47|            return false;
  287|     47|        }
  288|    127|    }
  289|  3.27k|    for (int32_t i = index; i < run->n_runs; ++i) {
  ------------------
  |  Branch (289:29): [True: 3.21k, False: 64]
  ------------------
  290|  3.21k|        const uint32_t stop = run->runs[i].value + run->runs[i].length;
  291|  3.21k|        if (run->runs[i].value >= pos_end) break;
  ------------------
  |  Branch (291:13): [True: 18, False: 3.19k]
  ------------------
  292|  3.19k|        if (stop >= pos_end) {
  ------------------
  |  Branch (292:13): [True: 69, False: 3.12k]
  ------------------
  293|     69|            count += (((pos_end - run->runs[i].value) > 0)
  ------------------
  |  Branch (293:23): [True: 69, False: 0]
  ------------------
  294|     69|                          ? (pos_end - run->runs[i].value)
  295|     69|                          : 0);
  296|     69|            break;
  297|     69|        }
  298|  3.12k|        const uint32_t min = (stop - pos_start) > 0 ? (stop - pos_start) : 0;
  ------------------
  |  Branch (298:30): [True: 3.11k, False: 13]
  ------------------
  299|  3.12k|        count += (min < run->runs[i].length) ? min : run->runs[i].length;
  ------------------
  |  Branch (299:18): [True: 57, False: 3.07k]
  ------------------
  300|  3.12k|    }
  301|    151|    return count >= (pos_end - pos_start - 1);
  302|    198|}
roaring_array.c:run_container_size_in_bytes:
  493|  2.67k|    const run_container_t *container) {
  494|  2.67k|    return run_container_serialized_size_in_bytes(container->n_runs);
  495|  2.67k|}
roaring_array.c:run_container_serialized_size_in_bytes:
  456|  2.67k|static inline int32_t run_container_serialized_size_in_bytes(int32_t num_runs) {
  457|  2.67k|    return sizeof(uint16_t) +
  458|  2.67k|           sizeof(rle16_t) * num_runs;  // each run requires 2 2-byte entries.
  459|  2.67k|}
convert.c:run_container_serialized_size_in_bytes:
  456|   154k|static inline int32_t run_container_serialized_size_in_bytes(int32_t num_runs) {
  457|   154k|    return sizeof(uint16_t) +
  458|   154k|           sizeof(rle16_t) * num_runs;  // each run requires 2 2-byte entries.
  459|   154k|}
mixed_intersection.c:run_container_is_full:
  394|  17.9k|static inline bool run_container_is_full(const run_container_t *run) {
  395|  17.9k|    rle16_t vl = run->runs[0];
  396|  17.9k|    return (run->n_runs == 1) && (vl.value == 0) && (vl.length == 0xFFFF);
  ------------------
  |  Branch (396:12): [True: 1.55k, False: 16.4k]
  |  Branch (396:34): [True: 628, False: 929]
  |  Branch (396:53): [True: 204, False: 424]
  ------------------
  397|  17.9k|}
mixed_union.c:run_container_is_full:
  394|  3.00k|static inline bool run_container_is_full(const run_container_t *run) {
  395|  3.00k|    rle16_t vl = run->runs[0];
  396|  3.00k|    return (run->n_runs == 1) && (vl.value == 0) && (vl.length == 0xFFFF);
  ------------------
  |  Branch (396:12): [True: 389, False: 2.61k]
  |  Branch (396:34): [True: 243, False: 146]
  |  Branch (396:53): [True: 115, False: 128]
  ------------------
  397|  3.00k|}
mixed_union.c:run_container_append_first:
  351|  2.20k|                                                 rle16_t vl) {
  352|  2.20k|    run->runs[run->n_runs] = vl;
  353|  2.20k|    run->n_runs++;
  354|  2.20k|    return vl;
  355|  2.20k|}
mixed_union.c:run_container_append_value_first:
  385|    684|                                                       uint16_t val) {
  386|    684|    rle16_t newrle = CROARING_MAKE_RLE16(val, 0);
  ------------------
  |  |   60|    684|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  387|    684|    run->runs[run->n_runs] = newrle;
  388|    684|    run->n_runs++;
  389|    684|    return newrle;
  390|    684|}
mixed_union.c:run_container_append:
  332|   173k|                                        rle16_t *previousrl) {
  333|   173k|    const uint32_t previousend = previousrl->value + previousrl->length;
  334|   173k|    if (vl.value > previousend + 1) {  // we add a new one
  ------------------
  |  Branch (334:9): [True: 160k, False: 13.1k]
  ------------------
  335|   160k|        run->runs[run->n_runs] = vl;
  336|   160k|        run->n_runs++;
  337|   160k|        *previousrl = vl;
  338|   160k|    } else {
  339|  13.1k|        uint32_t newend = vl.value + vl.length + UINT32_C(1);
  340|  13.1k|        if (newend > previousend) {  // we merge
  ------------------
  |  Branch (340:13): [True: 13.1k, False: 0]
  ------------------
  341|  13.1k|            previousrl->length = (uint16_t)(newend - 1 - previousrl->value);
  342|  13.1k|            run->runs[run->n_runs - 1] = *previousrl;
  343|  13.1k|        }
  344|  13.1k|    }
  345|   173k|}
mixed_union.c:run_container_append_value:
  368|   530k|                                              rle16_t *previousrl) {
  369|   530k|    const uint32_t previousend = previousrl->value + previousrl->length;
  370|   530k|    if (val > previousend + 1) {  // we add a new one
  ------------------
  |  Branch (370:9): [True: 55.9k, False: 474k]
  ------------------
  371|  55.9k|        *previousrl = CROARING_MAKE_RLE16(val, 0);
  ------------------
  |  |   60|  55.9k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  372|  55.9k|        run->runs[run->n_runs] = *previousrl;
  373|  55.9k|        run->n_runs++;
  374|   474k|    } else if (val == previousend + 1) {  // we merge
  ------------------
  |  Branch (374:16): [True: 166k, False: 307k]
  ------------------
  375|   166k|        previousrl->length++;
  376|   166k|        run->runs[run->n_runs - 1] = *previousrl;
  377|   166k|    }
  378|   530k|}
run.c:run_container_is_full:
  394|   136k|static inline bool run_container_is_full(const run_container_t *run) {
  395|   136k|    rle16_t vl = run->runs[0];
  396|   136k|    return (run->n_runs == 1) && (vl.value == 0) && (vl.length == 0xFFFF);
  ------------------
  |  Branch (396:12): [True: 121k, False: 14.7k]
  |  Branch (396:34): [True: 119k, False: 1.63k]
  |  Branch (396:53): [True: 117k, False: 2.28k]
  ------------------
  397|   136k|}
run.c:run_container_serialized_size_in_bytes:
  456|     50|static inline int32_t run_container_serialized_size_in_bytes(int32_t num_runs) {
  457|     50|    return sizeof(uint16_t) +
  458|     50|           sizeof(rle16_t) * num_runs;  // each run requires 2 2-byte entries.
  459|     50|}
run.c:recoverRoomAtIndex:
  102|  6.57k|static inline void recoverRoomAtIndex(run_container_t *run, uint16_t index) {
  103|  6.57k|    memmove(run->runs + index, run->runs + (1 + index),
  104|  6.57k|            (run->n_runs - index - 1) * sizeof(rle16_t));
  105|  6.57k|    run->n_runs--;
  106|  6.57k|}
run.c:makeRoomAtIndex:
  208|  44.4k|static inline void makeRoomAtIndex(run_container_t *run, uint16_t index) {
  209|       |    /* This function calls realloc + memmove sequentially to move by one index.
  210|       |     * Potentially copying twice the array.
  211|       |     */
  212|  44.4k|    if (run->n_runs + 1 > run->capacity)
  ------------------
  |  Branch (212:9): [True: 2.53k, False: 41.9k]
  ------------------
  213|  2.53k|        run_container_grow(run, run->n_runs + 1, true);
  214|  44.4k|    memmove(run->runs + 1 + index, run->runs + index,
  215|  44.4k|            (run->n_runs - index) * sizeof(rle16_t));
  216|  44.4k|    run->n_runs++;
  217|  44.4k|}
run.c:run_container_append_first:
  351|  2.37k|                                                 rle16_t vl) {
  352|  2.37k|    run->runs[run->n_runs] = vl;
  353|  2.37k|    run->n_runs++;
  354|  2.37k|    return vl;
  355|  2.37k|}
run.c:run_container_append:
  332|   304k|                                        rle16_t *previousrl) {
  333|   304k|    const uint32_t previousend = previousrl->value + previousrl->length;
  334|   304k|    if (vl.value > previousend + 1) {  // we add a new one
  ------------------
  |  Branch (334:9): [True: 157k, False: 146k]
  ------------------
  335|   157k|        run->runs[run->n_runs] = vl;
  336|   157k|        run->n_runs++;
  337|   157k|        *previousrl = vl;
  338|   157k|    } else {
  339|   146k|        uint32_t newend = vl.value + vl.length + UINT32_C(1);
  340|   146k|        if (newend > previousend) {  // we merge
  ------------------
  |  Branch (340:13): [True: 115k, False: 31.3k]
  ------------------
  341|   115k|            previousrl->length = (uint16_t)(newend - 1 - previousrl->value);
  342|   115k|            run->runs[run->n_runs - 1] = *previousrl;
  343|   115k|        }
  344|   146k|    }
  345|   304k|}
run.c:run_container_empty:
  314|     16|static inline bool run_container_empty(const run_container_t *run) {
  315|     16|    return run->n_runs == 0;  // runs never empty
  316|     16|}
run.c:run_container_size_in_bytes:
  493|     50|    const run_container_t *container) {
  494|     50|    return run_container_serialized_size_in_bytes(container->n_runs);
  495|     50|}

roaring_trailing_zeroes:
  242|  73.1M|inline int roaring_trailing_zeroes(unsigned long long input_num) {
  243|  73.1M|    return __builtin_ctzll(input_num);
  244|  73.1M|}
roaring_leading_zeroes:
  246|  4.49k|inline int roaring_leading_zeroes(unsigned long long input_num) {
  247|  4.49k|    return __builtin_clzll(input_num);
  248|  4.49k|}
roaring.c:roaring_hamming:
  287|   153k|static inline int roaring_hamming(uint64_t x) {
  288|       |#if defined(_WIN64) && defined(CROARING_REGULAR_VISUAL_STUDIO) && \
  289|       |    CROARING_REGULAR_VISUAL_STUDIO
  290|       |#ifdef CROARING_USENEON
  291|       |    return vaddv_u8(vcnt_u8(vcreate_u8(input_num)));
  292|       |#elif defined(_M_ARM64)
  293|       |    return roaring_hamming_backup(x);
  294|       |    // (int) _CountOneBits64(x); is unavailable
  295|       |#else   // _M_ARM64
  296|       |    return (int)__popcnt64(x);
  297|       |#endif  // _M_ARM64
  298|       |#elif defined(_WIN32) && defined(CROARING_REGULAR_VISUAL_STUDIO) && \
  299|       |    CROARING_REGULAR_VISUAL_STUDIO
  300|       |#ifdef _M_ARM
  301|       |    return roaring_hamming_backup(x);
  302|       |    // _CountOneBits is unavailable
  303|       |#else   // _M_ARM
  304|       |    return (int)__popcnt((unsigned int)x) +
  305|       |           (int)__popcnt((unsigned int)(x >> 32));
  306|       |#endif  // _M_ARM
  307|       |#else
  308|   153k|    return __builtin_popcountll(x);
  309|   153k|#endif
  310|   153k|}
mixed_intersection.c:roaring_hamming:
  287|   231k|static inline int roaring_hamming(uint64_t x) {
  288|       |#if defined(_WIN64) && defined(CROARING_REGULAR_VISUAL_STUDIO) && \
  289|       |    CROARING_REGULAR_VISUAL_STUDIO
  290|       |#ifdef CROARING_USENEON
  291|       |    return vaddv_u8(vcnt_u8(vcreate_u8(input_num)));
  292|       |#elif defined(_M_ARM64)
  293|       |    return roaring_hamming_backup(x);
  294|       |    // (int) _CountOneBits64(x); is unavailable
  295|       |#else   // _M_ARM64
  296|       |    return (int)__popcnt64(x);
  297|       |#endif  // _M_ARM64
  298|       |#elif defined(_WIN32) && defined(CROARING_REGULAR_VISUAL_STUDIO) && \
  299|       |    CROARING_REGULAR_VISUAL_STUDIO
  300|       |#ifdef _M_ARM
  301|       |    return roaring_hamming_backup(x);
  302|       |    // _CountOneBits is unavailable
  303|       |#else   // _M_ARM
  304|       |    return (int)__popcnt((unsigned int)x) +
  305|       |           (int)__popcnt((unsigned int)(x >> 32));
  306|       |#endif  // _M_ARM
  307|       |#else
  308|   231k|    return __builtin_popcountll(x);
  309|   231k|#endif
  310|   231k|}

roaring_bitmap_init_cleared:
   72|  32.4k|inline void roaring_bitmap_init_cleared(roaring_bitmap_t *r) {
   73|  32.4k|    roaring_bitmap_init_with_capacity(r, 0);
   74|  32.4k|}
roaring_bitmap_add_range:
  434|  6.48k|                                     uint64_t max) {
  435|  6.48k|    if (max <= min || min > (uint64_t)UINT32_MAX + 1) {
  ------------------
  |  Branch (435:9): [True: 3.59k, False: 2.88k]
  |  Branch (435:23): [True: 0, False: 2.88k]
  ------------------
  436|  3.59k|        return;
  437|  3.59k|    }
  438|  2.88k|    roaring_bitmap_add_range_closed(r, (uint32_t)min, (uint32_t)(max - 1));
  439|  2.88k|}
roaring_bitmap_remove_range:
  456|  6.48k|                                        uint64_t max) {
  457|  6.48k|    if (max <= min || min > (uint64_t)UINT32_MAX + 1) {
  ------------------
  |  Branch (457:9): [True: 5.52k, False: 951]
  |  Branch (457:23): [True: 0, False: 951]
  ------------------
  458|  5.52k|        return;
  459|  5.52k|    }
  460|    951|    roaring_bitmap_remove_range_closed(r, (uint32_t)min, (uint32_t)(max - 1));
  461|    951|}
roaring_bitmap_contains:
  478|  6.55k|inline bool roaring_bitmap_contains(const roaring_bitmap_t *r, uint32_t val) {
  479|       |    // For performance reasons, this function is inline and uses internal
  480|       |    // functions directly.
  481|  6.55k|#ifdef __cplusplus
  482|  6.55k|    using namespace ::roaring::internal;
  483|  6.55k|#endif
  484|  6.55k|    const uint16_t hb = val >> 16;
  485|       |    /*
  486|       |     * the next function call involves a binary search and lots of branching.
  487|       |     */
  488|  6.55k|    int32_t i = ra_get_index(&r->high_low_container, hb);
  489|  6.55k|    if (i < 0) return false;
  ------------------
  |  Branch (489:9): [True: 675, False: 5.87k]
  ------------------
  490|       |
  491|  5.87k|    uint8_t typecode;
  492|       |    // next call ought to be cheap
  493|  5.87k|    container_t *container = ra_get_container_at_index(&r->high_low_container,
  494|  5.87k|                                                       (uint16_t)i, &typecode);
  495|       |    // rest might be a tad expensive, possibly involving another round of binary
  496|       |    // search
  497|  5.87k|    return container_contains(container, val & 0xFFFF, typecode);
  498|  6.55k|}
roaring_bitmap_set_copy_on_write:
  117|  59.8k|inline void roaring_bitmap_set_copy_on_write(roaring_bitmap_t *r, bool cow) {
  118|  59.8k|    if (cow) {
  ------------------
  |  Branch (118:9): [True: 0, False: 59.8k]
  ------------------
  119|      0|        r->high_low_container.flags |= ROARING_FLAG_COW;
  ------------------
  |  |   46|      0|#define ROARING_FLAG_COW UINT8_C(0x1)
  ------------------
  120|  59.8k|    } else {
  121|  59.8k|        if (roaring_bitmap_get_copy_on_write(r)) {
  ------------------
  |  Branch (121:13): [True: 0, False: 59.8k]
  ------------------
  122|      0|            roaring_unshare_all(r);
  123|      0|        }
  124|       |        r->high_low_container.flags &= ~ROARING_FLAG_COW;
  ------------------
  |  |   46|  59.8k|#define ROARING_FLAG_COW UINT8_C(0x1)
  ------------------
  125|  59.8k|    }
  126|  59.8k|}
roaring_bitmap_get_copy_on_write:
  114|  72.8k|inline bool roaring_bitmap_get_copy_on_write(const roaring_bitmap_t *r) {
  115|       |    return r->high_low_container.flags & ROARING_FLAG_COW;
  ------------------
  |  |   46|  72.8k|#define ROARING_FLAG_COW UINT8_C(0x1)
  ------------------
  116|  72.8k|}

ra_get_index:
   93|  91.3k|inline int32_t ra_get_index(const roaring_array_t *ra, uint16_t x) {
   94|  91.3k|    if ((ra->size == 0) || ra->keys[ra->size - 1] == x) return ra->size - 1;
  ------------------
  |  Branch (94:9): [True: 13.0k, False: 78.2k]
  |  Branch (94:28): [True: 32.9k, False: 45.3k]
  ------------------
   95|  45.3k|    return binarySearch(ra->keys, (int32_t)ra->size, x);
   96|  91.3k|}
ra_get_container_at_index:
  102|   463k|                                              uint16_t i, uint8_t *typecode) {
  103|   463k|    *typecode = ra->typecodes[i];
  104|   463k|    return ra->containers[i];
  105|   463k|}
ra_get_key_at_index:
  110|   316k|inline uint16_t ra_get_key_at_index(const roaring_array_t *ra, uint16_t i) {
  111|   316k|    return ra->keys[i];
  112|   316k|}
ra_set_container_at_index:
  175|   116k|                                      container_t *c, uint8_t typecode) {
  176|       |    assert(i < ra->size);
  177|   116k|    ra->containers[i] = c;
  178|   116k|    ra->typecodes[i] = typecode;
  179|   116k|}
ra_get_size:
  191|  13.7k|inline int32_t ra_get_size(const roaring_array_t *ra) { return ra->size; }
ra_replace_key_and_container_at_index:
  205|   156k|                                                  uint8_t typecode) {
  206|   156k|    assert(i < ra->size);
  207|       |
  208|   156k|    ra->keys[i] = key;
  209|   156k|    ra->containers[i] = c;
  210|   156k|    ra->typecodes[i] = typecode;
  211|   156k|}
roaring.c:ra_advance_until:
  194|    518|                                       int32_t pos) {
  195|    518|    return advanceUntil(ra->keys, pos, ra->size, x);
  196|    518|}
roaring.c:ra_unshare_container_at_index:
  268|  64.0k|                                                 uint16_t i) {
  269|       |    assert(i < ra->size);
  270|  64.0k|    ra->containers[i] =
  271|  64.0k|        get_writable_copy_if_shared(ra->containers[i], &ra->typecodes[i]);
  272|  64.0k|}

intersect_vector16:
  386|  1.75k|                           size_t s_b, uint16_t *C) {
  387|  1.75k|    size_t count = 0;
  388|  1.75k|    size_t i_a = 0, i_b = 0;
  389|  1.75k|    const int vectorlength = sizeof(__m128i) / sizeof(uint16_t);
  390|  1.75k|    const size_t st_a = (s_a / vectorlength) * vectorlength;
  391|  1.75k|    const size_t st_b = (s_b / vectorlength) * vectorlength;
  392|  1.75k|    __m128i v_a, v_b;
  393|  1.75k|    if ((i_a < st_a) && (i_b < st_b)) {
  ------------------
  |  Branch (393:9): [True: 1.63k, False: 120]
  |  Branch (393:25): [True: 1.47k, False: 158]
  ------------------
  394|  1.47k|        v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  395|  1.47k|        v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  396|  4.11k|        while ((A[i_a] == 0) || (B[i_b] == 0)) {
  ------------------
  |  Branch (396:16): [True: 2.50k, False: 1.61k]
  |  Branch (396:33): [True: 273, False: 1.34k]
  ------------------
  397|  2.77k|            const __m128i res_v = _mm_cmpestrm(
  398|  2.77k|                v_b, vectorlength, v_a, vectorlength,
  399|  2.77k|                _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  400|  2.77k|            const int r = _mm_extract_epi32(res_v, 0);
  401|  2.77k|            __m128i sm16 = _mm_loadu_si128((const __m128i *)shuffle_mask16 + r);
  402|  2.77k|            __m128i p = _mm_shuffle_epi8(v_a, sm16);
  403|  2.77k|            _mm_storeu_si128((__m128i *)&C[count], p);  // can overflow
  404|  2.77k|            count += _mm_popcnt_u32(r);
  405|  2.77k|            const uint16_t a_max = A[i_a + vectorlength - 1];
  406|  2.77k|            const uint16_t b_max = B[i_b + vectorlength - 1];
  407|  2.77k|            if (a_max <= b_max) {
  ------------------
  |  Branch (407:17): [True: 1.62k, False: 1.15k]
  ------------------
  408|  1.62k|                i_a += vectorlength;
  409|  1.62k|                if (i_a == st_a) break;
  ------------------
  |  Branch (409:21): [True: 116, False: 1.50k]
  ------------------
  410|  1.50k|                v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  411|  1.50k|            }
  412|  2.66k|            if (b_max <= a_max) {
  ------------------
  |  Branch (412:17): [True: 1.24k, False: 1.41k]
  ------------------
  413|  1.24k|                i_b += vectorlength;
  414|  1.24k|                if (i_b == st_b) break;
  ------------------
  |  Branch (414:21): [True: 15, False: 1.23k]
  ------------------
  415|  1.23k|                v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  416|  1.23k|            }
  417|  2.66k|        }
  418|  1.47k|        if ((i_a < st_a) && (i_b < st_b))
  ------------------
  |  Branch (418:13): [True: 1.35k, False: 116]
  |  Branch (418:29): [True: 1.34k, False: 15]
  ------------------
  419|  43.7k|            while (true) {
  ------------------
  |  Branch (419:20): [True: 43.7k, Folded]
  ------------------
  420|  43.7k|                const __m128i res_v = _mm_cmpistrm(
  421|  43.7k|                    v_b, v_a,
  422|  43.7k|                    _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  423|  43.7k|                const int r = _mm_extract_epi32(res_v, 0);
  424|  43.7k|                __m128i sm16 =
  425|  43.7k|                    _mm_loadu_si128((const __m128i *)shuffle_mask16 + r);
  426|  43.7k|                __m128i p = _mm_shuffle_epi8(v_a, sm16);
  427|  43.7k|                _mm_storeu_si128((__m128i *)&C[count], p);  // can overflow
  428|  43.7k|                count += _mm_popcnt_u32(r);
  429|  43.7k|                const uint16_t a_max = A[i_a + vectorlength - 1];
  430|  43.7k|                const uint16_t b_max = B[i_b + vectorlength - 1];
  431|  43.7k|                if (a_max <= b_max) {
  ------------------
  |  Branch (431:21): [True: 19.6k, False: 24.1k]
  ------------------
  432|  19.6k|                    i_a += vectorlength;
  433|  19.6k|                    if (i_a == st_a) break;
  ------------------
  |  Branch (433:25): [True: 795, False: 18.8k]
  ------------------
  434|  18.8k|                    v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  435|  18.8k|                }
  436|  42.9k|                if (b_max <= a_max) {
  ------------------
  |  Branch (436:21): [True: 25.6k, False: 17.3k]
  ------------------
  437|  25.6k|                    i_b += vectorlength;
  438|  25.6k|                    if (i_b == st_b) break;
  ------------------
  |  Branch (438:25): [True: 546, False: 25.1k]
  ------------------
  439|  25.1k|                    v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  440|  25.1k|                }
  441|  42.9k|            }
  442|  1.47k|    }
  443|       |    // intersect the tail using scalar intersection
  444|  28.2k|    while (i_a < s_a && i_b < s_b) {
  ------------------
  |  Branch (444:12): [True: 26.8k, False: 1.38k]
  |  Branch (444:25): [True: 26.4k, False: 364]
  ------------------
  445|  26.4k|        uint16_t a = A[i_a];
  446|  26.4k|        uint16_t b = B[i_b];
  447|  26.4k|        if (a < b) {
  ------------------
  |  Branch (447:13): [True: 10.7k, False: 15.7k]
  ------------------
  448|  10.7k|            i_a++;
  449|  15.7k|        } else if (b < a) {
  ------------------
  |  Branch (449:20): [True: 10.0k, False: 5.69k]
  ------------------
  450|  10.0k|            i_b++;
  451|  10.0k|        } else {
  452|  5.69k|            C[count] = a;  //==b;
  453|  5.69k|            count++;
  454|  5.69k|            i_a++;
  455|  5.69k|            i_b++;
  456|  5.69k|        }
  457|  26.4k|    }
  458|  1.75k|    return (int32_t)count;
  459|  1.75k|}
array_container_to_uint32_array_vector16:
  464|  5.98k|                                             uint32_t base) {
  465|  5.98k|    int outpos = 0;
  466|  5.98k|    uint32_t *out = (uint32_t *)vout;
  467|  5.98k|    size_t i = 0;
  468|   203k|    for (; i + sizeof(__m128i) / sizeof(uint16_t) <= cardinality;
  ------------------
  |  Branch (468:12): [True: 197k, False: 5.98k]
  ------------------
  469|   197k|         i += sizeof(__m128i) / sizeof(uint16_t)) {
  470|   197k|        __m128i vinput = _mm_loadu_si128((const __m128i *)(array + i));
  471|   197k|        __m256i voutput = _mm256_add_epi32(_mm256_cvtepu16_epi32(vinput),
  472|   197k|                                           _mm256_set1_epi32(base));
  473|   197k|        _mm256_storeu_si256((__m256i *)(out + outpos), voutput);
  474|   197k|        outpos += sizeof(__m256i) / sizeof(uint32_t);
  475|   197k|    }
  476|  20.6k|    for (; i < cardinality; ++i) {
  ------------------
  |  Branch (476:12): [True: 14.6k, False: 5.98k]
  ------------------
  477|  14.6k|        const uint32_t val = base + array[i];
  478|  14.6k|        memcpy(out + outpos, &val,
  479|  14.6k|               sizeof(uint32_t));  // should be compiled as a MOV on x64
  480|  14.6k|        outpos++;
  481|  14.6k|    }
  482|  5.98k|    return outpos;
  483|  5.98k|}
intersect_vector16_inplace:
  486|  4.64k|                                   size_t s_b) {
  487|  4.64k|    size_t count = 0;
  488|  4.64k|    size_t i_a = 0, i_b = 0;
  489|  4.64k|    const int vectorlength = sizeof(__m128i) / sizeof(uint16_t);
  490|  4.64k|    const size_t st_a = (s_a / vectorlength) * vectorlength;
  491|  4.64k|    const size_t st_b = (s_b / vectorlength) * vectorlength;
  492|  4.64k|    __m128i v_a, v_b;
  493|  4.64k|    if ((i_a < st_a) && (i_b < st_b)) {
  ------------------
  |  Branch (493:9): [True: 2.29k, False: 2.35k]
  |  Branch (493:25): [True: 2.09k, False: 195]
  ------------------
  494|  2.09k|        v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  495|  2.09k|        v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  496|  2.09k|        __m128i tmp[2] = {_mm_setzero_si128()};
  497|  2.09k|        size_t tmp_count = 0;
  498|  4.20k|        while ((A[i_a] == 0) || (B[i_b] == 0)) {
  ------------------
  |  Branch (498:16): [True: 1.82k, False: 2.38k]
  |  Branch (498:33): [True: 376, False: 2.00k]
  ------------------
  499|  2.20k|            const __m128i res_v = _mm_cmpestrm(
  500|  2.20k|                v_b, vectorlength, v_a, vectorlength,
  501|  2.20k|                _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  502|  2.20k|            const int r = _mm_extract_epi32(res_v, 0);
  503|  2.20k|            __m128i sm16 = _mm_loadu_si128((const __m128i *)shuffle_mask16 + r);
  504|  2.20k|            __m128i p = _mm_shuffle_epi8(v_a, sm16);
  505|  2.20k|            _mm_storeu_si128((__m128i *)&((uint16_t *)tmp)[tmp_count], p);
  506|  2.20k|            tmp_count += _mm_popcnt_u32(r);
  507|  2.20k|            const uint16_t a_max = A[i_a + vectorlength - 1];
  508|  2.20k|            const uint16_t b_max = B[i_b + vectorlength - 1];
  509|  2.20k|            if (a_max <= b_max) {
  ------------------
  |  Branch (509:17): [True: 2.05k, False: 142]
  ------------------
  510|  2.05k|                _mm_storeu_si128((__m128i *)&A[count], tmp[0]);
  511|  2.05k|                _mm_storeu_si128(tmp, _mm_setzero_si128());
  512|  2.05k|                count += tmp_count;
  513|  2.05k|                tmp_count = 0;
  514|  2.05k|                i_a += vectorlength;
  515|  2.05k|                if (i_a == st_a) break;
  ------------------
  |  Branch (515:21): [True: 86, False: 1.97k]
  ------------------
  516|  1.97k|                v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  517|  1.97k|            }
  518|  2.11k|            if (b_max <= a_max) {
  ------------------
  |  Branch (518:17): [True: 325, False: 1.78k]
  ------------------
  519|    325|                i_b += vectorlength;
  520|    325|                if (i_b == st_b) break;
  ------------------
  |  Branch (520:21): [True: 6, False: 319]
  ------------------
  521|    319|                v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  522|    319|            }
  523|  2.11k|        }
  524|  2.09k|        if ((i_a < st_a) && (i_b < st_b)) {
  ------------------
  |  Branch (524:13): [True: 2.01k, False: 86]
  |  Branch (524:29): [True: 2.00k, False: 6]
  ------------------
  525|   251k|            while (true) {
  ------------------
  |  Branch (525:20): [True: 251k, Folded]
  ------------------
  526|   251k|                const __m128i res_v = _mm_cmpistrm(
  527|   251k|                    v_b, v_a,
  528|   251k|                    _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  529|   251k|                const int r = _mm_extract_epi32(res_v, 0);
  530|   251k|                __m128i sm16 =
  531|   251k|                    _mm_loadu_si128((const __m128i *)shuffle_mask16 + r);
  532|   251k|                __m128i p = _mm_shuffle_epi8(v_a, sm16);
  533|   251k|                _mm_storeu_si128((__m128i *)&((uint16_t *)tmp)[tmp_count], p);
  534|   251k|                tmp_count += _mm_popcnt_u32(r);
  535|   251k|                const uint16_t a_max = A[i_a + vectorlength - 1];
  536|   251k|                const uint16_t b_max = B[i_b + vectorlength - 1];
  537|   251k|                if (a_max <= b_max) {
  ------------------
  |  Branch (537:21): [True: 147k, False: 104k]
  ------------------
  538|   147k|                    _mm_storeu_si128((__m128i *)&A[count], tmp[0]);
  539|   147k|                    _mm_storeu_si128(tmp, _mm_setzero_si128());
  540|   147k|                    count += tmp_count;
  541|   147k|                    tmp_count = 0;
  542|   147k|                    i_a += vectorlength;
  543|   147k|                    if (i_a == st_a) break;
  ------------------
  |  Branch (543:25): [True: 1.12k, False: 146k]
  ------------------
  544|   146k|                    v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  545|   146k|                }
  546|   250k|                if (b_max <= a_max) {
  ------------------
  |  Branch (546:21): [True: 141k, False: 109k]
  ------------------
  547|   141k|                    i_b += vectorlength;
  548|   141k|                    if (i_b == st_b) break;
  ------------------
  |  Branch (548:25): [True: 875, False: 140k]
  ------------------
  549|   140k|                    v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  550|   140k|                }
  551|   250k|            }
  552|  2.00k|        }
  553|       |        // tmp_count <= 8, so this does not affect efficiency so much
  554|  4.49k|        for (size_t i = 0; i < tmp_count; i++) {
  ------------------
  |  Branch (554:28): [True: 2.40k, False: 2.09k]
  ------------------
  555|  2.40k|            A[count] = ((uint16_t *)tmp)[i];
  556|  2.40k|            count++;
  557|  2.40k|        }
  558|  2.09k|        i_a += tmp_count;  // We can at least jump pass $tmp_count elements in A
  559|  2.09k|    }
  560|       |    // intersect the tail using scalar intersection
  561|  33.3k|    while (i_a < s_a && i_b < s_b) {
  ------------------
  |  Branch (561:12): [True: 29.1k, False: 4.23k]
  |  Branch (561:25): [True: 28.6k, False: 411]
  ------------------
  562|  28.6k|        uint16_t a = A[i_a];
  563|  28.6k|        uint16_t b = B[i_b];
  564|  28.6k|        if (a < b) {
  ------------------
  |  Branch (564:13): [True: 9.39k, False: 19.2k]
  ------------------
  565|  9.39k|            i_a++;
  566|  19.2k|        } else if (b < a) {
  ------------------
  |  Branch (566:20): [True: 7.33k, False: 11.9k]
  ------------------
  567|  7.33k|            i_b++;
  568|  11.9k|        } else {
  569|  11.9k|            A[count] = a;  //==b;
  570|  11.9k|            count++;
  571|  11.9k|            i_a++;
  572|  11.9k|            i_b++;
  573|  11.9k|        }
  574|  28.6k|    }
  575|  4.64k|    return (int32_t)count;
  576|  4.64k|}
intersect_vector16_cardinality:
  581|  7.00k|                                       const uint16_t *B, size_t s_b) {
  582|  7.00k|    size_t count = 0;
  583|  7.00k|    size_t i_a = 0, i_b = 0;
  584|  7.00k|    const int vectorlength = sizeof(__m128i) / sizeof(uint16_t);
  585|  7.00k|    const size_t st_a = (s_a / vectorlength) * vectorlength;
  586|  7.00k|    const size_t st_b = (s_b / vectorlength) * vectorlength;
  587|  7.00k|    __m128i v_a, v_b;
  588|  7.00k|    if ((i_a < st_a) && (i_b < st_b)) {
  ------------------
  |  Branch (588:9): [True: 6.52k, False: 480]
  |  Branch (588:25): [True: 5.88k, False: 632]
  ------------------
  589|  5.88k|        v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  590|  5.88k|        v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  591|  16.4k|        while ((A[i_a] == 0) || (B[i_b] == 0)) {
  ------------------
  |  Branch (591:16): [True: 10.0k, False: 6.45k]
  |  Branch (591:33): [True: 1.09k, False: 5.36k]
  ------------------
  592|  11.1k|            const __m128i res_v = _mm_cmpestrm(
  593|  11.1k|                v_b, vectorlength, v_a, vectorlength,
  594|  11.1k|                _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  595|  11.1k|            const int r = _mm_extract_epi32(res_v, 0);
  596|  11.1k|            count += _mm_popcnt_u32(r);
  597|  11.1k|            const uint16_t a_max = A[i_a + vectorlength - 1];
  598|  11.1k|            const uint16_t b_max = B[i_b + vectorlength - 1];
  599|  11.1k|            if (a_max <= b_max) {
  ------------------
  |  Branch (599:17): [True: 6.49k, False: 4.61k]
  ------------------
  600|  6.49k|                i_a += vectorlength;
  601|  6.49k|                if (i_a == st_a) break;
  ------------------
  |  Branch (601:21): [True: 464, False: 6.02k]
  ------------------
  602|  6.02k|                v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  603|  6.02k|            }
  604|  10.6k|            if (b_max <= a_max) {
  ------------------
  |  Branch (604:17): [True: 4.98k, False: 5.66k]
  ------------------
  605|  4.98k|                i_b += vectorlength;
  606|  4.98k|                if (i_b == st_b) break;
  ------------------
  |  Branch (606:21): [True: 60, False: 4.92k]
  ------------------
  607|  4.92k|                v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  608|  4.92k|            }
  609|  10.6k|        }
  610|  5.88k|        if ((i_a < st_a) && (i_b < st_b))
  ------------------
  |  Branch (610:13): [True: 5.42k, False: 464]
  |  Branch (610:29): [True: 5.36k, False: 60]
  ------------------
  611|   175k|            while (true) {
  ------------------
  |  Branch (611:20): [True: 175k, Folded]
  ------------------
  612|   175k|                const __m128i res_v = _mm_cmpistrm(
  613|   175k|                    v_b, v_a,
  614|   175k|                    _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  615|   175k|                const int r = _mm_extract_epi32(res_v, 0);
  616|   175k|                count += _mm_popcnt_u32(r);
  617|   175k|                const uint16_t a_max = A[i_a + vectorlength - 1];
  618|   175k|                const uint16_t b_max = B[i_b + vectorlength - 1];
  619|   175k|                if (a_max <= b_max) {
  ------------------
  |  Branch (619:21): [True: 78.5k, False: 96.6k]
  ------------------
  620|  78.5k|                    i_a += vectorlength;
  621|  78.5k|                    if (i_a == st_a) break;
  ------------------
  |  Branch (621:25): [True: 3.18k, False: 75.3k]
  ------------------
  622|  75.3k|                    v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  623|  75.3k|                }
  624|   171k|                if (b_max <= a_max) {
  ------------------
  |  Branch (624:21): [True: 102k, False: 69.2k]
  ------------------
  625|   102k|                    i_b += vectorlength;
  626|   102k|                    if (i_b == st_b) break;
  ------------------
  |  Branch (626:25): [True: 2.18k, False: 100k]
  ------------------
  627|   100k|                    v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  628|   100k|                }
  629|   171k|            }
  630|  5.88k|    }
  631|       |    // intersect the tail using scalar intersection
  632|   112k|    while (i_a < s_a && i_b < s_b) {
  ------------------
  |  Branch (632:12): [True: 107k, False: 5.54k]
  |  Branch (632:25): [True: 105k, False: 1.45k]
  ------------------
  633|   105k|        uint16_t a = A[i_a];
  634|   105k|        uint16_t b = B[i_b];
  635|   105k|        if (a < b) {
  ------------------
  |  Branch (635:13): [True: 42.9k, False: 63.0k]
  ------------------
  636|  42.9k|            i_a++;
  637|  63.0k|        } else if (b < a) {
  ------------------
  |  Branch (637:20): [True: 40.2k, False: 22.7k]
  ------------------
  638|  40.2k|            i_b++;
  639|  40.2k|        } else {
  640|  22.7k|            count++;
  641|  22.7k|            i_a++;
  642|  22.7k|            i_b++;
  643|  22.7k|        }
  644|   105k|    }
  645|  7.00k|    return (int32_t)count;
  646|  7.00k|}
difference_vector16:
  655|  2.32k|                            size_t s_b, uint16_t *C) {
  656|       |    // we handle the degenerate case
  657|  2.32k|    if (s_a == 0) return 0;
  ------------------
  |  Branch (657:9): [True: 0, False: 2.32k]
  ------------------
  658|  2.32k|    if (s_b == 0) {
  ------------------
  |  Branch (658:9): [True: 0, False: 2.32k]
  ------------------
  659|      0|        if (A != C) memcpy(C, A, sizeof(uint16_t) * s_a);
  ------------------
  |  Branch (659:13): [True: 0, False: 0]
  ------------------
  660|      0|        return (int32_t)s_a;
  661|      0|    }
  662|       |    // handle the leading zeroes, it is messy but it allows us to use the fast
  663|       |    // _mm_cmpistrm instrinsic safely
  664|  2.32k|    int32_t count = 0;
  665|  2.32k|    if ((A[0] == 0) || (B[0] == 0)) {
  ------------------
  |  Branch (665:9): [True: 2.12k, False: 195]
  |  Branch (665:24): [True: 5, False: 190]
  ------------------
  666|  2.13k|        if ((A[0] == 0) && (B[0] == 0)) {
  ------------------
  |  Branch (666:13): [True: 2.12k, False: 5]
  |  Branch (666:28): [True: 307, False: 1.82k]
  ------------------
  667|    307|            A++;
  668|    307|            s_a--;
  669|    307|            B++;
  670|    307|            s_b--;
  671|  1.82k|        } else if (A[0] == 0) {
  ------------------
  |  Branch (671:20): [True: 1.82k, False: 5]
  ------------------
  672|  1.82k|            C[count++] = 0;
  673|  1.82k|            A++;
  674|  1.82k|            s_a--;
  675|  1.82k|        } else {
  676|      5|            B++;
  677|      5|            s_b--;
  678|      5|        }
  679|  2.13k|    }
  680|       |    // at this point, we have two non-empty arrays, made of non-zero
  681|       |    // increasing values.
  682|  2.32k|    size_t i_a = 0, i_b = 0;
  683|  2.32k|    const size_t vectorlength = sizeof(__m128i) / sizeof(uint16_t);
  684|  2.32k|    const size_t st_a = (s_a / vectorlength) * vectorlength;
  685|  2.32k|    const size_t st_b = (s_b / vectorlength) * vectorlength;
  686|  2.32k|    if ((i_a < st_a) && (i_b < st_b)) {  // this is the vectorized code path
  ------------------
  |  Branch (686:9): [True: 1.89k, False: 425]
  |  Branch (686:25): [True: 1.59k, False: 301]
  ------------------
  687|  1.59k|        __m128i v_a, v_b;                //, v_bmax;
  688|       |        // we load a vector from A and a vector from B
  689|  1.59k|        v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  690|  1.59k|        v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  691|       |        // we have a runningmask which indicates which values from A have been
  692|       |        // spotted in B, these don't get written out.
  693|  1.59k|        __m128i runningmask_a_found_in_b = _mm_setzero_si128();
  694|       |        /****
  695|       |         * start of the main vectorized loop
  696|       |         *****/
  697|  48.2k|        while (true) {
  ------------------
  |  Branch (697:16): [True: 48.2k, Folded]
  ------------------
  698|       |            // afoundinb will contain a mask indicate for each entry in A
  699|       |            // whether it is seen
  700|       |            // in B
  701|  48.2k|            const __m128i a_found_in_b = _mm_cmpistrm(
  702|  48.2k|                v_b, v_a,
  703|  48.2k|                _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  704|  48.2k|            runningmask_a_found_in_b =
  705|  48.2k|                _mm_or_si128(runningmask_a_found_in_b, a_found_in_b);
  706|       |            // we always compare the last values of A and B
  707|  48.2k|            const uint16_t a_max = A[i_a + vectorlength - 1];
  708|  48.2k|            const uint16_t b_max = B[i_b + vectorlength - 1];
  709|  48.2k|            if (a_max <= b_max) {
  ------------------
  |  Branch (709:17): [True: 21.6k, False: 26.5k]
  ------------------
  710|       |                // Ok. In this code path, we are ready to write our v_a
  711|       |                // because there is no need to read more from B, they will
  712|       |                // all be large values.
  713|  21.6k|                const int bitmask_belongs_to_difference =
  714|  21.6k|                    _mm_extract_epi32(runningmask_a_found_in_b, 0) ^ 0xFF;
  715|       |                /*** next few lines are probably expensive *****/
  716|  21.6k|                __m128i sm16 = _mm_loadu_si128((const __m128i *)shuffle_mask16 +
  717|  21.6k|                                               bitmask_belongs_to_difference);
  718|  21.6k|                __m128i p = _mm_shuffle_epi8(v_a, sm16);
  719|  21.6k|                _mm_storeu_si128((__m128i *)&C[count], p);  // can overflow
  720|  21.6k|                count += _mm_popcnt_u32(bitmask_belongs_to_difference);
  721|       |                // we advance a
  722|  21.6k|                i_a += vectorlength;
  723|  21.6k|                if (i_a == st_a)  // no more
  ------------------
  |  Branch (723:21): [True: 1.15k, False: 20.4k]
  ------------------
  724|  1.15k|                    break;
  725|  20.4k|                runningmask_a_found_in_b = _mm_setzero_si128();
  726|  20.4k|                v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  727|  20.4k|            }
  728|  47.0k|            if (b_max <= a_max) {
  ------------------
  |  Branch (728:17): [True: 29.5k, False: 17.4k]
  ------------------
  729|       |                // in this code path, the current v_b has become useless
  730|  29.5k|                i_b += vectorlength;
  731|  29.5k|                if (i_b == st_b) break;
  ------------------
  |  Branch (731:21): [True: 438, False: 29.1k]
  ------------------
  732|  29.1k|                v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  733|  29.1k|            }
  734|  47.0k|        }
  735|       |        // at this point, either we have i_a == st_a, which is the end of the
  736|       |        // vectorized processing,
  737|       |        // or we have i_b == st_b,  and we are not done processing the vector...
  738|       |        // so we need to finish it off.
  739|  1.59k|        if (i_a < st_a) {        // we have unfinished business...
  ------------------
  |  Branch (739:13): [True: 438, False: 1.15k]
  ------------------
  740|    438|            uint16_t buffer[8];  // buffer to do a masked load
  741|    438|            memset(buffer, 0, 8 * sizeof(uint16_t));
  742|    438|            memcpy(buffer, B + i_b, (s_b - i_b) * sizeof(uint16_t));
  743|    438|            v_b = _mm_lddqu_si128((__m128i *)buffer);
  744|    438|            const __m128i a_found_in_b = _mm_cmpistrm(
  745|    438|                v_b, v_a,
  746|    438|                _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  747|    438|            runningmask_a_found_in_b =
  748|    438|                _mm_or_si128(runningmask_a_found_in_b, a_found_in_b);
  749|    438|            const int bitmask_belongs_to_difference =
  750|    438|                _mm_extract_epi32(runningmask_a_found_in_b, 0) ^ 0xFF;
  751|    438|            __m128i sm16 = _mm_loadu_si128((const __m128i *)shuffle_mask16 +
  752|    438|                                           bitmask_belongs_to_difference);
  753|    438|            __m128i p = _mm_shuffle_epi8(v_a, sm16);
  754|    438|            _mm_storeu_si128((__m128i *)&C[count], p);  // can overflow
  755|    438|            count += _mm_popcnt_u32(bitmask_belongs_to_difference);
  756|    438|            i_a += vectorlength;
  757|    438|        }
  758|       |        // at this point we should have i_a == st_a and i_b == st_b
  759|  1.59k|    }
  760|       |    // do the tail using scalar code
  761|   110k|    while (i_a < s_a && i_b < s_b) {
  ------------------
  |  Branch (761:12): [True: 108k, False: 1.81k]
  |  Branch (761:25): [True: 107k, False: 513]
  ------------------
  762|   107k|        uint16_t a = A[i_a];
  763|   107k|        uint16_t b = B[i_b];
  764|   107k|        if (b < a) {
  ------------------
  |  Branch (764:13): [True: 76.8k, False: 31.0k]
  ------------------
  765|  76.8k|            i_b++;
  766|  76.8k|        } else if (a < b) {
  ------------------
  |  Branch (766:20): [True: 25.4k, False: 5.68k]
  ------------------
  767|  25.4k|            C[count] = a;
  768|  25.4k|            count++;
  769|  25.4k|            i_a++;
  770|  25.4k|        } else {  //==
  771|  5.68k|            i_a++;
  772|  5.68k|            i_b++;
  773|  5.68k|        }
  774|   107k|    }
  775|  2.32k|    if (i_a < s_a) {
  ------------------
  |  Branch (775:9): [True: 513, False: 1.81k]
  ------------------
  776|    513|        if (C == A) {
  ------------------
  |  Branch (776:13): [True: 0, False: 513]
  ------------------
  777|      0|            assert((size_t)count <= i_a);
  778|      0|            if ((size_t)count < i_a) {
  ------------------
  |  Branch (778:17): [True: 0, False: 0]
  ------------------
  779|      0|                memmove(C + count, A + i_a, sizeof(uint16_t) * (s_a - i_a));
  780|      0|            }
  781|    513|        } else {
  782|  26.5k|            for (size_t i = 0; i < (s_a - i_a); i++) {
  ------------------
  |  Branch (782:32): [True: 26.0k, False: 513]
  ------------------
  783|  26.0k|                C[count + i] = A[i + i_a];
  784|  26.0k|            }
  785|    513|        }
  786|    513|        count += (int32_t)(s_a - i_a);
  787|    513|    }
  788|  2.32k|    return count;
  789|  2.32k|}
intersect_skewed_uint16:
  855|    787|                                uint16_t *buffer) {
  856|    787|    size_t pos = 0, idx_l = 0, idx_s = 0;
  857|       |
  858|    787|    if (0 == size_s) {
  ------------------
  |  Branch (858:9): [True: 0, False: 787]
  ------------------
  859|      0|        return 0;
  860|      0|    }
  861|    787|    int32_t index1 = 0, index2 = 0, index3 = 0, index4 = 0;
  862|  2.17k|    while ((idx_s + 4 <= size_s) && (idx_l < size_l)) {
  ------------------
  |  Branch (862:12): [True: 1.39k, False: 787]
  |  Branch (862:37): [True: 1.39k, False: 0]
  ------------------
  863|  1.39k|        uint16_t target1 = small[idx_s];
  864|  1.39k|        uint16_t target2 = small[idx_s + 1];
  865|  1.39k|        uint16_t target3 = small[idx_s + 2];
  866|  1.39k|        uint16_t target4 = small[idx_s + 3];
  867|  1.39k|        binarySearch4(large + idx_l, (int32_t)(size_l - idx_l), target1,
  868|  1.39k|                      target2, target3, target4, &index1, &index2, &index3,
  869|  1.39k|                      &index4);
  870|  1.39k|        if ((index1 + idx_l < size_l) && (large[idx_l + index1] == target1)) {
  ------------------
  |  Branch (870:13): [True: 1.39k, False: 1]
  |  Branch (870:42): [True: 650, False: 741]
  ------------------
  871|    650|            buffer[pos++] = target1;
  872|    650|        }
  873|  1.39k|        if ((index2 + idx_l < size_l) && (large[idx_l + index2] == target2)) {
  ------------------
  |  Branch (873:13): [True: 1.38k, False: 3]
  |  Branch (873:42): [True: 814, False: 575]
  ------------------
  874|    814|            buffer[pos++] = target2;
  875|    814|        }
  876|  1.39k|        if ((index3 + idx_l < size_l) && (large[idx_l + index3] == target3)) {
  ------------------
  |  Branch (876:13): [True: 1.38k, False: 4]
  |  Branch (876:42): [True: 790, False: 598]
  ------------------
  877|    790|            buffer[pos++] = target3;
  878|    790|        }
  879|  1.39k|        if ((index4 + idx_l < size_l) && (large[idx_l + index4] == target4)) {
  ------------------
  |  Branch (879:13): [True: 1.38k, False: 6]
  |  Branch (879:42): [True: 758, False: 628]
  ------------------
  880|    758|            buffer[pos++] = target4;
  881|    758|        }
  882|  1.39k|        idx_s += 4;
  883|  1.39k|        idx_l += index4;
  884|  1.39k|    }
  885|    787|    if ((idx_s + 2 <= size_s) && (idx_l < size_l)) {
  ------------------
  |  Branch (885:9): [True: 415, False: 372]
  |  Branch (885:34): [True: 414, False: 1]
  ------------------
  886|    414|        uint16_t target1 = small[idx_s];
  887|    414|        uint16_t target2 = small[idx_s + 1];
  888|    414|        binarySearch2(large + idx_l, (int32_t)(size_l - idx_l), target1,
  889|    414|                      target2, &index1, &index2);
  890|    414|        if ((index1 + idx_l < size_l) && (large[idx_l + index1] == target1)) {
  ------------------
  |  Branch (890:13): [True: 409, False: 5]
  |  Branch (890:42): [True: 280, False: 129]
  ------------------
  891|    280|            buffer[pos++] = target1;
  892|    280|        }
  893|    414|        if ((index2 + idx_l < size_l) && (large[idx_l + index2] == target2)) {
  ------------------
  |  Branch (893:13): [True: 397, False: 17]
  |  Branch (893:42): [True: 287, False: 110]
  ------------------
  894|    287|            buffer[pos++] = target2;
  895|    287|        }
  896|    414|        idx_s += 2;
  897|    414|        idx_l += index2;
  898|    414|    }
  899|    787|    if ((idx_s < size_s) && (idx_l < size_l)) {
  ------------------
  |  Branch (899:9): [True: 353, False: 434]
  |  Branch (899:29): [True: 350, False: 3]
  ------------------
  900|    350|        uint16_t val_s = small[idx_s];
  901|    350|        int32_t index =
  902|    350|            binarySearch(large + idx_l, (int32_t)(size_l - idx_l), val_s);
  903|    350|        if (index >= 0) buffer[pos++] = val_s;
  ------------------
  |  Branch (903:13): [True: 247, False: 103]
  ------------------
  904|    350|    }
  905|    787|    return (int32_t)pos;
  906|    787|}
intersect_skewed_uint16_cardinality:
  912|  2.29k|                                            size_t size_l) {
  913|  2.29k|    size_t pos = 0, idx_l = 0, idx_s = 0;
  914|       |
  915|  2.29k|    if (0 == size_s) {
  ------------------
  |  Branch (915:9): [True: 0, False: 2.29k]
  ------------------
  916|      0|        return 0;
  917|      0|    }
  918|       |
  919|  2.29k|    uint16_t val_l = large[idx_l], val_s = small[idx_s];
  920|       |
  921|  32.1k|    while (true) {
  ------------------
  |  Branch (921:12): [True: 32.1k, Folded]
  ------------------
  922|  32.1k|        if (val_l < val_s) {
  ------------------
  |  Branch (922:13): [True: 7.08k, False: 25.0k]
  ------------------
  923|  7.08k|            idx_l = advanceUntil(large, (int32_t)idx_l, (int32_t)size_l, val_s);
  924|  7.08k|            if (idx_l == size_l) break;
  ------------------
  |  Branch (924:17): [True: 124, False: 6.96k]
  ------------------
  925|  6.96k|            val_l = large[idx_l];
  926|  25.0k|        } else if (val_s < val_l) {
  ------------------
  |  Branch (926:20): [True: 11.4k, False: 13.6k]
  ------------------
  927|  11.4k|            idx_s++;
  928|  11.4k|            if (idx_s == size_s) break;
  ------------------
  |  Branch (928:17): [True: 880, False: 10.5k]
  ------------------
  929|  10.5k|            val_s = small[idx_s];
  930|  13.6k|        } else {
  931|  13.6k|            pos++;
  932|  13.6k|            idx_s++;
  933|  13.6k|            if (idx_s == size_s) break;
  ------------------
  |  Branch (933:17): [True: 1.20k, False: 12.4k]
  ------------------
  934|  12.4k|            val_s = small[idx_s];
  935|  12.4k|            idx_l = advanceUntil(large, (int32_t)idx_l, (int32_t)size_l, val_s);
  936|  12.4k|            if (idx_l == size_l) break;
  ------------------
  |  Branch (936:17): [True: 84, False: 12.3k]
  ------------------
  937|  12.3k|            val_l = large[idx_l];
  938|  12.3k|        }
  939|  32.1k|    }
  940|       |
  941|  2.29k|    return (int32_t)pos;
  942|  2.29k|}
intersect_skewed_uint16_nonempty:
  945|    573|                                      const uint16_t *large, size_t size_l) {
  946|    573|    size_t idx_l = 0, idx_s = 0;
  947|       |
  948|    573|    if (0 == size_s) {
  ------------------
  |  Branch (948:9): [True: 0, False: 573]
  ------------------
  949|      0|        return false;
  950|      0|    }
  951|       |
  952|    573|    uint16_t val_l = large[idx_l], val_s = small[idx_s];
  953|       |
  954|  2.32k|    while (true) {
  ------------------
  |  Branch (954:12): [True: 2.32k, Folded]
  ------------------
  955|  2.32k|        if (val_l < val_s) {
  ------------------
  |  Branch (955:13): [True: 882, False: 1.44k]
  ------------------
  956|    882|            idx_l = advanceUntil(large, (int32_t)idx_l, (int32_t)size_l, val_s);
  957|    882|            if (idx_l == size_l) break;
  ------------------
  |  Branch (957:17): [True: 30, False: 852]
  ------------------
  958|    852|            val_l = large[idx_l];
  959|  1.44k|        } else if (val_s < val_l) {
  ------------------
  |  Branch (959:20): [True: 973, False: 471]
  ------------------
  960|    973|            idx_s++;
  961|    973|            if (idx_s == size_s) break;
  ------------------
  |  Branch (961:17): [True: 72, False: 901]
  ------------------
  962|    901|            val_s = small[idx_s];
  963|    901|        } else {
  964|    471|            return true;
  965|    471|        }
  966|  2.32k|    }
  967|       |
  968|    102|    return false;
  969|    573|}
intersect_uint16_nonempty:
 1025|  1.75k|                               const uint16_t *B, const size_t lenB) {
 1026|  1.75k|    if (lenA == 0 || lenB == 0) return 0;
  ------------------
  |  Branch (1026:9): [True: 0, False: 1.75k]
  |  Branch (1026:22): [True: 0, False: 1.75k]
  ------------------
 1027|  1.75k|    const uint16_t *endA = A + lenA;
 1028|  1.75k|    const uint16_t *endB = B + lenB;
 1029|       |
 1030|  1.75k|    while (1) {
  ------------------
  |  Branch (1030:12): [True: 1.75k, Folded]
  ------------------
 1031|  8.78k|        while (*A < *B) {
  ------------------
  |  Branch (1031:16): [True: 6.51k, False: 2.27k]
  ------------------
 1032|  7.07k|        SKIP_FIRST_COMPARE:
 1033|  7.07k|            if (++A == endA) return false;
  ------------------
  |  Branch (1033:17): [True: 43, False: 7.03k]
  ------------------
 1034|  7.07k|        }
 1035|  4.28k|        while (*A > *B) {
  ------------------
  |  Branch (1035:16): [True: 2.01k, False: 2.26k]
  ------------------
 1036|  2.01k|            if (++B == endB) return false;
  ------------------
  |  Branch (1036:17): [True: 6, False: 2.01k]
  ------------------
 1037|  2.01k|        }
 1038|  2.26k|        if (*A == *B) {
  ------------------
  |  Branch (1038:13): [True: 1.70k, False: 565]
  ------------------
 1039|  1.70k|            return true;
 1040|  1.70k|        } else {
 1041|    565|            goto SKIP_FIRST_COMPARE;
 1042|    565|        }
 1043|  2.26k|    }
 1044|      0|    return false;  // NOTREACHED
 1045|  1.75k|}
union_uint16:
 1105|  4.61k|                    size_t size_2, uint16_t *buffer) {
 1106|  4.61k|    size_t pos = 0, idx_1 = 0, idx_2 = 0;
 1107|       |
 1108|  4.61k|    if (0 == size_2) {
  ------------------
  |  Branch (1108:9): [True: 63, False: 4.54k]
  ------------------
 1109|     63|        memmove(buffer, set_1, size_1 * sizeof(uint16_t));
 1110|     63|        return size_1;
 1111|     63|    }
 1112|  4.54k|    if (0 == size_1) {
  ------------------
  |  Branch (1112:9): [True: 0, False: 4.54k]
  ------------------
 1113|      0|        memmove(buffer, set_2, size_2 * sizeof(uint16_t));
 1114|      0|        return size_2;
 1115|      0|    }
 1116|       |
 1117|  4.54k|    uint16_t val_1 = set_1[idx_1], val_2 = set_2[idx_2];
 1118|       |
 1119|   219k|    while (true) {
  ------------------
  |  Branch (1119:12): [True: 219k, Folded]
  ------------------
 1120|   219k|        if (val_1 < val_2) {
  ------------------
  |  Branch (1120:13): [True: 7.65k, False: 211k]
  ------------------
 1121|  7.65k|            buffer[pos++] = val_1;
 1122|  7.65k|            ++idx_1;
 1123|  7.65k|            if (idx_1 >= size_1) break;
  ------------------
  |  Branch (1123:17): [True: 376, False: 7.28k]
  ------------------
 1124|  7.28k|            val_1 = set_1[idx_1];
 1125|   211k|        } else if (val_2 < val_1) {
  ------------------
  |  Branch (1125:20): [True: 179k, False: 31.8k]
  ------------------
 1126|   179k|            buffer[pos++] = val_2;
 1127|   179k|            ++idx_2;
 1128|   179k|            if (idx_2 >= size_2) break;
  ------------------
  |  Branch (1128:17): [True: 177, False: 179k]
  ------------------
 1129|   179k|            val_2 = set_2[idx_2];
 1130|   179k|        } else {
 1131|  31.8k|            buffer[pos++] = val_1;
 1132|  31.8k|            ++idx_1;
 1133|  31.8k|            ++idx_2;
 1134|  31.8k|            if (idx_1 >= size_1 || idx_2 >= size_2) break;
  ------------------
  |  Branch (1134:17): [True: 3.86k, False: 27.9k]
  |  Branch (1134:36): [True: 131, False: 27.8k]
  ------------------
 1135|  27.8k|            val_1 = set_1[idx_1];
 1136|  27.8k|            val_2 = set_2[idx_2];
 1137|  27.8k|        }
 1138|   219k|    }
 1139|       |
 1140|  4.54k|    if (idx_1 < size_1) {
  ------------------
  |  Branch (1140:9): [True: 308, False: 4.24k]
  ------------------
 1141|    308|        const size_t n_elems = size_1 - idx_1;
 1142|    308|        memmove(buffer + pos, set_1 + idx_1, n_elems * sizeof(uint16_t));
 1143|    308|        pos += n_elems;
 1144|  4.24k|    } else if (idx_2 < size_2) {
  ------------------
  |  Branch (1144:16): [True: 1.80k, False: 2.44k]
  ------------------
 1145|  1.80k|        const size_t n_elems = size_2 - idx_2;
 1146|  1.80k|        memmove(buffer + pos, set_2 + idx_2, n_elems * sizeof(uint16_t));
 1147|  1.80k|        pos += n_elems;
 1148|  1.80k|    }
 1149|       |
 1150|  4.54k|    return pos;
 1151|  4.54k|}
difference_uint16:
 1154|  3.54k|                      int length2, uint16_t *a_out) {
 1155|  3.54k|    int out_card = 0;
 1156|  3.54k|    int k1 = 0, k2 = 0;
 1157|  3.54k|    if (length1 == 0) return 0;
  ------------------
  |  Branch (1157:9): [True: 0, False: 3.54k]
  ------------------
 1158|  3.54k|    if (length2 == 0) {
  ------------------
  |  Branch (1158:9): [True: 0, False: 3.54k]
  ------------------
 1159|      0|        if (a1 != a_out) memcpy(a_out, a1, sizeof(uint16_t) * length1);
  ------------------
  |  Branch (1159:13): [True: 0, False: 0]
  ------------------
 1160|      0|        return length1;
 1161|      0|    }
 1162|  3.54k|    uint16_t s1 = a1[k1];
 1163|  3.54k|    uint16_t s2 = a2[k2];
 1164|   449k|    while (true) {
  ------------------
  |  Branch (1164:12): [True: 449k, Folded]
  ------------------
 1165|   449k|        if (s1 < s2) {
  ------------------
  |  Branch (1165:13): [True: 222k, False: 227k]
  ------------------
 1166|   222k|            a_out[out_card++] = s1;
 1167|   222k|            ++k1;
 1168|   222k|            if (k1 >= length1) {
  ------------------
  |  Branch (1168:17): [True: 0, False: 222k]
  ------------------
 1169|      0|                break;
 1170|      0|            }
 1171|   222k|            s1 = a1[k1];
 1172|   227k|        } else if (s1 == s2) {
  ------------------
  |  Branch (1172:20): [True: 227k, False: 0]
  ------------------
 1173|   227k|            ++k1;
 1174|   227k|            ++k2;
 1175|   227k|            if (k1 >= length1) {
  ------------------
  |  Branch (1175:17): [True: 2.29k, False: 224k]
  ------------------
 1176|  2.29k|                break;
 1177|  2.29k|            }
 1178|   224k|            if (k2 >= length2) {
  ------------------
  |  Branch (1178:17): [True: 1.24k, False: 223k]
  ------------------
 1179|  1.24k|                memmove(a_out + out_card, a1 + k1,
 1180|  1.24k|                        sizeof(uint16_t) * (length1 - k1));
 1181|  1.24k|                return out_card + length1 - k1;
 1182|  1.24k|            }
 1183|   223k|            s1 = a1[k1];
 1184|   223k|            s2 = a2[k2];
 1185|   223k|        } else {  // if (val1>val2)
 1186|      0|            ++k2;
 1187|      0|            if (k2 >= length2) {
  ------------------
  |  Branch (1187:17): [True: 0, False: 0]
  ------------------
 1188|      0|                memmove(a_out + out_card, a1 + k1,
 1189|      0|                        sizeof(uint16_t) * (length1 - k1));
 1190|      0|                return out_card + length1 - k1;
 1191|      0|            }
 1192|      0|            s2 = a2[k2];
 1193|      0|        }
 1194|   449k|    }
 1195|  2.29k|    return out_card;
 1196|  3.54k|}
xor_uint16:
 1199|  8.04k|                   const uint16_t *array_2, int32_t card_2, uint16_t *out) {
 1200|  8.04k|    int32_t pos1 = 0, pos2 = 0, pos_out = 0;
 1201|   221k|    while (pos1 < card_1 && pos2 < card_2) {
  ------------------
  |  Branch (1201:12): [True: 214k, False: 7.44k]
  |  Branch (1201:29): [True: 213k, False: 600]
  ------------------
 1202|   213k|        const uint16_t v1 = array_1[pos1];
 1203|   213k|        const uint16_t v2 = array_2[pos2];
 1204|   213k|        if (v1 == v2) {
  ------------------
  |  Branch (1204:13): [True: 40.0k, False: 173k]
  ------------------
 1205|  40.0k|            ++pos1;
 1206|  40.0k|            ++pos2;
 1207|  40.0k|            continue;
 1208|  40.0k|        }
 1209|   173k|        if (v1 < v2) {
  ------------------
  |  Branch (1209:13): [True: 29.6k, False: 143k]
  ------------------
 1210|  29.6k|            out[pos_out++] = v1;
 1211|  29.6k|            ++pos1;
 1212|   143k|        } else {
 1213|   143k|            out[pos_out++] = v2;
 1214|   143k|            ++pos2;
 1215|   143k|        }
 1216|   173k|    }
 1217|  8.04k|    if (pos1 < card_1) {
  ------------------
  |  Branch (1217:9): [True: 600, False: 7.44k]
  ------------------
 1218|    600|        const size_t n_elems = card_1 - pos1;
 1219|    600|        memcpy(out + pos_out, array_1 + pos1, n_elems * sizeof(uint16_t));
 1220|    600|        pos_out += (int32_t)n_elems;
 1221|  7.44k|    } else if (pos2 < card_2) {
  ------------------
  |  Branch (1221:16): [True: 2.31k, False: 5.13k]
  ------------------
 1222|  2.31k|        const size_t n_elems = card_2 - pos2;
 1223|  2.31k|        memcpy(out + pos_out, array_2 + pos2, n_elems * sizeof(uint16_t));
 1224|  2.31k|        pos_out += (int32_t)n_elems;
 1225|  2.31k|    }
 1226|  8.04k|    return pos_out;
 1227|  8.04k|}
union_vector16:
 1654|  4.61k|                        uint16_t *output) {
 1655|  4.61k|    if ((length1 < 8) || (length2 < 8)) {
  ------------------
  |  Branch (1655:9): [True: 1.06k, False: 3.54k]
  |  Branch (1655:26): [True: 0, False: 3.54k]
  ------------------
 1656|  1.06k|        return (uint32_t)union_uint16(array1, length1, array2, length2, output);
 1657|  1.06k|    }
 1658|  3.54k|    __m128i vA, vB, V, vecMin, vecMax;
 1659|  3.54k|    __m128i laststore;
 1660|  3.54k|    uint16_t *initoutput = output;
 1661|  3.54k|    uint32_t len1 = length1 / 8;
 1662|  3.54k|    uint32_t len2 = length2 / 8;
 1663|  3.54k|    uint32_t pos1 = 0;
 1664|  3.54k|    uint32_t pos2 = 0;
 1665|       |    // we start the machine
 1666|  3.54k|    vA = _mm_lddqu_si128((const __m128i *)array1 + pos1);
 1667|  3.54k|    pos1++;
 1668|  3.54k|    vB = _mm_lddqu_si128((const __m128i *)array2 + pos2);
 1669|  3.54k|    pos2++;
 1670|  3.54k|    sse_merge(&vA, &vB, &vecMin, &vecMax);
 1671|  3.54k|    laststore = _mm_set1_epi16(-1);
 1672|  3.54k|    output += store_unique(laststore, vecMin, output);
 1673|  3.54k|    laststore = vecMin;
 1674|  3.54k|    if ((pos1 < len1) && (pos2 < len2)) {
  ------------------
  |  Branch (1674:9): [True: 3.04k, False: 500]
  |  Branch (1674:26): [True: 3.04k, False: 0]
  ------------------
 1675|  3.04k|        uint16_t curA, curB;
 1676|  3.04k|        curA = array1[8 * pos1];
 1677|  3.04k|        curB = array2[8 * pos2];
 1678|   105k|        while (true) {
  ------------------
  |  Branch (1678:16): [True: 105k, Folded]
  ------------------
 1679|   105k|            if (curA <= curB) {
  ------------------
  |  Branch (1679:17): [True: 44.8k, False: 60.8k]
  ------------------
 1680|  44.8k|                V = _mm_lddqu_si128((const __m128i *)array1 + pos1);
 1681|  44.8k|                pos1++;
 1682|  44.8k|                if (pos1 < len1) {
  ------------------
  |  Branch (1682:21): [True: 42.4k, False: 2.32k]
  ------------------
 1683|  42.4k|                    curA = array1[8 * pos1];
 1684|  42.4k|                } else {
 1685|  2.32k|                    break;
 1686|  2.32k|                }
 1687|  60.8k|            } else {
 1688|  60.8k|                V = _mm_lddqu_si128((const __m128i *)array2 + pos2);
 1689|  60.8k|                pos2++;
 1690|  60.8k|                if (pos2 < len2) {
  ------------------
  |  Branch (1690:21): [True: 60.1k, False: 719]
  ------------------
 1691|  60.1k|                    curB = array2[8 * pos2];
 1692|  60.1k|                } else {
 1693|    719|                    break;
 1694|    719|                }
 1695|  60.8k|            }
 1696|   102k|            sse_merge(&V, &vecMax, &vecMin, &vecMax);
 1697|   102k|            output += store_unique(laststore, vecMin, output);
 1698|   102k|            laststore = vecMin;
 1699|   102k|        }
 1700|  3.04k|        sse_merge(&V, &vecMax, &vecMin, &vecMax);
 1701|  3.04k|        output += store_unique(laststore, vecMin, output);
 1702|  3.04k|        laststore = vecMin;
 1703|  3.04k|    }
 1704|       |    // we finish the rest off using a scalar algorithm
 1705|       |    // could be improved?
 1706|       |    //
 1707|       |    // copy the small end on a tmp buffer
 1708|  3.54k|    uint32_t len = (uint32_t)(output - initoutput);
 1709|  3.54k|    uint16_t buffer[16];
 1710|  3.54k|    uint32_t leftoversize = store_unique(laststore, vecMax, buffer);
 1711|  3.54k|    if (pos1 == len1) {
  ------------------
  |  Branch (1711:9): [True: 2.82k, False: 719]
  ------------------
 1712|  2.82k|        memcpy(buffer + leftoversize, array1 + 8 * pos1,
 1713|  2.82k|               (length1 - 8 * len1) * sizeof(uint16_t));
 1714|  2.82k|        leftoversize += length1 - 8 * len1;
 1715|  2.82k|        qsort(buffer, leftoversize, sizeof(uint16_t), uint16_compare);
 1716|       |
 1717|  2.82k|        leftoversize = unique(buffer, leftoversize);
 1718|  2.82k|        len += (uint32_t)union_uint16(buffer, leftoversize, array2 + 8 * pos2,
 1719|  2.82k|                                      length2 - 8 * pos2, output);
 1720|  2.82k|    } else {
 1721|    719|        memcpy(buffer + leftoversize, array2 + 8 * pos2,
 1722|    719|               (length2 - 8 * len2) * sizeof(uint16_t));
 1723|    719|        leftoversize += length2 - 8 * len2;
 1724|    719|        qsort(buffer, leftoversize, sizeof(uint16_t), uint16_compare);
 1725|    719|        leftoversize = unique(buffer, leftoversize);
 1726|    719|        len += (uint32_t)union_uint16(buffer, leftoversize, array1 + 8 * pos1,
 1727|    719|                                      length1 - 8 * pos1, output);
 1728|    719|    }
 1729|  3.54k|    return len;
 1730|  4.61k|}
xor_vector16:
 1778|  8.05k|                      uint16_t *output) {
 1779|  8.05k|    if ((length1 < 8) || (length2 < 8)) {
  ------------------
  |  Branch (1779:9): [True: 3.27k, False: 4.78k]
  |  Branch (1779:26): [True: 363, False: 4.42k]
  ------------------
 1780|  3.63k|        return xor_uint16(array1, length1, array2, length2, output);
 1781|  3.63k|    }
 1782|  4.42k|    __m128i vA, vB, V, vecMin, vecMax;
 1783|  4.42k|    __m128i laststore;
 1784|  4.42k|    uint16_t *initoutput = output;
 1785|  4.42k|    uint32_t len1 = length1 / 8;
 1786|  4.42k|    uint32_t len2 = length2 / 8;
 1787|  4.42k|    uint32_t pos1 = 0;
 1788|  4.42k|    uint32_t pos2 = 0;
 1789|       |    // we start the machine
 1790|  4.42k|    vA = _mm_lddqu_si128((const __m128i *)array1 + pos1);
 1791|  4.42k|    pos1++;
 1792|  4.42k|    vB = _mm_lddqu_si128((const __m128i *)array2 + pos2);
 1793|  4.42k|    pos2++;
 1794|  4.42k|    sse_merge(&vA, &vB, &vecMin, &vecMax);
 1795|  4.42k|    laststore = _mm_set1_epi16(-1);
 1796|  4.42k|    uint16_t buffer[17];
 1797|  4.42k|    output += store_unique_xor(laststore, vecMin, output);
 1798|       |
 1799|  4.42k|    laststore = vecMin;
 1800|  4.42k|    if ((pos1 < len1) && (pos2 < len2)) {
  ------------------
  |  Branch (1800:9): [True: 4.09k, False: 326]
  |  Branch (1800:26): [True: 3.99k, False: 108]
  ------------------
 1801|  3.99k|        uint16_t curA, curB;
 1802|  3.99k|        curA = array1[8 * pos1];
 1803|  3.99k|        curB = array2[8 * pos2];
 1804|   193k|        while (true) {
  ------------------
  |  Branch (1804:16): [True: 193k, Folded]
  ------------------
 1805|   193k|            if (curA <= curB) {
  ------------------
  |  Branch (1805:17): [True: 92.3k, False: 101k]
  ------------------
 1806|  92.3k|                V = _mm_lddqu_si128((const __m128i *)array1 + pos1);
 1807|  92.3k|                pos1++;
 1808|  92.3k|                if (pos1 < len1) {
  ------------------
  |  Branch (1808:21): [True: 89.7k, False: 2.62k]
  ------------------
 1809|  89.7k|                    curA = array1[8 * pos1];
 1810|  89.7k|                } else {
 1811|  2.62k|                    break;
 1812|  2.62k|                }
 1813|   101k|            } else {
 1814|   101k|                V = _mm_lddqu_si128((const __m128i *)array2 + pos2);
 1815|   101k|                pos2++;
 1816|   101k|                if (pos2 < len2) {
  ------------------
  |  Branch (1816:21): [True: 100k, False: 1.36k]
  ------------------
 1817|   100k|                    curB = array2[8 * pos2];
 1818|   100k|                } else {
 1819|  1.36k|                    break;
 1820|  1.36k|                }
 1821|   101k|            }
 1822|   189k|            sse_merge(&V, &vecMax, &vecMin, &vecMax);
 1823|       |            // conditionally stores the last value of laststore as well as all
 1824|       |            // but the
 1825|       |            // last value of vecMin
 1826|   189k|            output += store_unique_xor(laststore, vecMin, output);
 1827|   189k|            laststore = vecMin;
 1828|   189k|        }
 1829|  3.99k|        sse_merge(&V, &vecMax, &vecMin, &vecMax);
 1830|       |        // conditionally stores the last value of laststore as well as all but
 1831|       |        // the
 1832|       |        // last value of vecMin
 1833|  3.99k|        output += store_unique_xor(laststore, vecMin, output);
 1834|  3.99k|        laststore = vecMin;
 1835|  3.99k|    }
 1836|  4.42k|    uint32_t len = (uint32_t)(output - initoutput);
 1837|       |
 1838|       |    // we finish the rest off using a scalar algorithm
 1839|       |    // could be improved?
 1840|       |    // conditionally stores the last value of laststore as well as all but the
 1841|       |    // last value of vecMax,
 1842|       |    // we store to "buffer"
 1843|  4.42k|    int leftoversize = store_unique_xor(laststore, vecMax, buffer);
 1844|  4.42k|    uint16_t vec7 = (uint16_t)_mm_extract_epi16(vecMax, 7);
 1845|  4.42k|    uint16_t vec6 = (uint16_t)_mm_extract_epi16(vecMax, 6);
 1846|  4.42k|    if (vec7 != vec6) buffer[leftoversize++] = vec7;
  ------------------
  |  Branch (1846:9): [True: 4.37k, False: 49]
  ------------------
 1847|  4.42k|    if (pos1 == len1) {
  ------------------
  |  Branch (1847:9): [True: 2.94k, False: 1.47k]
  ------------------
 1848|  2.94k|        memcpy(buffer + leftoversize, array1 + 8 * pos1,
 1849|  2.94k|               (length1 - 8 * len1) * sizeof(uint16_t));
 1850|  2.94k|        leftoversize += length1 - 8 * len1;
 1851|  2.94k|        if (leftoversize == 0) {  // trivial case
  ------------------
  |  Branch (1851:13): [True: 9, False: 2.94k]
  ------------------
 1852|      9|            memcpy(output, array2 + 8 * pos2,
 1853|      9|                   (length2 - 8 * pos2) * sizeof(uint16_t));
 1854|      9|            len += (length2 - 8 * pos2);
 1855|  2.94k|        } else {
 1856|  2.94k|            qsort(buffer, leftoversize, sizeof(uint16_t), uint16_compare);
 1857|  2.94k|            leftoversize = unique_xor(buffer, leftoversize);
 1858|  2.94k|            len += xor_uint16(buffer, leftoversize, array2 + 8 * pos2,
 1859|  2.94k|                              length2 - 8 * pos2, output);
 1860|  2.94k|        }
 1861|  2.94k|    } else {
 1862|  1.47k|        memcpy(buffer + leftoversize, array2 + 8 * pos2,
 1863|  1.47k|               (length2 - 8 * len2) * sizeof(uint16_t));
 1864|  1.47k|        leftoversize += length2 - 8 * len2;
 1865|  1.47k|        if (leftoversize == 0) {  // trivial case
  ------------------
  |  Branch (1865:13): [True: 4, False: 1.47k]
  ------------------
 1866|      4|            memcpy(output, array1 + 8 * pos1,
 1867|      4|                   (length1 - 8 * pos1) * sizeof(uint16_t));
 1868|      4|            len += (length1 - 8 * pos1);
 1869|  1.47k|        } else {
 1870|  1.47k|            qsort(buffer, leftoversize, sizeof(uint16_t), uint16_compare);
 1871|  1.47k|            leftoversize = unique_xor(buffer, leftoversize);
 1872|  1.47k|            len += xor_uint16(buffer, leftoversize, array1 + 8 * pos1,
 1873|  1.47k|                              length1 - 8 * pos1, output);
 1874|  1.47k|        }
 1875|  1.47k|    }
 1876|  4.42k|    return len;
 1877|  8.05k|}
fast_union_uint16:
 1980|  4.61k|                         uint16_t *buffer) {
 1981|  4.61k|#if CROARING_IS_X64
 1982|  4.61k|    if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (1982:9): [True: 4.61k, False: 0]
  ------------------
 1983|       |        // compute union with smallest array first
 1984|  4.61k|        if (size_1 < size_2) {
  ------------------
  |  Branch (1984:13): [True: 2.36k, False: 2.24k]
  ------------------
 1985|  2.36k|            return union_vector16(set_1, (uint32_t)size_1, set_2,
 1986|  2.36k|                                  (uint32_t)size_2, buffer);
 1987|  2.36k|        } else {
 1988|  2.24k|            return union_vector16(set_2, (uint32_t)size_2, set_1,
 1989|  2.24k|                                  (uint32_t)size_1, buffer);
 1990|  2.24k|        }
 1991|  4.61k|    } else {
 1992|       |        // compute union with smallest array first
 1993|      0|        if (size_1 < size_2) {
  ------------------
  |  Branch (1993:13): [True: 0, False: 0]
  ------------------
 1994|      0|            return union_uint16(set_1, size_1, set_2, size_2, buffer);
 1995|      0|        } else {
 1996|      0|            return union_uint16(set_2, size_2, set_1, size_1, buffer);
 1997|      0|        }
 1998|      0|    }
 1999|       |#else
 2000|       |    // compute union with smallest array first
 2001|       |    if (size_1 < size_2) {
 2002|       |        return union_uint16(set_1, size_1, set_2, size_2, buffer);
 2003|       |    } else {
 2004|       |        return union_uint16(set_2, size_2, set_1, size_1, buffer);
 2005|       |    }
 2006|       |#endif
 2007|  4.61k|}
memequals:
 2111|  7.38k|bool memequals(const void *s1, const void *s2, size_t n) {
 2112|  7.38k|    if (n == 0) {
  ------------------
  |  Branch (2112:9): [True: 0, False: 7.38k]
  ------------------
 2113|      0|        return true;
 2114|      0|    }
 2115|  7.38k|#if CROARING_IS_X64
 2116|  7.38k|    int support = croaring_hardware_support();
 2117|  7.38k|#if CROARING_COMPILER_SUPPORTS_AVX512
 2118|  7.38k|    if (support & ROARING_SUPPORTS_AVX512) {
  ------------------
  |  Branch (2118:9): [True: 0, False: 7.38k]
  ------------------
 2119|      0|        return _avx512_memequals(s1, s2, n);
 2120|      0|    } else
 2121|  7.38k|#endif  // CROARING_COMPILER_SUPPORTS_AVX512
 2122|  7.38k|        if (support & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (2122:13): [True: 7.38k, False: 0]
  ------------------
 2123|  7.38k|            return _avx2_memequals(s1, s2, n);
 2124|  7.38k|        } else {
 2125|      0|            return memcmp(s1, s2, n) == 0;
 2126|      0|        }
 2127|       |#else
 2128|       |    return memcmp(s1, s2, n) == 0;
 2129|       |#endif
 2130|  7.38k|}
array_util.c:binarySearch4:
  804|  1.39k|                          int32_t *index4) {
  805|  1.39k|    const uint16_t *base1 = array;
  806|  1.39k|    const uint16_t *base2 = array;
  807|  1.39k|    const uint16_t *base3 = array;
  808|  1.39k|    const uint16_t *base4 = array;
  809|  1.39k|    if (n == 0) return;
  ------------------
  |  Branch (809:9): [True: 0, False: 1.39k]
  ------------------
  810|  17.4k|    while (n > 1) {
  ------------------
  |  Branch (810:12): [True: 16.0k, False: 1.39k]
  ------------------
  811|  16.0k|        int32_t half = n >> 1;
  812|  16.0k|        base1 = (base1[half] < target1) ? &base1[half] : base1;
  ------------------
  |  Branch (812:17): [True: 1.21k, False: 14.8k]
  ------------------
  813|  16.0k|        base2 = (base2[half] < target2) ? &base2[half] : base2;
  ------------------
  |  Branch (813:17): [True: 2.34k, False: 13.6k]
  ------------------
  814|  16.0k|        base3 = (base3[half] < target3) ? &base3[half] : base3;
  ------------------
  |  Branch (814:17): [True: 3.06k, False: 12.9k]
  ------------------
  815|  16.0k|        base4 = (base4[half] < target4) ? &base4[half] : base4;
  ------------------
  |  Branch (815:17): [True: 3.46k, False: 12.5k]
  ------------------
  816|  16.0k|        n -= half;
  817|  16.0k|    }
  818|  1.39k|    *index1 = (int32_t)((*base1 < target1) + base1 - array);
  819|  1.39k|    *index2 = (int32_t)((*base2 < target2) + base2 - array);
  820|  1.39k|    *index3 = (int32_t)((*base3 < target3) + base3 - array);
  821|  1.39k|    *index4 = (int32_t)((*base4 < target4) + base4 - array);
  822|  1.39k|}
array_util.c:binarySearch2:
  833|    414|                          uint16_t target2, int32_t *index1, int32_t *index2) {
  834|    414|    const uint16_t *base1 = array;
  835|    414|    const uint16_t *base2 = array;
  836|    414|    if (n == 0) return;
  ------------------
  |  Branch (836:9): [True: 0, False: 414]
  ------------------
  837|  3.93k|    while (n > 1) {
  ------------------
  |  Branch (837:12): [True: 3.51k, False: 414]
  ------------------
  838|  3.51k|        int32_t half = n >> 1;
  839|  3.51k|        base1 = (base1[half] < target1) ? &base1[half] : base1;
  ------------------
  |  Branch (839:17): [True: 881, False: 2.63k]
  ------------------
  840|  3.51k|        base2 = (base2[half] < target2) ? &base2[half] : base2;
  ------------------
  |  Branch (840:17): [True: 1.39k, False: 2.12k]
  ------------------
  841|  3.51k|        n -= half;
  842|  3.51k|    }
  843|    414|    *index1 = (int32_t)((*base1 < target1) + base1 - array);
  844|    414|    *index2 = (int32_t)((*base2 < target2) + base2 - array);
  845|    414|}
array_util.c:sse_merge:
 1244|   307k|                             __m128i *vecMin, __m128i *vecMax) {  // output
 1245|   307k|    __m128i vecTmp;
 1246|   307k|    vecTmp = _mm_min_epu16(*vInput1, *vInput2);
 1247|   307k|    *vecMax = _mm_max_epu16(*vInput1, *vInput2);
 1248|   307k|    vecTmp = _mm_alignr_epi8(vecTmp, vecTmp, 2);
 1249|   307k|    *vecMin = _mm_min_epu16(vecTmp, *vecMax);
 1250|   307k|    *vecMax = _mm_max_epu16(vecTmp, *vecMax);
 1251|   307k|    vecTmp = _mm_alignr_epi8(*vecMin, *vecMin, 2);
 1252|   307k|    *vecMin = _mm_min_epu16(vecTmp, *vecMax);
 1253|   307k|    *vecMax = _mm_max_epu16(vecTmp, *vecMax);
 1254|   307k|    vecTmp = _mm_alignr_epi8(*vecMin, *vecMin, 2);
 1255|   307k|    *vecMin = _mm_min_epu16(vecTmp, *vecMax);
 1256|   307k|    *vecMax = _mm_max_epu16(vecTmp, *vecMax);
 1257|   307k|    vecTmp = _mm_alignr_epi8(*vecMin, *vecMin, 2);
 1258|   307k|    *vecMin = _mm_min_epu16(vecTmp, *vecMax);
 1259|   307k|    *vecMax = _mm_max_epu16(vecTmp, *vecMax);
 1260|   307k|    vecTmp = _mm_alignr_epi8(*vecMin, *vecMin, 2);
 1261|   307k|    *vecMin = _mm_min_epu16(vecTmp, *vecMax);
 1262|   307k|    *vecMax = _mm_max_epu16(vecTmp, *vecMax);
 1263|   307k|    vecTmp = _mm_alignr_epi8(*vecMin, *vecMin, 2);
 1264|   307k|    *vecMin = _mm_min_epu16(vecTmp, *vecMax);
 1265|   307k|    *vecMax = _mm_max_epu16(vecTmp, *vecMax);
 1266|   307k|    vecTmp = _mm_alignr_epi8(*vecMin, *vecMin, 2);
 1267|   307k|    *vecMin = _mm_min_epu16(vecTmp, *vecMax);
 1268|   307k|    *vecMax = _mm_max_epu16(vecTmp, *vecMax);
 1269|       |    *vecMin = _mm_alignr_epi8(*vecMin, *vecMin, 2);
 1270|   307k|}
array_util.c:store_unique:
 1619|   112k|static inline int store_unique(__m128i old, __m128i newval, uint16_t *output) {
 1620|   112k|    __m128i vecTmp = _mm_alignr_epi8(newval, old, 16 - 2);
 1621|       |    // lots of high latency instructions follow (optimize?)
 1622|   112k|    int M = _mm_movemask_epi8(
 1623|   112k|        _mm_packs_epi16(_mm_cmpeq_epi16(vecTmp, newval), _mm_setzero_si128()));
 1624|   112k|    int numberofnewvalues = 8 - _mm_popcnt_u32(M);
 1625|   112k|    __m128i key = _mm_lddqu_si128((const __m128i *)uniqshuf + M);
 1626|   112k|    __m128i val = _mm_shuffle_epi8(newval, key);
 1627|   112k|    _mm_storeu_si128((__m128i *)output, val);
 1628|   112k|    return numberofnewvalues;
 1629|   112k|}
array_util.c:uint16_compare:
 1645|   126k|static int uint16_compare(const void *a, const void *b) {
 1646|   126k|    return (*(uint16_t *)a - *(uint16_t *)b);
 1647|   126k|}
array_util.c:unique:
 1634|  3.54k|static inline uint32_t unique(uint16_t *out, uint32_t len) {
 1635|  3.54k|    uint32_t pos = 1;
 1636|  36.3k|    for (uint32_t i = 1; i < len; ++i) {
  ------------------
  |  Branch (1636:26): [True: 32.7k, False: 3.54k]
  ------------------
 1637|  32.7k|        if (out[i] != out[i - 1]) {
  ------------------
  |  Branch (1637:13): [True: 32.6k, False: 95]
  ------------------
 1638|  32.6k|            out[pos++] = out[i];
 1639|  32.6k|        }
 1640|  32.7k|    }
 1641|  3.54k|    return pos;
 1642|  3.54k|}
array_util.c:store_unique_xor:
 1746|   202k|                                   uint16_t *output) {
 1747|   202k|    __m128i vecTmp1 = _mm_alignr_epi8(newval, old, 16 - 4);
 1748|       |    __m128i vecTmp2 = _mm_alignr_epi8(newval, old, 16 - 2);
 1749|   202k|    __m128i equalleft = _mm_cmpeq_epi16(vecTmp2, vecTmp1);
 1750|   202k|    __m128i equalright = _mm_cmpeq_epi16(vecTmp2, newval);
 1751|   202k|    __m128i equalleftoright = _mm_or_si128(equalleft, equalright);
 1752|   202k|    int M = _mm_movemask_epi8(
 1753|   202k|        _mm_packs_epi16(equalleftoright, _mm_setzero_si128()));
 1754|   202k|    int numberofnewvalues = 8 - _mm_popcnt_u32(M);
 1755|   202k|    __m128i key = _mm_lddqu_si128((const __m128i *)uniqshuf + M);
 1756|   202k|    __m128i val = _mm_shuffle_epi8(vecTmp2, key);
 1757|   202k|    _mm_storeu_si128((__m128i *)output, val);
 1758|   202k|    return numberofnewvalues;
 1759|   202k|}
array_util.c:unique_xor:
 1764|  4.41k|static inline uint32_t unique_xor(uint16_t *out, uint32_t len) {
 1765|  4.41k|    uint32_t pos = 1;
 1766|  43.7k|    for (uint32_t i = 1; i < len; ++i) {
  ------------------
  |  Branch (1766:26): [True: 39.3k, False: 4.41k]
  ------------------
 1767|  39.3k|        if (out[i] != out[i - 1]) {
  ------------------
  |  Branch (1767:13): [True: 39.1k, False: 230]
  ------------------
 1768|  39.1k|            out[pos++] = out[i];
 1769|  39.1k|        } else
 1770|    230|            pos--;  // if it is identical to previous, delete it
 1771|  39.3k|    }
 1772|  4.41k|    return pos;
 1773|  4.41k|}
array_util.c:_avx2_memequals:
 2069|  7.38k|static inline bool _avx2_memequals(const void *s1, const void *s2, size_t n) {
 2070|  7.38k|    const uint8_t *ptr1 = (const uint8_t *)s1;
 2071|  7.38k|    const uint8_t *ptr2 = (const uint8_t *)s2;
 2072|  7.38k|    const uint8_t *end1 = ptr1 + n;
 2073|  7.38k|    const uint8_t *end8 = ptr1 + n / 8 * 8;
 2074|  7.38k|    const uint8_t *end32 = ptr1 + n / 32 * 32;
 2075|       |
 2076|   145k|    while (ptr1 < end32) {
  ------------------
  |  Branch (2076:12): [True: 138k, False: 7.31k]
  ------------------
 2077|   138k|        __m256i r1 = _mm256_loadu_si256((const __m256i *)ptr1);
 2078|   138k|        __m256i r2 = _mm256_loadu_si256((const __m256i *)ptr2);
 2079|   138k|        int mask = _mm256_movemask_epi8(_mm256_cmpeq_epi8(r1, r2));
 2080|   138k|        if ((uint32_t)mask != UINT32_MAX) {
  ------------------
  |  Branch (2080:13): [True: 63, False: 138k]
  ------------------
 2081|     63|            return false;
 2082|     63|        }
 2083|   138k|        ptr1 += 32;
 2084|   138k|        ptr2 += 32;
 2085|   138k|    }
 2086|       |
 2087|  13.1k|    while (ptr1 < end8) {
  ------------------
  |  Branch (2087:12): [True: 5.95k, False: 7.23k]
  ------------------
 2088|  5.95k|        uint64_t v1, v2;
 2089|  5.95k|        memcpy(&v1, ptr1, sizeof(uint64_t));
 2090|  5.95k|        memcpy(&v2, ptr2, sizeof(uint64_t));
 2091|  5.95k|        if (v1 != v2) {
  ------------------
  |  Branch (2091:13): [True: 84, False: 5.87k]
  ------------------
 2092|     84|            return false;
 2093|     84|        }
 2094|  5.87k|        ptr1 += 8;
 2095|  5.87k|        ptr2 += 8;
 2096|  5.87k|    }
 2097|       |
 2098|  25.6k|    while (ptr1 < end1) {
  ------------------
  |  Branch (2098:12): [True: 18.4k, False: 7.20k]
  ------------------
 2099|  18.4k|        if (*ptr1 != *ptr2) {
  ------------------
  |  Branch (2099:13): [True: 34, False: 18.4k]
  ------------------
 2100|     34|            return false;
 2101|     34|        }
 2102|  18.4k|        ptr1++;
 2103|  18.4k|        ptr2++;
 2104|  18.4k|    }
 2105|       |
 2106|  7.20k|    return true;
 2107|  7.23k|}

bitset_extract_setbits_avx2:
  687|  1.03k|                                   uint32_t base) {
  688|  1.03k|    if (outcapacity == 0) return 0;
  ------------------
  |  Branch (688:9): [True: 0, False: 1.03k]
  ------------------
  689|  1.03k|    uint32_t *initout = out;
  690|  1.03k|    __m256i baseVec = _mm256_set1_epi32(base - 1);
  691|  1.03k|    __m256i incVec = _mm256_set1_epi32(64);
  692|  1.03k|    __m256i add8 = _mm256_set1_epi32(8);
  693|  1.03k|    uint32_t *safeout = out + outcapacity;
  694|  1.03k|    size_t i = 0;
  695|   873k|    for (; (i < length) && (out + 64 <= safeout); ++i) {
  ------------------
  |  Branch (695:12): [True: 873k, False: 283]
  |  Branch (695:28): [True: 872k, False: 755]
  ------------------
  696|   872k|        uint64_t w = words[i];
  697|   872k|        if (w == 0) {
  ------------------
  |  Branch (697:13): [True: 117k, False: 755k]
  ------------------
  698|   117k|            baseVec = _mm256_add_epi32(baseVec, incVec);
  699|   755k|        } else {
  700|  3.77M|            for (int k = 0; k < 4; ++k) {
  ------------------
  |  Branch (700:29): [True: 3.02M, False: 755k]
  ------------------
  701|  3.02M|                uint8_t byteA = (uint8_t)w;
  702|  3.02M|                uint8_t byteB = (uint8_t)(w >> 8);
  703|  3.02M|                w >>= 16;
  704|  3.02M|                __m256i vecA =
  705|  3.02M|                    _mm256_loadu_si256((const __m256i *)vecDecodeTable[byteA]);
  706|  3.02M|                __m256i vecB =
  707|  3.02M|                    _mm256_loadu_si256((const __m256i *)vecDecodeTable[byteB]);
  708|  3.02M|                uint8_t advanceA = lengthTable[byteA];
  709|  3.02M|                uint8_t advanceB = lengthTable[byteB];
  710|  3.02M|                vecA = _mm256_add_epi32(baseVec, vecA);
  711|  3.02M|                baseVec = _mm256_add_epi32(baseVec, add8);
  712|  3.02M|                vecB = _mm256_add_epi32(baseVec, vecB);
  713|  3.02M|                baseVec = _mm256_add_epi32(baseVec, add8);
  714|  3.02M|                _mm256_storeu_si256((__m256i *)out, vecA);
  715|  3.02M|                out += advanceA;
  716|  3.02M|                _mm256_storeu_si256((__m256i *)out, vecB);
  717|  3.02M|                out += advanceB;
  718|  3.02M|            }
  719|   755k|        }
  720|   872k|    }
  721|  1.03k|    base += i * 64;
  722|  14.5k|    for (; (i < length) && (out < safeout); ++i) {
  ------------------
  |  Branch (722:12): [True: 14.1k, False: 374]
  |  Branch (722:28): [True: 13.5k, False: 664]
  ------------------
  723|  13.5k|        uint64_t w = words[i];
  724|  32.5k|        while ((w != 0) && (out < safeout)) {
  ------------------
  |  Branch (724:16): [True: 19.0k, False: 13.5k]
  |  Branch (724:28): [True: 19.0k, False: 0]
  ------------------
  725|  19.0k|            int r =
  726|  19.0k|                roaring_trailing_zeroes(w);  // on x64, should compile to TZCNT
  727|  19.0k|            uint32_t val = r + base;
  728|  19.0k|            memcpy(out, &val,
  729|  19.0k|                   sizeof(uint32_t));  // should be compiled as a MOV on x64
  730|  19.0k|            out++;
  731|  19.0k|            w &= (w - 1);
  732|  19.0k|        }
  733|  13.5k|        base += 64;
  734|  13.5k|    }
  735|  1.03k|    return out - initout;
  736|  1.03k|}
bitset_extract_setbits:
  741|    480|                              uint32_t *out, uint32_t base) {
  742|    480|    int outpos = 0;
  743|   492k|    for (size_t i = 0; i < length; ++i) {
  ------------------
  |  Branch (743:24): [True: 491k, False: 480]
  ------------------
  744|   491k|        uint64_t w = words[i];
  745|  2.79M|        while (w != 0) {
  ------------------
  |  Branch (745:16): [True: 2.30M, False: 491k]
  ------------------
  746|  2.30M|            int r =
  747|  2.30M|                roaring_trailing_zeroes(w);  // on x64, should compile to TZCNT
  748|  2.30M|            uint32_t val = r + base;
  749|  2.30M|            memcpy(out + outpos, &val,
  750|  2.30M|                   sizeof(uint32_t));  // should be compiled as a MOV on x64
  751|  2.30M|            outpos++;
  752|  2.30M|            w &= (w - 1);
  753|  2.30M|        }
  754|   491k|        base += 64;
  755|   491k|    }
  756|    480|    return outpos;
  757|    480|}
bitset_extract_setbits_uint16:
  852|  3.01k|                                     uint16_t *out, uint16_t base) {
  853|  3.01k|    int outpos = 0;
  854|  3.08M|    for (size_t i = 0; i < length; ++i) {
  ------------------
  |  Branch (854:24): [True: 3.08M, False: 3.01k]
  ------------------
  855|  3.08M|        uint64_t w = words[i];
  856|  6.02M|        while (w != 0) {
  ------------------
  |  Branch (856:16): [True: 2.93M, False: 3.08M]
  ------------------
  857|  2.93M|            int r = roaring_trailing_zeroes(w);
  858|  2.93M|            out[outpos++] = (uint16_t)(r + base);
  859|  2.93M|            w &= (w - 1);
  860|  2.93M|        }
  861|  3.08M|        base += 64;
  862|  3.08M|    }
  863|  3.01k|    return outpos;
  864|  3.01k|}
bitset_clear_list:
 1032|  1.75k|                           uint64_t length) {
 1033|  1.75k|    if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (1033:9): [True: 1.75k, False: 0]
  ------------------
 1034|  1.75k|        return _asm_bitset_clear_list(words, card, list, length);
 1035|  1.75k|    } else {
 1036|      0|        return _scalar_bitset_clear_list(words, card, list, length);
 1037|      0|    }
 1038|  1.75k|}
bitset_set_list_withcard:
 1041|  1.42k|                                  const uint16_t *list, uint64_t length) {
 1042|  1.42k|    if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (1042:9): [True: 1.42k, False: 0]
  ------------------
 1043|  1.42k|        return _asm_bitset_set_list_withcard(words, card, list, length);
 1044|  1.42k|    } else {
 1045|      0|        return _scalar_bitset_set_list_withcard(words, card, list, length);
 1046|      0|    }
 1047|  1.42k|}
bitset_set_list:
 1049|    222|void bitset_set_list(uint64_t *words, const uint16_t *list, uint64_t length) {
 1050|    222|    if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (1050:9): [True: 222, False: 0]
  ------------------
 1051|    222|        _asm_bitset_set_list(words, list, length);
 1052|    222|    } else {
 1053|      0|        _scalar_bitset_set_list(words, list, length);
 1054|      0|    }
 1055|    222|}
bitset_flip_list_withcard:
 1111|  1.52k|                                   const uint16_t *list, uint64_t length) {
 1112|  1.52k|    uint64_t offset, load, newload, pos, index;
 1113|  1.52k|    const uint16_t *end = list + length;
 1114|  2.73M|    while (list != end) {
  ------------------
  |  Branch (1114:12): [True: 2.73M, False: 1.52k]
  ------------------
 1115|  2.73M|        pos = *list;
 1116|  2.73M|        offset = pos >> 6;
 1117|  2.73M|        index = pos % 64;
 1118|  2.73M|        load = words[offset];
 1119|  2.73M|        newload = load ^ (UINT64_C(1) << index);
 1120|       |        // todo: is a branch here all that bad?
 1121|  2.73M|        card +=
 1122|       |            (1 - 2 * (((UINT64_C(1) << index) & load) >> index));  // +1 or -1
 1123|  2.73M|        words[offset] = newload;
 1124|  2.73M|        list++;
 1125|  2.73M|    }
 1126|  1.52k|    return card;
 1127|  1.52k|}
bitset_util.c:_asm_bitset_clear_list:
  953|  1.75k|                                              uint64_t length) {
  954|  1.75k|    uint64_t offset, load, pos;
  955|  1.75k|    uint64_t shift = 6;
  956|  1.75k|    const uint16_t *end = list + length;
  957|  1.75k|    if (!length) return card;
  ------------------
  |  Branch (957:9): [True: 0, False: 1.75k]
  ------------------
  958|       |    // btr is not available as an intrinsic in GCC
  959|  1.75k|    __asm volatile(
  960|  1.75k|        "1:\n"
  961|  1.75k|        "movzwq (%[list]), %[pos]\n"
  962|  1.75k|        "shrx %[shift], %[pos], %[offset]\n"
  963|  1.75k|        "mov (%[words],%[offset],8), %[load]\n"
  964|  1.75k|        "btr %[pos], %[load]\n"
  965|  1.75k|        "mov %[load], (%[words],%[offset],8)\n"
  966|  1.75k|        "sbb $0, %[card]\n"
  967|  1.75k|        "add $2, %[list]\n"
  968|  1.75k|        "cmp %[list], %[end]\n"
  969|  1.75k|        "jnz 1b"
  970|  1.75k|        : [card] "+&r"(card), [list] "+&r"(list), [load] "=&r"(load),
  971|  1.75k|          [pos] "=&r"(pos), [offset] "=&r"(offset)
  972|  1.75k|        : [end] "r"(end), [words] "r"(words), [shift] "r"(shift)
  973|  1.75k|        :
  974|  1.75k|        /* clobbers */ "memory");
  975|  1.75k|    return card;
  976|  1.75k|}
bitset_util.c:_asm_bitset_set_list_withcard:
  871|  1.42k|                                                     uint64_t length) {
  872|  1.42k|    uint64_t offset, load, pos;
  873|  1.42k|    uint64_t shift = 6;
  874|  1.42k|    const uint16_t *end = list + length;
  875|  1.42k|    if (!length) return card;
  ------------------
  |  Branch (875:9): [True: 0, False: 1.42k]
  ------------------
  876|       |    // TODO: could unroll for performance, see bitset_set_list
  877|       |    // bts is not available as an intrinsic in GCC
  878|  1.42k|    __asm volatile(
  879|  1.42k|        "1:\n"
  880|  1.42k|        "movzwq (%[list]), %[pos]\n"
  881|  1.42k|        "shrx %[shift], %[pos], %[offset]\n"
  882|  1.42k|        "mov (%[words],%[offset],8), %[load]\n"
  883|  1.42k|        "bts %[pos], %[load]\n"
  884|  1.42k|        "mov %[load], (%[words],%[offset],8)\n"
  885|  1.42k|        "sbb $-1, %[card]\n"
  886|  1.42k|        "add $2, %[list]\n"
  887|  1.42k|        "cmp %[list], %[end]\n"
  888|  1.42k|        "jnz 1b"
  889|  1.42k|        : [card] "+&r"(card), [list] "+&r"(list), [load] "=&r"(load),
  890|  1.42k|          [pos] "=&r"(pos), [offset] "=&r"(offset)
  891|  1.42k|        : [end] "r"(end), [words] "r"(words), [shift] "r"(shift));
  892|  1.42k|    return card;
  893|  1.42k|}
bitset_util.c:_asm_bitset_set_list:
  896|    222|                                        uint64_t length) {
  897|    222|    uint64_t pos;
  898|    222|    const uint16_t *end = list + length;
  899|       |
  900|    222|    uint64_t shift = 6;
  901|    222|    uint64_t offset;
  902|    222|    uint64_t load;
  903|  6.19k|    for (; list + 3 < end; list += 4) {
  ------------------
  |  Branch (903:12): [True: 5.97k, False: 222]
  ------------------
  904|  5.97k|        pos = list[0];
  905|  5.97k|        __asm volatile(
  906|  5.97k|            "shrx %[shift], %[pos], %[offset]\n"
  907|  5.97k|            "mov (%[words],%[offset],8), %[load]\n"
  908|  5.97k|            "bts %[pos], %[load]\n"
  909|  5.97k|            "mov %[load], (%[words],%[offset],8)"
  910|  5.97k|            : [load] "=&r"(load), [offset] "=&r"(offset)
  911|  5.97k|            : [words] "r"(words), [shift] "r"(shift), [pos] "r"(pos));
  912|  5.97k|        pos = list[1];
  913|  5.97k|        __asm volatile(
  914|  5.97k|            "shrx %[shift], %[pos], %[offset]\n"
  915|  5.97k|            "mov (%[words],%[offset],8), %[load]\n"
  916|  5.97k|            "bts %[pos], %[load]\n"
  917|  5.97k|            "mov %[load], (%[words],%[offset],8)"
  918|  5.97k|            : [load] "=&r"(load), [offset] "=&r"(offset)
  919|  5.97k|            : [words] "r"(words), [shift] "r"(shift), [pos] "r"(pos));
  920|  5.97k|        pos = list[2];
  921|  5.97k|        __asm volatile(
  922|  5.97k|            "shrx %[shift], %[pos], %[offset]\n"
  923|  5.97k|            "mov (%[words],%[offset],8), %[load]\n"
  924|  5.97k|            "bts %[pos], %[load]\n"
  925|  5.97k|            "mov %[load], (%[words],%[offset],8)"
  926|  5.97k|            : [load] "=&r"(load), [offset] "=&r"(offset)
  927|  5.97k|            : [words] "r"(words), [shift] "r"(shift), [pos] "r"(pos));
  928|  5.97k|        pos = list[3];
  929|  5.97k|        __asm volatile(
  930|  5.97k|            "shrx %[shift], %[pos], %[offset]\n"
  931|  5.97k|            "mov (%[words],%[offset],8), %[load]\n"
  932|  5.97k|            "bts %[pos], %[load]\n"
  933|  5.97k|            "mov %[load], (%[words],%[offset],8)"
  934|  5.97k|            : [load] "=&r"(load), [offset] "=&r"(offset)
  935|  5.97k|            : [words] "r"(words), [shift] "r"(shift), [pos] "r"(pos));
  936|  5.97k|    }
  937|       |
  938|    575|    while (list != end) {
  ------------------
  |  Branch (938:12): [True: 353, False: 222]
  ------------------
  939|    353|        pos = list[0];
  940|    353|        __asm volatile(
  941|    353|            "shrx %[shift], %[pos], %[offset]\n"
  942|    353|            "mov (%[words],%[offset],8), %[load]\n"
  943|    353|            "bts %[pos], %[load]\n"
  944|    353|            "mov %[load], (%[words],%[offset],8)"
  945|    353|            : [load] "=&r"(load), [offset] "=&r"(offset)
  946|    353|            : [words] "r"(words), [shift] "r"(shift), [pos] "r"(pos));
  947|    353|        list++;
  948|    353|    }
  949|    222|}

array_container_create_given_capacity:
   49|   150k|array_container_t *array_container_create_given_capacity(int32_t size) {
   50|   150k|    array_container_t *container;
   51|       |
   52|   150k|    if ((container = (array_container_t *)roaring_malloc(
  ------------------
  |  Branch (52:9): [True: 0, False: 150k]
  ------------------
   53|   150k|             sizeof(array_container_t))) == NULL) {
   54|      0|        return NULL;
   55|      0|    }
   56|       |
   57|   150k|    if (size <= 0) {  // we don't want to rely on malloc(0)
  ------------------
  |  Branch (57:9): [True: 93.6k, False: 57.1k]
  ------------------
   58|  93.6k|        container->array = NULL;
   59|  93.6k|    } else if ((container->array = (uint16_t *)roaring_malloc(sizeof(uint16_t) *
  ------------------
  |  Branch (59:16): [True: 0, False: 57.1k]
  ------------------
   60|  57.1k|                                                              size)) == NULL) {
   61|      0|        roaring_free(container);
   62|      0|        return NULL;
   63|      0|    }
   64|       |
   65|   150k|    container->capacity = size;
   66|   150k|    container->cardinality = 0;
   67|       |
   68|   150k|    return container;
   69|   150k|}
array_container_create:
   72|  26.4k|array_container_t *array_container_create(void) {
   73|  26.4k|    return array_container_create_given_capacity(ARRAY_DEFAULT_INIT_SIZE);
   74|  26.4k|}
array_container_create_range:
   77|    144|array_container_t *array_container_create_range(uint32_t min, uint32_t max) {
   78|    144|    array_container_t *answer =
   79|    144|        array_container_create_given_capacity(max - min + 1);
   80|    144|    if (answer == NULL) return answer;
  ------------------
  |  Branch (80:9): [True: 0, False: 144]
  ------------------
   81|    144|    answer->cardinality = 0;
   82|    288|    for (uint32_t k = min; k < max; k++) {
  ------------------
  |  Branch (82:28): [True: 144, False: 144]
  ------------------
   83|    144|        answer->array[answer->cardinality++] = k;
   84|    144|    }
   85|    144|    return answer;
   86|    144|}
array_container_clone:
   90|  23.2k|array_container_t *array_container_clone(const array_container_t *src) {
   91|  23.2k|    array_container_t *newcontainer =
   92|  23.2k|        array_container_create_given_capacity(src->capacity);
   93|  23.2k|    if (newcontainer == NULL) return NULL;
  ------------------
  |  Branch (93:9): [True: 0, False: 23.2k]
  ------------------
   94|       |
   95|  23.2k|    newcontainer->cardinality = src->cardinality;
   96|       |
   97|  23.2k|    memcpy(newcontainer->array, src->array,
   98|  23.2k|           src->cardinality * sizeof(uint16_t));
   99|       |
  100|  23.2k|    return newcontainer;
  101|  23.2k|}
array_container_shrink_to_fit:
  131|  3.80k|int array_container_shrink_to_fit(array_container_t *src) {
  132|  3.80k|    if (src->cardinality == src->capacity) return 0;  // nothing to do
  ------------------
  |  Branch (132:9): [True: 497, False: 3.30k]
  ------------------
  133|  3.30k|    int savings = src->capacity - src->cardinality;
  134|  3.30k|    src->capacity = src->cardinality;
  135|  3.30k|    if (src->capacity ==
  ------------------
  |  Branch (135:9): [True: 0, False: 3.30k]
  ------------------
  136|  3.30k|        0) {  // we do not want to rely on realloc for zero allocs
  137|      0|        roaring_free(src->array);
  138|      0|        src->array = NULL;
  139|  3.30k|    } else {
  140|  3.30k|        uint16_t *oldarray = src->array;
  141|  3.30k|        src->array = (uint16_t *)roaring_realloc(
  142|  3.30k|            oldarray, src->capacity * sizeof(uint16_t));
  143|  3.30k|        if (src->array == NULL) roaring_free(oldarray);  // should never happen?
  ------------------
  |  Branch (143:13): [True: 0, False: 3.30k]
  ------------------
  144|  3.30k|    }
  145|  3.30k|    return savings;
  146|  3.80k|}
array_container_free:
  149|   150k|void array_container_free(array_container_t *arr) {
  150|   150k|    if (arr == NULL) return;
  ------------------
  |  Branch (150:9): [True: 0, False: 150k]
  ------------------
  151|   150k|    roaring_free(arr->array);
  152|   150k|    roaring_free(arr);
  153|   150k|}
array_container_grow:
  167|   121k|                          bool preserve) {
  168|   121k|    int32_t max = (min <= DEFAULT_MAX_SIZE ? DEFAULT_MAX_SIZE : 65536);
  ------------------
  |  Branch (168:20): [True: 121k, False: 0]
  ------------------
  169|   121k|    int32_t new_capacity = clamp(grow_capacity(container->capacity), min, max);
  170|       |
  171|   121k|    container->capacity = new_capacity;
  172|   121k|    uint16_t *array = container->array;
  173|       |
  174|   121k|    if (preserve) {
  ------------------
  |  Branch (174:9): [True: 111k, False: 10.0k]
  ------------------
  175|   111k|        container->array =
  176|   111k|            (uint16_t *)roaring_realloc(array, new_capacity * sizeof(uint16_t));
  177|   111k|        if (container->array == NULL) roaring_free(array);
  ------------------
  |  Branch (177:13): [True: 0, False: 111k]
  ------------------
  178|   111k|    } else {
  179|  10.0k|        roaring_free(array);
  180|  10.0k|        container->array =
  181|  10.0k|            (uint16_t *)roaring_malloc(new_capacity * sizeof(uint16_t));
  182|  10.0k|    }
  183|       |
  184|       |    // if realloc fails, we have container->array == NULL.
  185|   121k|}
array_container_copy:
  189|     34|                          array_container_t *dst) {
  190|     34|    const int32_t cardinality = src->cardinality;
  191|     34|    if (cardinality > dst->capacity) {
  ------------------
  |  Branch (191:9): [True: 34, False: 0]
  ------------------
  192|     34|        array_container_grow(dst, cardinality, false);
  193|     34|    }
  194|       |
  195|     34|    dst->cardinality = cardinality;
  196|     34|    memcpy(dst->array, src->array, cardinality * sizeof(uint16_t));
  197|     34|}
array_container_union:
  211|  4.61k|                           array_container_t *out) {
  212|  4.61k|    const int32_t card_1 = array_1->cardinality, card_2 = array_2->cardinality;
  213|  4.61k|    const int32_t max_cardinality = card_1 + card_2;
  214|       |
  215|  4.61k|    if (out->capacity < max_cardinality) {
  ------------------
  |  Branch (215:9): [True: 0, False: 4.61k]
  ------------------
  216|       |        array_container_grow(out, max_cardinality, false);
  217|      0|    }
  218|  4.61k|    out->cardinality = (int32_t)fast_union_uint16(
  219|  4.61k|        array_1->array, card_1, array_2->array, card_2, out->array);
  220|  4.61k|}
array_container_andnot:
  228|  5.86k|                            array_container_t *out) {
  229|  5.86k|    if (out->capacity < array_1->cardinality)
  ------------------
  |  Branch (229:9): [True: 2.32k, False: 3.54k]
  ------------------
  230|  2.32k|        array_container_grow(out, array_1->cardinality, false);
  231|  5.86k|#if CROARING_IS_X64
  232|  5.86k|    if ((croaring_hardware_support() & ROARING_SUPPORTS_AVX2) &&
  ------------------
  |  Branch (232:9): [True: 5.86k, False: 0]
  ------------------
  233|  5.86k|        (out != array_1) && (out != array_2)) {
  ------------------
  |  Branch (233:9): [True: 2.32k, False: 3.54k]
  |  Branch (233:29): [True: 2.32k, False: 0]
  ------------------
  234|  2.32k|        out->cardinality = difference_vector16(
  235|  2.32k|            array_1->array, array_1->cardinality, array_2->array,
  236|  2.32k|            array_2->cardinality, out->array);
  237|  3.54k|    } else {
  238|  3.54k|        out->cardinality =
  239|  3.54k|            difference_uint16(array_1->array, array_1->cardinality,
  240|  3.54k|                              array_2->array, array_2->cardinality, out->array);
  241|  3.54k|    }
  242|       |#else
  243|       |    out->cardinality =
  244|       |        difference_uint16(array_1->array, array_1->cardinality, array_2->array,
  245|       |                          array_2->cardinality, out->array);
  246|       |#endif
  247|  5.86k|}
array_container_xor:
  256|  8.05k|                         array_container_t *out) {
  257|  8.05k|    const int32_t card_1 = array_1->cardinality, card_2 = array_2->cardinality;
  258|  8.05k|    const int32_t max_cardinality = card_1 + card_2;
  259|  8.05k|    if (out->capacity < max_cardinality) {
  ------------------
  |  Branch (259:9): [True: 0, False: 8.05k]
  ------------------
  260|      0|        array_container_grow(out, max_cardinality, false);
  261|      0|    }
  262|       |
  263|  8.05k|#if CROARING_IS_X64
  264|  8.05k|    if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (264:9): [True: 8.05k, False: 0]
  ------------------
  265|  8.05k|        out->cardinality =
  266|  8.05k|            xor_vector16(array_1->array, array_1->cardinality, array_2->array,
  267|  8.05k|                         array_2->cardinality, out->array);
  268|  8.05k|    } else {
  269|      0|        out->cardinality =
  270|      0|            xor_uint16(array_1->array, array_1->cardinality, array_2->array,
  271|      0|                       array_2->cardinality, out->array);
  272|      0|    }
  273|       |#else
  274|       |    out->cardinality =
  275|       |        xor_uint16(array_1->array, array_1->cardinality, array_2->array,
  276|       |                   array_2->cardinality, out->array);
  277|       |#endif
  278|  8.05k|}
array_container_intersection:
  290|  2.32k|                                  array_container_t *out) {
  291|  2.32k|    int32_t card_1 = array1->cardinality, card_2 = array2->cardinality,
  292|  2.32k|            min_card = minimum_int32(card_1, card_2);
  293|  2.32k|    const int threshold = 64;  // subject to tuning
  294|  2.32k|#if CROARING_IS_X64
  295|  2.32k|    if (out->capacity < min_card) {
  ------------------
  |  Branch (295:9): [True: 2.32k, False: 0]
  ------------------
  296|  2.32k|        array_container_grow(out, min_card + sizeof(__m128i) / sizeof(uint16_t),
  297|  2.32k|                             false);
  298|  2.32k|    }
  299|       |#else
  300|       |    if (out->capacity < min_card) {
  301|       |        array_container_grow(out, min_card, false);
  302|       |    }
  303|       |#endif
  304|       |
  305|  2.32k|    if (card_1 * threshold < card_2) {
  ------------------
  |  Branch (305:9): [True: 368, False: 1.95k]
  ------------------
  306|    368|        out->cardinality = intersect_skewed_uint16(
  307|    368|            array1->array, card_1, array2->array, card_2, out->array);
  308|  1.95k|    } else if (card_2 * threshold < card_1) {
  ------------------
  |  Branch (308:16): [True: 205, False: 1.75k]
  ------------------
  309|    205|        out->cardinality = intersect_skewed_uint16(
  310|    205|            array2->array, card_2, array1->array, card_1, out->array);
  311|  1.75k|    } else {
  312|  1.75k|#if CROARING_IS_X64
  313|  1.75k|        if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (313:13): [True: 1.75k, False: 0]
  ------------------
  314|  1.75k|            out->cardinality = intersect_vector16(
  315|  1.75k|                array1->array, card_1, array2->array, card_2, out->array);
  316|  1.75k|        } else {
  317|      0|            out->cardinality = intersect_uint16(
  318|      0|                array1->array, card_1, array2->array, card_2, out->array);
  319|      0|        }
  320|       |#else
  321|       |        out->cardinality = intersect_uint16(array1->array, card_1,
  322|       |                                            array2->array, card_2, out->array);
  323|       |#endif
  324|  1.75k|    }
  325|  2.32k|}
array_container_intersection_cardinality:
  330|  9.29k|                                             const array_container_t *array2) {
  331|  9.29k|    int32_t card_1 = array1->cardinality, card_2 = array2->cardinality;
  332|  9.29k|    const int threshold = 64;  // subject to tuning
  333|  9.29k|    if (card_1 * threshold < card_2) {
  ------------------
  |  Branch (333:9): [True: 1.47k, False: 7.82k]
  ------------------
  334|  1.47k|        return intersect_skewed_uint16_cardinality(array1->array, card_1,
  335|  1.47k|                                                   array2->array, card_2);
  336|  7.82k|    } else if (card_2 * threshold < card_1) {
  ------------------
  |  Branch (336:16): [True: 820, False: 7.00k]
  ------------------
  337|    820|        return intersect_skewed_uint16_cardinality(array2->array, card_2,
  338|    820|                                                   array1->array, card_1);
  339|  7.00k|    } else {
  340|  7.00k|#if CROARING_IS_X64
  341|  7.00k|        if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (341:13): [True: 7.00k, False: 0]
  ------------------
  342|  7.00k|            return intersect_vector16_cardinality(array1->array, card_1,
  343|  7.00k|                                                  array2->array, card_2);
  344|  7.00k|        } else {
  345|      0|            return intersect_uint16_cardinality(array1->array, card_1,
  346|      0|                                                array2->array, card_2);
  347|      0|        }
  348|       |#else
  349|       |        return intersect_uint16_cardinality(array1->array, card_1,
  350|       |                                            array2->array, card_2);
  351|       |#endif
  352|  7.00k|    }
  353|  9.29k|}
array_container_intersect:
  356|  2.32k|                               const array_container_t *array2) {
  357|  2.32k|    int32_t card_1 = array1->cardinality, card_2 = array2->cardinality;
  358|  2.32k|    const int threshold = 64;  // subject to tuning
  359|  2.32k|    if (card_1 * threshold < card_2) {
  ------------------
  |  Branch (359:9): [True: 368, False: 1.95k]
  ------------------
  360|    368|        return intersect_skewed_uint16_nonempty(array1->array, card_1,
  361|    368|                                                array2->array, card_2);
  362|  1.95k|    } else if (card_2 * threshold < card_1) {
  ------------------
  |  Branch (362:16): [True: 205, False: 1.75k]
  ------------------
  363|    205|        return intersect_skewed_uint16_nonempty(array2->array, card_2,
  364|    205|                                                array1->array, card_1);
  365|  1.75k|    } else {
  366|       |        // we do not bother vectorizing
  367|  1.75k|        return intersect_uint16_nonempty(array1->array, card_1, array2->array,
  368|  1.75k|                                         card_2);
  369|  1.75k|    }
  370|  2.32k|}
array_container_intersection_inplace:
  376|  4.86k|                                          const array_container_t *src_2) {
  377|  4.86k|    int32_t card_1 = src_1->cardinality, card_2 = src_2->cardinality;
  378|  4.86k|    const int threshold = 64;  // subject to tuning
  379|  4.86k|    if (card_1 * threshold < card_2) {
  ------------------
  |  Branch (379:9): [True: 0, False: 4.86k]
  ------------------
  380|      0|        src_1->cardinality = intersect_skewed_uint16(
  381|      0|            src_1->array, card_1, src_2->array, card_2, src_1->array);
  382|  4.86k|    } else if (card_2 * threshold < card_1) {
  ------------------
  |  Branch (382:16): [True: 214, False: 4.64k]
  ------------------
  383|    214|        src_1->cardinality = intersect_skewed_uint16(
  384|    214|            src_2->array, card_2, src_1->array, card_1, src_1->array);
  385|  4.64k|    } else {
  386|  4.64k|#if CROARING_IS_X64
  387|  4.64k|        if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (387:13): [True: 4.64k, False: 0]
  ------------------
  388|  4.64k|            src_1->cardinality = intersect_vector16_inplace(
  389|  4.64k|                src_1->array, card_1, src_2->array, card_2);
  390|  4.64k|        } else {
  391|      0|            src_1->cardinality = intersect_uint16(
  392|      0|                src_1->array, card_1, src_2->array, card_2, src_1->array);
  393|      0|        }
  394|       |#else
  395|       |        src_1->cardinality = intersect_uint16(
  396|       |            src_1->array, card_1, src_2->array, card_2, src_1->array);
  397|       |#endif
  398|  4.64k|    }
  399|  4.86k|}
array_container_to_uint32_array:
  403|  5.98k|                                    uint32_t base) {
  404|  5.98k|#if CROARING_IS_X64
  405|  5.98k|    int support = croaring_hardware_support();
  406|  5.98k|#if CROARING_COMPILER_SUPPORTS_AVX512
  407|  5.98k|    if (support & ROARING_SUPPORTS_AVX512) {
  ------------------
  |  Branch (407:9): [True: 0, False: 5.98k]
  ------------------
  408|      0|        return avx512_array_container_to_uint32_array(vout, cont->array,
  409|      0|                                                      cont->cardinality, base);
  410|      0|    }
  411|  5.98k|#endif
  412|  5.98k|    if (support & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (412:9): [True: 5.98k, False: 0]
  ------------------
  413|  5.98k|        return array_container_to_uint32_array_vector16(
  414|  5.98k|            vout, cont->array, cont->cardinality, base);
  415|  5.98k|    }
  416|      0|#endif  // CROARING_IS_X64
  417|      0|    int outpos = 0;
  418|      0|    uint32_t *out = (uint32_t *)vout;
  419|      0|    size_t i = 0;
  420|      0|    for (; i < (size_t)cont->cardinality; ++i) {
  ------------------
  |  Branch (420:12): [True: 0, False: 0]
  ------------------
  421|      0|        const uint32_t val = base + cont->array[i];
  422|      0|        memcpy(out + outpos, &val,
  423|      0|               sizeof(uint32_t));  // should be compiled as a MOV on x64
  424|      0|        outpos++;
  425|      0|    }
  426|      0|    return outpos;
  427|  5.98k|}
array_container_number_of_runs:
  495|  12.9k|int32_t array_container_number_of_runs(const array_container_t *ac) {
  496|       |    // Can SIMD work here?
  497|  12.9k|    int32_t nr_runs = 0;
  498|  12.9k|    int32_t prev = -2;
  499|  1.67M|    for (const uint16_t *p = ac->array; p != ac->array + ac->cardinality; ++p) {
  ------------------
  |  Branch (499:41): [True: 1.65M, False: 12.9k]
  ------------------
  500|  1.65M|        if (*p != prev + 1) nr_runs++;
  ------------------
  |  Branch (500:13): [True: 905k, False: 754k]
  ------------------
  501|  1.65M|        prev = *p;
  502|  1.65M|    }
  503|  12.9k|    return nr_runs;
  504|  12.9k|}
array_container_write:
  512|  7.20k|int32_t array_container_write(const array_container_t *container, char *buf) {
  513|       |#if CROARING_IS_BIG_ENDIAN
  514|       |    for (int32_t i = 0; i < container->cardinality; ++i) {
  515|       |        uint16_t v_le = croaring_htole16(container->array[i]);
  516|       |        memcpy(buf + i * sizeof(uint16_t), &v_le, sizeof(uint16_t));
  517|       |    }
  518|       |#else
  519|  7.20k|    memcpy(buf, container->array, container->cardinality * sizeof(uint16_t));
  520|  7.20k|#endif
  521|  7.20k|    return array_container_size_in_bytes(container);
  522|  7.20k|}
array_container_is_subset:
  525|  5.75k|                               const array_container_t *container2) {
  526|  5.75k|    if (container1->cardinality > container2->cardinality) {
  ------------------
  |  Branch (526:9): [True: 592, False: 5.16k]
  ------------------
  527|    592|        return false;
  528|    592|    }
  529|  5.16k|    int i1 = 0, i2 = 0;
  530|  55.0k|    while (i1 < container1->cardinality && i2 < container2->cardinality) {
  ------------------
  |  Branch (530:12): [True: 55.0k, False: 0]
  |  Branch (530:44): [True: 55.0k, False: 23]
  ------------------
  531|  55.0k|        if (container1->array[i1] == container2->array[i2]) {
  ------------------
  |  Branch (531:13): [True: 0, False: 55.0k]
  ------------------
  532|      0|            i1++;
  533|      0|            i2++;
  534|  55.0k|        } else if (container1->array[i1] > container2->array[i2]) {
  ------------------
  |  Branch (534:20): [True: 49.9k, False: 5.14k]
  ------------------
  535|  49.9k|            i2++;
  536|  49.9k|        } else {  // container1->array[i1] < container2->array[i2]
  537|  5.14k|            return false;
  538|  5.14k|        }
  539|  55.0k|    }
  540|     23|    if (i1 == container1->cardinality) {
  ------------------
  |  Branch (540:9): [True: 0, False: 23]
  ------------------
  541|      0|        return true;
  542|     23|    } else {
  543|       |        return false;
  544|     23|    }
  545|     23|}
array_container_read:
  548|  7.25k|                             const char *buf) {
  549|  7.25k|    if (container->capacity < cardinality) {
  ------------------
  |  Branch (549:9): [True: 0, False: 7.25k]
  ------------------
  550|      0|        array_container_grow(container, cardinality, false);
  551|      0|    }
  552|  7.25k|    container->cardinality = cardinality;
  553|       |#if CROARING_IS_BIG_ENDIAN
  554|       |    for (int32_t i = 0; i < cardinality; ++i) {
  555|       |        uint16_t v_le;
  556|       |        memcpy(&v_le, buf + i * sizeof(uint16_t), sizeof(uint16_t));
  557|       |        container->array[i] = croaring_letoh16(v_le);
  558|       |    }
  559|       |#else
  560|  7.25k|    memcpy(container->array, buf, container->cardinality * sizeof(uint16_t));
  561|  7.25k|#endif
  562|       |
  563|  7.25k|    return array_container_size_in_bytes(container);
  564|  7.25k|}
array_container_iterate:
  567|  6.58k|                             roaring_iterator iterator, void *ptr) {
  568|  2.18M|    for (int i = 0; i < cont->cardinality; i++)
  ------------------
  |  Branch (568:21): [True: 2.17M, False: 6.58k]
  ------------------
  569|  2.17M|        if (!iterator(cont->array[i] + base, ptr)) return false;
  ------------------
  |  Branch (569:13): [True: 0, False: 2.17M]
  ------------------
  570|  6.58k|    return true;
  571|  6.58k|}
array.c:clamp:
  162|   121k|static inline int32_t clamp(int32_t val, int32_t min, int32_t max) {
  163|   121k|    return ((val < min) ? min : (val > max) ? max : val);
  ------------------
  |  Branch (163:13): [True: 27.0k, False: 94.6k]
  |  Branch (163:33): [True: 268, False: 94.4k]
  ------------------
  164|   121k|}
array.c:grow_capacity:
  155|   121k|static inline int32_t grow_capacity(int32_t capacity) {
  156|   121k|    return (capacity <= 0)   ? ARRAY_DEFAULT_INIT_SIZE
  ------------------
  |  Branch (156:12): [True: 26.3k, False: 95.3k]
  ------------------
  157|   121k|           : capacity < 64   ? capacity * 2
  ------------------
  |  Branch (157:14): [True: 69.1k, False: 26.2k]
  ------------------
  158|  95.3k|           : capacity < 1024 ? capacity * 3 / 2
  ------------------
  |  Branch (158:14): [True: 25.9k, False: 305]
  ------------------
  159|  26.2k|                             : capacity * 5 / 4;
  160|   121k|}
array.c:minimum_int32:
  280|  2.32k|static inline int32_t minimum_int32(int32_t a, int32_t b) {
  281|  2.32k|    return (a < b) ? a : b;
  ------------------
  |  Branch (281:12): [True: 1.02k, False: 1.30k]
  ------------------
  282|  2.32k|}

bitset_container_clear:
   51|   153k|void bitset_container_clear(bitset_container_t *bitset) {
   52|   153k|    memset(bitset->words, 0, sizeof(uint64_t) * BITSET_CONTAINER_SIZE_IN_WORDS);
   53|   153k|    bitset->cardinality = 0;
   54|   153k|}
bitset_container_set_all:
   56|    185|void bitset_container_set_all(bitset_container_t *bitset) {
   57|       |    memset(bitset->words, INT64_C(-1),
   58|    185|           sizeof(uint64_t) * BITSET_CONTAINER_SIZE_IN_WORDS);
   59|    185|    bitset->cardinality = (1 << 16);
   60|    185|}
bitset_container_create:
   63|   153k|bitset_container_t *bitset_container_create(void) {
   64|   153k|    bitset_container_t *bitset =
   65|   153k|        (bitset_container_t *)roaring_malloc(sizeof(bitset_container_t));
   66|       |
   67|   153k|    if (!bitset) {
  ------------------
  |  Branch (67:9): [True: 0, False: 153k]
  ------------------
   68|      0|        return NULL;
   69|      0|    }
   70|       |
   71|   153k|    size_t align_size = 32;
   72|   153k|#if CROARING_IS_X64
   73|   153k|    int support = croaring_hardware_support();
   74|   153k|    if (support & ROARING_SUPPORTS_AVX512) {
  ------------------
  |  Branch (74:9): [True: 0, False: 153k]
  ------------------
   75|       |        // sizeof(__m512i) == 64
   76|      0|        align_size = 64;
   77|   153k|    } else {
   78|       |        // sizeof(__m256i) == 32
   79|   153k|        align_size = 32;
   80|   153k|    }
   81|   153k|#endif
   82|   153k|    bitset->words = (uint64_t *)roaring_aligned_malloc(
   83|   153k|        align_size, sizeof(uint64_t) * BITSET_CONTAINER_SIZE_IN_WORDS);
   84|   153k|    if (!bitset->words) {
  ------------------
  |  Branch (84:9): [True: 0, False: 153k]
  ------------------
   85|      0|        roaring_free(bitset);
   86|      0|        return NULL;
   87|      0|    }
   88|   153k|    bitset_container_clear(bitset);
   89|   153k|    return bitset;
   90|   153k|}
bitset_container_copy:
   94|  4.03k|                           bitset_container_t *dest) {
   95|  4.03k|    dest->cardinality = source->cardinality;
   96|  4.03k|    memcpy(dest->words, source->words,
   97|  4.03k|           sizeof(uint64_t) * BITSET_CONTAINER_SIZE_IN_WORDS);
   98|  4.03k|}
bitset_container_free:
  129|   302k|void bitset_container_free(bitset_container_t *bitset) {
  130|   302k|    if (bitset == NULL) return;
  ------------------
  |  Branch (130:9): [True: 0, False: 302k]
  ------------------
  131|   302k|    roaring_aligned_free(bitset->words);
  132|   302k|    roaring_free(bitset);
  133|   302k|}
bitset_container_clone:
  137|   148k|bitset_container_t *bitset_container_clone(const bitset_container_t *src) {
  138|   148k|    bitset_container_t *bitset =
  139|   148k|        (bitset_container_t *)roaring_malloc(sizeof(bitset_container_t));
  140|       |
  141|   148k|    if (!bitset) {
  ------------------
  |  Branch (141:9): [True: 0, False: 148k]
  ------------------
  142|      0|        return NULL;
  143|      0|    }
  144|       |
  145|   148k|    size_t align_size = 32;
  146|   148k|#if CROARING_IS_X64
  147|   148k|    if (croaring_hardware_support() & ROARING_SUPPORTS_AVX512) {
  ------------------
  |  Branch (147:9): [True: 0, False: 148k]
  ------------------
  148|       |        // sizeof(__m512i) == 64
  149|      0|        align_size = 64;
  150|   148k|    } else {
  151|       |        // sizeof(__m256i) == 32
  152|   148k|        align_size = 32;
  153|   148k|    }
  154|   148k|#endif
  155|   148k|    bitset->words = (uint64_t *)roaring_aligned_malloc(
  156|   148k|        align_size, sizeof(uint64_t) * BITSET_CONTAINER_SIZE_IN_WORDS);
  157|   148k|    if (!bitset->words) {
  ------------------
  |  Branch (157:9): [True: 0, False: 148k]
  ------------------
  158|      0|        roaring_free(bitset);
  159|      0|        return NULL;
  160|      0|    }
  161|   148k|    bitset->cardinality = src->cardinality;
  162|   148k|    memcpy(bitset->words, src->words,
  163|   148k|           sizeof(uint64_t) * BITSET_CONTAINER_SIZE_IN_WORDS);
  164|   148k|    return bitset;
  165|   148k|}
bitset_container_compute_cardinality:
  269|  3.60k|int bitset_container_compute_cardinality(const bitset_container_t *bitset) {
  270|  3.60k|    int support = croaring_hardware_support();
  271|  3.60k|#if CROARING_COMPILER_SUPPORTS_AVX512
  272|  3.60k|    if (support & ROARING_SUPPORTS_AVX512) {
  ------------------
  |  Branch (272:9): [True: 0, False: 3.60k]
  ------------------
  273|      0|        return (int)avx512_vpopcount(
  274|      0|            (const __m512i *)bitset->words,
  275|      0|            BITSET_CONTAINER_SIZE_IN_WORDS / (WORDS_IN_AVX512_REG));
  ------------------
  |  |  253|      0|#define WORDS_IN_AVX512_REG sizeof(__m512i) / sizeof(uint64_t)
  ------------------
  276|      0|    } else
  277|  3.60k|#endif  // CROARING_COMPILER_SUPPORTS_AVX512
  278|  3.60k|        if (support & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (278:13): [True: 3.60k, False: 0]
  ------------------
  279|  3.60k|            return (int)avx2_harley_seal_popcount256(
  280|  3.60k|                (const __m256i *)bitset->words,
  281|  3.60k|                BITSET_CONTAINER_SIZE_IN_WORDS / (CROARING_WORDS_IN_AVX2_REG));
  ------------------
  |  |  250|  3.60k|#define CROARING_WORDS_IN_AVX2_REG sizeof(__m256i) / sizeof(uint64_t)
  ------------------
  282|  3.60k|        } else {
  283|      0|            return _scalar_bitset_container_compute_cardinality(bitset);
  284|      0|        }
  285|  3.60k|}
bitset_container_and_nocard:
  724|  1.51k|                                         bitset_container_t *dst) {            \
  725|  1.51k|    int support = croaring_hardware_support();                                 \
  726|  1.51k|    if ( support & ROARING_SUPPORTS_AVX512 ) {                                 \
  ------------------
  |  Branch (726:10): [True: 0, False: 1.51k]
  ------------------
  727|      0|      return _avx512_bitset_container_##opname##_nocard(src_1, src_2, dst);    \
  728|      0|    }                                                                          \
  729|  1.51k|    else if ( support & ROARING_SUPPORTS_AVX2 ) {                              \
  ------------------
  |  Branch (729:15): [True: 1.51k, False: 0]
  ------------------
  730|  1.51k|      return _avx2_bitset_container_##opname##_nocard(src_1, src_2, dst);      \
  731|  1.51k|    } else {                                                                   \
  732|      0|      return _scalar_bitset_container_##opname##_nocard(src_1, src_2, dst);    \
  733|      0|    }                                                                          \
  734|  1.51k|  }                                                                            \
bitset_container_and_justcard:
  736|  1.51k|                                           const bitset_container_t *src_2) {  \
  737|  1.51k|     int support = croaring_hardware_support();                                \
  738|  1.51k|    if ( support & ROARING_SUPPORTS_AVX512 ) {                                 \
  ------------------
  |  Branch (738:10): [True: 0, False: 1.51k]
  ------------------
  739|      0|      return _avx512_bitset_container_##opname##_justcard(src_1, src_2);       \
  740|      0|    }                                                                          \
  741|  1.51k|    else if ( support & ROARING_SUPPORTS_AVX2 ) {                              \
  ------------------
  |  Branch (741:15): [True: 1.51k, False: 0]
  ------------------
  742|  1.51k|      return _avx2_bitset_container_##opname##_justcard(src_1, src_2);         \
  743|  1.51k|    } else {                                                                   \
  744|      0|      return _scalar_bitset_container_##opname##_justcard(src_1, src_2);       \
  745|      0|    }                                                                          \
  746|  1.51k|  }
bitset_container_xor:
  711|  1.57k|                                bitset_container_t *dst) {                     \
  712|  1.57k|    int support = croaring_hardware_support();                                 \
  713|  1.57k|    if ( support & ROARING_SUPPORTS_AVX512 ) {                                 \
  ------------------
  |  Branch (713:10): [True: 0, False: 1.57k]
  ------------------
  714|      0|      return _avx512_bitset_container_##opname(src_1, src_2, dst);             \
  715|      0|    }                                                                          \
  716|  1.57k|    else if ( support & ROARING_SUPPORTS_AVX2 ) {                              \
  ------------------
  |  Branch (716:15): [True: 1.57k, False: 0]
  ------------------
  717|  1.57k|      return _avx2_bitset_container_##opname(src_1, src_2, dst);               \
  718|  1.57k|    } else {                                                                   \
  719|      0|      return _scalar_bitset_container_##opname(src_1, src_2, dst);             \
  720|      0|    }                                                                          \
  721|  1.57k|  }                                                                            \
bitset_container_to_uint32_array:
  936|  1.51k|){
  937|  1.51k|#if CROARING_IS_X64
  938|  1.51k|   int support = croaring_hardware_support();
  939|  1.51k|#if CROARING_COMPILER_SUPPORTS_AVX512
  940|  1.51k|   if(( support & ROARING_SUPPORTS_AVX512 ) &&  (bc->cardinality >= 8192))  // heuristic
  ------------------
  |  Branch (940:7): [True: 0, False: 1.51k]
  |  Branch (940:49): [True: 0, False: 0]
  ------------------
  941|      0|		return (int) bitset_extract_setbits_avx512(bc->words,
  942|      0|                BITSET_CONTAINER_SIZE_IN_WORDS, out, bc->cardinality, base);
  943|  1.51k|   else
  944|  1.51k|#endif
  945|  1.51k|   if(( support & ROARING_SUPPORTS_AVX2 ) &&  (bc->cardinality >= 8192))  // heuristic
  ------------------
  |  Branch (945:7): [True: 1.51k, False: 0]
  |  Branch (945:47): [True: 1.03k, False: 480]
  ------------------
  946|  1.03k|		return (int) bitset_extract_setbits_avx2(bc->words,
  947|  1.03k|                BITSET_CONTAINER_SIZE_IN_WORDS, out, bc->cardinality, base);
  948|    480|	else
  949|    480|		return (int) bitset_extract_setbits(bc->words,
  950|    480|                BITSET_CONTAINER_SIZE_IN_WORDS, out, base);
  951|       |#else
  952|       |	return (int) bitset_extract_setbits(bc->words,
  953|       |                BITSET_CONTAINER_SIZE_IN_WORDS, out, base);
  954|       |#endif
  955|  1.51k|}
bitset_container_write:
 1050|  73.9k|                                  char *buf) {
 1051|       |#if CROARING_IS_BIG_ENDIAN
 1052|       |	for (int32_t i = 0; i < BITSET_CONTAINER_SIZE_IN_WORDS; ++i) {
 1053|       |		uint64_t w_le = croaring_htole64(container->words[i]);
 1054|       |		memcpy(buf + i * sizeof(uint64_t), &w_le, sizeof(uint64_t));
 1055|       |	}
 1056|       |#else
 1057|  73.9k|	memcpy(buf, container->words, BITSET_CONTAINER_SIZE_IN_WORDS * sizeof(uint64_t));
 1058|  73.9k|#endif
 1059|  73.9k|	return bitset_container_size_in_bytes(container);
 1060|  73.9k|}
bitset_container_read:
 1064|  73.9k|		const char *buf)  {
 1065|  73.9k|	container->cardinality = cardinality;
 1066|       |#if CROARING_IS_BIG_ENDIAN
 1067|       |	for (int32_t i = 0; i < BITSET_CONTAINER_SIZE_IN_WORDS; ++i) {
 1068|       |		uint64_t w_le;
 1069|       |		memcpy(&w_le, buf + i * sizeof(uint64_t), sizeof(uint64_t));
 1070|       |		container->words[i] = croaring_letoh64(w_le);
 1071|       |	}
 1072|       |#else
 1073|  73.9k|	memcpy(container->words, buf, BITSET_CONTAINER_SIZE_IN_WORDS * sizeof(uint64_t));
 1074|  73.9k|#endif
 1075|  73.9k|	return bitset_container_size_in_bytes(container);
 1076|  73.9k|}
bitset_container_iterate:
 1078|  1.69k|bool bitset_container_iterate(const bitset_container_t *cont, uint32_t base, roaring_iterator iterator, void *ptr) {
 1079|  1.73M|  for (int32_t i = 0; i < BITSET_CONTAINER_SIZE_IN_WORDS; ++i ) {
  ------------------
  |  Branch (1079:23): [True: 1.73M, False: 1.69k]
  ------------------
 1080|  1.73M|    uint64_t w = cont->words[i];
 1081|  65.3M|    while (w != 0) {
  ------------------
  |  Branch (1081:12): [True: 63.5M, False: 1.73M]
  ------------------
 1082|  63.5M|      uint64_t t = w & (~w + 1);
 1083|  63.5M|      int r = roaring_trailing_zeroes(w);
 1084|  63.5M|      if(!iterator(r + base, ptr)) return false;
  ------------------
  |  Branch (1084:10): [True: 0, False: 63.5M]
  ------------------
 1085|  63.5M|      w ^= t;
 1086|  63.5M|    }
 1087|  1.73M|    base += 64;
 1088|  1.73M|  }
 1089|  1.69k|  return true;
 1090|  1.69k|}
bitset_container_equals:
 1144|  73.9k|bool bitset_container_equals(const bitset_container_t *container1, const bitset_container_t *container2) {
 1145|  73.9k|  if((container1->cardinality != BITSET_UNKNOWN_CARDINALITY) && (container2->cardinality != BITSET_UNKNOWN_CARDINALITY)) {
  ------------------
  |  Branch (1145:6): [True: 73.9k, False: 0]
  |  Branch (1145:65): [True: 73.9k, False: 0]
  ------------------
 1146|  73.9k|    if(container1->cardinality != container2->cardinality) {
  ------------------
  |  Branch (1146:8): [True: 0, False: 73.9k]
  ------------------
 1147|      0|      return false;
 1148|      0|    }
 1149|  73.9k|    if (container1->cardinality == INT32_C(0x10000)) {
  ------------------
  |  Branch (1149:9): [True: 69.9k, False: 4.07k]
  ------------------
 1150|  69.9k|      return true;
 1151|  69.9k|    }
 1152|  73.9k|  }
 1153|  4.07k|#if CROARING_IS_X64
 1154|  4.07k|  int support = croaring_hardware_support();
 1155|  4.07k|#if CROARING_COMPILER_SUPPORTS_AVX512
 1156|  4.07k|  if( support & ROARING_SUPPORTS_AVX512 ) {
  ------------------
  |  Branch (1156:7): [True: 0, False: 4.07k]
  ------------------
 1157|      0|    return _avx512_bitset_container_equals(container1, container2);
 1158|      0|  }
 1159|  4.07k|  else
 1160|  4.07k|#endif
 1161|  4.07k|  if( support & ROARING_SUPPORTS_AVX2 ) {
  ------------------
  |  Branch (1161:7): [True: 4.07k, False: 0]
  ------------------
 1162|  4.07k|    return _avx2_bitset_container_equals(container1, container2);
 1163|  4.07k|  }
 1164|      0|#endif
 1165|      0|  return memcmp(container1->words,
 1166|      0|                container2->words,
 1167|      0|                BITSET_CONTAINER_SIZE_IN_WORDS*sizeof(uint64_t)) == 0;
 1168|  4.07k|}
bitset_container_minimum:
 1218|  1.27k|uint16_t bitset_container_minimum(const bitset_container_t *container) {
 1219|  13.5k|  for (int32_t i = 0; i < BITSET_CONTAINER_SIZE_IN_WORDS; ++i ) {
  ------------------
  |  Branch (1219:23): [True: 13.5k, False: 0]
  ------------------
 1220|  13.5k|    uint64_t w = container->words[i];
 1221|  13.5k|    if (w != 0) {
  ------------------
  |  Branch (1221:9): [True: 1.27k, False: 12.2k]
  ------------------
 1222|  1.27k|      int r = roaring_trailing_zeroes(w);
 1223|  1.27k|      return r + i * 64;
 1224|  1.27k|    }
 1225|  13.5k|  }
 1226|      0|  return UINT16_MAX;
 1227|  1.27k|}
bitset_container_maximum:
 1230|  4.49k|uint16_t bitset_container_maximum(const bitset_container_t *container) {
 1231|  1.12M|  for (int32_t i = BITSET_CONTAINER_SIZE_IN_WORDS - 1; i > 0; --i ) {
  ------------------
  |  Branch (1231:56): [True: 1.12M, False: 0]
  ------------------
 1232|  1.12M|    uint64_t w = container->words[i];
 1233|  1.12M|    if (w != 0) {
  ------------------
  |  Branch (1233:9): [True: 4.49k, False: 1.12M]
  ------------------
 1234|  4.49k|      int r = roaring_leading_zeroes(w);
 1235|  4.49k|      return i * 64 + 63  - r;
 1236|  4.49k|    }
 1237|  1.12M|  }
 1238|      0|  return 0;
 1239|  4.49k|}
bitset_container_index_equalorlarger:
 1299|  1.91k|int bitset_container_index_equalorlarger(const bitset_container_t *container, uint16_t x) {
 1300|  1.91k|  uint32_t x32 = x;
 1301|  1.91k|  uint32_t k = x32 / 64;
 1302|  1.91k|  uint64_t word = container->words[k];
 1303|  1.91k|  const int diff = x32 - k * 64; // in [0,64)
 1304|  1.91k|  word = (word >> diff) << diff; // a mask is faster, but we don't care
 1305|  5.42k|  while(word == 0) {
  ------------------
  |  Branch (1305:9): [True: 3.51k, False: 1.91k]
  ------------------
 1306|  3.51k|    k++;
 1307|  3.51k|    if(k == BITSET_CONTAINER_SIZE_IN_WORDS) return -1;
  ------------------
  |  Branch (1307:8): [True: 0, False: 3.51k]
  ------------------
 1308|  3.51k|    word = container->words[k];
 1309|  3.51k|  }
 1310|  1.91k|  return k * 64 + roaring_trailing_zeroes(word);
 1311|  1.91k|}
bitset.c:_avx2_bitset_container_and_nocard:
  503|  1.51k|      bitset_container_t *dst) {                                               \
  504|  1.51k|    const uint8_t *__restrict__ words_1 = (const uint8_t *)src_1->words;       \
  505|  1.51k|    const uint8_t *__restrict__ words_2 = (const uint8_t *)src_2->words;       \
  506|  1.51k|    /* not using the blocking optimization for some reason*/                   \
  507|  1.51k|    uint8_t *out = (uint8_t *)dst->words;                                      \
  508|  1.51k|    const int innerloop = 8;                                                   \
  509|  1.51k|    for (size_t i = 0;                                                         \
  510|  50.0k|         i < BITSET_CONTAINER_SIZE_IN_WORDS / (CROARING_WORDS_IN_AVX2_REG);             \
  ------------------
  |  |  250|  50.0k|#define CROARING_WORDS_IN_AVX2_REG sizeof(__m256i) / sizeof(uint64_t)
  ------------------
  |  Branch (510:10): [True: 48.5k, False: 1.51k]
  ------------------
  511|  48.5k|         i += innerloop) {                                                     \
  512|  48.5k|      __m256i A1, A2, AO;                                                      \
  513|  48.5k|      A1 = _mm256_lddqu_si256((const __m256i *)(words_1));                     \
  514|  48.5k|      A2 = _mm256_lddqu_si256((const __m256i *)(words_2));                     \
  515|  48.5k|      AO = avx_intrinsic(A2, A1);                                              \
  516|  48.5k|      _mm256_storeu_si256((__m256i *)out, AO);                                 \
  517|  48.5k|      A1 = _mm256_lddqu_si256((const __m256i *)(words_1 + 32));                \
  518|  48.5k|      A2 = _mm256_lddqu_si256((const __m256i *)(words_2 + 32));                \
  519|  48.5k|      AO = avx_intrinsic(A2, A1);                                              \
  520|  48.5k|      _mm256_storeu_si256((__m256i *)(out + 32), AO);                          \
  521|  48.5k|      A1 = _mm256_lddqu_si256((const __m256i *)(words_1 + 64));                \
  522|  48.5k|      A2 = _mm256_lddqu_si256((const __m256i *)(words_2 + 64));                \
  523|  48.5k|      AO = avx_intrinsic(A2, A1);                                              \
  524|  48.5k|      _mm256_storeu_si256((__m256i *)(out + 64), AO);                          \
  525|  48.5k|      A1 = _mm256_lddqu_si256((const __m256i *)(words_1 + 96));                \
  526|  48.5k|      A2 = _mm256_lddqu_si256((const __m256i *)(words_2 + 96));                \
  527|  48.5k|      AO = avx_intrinsic(A2, A1);                                              \
  528|  48.5k|      _mm256_storeu_si256((__m256i *)(out + 96), AO);                          \
  529|  48.5k|      A1 = _mm256_lddqu_si256((const __m256i *)(words_1 + 128));               \
  530|  48.5k|      A2 = _mm256_lddqu_si256((const __m256i *)(words_2 + 128));               \
  531|  48.5k|      AO = avx_intrinsic(A2, A1);                                              \
  532|  48.5k|      _mm256_storeu_si256((__m256i *)(out + 128), AO);                         \
  533|  48.5k|      A1 = _mm256_lddqu_si256((const __m256i *)(words_1 + 160));               \
  534|  48.5k|      A2 = _mm256_lddqu_si256((const __m256i *)(words_2 + 160));               \
  535|  48.5k|      AO = avx_intrinsic(A2, A1);                                              \
  536|  48.5k|      _mm256_storeu_si256((__m256i *)(out + 160), AO);                         \
  537|  48.5k|      A1 = _mm256_lddqu_si256((const __m256i *)(words_1 + 192));               \
  538|  48.5k|      A2 = _mm256_lddqu_si256((const __m256i *)(words_2 + 192));               \
  539|  48.5k|      AO = avx_intrinsic(A2, A1);                                              \
  540|  48.5k|      _mm256_storeu_si256((__m256i *)(out + 192), AO);                         \
  541|  48.5k|      A1 = _mm256_lddqu_si256((const __m256i *)(words_1 + 224));               \
  542|  48.5k|      A2 = _mm256_lddqu_si256((const __m256i *)(words_2 + 224));               \
  543|  48.5k|      AO = avx_intrinsic(A2, A1);                                              \
  544|  48.5k|      _mm256_storeu_si256((__m256i *)(out + 224), AO);                         \
  545|  48.5k|      out += 256;                                                              \
  546|  48.5k|      words_1 += 256;                                                          \
  547|  48.5k|      words_2 += 256;                                                          \
  548|  48.5k|    }                                                                          \
  549|  1.51k|    dst->cardinality = BITSET_UNKNOWN_CARDINALITY;                             \
  550|  1.51k|    return dst->cardinality;                                                   \
  551|  1.51k|  }
bitset.c:_avx2_bitset_container_and_justcard:
  572|  1.51k|      const bitset_container_t *src_1, const bitset_container_t *src_2) {      \
  573|  1.51k|    const __m256i *__restrict__ data1 = (const __m256i *)src_1->words;         \
  574|  1.51k|    const __m256i *__restrict__ data2 = (const __m256i *)src_2->words;         \
  575|  1.51k|    return (int)avx2_harley_seal_popcount256_##opname(                         \
  576|  1.51k|        data2, data1, BITSET_CONTAINER_SIZE_IN_WORDS / (CROARING_WORDS_IN_AVX2_REG));   \
  ------------------
  |  |  250|  1.51k|#define CROARING_WORDS_IN_AVX2_REG sizeof(__m256i) / sizeof(uint64_t)
  ------------------
  577|  1.51k|  }
bitset.c:_avx2_bitset_container_xor:
  558|  1.57k|                                      bitset_container_t *dst) {               \
  559|  1.57k|    const __m256i *__restrict__ words_1 = (const __m256i *)src_1->words;       \
  560|  1.57k|    const __m256i *__restrict__ words_2 = (const __m256i *)src_2->words;       \
  561|  1.57k|    __m256i *out = (__m256i *)dst->words;                                      \
  562|  1.57k|    dst->cardinality = (int32_t)avx2_harley_seal_popcount256andstore_##opname( \
  563|  1.57k|        words_2, words_1, out,                                                 \
  564|  1.57k|        BITSET_CONTAINER_SIZE_IN_WORDS / (CROARING_WORDS_IN_AVX2_REG));                 \
  ------------------
  |  |  250|  1.57k|#define CROARING_WORDS_IN_AVX2_REG sizeof(__m256i) / sizeof(uint64_t)
  ------------------
  565|  1.57k|    return dst->cardinality;                                                   \
  566|  1.57k|  }                                                                            \
bitset.c:_avx2_bitset_container_equals:
 1127|  4.07k|static inline bool _avx2_bitset_container_equals(const bitset_container_t *container1, const bitset_container_t *container2) {
 1128|  4.07k|    const __m256i *ptr1 = (const __m256i*)container1->words;
 1129|  4.07k|    const __m256i *ptr2 = (const __m256i*)container2->words;
 1130|  1.04M|    for (size_t i = 0; i < BITSET_CONTAINER_SIZE_IN_WORDS*sizeof(uint64_t)/32; i++) {
  ------------------
  |  Branch (1130:24): [True: 1.04M, False: 4.07k]
  ------------------
 1131|  1.04M|      __m256i r1 = _mm256_loadu_si256(ptr1+i);
 1132|  1.04M|      __m256i r2 = _mm256_loadu_si256(ptr2+i);
 1133|  1.04M|      int mask = _mm256_movemask_epi8(_mm256_cmpeq_epi8(r1, r2));
 1134|  1.04M|      if ((uint32_t)mask != UINT32_MAX) {
  ------------------
  |  Branch (1134:11): [True: 0, False: 1.04M]
  ------------------
 1135|      0|          return false;
 1136|      0|      }
 1137|  1.04M|  }
 1138|  4.07k|	return true;
 1139|  4.07k|}

container_free:
   58|   637k|void container_free(container_t *c, uint8_t type) {
   59|   637k|    switch (type) {
   60|   299k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|   299k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (60:9): [True: 299k, False: 338k]
  ------------------
   61|   299k|            bitset_container_free(CAST_bitset(c));
  ------------------
  |  |   52|   299k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|   299k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
   62|   299k|            break;
   63|   136k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|   136k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (63:9): [True: 136k, False: 501k]
  ------------------
   64|   136k|            array_container_free(CAST_array(c));
  ------------------
  |  |   54|   136k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|   136k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
   65|   136k|            break;
   66|   202k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|   202k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (66:9): [True: 202k, False: 435k]
  ------------------
   67|   202k|            run_container_free(CAST_run(c));
  ------------------
  |  |   77|   202k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|   202k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
   68|   202k|            break;
   69|      0|        case SHARED_CONTAINER_TYPE:
  ------------------
  |  |   51|      0|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (69:9): [True: 0, False: 637k]
  ------------------
   70|      0|            shared_container_free(CAST_shared(c));
  ------------------
  |  |   79|      0|#define CAST_shared(c) CAST(shared_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
   71|      0|            break;
   72|      0|        default:
  ------------------
  |  Branch (72:9): [True: 0, False: 637k]
  ------------------
   73|      0|            assert(false);
   74|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
   75|   637k|    }
   76|   637k|}
get_copy_of_container:
  181|    259|                                   bool copy_on_write) {
  182|    259|    if (copy_on_write) {
  ------------------
  |  Branch (182:9): [True: 0, False: 259]
  ------------------
  183|      0|        shared_container_t *shared_container;
  184|      0|        if (*typecode == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|      0|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (184:13): [True: 0, False: 0]
  ------------------
  185|      0|            shared_container = CAST_shared(c);
  ------------------
  |  |   79|      0|#define CAST_shared(c) CAST(shared_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  186|      0|            croaring_refcount_inc(&shared_container->counter);
  187|      0|            return shared_container;
  188|      0|        }
  189|      0|        assert(*typecode != SHARED_CONTAINER_TYPE);
  190|       |
  191|      0|        if ((shared_container = (shared_container_t *)roaring_malloc(
  ------------------
  |  Branch (191:13): [True: 0, False: 0]
  ------------------
  192|      0|                 sizeof(shared_container_t))) == NULL) {
  193|      0|            return NULL;
  194|      0|        }
  195|       |
  196|      0|        shared_container->container = c;
  197|      0|        shared_container->typecode = *typecode;
  198|       |        // At this point, we are creating new shared container
  199|       |        // so there should be no other references, and setting
  200|       |        // the counter to 2 - even non-atomically - is safe as
  201|       |        // long as the value is set before the return statement.
  202|      0|        shared_container->counter = 2;
  203|      0|        *typecode = SHARED_CONTAINER_TYPE;
  ------------------
  |  |   51|      0|#define SHARED_CONTAINER_TYPE 4
  ------------------
  204|       |
  205|      0|        return shared_container;
  206|      0|    }  // copy_on_write
  207|       |    // otherwise, no copy on write...
  208|    259|    const container_t *actual_container = container_unwrap_shared(c, typecode);
  209|       |    assert(*typecode != SHARED_CONTAINER_TYPE);
  210|    259|    return container_clone(actual_container, *typecode);
  211|    259|}
container_clone:
  217|   353k|container_t *container_clone(const container_t *c, uint8_t typecode) {
  218|       |    // We do not want to allow cloning of shared containers.
  219|       |    // c = container_unwrap_shared(c, &typecode);
  220|   353k|    switch (typecode) {
  221|   148k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|   148k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (221:9): [True: 148k, False: 204k]
  ------------------
  222|   148k|            return bitset_container_clone(const_CAST_bitset(c));
  ------------------
  |  |   53|   148k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|   148k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  223|  23.2k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  23.2k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (223:9): [True: 23.2k, False: 329k]
  ------------------
  224|  23.2k|            return array_container_clone(const_CAST_array(c));
  ------------------
  |  |   55|  23.2k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  23.2k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  225|   181k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|   181k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (225:9): [True: 181k, False: 172k]
  ------------------
  226|   181k|            return run_container_clone(const_CAST_run(c));
  ------------------
  |  |   78|   181k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|   181k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  227|      0|        case SHARED_CONTAINER_TYPE:
  ------------------
  |  |   51|      0|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (227:9): [True: 0, False: 353k]
  ------------------
  228|       |            // Shared containers are not cloneable. Are you mixing COW and
  229|       |            // non-COW bitmaps?
  230|      0|            return NULL;
  231|      0|        default:
  ------------------
  |  Branch (231:9): [True: 0, False: 353k]
  ------------------
  232|      0|            assert(false);
  233|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  234|      0|            return NULL;
  235|   353k|    }
  236|   353k|}
container_init_iterator:
  304|  19.1k|                                                     uint16_t *value) {
  305|  19.1k|    switch (typecode) {
  306|  3.87k|        case BITSET_CONTAINER_TYPE: {
  ------------------
  |  |   48|  3.87k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (306:9): [True: 3.87k, False: 15.2k]
  ------------------
  307|  3.87k|            const bitset_container_t *bc = const_CAST_bitset(c);
  ------------------
  |  |   53|  3.87k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.87k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  308|  3.87k|            uint32_t wordindex = 0;
  309|  3.87k|            uint64_t word;
  310|  20.8k|            while ((word = bc->words[wordindex]) == 0) {
  ------------------
  |  Branch (310:20): [True: 17.0k, False: 3.87k]
  ------------------
  311|  17.0k|                wordindex++;
  312|  17.0k|            }
  313|       |            // word is non-zero
  314|  3.87k|            int32_t index = wordindex * 64 + roaring_trailing_zeroes(word);
  315|  3.87k|            *value = index;
  316|  3.87k|            return ROARING_INIT_ROARING_CONTAINER_ITERATOR_T{
  ------------------
  |  |   13|  3.87k|#define ROARING_INIT_ROARING_CONTAINER_ITERATOR_T (roaring_container_iterator_t)
  ------------------
  317|  3.87k|                .index = index,
  318|  3.87k|            };
  319|      0|        }
  320|  14.7k|        case ARRAY_CONTAINER_TYPE: {
  ------------------
  |  |   49|  14.7k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (320:9): [True: 14.7k, False: 4.37k]
  ------------------
  321|  14.7k|            const array_container_t *ac = const_CAST_array(c);
  ------------------
  |  |   55|  14.7k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  14.7k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  322|  14.7k|            *value = ac->array[0];
  323|  14.7k|            return ROARING_INIT_ROARING_CONTAINER_ITERATOR_T{
  ------------------
  |  |   13|  14.7k|#define ROARING_INIT_ROARING_CONTAINER_ITERATOR_T (roaring_container_iterator_t)
  ------------------
  324|  14.7k|                .index = 0,
  325|  14.7k|            };
  326|      0|        }
  327|    503|        case RUN_CONTAINER_TYPE: {
  ------------------
  |  |   50|    503|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (327:9): [True: 503, False: 18.6k]
  ------------------
  328|    503|            const run_container_t *rc = const_CAST_run(c);
  ------------------
  |  |   78|    503|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    503|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  329|    503|            *value = rc->runs[0].value;
  330|    503|            return ROARING_INIT_ROARING_CONTAINER_ITERATOR_T{
  ------------------
  |  |   13|    503|#define ROARING_INIT_ROARING_CONTAINER_ITERATOR_T (roaring_container_iterator_t)
  ------------------
  331|    503|                .index = 0,
  332|    503|            };
  333|      0|        }
  334|      0|        default:
  ------------------
  |  Branch (334:9): [True: 0, False: 19.1k]
  ------------------
  335|      0|            assert(false);
  336|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  337|      0|            return ROARING_INIT_ROARING_CONTAINER_ITERATOR_T{0};
  ------------------
  |  |   13|      0|#define ROARING_INIT_ROARING_CONTAINER_ITERATOR_T (roaring_container_iterator_t)
  ------------------
  338|  19.1k|    }
  339|  19.1k|}
container_iterator_lower_bound:
  386|  6.38k|                                    uint16_t *value_out, uint16_t val) {
  387|  6.38k|    if (val > container_maximum(c, typecode)) {
  ------------------
  |  Branch (387:9): [True: 0, False: 6.38k]
  ------------------
  388|      0|        return false;
  389|      0|    }
  390|  6.38k|    switch (typecode) {
  391|  1.91k|        case BITSET_CONTAINER_TYPE: {
  ------------------
  |  |   48|  1.91k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (391:9): [True: 1.91k, False: 4.46k]
  ------------------
  392|  1.91k|            const bitset_container_t *bc = const_CAST_bitset(c);
  ------------------
  |  |   53|  1.91k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.91k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  393|  1.91k|            it->index = bitset_container_index_equalorlarger(bc, val);
  394|  1.91k|            *value_out = it->index;
  395|  1.91k|            return true;
  396|      0|        }
  397|  4.46k|        case ARRAY_CONTAINER_TYPE: {
  ------------------
  |  |   49|  4.46k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (397:9): [True: 4.46k, False: 1.91k]
  ------------------
  398|  4.46k|            const array_container_t *ac = const_CAST_array(c);
  ------------------
  |  |   55|  4.46k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  4.46k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  399|  4.46k|            it->index = array_container_index_equalorlarger(ac, val);
  400|  4.46k|            *value_out = ac->array[it->index];
  401|  4.46k|            return true;
  402|      0|        }
  403|      0|        case RUN_CONTAINER_TYPE: {
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (403:9): [True: 0, False: 6.38k]
  ------------------
  404|      0|            const run_container_t *rc = const_CAST_run(c);
  ------------------
  |  |   78|      0|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  405|      0|            it->index = run_container_index_equalorlarger(rc, val);
  406|      0|            if (rc->runs[it->index].value <= val) {
  ------------------
  |  Branch (406:17): [True: 0, False: 0]
  ------------------
  407|      0|                *value_out = val;
  408|      0|            } else {
  409|      0|                *value_out = rc->runs[it->index].value;
  410|      0|            }
  411|      0|            return true;
  412|      0|        }
  413|      0|        default:
  ------------------
  |  Branch (413:9): [True: 0, False: 6.38k]
  ------------------
  414|      0|            assert(false);
  415|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  416|      0|            return false;
  417|  6.38k|    }
  418|  6.38k|}

bitset_container_from_array:
   22|  2.37k|bitset_container_t *bitset_container_from_array(const array_container_t *ac) {
   23|  2.37k|    bitset_container_t *ans = bitset_container_create();
   24|  2.37k|    int limit = array_container_cardinality(ac);
   25|  2.46M|    for (int i = 0; i < limit; ++i) bitset_container_set(ans, ac->array[i]);
  ------------------
  |  Branch (25:21): [True: 2.46M, False: 2.37k]
  ------------------
   26|  2.37k|    return ans;
   27|  2.37k|}
bitset_container_from_run:
   29|    612|bitset_container_t *bitset_container_from_run(const run_container_t *arr) {
   30|    612|    int card = run_container_cardinality(arr);
   31|    612|    bitset_container_t *answer = bitset_container_create();
   32|  20.7k|    for (int rlepos = 0; rlepos < arr->n_runs; ++rlepos) {
  ------------------
  |  Branch (32:26): [True: 20.1k, False: 612]
  ------------------
   33|  20.1k|        rle16_t vl = arr->runs[rlepos];
   34|  20.1k|        bitset_set_lenrange(answer->words, vl.value, vl.length);
   35|  20.1k|    }
   36|    612|    answer->cardinality = card;
   37|    612|    return answer;
   38|    612|}
array_container_from_run:
   40|  1.18k|array_container_t *array_container_from_run(const run_container_t *arr) {
   41|  1.18k|    array_container_t *answer =
   42|  1.18k|        array_container_create_given_capacity(run_container_cardinality(arr));
   43|  1.18k|    answer->cardinality = 0;
   44|  88.1k|    for (int rlepos = 0; rlepos < arr->n_runs; ++rlepos) {
  ------------------
  |  Branch (44:26): [True: 86.9k, False: 1.18k]
  ------------------
   45|  86.9k|        int run_start = arr->runs[rlepos].value;
   46|  86.9k|        int run_end = run_start + arr->runs[rlepos].length;
   47|       |
   48|   450k|        for (int run_value = run_start; run_value <= run_end; ++run_value) {
  ------------------
  |  Branch (48:41): [True: 363k, False: 86.9k]
  ------------------
   49|   363k|            answer->array[answer->cardinality++] = (uint16_t)run_value;
   50|   363k|        }
   51|  86.9k|    }
   52|  1.18k|    return answer;
   53|  1.18k|}
array_container_from_bitset:
   55|  2.91k|array_container_t *array_container_from_bitset(const bitset_container_t *bits) {
   56|  2.91k|    array_container_t *result =
   57|  2.91k|        array_container_create_given_capacity(bits->cardinality);
   58|  2.91k|    result->cardinality = bits->cardinality;
   59|  2.91k|#if CROARING_IS_X64
   60|  2.91k|#if CROARING_COMPILER_SUPPORTS_AVX512
   61|  2.91k|    if (croaring_hardware_support() & ROARING_SUPPORTS_AVX512) {
  ------------------
  |  Branch (61:9): [True: 0, False: 2.91k]
  ------------------
   62|      0|        bitset_extract_setbits_avx512_uint16(
   63|      0|            bits->words, BITSET_CONTAINER_SIZE_IN_WORDS, result->array,
   64|      0|            bits->cardinality, 0);
   65|      0|    } else
   66|  2.91k|#endif
   67|  2.91k|    {
   68|       |        //  sse version ends up being slower here
   69|       |        // (bitset_extract_setbits_sse_uint16)
   70|       |        // because of the sparsity of the data
   71|  2.91k|        bitset_extract_setbits_uint16(
   72|  2.91k|            bits->words, BITSET_CONTAINER_SIZE_IN_WORDS, result->array, 0);
   73|  2.91k|    }
   74|       |#else
   75|       |    // If the system is not x64, then we have no accelerated function.
   76|       |    bitset_extract_setbits_uint16(bits->words, BITSET_CONTAINER_SIZE_IN_WORDS,
   77|       |                                  result->array, 0);
   78|       |#endif
   79|       |
   80|  2.91k|    return result;
   81|  2.91k|}
convert_to_bitset_or_array_container:
  120|  73.4k|                                                  uint8_t *resulttype) {
  121|  73.4k|    if (card <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (121:9): [True: 1.21k, False: 72.2k]
  ------------------
  122|  1.21k|        array_container_t *answer = array_container_create_given_capacity(card);
  123|  1.21k|        answer->cardinality = 0;
  124|  65.8k|        for (int rlepos = 0; rlepos < rc->n_runs; ++rlepos) {
  ------------------
  |  Branch (124:30): [True: 64.6k, False: 1.21k]
  ------------------
  125|  64.6k|            uint16_t run_start = rc->runs[rlepos].value;
  126|  64.6k|            uint16_t run_end = run_start + rc->runs[rlepos].length;
  127|   645k|            for (uint16_t run_value = run_start; run_value < run_end;
  ------------------
  |  Branch (127:50): [True: 580k, False: 64.6k]
  ------------------
  128|   580k|                 ++run_value) {
  129|   580k|                answer->array[answer->cardinality++] = run_value;
  130|   580k|            }
  131|  64.6k|            answer->array[answer->cardinality++] = run_end;
  132|  64.6k|        }
  133|  1.21k|        assert(card == answer->cardinality);
  134|  1.21k|        *resulttype = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  1.21k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  135|       |        // run_container_free(r);
  136|  1.21k|        return answer;
  137|  1.21k|    }
  138|  72.2k|    bitset_container_t *answer = bitset_container_create();
  139|   164k|    for (int rlepos = 0; rlepos < rc->n_runs; ++rlepos) {
  ------------------
  |  Branch (139:26): [True: 92.1k, False: 72.2k]
  ------------------
  140|  92.1k|        uint16_t run_start = rc->runs[rlepos].value;
  141|  92.1k|        bitset_set_lenrange(answer->words, run_start, rc->runs[rlepos].length);
  142|  92.1k|    }
  143|  72.2k|    answer->cardinality = card;
  144|  72.2k|    *resulttype = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|  72.2k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  145|       |    // run_container_free(r);
  146|  72.2k|    return answer;
  147|  73.4k|}
convert_run_to_efficient_container:
  155|   141k|                                                uint8_t *typecode_after) {
  156|   141k|    int32_t size_as_run_container =
  157|   141k|        run_container_serialized_size_in_bytes(c->n_runs);
  158|       |
  159|   141k|    int32_t size_as_bitset_container =
  160|   141k|        bitset_container_serialized_size_in_bytes();
  161|   141k|    int32_t card = run_container_cardinality(c);
  162|   141k|    int32_t size_as_array_container =
  163|   141k|        array_container_serialized_size_in_bytes(card);
  164|       |
  165|   141k|    int32_t min_size_non_run =
  166|   141k|        size_as_bitset_container < size_as_array_container
  ------------------
  |  Branch (166:9): [True: 63.4k, False: 77.8k]
  ------------------
  167|   141k|            ? size_as_bitset_container
  168|   141k|            : size_as_array_container;
  169|   141k|    if (size_as_run_container <= min_size_non_run) {  // no conversion
  ------------------
  |  Branch (169:9): [True: 71.8k, False: 69.4k]
  ------------------
  170|  71.8k|        *typecode_after = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|  71.8k|#define RUN_CONTAINER_TYPE 3
  ------------------
  171|  71.8k|        return c;
  172|  71.8k|    }
  173|  69.4k|    if (card <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (173:9): [True: 69.4k, False: 0]
  ------------------
  174|       |        // to array
  175|  69.4k|        array_container_t *answer = array_container_create_given_capacity(card);
  176|  69.4k|        answer->cardinality = 0;
  177|   212k|        for (int rlepos = 0; rlepos < c->n_runs; ++rlepos) {
  ------------------
  |  Branch (177:30): [True: 142k, False: 69.4k]
  ------------------
  178|   142k|            int run_start = c->runs[rlepos].value;
  179|   142k|            int run_end = run_start + c->runs[rlepos].length;
  180|       |
  181|   381k|            for (int run_value = run_start; run_value <= run_end; ++run_value) {
  ------------------
  |  Branch (181:45): [True: 238k, False: 142k]
  ------------------
  182|   238k|                answer->array[answer->cardinality++] = (uint16_t)run_value;
  183|   238k|            }
  184|   142k|        }
  185|  69.4k|        *typecode_after = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  69.4k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  186|  69.4k|        return answer;
  187|  69.4k|    }
  188|       |
  189|       |    // else to bitset
  190|      0|    bitset_container_t *answer = bitset_container_create();
  191|       |
  192|      0|    for (int rlepos = 0; rlepos < c->n_runs; ++rlepos) {
  ------------------
  |  Branch (192:26): [True: 0, False: 0]
  ------------------
  193|      0|        int start = c->runs[rlepos].value;
  194|      0|        int end = start + c->runs[rlepos].length;
  195|      0|        bitset_set_range(answer->words, start, end + 1);
  196|      0|    }
  197|      0|    answer->cardinality = card;
  198|      0|    *typecode_after = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  199|      0|    return answer;
  200|  69.4k|}
convert_run_to_efficient_container_and_free:
  204|   128k|    run_container_t *c, uint8_t *typecode_after) {
  205|   128k|    container_t *answer = convert_run_to_efficient_container(c, typecode_after);
  206|   128k|    if (answer != c) run_container_free(c);
  ------------------
  |  Branch (206:9): [True: 62.3k, False: 66.5k]
  ------------------
  207|   128k|    return answer;
  208|   128k|}
convert_run_optimize:
  218|  12.9k|                                  uint8_t *typecode_after) {
  219|  12.9k|    if (typecode_original == RUN_CONTAINER_TYPE) {
  ------------------
  |  |   50|  12.9k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (219:9): [True: 0, False: 12.9k]
  ------------------
  220|      0|        container_t *newc =
  221|      0|            convert_run_to_efficient_container(CAST_run(c), typecode_after);
  ------------------
  |  |   77|      0|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  222|      0|        if (newc != c) {
  ------------------
  |  Branch (222:13): [True: 0, False: 0]
  ------------------
  223|      0|            container_free(c, typecode_original);
  224|      0|        }
  225|      0|        return newc;
  226|  12.9k|    } else if (typecode_original == ARRAY_CONTAINER_TYPE) {
  ------------------
  |  |   49|  12.9k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (226:16): [True: 12.9k, False: 0]
  ------------------
  227|       |        // it might need to be converted to a run container.
  228|  12.9k|        array_container_t *c_qua_array = CAST_array(c);
  ------------------
  |  |   54|  12.9k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  12.9k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  229|  12.9k|        int32_t n_runs = array_container_number_of_runs(c_qua_array);
  230|  12.9k|        int32_t size_as_run_container =
  231|  12.9k|            run_container_serialized_size_in_bytes(n_runs);
  232|  12.9k|        int32_t card = array_container_cardinality(c_qua_array);
  233|  12.9k|        int32_t size_as_array_container =
  234|  12.9k|            array_container_serialized_size_in_bytes(card);
  235|       |
  236|  12.9k|        if (size_as_run_container >= size_as_array_container) {
  ------------------
  |  Branch (236:13): [True: 8.85k, False: 4.10k]
  ------------------
  237|  8.85k|            *typecode_after = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  8.85k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  238|  8.85k|            return c;
  239|  8.85k|        }
  240|       |        // else convert array to run container
  241|  4.10k|        run_container_t *answer = run_container_create_given_capacity(n_runs);
  242|  4.10k|        int prev = -2;
  243|  4.10k|        int run_start = -1;
  244|       |
  245|  4.10k|        assert(card > 0);
  246|   663k|        for (int i = 0; i < card; ++i) {
  ------------------
  |  Branch (246:25): [True: 659k, False: 4.10k]
  ------------------
  247|   659k|            uint16_t cur_val = c_qua_array->array[i];
  248|   659k|            if (cur_val != prev + 1) {
  ------------------
  |  Branch (248:17): [True: 269k, False: 389k]
  ------------------
  249|       |                // new run starts; flush old one, if any
  250|   269k|                if (run_start != -1) add_run(answer, run_start, prev);
  ------------------
  |  Branch (250:21): [True: 265k, False: 4.10k]
  ------------------
  251|   269k|                run_start = cur_val;
  252|   269k|            }
  253|   659k|            prev = c_qua_array->array[i];
  254|   659k|        }
  255|  4.10k|        assert(run_start >= 0);
  256|       |        // now prev is the last seen value
  257|  4.10k|        add_run(answer, run_start, prev);
  258|  4.10k|        *typecode_after = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|  4.10k|#define RUN_CONTAINER_TYPE 3
  ------------------
  259|  4.10k|        array_container_free(c_qua_array);
  260|  4.10k|        return answer;
  261|  12.9k|    } else if (typecode_original ==
  ------------------
  |  Branch (261:16): [True: 0, False: 0]
  ------------------
  262|      0|               BITSET_CONTAINER_TYPE) {  // run conversions on bitset
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  263|       |        // does bitset need conversion to run?
  264|      0|        bitset_container_t *c_qua_bitset = CAST_bitset(c);
  ------------------
  |  |   52|      0|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  265|      0|        int32_t n_runs = bitset_container_number_of_runs(c_qua_bitset);
  266|      0|        int32_t size_as_run_container =
  267|      0|            run_container_serialized_size_in_bytes(n_runs);
  268|      0|        int32_t size_as_bitset_container =
  269|      0|            bitset_container_serialized_size_in_bytes();
  270|       |
  271|      0|        if (size_as_bitset_container <= size_as_run_container) {
  ------------------
  |  Branch (271:13): [True: 0, False: 0]
  ------------------
  272|       |            // no conversion needed.
  273|      0|            *typecode_after = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  274|      0|            return c;
  275|      0|        }
  276|       |        // bitset to runcontainer (ported from Java  RunContainer(
  277|       |        // BitmapContainer bc, int nbrRuns))
  278|      0|        assert(n_runs > 0);  // no empty bitmaps
  279|      0|        run_container_t *answer = run_container_create_given_capacity(n_runs);
  280|       |
  281|      0|        int long_ctr = 0;
  282|      0|        uint64_t cur_word = c_qua_bitset->words[0];
  283|      0|        while (true) {
  ------------------
  |  Branch (283:16): [True: 0, Folded]
  ------------------
  284|      0|            while (cur_word == UINT64_C(0) &&
  ------------------
  |  Branch (284:20): [True: 0, False: 0]
  ------------------
  285|      0|                   long_ctr < BITSET_CONTAINER_SIZE_IN_WORDS - 1)
  ------------------
  |  Branch (285:20): [True: 0, False: 0]
  ------------------
  286|      0|                cur_word = c_qua_bitset->words[++long_ctr];
  287|       |
  288|      0|            if (cur_word == UINT64_C(0)) {
  ------------------
  |  Branch (288:17): [True: 0, False: 0]
  ------------------
  289|      0|                bitset_container_free(c_qua_bitset);
  290|      0|                *typecode_after = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
  291|      0|                return answer;
  292|      0|            }
  293|       |
  294|      0|            int local_run_start = roaring_trailing_zeroes(cur_word);
  295|      0|            int run_start = local_run_start + 64 * long_ctr;
  296|      0|            uint64_t cur_word_with_1s = cur_word | (cur_word - 1);
  297|       |
  298|      0|            int run_end = 0;
  299|      0|            while (cur_word_with_1s == UINT64_C(0xFFFFFFFFFFFFFFFF) &&
  ------------------
  |  Branch (299:20): [True: 0, False: 0]
  ------------------
  300|      0|                   long_ctr < BITSET_CONTAINER_SIZE_IN_WORDS - 1)
  ------------------
  |  Branch (300:20): [True: 0, False: 0]
  ------------------
  301|      0|                cur_word_with_1s = c_qua_bitset->words[++long_ctr];
  302|       |
  303|      0|            if (cur_word_with_1s == UINT64_C(0xFFFFFFFFFFFFFFFF)) {
  ------------------
  |  Branch (303:17): [True: 0, False: 0]
  ------------------
  304|      0|                run_end = 64 + long_ctr * 64;  // exclusive, I guess
  305|      0|                add_run(answer, run_start, run_end - 1);
  306|      0|                bitset_container_free(c_qua_bitset);
  307|      0|                *typecode_after = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
  308|      0|                return answer;
  309|      0|            }
  310|      0|            int local_run_end = roaring_trailing_zeroes(~cur_word_with_1s);
  311|      0|            run_end = local_run_end + long_ctr * 64;
  312|      0|            add_run(answer, run_start, run_end - 1);
  313|      0|            cur_word = cur_word_with_1s & (cur_word_with_1s + 1);
  314|      0|        }
  315|      0|        return answer;
  316|      0|    } else {
  317|      0|        assert(false);
  318|      0|        roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  319|      0|        return NULL;
  320|      0|    }
  321|  12.9k|}
convert.c:add_run:
   84|   269k|static void add_run(run_container_t *rc, int s, int e) {
   85|   269k|    rc->runs[rc->n_runs].value = s;
   86|   269k|    rc->runs[rc->n_runs].length = e - s;
   87|   269k|    rc->n_runs++;
   88|   269k|}

array_bitset_container_andnot:
   26|    575|                                   array_container_t *dst) {
   27|       |    // follows Java implementation as of June 2016
   28|    575|    if (dst->capacity < src_1->cardinality) {
  ------------------
  |  Branch (28:9): [True: 575, False: 0]
  ------------------
   29|    575|        array_container_grow(dst, src_1->cardinality, false);
   30|    575|    }
   31|    575|    int32_t newcard = 0;
   32|    575|    const int32_t origcard = src_1->cardinality;
   33|   102k|    for (int i = 0; i < origcard; ++i) {
  ------------------
  |  Branch (33:21): [True: 101k, False: 575]
  ------------------
   34|   101k|        uint16_t key = src_1->array[i];
   35|   101k|        dst->array[newcard] = key;
   36|   101k|        newcard += 1 - bitset_container_contains(src_2, key);
   37|   101k|    }
   38|    575|    dst->cardinality = newcard;
   39|    575|}
bitset_array_container_iandnot:
   83|  1.57k|                                    container_t **dst) {
   84|  1.57k|    *dst = src_1;
   85|  1.57k|    src_1->cardinality =
   86|  1.57k|        (int32_t)bitset_clear_list(src_1->words, (uint64_t)src_1->cardinality,
   87|  1.57k|                                   src_2->array, (uint64_t)src_2->cardinality);
   88|       |
   89|  1.57k|    if (src_1->cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (89:9): [True: 201, False: 1.36k]
  ------------------
   90|    201|        *dst = array_container_from_bitset(src_1);
   91|    201|        bitset_container_free(src_1);
   92|    201|        return false;  // not bitset
   93|    201|    } else
   94|  1.36k|        return true;
   95|  1.57k|}
run_bitset_container_andnot:
  106|    691|                                 container_t **dst) {
  107|       |    // follows the Java implementation as of June 2016
  108|    691|    int card = run_container_cardinality(src_1);
  109|    691|    if (card <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (109:9): [True: 691, False: 0]
  ------------------
  110|       |        // must be an array
  111|    691|        array_container_t *answer = array_container_create_given_capacity(card);
  112|    691|        answer->cardinality = 0;
  113|  57.0k|        for (int32_t rlepos = 0; rlepos < src_1->n_runs; ++rlepos) {
  ------------------
  |  Branch (113:34): [True: 56.3k, False: 691]
  ------------------
  114|  56.3k|            rle16_t rle = src_1->runs[rlepos];
  115|   202k|            for (int run_value = rle.value; run_value <= rle.value + rle.length;
  ------------------
  |  Branch (115:45): [True: 146k, False: 56.3k]
  ------------------
  116|   146k|                 ++run_value) {
  117|   146k|                if (!bitset_container_get(src_2, (uint16_t)run_value)) {
  ------------------
  |  Branch (117:21): [True: 42.8k, False: 103k]
  ------------------
  118|  42.8k|                    answer->array[answer->cardinality++] = (uint16_t)run_value;
  119|  42.8k|                }
  120|   146k|            }
  121|  56.3k|        }
  122|    691|        *dst = answer;
  123|    691|        return false;
  124|    691|    } else {  // we guess it will be a bitset, though have to check guess when
  125|       |              // done
  126|      0|        bitset_container_t *answer = bitset_container_clone(src_2);
  127|       |
  128|      0|        uint32_t last_pos = 0;
  129|      0|        for (int32_t rlepos = 0; rlepos < src_1->n_runs; ++rlepos) {
  ------------------
  |  Branch (129:34): [True: 0, False: 0]
  ------------------
  130|      0|            rle16_t rle = src_1->runs[rlepos];
  131|       |
  132|      0|            uint32_t start = rle.value;
  133|      0|            uint32_t end = start + rle.length + 1;
  134|      0|            bitset_reset_range(answer->words, last_pos, start);
  135|      0|            bitset_flip_range(answer->words, start, end);
  136|      0|            last_pos = end;
  137|      0|        }
  138|      0|        bitset_reset_range(answer->words, last_pos, (uint32_t)(1 << 16));
  139|       |
  140|      0|        answer->cardinality = bitset_container_compute_cardinality(answer);
  141|       |
  142|      0|        if (answer->cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (142:13): [True: 0, False: 0]
  ------------------
  143|      0|            *dst = array_container_from_bitset(answer);
  144|      0|            bitset_container_free(answer);
  145|      0|            return false;  // not bitset
  146|      0|        }
  147|      0|        *dst = answer;
  148|       |        return true;  // bitset
  149|      0|    }
  150|    691|}
run_array_container_andnot:
  279|  2.07k|                               container_t **dst) {
  280|       |    // follows the Java impl as of June 2016
  281|       |
  282|  2.07k|    int card = run_container_cardinality(src_1);
  283|  2.07k|    const int arbitrary_threshold = 32;
  284|       |
  285|  2.07k|    if (card <= arbitrary_threshold) {
  ------------------
  |  Branch (285:9): [True: 381, False: 1.69k]
  ------------------
  286|    381|        if (src_2->cardinality == 0) {
  ------------------
  |  Branch (286:13): [True: 0, False: 381]
  ------------------
  287|      0|            *dst = run_container_clone(src_1);
  288|      0|            return RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
  289|      0|        }
  290|       |        // Java's "lazyandNot.toEfficientContainer" thing
  291|    381|        run_container_t *answer = run_container_create_given_capacity(
  292|    381|            card + array_container_cardinality(src_2));
  293|       |
  294|    381|        int rlepos = 0;
  295|    381|        int xrlepos = 0;  // "x" is src_2
  296|    381|        rle16_t rle = src_1->runs[rlepos];
  297|    381|        int32_t start = rle.value;
  298|    381|        int32_t end = start + rle.length + 1;
  299|    381|        int32_t xstart = src_2->array[xrlepos];
  300|       |
  301|  13.7k|        while ((rlepos < src_1->n_runs) && (xrlepos < src_2->cardinality)) {
  ------------------
  |  Branch (301:16): [True: 13.4k, False: 302]
  |  Branch (301:44): [True: 13.3k, False: 79]
  ------------------
  302|  13.3k|            if (end <= xstart) {
  ------------------
  |  Branch (302:17): [True: 639, False: 12.7k]
  ------------------
  303|       |                // output the first run
  304|    639|                answer->runs[answer->n_runs++] =
  305|    639|                    CROARING_MAKE_RLE16(start, end - start - 1);
  ------------------
  |  |   60|    639|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  306|    639|                rlepos++;
  307|    639|                if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (307:21): [True: 584, False: 55]
  ------------------
  308|    584|                    start = src_1->runs[rlepos].value;
  309|    584|                    end = start + src_1->runs[rlepos].length + 1;
  310|    584|                }
  311|  12.7k|            } else if (xstart + 1 <= start) {
  ------------------
  |  Branch (311:24): [True: 8.14k, False: 4.57k]
  ------------------
  312|       |                // exit the second run
  313|  8.14k|                xrlepos++;
  314|  8.14k|                if (xrlepos < src_2->cardinality) {
  ------------------
  |  Branch (314:21): [True: 8.06k, False: 79]
  ------------------
  315|  8.06k|                    xstart = src_2->array[xrlepos];
  316|  8.06k|                }
  317|  8.14k|            } else {
  318|  4.57k|                if (start < xstart) {
  ------------------
  |  Branch (318:21): [True: 323, False: 4.25k]
  ------------------
  319|    323|                    answer->runs[answer->n_runs++] =
  320|    323|                        CROARING_MAKE_RLE16(start, xstart - start - 1);
  ------------------
  |  |   60|    323|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  321|    323|                }
  322|  4.57k|                if (xstart + 1 < end) {
  ------------------
  |  Branch (322:21): [True: 2.77k, False: 1.80k]
  ------------------
  323|  2.77k|                    start = xstart + 1;
  324|  2.77k|                } else {
  325|  1.80k|                    rlepos++;
  326|  1.80k|                    if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (326:25): [True: 1.55k, False: 247]
  ------------------
  327|  1.55k|                        start = src_1->runs[rlepos].value;
  328|  1.55k|                        end = start + src_1->runs[rlepos].length + 1;
  329|  1.55k|                    }
  330|  1.80k|                }
  331|  4.57k|            }
  332|  13.3k|        }
  333|    381|        if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (333:13): [True: 79, False: 302]
  ------------------
  334|     79|            answer->runs[answer->n_runs++] =
  335|     79|                CROARING_MAKE_RLE16(start, end - start - 1);
  ------------------
  |  |   60|     79|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  336|     79|            rlepos++;
  337|     79|            if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (337:17): [True: 25, False: 54]
  ------------------
  338|     25|                memcpy(answer->runs + answer->n_runs, src_1->runs + rlepos,
  339|     25|                       (src_1->n_runs - rlepos) * sizeof(rle16_t));
  340|     25|                answer->n_runs += (src_1->n_runs - rlepos);
  341|     25|            }
  342|     79|        }
  343|    381|        uint8_t return_type;
  344|    381|        *dst = convert_run_to_efficient_container(answer, &return_type);
  345|    381|        if (answer != *dst) run_container_free(answer);
  ------------------
  |  Branch (345:13): [True: 242, False: 139]
  ------------------
  346|    381|        return return_type;
  347|    381|    }
  348|       |    // else it's a bitmap or array
  349|       |
  350|  1.69k|    if (card <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (350:9): [True: 1.36k, False: 333]
  ------------------
  351|  1.36k|        array_container_t *ac = array_container_create_given_capacity(card);
  352|       |        // nb Java code used a generic iterator-based merge to compute
  353|       |        // difference
  354|  1.36k|        ac->cardinality = run_array_array_subtract(src_1, src_2, ac);
  355|  1.36k|        *dst = ac;
  356|  1.36k|        return ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  1.36k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  357|  1.36k|    }
  358|    333|    bitset_container_t *ans = bitset_container_from_run(src_1);
  359|    333|    bool result_is_bitset = bitset_array_container_iandnot(ans, src_2, dst);
  360|    333|    return (result_is_bitset ? BITSET_CONTAINER_TYPE : ARRAY_CONTAINER_TYPE);
  ------------------
  |  |   48|    315|#define BITSET_CONTAINER_TYPE 1
  ------------------
                  return (result_is_bitset ? BITSET_CONTAINER_TYPE : ARRAY_CONTAINER_TYPE);
  ------------------
  |  |   49|     18|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (360:13): [True: 315, False: 18]
  ------------------
  361|  1.69k|}
run_array_container_iandnot:
  372|    801|                                container_t **dst) {
  373|       |    // dummy implementation same as June 2016 Java
  374|    801|    int ans = run_array_container_andnot(src_1, src_2, dst);
  375|    801|    run_container_free(src_1);
  376|    801|    return ans;
  377|    801|}
array_run_container_andnot:
  383|    825|                                array_container_t *dst) {
  384|       |    // basically following Java impl as of June 2016
  385|    825|    if (src_1->cardinality > dst->capacity) {
  ------------------
  |  Branch (385:9): [True: 780, False: 45]
  ------------------
  386|    780|        array_container_grow(dst, src_1->cardinality, false);
  387|    780|    }
  388|       |
  389|    825|    if (src_2->n_runs == 0) {
  ------------------
  |  Branch (389:9): [True: 0, False: 825]
  ------------------
  390|      0|        memmove(dst->array, src_1->array,
  391|      0|                sizeof(uint16_t) * src_1->cardinality);
  392|      0|        dst->cardinality = src_1->cardinality;
  393|      0|        return;
  394|      0|    }
  395|    825|    int32_t run_start = src_2->runs[0].value;
  396|    825|    int32_t run_end = run_start + src_2->runs[0].length;
  397|    825|    int which_run = 0;
  398|       |
  399|    825|    uint16_t val = 0;
  400|    825|    int dest_card = 0;
  401|   176k|    for (int i = 0; i < src_1->cardinality; ++i) {
  ------------------
  |  Branch (401:21): [True: 175k, False: 825]
  ------------------
  402|   175k|        val = src_1->array[i];
  403|   175k|        if (val < run_start)
  ------------------
  |  Branch (403:13): [True: 44.3k, False: 130k]
  ------------------
  404|  44.3k|            dst->array[dest_card++] = val;
  405|   130k|        else if (val <= run_end) {
  ------------------
  |  Branch (405:18): [True: 95.3k, False: 35.6k]
  ------------------
  406|  95.3k|            ;  // omitted item
  407|  95.3k|        } else {
  408|  49.8k|            do {
  409|  49.8k|                if (which_run + 1 < src_2->n_runs) {
  ------------------
  |  Branch (409:21): [True: 49.6k, False: 197]
  ------------------
  410|  49.6k|                    ++which_run;
  411|  49.6k|                    run_start = src_2->runs[which_run].value;
  412|  49.6k|                    run_end = run_start + src_2->runs[which_run].length;
  413|       |
  414|  49.6k|                } else
  415|    197|                    run_start = run_end = (1 << 16) + 1;
  416|  49.8k|            } while (val > run_end);
  ------------------
  |  Branch (416:22): [True: 14.2k, False: 35.6k]
  ------------------
  417|  35.6k|            --i;
  418|  35.6k|        }
  419|   175k|    }
  420|    825|    dst->cardinality = dest_card;
  421|    825|}
array_run_container_iandnot:
  428|     45|                                 const run_container_t *src_2) {
  429|     45|    array_run_container_andnot(src_1, src_2, src_1);
  430|     45|}
run_run_container_andnot:
  437|  1.09k|                             const run_container_t *src_2, container_t **dst) {
  438|  1.09k|    run_container_t *ans = run_container_create();
  439|  1.09k|    run_container_andnot(src_1, src_2, ans);
  440|  1.09k|    uint8_t typecode_after;
  441|  1.09k|    *dst = convert_run_to_efficient_container_and_free(ans, &typecode_after);
  442|  1.09k|    return typecode_after;
  443|  1.09k|}
run_run_container_iandnot:
  453|    432|                              const run_container_t *src_2, container_t **dst) {
  454|       |    // following Java impl as of June 2016 (dummy)
  455|    432|    int ans = run_run_container_andnot(src_1, src_2, dst);
  456|    432|    run_container_free(src_1);
  457|    432|    return ans;
  458|    432|}
array_array_container_andnot:
  466|  2.32k|                                  array_container_t *dst) {
  467|  2.32k|    array_container_andnot(src_1, src_2, dst);
  468|  2.32k|}
array_array_container_iandnot:
  473|  3.54k|                                   const array_container_t *src_2) {
  474|  3.54k|    array_container_andnot(src_1, src_2, src_1);
  475|  3.54k|}
mixed_andnot.c:run_array_array_subtract:
  235|  1.36k|                                    array_container_t *a_out) {
  236|  1.36k|    int out_card = 0;
  237|  1.36k|    int32_t in_array_pos =
  238|  1.36k|        -1;  // since advanceUntil always assumes we start the search AFTER this
  239|       |
  240|   103k|    for (int rlepos = 0; rlepos < rc->n_runs; rlepos++) {
  ------------------
  |  Branch (240:26): [True: 101k, False: 1.36k]
  ------------------
  241|   101k|        int32_t start = rc->runs[rlepos].value;
  242|   101k|        int32_t end = start + rc->runs[rlepos].length + 1;
  243|       |
  244|   101k|        in_array_pos = advanceUntil(a_in->array, in_array_pos,
  245|   101k|                                    a_in->cardinality, (uint16_t)start);
  246|       |
  247|   101k|        if (in_array_pos >= a_in->cardinality) {  // run has no items subtracted
  ------------------
  |  Branch (247:13): [True: 5.00k, False: 96.7k]
  ------------------
  248|  79.1k|            for (int32_t i = start; i < end; ++i)
  ------------------
  |  Branch (248:37): [True: 74.1k, False: 5.00k]
  ------------------
  249|  74.1k|                a_out->array[out_card++] = (uint16_t)i;
  250|  96.7k|        } else {
  251|  96.7k|            uint16_t next_nonincluded = a_in->array[in_array_pos];
  252|  96.7k|            if (next_nonincluded >= end) {
  ------------------
  |  Branch (252:17): [True: 33.1k, False: 63.5k]
  ------------------
  253|       |                // another case when run goes unaltered
  254|  89.1k|                for (int32_t i = start; i < end; ++i)
  ------------------
  |  Branch (254:41): [True: 55.9k, False: 33.1k]
  ------------------
  255|  55.9k|                    a_out->array[out_card++] = (uint16_t)i;
  256|  33.1k|                in_array_pos--;  // ensure we see this item again if necessary
  257|  63.5k|            } else {
  258|   318k|                for (int32_t i = start; i < end; ++i)
  ------------------
  |  Branch (258:41): [True: 254k, False: 63.5k]
  ------------------
  259|   254k|                    if (i != next_nonincluded)
  ------------------
  |  Branch (259:25): [True: 113k, False: 141k]
  ------------------
  260|   113k|                        a_out->array[out_card++] = (uint16_t)i;
  261|   141k|                    else  // 0 should ensure  we don't match
  262|   141k|                        next_nonincluded =
  263|   141k|                            (in_array_pos + 1 >= a_in->cardinality)
  ------------------
  |  Branch (263:29): [True: 1.08k, False: 140k]
  ------------------
  264|   141k|                                ? 0
  265|   141k|                                : a_in->array[++in_array_pos];
  266|  63.5k|                in_array_pos--;  // see again
  267|  63.5k|            }
  268|  96.7k|        }
  269|   101k|    }
  270|  1.36k|    return out_card;
  271|  1.36k|}

array_container_equal_bitset:
   10|    469|                                  const bitset_container_t* container2) {
   11|    469|    if (container2->cardinality != BITSET_UNKNOWN_CARDINALITY) {
  ------------------
  |  Branch (11:9): [True: 469, False: 0]
  ------------------
   12|    469|        if (container2->cardinality != container1->cardinality) {
  ------------------
  |  Branch (12:13): [True: 469, False: 0]
  ------------------
   13|    469|            return false;
   14|    469|        }
   15|    469|    }
   16|      0|    int32_t pos = 0;
   17|      0|    for (int32_t i = 0; i < BITSET_CONTAINER_SIZE_IN_WORDS; ++i) {
  ------------------
  |  Branch (17:25): [True: 0, False: 0]
  ------------------
   18|      0|        uint64_t w = container2->words[i];
   19|      0|        while (w != 0) {
  ------------------
  |  Branch (19:16): [True: 0, False: 0]
  ------------------
   20|      0|            uint64_t t = w & (~w + 1);
   21|      0|            uint16_t r = i * 64 + roaring_trailing_zeroes(w);
   22|      0|            if (pos >= container1->cardinality) {
  ------------------
  |  Branch (22:17): [True: 0, False: 0]
  ------------------
   23|      0|                return false;
   24|      0|            }
   25|      0|            if (container1->array[pos] != r) {
  ------------------
  |  Branch (25:17): [True: 0, False: 0]
  ------------------
   26|      0|                return false;
   27|      0|            }
   28|      0|            ++pos;
   29|      0|            w ^= t;
   30|      0|        }
   31|      0|    }
   32|      0|    return (pos == container1->cardinality);
   33|      0|}
run_container_equals_array:
   36|    886|                                const array_container_t* container2) {
   37|    886|    if (run_container_cardinality(container1) != container2->cardinality)
  ------------------
  |  Branch (37:9): [True: 832, False: 54]
  ------------------
   38|    832|        return false;
   39|     54|    int32_t pos = 0;
   40|     54|    for (int i = 0; i < container1->n_runs; ++i) {
  ------------------
  |  Branch (40:21): [True: 54, False: 0]
  ------------------
   41|     54|        const uint32_t run_start = container1->runs[i].value;
   42|     54|        const uint32_t le = container1->runs[i].length;
   43|       |
   44|     54|        if (container2->array[pos] != run_start) {
  ------------------
  |  Branch (44:13): [True: 54, False: 0]
  ------------------
   45|     54|            return false;
   46|     54|        }
   47|       |
   48|      0|        if (container2->array[pos + le] != run_start + le) {
  ------------------
  |  Branch (48:13): [True: 0, False: 0]
  ------------------
   49|      0|            return false;
   50|      0|        }
   51|       |
   52|      0|        pos += le + 1;
   53|      0|    }
   54|      0|    return true;
   55|     54|}

array_bitset_container_intersection:
   21|    627|                                         array_container_t *dst) {
   22|    627|    if (dst->capacity < src_1->cardinality) {
  ------------------
  |  Branch (22:9): [True: 627, False: 0]
  ------------------
   23|    627|        array_container_grow(dst, src_1->cardinality, false);
   24|    627|    }
   25|    627|    int32_t newcard = 0;  // dst could be src_1
   26|    627|    const int32_t origcard = src_1->cardinality;
   27|   314k|    for (int i = 0; i < origcard; ++i) {
  ------------------
  |  Branch (27:21): [True: 313k, False: 627]
  ------------------
   28|   313k|        uint16_t key = src_1->array[i];
   29|       |        // this branchless approach is much faster...
   30|   313k|        dst->array[newcard] = key;
   31|   313k|        newcard += bitset_container_contains(src_2, key);
   32|       |        /**
   33|       |         * we could do it this way instead...
   34|       |         * if (bitset_container_contains(src_2, key)) {
   35|       |         * dst->array[newcard++] = key;
   36|       |         * }
   37|       |         * but if the result is unpredictible, the processor generates
   38|       |         * many mispredicted branches.
   39|       |         * Difference can be huge (from 3 cycles when predictible all the way
   40|       |         * to 16 cycles when unpredictible.
   41|       |         * See
   42|       |         * https://github.com/lemire/Code-used-on-Daniel-Lemire-s-blog/blob/master/extra/bitset/c/arraybitsetintersection.c
   43|       |         */
   44|   313k|    }
   45|    627|    dst->cardinality = newcard;
   46|    627|}
array_bitset_container_intersection_cardinality:
   50|  2.30k|    const array_container_t *src_1, const bitset_container_t *src_2) {
   51|  2.30k|    int32_t newcard = 0;
   52|  2.30k|    const int32_t origcard = src_1->cardinality;
   53|   408k|    for (int i = 0; i < origcard; ++i) {
  ------------------
  |  Branch (53:21): [True: 406k, False: 2.30k]
  ------------------
   54|   406k|        uint16_t key = src_1->array[i];
   55|   406k|        newcard += bitset_container_contains(src_2, key);
   56|   406k|    }
   57|  2.30k|    return newcard;
   58|  2.30k|}
array_bitset_container_intersect:
   61|    575|                                      const bitset_container_t *src_2) {
   62|    575|    const int32_t origcard = src_1->cardinality;
   63|  3.93k|    for (int i = 0; i < origcard; ++i) {
  ------------------
  |  Branch (63:21): [True: 3.91k, False: 14]
  ------------------
   64|  3.91k|        uint16_t key = src_1->array[i];
   65|  3.91k|        if (bitset_container_contains(src_2, key)) return true;
  ------------------
  |  Branch (65:13): [True: 561, False: 3.35k]
  ------------------
   66|  3.91k|    }
   67|     14|    return false;
   68|    575|}
array_run_container_intersection:
   75|  3.35k|                                      array_container_t *dst) {
   76|  3.35k|    if (run_container_is_full(src_2)) {
  ------------------
  |  Branch (76:9): [True: 34, False: 3.32k]
  ------------------
   77|     34|        if (dst != src_1) array_container_copy(src_1, dst);
  ------------------
  |  Branch (77:13): [True: 34, False: 0]
  ------------------
   78|     34|        return;
   79|     34|    }
   80|  3.32k|    if (dst->capacity < src_1->cardinality) {
  ------------------
  |  Branch (80:9): [True: 3.32k, False: 0]
  ------------------
   81|  3.32k|        array_container_grow(dst, src_1->cardinality, false);
   82|  3.32k|    }
   83|  3.32k|    if (src_2->n_runs == 0) {
  ------------------
  |  Branch (83:9): [True: 0, False: 3.32k]
  ------------------
   84|      0|        return;
   85|      0|    }
   86|  3.32k|    int32_t rlepos = 0;
   87|  3.32k|    int32_t arraypos = 0;
   88|  3.32k|    rle16_t rle = src_2->runs[rlepos];
   89|  3.32k|    int32_t newcard = 0;
   90|   457k|    while (arraypos < src_1->cardinality) {
  ------------------
  |  Branch (90:12): [True: 454k, False: 2.75k]
  ------------------
   91|   454k|        const uint16_t arrayval = src_1->array[arraypos];
   92|   610k|        while (rle.value + rle.length <
  ------------------
  |  Branch (92:16): [True: 156k, False: 453k]
  ------------------
   93|   610k|               arrayval) {  // this will frequently be false
   94|   156k|            ++rlepos;
   95|   156k|            if (rlepos == src_2->n_runs) {
  ------------------
  |  Branch (95:17): [True: 570, False: 156k]
  ------------------
   96|    570|                dst->cardinality = newcard;
   97|    570|                return;  // we are done
   98|    570|            }
   99|   156k|            rle = src_2->runs[rlepos];
  100|   156k|        }
  101|   453k|        if (rle.value > arrayval) {
  ------------------
  |  Branch (101:13): [True: 30.6k, False: 422k]
  ------------------
  102|  30.6k|            arraypos = advanceUntil(src_1->array, arraypos, src_1->cardinality,
  103|  30.6k|                                    rle.value);
  104|   422k|        } else {
  105|   422k|            dst->array[newcard] = arrayval;
  106|   422k|            newcard++;
  107|   422k|            arraypos++;
  108|   422k|        }
  109|   453k|    }
  110|  2.75k|    dst->cardinality = newcard;
  111|  2.75k|}
run_bitset_container_intersection:
  119|    691|                                       container_t **dst) {
  120|    691|    if (run_container_is_full(src_1)) {
  ------------------
  |  Branch (120:9): [True: 0, False: 691]
  ------------------
  121|      0|        if (*dst != src_2) *dst = bitset_container_clone(src_2);
  ------------------
  |  Branch (121:13): [True: 0, False: 0]
  ------------------
  122|      0|        return true;
  123|      0|    }
  124|    691|    int32_t card = run_container_cardinality(src_1);
  125|    691|    if (card <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (125:9): [True: 691, False: 0]
  ------------------
  126|       |        // result can only be an array (assuming that we never make a
  127|       |        // RunContainer)
  128|    691|        if (card > src_2->cardinality) {
  ------------------
  |  Branch (128:13): [True: 0, False: 691]
  ------------------
  129|      0|            card = src_2->cardinality;
  130|      0|        }
  131|    691|        array_container_t *answer = array_container_create_given_capacity(card);
  132|    691|        *dst = answer;
  133|    691|        if (*dst == NULL) {
  ------------------
  |  Branch (133:13): [True: 0, False: 691]
  ------------------
  134|      0|            return false;
  135|      0|        }
  136|  57.0k|        for (int32_t rlepos = 0; rlepos < src_1->n_runs; ++rlepos) {
  ------------------
  |  Branch (136:34): [True: 56.3k, False: 691]
  ------------------
  137|  56.3k|            rle16_t rle = src_1->runs[rlepos];
  138|  56.3k|            uint32_t endofrun = (uint32_t)rle.value + rle.length;
  139|   202k|            for (uint32_t runValue = rle.value; runValue <= endofrun;
  ------------------
  |  Branch (139:49): [True: 146k, False: 56.3k]
  ------------------
  140|   146k|                 ++runValue) {
  141|   146k|                answer->array[answer->cardinality] = (uint16_t)runValue;
  142|   146k|                answer->cardinality +=
  143|   146k|                    bitset_container_contains(src_2, runValue);
  144|   146k|            }
  145|  56.3k|        }
  146|    691|        return false;
  147|    691|    }
  148|      0|    if (*dst == src_2) {  // we attempt in-place
  ------------------
  |  Branch (148:9): [True: 0, False: 0]
  ------------------
  149|      0|        bitset_container_t *answer = CAST_bitset(*dst);
  ------------------
  |  |   52|      0|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  150|      0|        uint32_t start = 0;
  151|      0|        for (int32_t rlepos = 0; rlepos < src_1->n_runs; ++rlepos) {
  ------------------
  |  Branch (151:34): [True: 0, False: 0]
  ------------------
  152|      0|            const rle16_t rle = src_1->runs[rlepos];
  153|      0|            uint32_t end = rle.value;
  154|      0|            bitset_reset_range(src_2->words, start, end);
  155|       |
  156|      0|            start = end + rle.length + 1;
  157|      0|        }
  158|      0|        bitset_reset_range(src_2->words, start, UINT32_C(1) << 16);
  159|      0|        answer->cardinality = bitset_container_compute_cardinality(answer);
  160|      0|        if (src_2->cardinality > DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (160:13): [True: 0, False: 0]
  ------------------
  161|      0|            return true;
  162|      0|        } else {
  163|      0|            array_container_t *newanswer = array_container_from_bitset(src_2);
  164|      0|            if (newanswer == NULL) {
  ------------------
  |  Branch (164:17): [True: 0, False: 0]
  ------------------
  165|      0|                *dst = NULL;
  166|      0|                return false;
  167|      0|            }
  168|      0|            *dst = newanswer;
  169|      0|            return false;
  170|      0|        }
  171|      0|    } else {  // no inplace
  172|       |        // we expect the answer to be a bitmap (if we are lucky)
  173|      0|        bitset_container_t *answer = bitset_container_clone(src_2);
  174|       |
  175|      0|        *dst = answer;
  176|      0|        if (answer == NULL) {
  ------------------
  |  Branch (176:13): [True: 0, False: 0]
  ------------------
  177|      0|            return true;
  178|      0|        }
  179|      0|        uint32_t start = 0;
  180|      0|        for (int32_t rlepos = 0; rlepos < src_1->n_runs; ++rlepos) {
  ------------------
  |  Branch (180:34): [True: 0, False: 0]
  ------------------
  181|      0|            const rle16_t rle = src_1->runs[rlepos];
  182|      0|            uint32_t end = rle.value;
  183|      0|            bitset_reset_range(answer->words, start, end);
  184|      0|            start = end + rle.length + 1;
  185|      0|        }
  186|      0|        bitset_reset_range(answer->words, start, UINT32_C(1) << 16);
  187|      0|        answer->cardinality = bitset_container_compute_cardinality(answer);
  188|       |
  189|      0|        if (answer->cardinality > DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (189:13): [True: 0, False: 0]
  ------------------
  190|      0|            return true;
  191|      0|        } else {
  192|      0|            array_container_t *newanswer = array_container_from_bitset(answer);
  193|      0|            bitset_container_free(CAST_bitset(*dst));
  ------------------
  |  |   52|      0|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  194|      0|            if (newanswer == NULL) {
  ------------------
  |  Branch (194:17): [True: 0, False: 0]
  ------------------
  195|      0|                *dst = NULL;
  196|      0|                return false;
  197|      0|            }
  198|      0|            *dst = newanswer;
  199|       |            return false;
  200|      0|        }
  201|      0|    }
  202|      0|}
array_run_container_intersection_cardinality:
  206|  8.36k|                                                 const run_container_t *src_2) {
  207|  8.36k|    if (run_container_is_full(src_2)) {
  ------------------
  |  Branch (207:9): [True: 136, False: 8.22k]
  ------------------
  208|    136|        return src_1->cardinality;
  209|    136|    }
  210|  8.22k|    if (src_2->n_runs == 0) {
  ------------------
  |  Branch (210:9): [True: 0, False: 8.22k]
  ------------------
  211|      0|        return 0;
  212|      0|    }
  213|  8.22k|    int32_t rlepos = 0;
  214|  8.22k|    int32_t arraypos = 0;
  215|  8.22k|    rle16_t rle = src_2->runs[rlepos];
  216|  8.22k|    int32_t newcard = 0;
  217|   819k|    while (arraypos < src_1->cardinality) {
  ------------------
  |  Branch (217:12): [True: 812k, False: 6.36k]
  ------------------
  218|   812k|        const uint16_t arrayval = src_1->array[arraypos];
  219|  1.21M|        while (rle.value + rle.length <
  ------------------
  |  Branch (219:16): [True: 402k, False: 811k]
  ------------------
  220|  1.21M|               arrayval) {  // this will frequently be false
  221|   402k|            ++rlepos;
  222|   402k|            if (rlepos == src_2->n_runs) {
  ------------------
  |  Branch (222:17): [True: 1.86k, False: 400k]
  ------------------
  223|  1.86k|                return newcard;  // we are done
  224|  1.86k|            }
  225|   400k|            rle = src_2->runs[rlepos];
  226|   400k|        }
  227|   811k|        if (rle.value > arrayval) {
  ------------------
  |  Branch (227:13): [True: 110k, False: 700k]
  ------------------
  228|   110k|            arraypos = advanceUntil(src_1->array, arraypos, src_1->cardinality,
  229|   110k|                                    rle.value);
  230|   700k|        } else {
  231|   700k|            newcard++;
  232|   700k|            arraypos++;
  233|   700k|        }
  234|   811k|    }
  235|  6.36k|    return newcard;
  236|  8.22k|}
run_bitset_container_intersection_cardinality:
  241|  2.76k|    const run_container_t *src_1, const bitset_container_t *src_2) {
  242|  2.76k|    if (run_container_is_full(src_1)) {
  ------------------
  |  Branch (242:9): [True: 0, False: 2.76k]
  ------------------
  243|      0|        return bitset_container_cardinality(src_2);
  244|      0|    }
  245|  2.76k|    int answer = 0;
  246|   228k|    for (int32_t rlepos = 0; rlepos < src_1->n_runs; ++rlepos) {
  ------------------
  |  Branch (246:30): [True: 225k, False: 2.76k]
  ------------------
  247|   225k|        rle16_t rle = src_1->runs[rlepos];
  248|   225k|        answer +=
  249|   225k|            bitset_lenrange_cardinality(src_2->words, rle.value, rle.length);
  250|   225k|    }
  251|  2.76k|    return answer;
  252|  2.76k|}
array_run_container_intersect:
  255|  2.09k|                                   const run_container_t *src_2) {
  256|  2.09k|    if (run_container_is_full(src_2)) {
  ------------------
  |  Branch (256:9): [True: 34, False: 2.05k]
  ------------------
  257|     34|        return !array_container_empty(src_1);
  258|     34|    }
  259|  2.05k|    if (src_2->n_runs == 0) {
  ------------------
  |  Branch (259:9): [True: 0, False: 2.05k]
  ------------------
  260|      0|        return false;
  261|      0|    }
  262|  2.05k|    int32_t rlepos = 0;
  263|  2.05k|    int32_t arraypos = 0;
  264|  2.05k|    rle16_t rle = src_2->runs[rlepos];
  265|  3.54k|    while (arraypos < src_1->cardinality) {
  ------------------
  |  Branch (265:12): [True: 3.48k, False: 56]
  ------------------
  266|  3.48k|        const uint16_t arrayval = src_1->array[arraypos];
  267|  9.41k|        while (rle.value + rle.length <
  ------------------
  |  Branch (267:16): [True: 5.98k, False: 3.43k]
  ------------------
  268|  9.41k|               arrayval) {  // this will frequently be false
  269|  5.98k|            ++rlepos;
  270|  5.98k|            if (rlepos == src_2->n_runs) {
  ------------------
  |  Branch (270:17): [True: 50, False: 5.93k]
  ------------------
  271|     50|                return false;  // we are done
  272|     50|            }
  273|  5.93k|            rle = src_2->runs[rlepos];
  274|  5.93k|        }
  275|  3.43k|        if (rle.value > arrayval) {
  ------------------
  |  Branch (275:13): [True: 1.48k, False: 1.95k]
  ------------------
  276|  1.48k|            arraypos = advanceUntil(src_1->array, arraypos, src_1->cardinality,
  277|  1.48k|                                    rle.value);
  278|  1.95k|        } else {
  279|  1.95k|            return true;
  280|  1.95k|        }
  281|  3.43k|    }
  282|     56|    return false;
  283|  2.05k|}
run_bitset_container_intersect:
  288|    691|                                    const bitset_container_t *src_2) {
  289|    691|    if (run_container_is_full(src_1)) {
  ------------------
  |  Branch (289:9): [True: 0, False: 691]
  ------------------
  290|      0|        return !bitset_container_empty(src_2);
  291|      0|    }
  292|  4.14k|    for (int32_t rlepos = 0; rlepos < src_1->n_runs; ++rlepos) {
  ------------------
  |  Branch (292:30): [True: 4.12k, False: 15]
  ------------------
  293|  4.12k|        rle16_t rle = src_1->runs[rlepos];
  294|  4.12k|        if (!bitset_lenrange_empty(src_2->words, rle.value, rle.length))
  ------------------
  |  Branch (294:13): [True: 676, False: 3.44k]
  ------------------
  295|    676|            return true;
  296|  4.12k|    }
  297|     15|    return false;
  298|    691|}
bitset_bitset_container_intersection_inplace:
  329|  1.51k|    container_t **dst) {
  330|  1.51k|    const int newCardinality = bitset_container_and_justcard(src_1, src_2);
  331|  1.51k|    if (newCardinality > DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (331:9): [True: 1.51k, False: 0]
  ------------------
  332|  1.51k|        *dst = src_1;
  333|  1.51k|        bitset_container_and_nocard(src_1, src_2, src_1);
  334|  1.51k|        CAST_bitset(*dst)->cardinality = newCardinality;
  ------------------
  |  |   52|  1.51k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.51k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  335|  1.51k|        return true;  // it is a bitset
  336|  1.51k|    }
  337|      0|    *dst = array_container_create_given_capacity(newCardinality);
  338|      0|    if (*dst != NULL) {
  ------------------
  |  Branch (338:9): [True: 0, False: 0]
  ------------------
  339|      0|        CAST_array(*dst)->cardinality = newCardinality;
  ------------------
  |  |   54|      0|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  340|      0|        bitset_extract_intersection_setbits_uint16(
  341|      0|            src_1->words, src_2->words, BITSET_CONTAINER_SIZE_IN_WORDS,
  342|      0|            CAST_array(*dst)->array, 0);
  ------------------
  |  |   54|      0|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  343|      0|    }
  344|       |    return false;  // not a bitset
  345|  1.51k|}

array_container_negation:
   33|    185|                              bitset_container_t *dst) {
   34|    185|    uint64_t card = UINT64_C(1 << 16);
   35|    185|    bitset_container_set_all(dst);
   36|       |
   37|    185|    if (src->cardinality == 0) {
  ------------------
  |  Branch (37:9): [True: 0, False: 185]
  ------------------
   38|      0|        return;
   39|      0|    }
   40|       |
   41|    185|    dst->cardinality = (int32_t)bitset_clear_list(dst->words, card, src->array,
   42|    185|                                                  (uint64_t)src->cardinality);
   43|    185|}
bitset_container_negation_inplace:
   67|     87|                                       container_t **dst) {
   68|     87|    return bitset_container_negation_range_inplace(src, 0, (1 << 16), dst);
   69|     87|}
run_container_negation_inplace:
   88|  6.58k|int run_container_negation_inplace(run_container_t *src, container_t **dst) {
   89|  6.58k|    return run_container_negation_range_inplace(src, 0, (1 << 16), dst);
   90|  6.58k|}
array_container_negation_range:
   99|  3.57k|                                    container_t **dst) {
  100|       |    /* close port of the Java implementation */
  101|  3.57k|    if (range_start >= range_end) {
  ------------------
  |  Branch (101:9): [True: 0, False: 3.57k]
  ------------------
  102|      0|        *dst = array_container_clone(src);
  103|      0|        return false;
  104|      0|    }
  105|       |
  106|  3.57k|    int32_t start_index =
  107|  3.57k|        binarySearch(src->array, src->cardinality, (uint16_t)range_start);
  108|  3.57k|    if (start_index < 0) start_index = -start_index - 1;
  ------------------
  |  Branch (108:9): [True: 3.24k, False: 327]
  ------------------
  109|       |
  110|  3.57k|    int32_t last_index =
  111|  3.57k|        binarySearch(src->array, src->cardinality, (uint16_t)(range_end - 1));
  112|  3.57k|    if (last_index < 0) last_index = -last_index - 2;
  ------------------
  |  Branch (112:9): [True: 3.30k, False: 273]
  ------------------
  113|       |
  114|  3.57k|    const int32_t current_values_in_range = last_index - start_index + 1;
  115|  3.57k|    const int32_t span_to_be_flipped = range_end - range_start;
  116|  3.57k|    const int32_t new_values_in_range =
  117|  3.57k|        span_to_be_flipped - current_values_in_range;
  118|  3.57k|    const int32_t cardinality_change =
  119|  3.57k|        new_values_in_range - current_values_in_range;
  120|  3.57k|    const int32_t new_cardinality = src->cardinality + cardinality_change;
  121|       |
  122|  3.57k|    if (new_cardinality > DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (122:9): [True: 130, False: 3.44k]
  ------------------
  123|    130|        bitset_container_t *temp = bitset_container_from_array(src);
  124|    130|        bitset_flip_range(temp->words, (uint32_t)range_start,
  125|    130|                          (uint32_t)range_end);
  126|    130|        temp->cardinality = new_cardinality;
  127|    130|        *dst = temp;
  128|    130|        return true;
  129|    130|    }
  130|       |
  131|  3.44k|    array_container_t *arr =
  132|  3.44k|        array_container_create_given_capacity(new_cardinality);
  133|  3.44k|    *dst = (container_t *)arr;
  134|  3.44k|    if (new_cardinality == 0) {
  ------------------
  |  Branch (134:9): [True: 12, False: 3.43k]
  ------------------
  135|     12|        arr->cardinality = new_cardinality;
  136|     12|        return false;  // we are done.
  137|     12|    }
  138|       |    // copy stuff before the active area
  139|  3.43k|    memcpy(arr->array, src->array, start_index * sizeof(uint16_t));
  140|       |
  141|       |    // work on the range
  142|  3.43k|    int32_t out_pos = start_index, in_pos = start_index;
  143|  3.43k|    int32_t val_in_range = range_start;
  144|  35.0k|    for (; val_in_range < range_end && in_pos <= last_index; ++val_in_range) {
  ------------------
  |  Branch (144:12): [True: 34.7k, False: 260]
  |  Branch (144:40): [True: 31.5k, False: 3.17k]
  ------------------
  145|  31.5k|        if ((uint16_t)val_in_range != src->array[in_pos]) {
  ------------------
  |  Branch (145:13): [True: 15.7k, False: 15.8k]
  ------------------
  146|  15.7k|            arr->array[out_pos++] = (uint16_t)val_in_range;
  147|  15.8k|        } else {
  148|  15.8k|            ++in_pos;
  149|  15.8k|        }
  150|  31.5k|    }
  151|  69.1k|    for (; val_in_range < range_end; ++val_in_range)
  ------------------
  |  Branch (151:12): [True: 65.6k, False: 3.43k]
  ------------------
  152|  65.6k|        arr->array[out_pos++] = (uint16_t)val_in_range;
  153|       |
  154|       |    // content after the active range
  155|  3.43k|    memcpy(arr->array + out_pos, src->array + (last_index + 1),
  156|  3.43k|           (src->cardinality - (last_index + 1)) * sizeof(uint16_t));
  157|  3.43k|    arr->cardinality = new_cardinality;
  158|       |    return false;
  159|  3.44k|}
array_container_negation_range_inplace:
  168|  3.57k|                                            container_t **dst) {
  169|  3.57k|    bool ans = array_container_negation_range(src, range_start, range_end, dst);
  170|       |    // TODO : try a real inplace version
  171|  3.57k|    array_container_free(src);
  172|  3.57k|    return ans;
  173|  3.57k|}
bitset_container_negation_range_inplace:
  217|  1.44k|                                             container_t **dst) {
  218|  1.44k|    bitset_flip_range(src->words, (uint32_t)range_start, (uint32_t)range_end);
  219|  1.44k|    src->cardinality = bitset_container_compute_cardinality(src);
  220|  1.44k|    if (src->cardinality > DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (220:9): [True: 1.36k, False: 75]
  ------------------
  221|  1.36k|        *dst = src;
  222|  1.36k|        return true;
  223|  1.36k|    }
  224|     75|    *dst = array_container_from_bitset(src);
  225|     75|    bitset_container_free(src);
  226|       |    return false;
  227|  1.44k|}
run_container_negation_range:
  237|    146|                                 container_t **dst) {
  238|    146|    uint8_t return_typecode;
  239|       |
  240|       |    // follows the Java implementation
  241|    146|    if (range_end <= range_start) {
  ------------------
  |  Branch (241:9): [True: 0, False: 146]
  ------------------
  242|      0|        *dst = run_container_clone(src);
  243|      0|        return RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
  244|      0|    }
  245|       |
  246|    146|    run_container_t *ans = run_container_create_given_capacity(
  247|    146|        src->n_runs + 1);  // src->n_runs + 1);
  248|    146|    int k = 0;
  249|  3.05k|    for (; k < src->n_runs && src->runs[k].value < range_start; ++k) {
  ------------------
  |  Branch (249:12): [True: 3.00k, False: 47]
  |  Branch (249:31): [True: 2.90k, False: 99]
  ------------------
  250|  2.90k|        ans->runs[k] = src->runs[k];
  251|  2.90k|        ans->n_runs++;
  252|  2.90k|    }
  253|       |
  254|    146|    run_container_smart_append_exclusive(
  255|    146|        ans, (uint16_t)range_start, (uint16_t)(range_end - range_start - 1));
  256|       |
  257|  3.73k|    for (; k < src->n_runs; ++k) {
  ------------------
  |  Branch (257:12): [True: 3.58k, False: 146]
  ------------------
  258|  3.58k|        run_container_smart_append_exclusive(ans, src->runs[k].value,
  259|  3.58k|                                             src->runs[k].length);
  260|  3.58k|    }
  261|       |
  262|    146|    *dst = convert_run_to_efficient_container(ans, &return_typecode);
  263|    146|    if (return_typecode != RUN_CONTAINER_TYPE) run_container_free(ans);
  ------------------
  |  |   50|    146|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (263:9): [True: 8, False: 138]
  ------------------
  264|       |
  265|    146|    return return_typecode;
  266|    146|}
run_container_negation_range_inplace:
  278|  8.28k|                                         container_t **dst) {
  279|  8.28k|    uint8_t return_typecode;
  280|       |
  281|  8.28k|    if (range_end <= range_start) {
  ------------------
  |  Branch (281:9): [True: 0, False: 8.28k]
  ------------------
  282|      0|        *dst = src;
  283|      0|        return RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
  284|      0|    }
  285|       |
  286|       |    // TODO: efficient special case when range is 0 to 65535 inclusive
  287|       |
  288|  8.28k|    if (src->capacity == src->n_runs) {
  ------------------
  |  Branch (288:9): [True: 7.12k, False: 1.15k]
  ------------------
  289|       |        // no excess room.  More checking to see if result can fit
  290|  7.12k|        bool last_val_before_range = false;
  291|  7.12k|        bool first_val_in_range = false;
  292|  7.12k|        bool last_val_in_range = false;
  293|  7.12k|        bool first_val_past_range = false;
  294|       |
  295|  7.12k|        if (range_start > 0)
  ------------------
  |  Branch (295:13): [True: 166, False: 6.95k]
  ------------------
  296|    166|            last_val_before_range =
  297|    166|                run_container_contains(src, (uint16_t)(range_start - 1));
  298|  7.12k|        first_val_in_range = run_container_contains(src, (uint16_t)range_start);
  299|       |
  300|  7.12k|        if (last_val_before_range == first_val_in_range) {
  ------------------
  |  Branch (300:13): [True: 459, False: 6.66k]
  ------------------
  301|    459|            last_val_in_range =
  302|    459|                run_container_contains(src, (uint16_t)(range_end - 1));
  303|    459|            if (range_end != 0x10000)
  ------------------
  |  Branch (303:17): [True: 294, False: 165]
  ------------------
  304|    294|                first_val_past_range =
  305|    294|                    run_container_contains(src, (uint16_t)range_end);
  306|       |
  307|    459|            if (last_val_in_range ==
  ------------------
  |  Branch (307:17): [True: 146, False: 313]
  ------------------
  308|    459|                first_val_past_range) {  // no space for inplace
  309|    146|                int ans = run_container_negation_range(src, range_start,
  310|    146|                                                       range_end, dst);
  311|    146|                run_container_free(src);
  312|    146|                return ans;
  313|    146|            }
  314|    459|        }
  315|  7.12k|    }
  316|       |    // all other cases: result will fit
  317|       |
  318|  8.13k|    run_container_t *ans = src;
  319|  8.13k|    int my_nbr_runs = src->n_runs;
  320|       |
  321|  8.13k|    ans->n_runs = 0;
  322|  8.13k|    int k = 0;
  323|  10.6k|    for (; (k < my_nbr_runs) && (src->runs[k].value < range_start); ++k) {
  ------------------
  |  Branch (323:12): [True: 10.6k, False: 69]
  |  Branch (323:33): [True: 2.54k, False: 8.06k]
  ------------------
  324|       |        // ans->runs[k] = src->runs[k]; (would be self-copy)
  325|  2.54k|        ans->n_runs++;
  326|  2.54k|    }
  327|       |
  328|       |    // as with Java implementation, use locals to give self a buffer of depth 1
  329|  8.13k|    rle16_t buffered = CROARING_MAKE_RLE16(0, 0);
  ------------------
  |  |   60|  8.13k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  330|  8.13k|    rle16_t next = buffered;
  331|  8.13k|    if (k < my_nbr_runs) buffered = src->runs[k];
  ------------------
  |  Branch (331:9): [True: 8.06k, False: 69]
  ------------------
  332|       |
  333|  8.13k|    run_container_smart_append_exclusive(
  334|  8.13k|        ans, (uint16_t)range_start, (uint16_t)(range_end - range_start - 1));
  335|       |
  336|  97.7k|    for (; k < my_nbr_runs; ++k) {
  ------------------
  |  Branch (336:12): [True: 89.6k, False: 8.13k]
  ------------------
  337|  89.6k|        if (k + 1 < my_nbr_runs) next = src->runs[k + 1];
  ------------------
  |  Branch (337:13): [True: 81.5k, False: 8.06k]
  ------------------
  338|       |
  339|  89.6k|        run_container_smart_append_exclusive(ans, buffered.value,
  340|  89.6k|                                             buffered.length);
  341|  89.6k|        buffered = next;
  342|  89.6k|    }
  343|       |
  344|  8.13k|    *dst = convert_run_to_efficient_container(ans, &return_typecode);
  345|  8.13k|    if (return_typecode != RUN_CONTAINER_TYPE) run_container_free(ans);
  ------------------
  |  |   50|  8.13k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (345:9): [True: 6.44k, False: 1.68k]
  ------------------
  346|       |
  347|  8.13k|    return return_typecode;
  348|  8.28k|}

array_container_is_subset_bitset:
   11|  2.45k|                                      const bitset_container_t* container2) {
   12|  2.45k|    if (container2->cardinality != BITSET_UNKNOWN_CARDINALITY) {
  ------------------
  |  Branch (12:9): [True: 2.45k, False: 0]
  ------------------
   13|  2.45k|        if (container2->cardinality < container1->cardinality) {
  ------------------
  |  Branch (13:13): [True: 0, False: 2.45k]
  ------------------
   14|      0|            return false;
   15|      0|        }
   16|  2.45k|    }
   17|  2.45k|    for (int i = 0; i < container1->cardinality; ++i) {
  ------------------
  |  Branch (17:21): [True: 2.45k, False: 0]
  ------------------
   18|  2.45k|        if (!bitset_container_contains(container2, container1->array[i])) {
  ------------------
  |  Branch (18:13): [True: 2.45k, False: 0]
  ------------------
   19|  2.45k|            return false;
   20|  2.45k|        }
   21|  2.45k|    }
   22|      0|    return true;
   23|  2.45k|}
run_container_is_subset_array:
   26|    423|                                   const array_container_t* container2) {
   27|    423|    if (run_container_cardinality(container1) > container2->cardinality)
  ------------------
  |  Branch (27:9): [True: 171, False: 252]
  ------------------
   28|    171|        return false;
   29|    252|    int32_t start_pos = -1, stop_pos = -1;
   30|    252|    for (int i = 0; i < container1->n_runs; ++i) {
  ------------------
  |  Branch (30:21): [True: 252, False: 0]
  ------------------
   31|    252|        int32_t start = container1->runs[i].value;
   32|    252|        int32_t stop = start + container1->runs[i].length;
   33|    252|        start_pos = advanceUntil(container2->array, stop_pos,
   34|    252|                                 container2->cardinality, start);
   35|    252|        stop_pos = advanceUntil(container2->array, stop_pos,
   36|    252|                                container2->cardinality, stop);
   37|    252|        if (stop_pos == container2->cardinality) {
  ------------------
  |  Branch (37:13): [True: 5, False: 247]
  ------------------
   38|      5|            return false;
   39|    247|        } else if (stop_pos - start_pos != stop - start ||
  ------------------
  |  Branch (39:20): [True: 87, False: 160]
  ------------------
   40|    160|                   container2->array[start_pos] != start ||
  ------------------
  |  Branch (40:20): [True: 160, False: 0]
  ------------------
   41|    247|                   container2->array[stop_pos] != stop) {
  ------------------
  |  Branch (41:20): [True: 0, False: 0]
  ------------------
   42|    247|            return false;
   43|    247|        }
   44|    252|    }
   45|      0|    return true;
   46|    252|}
array_container_is_subset_run:
   49|  2.25k|                                   const run_container_t* container2) {
   50|  2.25k|    if (container1->cardinality > run_container_cardinality(container2))
  ------------------
  |  Branch (50:9): [True: 161, False: 2.09k]
  ------------------
   51|    161|        return false;
   52|  2.09k|    int i_array = 0, i_run = 0;
   53|  7.03k|    while (i_array < container1->cardinality && i_run < container2->n_runs) {
  ------------------
  |  Branch (53:12): [True: 7.03k, False: 0]
  |  Branch (53:49): [True: 7.02k, False: 14]
  ------------------
   54|  7.02k|        uint32_t start = container2->runs[i_run].value;
   55|  7.02k|        uint32_t stop = start + container2->runs[i_run].length;
   56|  7.02k|        if (container1->array[i_array] < start) {
  ------------------
  |  Branch (56:13): [True: 2.08k, False: 4.94k]
  ------------------
   57|  2.08k|            return false;
   58|  4.94k|        } else if (container1->array[i_array] > stop) {
  ------------------
  |  Branch (58:20): [True: 4.94k, False: 0]
  ------------------
   59|  4.94k|            i_run++;
   60|  4.94k|        } else {  // the value of the array is in the run
   61|      0|            i_array++;
   62|      0|        }
   63|  7.02k|    }
   64|     14|    if (i_array == container1->cardinality) {
  ------------------
  |  Branch (64:9): [True: 0, False: 14]
  ------------------
   65|      0|        return true;
   66|     14|    } else {
   67|       |        return false;
   68|     14|    }
   69|     14|}

array_bitset_container_union:
   24|  1.20k|                                  bitset_container_t *dst) {
   25|  1.20k|    if (src_2 != dst) bitset_container_copy(src_2, dst);
  ------------------
  |  Branch (25:9): [True: 1.20k, False: 0]
  ------------------
   26|  1.20k|    dst->cardinality = (int32_t)bitset_set_list_withcard(
   27|  1.20k|        dst->words, dst->cardinality, src_1->array, src_1->cardinality);
   28|  1.20k|}
run_bitset_container_union:
   43|  1.38k|                                bitset_container_t *dst) {
   44|  1.38k|    assert(!run_container_is_full(src_1));  // catch this case upstream
   45|  1.38k|    if (src_2 != dst) bitset_container_copy(src_2, dst);
  ------------------
  |  Branch (45:9): [True: 1.38k, False: 0]
  ------------------
   46|   114k|    for (int32_t rlepos = 0; rlepos < src_1->n_runs; ++rlepos) {
  ------------------
  |  Branch (46:30): [True: 112k, False: 1.38k]
  ------------------
   47|   112k|        rle16_t rle = src_1->runs[rlepos];
   48|   112k|        bitset_set_lenrange(dst->words, rle.value, rle.length);
   49|   112k|    }
   50|  1.38k|    dst->cardinality = bitset_container_compute_cardinality(dst);
   51|  1.38k|}
array_run_container_union:
   68|  2.75k|                               run_container_t *dst) {
   69|  2.75k|    if (run_container_is_full(src_2)) {
  ------------------
  |  Branch (69:9): [True: 115, False: 2.64k]
  ------------------
   70|    115|        run_container_copy(src_2, dst);
   71|    115|        return;
   72|    115|    }
   73|       |    // TODO: see whether the "2*" is spurious
   74|  2.64k|    run_container_grow(dst, 2 * (src_1->cardinality + src_2->n_runs), false);
   75|  2.64k|    int32_t rlepos = 0;
   76|  2.64k|    int32_t arraypos = 0;
   77|  2.64k|    rle16_t previousrle;
   78|  2.64k|    if (src_2->runs[rlepos].value <= src_1->array[arraypos]) {
  ------------------
  |  Branch (78:9): [True: 1.99k, False: 642]
  ------------------
   79|  1.99k|        previousrle = run_container_append_first(dst, src_2->runs[rlepos]);
   80|  1.99k|        rlepos++;
   81|  1.99k|    } else {
   82|    642|        previousrle =
   83|    642|            run_container_append_value_first(dst, src_1->array[arraypos]);
   84|    642|        arraypos++;
   85|    642|    }
   86|   477k|    while ((rlepos < src_2->n_runs) && (arraypos < src_1->cardinality)) {
  ------------------
  |  Branch (86:12): [True: 475k, False: 1.73k]
  |  Branch (86:40): [True: 474k, False: 910]
  ------------------
   87|   474k|        if (src_2->runs[rlepos].value <= src_1->array[arraypos]) {
  ------------------
  |  Branch (87:13): [True: 155k, False: 318k]
  ------------------
   88|   155k|            run_container_append(dst, src_2->runs[rlepos], &previousrle);
   89|   155k|            rlepos++;
   90|   318k|        } else {
   91|   318k|            run_container_append_value(dst, src_1->array[arraypos],
   92|   318k|                                       &previousrle);
   93|   318k|            arraypos++;
   94|   318k|        }
   95|   474k|    }
   96|  2.64k|    if (arraypos < src_1->cardinality) {
  ------------------
  |  Branch (96:9): [True: 1.73k, False: 910]
  ------------------
   97|   174k|        while (arraypos < src_1->cardinality) {
  ------------------
  |  Branch (97:16): [True: 172k, False: 1.73k]
  ------------------
   98|   172k|            run_container_append_value(dst, src_1->array[arraypos],
   99|   172k|                                       &previousrle);
  100|   172k|            arraypos++;
  101|   172k|        }
  102|  1.73k|    } else {
  103|  6.21k|        while (rlepos < src_2->n_runs) {
  ------------------
  |  Branch (103:16): [True: 5.30k, False: 910]
  ------------------
  104|  5.30k|            run_container_append(dst, src_2->runs[rlepos], &previousrle);
  105|  5.30k|            rlepos++;
  106|  5.30k|        }
  107|    910|    }
  108|  2.64k|}
array_run_container_inplace_union:
  111|    248|                                       run_container_t *src_2) {
  112|    248|    if (run_container_is_full(src_2)) {
  ------------------
  |  Branch (112:9): [True: 0, False: 248]
  ------------------
  113|      0|        return;
  114|      0|    }
  115|    248|    const int32_t maxoutput = src_1->cardinality + src_2->n_runs;
  116|    248|    const int32_t neededcapacity = maxoutput + src_2->n_runs;
  117|    248|    if (src_2->capacity < neededcapacity)
  ------------------
  |  Branch (117:9): [True: 248, False: 0]
  ------------------
  118|    248|        run_container_grow(src_2, neededcapacity, true);
  119|    248|    memmove(src_2->runs + maxoutput, src_2->runs,
  120|    248|            src_2->n_runs * sizeof(rle16_t));
  121|    248|    rle16_t *inputsrc2 = src_2->runs + maxoutput;
  122|    248|    int32_t rlepos = 0;
  123|    248|    int32_t arraypos = 0;
  124|    248|    int src2nruns = src_2->n_runs;
  125|    248|    src_2->n_runs = 0;
  126|       |
  127|    248|    rle16_t previousrle;
  128|       |
  129|    248|    if (inputsrc2[rlepos].value <= src_1->array[arraypos]) {
  ------------------
  |  Branch (129:9): [True: 206, False: 42]
  ------------------
  130|    206|        previousrle = run_container_append_first(src_2, inputsrc2[rlepos]);
  131|    206|        rlepos++;
  132|    206|    } else {
  133|     42|        previousrle =
  134|     42|            run_container_append_value_first(src_2, src_1->array[arraypos]);
  135|     42|        arraypos++;
  136|     42|    }
  137|       |
  138|  49.9k|    while ((rlepos < src2nruns) && (arraypos < src_1->cardinality)) {
  ------------------
  |  Branch (138:12): [True: 49.7k, False: 248]
  |  Branch (138:36): [True: 49.7k, False: 0]
  ------------------
  139|  49.7k|        if (inputsrc2[rlepos].value <= src_1->array[arraypos]) {
  ------------------
  |  Branch (139:13): [True: 12.6k, False: 37.0k]
  ------------------
  140|  12.6k|            run_container_append(src_2, inputsrc2[rlepos], &previousrle);
  141|  12.6k|            rlepos++;
  142|  37.0k|        } else {
  143|  37.0k|            run_container_append_value(src_2, src_1->array[arraypos],
  144|  37.0k|                                       &previousrle);
  145|  37.0k|            arraypos++;
  146|  37.0k|        }
  147|  49.7k|    }
  148|    248|    if (arraypos < src_1->cardinality) {
  ------------------
  |  Branch (148:9): [True: 248, False: 0]
  ------------------
  149|  2.55k|        while (arraypos < src_1->cardinality) {
  ------------------
  |  Branch (149:16): [True: 2.30k, False: 248]
  ------------------
  150|  2.30k|            run_container_append_value(src_2, src_1->array[arraypos],
  151|  2.30k|                                       &previousrle);
  152|  2.30k|            arraypos++;
  153|  2.30k|        }
  154|    248|    } else {
  155|      0|        while (rlepos < src2nruns) {
  ------------------
  |  Branch (155:16): [True: 0, False: 0]
  ------------------
  156|      0|            run_container_append(src_2, inputsrc2[rlepos], &previousrle);
  157|      0|            rlepos++;
  158|      0|        }
  159|      0|    }
  160|    248|}
array_array_container_union:
  164|  2.32k|                                 container_t **dst) {
  165|  2.32k|    int totalCardinality = src_1->cardinality + src_2->cardinality;
  166|  2.32k|    if (totalCardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (166:9): [True: 2.19k, False: 126]
  ------------------
  167|  2.19k|        *dst = array_container_create_given_capacity(totalCardinality);
  168|  2.19k|        if (*dst != NULL) {
  ------------------
  |  Branch (168:13): [True: 2.19k, False: 0]
  ------------------
  169|  2.19k|            array_container_union(src_1, src_2, CAST_array(*dst));
  ------------------
  |  |   54|  2.19k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  2.19k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  170|  2.19k|        } else {
  171|      0|            return true;  // otherwise failure won't be caught
  172|      0|        }
  173|  2.19k|        return false;  // not a bitset
  174|  2.19k|    }
  175|    126|    *dst = bitset_container_create();
  176|    126|    bool returnval = true;  // expect a bitset
  177|    126|    if (*dst != NULL) {
  ------------------
  |  Branch (177:9): [True: 126, False: 0]
  ------------------
  178|    126|        bitset_container_t *ourbitset = CAST_bitset(*dst);
  ------------------
  |  |   52|    126|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    126|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  179|    126|        bitset_set_list(ourbitset->words, src_1->array, src_1->cardinality);
  180|    126|        ourbitset->cardinality = (int32_t)bitset_set_list_withcard(
  181|    126|            ourbitset->words, src_1->cardinality, src_2->array,
  182|    126|            src_2->cardinality);
  183|    126|        if (ourbitset->cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (183:13): [True: 74, False: 52]
  ------------------
  184|       |            // need to convert!
  185|     74|            *dst = array_container_from_bitset(ourbitset);
  186|     74|            bitset_container_free(ourbitset);
  187|       |            returnval = false;  // not going to be a bitset
  188|     74|        }
  189|    126|    }
  190|    126|    return returnval;
  191|  2.32k|}
array_array_container_inplace_union:
  195|  2.51k|                                         container_t **dst) {
  196|  2.51k|    int totalCardinality = src_1->cardinality + src_2->cardinality;
  197|  2.51k|    *dst = NULL;
  198|  2.51k|    if (totalCardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (198:9): [True: 2.41k, False: 96]
  ------------------
  199|  2.41k|        if (src_1->capacity < totalCardinality) {
  ------------------
  |  Branch (199:13): [True: 2.41k, False: 0]
  ------------------
  200|  2.41k|            *dst = array_container_create_given_capacity(
  201|  2.41k|                2 * totalCardinality);  // be purposefully generous
  202|  2.41k|            if (*dst != NULL) {
  ------------------
  |  Branch (202:17): [True: 2.41k, False: 0]
  ------------------
  203|  2.41k|                array_container_union(src_1, src_2, CAST_array(*dst));
  ------------------
  |  |   54|  2.41k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  2.41k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  204|  2.41k|            } else {
  205|      0|                return true;  // otherwise failure won't be caught
  206|      0|            }
  207|  2.41k|            return false;  // not a bitset
  208|  2.41k|        } else {
  209|      0|            memmove(src_1->array + src_2->cardinality, src_1->array,
  210|      0|                    src_1->cardinality * sizeof(uint16_t));
  211|       |            // In theory, we could use fast_union_uint16, but it is unsafe. It
  212|       |            // fails with Intel compilers in particular.
  213|       |            // https://github.com/RoaringBitmap/CRoaring/pull/452
  214|       |            // See report https://github.com/RoaringBitmap/CRoaring/issues/476
  215|      0|            src_1->cardinality = (int32_t)union_uint16(
  216|      0|                src_1->array + src_2->cardinality, src_1->cardinality,
  217|      0|                src_2->array, src_2->cardinality, src_1->array);
  218|      0|            return false;  // not a bitset
  219|      0|        }
  220|  2.41k|    }
  221|     96|    *dst = bitset_container_create();
  222|     96|    bool returnval = true;  // expect a bitset
  223|     96|    if (*dst != NULL) {
  ------------------
  |  Branch (223:9): [True: 96, False: 0]
  ------------------
  224|     96|        bitset_container_t *ourbitset = CAST_bitset(*dst);
  ------------------
  |  |   52|     96|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     96|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  225|     96|        bitset_set_list(ourbitset->words, src_1->array, src_1->cardinality);
  226|     96|        ourbitset->cardinality = (int32_t)bitset_set_list_withcard(
  227|     96|            ourbitset->words, src_1->cardinality, src_2->array,
  228|     96|            src_2->cardinality);
  229|     96|        if (ourbitset->cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (229:13): [True: 96, False: 0]
  ------------------
  230|       |            // need to convert!
  231|     96|            if (src_1->capacity < ourbitset->cardinality) {
  ------------------
  |  Branch (231:17): [True: 96, False: 0]
  ------------------
  232|     96|                array_container_grow(src_1, ourbitset->cardinality, false);
  233|     96|            }
  234|       |
  235|     96|            bitset_extract_setbits_uint16(ourbitset->words,
  236|     96|                                          BITSET_CONTAINER_SIZE_IN_WORDS,
  237|     96|                                          src_1->array, 0);
  238|     96|            src_1->cardinality = ourbitset->cardinality;
  239|     96|            *dst = src_1;
  240|     96|            bitset_container_free(ourbitset);
  241|       |            returnval = false;  // not going to be a bitset
  242|     96|        }
  243|     96|    }
  244|     96|    return returnval;
  245|  2.51k|}

array_bitset_container_xor:
   25|    673|                                container_t **dst) {
   26|    673|    bitset_container_t *result = bitset_container_create();
   27|    673|    bitset_container_copy(src_2, result);
   28|    673|    result->cardinality = (int32_t)bitset_flip_list_withcard(
   29|    673|        result->words, result->cardinality, src_1->array, src_1->cardinality);
   30|       |
   31|       |    // do required type conversions.
   32|    673|    if (result->cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (32:9): [True: 153, False: 520]
  ------------------
   33|    153|        *dst = array_container_from_bitset(result);
   34|    153|        bitset_container_free(result);
   35|    153|        return false;  // not bitset
   36|    153|    }
   37|    520|    *dst = result;
   38|       |    return true;  // bitset
   39|    673|}
run_bitset_container_xor:
   63|    782|                              container_t **dst) {
   64|    782|    bitset_container_t *result = bitset_container_create();
   65|       |
   66|    782|    bitset_container_copy(src_2, result);
   67|  60.6k|    for (int32_t rlepos = 0; rlepos < src_1->n_runs; ++rlepos) {
  ------------------
  |  Branch (67:30): [True: 59.8k, False: 782]
  ------------------
   68|  59.8k|        rle16_t rle = src_1->runs[rlepos];
   69|  59.8k|        bitset_flip_range(result->words, rle.value,
   70|  59.8k|                          rle.value + rle.length + UINT32_C(1));
   71|  59.8k|    }
   72|    782|    result->cardinality = bitset_container_compute_cardinality(result);
   73|       |
   74|    782|    if (result->cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (74:9): [True: 137, False: 645]
  ------------------
   75|    137|        *dst = array_container_from_bitset(result);
   76|    137|        bitset_container_free(result);
   77|    137|        return false;  // not bitset
   78|    137|    }
   79|    645|    *dst = result;
   80|       |    return true;  // bitset
   81|    782|}
array_run_container_xor:
  105|  2.41k|                            const run_container_t *src_2, container_t **dst) {
  106|       |    // semi following Java XOR implementation as of May 2016
  107|       |    // the C OR implementation works quite differently and can return a run
  108|       |    // container
  109|       |    // TODO could optimize for full run containers.
  110|       |
  111|       |    // use of lazy following Java impl.
  112|  2.41k|    const int arbitrary_threshold = 32;
  113|  2.41k|    if (src_1->cardinality < arbitrary_threshold) {
  ------------------
  |  Branch (113:9): [True: 945, False: 1.46k]
  ------------------
  114|    945|        run_container_t *ans = run_container_create();
  115|    945|        array_run_container_lazy_xor(src_1, src_2, ans);  // keeps runs.
  116|    945|        uint8_t typecode_after;
  117|    945|        *dst =
  118|    945|            convert_run_to_efficient_container_and_free(ans, &typecode_after);
  119|    945|        return typecode_after;
  120|    945|    }
  121|       |
  122|  1.46k|    int card = run_container_cardinality(src_2);
  123|  1.46k|    if (card <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (123:9): [True: 1.18k, False: 279]
  ------------------
  124|       |        // Java implementation works with the array, xoring the run elements via
  125|       |        // iterator
  126|  1.18k|        array_container_t *temp = array_container_from_run(src_2);
  127|  1.18k|        bool ret_is_bitset = array_array_container_xor(temp, src_1, dst);
  128|  1.18k|        array_container_free(temp);
  129|  1.18k|        return ret_is_bitset ? BITSET_CONTAINER_TYPE : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   48|      6|#define BITSET_CONTAINER_TYPE 1
  ------------------
                      return ret_is_bitset ? BITSET_CONTAINER_TYPE : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  1.18k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (129:16): [True: 6, False: 1.18k]
  ------------------
  130|       |
  131|  1.18k|    } else {  // guess that it will end up as a bitset
  132|    279|        bitset_container_t *result = bitset_container_from_run(src_2);
  133|    279|        bool is_bitset = bitset_array_container_ixor(result, src_1, dst);
  134|       |        // any necessary type conversion has been done by the ixor
  135|    279|        int retval = (is_bitset ? BITSET_CONTAINER_TYPE : ARRAY_CONTAINER_TYPE);
  ------------------
  |  |   48|    262|#define BITSET_CONTAINER_TYPE 1
  ------------------
                      int retval = (is_bitset ? BITSET_CONTAINER_TYPE : ARRAY_CONTAINER_TYPE);
  ------------------
  |  |   49|     17|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (135:23): [True: 262, False: 17]
  ------------------
  136|    279|        return retval;
  137|    279|    }
  138|  1.46k|}
array_run_container_lazy_xor:
  147|    945|                                  run_container_t *dst) {
  148|    945|    run_container_grow(dst, src_1->cardinality + src_2->n_runs, false);
  149|    945|    int32_t rlepos = 0;
  150|    945|    int32_t arraypos = 0;
  151|    945|    dst->n_runs = 0;
  152|       |
  153|  29.3k|    while ((rlepos < src_2->n_runs) && (arraypos < src_1->cardinality)) {
  ------------------
  |  Branch (153:12): [True: 28.7k, False: 593]
  |  Branch (153:40): [True: 28.4k, False: 352]
  ------------------
  154|  28.4k|        if (src_2->runs[rlepos].value <= src_1->array[arraypos]) {
  ------------------
  |  Branch (154:13): [True: 17.3k, False: 11.1k]
  ------------------
  155|  17.3k|            run_container_smart_append_exclusive(dst, src_2->runs[rlepos].value,
  156|  17.3k|                                                 src_2->runs[rlepos].length);
  157|  17.3k|            rlepos++;
  158|  17.3k|        } else {
  159|  11.1k|            run_container_smart_append_exclusive(dst, src_1->array[arraypos],
  160|  11.1k|                                                 0);
  161|  11.1k|            arraypos++;
  162|  11.1k|        }
  163|  28.4k|    }
  164|  3.51k|    while (arraypos < src_1->cardinality) {
  ------------------
  |  Branch (164:12): [True: 2.56k, False: 945]
  ------------------
  165|  2.56k|        run_container_smart_append_exclusive(dst, src_1->array[arraypos], 0);
  166|  2.56k|        arraypos++;
  167|  2.56k|    }
  168|  8.19k|    while (rlepos < src_2->n_runs) {
  ------------------
  |  Branch (168:12): [True: 7.25k, False: 945]
  ------------------
  169|  7.25k|        run_container_smart_append_exclusive(dst, src_2->runs[rlepos].value,
  170|  7.25k|                                             src_2->runs[rlepos].length);
  171|  7.25k|        rlepos++;
  172|  7.25k|    }
  173|    945|}
run_run_container_xor:
  180|  61.2k|                          const run_container_t *src_2, container_t **dst) {
  181|  61.2k|    run_container_t *ans = run_container_create();
  182|  61.2k|    run_container_xor(src_1, src_2, ans);
  183|  61.2k|    uint8_t typecode_after;
  184|  61.2k|    *dst = convert_run_to_efficient_container_and_free(ans, &typecode_after);
  185|  61.2k|    return typecode_after;
  186|  61.2k|}
array_array_container_xor:
  198|  8.62k|                               container_t **dst) {
  199|  8.62k|    int totalCardinality =
  200|  8.62k|        src_1->cardinality + src_2->cardinality;  // upper bound
  201|  8.62k|    if (totalCardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (201:9): [True: 8.05k, False: 572]
  ------------------
  202|  8.05k|        *dst = array_container_create_given_capacity(totalCardinality);
  203|  8.05k|        array_container_xor(src_1, src_2, CAST_array(*dst));
  ------------------
  |  |   54|  8.05k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  8.05k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  204|  8.05k|        return false;  // not a bitset
  205|  8.05k|    }
  206|    572|    *dst = bitset_container_from_array(src_1);
  207|    572|    bool returnval = true;  // expect a bitset
  208|    572|    bitset_container_t *ourbitset = CAST_bitset(*dst);
  ------------------
  |  |   52|    572|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    572|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  209|    572|    ourbitset->cardinality = (uint32_t)bitset_flip_list_withcard(
  210|    572|        ourbitset->words, src_1->cardinality, src_2->array, src_2->cardinality);
  211|    572|    if (ourbitset->cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (211:9): [True: 558, False: 14]
  ------------------
  212|       |        // need to convert!
  213|    558|        *dst = array_container_from_bitset(ourbitset);
  214|    558|        bitset_container_free(ourbitset);
  215|    558|        returnval = false;  // not going to be a bitset
  216|    558|    }
  217|       |
  218|    572|    return returnval;
  219|  8.62k|}
bitset_array_container_ixor:
  284|    279|                                 container_t **dst) {
  285|    279|    *dst = src_1;
  286|    279|    src_1->cardinality = (uint32_t)bitset_flip_list_withcard(
  287|    279|        src_1->words, src_1->cardinality, src_2->array, src_2->cardinality);
  288|       |
  289|    279|    if (src_1->cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (289:9): [True: 17, False: 262]
  ------------------
  290|     17|        *dst = array_container_from_bitset(src_1);
  291|     17|        bitset_container_free(src_1);
  292|     17|        return false;  // not bitset
  293|     17|    } else
  294|    262|        return true;
  295|    279|}
bitset_bitset_container_ixor:
  304|  1.57k|                                  container_t **dst) {
  305|  1.57k|    int card = bitset_container_xor(src_1, src_2, src_1);
  306|  1.57k|    if (card <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (306:9): [True: 1.57k, False: 0]
  ------------------
  307|  1.57k|        *dst = array_container_from_bitset(src_1);
  308|  1.57k|        bitset_container_free(src_1);
  309|  1.57k|        return false;  // not bitset
  310|  1.57k|    } else {
  311|      0|        *dst = src_1;
  312|       |        return true;
  313|      0|    }
  314|  1.57k|}
array_bitset_container_ixor:
  318|     98|                                 container_t **dst) {
  319|       |    bool ans = array_bitset_container_xor(src_1, src_2, dst);
  320|     98|    array_container_free(src_1);
  321|     98|    return ans;
  322|     98|}
run_bitset_container_ixor:
  333|     18|                               container_t **dst) {
  334|       |    bool ans = run_bitset_container_xor(src_1, src_2, dst);
  335|     18|    run_container_free(src_1);
  336|     18|    return ans;
  337|     18|}
bitset_run_container_ixor:
  341|     73|                               container_t **dst) {
  342|       |    bool ans = run_bitset_container_xor(src_2, src_1, dst);
  343|     73|    bitset_container_free(src_1);
  344|     73|    return ans;
  345|     73|}
array_run_container_ixor:
  352|    269|                             const run_container_t *src_2, container_t **dst) {
  353|    269|    int ans = array_run_container_xor(src_1, src_2, dst);
  354|    269|    array_container_free(src_1);
  355|    269|    return ans;
  356|    269|}
run_array_container_ixor:
  360|     53|                             container_t **dst) {
  361|     53|    int ans = array_run_container_xor(src_2, src_1, dst);
  362|     53|    run_container_free(src_1);
  363|     53|    return ans;
  364|     53|}
array_array_container_ixor:
  368|  5.11k|                                container_t **dst) {
  369|       |    bool ans = array_array_container_xor(src_1, src_2, dst);
  370|  5.11k|    array_container_free(src_1);
  371|  5.11k|    return ans;
  372|  5.11k|}
run_run_container_ixor:
  375|  60.5k|                           container_t **dst) {
  376|  60.5k|    int ans = run_run_container_xor(src_1, src_2, dst);
  377|  60.5k|    run_container_free(src_1);
  378|  60.5k|    return ans;
  379|  60.5k|}

run_container_add:
   39|   413k|bool run_container_add(run_container_t *run, uint16_t pos) {
   40|   413k|    int32_t index = interleavedBinarySearch(run->runs, run->n_runs, pos);
   41|   413k|    if (index >= 0) return false;  // already there
  ------------------
  |  Branch (41:9): [True: 183k, False: 229k]
  ------------------
   42|   229k|    index = -index - 2;            // points to preceding value, possibly -1
   43|   229k|    if (index >= 0) {              // possible match
  ------------------
  |  Branch (43:9): [True: 229k, False: 380]
  ------------------
   44|   229k|        int32_t offset = pos - run->runs[index].value;
   45|   229k|        int32_t le = run->runs[index].length;
   46|   229k|        if (offset <= le) return false;  // already there
  ------------------
  |  Branch (46:13): [True: 137k, False: 91.8k]
  ------------------
   47|  91.8k|        if (offset == le + 1) {
  ------------------
  |  Branch (47:13): [True: 14.5k, False: 77.3k]
  ------------------
   48|       |            // we may need to fuse
   49|  14.5k|            if (index + 1 < run->n_runs) {
  ------------------
  |  Branch (49:17): [True: 14.2k, False: 287]
  ------------------
   50|  14.2k|                if (run->runs[index + 1].value == pos + 1) {
  ------------------
  |  Branch (50:21): [True: 6.57k, False: 7.70k]
  ------------------
   51|       |                    // indeed fusion is needed
   52|  6.57k|                    run->runs[index].length = run->runs[index + 1].value +
   53|  6.57k|                                              run->runs[index + 1].length -
   54|  6.57k|                                              run->runs[index].value;
   55|  6.57k|                    recoverRoomAtIndex(run, (uint16_t)(index + 1));
   56|  6.57k|                    return true;
   57|  6.57k|                }
   58|  14.2k|            }
   59|  7.99k|            run->runs[index].length++;
   60|  7.99k|            return true;
   61|  14.5k|        }
   62|  77.3k|        if (index + 1 < run->n_runs) {
  ------------------
  |  Branch (62:13): [True: 75.4k, False: 1.83k]
  ------------------
   63|       |            // we may need to fuse
   64|  75.4k|            if (run->runs[index + 1].value == pos + 1) {
  ------------------
  |  Branch (64:17): [True: 32.9k, False: 42.5k]
  ------------------
   65|       |                // indeed fusion is needed
   66|  32.9k|                run->runs[index + 1].value = pos;
   67|  32.9k|                run->runs[index + 1].length = run->runs[index + 1].length + 1;
   68|  32.9k|                return true;
   69|  32.9k|            }
   70|  75.4k|        }
   71|  77.3k|    }
   72|  44.7k|    if (index == -1) {
  ------------------
  |  Branch (72:9): [True: 380, False: 44.3k]
  ------------------
   73|       |        // we may need to extend the first run
   74|    380|        if (0 < run->n_runs) {
  ------------------
  |  Branch (74:13): [True: 380, False: 0]
  ------------------
   75|    380|            if (run->runs[0].value == pos + 1) {
  ------------------
  |  Branch (75:17): [True: 260, False: 120]
  ------------------
   76|    260|                run->runs[0].length++;
   77|    260|                run->runs[0].value--;
   78|    260|                return true;
   79|    260|            }
   80|    380|        }
   81|    380|    }
   82|  44.4k|    makeRoomAtIndex(run, (uint16_t)(index + 1));
   83|  44.4k|    run->runs[index + 1].value = pos;
   84|  44.4k|    run->runs[index + 1].length = 0;
   85|       |    return true;
   86|  44.7k|}
run_container_create_given_capacity:
   89|   406k|run_container_t *run_container_create_given_capacity(int32_t size) {
   90|   406k|    run_container_t *run;
   91|       |    /* Allocate the run container itself. */
   92|   406k|    if ((run = (run_container_t *)roaring_malloc(sizeof(run_container_t))) ==
  ------------------
  |  Branch (92:9): [True: 0, False: 406k]
  ------------------
   93|   406k|        NULL) {
   94|      0|        return NULL;
   95|      0|    }
   96|   406k|    if (size <= 0) {  // we don't want to rely on malloc(0)
  ------------------
  |  Branch (96:9): [True: 128k, False: 277k]
  ------------------
   97|   128k|        run->runs = NULL;
   98|   277k|    } else if ((run->runs = (rle16_t *)roaring_malloc(sizeof(rle16_t) *
  ------------------
  |  Branch (98:16): [True: 0, False: 277k]
  ------------------
   99|   277k|                                                      size)) == NULL) {
  100|      0|        roaring_free(run);
  101|      0|        return NULL;
  102|      0|    }
  103|   406k|    run->capacity = size;
  104|   406k|    run->n_runs = 0;
  105|   406k|    return run;
  106|   406k|}
run_container_shrink_to_fit:
  108|  2.67k|int run_container_shrink_to_fit(run_container_t *src) {
  109|  2.67k|    if (src->n_runs == src->capacity) return 0;  // nothing to do
  ------------------
  |  Branch (109:9): [True: 2.67k, False: 0]
  ------------------
  110|      0|    int savings = src->capacity - src->n_runs;
  111|      0|    src->capacity = src->n_runs;
  112|      0|    rle16_t *oldruns = src->runs;
  113|      0|    src->runs =
  114|      0|        (rle16_t *)roaring_realloc(oldruns, src->capacity * sizeof(rle16_t));
  115|      0|    if (src->runs == NULL) roaring_free(oldruns);  // should never happen?
  ------------------
  |  Branch (115:9): [True: 0, False: 0]
  ------------------
  116|      0|    return savings;
  117|  2.67k|}
run_container_create:
  119|   128k|run_container_t *run_container_create(void) {
  120|   128k|    return run_container_create_given_capacity(RUN_DEFAULT_INIT_SIZE);
  121|   128k|}
run_container_clone:
  124|   181k|run_container_t *run_container_clone(const run_container_t *src) {
  125|   181k|    run_container_t *run = run_container_create_given_capacity(src->capacity);
  126|   181k|    if (run == NULL) return NULL;
  ------------------
  |  Branch (126:9): [True: 0, False: 181k]
  ------------------
  127|   181k|    run->capacity = src->capacity;
  128|   181k|    run->n_runs = src->n_runs;
  129|   181k|    memcpy(run->runs, src->runs, src->n_runs * sizeof(rle16_t));
  130|   181k|    return run;
  131|   181k|}
run_container_free:
  193|   406k|void run_container_free(run_container_t *run) {
  194|   406k|    if (run == NULL) return;
  ------------------
  |  Branch (194:9): [True: 0, False: 406k]
  ------------------
  195|   406k|    roaring_free(run->runs);
  196|   406k|    roaring_free(run);
  197|   406k|}
run_container_grow:
  199|   134k|void run_container_grow(run_container_t *run, int32_t min, bool copy) {
  200|   134k|    int32_t newCapacity = (run->capacity == 0)   ? RUN_DEFAULT_INIT_SIZE
  ------------------
  |  Branch (200:27): [True: 128k, False: 5.22k]
  ------------------
  201|   134k|                          : run->capacity < 64   ? run->capacity * 2
  ------------------
  |  Branch (201:29): [True: 3.64k, False: 1.58k]
  ------------------
  202|  5.22k|                          : run->capacity < 1024 ? run->capacity * 3 / 2
  ------------------
  |  Branch (202:29): [True: 1.58k, False: 0]
  ------------------
  203|  1.58k|                                                 : run->capacity * 5 / 4;
  204|   134k|    if (newCapacity < min) newCapacity = min;
  ------------------
  |  Branch (204:9): [True: 130k, False: 3.27k]
  ------------------
  205|   134k|    run->capacity = newCapacity;
  206|   134k|    assert(run->capacity >= min);
  207|   134k|    if (copy) {
  ------------------
  |  Branch (207:9): [True: 5.22k, False: 128k]
  ------------------
  208|  5.22k|        rle16_t *oldruns = run->runs;
  209|  5.22k|        run->runs = (rle16_t *)roaring_realloc(oldruns,
  210|  5.22k|                                               run->capacity * sizeof(rle16_t));
  211|  5.22k|        if (run->runs == NULL) roaring_free(oldruns);
  ------------------
  |  Branch (211:13): [True: 0, False: 5.22k]
  ------------------
  212|   128k|    } else {
  213|   128k|        roaring_free(run->runs);
  214|   128k|        run->runs = (rle16_t *)roaring_malloc(run->capacity * sizeof(rle16_t));
  215|   128k|    }
  216|       |    // We may have run->runs == NULL.
  217|   134k|}
run_container_copy:
  220|  58.8k|void run_container_copy(const run_container_t *src, run_container_t *dst) {
  221|  58.8k|    const int32_t n_runs = src->n_runs;
  222|  58.8k|    if (src->n_runs > dst->capacity) {
  ------------------
  |  Branch (222:9): [True: 58.8k, False: 32]
  ------------------
  223|       |        run_container_grow(dst, n_runs, false);
  224|  58.8k|    }
  225|  58.8k|    dst->n_runs = n_runs;
  226|  58.8k|    memcpy(dst->runs, src->runs, sizeof(rle16_t) * n_runs);
  227|  58.8k|}
run_container_union:
  232|    680|                         const run_container_t *src_2, run_container_t *dst) {
  233|       |    // TODO: this could be a lot more efficient
  234|       |
  235|       |    // we start out with inexpensive checks
  236|    680|    const bool if1 = run_container_is_full(src_1);
  237|    680|    const bool if2 = run_container_is_full(src_2);
  238|    680|    if (if1 || if2) {
  ------------------
  |  Branch (238:9): [True: 0, False: 680]
  |  Branch (238:16): [True: 16, False: 664]
  ------------------
  239|     16|        if (if1) {
  ------------------
  |  Branch (239:13): [True: 0, False: 16]
  ------------------
  240|      0|            run_container_copy(src_1, dst);
  241|      0|            return;
  242|      0|        }
  243|     16|        if (if2) {
  ------------------
  |  Branch (243:13): [True: 16, False: 0]
  ------------------
  244|     16|            run_container_copy(src_2, dst);
  245|     16|            return;
  246|     16|        }
  247|     16|    }
  248|    664|    const int32_t neededcapacity = src_1->n_runs + src_2->n_runs;
  249|    664|    if (dst->capacity < neededcapacity)
  ------------------
  |  Branch (249:9): [True: 664, False: 0]
  ------------------
  250|    664|        run_container_grow(dst, neededcapacity, false);
  251|    664|    dst->n_runs = 0;
  252|    664|    int32_t rlepos = 0;
  253|    664|    int32_t xrlepos = 0;
  254|       |
  255|    664|    rle16_t previousrle;
  256|    664|    if (src_1->runs[rlepos].value <= src_2->runs[xrlepos].value) {
  ------------------
  |  Branch (256:9): [True: 604, False: 60]
  ------------------
  257|    604|        previousrle = run_container_append_first(dst, src_1->runs[rlepos]);
  258|    604|        rlepos++;
  259|    604|    } else {
  260|     60|        previousrle = run_container_append_first(dst, src_2->runs[xrlepos]);
  261|     60|        xrlepos++;
  262|     60|    }
  263|       |
  264|  85.0k|    while ((xrlepos < src_2->n_runs) && (rlepos < src_1->n_runs)) {
  ------------------
  |  Branch (264:12): [True: 84.7k, False: 283]
  |  Branch (264:41): [True: 84.4k, False: 381]
  ------------------
  265|  84.4k|        rle16_t newrl;
  266|  84.4k|        if (src_1->runs[rlepos].value <= src_2->runs[xrlepos].value) {
  ------------------
  |  Branch (266:13): [True: 46.0k, False: 38.3k]
  ------------------
  267|  46.0k|            newrl = src_1->runs[rlepos];
  268|  46.0k|            rlepos++;
  269|  46.0k|        } else {
  270|  38.3k|            newrl = src_2->runs[xrlepos];
  271|  38.3k|            xrlepos++;
  272|  38.3k|        }
  273|  84.4k|        run_container_append(dst, newrl, &previousrle);
  274|  84.4k|    }
  275|  1.61k|    while (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (275:12): [True: 950, False: 664]
  ------------------
  276|    950|        run_container_append(dst, src_2->runs[xrlepos], &previousrle);
  277|    950|        xrlepos++;
  278|    950|    }
  279|  11.1k|    while (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (279:12): [True: 10.5k, False: 664]
  ------------------
  280|  10.5k|        run_container_append(dst, src_1->runs[rlepos], &previousrle);
  281|  10.5k|        rlepos++;
  282|  10.5k|    }
  283|    664|}
run_container_union_inplace:
  288|  1.73k|                                 const run_container_t *src_2) {
  289|       |    // TODO: this could be a lot more efficient
  290|       |
  291|       |    // we start out with inexpensive checks
  292|  1.73k|    const bool if1 = run_container_is_full(src_1);
  293|  1.73k|    const bool if2 = run_container_is_full(src_2);
  294|  1.73k|    if (if1 || if2) {
  ------------------
  |  Branch (294:9): [True: 0, False: 1.73k]
  |  Branch (294:16): [True: 32, False: 1.70k]
  ------------------
  295|     32|        if (if1) {
  ------------------
  |  Branch (295:13): [True: 0, False: 32]
  ------------------
  296|      0|            return;
  297|      0|        }
  298|     32|        if (if2) {
  ------------------
  |  Branch (298:13): [True: 32, False: 0]
  ------------------
  299|     32|            run_container_copy(src_2, src_1);
  300|     32|            return;
  301|     32|        }
  302|     32|    }
  303|       |    // we move the data to the end of the current array
  304|  1.70k|    const int32_t maxoutput = src_1->n_runs + src_2->n_runs;
  305|  1.70k|    const int32_t neededcapacity = maxoutput + src_1->n_runs;
  306|  1.70k|    if (src_1->capacity < neededcapacity)
  ------------------
  |  Branch (306:9): [True: 1.70k, False: 0]
  ------------------
  307|  1.70k|        run_container_grow(src_1, neededcapacity, true);
  308|  1.70k|    memmove(src_1->runs + maxoutput, src_1->runs,
  309|  1.70k|            src_1->n_runs * sizeof(rle16_t));
  310|  1.70k|    rle16_t *inputsrc1 = src_1->runs + maxoutput;
  311|  1.70k|    const int32_t input1nruns = src_1->n_runs;
  312|  1.70k|    src_1->n_runs = 0;
  313|  1.70k|    int32_t rlepos = 0;
  314|  1.70k|    int32_t xrlepos = 0;
  315|       |
  316|  1.70k|    rle16_t previousrle;
  317|  1.70k|    if (inputsrc1[rlepos].value <= src_2->runs[xrlepos].value) {
  ------------------
  |  Branch (317:9): [True: 1.61k, False: 90]
  ------------------
  318|  1.61k|        previousrle = run_container_append_first(src_1, inputsrc1[rlepos]);
  319|  1.61k|        rlepos++;
  320|  1.61k|    } else {
  321|     90|        previousrle = run_container_append_first(src_1, src_2->runs[xrlepos]);
  322|     90|        xrlepos++;
  323|     90|    }
  324|   200k|    while ((xrlepos < src_2->n_runs) && (rlepos < input1nruns)) {
  ------------------
  |  Branch (324:12): [True: 200k, False: 142]
  |  Branch (324:41): [True: 198k, False: 1.56k]
  ------------------
  325|   198k|        rle16_t newrl;
  326|   198k|        if (inputsrc1[rlepos].value <= src_2->runs[xrlepos].value) {
  ------------------
  |  Branch (326:13): [True: 95.0k, False: 103k]
  ------------------
  327|  95.0k|            newrl = inputsrc1[rlepos];
  328|  95.0k|            rlepos++;
  329|   103k|        } else {
  330|   103k|            newrl = src_2->runs[xrlepos];
  331|   103k|            xrlepos++;
  332|   103k|        }
  333|   198k|        run_container_append(src_1, newrl, &previousrle);
  334|   198k|    }
  335|  4.28k|    while (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (335:12): [True: 2.58k, False: 1.70k]
  ------------------
  336|  2.58k|        run_container_append(src_1, src_2->runs[xrlepos], &previousrle);
  337|  2.58k|        xrlepos++;
  338|  2.58k|    }
  339|  8.73k|    while (rlepos < input1nruns) {
  ------------------
  |  Branch (339:12): [True: 7.02k, False: 1.70k]
  ------------------
  340|  7.02k|        run_container_append(src_1, inputsrc1[rlepos], &previousrle);
  341|  7.02k|        rlepos++;
  342|  7.02k|    }
  343|  1.70k|}
run_container_xor:
  349|  61.2k|                       const run_container_t *src_2, run_container_t *dst) {
  350|       |    // don't bother to convert xor with full range into negation
  351|       |    // since negation is implemented similarly
  352|       |
  353|  61.2k|    const int32_t neededcapacity = src_1->n_runs + src_2->n_runs;
  354|  61.2k|    if (dst->capacity < neededcapacity)
  ------------------
  |  Branch (354:9): [True: 61.2k, False: 0]
  ------------------
  355|  61.2k|        run_container_grow(dst, neededcapacity, false);
  356|       |
  357|  61.2k|    int32_t pos1 = 0;
  358|  61.2k|    int32_t pos2 = 0;
  359|  61.2k|    dst->n_runs = 0;
  360|       |
  361|   239k|    while ((pos1 < src_1->n_runs) && (pos2 < src_2->n_runs)) {
  ------------------
  |  Branch (361:12): [True: 178k, False: 60.9k]
  |  Branch (361:38): [True: 178k, False: 304]
  ------------------
  362|   178k|        if (src_1->runs[pos1].value <= src_2->runs[pos2].value) {
  ------------------
  |  Branch (362:13): [True: 121k, False: 56.4k]
  ------------------
  363|   121k|            run_container_smart_append_exclusive(dst, src_1->runs[pos1].value,
  364|   121k|                                                 src_1->runs[pos1].length);
  365|   121k|            pos1++;
  366|   121k|        } else {
  367|  56.4k|            run_container_smart_append_exclusive(dst, src_2->runs[pos2].value,
  368|  56.4k|                                                 src_2->runs[pos2].length);
  369|  56.4k|            pos2++;
  370|  56.4k|        }
  371|   178k|    }
  372|  73.1k|    while (pos1 < src_1->n_runs) {
  ------------------
  |  Branch (372:12): [True: 11.9k, False: 61.2k]
  ------------------
  373|  11.9k|        run_container_smart_append_exclusive(dst, src_1->runs[pos1].value,
  374|  11.9k|                                             src_1->runs[pos1].length);
  375|  11.9k|        pos1++;
  376|  11.9k|    }
  377|       |
  378|   123k|    while (pos2 < src_2->n_runs) {
  ------------------
  |  Branch (378:12): [True: 62.6k, False: 61.2k]
  ------------------
  379|  62.6k|        run_container_smart_append_exclusive(dst, src_2->runs[pos2].value,
  380|  62.6k|                                             src_2->runs[pos2].length);
  381|  62.6k|        pos2++;
  382|  62.6k|    }
  383|  61.2k|}
run_container_intersection:
  389|  62.2k|                                run_container_t *dst) {
  390|  62.2k|    const bool if1 = run_container_is_full(src_1);
  391|  62.2k|    const bool if2 = run_container_is_full(src_2);
  392|  62.2k|    if (if1 || if2) {
  ------------------
  |  Branch (392:9): [True: 58.6k, False: 3.57k]
  |  Branch (392:16): [True: 16, False: 3.55k]
  ------------------
  393|  58.7k|        if (if1) {
  ------------------
  |  Branch (393:13): [True: 58.6k, False: 16]
  ------------------
  394|  58.6k|            run_container_copy(src_2, dst);
  395|  58.6k|            return;
  396|  58.6k|        }
  397|     16|        if (if2) {
  ------------------
  |  Branch (397:13): [True: 16, False: 0]
  ------------------
  398|     16|            run_container_copy(src_1, dst);
  399|     16|            return;
  400|     16|        }
  401|     16|    }
  402|       |    // TODO: this could be a lot more efficient, could use SIMD optimizations
  403|  3.55k|    const int32_t neededcapacity = src_1->n_runs + src_2->n_runs;
  404|  3.55k|    if (dst->capacity < neededcapacity)
  ------------------
  |  Branch (404:9): [True: 3.55k, False: 0]
  ------------------
  405|  3.55k|        run_container_grow(dst, neededcapacity, false);
  406|  3.55k|    dst->n_runs = 0;
  407|  3.55k|    int32_t rlepos = 0;
  408|  3.55k|    int32_t xrlepos = 0;
  409|  3.55k|    int32_t start = src_1->runs[rlepos].value;
  410|  3.55k|    int32_t end = start + src_1->runs[rlepos].length + 1;
  411|  3.55k|    int32_t xstart = src_2->runs[xrlepos].value;
  412|  3.55k|    int32_t xend = xstart + src_2->runs[xrlepos].length + 1;
  413|   187k|    while ((rlepos < src_1->n_runs) && (xrlepos < src_2->n_runs)) {
  ------------------
  |  Branch (413:12): [True: 184k, False: 3.07k]
  |  Branch (413:40): [True: 183k, False: 483]
  ------------------
  414|   183k|        if (end <= xstart) {
  ------------------
  |  Branch (414:13): [True: 47.0k, False: 136k]
  ------------------
  415|  47.0k|            ++rlepos;
  416|  47.0k|            if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (416:17): [True: 46.9k, False: 88]
  ------------------
  417|  46.9k|                start = src_1->runs[rlepos].value;
  418|  46.9k|                end = start + src_1->runs[rlepos].length + 1;
  419|  46.9k|            }
  420|   136k|        } else if (xend <= start) {
  ------------------
  |  Branch (420:20): [True: 12.4k, False: 124k]
  ------------------
  421|  12.4k|            ++xrlepos;
  422|  12.4k|            if (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (422:17): [True: 12.4k, False: 52]
  ------------------
  423|  12.4k|                xstart = src_2->runs[xrlepos].value;
  424|  12.4k|                xend = xstart + src_2->runs[xrlepos].length + 1;
  425|  12.4k|            }
  426|   124k|        } else {  // they overlap
  427|   124k|            const int32_t lateststart = start > xstart ? start : xstart;
  ------------------
  |  Branch (427:41): [True: 14.4k, False: 109k]
  ------------------
  428|   124k|            int32_t earliestend;
  429|   124k|            if (end == xend) {  // improbable
  ------------------
  |  Branch (429:17): [True: 95.1k, False: 29.2k]
  ------------------
  430|  95.1k|                earliestend = end;
  431|  95.1k|                rlepos++;
  432|  95.1k|                xrlepos++;
  433|  95.1k|                if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (433:21): [True: 92.2k, False: 2.84k]
  ------------------
  434|  92.2k|                    start = src_1->runs[rlepos].value;
  435|  92.2k|                    end = start + src_1->runs[rlepos].length + 1;
  436|  92.2k|                }
  437|  95.1k|                if (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (437:21): [True: 92.0k, False: 3.04k]
  ------------------
  438|  92.0k|                    xstart = src_2->runs[xrlepos].value;
  439|  92.0k|                    xend = xstart + src_2->runs[xrlepos].length + 1;
  440|  92.0k|                }
  441|  95.1k|            } else if (end < xend) {
  ------------------
  |  Branch (441:24): [True: 14.7k, False: 14.5k]
  ------------------
  442|  14.7k|                earliestend = end;
  443|  14.7k|                rlepos++;
  444|  14.7k|                if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (444:21): [True: 14.5k, False: 145]
  ------------------
  445|  14.5k|                    start = src_1->runs[rlepos].value;
  446|  14.5k|                    end = start + src_1->runs[rlepos].length + 1;
  447|  14.5k|                }
  448|       |
  449|  14.7k|            } else {  // end > xend
  450|  14.5k|                earliestend = xend;
  451|  14.5k|                xrlepos++;
  452|  14.5k|                if (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (452:21): [True: 14.3k, False: 161]
  ------------------
  453|  14.3k|                    xstart = src_2->runs[xrlepos].value;
  454|  14.3k|                    xend = xstart + src_2->runs[xrlepos].length + 1;
  455|  14.3k|                }
  456|  14.5k|            }
  457|   124k|            dst->runs[dst->n_runs].value = (uint16_t)lateststart;
  458|   124k|            dst->runs[dst->n_runs].length =
  459|   124k|                (uint16_t)(earliestend - lateststart - 1);
  460|   124k|            dst->n_runs++;
  461|   124k|        }
  462|   183k|    }
  463|  3.55k|}
run_container_intersection_cardinality:
  467|  2.72k|                                           const run_container_t *src_2) {
  468|  2.72k|    const bool if1 = run_container_is_full(src_1);
  469|  2.72k|    const bool if2 = run_container_is_full(src_2);
  470|  2.72k|    if (if1 || if2) {
  ------------------
  |  Branch (470:9): [True: 0, False: 2.72k]
  |  Branch (470:16): [True: 64, False: 2.65k]
  ------------------
  471|     64|        if (if1) {
  ------------------
  |  Branch (471:13): [True: 0, False: 64]
  ------------------
  472|      0|            return run_container_cardinality(src_2);
  473|      0|        }
  474|     64|        if (if2) {
  ------------------
  |  Branch (474:13): [True: 64, False: 0]
  ------------------
  475|     64|            return run_container_cardinality(src_1);
  476|     64|        }
  477|     64|    }
  478|  2.65k|    int answer = 0;
  479|  2.65k|    int32_t rlepos = 0;
  480|  2.65k|    int32_t xrlepos = 0;
  481|  2.65k|    int32_t start = src_1->runs[rlepos].value;
  482|  2.65k|    int32_t end = start + src_1->runs[rlepos].length + 1;
  483|  2.65k|    int32_t xstart = src_2->runs[xrlepos].value;
  484|  2.65k|    int32_t xend = xstart + src_2->runs[xrlepos].length + 1;
  485|   285k|    while ((rlepos < src_1->n_runs) && (xrlepos < src_2->n_runs)) {
  ------------------
  |  Branch (485:12): [True: 283k, False: 1.82k]
  |  Branch (485:40): [True: 282k, False: 836]
  ------------------
  486|   282k|        if (end <= xstart) {
  ------------------
  |  Branch (486:13): [True: 68.9k, False: 213k]
  ------------------
  487|  68.9k|            ++rlepos;
  488|  68.9k|            if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (488:17): [True: 68.5k, False: 352]
  ------------------
  489|  68.5k|                start = src_1->runs[rlepos].value;
  490|  68.5k|                end = start + src_1->runs[rlepos].length + 1;
  491|  68.5k|            }
  492|   213k|        } else if (xend <= start) {
  ------------------
  |  Branch (492:20): [True: 49.8k, False: 163k]
  ------------------
  493|  49.8k|            ++xrlepos;
  494|  49.8k|            if (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (494:17): [True: 49.6k, False: 208]
  ------------------
  495|  49.6k|                xstart = src_2->runs[xrlepos].value;
  496|  49.6k|                xend = xstart + src_2->runs[xrlepos].length + 1;
  497|  49.6k|            }
  498|   163k|        } else {  // they overlap
  499|   163k|            const int32_t lateststart = start > xstart ? start : xstart;
  ------------------
  |  Branch (499:41): [True: 57.6k, False: 106k]
  ------------------
  500|   163k|            int32_t earliestend;
  501|   163k|            if (end == xend) {  // improbable
  ------------------
  |  Branch (501:17): [True: 86.5k, False: 77.3k]
  ------------------
  502|  86.5k|                earliestend = end;
  503|  86.5k|                rlepos++;
  504|  86.5k|                xrlepos++;
  505|  86.5k|                if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (505:21): [True: 85.6k, False: 888]
  ------------------
  506|  85.6k|                    start = src_1->runs[rlepos].value;
  507|  85.6k|                    end = start + src_1->runs[rlepos].length + 1;
  508|  85.6k|                }
  509|  86.5k|                if (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (509:21): [True: 85.5k, False: 1.04k]
  ------------------
  510|  85.5k|                    xstart = src_2->runs[xrlepos].value;
  511|  85.5k|                    xend = xstart + src_2->runs[xrlepos].length + 1;
  512|  85.5k|                }
  513|  86.5k|            } else if (end < xend) {
  ------------------
  |  Branch (513:24): [True: 58.9k, False: 18.4k]
  ------------------
  514|  58.9k|                earliestend = end;
  515|  58.9k|                rlepos++;
  516|  58.9k|                if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (516:21): [True: 58.3k, False: 580]
  ------------------
  517|  58.3k|                    start = src_1->runs[rlepos].value;
  518|  58.3k|                    end = start + src_1->runs[rlepos].length + 1;
  519|  58.3k|                }
  520|       |
  521|  58.9k|            } else {  // end > xend
  522|  18.4k|                earliestend = xend;
  523|  18.4k|                xrlepos++;
  524|  18.4k|                if (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (524:21): [True: 18.2k, False: 204]
  ------------------
  525|  18.2k|                    xstart = src_2->runs[xrlepos].value;
  526|  18.2k|                    xend = xstart + src_2->runs[xrlepos].length + 1;
  527|  18.2k|                }
  528|  18.4k|            }
  529|   163k|            answer += earliestend - lateststart;
  530|   163k|        }
  531|   282k|    }
  532|  2.65k|    return answer;
  533|  2.72k|}
run_container_intersect:
  536|    680|                             const run_container_t *src_2) {
  537|    680|    const bool if1 = run_container_is_full(src_1);
  538|    680|    const bool if2 = run_container_is_full(src_2);
  539|    680|    if (if1 || if2) {
  ------------------
  |  Branch (539:9): [True: 0, False: 680]
  |  Branch (539:16): [True: 16, False: 664]
  ------------------
  540|     16|        if (if1) {
  ------------------
  |  Branch (540:13): [True: 0, False: 16]
  ------------------
  541|      0|            return !run_container_empty(src_2);
  542|      0|        }
  543|     16|        if (if2) {
  ------------------
  |  Branch (543:13): [True: 16, False: 0]
  ------------------
  544|     16|            return !run_container_empty(src_1);
  545|     16|        }
  546|     16|    }
  547|    664|    int32_t rlepos = 0;
  548|    664|    int32_t xrlepos = 0;
  549|    664|    int32_t start = src_1->runs[rlepos].value;
  550|    664|    int32_t end = start + src_1->runs[rlepos].length + 1;
  551|    664|    int32_t xstart = src_2->runs[xrlepos].value;
  552|    664|    int32_t xend = xstart + src_2->runs[xrlepos].length + 1;
  553|  3.27k|    while ((rlepos < src_1->n_runs) && (xrlepos < src_2->n_runs)) {
  ------------------
  |  Branch (553:12): [True: 3.25k, False: 15]
  |  Branch (553:40): [True: 3.25k, False: 4]
  ------------------
  554|  3.25k|        if (end <= xstart) {
  ------------------
  |  Branch (554:13): [True: 2.21k, False: 1.03k]
  ------------------
  555|  2.21k|            ++rlepos;
  556|  2.21k|            if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (556:17): [True: 2.20k, False: 15]
  ------------------
  557|  2.20k|                start = src_1->runs[rlepos].value;
  558|  2.20k|                end = start + src_1->runs[rlepos].length + 1;
  559|  2.20k|            }
  560|  2.21k|        } else if (xend <= start) {
  ------------------
  |  Branch (560:20): [True: 393, False: 645]
  ------------------
  561|    393|            ++xrlepos;
  562|    393|            if (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (562:17): [True: 389, False: 4]
  ------------------
  563|    389|                xstart = src_2->runs[xrlepos].value;
  564|    389|                xend = xstart + src_2->runs[xrlepos].length + 1;
  565|    389|            }
  566|    645|        } else {  // they overlap
  567|    645|            return true;
  568|    645|        }
  569|  3.25k|    }
  570|     19|    return false;
  571|    664|}
run_container_andnot:
  576|  1.09k|                          const run_container_t *src_2, run_container_t *dst) {
  577|       |    // following Java implementation as of June 2016
  578|       |
  579|  1.09k|    if (dst->capacity < src_1->n_runs + src_2->n_runs)
  ------------------
  |  Branch (579:9): [True: 1.09k, False: 0]
  ------------------
  580|  1.09k|        run_container_grow(dst, src_1->n_runs + src_2->n_runs, false);
  581|       |
  582|  1.09k|    dst->n_runs = 0;
  583|       |
  584|  1.09k|    int rlepos1 = 0;
  585|  1.09k|    int rlepos2 = 0;
  586|  1.09k|    int32_t start = src_1->runs[rlepos1].value;
  587|  1.09k|    int32_t end = start + src_1->runs[rlepos1].length + 1;
  588|  1.09k|    int32_t start2 = src_2->runs[rlepos2].value;
  589|  1.09k|    int32_t end2 = start2 + src_2->runs[rlepos2].length + 1;
  590|       |
  591|   156k|    while ((rlepos1 < src_1->n_runs) && (rlepos2 < src_2->n_runs)) {
  ------------------
  |  Branch (591:12): [True: 155k, False: 670]
  |  Branch (591:41): [True: 155k, False: 426]
  ------------------
  592|   155k|        if (end <= start2) {
  ------------------
  |  Branch (592:13): [True: 23.1k, False: 132k]
  ------------------
  593|       |            // output the first run
  594|  23.1k|            dst->runs[dst->n_runs++] =
  595|  23.1k|                CROARING_MAKE_RLE16(start, end - start - 1);
  ------------------
  |  |   60|  23.1k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  596|  23.1k|            rlepos1++;
  597|  23.1k|            if (rlepos1 < src_1->n_runs) {
  ------------------
  |  Branch (597:17): [True: 23.0k, False: 88]
  ------------------
  598|  23.0k|                start = src_1->runs[rlepos1].value;
  599|  23.0k|                end = start + src_1->runs[rlepos1].length + 1;
  600|  23.0k|            }
  601|   132k|        } else if (end2 <= start) {
  ------------------
  |  Branch (601:20): [True: 64.7k, False: 67.4k]
  ------------------
  602|       |            // exit the second run
  603|  64.7k|            rlepos2++;
  604|  64.7k|            if (rlepos2 < src_2->n_runs) {
  ------------------
  |  Branch (604:17): [True: 64.2k, False: 426]
  ------------------
  605|  64.2k|                start2 = src_2->runs[rlepos2].value;
  606|  64.2k|                end2 = start2 + src_2->runs[rlepos2].length + 1;
  607|  64.2k|            }
  608|  67.4k|        } else {
  609|  67.4k|            if (start < start2) {
  ------------------
  |  Branch (609:17): [True: 17.9k, False: 49.4k]
  ------------------
  610|  17.9k|                dst->runs[dst->n_runs++] =
  611|  17.9k|                    CROARING_MAKE_RLE16(start, start2 - start - 1);
  ------------------
  |  |   60|  17.9k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  612|  17.9k|            }
  613|  67.4k|            if (end2 < end) {
  ------------------
  |  Branch (613:17): [True: 17.4k, False: 49.9k]
  ------------------
  614|  17.4k|                start = end2;
  615|  49.9k|            } else {
  616|  49.9k|                rlepos1++;
  617|  49.9k|                if (rlepos1 < src_1->n_runs) {
  ------------------
  |  Branch (617:21): [True: 49.3k, False: 582]
  ------------------
  618|  49.3k|                    start = src_1->runs[rlepos1].value;
  619|  49.3k|                    end = start + src_1->runs[rlepos1].length + 1;
  620|  49.3k|                }
  621|  49.9k|            }
  622|  67.4k|        }
  623|   155k|    }
  624|  1.09k|    if (rlepos1 < src_1->n_runs) {
  ------------------
  |  Branch (624:9): [True: 426, False: 670]
  ------------------
  625|    426|        dst->runs[dst->n_runs++] = CROARING_MAKE_RLE16(start, end - start - 1);
  ------------------
  |  |   60|    426|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  626|    426|        rlepos1++;
  627|    426|        if (rlepos1 < src_1->n_runs) {
  ------------------
  |  Branch (627:13): [True: 182, False: 244]
  ------------------
  628|    182|            memcpy(dst->runs + dst->n_runs, src_1->runs + rlepos1,
  629|    182|                   sizeof(rle16_t) * (src_1->n_runs - rlepos1));
  630|    182|            dst->n_runs += src_1->n_runs - rlepos1;
  631|    182|        }
  632|    426|    }
  633|  1.09k|}
run_container_read:
  739|     50|                           const char *buf) {
  740|     50|    (void)cardinality;
  741|     50|    uint16_t cast_16;
  742|     50|    memcpy(&cast_16, buf, sizeof(uint16_t));
  743|     50|    container->n_runs = croaring_letoh16(cast_16);
  ------------------
  |  |  523|     50|#define croaring_letoh16(x) croaring_htole16(x)
  |  |  ------------------
  |  |  |  |  517|     50|#define croaring_htole16(x) (x)
  |  |  ------------------
  ------------------
  744|     50|    if (container->n_runs > container->capacity)
  ------------------
  |  Branch (744:9): [True: 7, False: 43]
  ------------------
  745|      7|        run_container_grow(container, container->n_runs, false);
  746|     50|    if (container->n_runs > 0) {
  ------------------
  |  Branch (746:9): [True: 7, False: 43]
  ------------------
  747|       |#if CROARING_IS_BIG_ENDIAN
  748|       |        const char *in = buf + sizeof(uint16_t);
  749|       |        for (int32_t i = 0; i < container->n_runs; ++i) {
  750|       |            uint16_t v_le, l_le;
  751|       |            memcpy(&v_le, in, sizeof(uint16_t));
  752|       |            memcpy(&l_le, in + sizeof(uint16_t), sizeof(uint16_t));
  753|       |            container->runs[i].value = croaring_letoh16(v_le);
  754|       |            container->runs[i].length = croaring_letoh16(l_le);
  755|       |            in += sizeof(rle16_t);
  756|       |        }
  757|       |#else
  758|      7|        memcpy(container->runs, buf + sizeof(uint16_t),
  759|      7|               container->n_runs * sizeof(rle16_t));
  760|      7|#endif
  761|      7|    }
  762|     50|    return run_container_size_in_bytes(container);
  763|     50|}
run_container_iterate:
  766|  61.1k|                           roaring_iterator iterator, void *ptr) {
  767|   162k|    for (int i = 0; i < cont->n_runs; ++i) {
  ------------------
  |  Branch (767:21): [True: 101k, False: 61.1k]
  ------------------
  768|   101k|        uint32_t run_start = base + cont->runs[i].value;
  769|   101k|        uint16_t le = cont->runs[i].length;
  770|       |
  771|  3.91G|        for (int j = 0; j <= le; ++j)
  ------------------
  |  Branch (771:25): [True: 3.91G, False: 101k]
  ------------------
  772|  3.91G|            if (!iterator(run_start + j, ptr)) return false;
  ------------------
  |  Branch (772:17): [True: 0, False: 3.91G]
  ------------------
  773|   101k|    }
  774|  61.1k|    return true;
  775|  61.1k|}
run_container_is_subset:
  792|    244|                             const run_container_t *container2) {
  793|    244|    int i1 = 0, i2 = 0;
  794|    643|    while (i1 < container1->n_runs && i2 < container2->n_runs) {
  ------------------
  |  Branch (794:12): [True: 643, False: 0]
  |  Branch (794:39): [True: 631, False: 12]
  ------------------
  795|    631|        int start1 = container1->runs[i1].value;
  796|    631|        int stop1 = start1 + container1->runs[i1].length;
  797|    631|        int start2 = container2->runs[i2].value;
  798|    631|        int stop2 = start2 + container2->runs[i2].length;
  799|    631|        if (start1 < start2) {
  ------------------
  |  Branch (799:13): [True: 232, False: 399]
  ------------------
  800|    232|            return false;
  801|    399|        } else {  // start1 >= start2
  802|    399|            if (stop1 < stop2) {
  ------------------
  |  Branch (802:17): [True: 0, False: 399]
  ------------------
  803|      0|                i1++;
  804|    399|            } else if (stop1 == stop2) {
  ------------------
  |  Branch (804:24): [True: 0, False: 399]
  ------------------
  805|      0|                i1++;
  806|      0|                i2++;
  807|    399|            } else {  // stop1 > stop2
  808|    399|                i2++;
  809|    399|            }
  810|    399|        }
  811|    631|    }
  812|     12|    if (i1 == container1->n_runs) {
  ------------------
  |  Branch (812:9): [True: 0, False: 12]
  ------------------
  813|      0|        return true;
  814|     12|    } else {
  815|       |        return false;
  816|     12|    }
  817|     12|}
run_container_smart_append_exclusive:
  826|   392k|                                          const uint16_t length) {
  827|   392k|    int old_end;
  828|   392k|    rle16_t *last_run = src->n_runs ? src->runs + (src->n_runs - 1) : NULL;
  ------------------
  |  Branch (828:25): [True: 315k, False: 76.9k]
  ------------------
  829|   392k|    rle16_t *appended_last_run = src->runs + src->n_runs;
  830|       |
  831|   392k|    if (!src->n_runs ||
  ------------------
  |  Branch (831:9): [True: 76.9k, False: 315k]
  ------------------
  832|   315k|        (start > (old_end = last_run->value + last_run->length + 1))) {
  ------------------
  |  Branch (832:9): [True: 170k, False: 145k]
  ------------------
  833|   247k|        *appended_last_run = CROARING_MAKE_RLE16(start, length);
  ------------------
  |  |   60|   247k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  834|   247k|        src->n_runs++;
  835|   247k|        return;
  836|   247k|    }
  837|   145k|    if (old_end == start) {
  ------------------
  |  Branch (837:9): [True: 3.75k, False: 141k]
  ------------------
  838|       |        // we merge
  839|  3.75k|        last_run->length += (length + 1);
  840|  3.75k|        return;
  841|  3.75k|    }
  842|   141k|    int new_end = start + length + 1;
  843|       |
  844|   141k|    if (start == last_run->value) {
  ------------------
  |  Branch (844:9): [True: 113k, False: 28.6k]
  ------------------
  845|       |        // wipe out previous
  846|   113k|        if (new_end < old_end) {
  ------------------
  |  Branch (846:13): [True: 7.20k, False: 105k]
  ------------------
  847|  7.20k|            *last_run = CROARING_MAKE_RLE16(new_end, old_end - new_end - 1);
  ------------------
  |  |   60|  7.20k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  848|  7.20k|            return;
  849|   105k|        } else if (new_end > old_end) {
  ------------------
  |  Branch (849:20): [True: 2.33k, False: 103k]
  ------------------
  850|  2.33k|            *last_run = CROARING_MAKE_RLE16(old_end, new_end - old_end - 1);
  ------------------
  |  |   60|  2.33k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  851|  2.33k|            return;
  852|   103k|        } else {
  853|   103k|            src->n_runs--;
  854|   103k|            return;
  855|   103k|        }
  856|   113k|    }
  857|  28.6k|    last_run->length = start - last_run->value - 1;
  858|  28.6k|    if (new_end < old_end) {
  ------------------
  |  Branch (858:9): [True: 22.6k, False: 5.93k]
  ------------------
  859|  22.6k|        *appended_last_run =
  860|  22.6k|            CROARING_MAKE_RLE16(new_end, old_end - new_end - 1);
  ------------------
  |  |   60|  22.6k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  861|  22.6k|        src->n_runs++;
  862|  22.6k|    } else if (new_end > old_end) {
  ------------------
  |  Branch (862:16): [True: 1.07k, False: 4.85k]
  ------------------
  863|  1.07k|        *appended_last_run =
  864|  1.07k|            CROARING_MAKE_RLE16(old_end, new_end - old_end - 1);
  ------------------
  |  |   60|  1.07k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  865|  1.07k|        src->n_runs++;
  866|  1.07k|    }
  867|  28.6k|}
run_container_select:
  871|  2.67k|                          uint32_t *element) {
  872|  15.7k|    for (int i = 0; i < container->n_runs; i++) {
  ------------------
  |  Branch (872:21): [True: 15.6k, False: 104]
  ------------------
  873|  15.6k|        uint16_t length = container->runs[i].length;
  874|  15.6k|        if (rank <= *start_rank + length) {
  ------------------
  |  Branch (874:13): [True: 2.57k, False: 13.0k]
  ------------------
  875|  2.57k|            uint16_t value = container->runs[i].value;
  876|  2.57k|            *element = value + rank - (*start_rank);
  877|  2.57k|            return true;
  878|  2.57k|        } else
  879|  13.0k|            *start_rank += length + 1;
  880|  15.6k|    }
  881|    104|    return false;
  882|  2.67k|}
run_container_rank:
  884|  2.67k|int run_container_rank(const run_container_t *container, uint16_t x) {
  885|  2.67k|    int sum = 0;
  886|  2.67k|    uint32_t x32 = x;
  887|  12.9k|    for (int i = 0; i < container->n_runs; i++) {
  ------------------
  |  Branch (887:21): [True: 12.9k, False: 74]
  ------------------
  888|  12.9k|        uint32_t startpoint = container->runs[i].value;
  889|  12.9k|        uint32_t length = container->runs[i].length;
  890|  12.9k|        uint32_t endpoint = length + startpoint;
  891|  12.9k|        if (x <= endpoint) {
  ------------------
  |  Branch (891:13): [True: 2.60k, False: 10.3k]
  ------------------
  892|  2.60k|            if (x < startpoint) break;
  ------------------
  |  Branch (892:17): [True: 293, False: 2.31k]
  ------------------
  893|  2.31k|            return sum + (x32 - startpoint) + 1;
  894|  10.3k|        } else {
  895|  10.3k|            sum += length + 1;
  896|  10.3k|        }
  897|  12.9k|    }
  898|    367|    return sum;
  899|  2.67k|}
_avx2_run_container_to_uint32_array:
 1021|  61.7k|                                        uint32_t base) {
 1022|  61.7k|    int outpos = 0;
 1023|  61.7k|    uint32_t *out = (uint32_t *)vout;
 1024|       |
 1025|   210k|    for (int i = 0; i < cont->n_runs; ++i) {
  ------------------
  |  Branch (1025:21): [True: 149k, False: 61.7k]
  ------------------
 1026|   149k|        uint32_t run_start = base + cont->runs[i].value;
 1027|   149k|        uint16_t le = cont->runs[i].length;
 1028|   149k|        if (le < 8) {
  ------------------
  |  Branch (1028:13): [True: 83.6k, False: 65.5k]
  ------------------
 1029|   216k|            for (int j = 0; j <= le; ++j) {
  ------------------
  |  Branch (1029:29): [True: 133k, False: 83.6k]
  ------------------
 1030|   133k|                uint32_t val = run_start + j;
 1031|   133k|                memcpy(out + outpos, &val,
 1032|   133k|                       sizeof(uint32_t));  // should be compiled as a MOV on x64
 1033|   133k|                outpos++;
 1034|   133k|            }
 1035|  83.6k|        } else {
 1036|  65.5k|            int j = 0;
 1037|  65.5k|            __m256i run_start_v = _mm256_set1_epi32(run_start);
 1038|       |            // [8,8,8,8....]
 1039|  65.5k|            __m256i inc = _mm256_set1_epi32(8);
 1040|       |            // used for generate sequence:
 1041|       |            // [0, 1, 2, 3...], [8, 9, 10,...]
 1042|  65.5k|            __m256i delta = _mm256_setr_epi32(0, 1, 2, 3, 4, 5, 6, 7);
 1043|   491M|            for (j = 0; j + 8 <= le; j += 8) {
  ------------------
  |  Branch (1043:25): [True: 491M, False: 65.5k]
  ------------------
 1044|   491M|                __m256i val_v = _mm256_add_epi32(run_start_v, delta);
 1045|   491M|                _mm256_storeu_si256((__m256i *)(out + outpos), val_v);
 1046|   491M|                delta = _mm256_add_epi32(inc, delta);
 1047|   491M|                outpos += 8;
 1048|   491M|            }
 1049|   564k|            for (; j <= le; ++j) {
  ------------------
  |  Branch (1049:20): [True: 499k, False: 65.5k]
  ------------------
 1050|   499k|                uint32_t val = run_start + j;
 1051|   499k|                memcpy(out + outpos, &val,
 1052|   499k|                       sizeof(uint32_t));  // should be compiled as a MOV on x64
 1053|   499k|                outpos++;
 1054|   499k|            }
 1055|  65.5k|        }
 1056|   149k|    }
 1057|  61.7k|    return outpos;
 1058|  61.7k|}
run_container_cardinality:
 1077|   550k|int run_container_cardinality(const run_container_t *run) {
 1078|       |    // Empirically AVX-512 is not always faster than AVX2
 1079|       |#if CROARING_COMPILER_SUPPORTS_AVX512 && \
 1080|       |    CROARING_ENABLE_AVX512_RUN_CONTAINER_CARDINALITY
 1081|       |    if (croaring_hardware_support() & ROARING_SUPPORTS_AVX512) {
 1082|       |        return _avx512_run_container_cardinality(run);
 1083|       |    } else
 1084|       |#endif
 1085|   550k|        if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (1085:13): [True: 550k, False: 0]
  ------------------
 1086|   550k|        return _avx2_run_container_cardinality(run);
 1087|   550k|    } else {
 1088|      0|        return _scalar_run_container_cardinality(run);
 1089|      0|    }
 1090|   550k|}
run_container_to_uint32_array:
 1111|  61.7k|                                  uint32_t base) {
 1112|  61.7k|    if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (1112:9): [True: 61.7k, False: 0]
  ------------------
 1113|  61.7k|        return _avx2_run_container_to_uint32_array(vout, cont, base);
 1114|  61.7k|    } else {
 1115|      0|        return _scalar_run_container_to_uint32_array(vout, cont, base);
 1116|      0|    }
 1117|  61.7k|}
run.c:_avx2_run_container_cardinality:
  991|   550k|static inline int _avx2_run_container_cardinality(const run_container_t *run) {
  992|   550k|    const int32_t n_runs = run->n_runs;
  993|   550k|    const rle16_t *runs = run->runs;
  994|       |
  995|       |    /* by initializing with n_runs, we omit counting the +1 for each pair. */
  996|   550k|    int sum = n_runs;
  997|   550k|    int32_t k = 0;
  998|   550k|    const int32_t step = sizeof(__m256i) / sizeof(rle16_t);
  999|   550k|    if (n_runs > step) {
  ------------------
  |  Branch (999:9): [True: 33.7k, False: 516k]
  ------------------
 1000|  33.7k|        __m256i total = _mm256_setzero_si256();
 1001|   382k|        for (; k + step <= n_runs; k += step) {
  ------------------
  |  Branch (1001:16): [True: 348k, False: 33.7k]
  ------------------
 1002|   348k|            __m256i ymm1 = _mm256_lddqu_si256((const __m256i *)(runs + k));
 1003|   348k|            __m256i justlengths = _mm256_srli_epi32(ymm1, 16);
 1004|   348k|            total = _mm256_add_epi32(total, justlengths);
 1005|   348k|        }
 1006|       |        // a store might be faster than extract?
 1007|  33.7k|        uint32_t buffer[sizeof(__m256i) / sizeof(rle16_t)];
 1008|  33.7k|        _mm256_storeu_si256((__m256i *)buffer, total);
 1009|  33.7k|        sum += (buffer[0] + buffer[1]) + (buffer[2] + buffer[3]) +
 1010|  33.7k|               (buffer[4] + buffer[5]) + (buffer[6] + buffer[7]);
 1011|  33.7k|    }
 1012|  1.14M|    for (; k < n_runs; ++k) {
  ------------------
  |  Branch (1012:12): [True: 593k, False: 550k]
  ------------------
 1013|   593k|        sum += runs[k].length;
 1014|   593k|    }
 1015|       |
 1016|   550k|    return sum;
 1017|   550k|}

croaring_hardware_support:
  321|   980k|int croaring_hardware_support(void) {
  322|   980k|    static
  323|   980k|#if CROARING_ATOMIC_IMPL == CROARING_ATOMIC_IMPL_C
  324|   980k|        _Atomic
  325|   980k|#endif
  326|   980k|        int support = 0xFFFFFFF;
  327|   980k|    if (support == 0xFFFFFFF) {
  ------------------
  |  Branch (327:9): [True: 1, False: 980k]
  ------------------
  328|      1|        bool has_avx2 = (croaring_detect_supported_architectures() &
  329|      1|                         CROARING_AVX2) == CROARING_AVX2;
  330|      1|        bool has_avx512 = false;
  331|      1|#if CROARING_COMPILER_SUPPORTS_AVX512
  332|      1|        has_avx512 = (croaring_detect_supported_architectures() &
  333|      1|                      CROARING_AVX512_REQUIRED) == CROARING_AVX512_REQUIRED;
  334|      1|#endif  // CROARING_COMPILER_SUPPORTS_AVX512
  335|      1|        support = (has_avx2 ? ROARING_SUPPORTS_AVX2 : 0) |
  ------------------
  |  Branch (335:20): [True: 1, False: 0]
  ------------------
  336|      1|                  (has_avx512 ? ROARING_SUPPORTS_AVX512 : 0);
  ------------------
  |  Branch (336:20): [True: 0, False: 1]
  ------------------
  337|      1|    }
  338|   980k|    return support;
  339|   980k|}
isadetection.c:croaring_detect_supported_architectures:
  269|      2|static uint32_t croaring_detect_supported_architectures(void) {
  270|       |    // we use an atomic for thread safety
  271|      2|    static _Atomic uint32_t buffer = CROARING_UNINITIALIZED;
  272|      2|    if (buffer == CROARING_UNINITIALIZED) {
  ------------------
  |  Branch (272:9): [True: 1, False: 1]
  ------------------
  273|       |        // atomicity is sufficient
  274|      1|        buffer = dynamic_croaring_detect_supported_architectures();
  275|      1|    }
  276|      2|    return buffer;
  277|      2|}
isadetection.c:dynamic_croaring_detect_supported_architectures:
  154|      1|static inline uint32_t dynamic_croaring_detect_supported_architectures(void) {
  155|      1|    uint32_t eax, ebx, ecx, edx;
  156|      1|    uint32_t host_isa = 0x0;
  157|       |    // Can be found on Intel ISA Reference for CPUID
  158|      1|    static uint32_t cpuid_avx2_bit =
  159|      1|        1 << 5;  ///< @private Bit 5 of EBX for EAX=0x7
  160|      1|    static uint32_t cpuid_bmi1_bit =
  161|      1|        1 << 3;  ///< @private bit 3 of EBX for EAX=0x7
  162|      1|    static uint32_t cpuid_bmi2_bit =
  163|      1|        1 << 8;  ///< @private bit 8 of EBX for EAX=0x7
  164|      1|    static uint32_t cpuid_avx512f_bit =
  165|      1|        1 << 16;  ///< @private bit 16 of EBX for EAX=0x7
  166|      1|    static uint32_t cpuid_avx512dq_bit =
  167|      1|        1 << 17;  ///< @private bit 17 of EBX for EAX=0x7
  168|      1|    static uint32_t cpuid_avx512bw_bit =
  169|      1|        1 << 30;  ///< @private bit 30 of EBX for EAX=0x7
  170|      1|    static uint32_t cpuid_avx512vbmi2_bit =
  171|      1|        1 << 6;  ///< @private bit 6 of ECX for EAX=0x7
  172|      1|    static uint32_t cpuid_avx512bitalg_bit =
  173|      1|        1 << 12;  ///< @private bit 12 of ECX for EAX=0x7
  174|      1|    static uint32_t cpuid_avx512vpopcntdq_bit =
  175|      1|        1 << 14;  ///< @private bit 14 of ECX for EAX=0x7
  176|      1|    static uint64_t cpuid_avx256_saved = 1 << 2;  ///< @private bit 2 = AVX
  177|      1|    static uint64_t cpuid_avx512_saved =
  178|      1|        7 << 5;  ///< @private bits 5,6,7 = opmask, ZMM_hi256, hi16_ZMM
  179|      1|    static uint32_t cpuid_sse42_bit =
  180|      1|        1 << 20;  ///< @private bit 20 of ECX for EAX=0x1
  181|      1|    static uint32_t cpuid_osxsave =
  182|      1|        (1 << 26) | (1 << 27);  ///< @private bits 26+27 of ECX for EAX=0x1
  183|      1|    static uint32_t cpuid_pclmulqdq_bit =
  184|      1|        1 << 1;  ///< @private bit  1 of ECX for EAX=0x1
  185|       |
  186|       |    // EBX for EAX=0x1
  187|      1|    eax = 0x1;
  188|      1|    ecx = 0x0;
  189|      1|    cpuid(&eax, &ebx, &ecx, &edx);
  190|       |
  191|      1|    if (ecx & cpuid_sse42_bit) {
  ------------------
  |  Branch (191:9): [True: 1, False: 0]
  ------------------
  192|      1|        host_isa |= CROARING_SSE42;
  193|      1|    } else {
  194|      0|        return host_isa;  // everything after is redundant
  195|      0|    }
  196|       |
  197|      1|    if (ecx & cpuid_pclmulqdq_bit) {
  ------------------
  |  Branch (197:9): [True: 1, False: 0]
  ------------------
  198|      1|        host_isa |= CROARING_PCLMULQDQ;
  199|      1|    }
  200|       |
  201|      1|    if ((ecx & cpuid_osxsave) != cpuid_osxsave) {
  ------------------
  |  Branch (201:9): [True: 0, False: 1]
  ------------------
  202|      0|        return host_isa;
  203|      0|    }
  204|       |
  205|       |    // xgetbv for checking if the OS saves registers
  206|      1|    uint64_t xcr0 = xgetbv();
  207|       |
  208|      1|    if ((xcr0 & cpuid_avx256_saved) == 0) {
  ------------------
  |  Branch (208:9): [True: 0, False: 1]
  ------------------
  209|      0|        return host_isa;
  210|      0|    }
  211|       |
  212|       |    // ECX for EAX=0x7
  213|      1|    eax = 0x7;
  214|      1|    ecx = 0x0;
  215|      1|    cpuid(&eax, &ebx, &ecx, &edx);
  216|      1|    if (ebx & cpuid_avx2_bit) {
  ------------------
  |  Branch (216:9): [True: 1, False: 0]
  ------------------
  217|      1|        host_isa |= CROARING_AVX2;
  218|      1|    }
  219|      1|    if (ebx & cpuid_bmi1_bit) {
  ------------------
  |  Branch (219:9): [True: 1, False: 0]
  ------------------
  220|      1|        host_isa |= CROARING_BMI1;
  221|      1|    }
  222|       |
  223|      1|    if (ebx & cpuid_bmi2_bit) {
  ------------------
  |  Branch (223:9): [True: 1, False: 0]
  ------------------
  224|      1|        host_isa |= CROARING_BMI2;
  225|      1|    }
  226|       |
  227|      1|    if (!((xcr0 & cpuid_avx512_saved) == cpuid_avx512_saved)) {
  ------------------
  |  Branch (227:9): [True: 1, False: 0]
  ------------------
  228|      1|        return host_isa;
  229|      1|    }
  230|       |
  231|      0|    if (ebx & cpuid_avx512f_bit) {
  ------------------
  |  Branch (231:9): [True: 0, False: 0]
  ------------------
  232|      0|        host_isa |= CROARING_AVX512F;
  233|      0|    }
  234|       |
  235|      0|    if (ebx & cpuid_avx512bw_bit) {
  ------------------
  |  Branch (235:9): [True: 0, False: 0]
  ------------------
  236|      0|        host_isa |= CROARING_AVX512BW;
  237|      0|    }
  238|       |
  239|      0|    if (ebx & cpuid_avx512dq_bit) {
  ------------------
  |  Branch (239:9): [True: 0, False: 0]
  ------------------
  240|      0|        host_isa |= CROARING_AVX512DQ;
  241|      0|    }
  242|       |
  243|      0|    if (ecx & cpuid_avx512vbmi2_bit) {
  ------------------
  |  Branch (243:9): [True: 0, False: 0]
  ------------------
  244|      0|        host_isa |= CROARING_AVX512VBMI2;
  245|      0|    }
  246|       |
  247|      0|    if (ecx & cpuid_avx512bitalg_bit) {
  ------------------
  |  Branch (247:9): [True: 0, False: 0]
  ------------------
  248|      0|        host_isa |= CROARING_AVX512BITALG;
  249|      0|    }
  250|       |
  251|      0|    if (ecx & cpuid_avx512vpopcntdq_bit) {
  ------------------
  |  Branch (251:9): [True: 0, False: 0]
  ------------------
  252|      0|        host_isa |= CROARING_AVX512VPOPCNTDQ;
  253|      0|    }
  254|       |
  255|      0|    return host_isa;
  256|      1|}
isadetection.c:cpuid:
  115|      2|                         uint32_t *edx) {
  116|       |#if CROARING_REGULAR_VISUAL_STUDIO
  117|       |    int cpu_info[4];
  118|       |    __cpuidex(cpu_info, *eax, *ecx);
  119|       |    *eax = cpu_info[0];
  120|       |    *ebx = cpu_info[1];
  121|       |    *ecx = cpu_info[2];
  122|       |    *edx = cpu_info[3];
  123|       |#elif (defined(HAVE_GCC_GET_CPUID) && defined(USE_GCC_GET_CPUID)) || \
  124|       |    defined(__FILC__)
  125|       |    uint32_t level = *eax;
  126|       |    __get_cpuid(level, eax, ebx, ecx, edx);
  127|       |#else
  128|      2|    uint32_t a = *eax, b, c = *ecx, d;
  129|      2|    __asm__("cpuid\n\t" : "+a"(a), "=b"(b), "+c"(c), "=d"(d));
  130|      2|    *eax = a;
  131|      2|    *ebx = b;
  132|      2|    *ecx = c;
  133|      2|    *edx = d;
  134|      2|#endif
  135|      2|}
isadetection.c:xgetbv:
  137|      1|static inline uint64_t xgetbv(void) {
  138|       |#if defined(_MSC_VER)
  139|       |    return _xgetbv(0);
  140|       |#elif defined(__FILC__)
  141|       |    return zxgetbv();
  142|       |#else
  143|      1|    uint32_t xcr0_lo, xcr0_hi;
  144|      1|    __asm__("xgetbv\n\t" : "=a"(xcr0_lo), "=d"(xcr0_hi) : "c"(0));
  145|      1|    return xcr0_lo | ((uint64_t)xcr0_hi << 32);
  146|      1|#endif
  147|      1|}

roaring_malloc:
   48|  1.44M|void* roaring_malloc(size_t n) { return global_memory_hook.malloc(n); }
roaring_realloc:
   50|   120k|void* roaring_realloc(void* p, size_t new_sz) {
   51|   120k|    return global_memory_hook.realloc(p, new_sz);
   52|   120k|}
roaring_free:
   58|  1.70M|void roaring_free(void* p) { global_memory_hook.free(p); }
roaring_aligned_malloc:
   60|   302k|void* roaring_aligned_malloc(size_t alignment, size_t size) {
   61|   302k|    return global_memory_hook.aligned_malloc(alignment, size);
   62|   302k|}
roaring_aligned_free:
   64|   302k|void roaring_aligned_free(void* p) { global_memory_hook.aligned_free(p); }
memory.c:roaring_bitmap_aligned_malloc:
   11|   302k|static void* roaring_bitmap_aligned_malloc(size_t alignment, size_t size) {
   12|   302k|    void* p;
   13|       |#ifdef _MSC_VER
   14|       |    p = _aligned_malloc(size, alignment);
   15|       |#elif defined(__MINGW32__) || defined(__MINGW64__)
   16|       |    p = __mingw_aligned_malloc(size, alignment);
   17|       |#else
   18|       |    // somehow, if this is used before including "x86intrin.h", it creates an
   19|       |    // implicit defined warning.
   20|   302k|    if (posix_memalign(&p, alignment, size) != 0) return NULL;
  ------------------
  |  Branch (20:9): [True: 0, False: 302k]
  ------------------
   21|   302k|#endif
   22|   302k|    return p;
   23|   302k|}
memory.c:roaring_bitmap_aligned_free:
   25|   302k|static void roaring_bitmap_aligned_free(void* memblock) {
   26|       |#ifdef _MSC_VER
   27|       |    _aligned_free(memblock);
   28|       |#elif defined(__MINGW32__) || defined(__MINGW64__)
   29|       |    __mingw_aligned_free(memblock);
   30|       |#else
   31|   302k|    free(memblock);
   32|   302k|#endif
   33|   302k|}

roaring_bitmap_create_with_capacity:
   86|  25.7k|roaring_bitmap_t *roaring_bitmap_create_with_capacity(uint32_t cap) {
   87|  25.7k|    roaring_bitmap_t *ans =
   88|  25.7k|        (roaring_bitmap_t *)roaring_malloc(sizeof(roaring_bitmap_t));
   89|  25.7k|    if (!ans) {
  ------------------
  |  Branch (89:9): [True: 0, False: 25.7k]
  ------------------
   90|      0|        return NULL;
   91|      0|    }
   92|  25.7k|    bool is_ok = ra_init_with_capacity(&ans->high_low_container, cap);
   93|  25.7k|    if (!is_ok) {
  ------------------
  |  Branch (93:9): [True: 0, False: 25.7k]
  ------------------
   94|      0|        roaring_free(ans);
   95|      0|        return NULL;
   96|      0|    }
   97|  25.7k|    return ans;
   98|  25.7k|}
roaring_bitmap_init_with_capacity:
  100|  32.4k|bool roaring_bitmap_init_with_capacity(roaring_bitmap_t *r, uint32_t cap) {
  101|  32.4k|    return ra_init_with_capacity(&r->high_low_container, cap);
  102|  32.4k|}
roaring_bitmap_add_many:
  135|  19.4k|                             const uint32_t *vals) {
  136|  19.4k|    uint32_t val;
  137|  19.4k|    const uint32_t *start = vals;
  138|  19.4k|    const uint32_t *end = vals + n_args;
  139|  19.4k|    const uint32_t *current_val = start;
  140|       |
  141|  19.4k|    if (n_args == 0) {
  ------------------
  |  Branch (141:9): [True: 0, False: 19.4k]
  ------------------
  142|      0|        return;
  143|      0|    }
  144|       |
  145|  19.4k|    uint8_t typecode;
  146|  19.4k|    int idx;
  147|  19.4k|    container_t *container;
  148|  19.4k|    val = *current_val;
  149|  19.4k|    container = containerptr_roaring_bitmap_add(r, val, &typecode, &idx);
  150|  19.4k|    roaring_bulk_context_t context = {container, idx, (uint16_t)(val >> 16),
  151|  19.4k|                                      typecode};
  152|       |
  153|  8.11M|    for (; current_val != end; current_val++) {
  ------------------
  |  Branch (153:12): [True: 8.10M, False: 19.4k]
  ------------------
  154|  8.10M|        memcpy(&val, current_val, sizeof(val));
  155|  8.10M|        add_bulk_impl(r, &context, val);
  156|  8.10M|    }
  157|  19.4k|}
roaring_bitmap_add_range_closed:
  252|  2.88k|                                     uint32_t max) {
  253|  2.88k|    if (min > max) {
  ------------------
  |  Branch (253:9): [True: 0, False: 2.88k]
  ------------------
  254|      0|        return;
  255|      0|    }
  256|       |
  257|  2.88k|    roaring_array_t *ra = &r->high_low_container;
  258|       |
  259|  2.88k|    uint32_t min_key = min >> 16;
  260|  2.88k|    uint32_t max_key = max >> 16;
  261|       |
  262|  2.88k|    int32_t num_required_containers = max_key - min_key + 1;
  263|  2.88k|    int32_t suffix_length =
  264|  2.88k|        count_greater(ra->keys, ra->size, (uint16_t)max_key);
  265|  2.88k|    int32_t prefix_length =
  266|  2.88k|        count_less(ra->keys, ra->size - suffix_length, (uint16_t)min_key);
  267|  2.88k|    int32_t common_length = ra->size - prefix_length - suffix_length;
  268|       |
  269|  2.88k|    if (num_required_containers > common_length) {
  ------------------
  |  Branch (269:9): [True: 1.33k, False: 1.54k]
  ------------------
  270|  1.33k|        ra_shift_tail(ra, suffix_length,
  271|  1.33k|                      num_required_containers - common_length);
  272|  1.33k|    }
  273|       |
  274|  2.88k|    int32_t src = prefix_length + common_length - 1;
  275|  2.88k|    int32_t dst = ra->size - suffix_length - 1;
  276|  79.4k|    for (uint32_t key = max_key; key != min_key - 1;
  ------------------
  |  Branch (276:34): [True: 76.5k, False: 2.88k]
  ------------------
  277|  76.5k|         key--) {  // beware of min_key==0
  278|  76.5k|        uint32_t container_min = (min_key == key) ? (min & 0xffff) : 0;
  ------------------
  |  Branch (278:34): [True: 2.88k, False: 73.7k]
  ------------------
  279|  76.5k|        uint32_t container_max = (max_key == key) ? (max & 0xffff) : 0xffff;
  ------------------
  |  Branch (279:34): [True: 2.88k, False: 73.7k]
  ------------------
  280|  76.5k|        container_t *new_container;
  281|  76.5k|        uint8_t new_type;
  282|       |
  283|  76.5k|        if (src >= 0 && ra->keys[src] == key) {
  ------------------
  |  Branch (283:13): [True: 76.5k, False: 0]
  |  Branch (283:25): [True: 3.34k, False: 73.2k]
  ------------------
  284|  3.34k|            ra_unshare_container_at_index(ra, (uint16_t)src);
  285|  3.34k|            new_container =
  286|  3.34k|                container_add_range(ra->containers[src], ra->typecodes[src],
  287|  3.34k|                                    container_min, container_max, &new_type);
  288|  3.34k|            if (new_container != ra->containers[src]) {
  ------------------
  |  Branch (288:17): [True: 2.23k, False: 1.10k]
  ------------------
  289|  2.23k|                container_free(ra->containers[src], ra->typecodes[src]);
  290|  2.23k|            }
  291|  3.34k|            src--;
  292|  73.2k|        } else {
  293|  73.2k|            new_container = container_from_range(&new_type, container_min,
  294|  73.2k|                                                 container_max + 1, 1);
  295|  73.2k|        }
  296|  76.5k|        ra_replace_key_and_container_at_index(ra, dst, (uint16_t)key,
  297|  76.5k|                                              new_container, new_type);
  298|  76.5k|        dst--;
  299|  76.5k|    }
  300|  2.88k|}
roaring_bitmap_remove_range_closed:
  303|  7.43k|                                        uint32_t max) {
  304|  7.43k|    if (min > max) {
  ------------------
  |  Branch (304:9): [True: 866, False: 6.56k]
  ------------------
  305|    866|        return;
  306|    866|    }
  307|       |
  308|  6.56k|    roaring_array_t *ra = &r->high_low_container;
  309|       |
  310|  6.56k|    uint32_t min_key = min >> 16;
  311|  6.56k|    uint32_t max_key = max >> 16;
  312|       |
  313|  6.56k|    int32_t src = count_less(ra->keys, ra->size, (uint16_t)min_key);
  314|  6.56k|    int32_t dst = src;
  315|  26.6k|    while (src < ra->size && ra->keys[src] <= max_key) {
  ------------------
  |  Branch (315:12): [True: 22.2k, False: 4.37k]
  |  Branch (315:30): [True: 20.0k, False: 2.18k]
  ------------------
  316|  20.0k|        uint32_t container_min =
  317|  20.0k|            (min_key == ra->keys[src]) ? (min & 0xffff) : 0;
  ------------------
  |  Branch (317:13): [True: 6.13k, False: 13.9k]
  ------------------
  318|  20.0k|        uint32_t container_max =
  319|  20.0k|            (max_key == ra->keys[src]) ? (max & 0xffff) : 0xffff;
  ------------------
  |  Branch (319:13): [True: 5.80k, False: 14.2k]
  ------------------
  320|  20.0k|        ra_unshare_container_at_index(ra, (uint16_t)src);
  321|  20.0k|        container_t *new_container;
  322|  20.0k|        uint8_t new_type;
  323|  20.0k|        new_container =
  324|  20.0k|            container_remove_range(ra->containers[src], ra->typecodes[src],
  325|  20.0k|                                   container_min, container_max, &new_type);
  326|  20.0k|        if (new_container != ra->containers[src]) {
  ------------------
  |  Branch (326:13): [True: 14.0k, False: 6.02k]
  ------------------
  327|  14.0k|            container_free(ra->containers[src], ra->typecodes[src]);
  328|  14.0k|        }
  329|  20.0k|        if (new_container) {
  ------------------
  |  Branch (329:13): [True: 6.27k, False: 13.8k]
  ------------------
  330|  6.27k|            ra_replace_key_and_container_at_index(ra, dst, ra->keys[src],
  331|  6.27k|                                                  new_container, new_type);
  332|  6.27k|            dst++;
  333|  6.27k|        }
  334|  20.0k|        src++;
  335|  20.0k|    }
  336|  6.56k|    if (src > dst) {
  ------------------
  |  Branch (336:9): [True: 634, False: 5.93k]
  ------------------
  337|    634|        ra_shift_tail(ra, ra->size - src, dst - src);
  338|    634|    }
  339|  6.56k|}
roaring_bitmap_copy:
  525|    138|roaring_bitmap_t *roaring_bitmap_copy(const roaring_bitmap_t *r) {
  526|    138|    roaring_bitmap_t *ans =
  527|    138|        (roaring_bitmap_t *)roaring_malloc(sizeof(roaring_bitmap_t));
  528|    138|    if (!ans) {
  ------------------
  |  Branch (528:9): [True: 0, False: 138]
  ------------------
  529|      0|        return NULL;
  530|      0|    }
  531|    138|    if (!ra_init_with_capacity(  // allocation of list of containers can fail
  ------------------
  |  Branch (531:9): [True: 0, False: 138]
  ------------------
  532|    138|            &ans->high_low_container, r->high_low_container.size)) {
  533|      0|        roaring_free(ans);
  534|      0|        return NULL;
  535|      0|    }
  536|    138|    if (!ra_overwrite(  // memory allocation of individual containers may fail
  ------------------
  |  Branch (536:9): [True: 0, False: 138]
  ------------------
  537|    138|            &r->high_low_container, &ans->high_low_container, is_cow(r))) {
  538|      0|        roaring_bitmap_free(ans);  // overwrite should leave in freeable state
  539|      0|        return NULL;
  540|      0|    }
  541|    138|    roaring_bitmap_set_copy_on_write(ans, is_cow(r));
  542|    138|    return ans;
  543|    138|}
roaring_bitmap_overwrite:
  546|  14.5k|                              const roaring_bitmap_t *src) {
  547|  14.5k|    roaring_bitmap_set_copy_on_write(dest, is_cow(src));
  548|  14.5k|    return ra_overwrite(&src->high_low_container, &dest->high_low_container,
  549|  14.5k|                        is_cow(src));
  550|  14.5k|}
roaring_bitmap_clear:
  562|  64.8k|void roaring_bitmap_clear(roaring_bitmap_t *r) {
  563|  64.8k|    ra_reset(&r->high_low_container);
  564|  64.8k|}
roaring_bitmap_add:
  566|  6.48k|void roaring_bitmap_add(roaring_bitmap_t *r, uint32_t val) {
  567|  6.48k|    roaring_array_t *ra = &r->high_low_container;
  568|       |
  569|  6.48k|    const uint16_t hb = val >> 16;
  570|  6.48k|    const int i = ra_get_index(ra, hb);
  571|  6.48k|    uint8_t typecode;
  572|  6.48k|    if (i >= 0) {
  ------------------
  |  Branch (572:9): [True: 4.64k, False: 1.83k]
  ------------------
  573|  4.64k|        ra_unshare_container_at_index(ra, (uint16_t)i);
  574|  4.64k|        container_t *container =
  575|  4.64k|            ra_get_container_at_index(ra, (uint16_t)i, &typecode);
  576|  4.64k|        uint8_t newtypecode = typecode;
  577|  4.64k|        container_t *container2 =
  578|  4.64k|            container_add(container, val & 0xFFFF, typecode, &newtypecode);
  579|  4.64k|        if (container2 != container) {
  ------------------
  |  Branch (579:13): [True: 0, False: 4.64k]
  ------------------
  580|      0|            container_free(container, typecode);
  581|      0|            ra_set_container_at_index(&r->high_low_container, i, container2,
  582|      0|                                      newtypecode);
  583|      0|        }
  584|  4.64k|    } else {
  585|  1.83k|        array_container_t *newac = array_container_create();
  586|  1.83k|        container_t *container =
  587|  1.83k|            container_add(newac, val & 0xFFFF, ARRAY_CONTAINER_TYPE, &typecode);
  ------------------
  |  |   49|  1.83k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  588|       |        // we could just assume that it stays an array container
  589|  1.83k|        ra_insert_new_key_value_at(&r->high_low_container, -i - 1, hb,
  590|  1.83k|                                   container, typecode);
  591|  1.83k|    }
  592|  6.48k|}
roaring_bitmap_add_checked:
  594|  6.48k|bool roaring_bitmap_add_checked(roaring_bitmap_t *r, uint32_t val) {
  595|  6.48k|    const uint16_t hb = val >> 16;
  596|  6.48k|    const int i = ra_get_index(&r->high_low_container, hb);
  597|  6.48k|    uint8_t typecode;
  598|  6.48k|    bool result = false;
  599|  6.48k|    if (i >= 0) {
  ------------------
  |  Branch (599:9): [True: 4.87k, False: 1.60k]
  ------------------
  600|  4.87k|        ra_unshare_container_at_index(&r->high_low_container, (uint16_t)i);
  601|  4.87k|        container_t *container = ra_get_container_at_index(
  602|  4.87k|            &r->high_low_container, (uint16_t)i, &typecode);
  603|       |
  604|  4.87k|        const int oldCardinality =
  605|  4.87k|            container_get_cardinality(container, typecode);
  606|       |
  607|  4.87k|        uint8_t newtypecode = typecode;
  608|  4.87k|        container_t *container2 =
  609|  4.87k|            container_add(container, val & 0xFFFF, typecode, &newtypecode);
  610|  4.87k|        if (container2 != container) {
  ------------------
  |  Branch (610:13): [True: 0, False: 4.87k]
  ------------------
  611|      0|            container_free(container, typecode);
  612|      0|            ra_set_container_at_index(&r->high_low_container, i, container2,
  613|      0|                                      newtypecode);
  614|      0|            result = true;
  615|  4.87k|        } else {
  616|  4.87k|            const int newCardinality =
  617|  4.87k|                container_get_cardinality(container, newtypecode);
  618|       |
  619|  4.87k|            result = oldCardinality != newCardinality;
  620|  4.87k|        }
  621|  4.87k|    } else {
  622|  1.60k|        array_container_t *newac = array_container_create();
  623|  1.60k|        container_t *container =
  624|  1.60k|            container_add(newac, val & 0xFFFF, ARRAY_CONTAINER_TYPE, &typecode);
  ------------------
  |  |   49|  1.60k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  625|       |        // we could just assume that it stays an array container
  626|  1.60k|        ra_insert_new_key_value_at(&r->high_low_container, -i - 1, hb,
  627|  1.60k|                                   container, typecode);
  628|  1.60k|        result = true;
  629|  1.60k|    }
  630|       |
  631|  6.48k|    return result;
  632|  6.48k|}
roaring_bitmap_remove:
  634|  6.48k|void roaring_bitmap_remove(roaring_bitmap_t *r, uint32_t val) {
  635|  6.48k|    const uint16_t hb = val >> 16;
  636|  6.48k|    const int i = ra_get_index(&r->high_low_container, hb);
  637|  6.48k|    uint8_t typecode;
  638|  6.48k|    if (i >= 0) {
  ------------------
  |  Branch (638:9): [True: 5.83k, False: 644]
  ------------------
  639|  5.83k|        ra_unshare_container_at_index(&r->high_low_container, (uint16_t)i);
  640|  5.83k|        container_t *container = ra_get_container_at_index(
  641|  5.83k|            &r->high_low_container, (uint16_t)i, &typecode);
  642|  5.83k|        uint8_t newtypecode = typecode;
  643|  5.83k|        container_t *container2 =
  644|  5.83k|            container_remove(container, val & 0xFFFF, typecode, &newtypecode);
  645|  5.83k|        if (container2 != container) {
  ------------------
  |  Branch (645:13): [True: 12, False: 5.82k]
  ------------------
  646|     12|            container_free(container, typecode);
  647|     12|            ra_set_container_at_index(&r->high_low_container, i, container2,
  648|     12|                                      newtypecode);
  649|     12|        }
  650|  5.83k|        if (container_nonzero_cardinality(container2, newtypecode)) {
  ------------------
  |  Branch (650:13): [True: 5.77k, False: 61]
  ------------------
  651|  5.77k|            ra_set_container_at_index(&r->high_low_container, i, container2,
  652|  5.77k|                                      newtypecode);
  653|  5.77k|        } else {
  654|     61|            ra_remove_at_index_and_free(&r->high_low_container, i);
  655|     61|        }
  656|  5.83k|    }
  657|  6.48k|}
roaring_bitmap_remove_checked:
  659|  6.48k|bool roaring_bitmap_remove_checked(roaring_bitmap_t *r, uint32_t val) {
  660|  6.48k|    const uint16_t hb = val >> 16;
  661|  6.48k|    const int i = ra_get_index(&r->high_low_container, hb);
  662|  6.48k|    uint8_t typecode;
  663|  6.48k|    bool result = false;
  664|  6.48k|    if (i >= 0) {
  ------------------
  |  Branch (664:9): [True: 5.84k, False: 637]
  ------------------
  665|  5.84k|        ra_unshare_container_at_index(&r->high_low_container, (uint16_t)i);
  666|  5.84k|        container_t *container = ra_get_container_at_index(
  667|  5.84k|            &r->high_low_container, (uint16_t)i, &typecode);
  668|       |
  669|  5.84k|        const int oldCardinality =
  670|  5.84k|            container_get_cardinality(container, typecode);
  671|       |
  672|  5.84k|        uint8_t newtypecode = typecode;
  673|  5.84k|        container_t *container2 =
  674|  5.84k|            container_remove(container, val & 0xFFFF, typecode, &newtypecode);
  675|  5.84k|        if (container2 != container) {
  ------------------
  |  Branch (675:13): [True: 2, False: 5.84k]
  ------------------
  676|      2|            container_free(container, typecode);
  677|      2|            ra_set_container_at_index(&r->high_low_container, i, container2,
  678|      2|                                      newtypecode);
  679|      2|        }
  680|       |
  681|  5.84k|        const int newCardinality =
  682|  5.84k|            container_get_cardinality(container2, newtypecode);
  683|       |
  684|  5.84k|        if (newCardinality != 0) {
  ------------------
  |  Branch (684:13): [True: 5.83k, False: 8]
  ------------------
  685|  5.83k|            ra_set_container_at_index(&r->high_low_container, i, container2,
  686|  5.83k|                                      newtypecode);
  687|  5.83k|        } else {
  688|      8|            ra_remove_at_index_and_free(&r->high_low_container, i);
  689|      8|        }
  690|       |
  691|  5.84k|        result = oldCardinality != newCardinality;
  692|  5.84k|    }
  693|  6.48k|    return result;
  694|  6.48k|}
roaring_bitmap_and:
  732|  6.48k|                                     const roaring_bitmap_t *x2) {
  733|  6.48k|    uint8_t result_type = 0;
  734|  6.48k|    const int length1 = x1->high_low_container.size,
  735|  6.48k|              length2 = x2->high_low_container.size;
  736|  6.48k|    uint32_t neededcap = length1 > length2 ? length2 : length1;
  ------------------
  |  Branch (736:26): [True: 46, False: 6.43k]
  ------------------
  737|  6.48k|    roaring_bitmap_t *answer = roaring_bitmap_create_with_capacity(neededcap);
  738|  6.48k|    roaring_bitmap_set_copy_on_write(answer, is_cow(x1) || is_cow(x2));
  ------------------
  |  Branch (738:46): [True: 0, False: 6.48k]
  |  Branch (738:60): [True: 0, False: 6.48k]
  ------------------
  739|       |
  740|  6.48k|    int pos1 = 0, pos2 = 0;
  741|       |
  742|  12.9k|    while (pos1 < length1 && pos2 < length2) {
  ------------------
  |  Branch (742:12): [True: 6.48k, False: 6.43k]
  |  Branch (742:30): [True: 6.43k, False: 46]
  ------------------
  743|  6.43k|        const uint16_t s1 =
  744|  6.43k|            ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
  745|  6.43k|        const uint16_t s2 =
  746|  6.43k|            ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
  747|       |
  748|  6.43k|        if (s1 == s2) {
  ------------------
  |  Branch (748:13): [True: 6.36k, False: 74]
  ------------------
  749|  6.36k|            uint8_t type1, type2;
  750|  6.36k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
  751|  6.36k|                                                        (uint16_t)pos1, &type1);
  752|  6.36k|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
  753|  6.36k|                                                        (uint16_t)pos2, &type2);
  754|  6.36k|            container_t *c = container_and(c1, type1, c2, type2, &result_type);
  755|       |
  756|  6.36k|            if (container_nonzero_cardinality(c, result_type)) {
  ------------------
  |  Branch (756:17): [True: 6.05k, False: 305]
  ------------------
  757|  6.05k|                ra_append(&answer->high_low_container, s1, c, result_type);
  758|  6.05k|            } else {
  759|    305|                container_free(c, result_type);  // otherwise: memory leak!
  760|    305|            }
  761|  6.36k|            ++pos1;
  762|  6.36k|            ++pos2;
  763|  6.36k|        } else if (s1 < s2) {  // s1 < s2
  ------------------
  |  Branch (763:20): [True: 74, False: 0]
  ------------------
  764|     74|            pos1 = ra_advance_until(&x1->high_low_container, s2, pos1);
  765|     74|        } else {  // s1 > s2
  766|      0|            pos2 = ra_advance_until(&x2->high_low_container, s1, pos2);
  767|      0|        }
  768|  6.43k|    }
  769|  6.48k|    return answer;
  770|  6.48k|}
roaring_bitmap_and_inplace:
  813|  6.48k|                                const roaring_bitmap_t *x2) {
  814|  6.48k|    if (x1 == x2) return;
  ------------------
  |  Branch (814:9): [True: 0, False: 6.48k]
  ------------------
  815|  6.48k|    int pos1 = 0, pos2 = 0, intersection_size = 0;
  816|  6.48k|    const int length1 = ra_get_size(&x1->high_low_container);
  817|  6.48k|    const int length2 = ra_get_size(&x2->high_low_container);
  818|       |
  819|       |    // any skipped-over or newly emptied containers in x1
  820|       |    // have to be freed.
  821|  75.8k|    while (pos1 < length1 && pos2 < length2) {
  ------------------
  |  Branch (821:12): [True: 69.4k, False: 6.43k]
  |  Branch (821:30): [True: 69.3k, False: 46]
  ------------------
  822|  69.3k|        const uint16_t s1 =
  823|  69.3k|            ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
  824|  69.3k|        const uint16_t s2 =
  825|  69.3k|            ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
  826|       |
  827|  69.3k|        if (s1 == s2) {
  ------------------
  |  Branch (827:13): [True: 69.2k, False: 74]
  ------------------
  828|  69.2k|            uint8_t type1, type2, result_type;
  829|  69.2k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
  830|  69.2k|                                                        (uint16_t)pos1, &type1);
  831|  69.2k|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
  832|  69.2k|                                                        (uint16_t)pos2, &type2);
  833|       |
  834|       |            // We do the computation "in place" only when c1 is not a shared
  835|       |            // container. Rationale: using a shared container safely with in
  836|       |            // place computation would require making a copy and then doing the
  837|       |            // computation in place which is likely less efficient than avoiding
  838|       |            // in place entirely and always generating a new container.
  839|  69.2k|            container_t *c =
  840|  69.2k|                (type1 == SHARED_CONTAINER_TYPE)
  ------------------
  |  |   51|  69.2k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (840:17): [True: 0, False: 69.2k]
  ------------------
  841|  69.2k|                    ? container_and(c1, type1, c2, type2, &result_type)
  842|  69.2k|                    : container_iand(c1, type1, c2, type2, &result_type);
  843|       |
  844|  69.2k|            if (c != c1) {  // in this instance a new container was created, and
  ------------------
  |  Branch (844:17): [True: 62.9k, False: 6.38k]
  ------------------
  845|       |                            // we need to free the old one
  846|  62.9k|                container_free(c1, type1);
  847|  62.9k|            }
  848|  69.2k|            if (container_nonzero_cardinality(c, result_type)) {
  ------------------
  |  Branch (848:17): [True: 69.2k, False: 0]
  ------------------
  849|  69.2k|                ra_replace_key_and_container_at_index(&x1->high_low_container,
  850|  69.2k|                                                      intersection_size, s1, c,
  851|  69.2k|                                                      result_type);
  852|  69.2k|                intersection_size++;
  853|  69.2k|            } else {
  854|      0|                container_free(c, result_type);
  855|      0|            }
  856|  69.2k|            ++pos1;
  857|  69.2k|            ++pos2;
  858|  69.2k|        } else if (s1 < s2) {
  ------------------
  |  Branch (858:20): [True: 74, False: 0]
  ------------------
  859|     74|            pos1 = ra_advance_until_freeing(&x1->high_low_container, s2, pos1);
  860|     74|        } else {  // s1 > s2
  861|      0|            pos2 = ra_advance_until(&x2->high_low_container, s1, pos2);
  862|      0|        }
  863|  69.3k|    }
  864|       |
  865|       |    // if we ended early because x2 ran out, then all remaining in x1 should be
  866|       |    // freed
  867|  6.52k|    while (pos1 < length1) {
  ------------------
  |  Branch (867:12): [True: 46, False: 6.48k]
  ------------------
  868|     46|        container_free(x1->high_low_container.containers[pos1],
  869|     46|                       x1->high_low_container.typecodes[pos1]);
  870|     46|        ++pos1;
  871|     46|    }
  872|       |
  873|       |    // all containers after this have either been copied or freed
  874|  6.48k|    ra_downsize(&x1->high_low_container, intersection_size);
  875|  6.48k|}
roaring_bitmap_or:
  878|  6.48k|                                    const roaring_bitmap_t *x2) {
  879|  6.48k|    uint8_t result_type = 0;
  880|  6.48k|    const int length1 = x1->high_low_container.size,
  881|  6.48k|              length2 = x2->high_low_container.size;
  882|  6.48k|    if (0 == length1) {
  ------------------
  |  Branch (882:9): [True: 0, False: 6.48k]
  ------------------
  883|      0|        return roaring_bitmap_copy(x2);
  884|      0|    }
  885|  6.48k|    if (0 == length2) {
  ------------------
  |  Branch (885:9): [True: 46, False: 6.43k]
  ------------------
  886|     46|        return roaring_bitmap_copy(x1);
  887|     46|    }
  888|  6.43k|    roaring_bitmap_t *answer =
  889|  6.43k|        roaring_bitmap_create_with_capacity(length1 + length2);
  890|  6.43k|    roaring_bitmap_set_copy_on_write(answer, is_cow(x1) || is_cow(x2));
  ------------------
  |  Branch (890:46): [True: 0, False: 6.43k]
  |  Branch (890:60): [True: 0, False: 6.43k]
  ------------------
  891|  6.43k|    int pos1 = 0, pos2 = 0;
  892|  6.43k|    uint8_t type1, type2;
  893|  6.43k|    uint16_t s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
  894|  6.43k|    uint16_t s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
  895|  6.43k|    while (true) {
  ------------------
  |  Branch (895:12): [True: 6.43k, Folded]
  ------------------
  896|  6.43k|        if (s1 == s2) {
  ------------------
  |  Branch (896:13): [True: 6.36k, False: 74]
  ------------------
  897|  6.36k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
  898|  6.36k|                                                        (uint16_t)pos1, &type1);
  899|  6.36k|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
  900|  6.36k|                                                        (uint16_t)pos2, &type2);
  901|  6.36k|            container_t *c = container_or(c1, type1, c2, type2, &result_type);
  902|       |
  903|       |            // since we assume that the initial containers are non-empty, the
  904|       |            // result here
  905|       |            // can only be non-empty
  906|  6.36k|            ra_append(&answer->high_low_container, s1, c, result_type);
  907|  6.36k|            ++pos1;
  908|  6.36k|            ++pos2;
  909|  6.36k|            if (pos1 == length1) break;
  ------------------
  |  Branch (909:17): [True: 6.36k, False: 0]
  ------------------
  910|      0|            if (pos2 == length2) break;
  ------------------
  |  Branch (910:17): [True: 0, False: 0]
  ------------------
  911|      0|            s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
  912|      0|            s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
  913|       |
  914|     74|        } else if (s1 < s2) {  // s1 < s2
  ------------------
  |  Branch (914:20): [True: 74, False: 0]
  ------------------
  915|     74|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
  916|     74|                                                        (uint16_t)pos1, &type1);
  917|       |            // c1 = container_clone(c1, type1);
  918|     74|            c1 = get_copy_of_container(c1, &type1, is_cow(x1));
  919|     74|            if (is_cow(x1)) {
  ------------------
  |  Branch (919:17): [True: 0, False: 74]
  ------------------
  920|      0|                ra_set_container_at_index(&x1->high_low_container, pos1, c1,
  921|      0|                                          type1);
  922|      0|            }
  923|     74|            ra_append(&answer->high_low_container, s1, c1, type1);
  924|     74|            pos1++;
  925|     74|            if (pos1 == length1) break;
  ------------------
  |  Branch (925:17): [True: 74, False: 0]
  ------------------
  926|      0|            s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
  927|       |
  928|      0|        } else {  // s1 > s2
  929|      0|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
  930|      0|                                                        (uint16_t)pos2, &type2);
  931|       |            // c2 = container_clone(c2, type2);
  932|      0|            c2 = get_copy_of_container(c2, &type2, is_cow(x2));
  933|      0|            if (is_cow(x2)) {
  ------------------
  |  Branch (933:17): [True: 0, False: 0]
  ------------------
  934|      0|                ra_set_container_at_index(&x2->high_low_container, pos2, c2,
  935|      0|                                          type2);
  936|      0|            }
  937|      0|            ra_append(&answer->high_low_container, s2, c2, type2);
  938|      0|            pos2++;
  939|      0|            if (pos2 == length2) break;
  ------------------
  |  Branch (939:17): [True: 0, False: 0]
  ------------------
  940|      0|            s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
  941|      0|        }
  942|  6.43k|    }
  943|  6.43k|    if (pos1 == length1) {
  ------------------
  |  Branch (943:9): [True: 6.43k, False: 0]
  ------------------
  944|  6.43k|        ra_append_copy_range(&answer->high_low_container,
  945|  6.43k|                             &x2->high_low_container, pos2, length2,
  946|  6.43k|                             is_cow(x2));
  947|  6.43k|    } else if (pos2 == length2) {
  ------------------
  |  Branch (947:16): [True: 0, False: 0]
  ------------------
  948|      0|        ra_append_copy_range(&answer->high_low_container,
  949|      0|                             &x1->high_low_container, pos1, length1,
  950|      0|                             is_cow(x1));
  951|      0|    }
  952|  6.43k|    return answer;
  953|  6.48k|}
roaring_bitmap_or_inplace:
 1064|  6.48k|                               const roaring_bitmap_t *x2) {
 1065|  6.48k|    uint8_t result_type = 0;
 1066|  6.48k|    int length1 = x1->high_low_container.size;
 1067|  6.48k|    const int length2 = x2->high_low_container.size;
 1068|       |
 1069|  6.48k|    if (0 == length2) return;
  ------------------
  |  Branch (1069:9): [True: 0, False: 6.48k]
  ------------------
 1070|       |
 1071|  6.48k|    if (0 == length1) {
  ------------------
  |  Branch (1071:9): [True: 0, False: 6.48k]
  ------------------
 1072|      0|        roaring_bitmap_overwrite(x1, x2);
 1073|      0|        return;
 1074|      0|    }
 1075|  6.48k|    int pos1 = 0, pos2 = 0;
 1076|  6.48k|    uint8_t type1, type2;
 1077|  6.48k|    uint16_t s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1078|  6.48k|    uint16_t s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 1079|  6.48k|    while (true) {
  ------------------
  |  Branch (1079:12): [True: 6.48k, Folded]
  ------------------
 1080|  6.48k|        if (s1 == s2) {
  ------------------
  |  Branch (1080:13): [True: 6.48k, False: 0]
  ------------------
 1081|  6.48k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
 1082|  6.48k|                                                        (uint16_t)pos1, &type1);
 1083|  6.48k|            if (!container_is_full(c1, type1)) {
  ------------------
  |  Branch (1083:17): [True: 6.48k, False: 0]
  ------------------
 1084|  6.48k|                container_t *c2 = ra_get_container_at_index(
 1085|  6.48k|                    &x2->high_low_container, (uint16_t)pos2, &type2);
 1086|  6.48k|                container_t *c =
 1087|  6.48k|                    (type1 == SHARED_CONTAINER_TYPE)
  ------------------
  |  |   51|  6.48k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (1087:21): [True: 0, False: 6.48k]
  ------------------
 1088|  6.48k|                        ? container_or(c1, type1, c2, type2, &result_type)
 1089|  6.48k|                        : container_ior(c1, type1, c2, type2, &result_type);
 1090|       |
 1091|  6.48k|                if (c != c1) {  // in this instance a new container was created,
  ------------------
  |  Branch (1091:21): [True: 4.64k, False: 1.83k]
  ------------------
 1092|       |                                // and we need to free the old one
 1093|  4.64k|                    container_free(c1, type1);
 1094|  4.64k|                }
 1095|  6.48k|                ra_set_container_at_index(&x1->high_low_container, pos1, c,
 1096|  6.48k|                                          result_type);
 1097|  6.48k|            }
 1098|  6.48k|            ++pos1;
 1099|  6.48k|            ++pos2;
 1100|  6.48k|            if (pos1 == length1) break;
  ------------------
  |  Branch (1100:17): [True: 6.48k, False: 0]
  ------------------
 1101|      0|            if (pos2 == length2) break;
  ------------------
  |  Branch (1101:17): [True: 0, False: 0]
  ------------------
 1102|      0|            s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1103|      0|            s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 1104|       |
 1105|      0|        } else if (s1 < s2) {  // s1 < s2
  ------------------
  |  Branch (1105:20): [True: 0, False: 0]
  ------------------
 1106|      0|            pos1++;
 1107|      0|            if (pos1 == length1) break;
  ------------------
  |  Branch (1107:17): [True: 0, False: 0]
  ------------------
 1108|      0|            s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1109|       |
 1110|      0|        } else {  // s1 > s2
 1111|      0|            roaring_inplace_merge_bulk(x1, x2, pos1, pos1, pos2, false);
 1112|      0|            return;
 1113|      0|        }
 1114|  6.48k|    }
 1115|  6.48k|    if (pos1 == length1) {
  ------------------
  |  Branch (1115:9): [True: 6.48k, False: 0]
  ------------------
 1116|  6.48k|        ra_append_copy_range(&x1->high_low_container, &x2->high_low_container,
 1117|  6.48k|                             pos2, length2, is_cow(x2));
 1118|  6.48k|    }
 1119|  6.48k|}
roaring_bitmap_xor:
 1122|  6.48k|                                     const roaring_bitmap_t *x2) {
 1123|  6.48k|    uint8_t result_type = 0;
 1124|  6.48k|    const int length1 = x1->high_low_container.size,
 1125|  6.48k|              length2 = x2->high_low_container.size;
 1126|  6.48k|    if (0 == length1) {
  ------------------
  |  Branch (1126:9): [True: 0, False: 6.48k]
  ------------------
 1127|      0|        return roaring_bitmap_copy(x2);
 1128|      0|    }
 1129|  6.48k|    if (0 == length2) {
  ------------------
  |  Branch (1129:9): [True: 46, False: 6.43k]
  ------------------
 1130|     46|        return roaring_bitmap_copy(x1);
 1131|     46|    }
 1132|  6.43k|    roaring_bitmap_t *answer =
 1133|  6.43k|        roaring_bitmap_create_with_capacity(length1 + length2);
 1134|  6.43k|    roaring_bitmap_set_copy_on_write(answer, is_cow(x1) || is_cow(x2));
  ------------------
  |  Branch (1134:46): [True: 0, False: 6.43k]
  |  Branch (1134:60): [True: 0, False: 6.43k]
  ------------------
 1135|  6.43k|    int pos1 = 0, pos2 = 0;
 1136|  6.43k|    uint8_t type1, type2;
 1137|  6.43k|    uint16_t s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1138|  6.43k|    uint16_t s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 1139|  6.43k|    while (true) {
  ------------------
  |  Branch (1139:12): [True: 6.43k, Folded]
  ------------------
 1140|  6.43k|        if (s1 == s2) {
  ------------------
  |  Branch (1140:13): [True: 6.36k, False: 74]
  ------------------
 1141|  6.36k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
 1142|  6.36k|                                                        (uint16_t)pos1, &type1);
 1143|  6.36k|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
 1144|  6.36k|                                                        (uint16_t)pos2, &type2);
 1145|  6.36k|            container_t *c = container_xor(c1, type1, c2, type2, &result_type);
 1146|       |
 1147|  6.36k|            if (container_nonzero_cardinality(c, result_type)) {
  ------------------
  |  Branch (1147:17): [True: 6.34k, False: 17]
  ------------------
 1148|  6.34k|                ra_append(&answer->high_low_container, s1, c, result_type);
 1149|  6.34k|            } else {
 1150|     17|                container_free(c, result_type);
 1151|     17|            }
 1152|  6.36k|            ++pos1;
 1153|  6.36k|            ++pos2;
 1154|  6.36k|            if (pos1 == length1) break;
  ------------------
  |  Branch (1154:17): [True: 6.36k, False: 0]
  ------------------
 1155|      0|            if (pos2 == length2) break;
  ------------------
  |  Branch (1155:17): [True: 0, False: 0]
  ------------------
 1156|      0|            s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1157|      0|            s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 1158|       |
 1159|     74|        } else if (s1 < s2) {  // s1 < s2
  ------------------
  |  Branch (1159:20): [True: 74, False: 0]
  ------------------
 1160|     74|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
 1161|     74|                                                        (uint16_t)pos1, &type1);
 1162|     74|            c1 = get_copy_of_container(c1, &type1, is_cow(x1));
 1163|     74|            if (is_cow(x1)) {
  ------------------
  |  Branch (1163:17): [True: 0, False: 74]
  ------------------
 1164|      0|                ra_set_container_at_index(&x1->high_low_container, pos1, c1,
 1165|      0|                                          type1);
 1166|      0|            }
 1167|     74|            ra_append(&answer->high_low_container, s1, c1, type1);
 1168|     74|            pos1++;
 1169|     74|            if (pos1 == length1) break;
  ------------------
  |  Branch (1169:17): [True: 74, False: 0]
  ------------------
 1170|      0|            s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1171|       |
 1172|      0|        } else {  // s1 > s2
 1173|      0|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
 1174|      0|                                                        (uint16_t)pos2, &type2);
 1175|      0|            c2 = get_copy_of_container(c2, &type2, is_cow(x2));
 1176|      0|            if (is_cow(x2)) {
  ------------------
  |  Branch (1176:17): [True: 0, False: 0]
  ------------------
 1177|      0|                ra_set_container_at_index(&x2->high_low_container, pos2, c2,
 1178|      0|                                          type2);
 1179|      0|            }
 1180|      0|            ra_append(&answer->high_low_container, s2, c2, type2);
 1181|      0|            pos2++;
 1182|      0|            if (pos2 == length2) break;
  ------------------
  |  Branch (1182:17): [True: 0, False: 0]
  ------------------
 1183|      0|            s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 1184|      0|        }
 1185|  6.43k|    }
 1186|  6.43k|    if (pos1 == length1) {
  ------------------
  |  Branch (1186:9): [True: 6.43k, False: 0]
  ------------------
 1187|  6.43k|        ra_append_copy_range(&answer->high_low_container,
 1188|  6.43k|                             &x2->high_low_container, pos2, length2,
 1189|  6.43k|                             is_cow(x2));
 1190|  6.43k|    } else if (pos2 == length2) {
  ------------------
  |  Branch (1190:16): [True: 0, False: 0]
  ------------------
 1191|      0|        ra_append_copy_range(&answer->high_low_container,
 1192|      0|                             &x1->high_low_container, pos1, length1,
 1193|      0|                             is_cow(x1));
 1194|      0|    }
 1195|  6.43k|    return answer;
 1196|  6.48k|}
roaring_bitmap_xor_inplace:
 1201|  6.48k|                                const roaring_bitmap_t *x2) {
 1202|  6.48k|    assert(x1 != x2);
 1203|  6.48k|    uint8_t result_type = 0;
 1204|  6.48k|    int length1 = x1->high_low_container.size;
 1205|  6.48k|    const int length2 = x2->high_low_container.size;
 1206|       |
 1207|  6.48k|    if (0 == length2) return;
  ------------------
  |  Branch (1207:9): [True: 15, False: 6.46k]
  ------------------
 1208|       |
 1209|  6.46k|    if (0 == length1) {
  ------------------
  |  Branch (1209:9): [True: 1.54k, False: 4.92k]
  ------------------
 1210|  1.54k|        roaring_bitmap_overwrite(x1, x2);
 1211|  1.54k|        return;
 1212|  1.54k|    }
 1213|       |
 1214|       |    // XOR can have new containers inserted from x2, but can also
 1215|       |    // lose containers when x1 and x2 are nonempty and identical.
 1216|       |
 1217|  4.92k|    int pos1 = 0, pos2 = 0;
 1218|  4.92k|    uint8_t type1, type2;
 1219|  4.92k|    uint16_t s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1220|  4.92k|    uint16_t s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 1221|  7.09k|    while (true) {
  ------------------
  |  Branch (1221:12): [True: 7.09k, Folded]
  ------------------
 1222|  7.09k|        if (s1 == s2) {
  ------------------
  |  Branch (1222:13): [True: 6.98k, False: 111]
  ------------------
 1223|  6.98k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
 1224|  6.98k|                                                        (uint16_t)pos1, &type1);
 1225|  6.98k|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
 1226|  6.98k|                                                        (uint16_t)pos2, &type2);
 1227|       |
 1228|       |            // We do the computation "in place" only when c1 is not a shared
 1229|       |            // container. Rationale: using a shared container safely with in
 1230|       |            // place computation would require making a copy and then doing the
 1231|       |            // computation in place which is likely less efficient than avoiding
 1232|       |            // in place entirely and always generating a new container.
 1233|       |
 1234|  6.98k|            container_t *c;
 1235|  6.98k|            if (type1 == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|  6.98k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (1235:17): [True: 0, False: 6.98k]
  ------------------
 1236|      0|                c = container_xor(c1, type1, c2, type2, &result_type);
 1237|      0|                shared_container_free(CAST_shared(c1));  // so release
  ------------------
  |  |   79|      0|#define CAST_shared(c) CAST(shared_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1238|  6.98k|            } else {
 1239|  6.98k|                c = container_ixor(c1, type1, c2, type2, &result_type);
 1240|  6.98k|            }
 1241|       |
 1242|  6.98k|            if (container_nonzero_cardinality(c, result_type)) {
  ------------------
  |  Branch (1242:17): [True: 4.57k, False: 2.40k]
  ------------------
 1243|  4.57k|                ra_set_container_at_index(&x1->high_low_container, pos1, c,
 1244|  4.57k|                                          result_type);
 1245|  4.57k|                ++pos1;
 1246|  4.57k|            } else {
 1247|  2.40k|                container_free(c, result_type);
 1248|  2.40k|                roaring_inplace_merge_bulk(x1, x2, pos1, pos1 + 1, pos2 + 1,
 1249|  2.40k|                                           true);
 1250|  2.40k|                return;
 1251|  2.40k|            }
 1252|       |
 1253|  4.57k|            ++pos2;
 1254|  4.57k|            if (pos1 == length1) break;
  ------------------
  |  Branch (1254:17): [True: 2.40k, False: 2.17k]
  ------------------
 1255|  2.17k|            if (pos2 == length2) break;
  ------------------
  |  Branch (1255:17): [True: 0, False: 2.17k]
  ------------------
 1256|  2.17k|            s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1257|  2.17k|            s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 1258|       |
 1259|  2.17k|        } else if (s1 < s2) {  // s1 < s2
  ------------------
  |  Branch (1259:20): [True: 0, False: 111]
  ------------------
 1260|      0|            pos1++;
 1261|      0|            if (pos1 == length1) break;
  ------------------
  |  Branch (1261:17): [True: 0, False: 0]
  ------------------
 1262|      0|            s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1263|       |
 1264|    111|        } else {  // s1 > s2
 1265|    111|            roaring_inplace_merge_bulk(x1, x2, pos1, pos1, pos2, true);
 1266|    111|            return;
 1267|    111|        }
 1268|  7.09k|    }
 1269|  2.40k|    if (pos1 == length1) {
  ------------------
  |  Branch (1269:9): [True: 2.40k, False: 0]
  ------------------
 1270|  2.40k|        ra_append_copy_range(&x1->high_low_container, &x2->high_low_container,
 1271|  2.40k|                             pos2, length2, is_cow(x2));
 1272|  2.40k|    }
 1273|  2.40k|}
roaring_bitmap_andnot:
 1276|  6.48k|                                        const roaring_bitmap_t *x2) {
 1277|  6.48k|    uint8_t result_type = 0;
 1278|  6.48k|    const int length1 = x1->high_low_container.size,
 1279|  6.48k|              length2 = x2->high_low_container.size;
 1280|  6.48k|    if (0 == length1) {
  ------------------
  |  Branch (1280:9): [True: 0, False: 6.48k]
  ------------------
 1281|      0|        roaring_bitmap_t *empty_bitmap = roaring_bitmap_create();
 1282|      0|        roaring_bitmap_set_copy_on_write(empty_bitmap,
 1283|      0|                                         is_cow(x1) || is_cow(x2));
  ------------------
  |  Branch (1283:42): [True: 0, False: 0]
  |  Branch (1283:56): [True: 0, False: 0]
  ------------------
 1284|      0|        return empty_bitmap;
 1285|      0|    }
 1286|  6.48k|    if (0 == length2) {
  ------------------
  |  Branch (1286:9): [True: 46, False: 6.43k]
  ------------------
 1287|     46|        return roaring_bitmap_copy(x1);
 1288|     46|    }
 1289|  6.43k|    roaring_bitmap_t *answer = roaring_bitmap_create_with_capacity(length1);
 1290|  6.43k|    roaring_bitmap_set_copy_on_write(answer, is_cow(x1) || is_cow(x2));
  ------------------
  |  Branch (1290:46): [True: 0, False: 6.43k]
  |  Branch (1290:60): [True: 0, False: 6.43k]
  ------------------
 1291|       |
 1292|  6.43k|    int pos1 = 0, pos2 = 0;
 1293|  6.43k|    uint8_t type1, type2;
 1294|  6.43k|    uint16_t s1 = 0;
 1295|  6.43k|    uint16_t s2 = 0;
 1296|  6.43k|    while (true) {
  ------------------
  |  Branch (1296:12): [True: 6.43k, Folded]
  ------------------
 1297|  6.43k|        s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1298|  6.43k|        s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 1299|       |
 1300|  6.43k|        if (s1 == s2) {
  ------------------
  |  Branch (1300:13): [True: 6.36k, False: 74]
  ------------------
 1301|  6.36k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
 1302|  6.36k|                                                        (uint16_t)pos1, &type1);
 1303|  6.36k|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
 1304|  6.36k|                                                        (uint16_t)pos2, &type2);
 1305|  6.36k|            container_t *c =
 1306|  6.36k|                container_andnot(c1, type1, c2, type2, &result_type);
 1307|       |
 1308|  6.36k|            if (container_nonzero_cardinality(c, result_type)) {
  ------------------
  |  Branch (1308:17): [True: 6.11k, False: 250]
  ------------------
 1309|  6.11k|                ra_append(&answer->high_low_container, s1, c, result_type);
 1310|  6.11k|            } else {
 1311|    250|                container_free(c, result_type);
 1312|    250|            }
 1313|  6.36k|            ++pos1;
 1314|  6.36k|            ++pos2;
 1315|  6.36k|            if (pos1 == length1) break;
  ------------------
  |  Branch (1315:17): [True: 6.36k, False: 0]
  ------------------
 1316|      0|            if (pos2 == length2) break;
  ------------------
  |  Branch (1316:17): [True: 0, False: 0]
  ------------------
 1317|     74|        } else if (s1 < s2) {  // s1 < s2
  ------------------
  |  Branch (1317:20): [True: 74, False: 0]
  ------------------
 1318|     74|            const int next_pos1 =
 1319|     74|                ra_advance_until(&x1->high_low_container, s2, pos1);
 1320|     74|            ra_append_copy_range(&answer->high_low_container,
 1321|     74|                                 &x1->high_low_container, pos1, next_pos1,
 1322|     74|                                 is_cow(x1));
 1323|       |            // TODO : perhaps some of the copy_on_write should be based on
 1324|       |            // answer rather than x1 (more stringent?).  Many similar cases
 1325|     74|            pos1 = next_pos1;
 1326|     74|            if (pos1 == length1) break;
  ------------------
  |  Branch (1326:17): [True: 74, False: 0]
  ------------------
 1327|     74|        } else {  // s1 > s2
 1328|      0|            pos2 = ra_advance_until(&x2->high_low_container, s1, pos2);
 1329|      0|            if (pos2 == length2) break;
  ------------------
  |  Branch (1329:17): [True: 0, False: 0]
  ------------------
 1330|      0|        }
 1331|  6.43k|    }
 1332|  6.43k|    if (pos2 == length2) {
  ------------------
  |  Branch (1332:9): [True: 4.00k, False: 2.42k]
  ------------------
 1333|  4.00k|        ra_append_copy_range(&answer->high_low_container,
 1334|  4.00k|                             &x1->high_low_container, pos1, length1,
 1335|  4.00k|                             is_cow(x1));
 1336|  4.00k|    }
 1337|  6.43k|    return answer;
 1338|  6.48k|}
roaring_bitmap_andnot_inplace:
 1343|  6.48k|                                   const roaring_bitmap_t *x2) {
 1344|  6.48k|    assert(x1 != x2);
 1345|       |
 1346|  6.48k|    uint8_t result_type = 0;
 1347|  6.48k|    int length1 = x1->high_low_container.size;
 1348|  6.48k|    const int length2 = x2->high_low_container.size;
 1349|  6.48k|    int intersection_size = 0;
 1350|       |
 1351|  6.48k|    if (0 == length2) return;
  ------------------
  |  Branch (1351:9): [True: 425, False: 6.05k]
  ------------------
 1352|       |
 1353|  6.05k|    if (0 == length1) {
  ------------------
  |  Branch (1353:9): [True: 0, False: 6.05k]
  ------------------
 1354|      0|        roaring_bitmap_clear(x1);
 1355|      0|        return;
 1356|      0|    }
 1357|       |
 1358|  6.05k|    int pos1 = 0, pos2 = 0;
 1359|  6.05k|    uint8_t type1, type2;
 1360|  6.05k|    uint16_t s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1361|  6.05k|    uint16_t s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 1362|  6.05k|    while (true) {
  ------------------
  |  Branch (1362:12): [True: 6.05k, Folded]
  ------------------
 1363|  6.05k|        if (s1 == s2) {
  ------------------
  |  Branch (1363:13): [True: 6.05k, False: 0]
  ------------------
 1364|  6.05k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
 1365|  6.05k|                                                        (uint16_t)pos1, &type1);
 1366|  6.05k|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
 1367|  6.05k|                                                        (uint16_t)pos2, &type2);
 1368|       |
 1369|       |            // We do the computation "in place" only when c1 is not a shared
 1370|       |            // container. Rationale: using a shared container safely with in
 1371|       |            // place computation would require making a copy and then doing the
 1372|       |            // computation in place which is likely less efficient than avoiding
 1373|       |            // in place entirely and always generating a new container.
 1374|       |
 1375|  6.05k|            container_t *c;
 1376|  6.05k|            if (type1 == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|  6.05k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (1376:17): [True: 0, False: 6.05k]
  ------------------
 1377|      0|                c = container_andnot(c1, type1, c2, type2, &result_type);
 1378|      0|                shared_container_free(CAST_shared(c1));  // release
  ------------------
  |  |   79|      0|#define CAST_shared(c) CAST(shared_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1379|  6.05k|            } else {
 1380|  6.05k|                c = container_iandnot(c1, type1, c2, type2, &result_type);
 1381|  6.05k|            }
 1382|       |
 1383|  6.05k|            if (container_nonzero_cardinality(c, result_type)) {
  ------------------
  |  Branch (1383:17): [True: 4.50k, False: 1.54k]
  ------------------
 1384|  4.50k|                ra_replace_key_and_container_at_index(&x1->high_low_container,
 1385|  4.50k|                                                      intersection_size++, s1,
 1386|  4.50k|                                                      c, result_type);
 1387|  4.50k|            } else {
 1388|  1.54k|                container_free(c, result_type);
 1389|  1.54k|            }
 1390|       |
 1391|  6.05k|            ++pos1;
 1392|  6.05k|            ++pos2;
 1393|  6.05k|            if (pos1 == length1) break;
  ------------------
  |  Branch (1393:17): [True: 3.79k, False: 2.25k]
  ------------------
 1394|  2.25k|            if (pos2 == length2) break;
  ------------------
  |  Branch (1394:17): [True: 2.25k, False: 0]
  ------------------
 1395|      0|            s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1396|      0|            s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 1397|       |
 1398|      0|        } else if (s1 < s2) {  // s1 < s2
  ------------------
  |  Branch (1398:20): [True: 0, False: 0]
  ------------------
 1399|      0|            if (pos1 != intersection_size) {
  ------------------
  |  Branch (1399:17): [True: 0, False: 0]
  ------------------
 1400|      0|                container_t *c1 = ra_get_container_at_index(
 1401|      0|                    &x1->high_low_container, (uint16_t)pos1, &type1);
 1402|       |
 1403|      0|                ra_replace_key_and_container_at_index(
 1404|      0|                    &x1->high_low_container, intersection_size, s1, c1, type1);
 1405|      0|            }
 1406|      0|            intersection_size++;
 1407|      0|            pos1++;
 1408|      0|            if (pos1 == length1) break;
  ------------------
  |  Branch (1408:17): [True: 0, False: 0]
  ------------------
 1409|      0|            s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1410|       |
 1411|      0|        } else {  // s1 > s2
 1412|      0|            pos2 = ra_advance_until(&x2->high_low_container, s1, pos2);
 1413|      0|            if (pos2 == length2) break;
  ------------------
  |  Branch (1413:17): [True: 0, False: 0]
  ------------------
 1414|      0|            s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 1415|      0|        }
 1416|  6.05k|    }
 1417|       |
 1418|  6.05k|    if (pos1 < length1) {
  ------------------
  |  Branch (1418:9): [True: 2.25k, False: 3.79k]
  ------------------
 1419|       |        // all containers between intersection_size and
 1420|       |        // pos1 are junk.  However, they have either been moved
 1421|       |        // (thus still referenced) or involved in an iandnot
 1422|       |        // that will clean up all containers that could not be reused.
 1423|       |        // Thus we should not free the junk containers between
 1424|       |        // intersection_size and pos1.
 1425|  2.25k|        if (pos1 > intersection_size) {
  ------------------
  |  Branch (1425:13): [True: 39, False: 2.21k]
  ------------------
 1426|       |            // left slide of remaining items
 1427|     39|            ra_copy_range(&x1->high_low_container, pos1, length1,
 1428|     39|                          intersection_size);
 1429|     39|        }
 1430|       |        // else current placement is fine
 1431|  2.25k|        intersection_size += (length1 - pos1);
 1432|  2.25k|    }
 1433|  6.05k|    ra_downsize(&x1->high_low_container, intersection_size);
 1434|  6.05k|}
roaring_bitmap_get_cardinality:
 1436|  64.8k|uint64_t roaring_bitmap_get_cardinality(const roaring_bitmap_t *r) {
 1437|  64.8k|    const roaring_array_t *ra = &r->high_low_container;
 1438|       |
 1439|  64.8k|    uint64_t card = 0;
 1440|   443k|    for (int i = 0; i < ra->size; ++i)
  ------------------
  |  Branch (1440:21): [True: 378k, False: 64.8k]
  ------------------
 1441|   378k|        card += container_get_cardinality(ra->containers[i], ra->typecodes[i]);
 1442|  64.8k|    return card;
 1443|  64.8k|}
roaring_bitmap_is_empty:
 1506|  12.9k|bool roaring_bitmap_is_empty(const roaring_bitmap_t *r) {
 1507|  12.9k|    return r->high_low_container.size == 0;
 1508|  12.9k|}
roaring_bitmap_to_uint32_array:
 1510|  6.48k|void roaring_bitmap_to_uint32_array(const roaring_bitmap_t *r, uint32_t *ans) {
 1511|  6.48k|    ra_to_uint32_array(&r->high_low_container, ans);
 1512|  6.48k|}
roaring_bitmap_run_optimize:
 1530|  12.9k|bool roaring_bitmap_run_optimize(roaring_bitmap_t *r) {
 1531|  12.9k|    bool answer = false;
 1532|  25.9k|    for (int i = 0; i < r->high_low_container.size; i++) {
  ------------------
  |  Branch (1532:21): [True: 12.9k, False: 12.9k]
  ------------------
 1533|  12.9k|        uint8_t type_original, type_after;
 1534|  12.9k|        ra_unshare_container_at_index(
 1535|  12.9k|            &r->high_low_container,
 1536|  12.9k|            (uint16_t)i);  // TODO: this introduces extra cloning!
 1537|  12.9k|        container_t *c = ra_get_container_at_index(&r->high_low_container,
 1538|  12.9k|                                                   (uint16_t)i, &type_original);
 1539|  12.9k|        container_t *c1 = convert_run_optimize(c, type_original, &type_after);
 1540|  12.9k|        if (type_after == RUN_CONTAINER_TYPE) {
  ------------------
  |  |   50|  12.9k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (1540:13): [True: 4.10k, False: 8.85k]
  ------------------
 1541|       |            answer = true;
 1542|  4.10k|        }
 1543|  12.9k|        ra_set_container_at_index(&r->high_low_container, i, c1, type_after);
 1544|  12.9k|    }
 1545|  12.9k|    return answer;
 1546|  12.9k|}
roaring_bitmap_shrink_to_fit:
 1548|  6.48k|size_t roaring_bitmap_shrink_to_fit(roaring_bitmap_t *r) {
 1549|  6.48k|    size_t answer = 0;
 1550|  12.9k|    for (int i = 0; i < r->high_low_container.size; i++) {
  ------------------
  |  Branch (1550:21): [True: 6.48k, False: 6.48k]
  ------------------
 1551|  6.48k|        uint8_t type_original;
 1552|  6.48k|        container_t *c = ra_get_container_at_index(&r->high_low_container,
 1553|  6.48k|                                                   (uint16_t)i, &type_original);
 1554|  6.48k|        answer += container_shrink_to_fit(c, type_original);
 1555|  6.48k|    }
 1556|  6.48k|    answer += ra_shrink_to_fit(&r->high_low_container);
 1557|  6.48k|    return answer;
 1558|  6.48k|}
roaring_bitmap_remove_run_compression:
 1564|  6.48k|bool roaring_bitmap_remove_run_compression(roaring_bitmap_t *r) {
 1565|  6.48k|    bool answer = false;
 1566|  87.6k|    for (int i = 0; i < r->high_low_container.size; i++) {
  ------------------
  |  Branch (1566:21): [True: 81.1k, False: 6.48k]
  ------------------
 1567|  81.1k|        uint8_t type_original, type_after;
 1568|  81.1k|        container_t *c = ra_get_container_at_index(&r->high_low_container,
 1569|  81.1k|                                                   (uint16_t)i, &type_original);
 1570|  81.1k|        if (get_container_type(c, type_original) == RUN_CONTAINER_TYPE) {
  ------------------
  |  |   50|  81.1k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (1570:13): [True: 73.4k, False: 7.73k]
  ------------------
 1571|  73.4k|            answer = true;
 1572|  73.4k|            if (type_original == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|  73.4k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (1572:17): [True: 0, False: 73.4k]
  ------------------
 1573|      0|                run_container_t *truec = CAST_run(CAST_shared(c)->container);
  ------------------
  |  |   77|      0|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1574|      0|                int32_t card = run_container_cardinality(truec);
 1575|      0|                container_t *c1 = convert_to_bitset_or_array_container(
 1576|      0|                    truec, card, &type_after);
 1577|      0|                shared_container_free(CAST_shared(c));  // frees run as needed
  ------------------
  |  |   79|      0|#define CAST_shared(c) CAST(shared_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1578|      0|                ra_set_container_at_index(&r->high_low_container, i, c1,
 1579|      0|                                          type_after);
 1580|       |
 1581|  73.4k|            } else {
 1582|  73.4k|                int32_t card = run_container_cardinality(CAST_run(c));
  ------------------
  |  |   77|  73.4k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  73.4k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1583|  73.4k|                container_t *c1 = convert_to_bitset_or_array_container(
 1584|  73.4k|                    CAST_run(c), card, &type_after);
  ------------------
  |  |   77|  73.4k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  73.4k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1585|  73.4k|                run_container_free(CAST_run(c));
  ------------------
  |  |   77|  73.4k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  73.4k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1586|  73.4k|                ra_set_container_at_index(&r->high_low_container, i, c1,
 1587|  73.4k|                                          type_after);
 1588|  73.4k|            }
 1589|  73.4k|        }
 1590|  81.1k|    }
 1591|  6.48k|    return answer;
 1592|  6.48k|}
roaring_bitmap_portable_size_in_bytes:
 1627|  12.9k|size_t roaring_bitmap_portable_size_in_bytes(const roaring_bitmap_t *r) {
 1628|  12.9k|    return ra_portable_size_in_bytes(&r->high_low_container);
 1629|  12.9k|}
roaring_bitmap_portable_deserialize_safe:
 1632|  12.9k|                                                           size_t maxbytes) {
 1633|  12.9k|    roaring_bitmap_t *ans =
 1634|  12.9k|        (roaring_bitmap_t *)roaring_malloc(sizeof(roaring_bitmap_t));
 1635|  12.9k|    if (ans == NULL) {
  ------------------
  |  Branch (1635:9): [True: 0, False: 12.9k]
  ------------------
 1636|      0|        return NULL;
 1637|      0|    }
 1638|  12.9k|    size_t bytesread;
 1639|  12.9k|    bool is_ok = ra_portable_deserialize(&ans->high_low_container, buf,
 1640|  12.9k|                                         maxbytes, &bytesread);
 1641|  12.9k|    if (!is_ok) {
  ------------------
  |  Branch (1641:9): [True: 6.46k, False: 6.49k]
  ------------------
 1642|  6.46k|        roaring_free(ans);
 1643|  6.46k|        return NULL;
 1644|  6.46k|    }
 1645|  6.49k|    roaring_bitmap_set_copy_on_write(ans, false);
 1646|  6.49k|    if (!is_ok) {
  ------------------
  |  Branch (1646:9): [True: 0, False: 6.49k]
  ------------------
 1647|      0|        roaring_free(ans);
 1648|      0|        return NULL;
 1649|      0|    }
 1650|  6.49k|    return ans;
 1651|  6.49k|}
roaring_bitmap_portable_serialize:
 1662|  6.48k|size_t roaring_bitmap_portable_serialize(const roaring_bitmap_t *r, char *buf) {
 1663|  6.48k|    return ra_portable_serialize(&r->high_low_container, buf);
 1664|  6.48k|}
roaring_iterate:
 1745|  6.46k|                     void *ptr) {
 1746|  6.46k|    const roaring_array_t *ra = &r->high_low_container;
 1747|       |
 1748|  75.8k|    for (int i = 0; i < ra->size; ++i)
  ------------------
  |  Branch (1748:21): [True: 69.3k, False: 6.46k]
  ------------------
 1749|  69.3k|        if (!container_iterate(ra->containers[i], ra->typecodes[i],
  ------------------
  |  Branch (1749:13): [True: 0, False: 69.3k]
  ------------------
 1750|  69.3k|                               ((uint32_t)ra->keys[i]) << 16, iterator, ptr)) {
 1751|      0|            return false;
 1752|      0|        }
 1753|  6.46k|    return true;
 1754|  6.46k|}
roaring_iterator_init:
 1861|  12.9k|                           roaring_uint32_iterator_t *newit) {
 1862|  12.9k|    newit->parent = r;
 1863|  12.9k|    newit->container_index = 0;
 1864|  12.9k|    newit->has_value = loadfirstvalue(newit);
 1865|  12.9k|}
roaring_uint32_iterator_move_equalorlarger:
 1893|  6.48k|                                                uint32_t val) {
 1894|  6.48k|    uint16_t hb = val >> 16;
 1895|  6.48k|    const int i = ra_get_index(&it->parent->high_low_container, hb);
 1896|  6.48k|    if (i >= 0) {
  ------------------
  |  Branch (1896:9): [True: 6.40k, False: 73]
  ------------------
 1897|  6.40k|        uint32_t lowvalue =
 1898|  6.40k|            container_maximum(it->parent->high_low_container.containers[i],
 1899|  6.40k|                              it->parent->high_low_container.typecodes[i]);
 1900|  6.40k|        uint16_t lb = val & 0xFFFF;
 1901|  6.40k|        if (lowvalue < lb) {
  ------------------
  |  Branch (1901:13): [True: 23, False: 6.38k]
  ------------------
 1902|       |            // will have to load first value of next container
 1903|     23|            it->container_index = i + 1;
 1904|  6.38k|        } else {
 1905|       |            // the value is necessarily within the range of the container
 1906|  6.38k|            it->container_index = i;
 1907|  6.38k|            it->has_value = loadfirstvalue_largeorequal(it, val);
 1908|  6.38k|            return it->has_value;
 1909|  6.38k|        }
 1910|  6.40k|    } else {
 1911|       |        // there is no matching, so we are going for the next container
 1912|     73|        it->container_index = -i - 1;
 1913|     73|    }
 1914|     96|    it->has_value = loadfirstvalue(it);
 1915|     96|    return it->has_value;
 1916|  6.48k|}
roaring_uint32_iterator_advance:
 1918|   335k|bool roaring_uint32_iterator_advance(roaring_uint32_iterator_t *it) {
 1919|   335k|    if (it->container_index >= it->parent->high_low_container.size) {
  ------------------
  |  Branch (1919:9): [True: 0, False: 335k]
  ------------------
 1920|      0|        return (it->has_value = false);
 1921|      0|    }
 1922|   335k|    if (it->container_index < 0) {
  ------------------
  |  Branch (1922:9): [True: 0, False: 335k]
  ------------------
 1923|      0|        it->container_index = 0;
 1924|      0|        return (it->has_value = loadfirstvalue(it));
 1925|      0|    }
 1926|   335k|    uint16_t low16 = (uint16_t)it->current_value;
 1927|   335k|    if (container_iterator_next(it->container, it->typecode, &it->container_it,
  ------------------
  |  Branch (1927:9): [True: 329k, False: 6.23k]
  ------------------
 1928|   335k|                                &low16)) {
 1929|   329k|        it->current_value = it->highbits | low16;
 1930|   329k|        return (it->has_value = true);
 1931|   329k|    }
 1932|  6.23k|    it->container_index++;
 1933|  6.23k|    return (it->has_value = loadfirstvalue(it));
 1934|   335k|}
roaring_bitmap_equals:
 2129|  12.9k|                           const roaring_bitmap_t *r2) {
 2130|  12.9k|    const roaring_array_t *ra1 = &r1->high_low_container;
 2131|  12.9k|    const roaring_array_t *ra2 = &r2->high_low_container;
 2132|       |
 2133|  12.9k|    if (ra1->size != ra2->size) {
  ------------------
  |  Branch (2133:9): [True: 2.55k, False: 10.4k]
  ------------------
 2134|  2.55k|        return false;
 2135|  2.55k|    }
 2136|  95.5k|    for (int i = 0; i < ra1->size; ++i) {
  ------------------
  |  Branch (2136:21): [True: 85.1k, False: 10.3k]
  ------------------
 2137|  85.1k|        if (ra1->keys[i] != ra2->keys[i]) {
  ------------------
  |  Branch (2137:13): [True: 23, False: 85.0k]
  ------------------
 2138|     23|            return false;
 2139|     23|        }
 2140|  85.1k|    }
 2141|  91.5k|    for (int i = 0; i < ra1->size; ++i) {
  ------------------
  |  Branch (2141:21): [True: 85.0k, False: 6.48k]
  ------------------
 2142|  85.0k|        bool areequal = container_equals(ra1->containers[i], ra1->typecodes[i],
 2143|  85.0k|                                         ra2->containers[i], ra2->typecodes[i]);
 2144|  85.0k|        if (!areequal) {
  ------------------
  |  Branch (2144:13): [True: 3.90k, False: 81.1k]
  ------------------
 2145|  3.90k|            return false;
 2146|  3.90k|        }
 2147|  85.0k|    }
 2148|  6.48k|    return true;
 2149|  10.3k|}
roaring_bitmap_is_subset:
 2152|  11.7k|                              const roaring_bitmap_t *r2) {
 2153|  11.7k|    const roaring_array_t *ra1 = &r1->high_low_container;
 2154|  11.7k|    const roaring_array_t *ra2 = &r2->high_low_container;
 2155|       |
 2156|  11.7k|    const int length1 = ra1->size, length2 = ra2->size;
 2157|       |
 2158|  11.7k|    int pos1 = 0, pos2 = 0;
 2159|       |
 2160|  11.7k|    while (pos1 < length1 && pos2 < length2) {
  ------------------
  |  Branch (2160:12): [True: 11.2k, False: 500]
  |  Branch (2160:30): [True: 11.2k, False: 46]
  ------------------
 2161|  11.2k|        const uint16_t s1 = ra_get_key_at_index(ra1, (uint16_t)pos1);
 2162|  11.2k|        const uint16_t s2 = ra_get_key_at_index(ra2, (uint16_t)pos2);
 2163|       |
 2164|  11.2k|        if (s1 == s2) {
  ------------------
  |  Branch (2164:13): [True: 11.1k, False: 114]
  ------------------
 2165|  11.1k|            uint8_t type1, type2;
 2166|  11.1k|            container_t *c1 =
 2167|  11.1k|                ra_get_container_at_index(ra1, (uint16_t)pos1, &type1);
 2168|  11.1k|            container_t *c2 =
 2169|  11.1k|                ra_get_container_at_index(ra2, (uint16_t)pos2, &type2);
 2170|  11.1k|            if (!container_is_subset(c1, type1, c2, type2)) return false;
  ------------------
  |  Branch (2170:17): [True: 11.1k, False: 0]
  ------------------
 2171|      0|            ++pos1;
 2172|      0|            ++pos2;
 2173|    114|        } else if (s1 < s2) {  // s1 < s2
  ------------------
  |  Branch (2173:20): [True: 114, False: 0]
  ------------------
 2174|    114|            return false;
 2175|    114|        } else {  // s1 > s2
 2176|      0|            pos2 = ra_advance_until(ra2, s1, pos2);
 2177|      0|        }
 2178|  11.2k|    }
 2179|    546|    if (pos1 == length1)
  ------------------
  |  Branch (2179:9): [True: 500, False: 46]
  ------------------
 2180|    500|        return true;
 2181|     46|    else
 2182|     46|        return false;
 2183|    546|}
roaring_bitmap_flip_inplace:
 2352|  6.48k|                                 uint64_t range_end) {
 2353|  6.48k|    if (range_start >= range_end || range_start > (uint64_t)UINT32_MAX + 1) {
  ------------------
  |  Branch (2353:9): [True: 5.95k, False: 525]
  |  Branch (2353:37): [True: 0, False: 525]
  ------------------
 2354|  5.95k|        return;
 2355|  5.95k|    }
 2356|    525|    roaring_bitmap_flip_inplace_closed(x1, (uint32_t)range_start,
 2357|    525|                                       (uint32_t)(range_end - 1));
 2358|    525|}
roaring_bitmap_flip_inplace_closed:
 2362|  7.00k|                                        uint32_t range_end) {
 2363|  7.00k|    if (range_start > range_end) {
  ------------------
  |  Branch (2363:9): [True: 176, False: 6.82k]
  ------------------
 2364|    176|        return;  // empty range
 2365|    176|    }
 2366|       |
 2367|  6.82k|    uint16_t hb_start = (uint16_t)(range_start >> 16);
 2368|  6.82k|    const uint16_t lb_start = (uint16_t)range_start;
 2369|  6.82k|    uint16_t hb_end = (uint16_t)(range_end >> 16);
 2370|  6.82k|    const uint16_t lb_end = (uint16_t)range_end;
 2371|       |
 2372|  6.82k|    if (hb_start == hb_end) {
  ------------------
  |  Branch (2372:9): [True: 6.36k, False: 467]
  ------------------
 2373|  6.36k|        inplace_flip_container(&x1->high_low_container, hb_start, lb_start,
 2374|  6.36k|                               lb_end);
 2375|  6.36k|    } else {
 2376|       |        // start and end containers are distinct
 2377|    467|        if (lb_start > 0) {
  ------------------
  |  Branch (2377:13): [True: 356, False: 111]
  ------------------
 2378|       |            // handle first (partial) container
 2379|    356|            inplace_flip_container(&x1->high_low_container, hb_start, lb_start,
 2380|    356|                                   0xFFFF);
 2381|    356|            ++hb_start;  // for the full containers.  Can't wrap.
 2382|    356|        }
 2383|       |
 2384|    467|        if (lb_end != 0xFFFF) --hb_end;
  ------------------
  |  Branch (2384:13): [True: 442, False: 25]
  ------------------
 2385|       |
 2386|  25.0k|        for (uint32_t hb = hb_start; hb <= hb_end; ++hb) {
  ------------------
  |  Branch (2386:38): [True: 24.5k, False: 467]
  ------------------
 2387|  24.5k|            inplace_fully_flip_container(&x1->high_low_container, (uint16_t)hb);
 2388|  24.5k|        }
 2389|       |        // handle a partial final container
 2390|    467|        if (lb_end != 0xFFFF) {
  ------------------
  |  Branch (2390:13): [True: 442, False: 25]
  ------------------
 2391|    442|            inplace_flip_container(&x1->high_low_container, hb_end + 1, 0,
 2392|    442|                                   lb_end);
 2393|    442|            ++hb_end;
 2394|    442|        }
 2395|    467|    }
 2396|  6.82k|}
roaring_bitmap_rank:
 2862|  6.48k|uint64_t roaring_bitmap_rank(const roaring_bitmap_t *bm, uint32_t x) {
 2863|  6.48k|    uint64_t size = 0;
 2864|  6.48k|    uint32_t xhigh = x >> 16;
 2865|  6.48k|    for (int i = 0; i < bm->high_low_container.size; i++) {
  ------------------
  |  Branch (2865:21): [True: 6.48k, False: 0]
  ------------------
 2866|  6.48k|        uint32_t key = bm->high_low_container.keys[i];
 2867|  6.48k|        if (xhigh > key) {
  ------------------
  |  Branch (2867:13): [True: 0, False: 6.48k]
  ------------------
 2868|      0|            size +=
 2869|      0|                container_get_cardinality(bm->high_low_container.containers[i],
 2870|      0|                                          bm->high_low_container.typecodes[i]);
 2871|  6.48k|        } else if (xhigh == key) {
  ------------------
  |  Branch (2871:20): [True: 6.48k, False: 0]
  ------------------
 2872|  6.48k|            return size + container_rank(bm->high_low_container.containers[i],
 2873|  6.48k|                                         bm->high_low_container.typecodes[i],
 2874|  6.48k|                                         x & 0xFFFF);
 2875|  6.48k|        } else {
 2876|      0|            return size;
 2877|      0|        }
 2878|  6.48k|    }
 2879|      0|    return size;
 2880|  6.48k|}
roaring_bitmap_minimum:
 2945|  6.48k|uint32_t roaring_bitmap_minimum(const roaring_bitmap_t *bm) {
 2946|  6.48k|    if (bm->high_low_container.size > 0) {
  ------------------
  |  Branch (2946:9): [True: 6.43k, False: 46]
  ------------------
 2947|  6.43k|        container_t *c = bm->high_low_container.containers[0];
 2948|  6.43k|        uint8_t type = bm->high_low_container.typecodes[0];
 2949|  6.43k|        uint32_t key = bm->high_low_container.keys[0];
 2950|  6.43k|        uint32_t lowvalue = container_minimum(c, type);
 2951|  6.43k|        return lowvalue | (key << 16);
 2952|  6.43k|    }
 2953|     46|    return UINT32_MAX;
 2954|  6.48k|}
roaring_bitmap_maximum:
 2960|  6.48k|uint32_t roaring_bitmap_maximum(const roaring_bitmap_t *bm) {
 2961|  6.48k|    if (bm->high_low_container.size > 0) {
  ------------------
  |  Branch (2961:9): [True: 6.43k, False: 46]
  ------------------
 2962|  6.43k|        container_t *container =
 2963|  6.43k|            bm->high_low_container.containers[bm->high_low_container.size - 1];
 2964|  6.43k|        uint8_t typecode =
 2965|  6.43k|            bm->high_low_container.typecodes[bm->high_low_container.size - 1];
 2966|  6.43k|        uint32_t key =
 2967|  6.43k|            bm->high_low_container.keys[bm->high_low_container.size - 1];
 2968|  6.43k|        uint32_t lowvalue = container_maximum(container, typecode);
 2969|  6.43k|        return lowvalue | (key << 16);
 2970|  6.43k|    }
 2971|     46|    return 0;
 2972|  6.48k|}
roaring_bitmap_select:
 2975|  6.48k|                           uint32_t *element) {
 2976|  6.48k|    container_t *container;
 2977|  6.48k|    uint8_t typecode;
 2978|  6.48k|    uint16_t key;
 2979|  6.48k|    uint32_t start_rank = 0;
 2980|  6.48k|    int i = 0;
 2981|  6.48k|    bool valid = false;
 2982|  12.9k|    while (!valid && i < bm->high_low_container.size) {
  ------------------
  |  Branch (2982:12): [True: 6.90k, False: 6.05k]
  |  Branch (2982:22): [True: 6.48k, False: 425]
  ------------------
 2983|  6.48k|        container = bm->high_low_container.containers[i];
 2984|  6.48k|        typecode = bm->high_low_container.typecodes[i];
 2985|  6.48k|        valid =
 2986|  6.48k|            container_select(container, typecode, &start_rank, rank, element);
 2987|  6.48k|        i++;
 2988|  6.48k|    }
 2989|       |
 2990|  6.48k|    if (valid) {
  ------------------
  |  Branch (2990:9): [True: 6.05k, False: 425]
  ------------------
 2991|  6.05k|        key = bm->high_low_container.keys[i - 1];
 2992|  6.05k|        *element |= (((uint32_t)key) << 16);  // w/o cast, key promotes signed
 2993|  6.05k|        return true;
 2994|  6.05k|    } else
 2995|    425|        return false;
 2996|  6.48k|}
roaring_bitmap_intersect:
 2999|  6.48k|                              const roaring_bitmap_t *x2) {
 3000|  6.48k|    const int length1 = x1->high_low_container.size,
 3001|  6.48k|              length2 = x2->high_low_container.size;
 3002|  6.48k|    uint64_t answer = 0;
 3003|  6.48k|    int pos1 = 0, pos2 = 0;
 3004|       |
 3005|  6.85k|    while (pos1 < length1 && pos2 < length2) {
  ------------------
  |  Branch (3005:12): [True: 6.48k, False: 379]
  |  Branch (3005:30): [True: 6.43k, False: 46]
  ------------------
 3006|  6.43k|        const uint16_t s1 =
 3007|  6.43k|            ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 3008|  6.43k|        const uint16_t s2 =
 3009|  6.43k|            ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 3010|       |
 3011|  6.43k|        if (s1 == s2) {
  ------------------
  |  Branch (3011:13): [True: 6.36k, False: 74]
  ------------------
 3012|  6.36k|            uint8_t type1, type2;
 3013|  6.36k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
 3014|  6.36k|                                                        (uint16_t)pos1, &type1);
 3015|  6.36k|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
 3016|  6.36k|                                                        (uint16_t)pos2, &type2);
 3017|  6.36k|            if (container_intersect(c1, type1, c2, type2)) return true;
  ------------------
  |  Branch (3017:17): [True: 6.05k, False: 305]
  ------------------
 3018|    305|            ++pos1;
 3019|    305|            ++pos2;
 3020|    305|        } else if (s1 < s2) {  // s1 < s2
  ------------------
  |  Branch (3020:20): [True: 74, False: 0]
  ------------------
 3021|     74|            pos1 = ra_advance_until(&x1->high_low_container, s2, pos1);
 3022|     74|        } else {  // s1 > s2
 3023|      0|            pos2 = ra_advance_until(&x2->high_low_container, s1, pos2);
 3024|      0|        }
 3025|  6.43k|    }
 3026|    425|    return answer != 0;
 3027|  6.48k|}
roaring_bitmap_and_cardinality:
 3049|  25.9k|                                        const roaring_bitmap_t *x2) {
 3050|  25.9k|    const int length1 = x1->high_low_container.size,
 3051|  25.9k|              length2 = x2->high_low_container.size;
 3052|  25.9k|    uint64_t answer = 0;
 3053|  25.9k|    int pos1 = 0, pos2 = 0;
 3054|  51.6k|    while (pos1 < length1 && pos2 < length2) {
  ------------------
  |  Branch (3054:12): [True: 25.9k, False: 25.7k]
  |  Branch (3054:30): [True: 25.7k, False: 184]
  ------------------
 3055|  25.7k|        const uint16_t s1 =
 3056|  25.7k|            ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 3057|  25.7k|        const uint16_t s2 =
 3058|  25.7k|            ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 3059|       |
 3060|  25.7k|        if (s1 == s2) {
  ------------------
  |  Branch (3060:13): [True: 25.4k, False: 296]
  ------------------
 3061|  25.4k|            uint8_t type1, type2;
 3062|  25.4k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
 3063|  25.4k|                                                        (uint16_t)pos1, &type1);
 3064|  25.4k|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
 3065|  25.4k|                                                        (uint16_t)pos2, &type2);
 3066|  25.4k|            answer += container_and_cardinality(c1, type1, c2, type2);
 3067|  25.4k|            ++pos1;
 3068|  25.4k|            ++pos2;
 3069|  25.4k|        } else if (s1 < s2) {  // s1 < s2
  ------------------
  |  Branch (3069:20): [True: 296, False: 0]
  ------------------
 3070|    296|            pos1 = ra_advance_until(&x1->high_low_container, s2, pos1);
 3071|    296|        } else {  // s1 > s2
 3072|      0|            pos2 = ra_advance_until(&x2->high_low_container, s1, pos2);
 3073|      0|        }
 3074|  25.7k|    }
 3075|  25.9k|    return answer;
 3076|  25.9k|}
roaring_bitmap_jaccard_index:
 3079|  6.48k|                                    const roaring_bitmap_t *x2) {
 3080|  6.48k|    const uint64_t c1 = roaring_bitmap_get_cardinality(x1);
 3081|  6.48k|    const uint64_t c2 = roaring_bitmap_get_cardinality(x2);
 3082|  6.48k|    const uint64_t inter = roaring_bitmap_and_cardinality(x1, x2);
 3083|  6.48k|    return (double)inter / (double)(c1 + c2 - inter);
 3084|  6.48k|}
roaring_bitmap_or_cardinality:
 3087|  6.48k|                                       const roaring_bitmap_t *x2) {
 3088|  6.48k|    const uint64_t c1 = roaring_bitmap_get_cardinality(x1);
 3089|  6.48k|    const uint64_t c2 = roaring_bitmap_get_cardinality(x2);
 3090|  6.48k|    const uint64_t inter = roaring_bitmap_and_cardinality(x1, x2);
 3091|  6.48k|    return c1 + c2 - inter;
 3092|  6.48k|}
roaring_bitmap_andnot_cardinality:
 3095|  6.48k|                                           const roaring_bitmap_t *x2) {
 3096|  6.48k|    const uint64_t c1 = roaring_bitmap_get_cardinality(x1);
 3097|  6.48k|    const uint64_t inter = roaring_bitmap_and_cardinality(x1, x2);
 3098|  6.48k|    return c1 - inter;
 3099|  6.48k|}
roaring_bitmap_xor_cardinality:
 3102|  6.48k|                                        const roaring_bitmap_t *x2) {
 3103|  6.48k|    const uint64_t c1 = roaring_bitmap_get_cardinality(x1);
 3104|  6.48k|    const uint64_t c2 = roaring_bitmap_get_cardinality(x2);
 3105|  6.48k|    const uint64_t inter = roaring_bitmap_and_cardinality(x1, x2);
 3106|  6.48k|    return c1 + c2 - 2 * inter;
 3107|  6.48k|}
roaring_bitmap_contains_range:
 3114|  6.48k|                                   uint64_t range_start, uint64_t range_end) {
 3115|  6.48k|    if (range_start >= range_end || range_start > (uint64_t)UINT32_MAX + 1) {
  ------------------
  |  Branch (3115:9): [True: 5.58k, False: 895]
  |  Branch (3115:37): [True: 0, False: 895]
  ------------------
 3116|  5.58k|        return true;
 3117|  5.58k|    }
 3118|    895|    return roaring_bitmap_contains_range_closed(r, (uint32_t)range_start,
 3119|    895|                                                (uint32_t)(range_end - 1));
 3120|  6.48k|}
roaring_bitmap_contains_range_closed:
 3128|    895|                                          uint32_t range_end) {
 3129|    895|    if (range_start > range_end) {
  ------------------
  |  Branch (3129:9): [True: 0, False: 895]
  ------------------
 3130|      0|        return true;
 3131|      0|    }  // empty range are always contained!
 3132|    895|    if (range_end == range_start) {
  ------------------
  |  Branch (3132:9): [True: 74, False: 821]
  ------------------
 3133|     74|        return roaring_bitmap_contains(r, (uint32_t)range_start);
 3134|     74|    }
 3135|    821|    uint16_t hb_rs = (uint16_t)(range_start >> 16);
 3136|    821|    uint16_t hb_re = (uint16_t)(range_end >> 16);
 3137|    821|    const int32_t span = hb_re - hb_rs;
 3138|    821|    const int32_t hlc_sz = ra_get_size(&r->high_low_container);
 3139|    821|    if (hlc_sz < span + 1) {
  ------------------
  |  Branch (3139:9): [True: 225, False: 596]
  ------------------
 3140|    225|        return false;
 3141|    225|    }
 3142|    596|    int32_t is = ra_get_index(&r->high_low_container, hb_rs);
 3143|    596|    int32_t ie = ra_get_index(&r->high_low_container, hb_re);
 3144|    596|    if ((ie < 0) || (is < 0) || ((ie - is) != span) || ie >= hlc_sz) {
  ------------------
  |  Branch (3144:9): [True: 31, False: 565]
  |  Branch (3144:21): [True: 17, False: 548]
  |  Branch (3144:33): [True: 9, False: 539]
  |  Branch (3144:56): [True: 0, False: 539]
  ------------------
 3145|     57|        return false;
 3146|     57|    }
 3147|    539|    const uint32_t lb_rs = range_start & 0xFFFF;
 3148|    539|    const uint32_t lb_re = (range_end & 0xFFFF) + 1;
 3149|    539|    uint8_t type;
 3150|    539|    container_t *c =
 3151|    539|        ra_get_container_at_index(&r->high_low_container, (uint16_t)is, &type);
 3152|    539|    if (hb_rs == hb_re) {
  ------------------
  |  Branch (3152:9): [True: 468, False: 71]
  ------------------
 3153|    468|        return container_contains_range(c, lb_rs, lb_re, type);
 3154|    468|    }
 3155|     71|    if (!container_contains_range(c, lb_rs, 1 << 16, type)) {
  ------------------
  |  Branch (3155:9): [True: 27, False: 44]
  ------------------
 3156|     27|        return false;
 3157|     27|    }
 3158|     44|    c = ra_get_container_at_index(&r->high_low_container, (uint16_t)ie, &type);
 3159|     44|    if (!container_contains_range(c, 0, lb_re, type)) {
  ------------------
  |  Branch (3159:9): [True: 5, False: 39]
  ------------------
 3160|      5|        return false;
 3161|      5|    }
 3162|    885|    for (int32_t i = is + 1; i < ie; ++i) {
  ------------------
  |  Branch (3162:30): [True: 861, False: 24]
  ------------------
 3163|    861|        c = ra_get_container_at_index(&r->high_low_container, (uint16_t)i,
 3164|    861|                                      &type);
 3165|    861|        if (!container_is_full(c, type)) {
  ------------------
  |  Branch (3165:13): [True: 15, False: 846]
  ------------------
 3166|     15|            return false;
 3167|     15|        }
 3168|    861|    }
 3169|     24|    return true;
 3170|     39|}
roaring_bitmap_is_strict_subset:
 3173|  6.48k|                                     const roaring_bitmap_t *r2) {
 3174|  6.48k|    return (roaring_bitmap_get_cardinality(r2) >
  ------------------
  |  Branch (3174:13): [True: 5.31k, False: 1.16k]
  ------------------
 3175|  6.48k|                roaring_bitmap_get_cardinality(r1) &&
 3176|  5.31k|            roaring_bitmap_is_subset(r1, r2));
  ------------------
  |  Branch (3176:13): [True: 250, False: 5.06k]
  ------------------
 3177|  6.48k|}
roaring.c:containerptr_roaring_bitmap_add:
   56|  19.4k|                                                           int *index) {
   57|  19.4k|    roaring_array_t *ra = &r->high_low_container;
   58|       |
   59|  19.4k|    uint16_t hb = val >> 16;
   60|  19.4k|    const int i = ra_get_index(ra, hb);
   61|  19.4k|    if (i >= 0) {
  ------------------
  |  Branch (61:9): [True: 6.48k, False: 12.9k]
  ------------------
   62|  6.48k|        ra_unshare_container_at_index(ra, (uint16_t)i);
   63|  6.48k|        container_t *c = ra_get_container_at_index(ra, (uint16_t)i, type);
   64|  6.48k|        uint8_t new_type = *type;
   65|  6.48k|        container_t *c2 = container_add(c, val & 0xFFFF, *type, &new_type);
   66|  6.48k|        *index = i;
   67|  6.48k|        if (c2 != c) {
  ------------------
  |  Branch (67:13): [True: 3, False: 6.47k]
  ------------------
   68|      3|            container_free(c, *type);
   69|      3|            ra_set_container_at_index(ra, i, c2, new_type);
   70|      3|            *type = new_type;
   71|      3|            return c2;
   72|  6.47k|        } else {
   73|  6.47k|            return c;
   74|  6.47k|        }
   75|  12.9k|    } else {
   76|  12.9k|        array_container_t *new_ac = array_container_create();
   77|  12.9k|        container_t *c =
   78|  12.9k|            container_add(new_ac, val & 0xFFFF, ARRAY_CONTAINER_TYPE, type);
  ------------------
  |  |   49|  12.9k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
   79|       |        // we could just assume that it stays an array container
   80|  12.9k|        ra_insert_new_key_value_at(ra, -i - 1, hb, c, *type);
   81|  12.9k|        *index = -i - 1;
   82|  12.9k|        return c;
   83|  12.9k|    }
   84|  19.4k|}
roaring.c:add_bulk_impl:
  106|  8.10M|                                 uint32_t val) {
  107|  8.10M|    uint16_t key = val >> 16;
  108|  8.10M|    if (context->container == NULL || context->key != key) {
  ------------------
  |  Branch (108:9): [True: 0, False: 8.10M]
  |  Branch (108:39): [True: 0, False: 8.10M]
  ------------------
  109|      0|        uint8_t typecode;
  110|      0|        int idx;
  111|      0|        context->container =
  112|      0|            containerptr_roaring_bitmap_add(r, val, &typecode, &idx);
  113|      0|        context->typecode = typecode;
  114|      0|        context->idx = idx;
  115|      0|        context->key = key;
  116|  8.10M|    } else {
  117|       |        // no need to seek the container, it is at hand
  118|       |        // because we already have the container at hand, we can do the
  119|       |        // insertion directly, bypassing the roaring_bitmap_add call
  120|  8.10M|        uint8_t new_typecode;
  121|  8.10M|        container_t *container2 = container_add(
  122|  8.10M|            context->container, val & 0xFFFF, context->typecode, &new_typecode);
  123|  8.10M|        if (container2 != context->container) {
  ------------------
  |  Branch (123:13): [True: 128, False: 8.09M]
  ------------------
  124|       |            // rare instance when we need to change the container type
  125|    128|            container_free(context->container, context->typecode);
  126|    128|            ra_set_container_at_index(&r->high_low_container, context->idx,
  127|    128|                                      container2, new_typecode);
  128|    128|            context->typecode = new_typecode;
  129|    128|            context->container = container2;
  130|    128|        }
  131|  8.10M|    }
  132|  8.10M|}
roaring.c:is_cow:
   41|   109k|static inline bool is_cow(const roaring_bitmap_t *r) {
   42|       |    return r->high_low_container.flags & ROARING_FLAG_COW;
  ------------------
  |  |   46|   109k|#define ROARING_FLAG_COW UINT8_C(0x1)
  ------------------
   43|   109k|}
roaring.c:roaring_inplace_merge_bulk:
  957|  2.51k|                                       int left, int right, bool is_xor) {
  958|  2.51k|    roaring_array_t *ra1 = &x1->high_low_container;
  959|  2.51k|    const roaring_array_t *ra2 = &x2->high_low_container;
  960|  2.51k|    const bool cow2 = is_cow(x2);
  961|  2.51k|    const int length1 = ra1->size;
  962|  2.51k|    const int length2 = ra2->size;
  963|       |
  964|  2.51k|    int distinct = 0;
  965|  2.51k|    {
  966|  2.51k|        int l = left, r = right;
  967|  63.3k|        while (l < length1 && r < length2) {
  ------------------
  |  Branch (967:16): [True: 60.8k, False: 2.51k]
  |  Branch (967:31): [True: 60.8k, False: 0]
  ------------------
  968|  60.8k|            uint16_t k1 = ra1->keys[l];
  969|  60.8k|            uint16_t k2 = ra2->keys[r];
  970|  60.8k|            if (k1 < k2) {
  ------------------
  |  Branch (970:17): [True: 0, False: 60.8k]
  ------------------
  971|      0|                l++;
  972|  60.8k|            } else if (k1 > k2) {
  ------------------
  |  Branch (972:24): [True: 111, False: 60.7k]
  ------------------
  973|    111|                r++;
  974|  60.7k|            } else {
  975|  60.7k|                l++;
  976|  60.7k|                r++;
  977|  60.7k|            }
  978|  60.8k|            distinct++;
  979|  60.8k|        }
  980|  2.51k|        distinct += (length1 - l) + (length2 - r);
  981|  2.51k|    }
  982|  2.51k|    const int total = dst + distinct;
  983|       |
  984|  2.51k|    roaring_array_t merged;
  985|  2.51k|    ra_init_with_capacity(&merged, total > 0 ? (uint32_t)total : 1);
  ------------------
  |  Branch (985:36): [True: 2.42k, False: 92]
  ------------------
  986|       |
  987|  4.69k|    for (int i = 0; i < dst; i++) {
  ------------------
  |  Branch (987:21): [True: 2.17k, False: 2.51k]
  ------------------
  988|  2.17k|        ra_append(&merged, ra1->keys[i], ra1->containers[i], ra1->typecodes[i]);
  989|  2.17k|    }
  990|       |
  991|  2.51k|    uint8_t result_type = 0;
  992|  63.3k|    while (left < length1 && right < length2) {
  ------------------
  |  Branch (992:12): [True: 60.8k, False: 2.51k]
  |  Branch (992:30): [True: 60.8k, False: 0]
  ------------------
  993|  60.8k|        uint16_t k1 = ra1->keys[left];
  994|  60.8k|        uint16_t k2 = ra2->keys[right];
  995|  60.8k|        if (k1 < k2) {
  ------------------
  |  Branch (995:13): [True: 0, False: 60.8k]
  ------------------
  996|      0|            ra_append(&merged, k1, ra1->containers[left], ra1->typecodes[left]);
  997|      0|            left++;
  998|  60.8k|        } else if (k1 > k2) {
  ------------------
  |  Branch (998:20): [True: 111, False: 60.7k]
  ------------------
  999|    111|            uint8_t type2 = ra2->typecodes[right];
 1000|    111|            container_t *c2 =
 1001|    111|                get_copy_of_container(ra2->containers[right], &type2, cow2);
 1002|    111|            if (cow2) {
  ------------------
  |  Branch (1002:17): [True: 0, False: 111]
  ------------------
 1003|      0|                ra_set_container_at_index(ra2, right, c2, type2);
 1004|      0|            }
 1005|    111|            ra_append(&merged, k2, c2, type2);
 1006|    111|            right++;
 1007|  60.7k|        } else {
 1008|  60.7k|            uint8_t type1 = ra1->typecodes[left];
 1009|  60.7k|            container_t *c1 = ra1->containers[left];
 1010|  60.7k|            uint8_t type2 = ra2->typecodes[right];
 1011|  60.7k|            container_t *c2 = ra2->containers[right];
 1012|  60.7k|            if (is_xor) {
  ------------------
  |  Branch (1012:17): [True: 60.7k, False: 0]
  ------------------
 1013|  60.7k|                container_t *c;
 1014|  60.7k|                if (type1 == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|  60.7k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (1014:21): [True: 0, False: 60.7k]
  ------------------
 1015|      0|                    c = container_xor(c1, type1, c2, type2, &result_type);
 1016|      0|                    shared_container_free(CAST_shared(c1));
  ------------------
  |  |   79|      0|#define CAST_shared(c) CAST(shared_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1017|  60.7k|                } else {
 1018|  60.7k|                    c = container_ixor(c1, type1, c2, type2, &result_type);
 1019|  60.7k|                }
 1020|  60.7k|                if (container_nonzero_cardinality(c, result_type)) {
  ------------------
  |  Branch (1020:21): [True: 0, False: 60.7k]
  ------------------
 1021|      0|                    ra_append(&merged, k1, c, result_type);
 1022|  60.7k|                } else {
 1023|  60.7k|                    container_free(c, result_type);
 1024|  60.7k|                }
 1025|  60.7k|            } else {
 1026|      0|                if (container_is_full(c1, type1)) {
  ------------------
  |  Branch (1026:21): [True: 0, False: 0]
  ------------------
 1027|      0|                    ra_append(&merged, k1, c1, type1);
 1028|      0|                } else {
 1029|      0|                    container_t *c =
 1030|      0|                        (type1 == SHARED_CONTAINER_TYPE)
  ------------------
  |  |   51|      0|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (1030:25): [True: 0, False: 0]
  ------------------
 1031|      0|                            ? container_or(c1, type1, c2, type2, &result_type)
 1032|      0|                            : container_ior(c1, type1, c2, type2, &result_type);
 1033|      0|                    if (c != c1) {
  ------------------
  |  Branch (1033:25): [True: 0, False: 0]
  ------------------
 1034|      0|                        container_free(c1, type1);
 1035|      0|                    }
 1036|      0|                    ra_append(&merged, k1, c, result_type);
 1037|      0|                }
 1038|      0|            }
 1039|  60.7k|            left++;
 1040|  60.7k|            right++;
 1041|  60.7k|        }
 1042|  60.8k|    }
 1043|  2.51k|    for (; left < length1; left++) {
  ------------------
  |  Branch (1043:12): [True: 0, False: 2.51k]
  ------------------
 1044|      0|        ra_append(&merged, ra1->keys[left], ra1->containers[left],
 1045|      0|                  ra1->typecodes[left]);
 1046|      0|    }
 1047|  2.51k|    for (; right < length2; right++) {
  ------------------
  |  Branch (1047:12): [True: 0, False: 2.51k]
  ------------------
 1048|      0|        uint8_t type2 = ra2->typecodes[right];
 1049|      0|        container_t *c2 =
 1050|      0|            get_copy_of_container(ra2->containers[right], &type2, cow2);
 1051|      0|        if (cow2) {
  ------------------
  |  Branch (1051:13): [True: 0, False: 0]
  ------------------
 1052|      0|            ra_set_container_at_index(ra2, right, c2, type2);
 1053|      0|        }
 1054|      0|        ra_append(&merged, ra2->keys[right], c2, type2);
 1055|      0|    }
 1056|       |
 1057|  2.51k|    merged.flags = ra1->flags;
 1058|  2.51k|    ra_clear_without_containers(ra1);
 1059|  2.51k|    *ra1 = merged;
 1060|  2.51k|}
roaring.c:loadfirstvalue:
 1809|  19.2k|    roaring_uint32_iterator_t *newit) {
 1810|  19.2k|    if (iter_new_container_partial_init(newit)) {
  ------------------
  |  Branch (1810:9): [True: 12.7k, False: 6.52k]
  ------------------
 1811|  12.7k|        uint16_t value = 0;
 1812|  12.7k|        newit->container_it =
 1813|  12.7k|            container_init_iterator(newit->container, newit->typecode, &value);
 1814|  12.7k|        newit->current_value = newit->highbits | value;
 1815|  12.7k|    }
 1816|  19.2k|    return newit->has_value;
 1817|  19.2k|}
roaring.c:iter_new_container_partial_init:
 1779|  25.6k|    roaring_uint32_iterator_t *newit) {
 1780|  25.6k|    newit->current_value = 0;
 1781|  25.6k|    if (newit->container_index >= newit->parent->high_low_container.size ||
  ------------------
  |  Branch (1781:9): [True: 6.52k, False: 19.1k]
  ------------------
 1782|  19.1k|        newit->container_index < 0) {
  ------------------
  |  Branch (1782:9): [True: 0, False: 19.1k]
  ------------------
 1783|  6.52k|        newit->current_value = UINT32_MAX;
 1784|  6.52k|        return (newit->has_value = false);
 1785|  6.52k|    }
 1786|  19.1k|    newit->has_value = true;
 1787|       |    // we precompute container, typecode and highbits so that successive
 1788|       |    // iterators do not have to grab them from odd memory locations
 1789|       |    // and have to worry about the (easily predicted) container_unwrap_shared
 1790|       |    // call.
 1791|  19.1k|    newit->container =
 1792|  19.1k|        newit->parent->high_low_container.containers[newit->container_index];
 1793|  19.1k|    newit->typecode =
 1794|  19.1k|        newit->parent->high_low_container.typecodes[newit->container_index];
 1795|  19.1k|    newit->highbits =
 1796|  19.1k|        ((uint32_t)
 1797|  19.1k|             newit->parent->high_low_container.keys[newit->container_index])
 1798|  19.1k|        << 16;
 1799|  19.1k|    newit->container =
 1800|  19.1k|        container_unwrap_shared(newit->container, &(newit->typecode));
 1801|       |    return true;
 1802|  25.6k|}
roaring.c:loadfirstvalue_largeorequal:
 1840|  6.38k|    roaring_uint32_iterator_t *newit, uint32_t val) {
 1841|  6.38k|    bool partial_init = iter_new_container_partial_init(newit);
 1842|  6.38k|    assert(partial_init);
 1843|  6.38k|    if (!partial_init) {
  ------------------
  |  Branch (1843:9): [True: 0, False: 6.38k]
  ------------------
 1844|      0|        return false;
 1845|      0|    }
 1846|  6.38k|    uint16_t value = 0;
 1847|  6.38k|    newit->container_it =
 1848|  6.38k|        container_init_iterator(newit->container, newit->typecode, &value);
 1849|  6.38k|    bool found = container_iterator_lower_bound(
 1850|  6.38k|        newit->container, newit->typecode, &newit->container_it, &value,
 1851|  6.38k|        val & 0xFFFF);
 1852|  6.38k|    assert(found);
 1853|  6.38k|    if (!found) {
  ------------------
  |  Branch (1853:9): [True: 0, False: 6.38k]
  ------------------
 1854|      0|        return false;
 1855|      0|    }
 1856|  6.38k|    newit->current_value = newit->highbits | value;
 1857|       |    return true;
 1858|  6.38k|}
roaring.c:inplace_flip_container:
 2214|  7.16k|                                   uint16_t lb_start, uint16_t lb_end) {
 2215|  7.16k|    const int i = ra_get_index(x1_arr, hb);
 2216|  7.16k|    uint8_t ctype_in, ctype_out;
 2217|  7.16k|    container_t *flipped_container = NULL;
 2218|  7.16k|    if (i >= 0) {
  ------------------
  |  Branch (2218:9): [True: 6.62k, False: 531]
  ------------------
 2219|  6.62k|        container_t *container_to_flip =
 2220|  6.62k|            ra_get_container_at_index(x1_arr, (uint16_t)i, &ctype_in);
 2221|  6.62k|        flipped_container = container_inot_range(
 2222|  6.62k|            container_to_flip, ctype_in, (uint32_t)lb_start,
 2223|  6.62k|            (uint32_t)(lb_end + 1), &ctype_out);
 2224|       |        // if a new container was created, the old one was already freed
 2225|  6.62k|        if (container_nonzero_cardinality(flipped_container, ctype_out)) {
  ------------------
  |  Branch (2225:13): [True: 6.60k, False: 22]
  ------------------
 2226|  6.60k|            ra_set_container_at_index(x1_arr, i, flipped_container, ctype_out);
 2227|  6.60k|        } else {
 2228|     22|            container_free(flipped_container, ctype_out);
 2229|     22|            ra_remove_at_index(x1_arr, i);
 2230|     22|        }
 2231|       |
 2232|  6.62k|    } else {
 2233|    531|        flipped_container = container_range_of_ones(
 2234|    531|            (uint32_t)lb_start, (uint32_t)(lb_end + 1), &ctype_out);
 2235|    531|        ra_insert_new_key_value_at(x1_arr, -i - 1, hb, flipped_container,
 2236|    531|                                   ctype_out);
 2237|    531|    }
 2238|  7.16k|}
roaring.c:inplace_fully_flip_container:
 2265|  24.5k|static void inplace_fully_flip_container(roaring_array_t *x1_arr, uint16_t hb) {
 2266|  24.5k|    const int i = ra_get_index(x1_arr, hb);
 2267|  24.5k|    uint8_t ctype_in, ctype_out;
 2268|  24.5k|    container_t *flipped_container = NULL;
 2269|  24.5k|    if (i >= 0) {
  ------------------
  |  Branch (2269:9): [True: 6.85k, False: 17.7k]
  ------------------
 2270|  6.85k|        container_t *container_to_flip =
 2271|  6.85k|            ra_get_container_at_index(x1_arr, (uint16_t)i, &ctype_in);
 2272|  6.85k|        flipped_container =
 2273|  6.85k|            container_inot(container_to_flip, ctype_in, &ctype_out);
 2274|       |
 2275|  6.85k|        if (container_nonzero_cardinality(flipped_container, ctype_out)) {
  ------------------
  |  Branch (2275:13): [True: 539, False: 6.31k]
  ------------------
 2276|    539|            ra_set_container_at_index(x1_arr, i, flipped_container, ctype_out);
 2277|  6.31k|        } else {
 2278|  6.31k|            container_free(flipped_container, ctype_out);
 2279|  6.31k|            ra_remove_at_index(x1_arr, i);
 2280|  6.31k|        }
 2281|       |
 2282|  17.7k|    } else {
 2283|  17.7k|        flipped_container = container_range_of_ones(0U, 0x10000U, &ctype_out);
 2284|  17.7k|        ra_insert_new_key_value_at(x1_arr, -i - 1, hb, flipped_container,
 2285|  17.7k|                                   ctype_out);
 2286|  17.7k|    }
 2287|  24.5k|}

ra_init_with_capacity:
   80|  67.3k|bool ra_init_with_capacity(roaring_array_t *new_ra, uint32_t cap) {
   81|  67.3k|    if (!new_ra) return false;
  ------------------
  |  Branch (81:9): [True: 0, False: 67.3k]
  ------------------
   82|  67.3k|    ra_init(new_ra);
   83|       |
   84|       |    // Containers hold 64Ki elements, so 64Ki containers is enough to hold
   85|       |    // `0x10000 * 0x10000` (all 2^32) elements
   86|  67.3k|    if (cap > 0x10000) {
  ------------------
  |  Branch (86:9): [True: 0, False: 67.3k]
  ------------------
   87|      0|        cap = 0x10000;
   88|      0|    }
   89|       |
   90|  67.3k|    if (cap > 0) {
  ------------------
  |  Branch (90:9): [True: 34.9k, False: 32.4k]
  ------------------
   91|  34.9k|        void *bigalloc = roaring_malloc(
   92|  34.9k|            cap * (sizeof(uint16_t) + sizeof(container_t *) + sizeof(uint8_t)));
   93|  34.9k|        if (bigalloc == NULL) return false;
  ------------------
  |  Branch (93:13): [True: 0, False: 34.9k]
  ------------------
   94|  34.9k|        new_ra->containers = (container_t **)bigalloc;
   95|  34.9k|        new_ra->keys = (uint16_t *)(new_ra->containers + cap);
   96|  34.9k|        new_ra->typecodes = (uint8_t *)(new_ra->keys + cap);
   97|       |        // Narrowing is safe because of above check
   98|  34.9k|        new_ra->allocation_size = (int32_t)cap;
   99|  34.9k|    }
  100|  67.3k|    return true;
  101|  67.3k|}
ra_shrink_to_fit:
  103|  71.2k|int ra_shrink_to_fit(roaring_array_t *ra) {
  104|  71.2k|    int savings = (ra->allocation_size - ra->size) *
  105|  71.2k|                  (sizeof(uint16_t) + sizeof(container_t *) + sizeof(uint8_t));
  106|  71.2k|    if (!realloc_array(ra, ra->size)) {
  ------------------
  |  Branch (106:9): [True: 0, False: 71.2k]
  ------------------
  107|      0|        return 0;
  108|      0|    }
  109|  71.2k|    ra->allocation_size = ra->size;
  110|  71.2k|    return savings;
  111|  71.2k|}
ra_init:
  113|  67.3k|void ra_init(roaring_array_t *new_ra) {
  114|  67.3k|    if (!new_ra) {
  ------------------
  |  Branch (114:9): [True: 0, False: 67.3k]
  ------------------
  115|      0|        return;
  116|      0|    }
  117|  67.3k|    new_ra->keys = NULL;
  118|  67.3k|    new_ra->containers = NULL;
  119|  67.3k|    new_ra->typecodes = NULL;
  120|       |
  121|  67.3k|    new_ra->allocation_size = 0;
  122|  67.3k|    new_ra->size = 0;
  123|  67.3k|    new_ra->flags = 0;
  124|  67.3k|}
ra_overwrite:
  127|  14.6k|                  bool copy_on_write) {
  128|  14.6k|    ra_clear_containers(dest);  // we are going to overwrite them
  129|  14.6k|    if (source->size == 0) {    // Note: can't call memcpy(NULL), even w/size
  ------------------
  |  Branch (129:9): [True: 16, False: 14.6k]
  ------------------
  130|     16|        dest->size = 0;         // <--- This is important.
  131|     16|        return true;            // output was just cleared, so they match
  132|     16|    }
  133|  14.6k|    if (dest->allocation_size < source->size) {
  ------------------
  |  Branch (133:9): [True: 12.9k, False: 1.67k]
  ------------------
  134|  12.9k|        if (!realloc_array(dest, source->size)) {
  ------------------
  |  Branch (134:13): [True: 0, False: 12.9k]
  ------------------
  135|      0|            return false;
  136|      0|        }
  137|  12.9k|    }
  138|  14.6k|    dest->size = source->size;
  139|  14.6k|    memcpy(dest->keys, source->keys, dest->size * sizeof(uint16_t));
  140|       |    // we go through the containers, turning them into shared containers...
  141|  14.6k|    if (copy_on_write) {
  ------------------
  |  Branch (141:9): [True: 0, False: 14.6k]
  ------------------
  142|      0|        for (int32_t i = 0; i < dest->size; ++i) {
  ------------------
  |  Branch (142:29): [True: 0, False: 0]
  ------------------
  143|      0|            source->containers[i] = get_copy_of_container(
  144|      0|                source->containers[i], &source->typecodes[i], copy_on_write);
  145|      0|        }
  146|       |        // we do a shallow copy to the other bitmap
  147|      0|        memcpy(dest->containers, source->containers,
  148|      0|               dest->size * sizeof(container_t *));
  149|      0|        memcpy(dest->typecodes, source->typecodes,
  150|      0|               dest->size * sizeof(uint8_t));
  151|  14.6k|    } else {
  152|  14.6k|        memcpy(dest->typecodes, source->typecodes,
  153|  14.6k|               dest->size * sizeof(uint8_t));
  154|   178k|        for (int32_t i = 0; i < dest->size; i++) {
  ------------------
  |  Branch (154:29): [True: 164k, False: 14.6k]
  ------------------
  155|   164k|            dest->containers[i] =
  156|   164k|                container_clone(source->containers[i], source->typecodes[i]);
  157|   164k|            if (dest->containers[i] == NULL) {
  ------------------
  |  Branch (157:17): [True: 0, False: 164k]
  ------------------
  158|      0|                for (int32_t j = 0; j < i; j++) {
  ------------------
  |  Branch (158:37): [True: 0, False: 0]
  ------------------
  159|      0|                    container_free(dest->containers[j], dest->typecodes[j]);
  160|      0|                }
  161|      0|                ra_clear_without_containers(dest);
  162|      0|                return false;
  163|      0|            }
  164|   164k|        }
  165|  14.6k|    }
  166|  14.6k|    return true;
  167|  14.6k|}
ra_clear_containers:
  169|  79.4k|void ra_clear_containers(roaring_array_t *ra) {
  170|   561k|    for (int32_t i = 0; i < ra->size; ++i) {
  ------------------
  |  Branch (170:25): [True: 482k, False: 79.4k]
  ------------------
  171|   482k|        container_free(ra->containers[i], ra->typecodes[i]);
  172|   482k|    }
  173|  79.4k|}
ra_reset:
  175|  64.8k|void ra_reset(roaring_array_t *ra) {
  176|  64.8k|    ra_clear_containers(ra);
  177|  64.8k|    ra->size = 0;
  178|  64.8k|    ra_shrink_to_fit(ra);
  179|  64.8k|}
ra_clear_without_containers:
  181|  2.55k|void ra_clear_without_containers(roaring_array_t *ra) {
  182|  2.55k|    roaring_free(
  183|  2.55k|        ra->containers);  // keys and typecodes are allocated with containers
  184|  2.55k|    ra->size = 0;
  185|  2.55k|    ra->allocation_size = 0;
  186|  2.55k|    ra->containers = NULL;
  187|  2.55k|    ra->keys = NULL;
  188|       |    ra->typecodes = NULL;
  189|  2.55k|}
ra_clear:
  191|     37|void ra_clear(roaring_array_t *ra) {
  192|     37|    ra_clear_containers(ra);
  193|     37|    ra_clear_without_containers(ra);
  194|     37|}
extend_array:
  196|  89.1k|bool extend_array(roaring_array_t *ra, int32_t k) {
  197|  89.1k|    int32_t desired_size = ra->size + k;
  198|  89.1k|    const int32_t max_containers = 65536;
  199|  89.1k|    assert(desired_size <= max_containers);
  200|  89.1k|    if (desired_size > ra->allocation_size) {
  ------------------
  |  Branch (200:9): [True: 18.5k, False: 70.6k]
  ------------------
  201|  18.5k|        int32_t new_capacity =
  202|  18.5k|            (ra->size < 1024) ? 2 * desired_size : 5 * desired_size / 4;
  ------------------
  |  Branch (202:13): [True: 18.5k, False: 0]
  ------------------
  203|  18.5k|        if (new_capacity > max_containers) {
  ------------------
  |  Branch (203:13): [True: 0, False: 18.5k]
  ------------------
  204|      0|            new_capacity = max_containers;
  205|      0|        }
  206|       |
  207|  18.5k|        return realloc_array(ra, new_capacity);
  208|  18.5k|    }
  209|  70.6k|    return true;
  210|  89.1k|}
ra_append:
  213|  27.3k|               uint8_t typecode) {
  214|  27.3k|    extend_array(ra, 1);
  215|  27.3k|    const int32_t pos = ra->size;
  216|       |
  217|  27.3k|    ra->keys[pos] = key;
  218|  27.3k|    ra->containers[pos] = c;
  219|  27.3k|    ra->typecodes[pos] = typecode;
  220|  27.3k|    ra->size++;
  221|  27.3k|}
ra_append_copy_range:
  254|  25.8k|                          bool copy_on_write) {
  255|  25.8k|    extend_array(ra, end_index - start_index);
  256|   214k|    for (int32_t i = start_index; i < end_index; ++i) {
  ------------------
  |  Branch (256:35): [True: 188k, False: 25.8k]
  ------------------
  257|   188k|        const int32_t pos = ra->size;
  258|   188k|        ra->keys[pos] = sa->keys[i];
  259|   188k|        if (copy_on_write) {
  ------------------
  |  Branch (259:13): [True: 0, False: 188k]
  ------------------
  260|      0|            sa->containers[i] = get_copy_of_container(
  261|      0|                sa->containers[i], &sa->typecodes[i], copy_on_write);
  262|      0|            ra->containers[pos] = sa->containers[i];
  263|      0|            ra->typecodes[pos] = sa->typecodes[i];
  264|   188k|        } else {
  265|   188k|            ra->containers[pos] =
  266|   188k|                container_clone(sa->containers[i], sa->typecodes[i]);
  267|   188k|            ra->typecodes[pos] = sa->typecodes[i];
  268|   188k|        }
  269|   188k|        ra->size++;
  270|   188k|    }
  271|  25.8k|}
ra_advance_until_freeing:
  340|     74|int32_t ra_advance_until_freeing(roaring_array_t *ra, uint16_t x, int32_t pos) {
  341|    148|    while (pos < ra->size && ra->keys[pos] < x) {
  ------------------
  |  Branch (341:12): [True: 148, False: 0]
  |  Branch (341:30): [True: 74, False: 74]
  ------------------
  342|     74|        container_free(ra->containers[pos], ra->typecodes[pos]);
  343|     74|        ++pos;
  344|     74|    }
  345|     74|    return pos;
  346|     74|}
ra_insert_new_key_value_at:
  349|  34.6k|                                container_t *c, uint8_t typecode) {
  350|  34.6k|    extend_array(ra, 1);
  351|       |    // May be an optimization opportunity with DIY memmove
  352|  34.6k|    memmove(&(ra->keys[i + 1]), &(ra->keys[i]),
  353|  34.6k|            sizeof(uint16_t) * (ra->size - i));
  354|  34.6k|    memmove(&(ra->containers[i + 1]), &(ra->containers[i]),
  355|  34.6k|            sizeof(container_t *) * (ra->size - i));
  356|  34.6k|    memmove(&(ra->typecodes[i + 1]), &(ra->typecodes[i]),
  357|  34.6k|            sizeof(uint8_t) * (ra->size - i));
  358|  34.6k|    ra->keys[i] = key;
  359|  34.6k|    ra->containers[i] = c;
  360|  34.6k|    ra->typecodes[i] = typecode;
  361|  34.6k|    ra->size++;
  362|  34.6k|}
ra_downsize:
  369|  12.5k|void ra_downsize(roaring_array_t *ra, int32_t new_length) {
  370|       |    assert(new_length <= ra->size);
  371|  12.5k|    ra->size = new_length;
  372|  12.5k|}
ra_remove_at_index:
  374|  6.40k|void ra_remove_at_index(roaring_array_t *ra, int32_t i) {
  375|  6.40k|    memmove(&(ra->containers[i]), &(ra->containers[i + 1]),
  376|  6.40k|            sizeof(container_t *) * (ra->size - i - 1));
  377|  6.40k|    memmove(&(ra->keys[i]), &(ra->keys[i + 1]),
  378|  6.40k|            sizeof(uint16_t) * (ra->size - i - 1));
  379|  6.40k|    memmove(&(ra->typecodes[i]), &(ra->typecodes[i + 1]),
  380|  6.40k|            sizeof(uint8_t) * (ra->size - i - 1));
  381|  6.40k|    ra->size--;
  382|  6.40k|}
ra_remove_at_index_and_free:
  384|     69|void ra_remove_at_index_and_free(roaring_array_t *ra, int32_t i) {
  385|     69|    container_free(ra->containers[i], ra->typecodes[i]);
  386|     69|    ra_remove_at_index(ra, i);
  387|     69|}
ra_copy_range:
  395|     39|                   uint32_t new_begin) {
  396|     39|    assert(begin <= end);
  397|     39|    assert(new_begin < begin);
  398|       |
  399|     39|    const int range = end - begin;
  400|       |
  401|       |    // We ensure to previously have freed overwritten containers
  402|       |    // that are not copied elsewhere
  403|       |
  404|     39|    memmove(&(ra->containers[new_begin]), &(ra->containers[begin]),
  405|     39|            sizeof(container_t *) * range);
  406|     39|    memmove(&(ra->keys[new_begin]), &(ra->keys[begin]),
  407|     39|            sizeof(uint16_t) * range);
  408|     39|    memmove(&(ra->typecodes[new_begin]), &(ra->typecodes[begin]),
  409|     39|            sizeof(uint8_t) * range);
  410|     39|}
ra_shift_tail:
  412|  1.97k|void ra_shift_tail(roaring_array_t *ra, int32_t count, int32_t distance) {
  413|  1.97k|    if (distance > 0) {
  ------------------
  |  Branch (413:9): [True: 1.33k, False: 634]
  ------------------
  414|  1.33k|        extend_array(ra, distance);
  415|  1.33k|    }
  416|  1.97k|    int32_t srcpos = ra->size - count;
  417|  1.97k|    int32_t dstpos = srcpos + distance;
  418|  1.97k|    memmove(&(ra->keys[dstpos]), &(ra->keys[srcpos]), sizeof(uint16_t) * count);
  419|  1.97k|    memmove(&(ra->containers[dstpos]), &(ra->containers[srcpos]),
  420|  1.97k|            sizeof(container_t *) * count);
  421|  1.97k|    memmove(&(ra->typecodes[dstpos]), &(ra->typecodes[srcpos]),
  422|  1.97k|            sizeof(uint8_t) * count);
  423|  1.97k|    ra->size += distance;
  424|  1.97k|}
ra_to_uint32_array:
  426|  6.48k|void ra_to_uint32_array(const roaring_array_t *ra, uint32_t *ans) {
  427|  6.48k|    size_t ctr = 0;
  428|  75.7k|    for (int32_t i = 0; i < ra->size; ++i) {
  ------------------
  |  Branch (428:25): [True: 69.2k, False: 6.48k]
  ------------------
  429|  69.2k|        int num_added = container_to_uint32_array(
  430|  69.2k|            ans + ctr, ra->containers[i], ra->typecodes[i],
  431|  69.2k|            ((uint32_t)ra->keys[i]) << 16);
  432|  69.2k|        ctr += num_added;
  433|  69.2k|    }
  434|  6.48k|}
ra_has_run_container:
  436|  19.4k|bool ra_has_run_container(const roaring_array_t *ra) {
  437|   185k|    for (int32_t k = 0; k < ra->size; ++k) {
  ------------------
  |  Branch (437:25): [True: 168k, False: 16.7k]
  ------------------
  438|   168k|        if (get_container_type(ra->containers[k], ra->typecodes[k]) ==
  ------------------
  |  Branch (438:13): [True: 2.67k, False: 166k]
  ------------------
  439|   168k|            RUN_CONTAINER_TYPE)
  ------------------
  |  |   50|   168k|#define RUN_CONTAINER_TYPE 3
  ------------------
  440|  2.67k|            return true;
  441|   168k|    }
  442|  16.7k|    return false;
  443|  19.4k|}
ra_portable_header_size:
  445|  12.9k|uint32_t ra_portable_header_size(const roaring_array_t *ra) {
  446|  12.9k|    if (ra_has_run_container(ra)) {
  ------------------
  |  Branch (446:9): [True: 2.67k, False: 10.2k]
  ------------------
  447|  2.67k|        if (ra->size <
  ------------------
  |  Branch (447:13): [True: 2.67k, False: 0]
  ------------------
  448|  2.67k|            NO_OFFSET_THRESHOLD) {  // for small bitmaps, we omit the offsets
  449|  2.67k|            return 4 + (ra->size + 7) / 8 + 4 * ra->size;
  450|  2.67k|        }
  451|      0|        return 4 + (ra->size + 7) / 8 +
  452|      0|               8 * ra->size;  // - 4 because we pack the size with the cookie
  453|  10.2k|    } else {
  454|  10.2k|        return 4 + 4 + 8 * ra->size;
  455|  10.2k|    }
  456|  12.9k|}
ra_portable_size_in_bytes:
  458|  12.9k|size_t ra_portable_size_in_bytes(const roaring_array_t *ra) {
  459|  12.9k|    size_t count = ra_portable_header_size(ra);
  460|       |
  461|   100k|    for (int32_t k = 0; k < ra->size; ++k) {
  ------------------
  |  Branch (461:25): [True: 87.6k, False: 12.9k]
  ------------------
  462|  87.6k|        count += container_size_in_bytes(ra->containers[k], ra->typecodes[k]);
  463|  87.6k|    }
  464|  12.9k|    return count;
  465|  12.9k|}
ra_portable_serialize:
  469|  6.48k|size_t ra_portable_serialize(const roaring_array_t *ra, char *buf) {
  470|  6.48k|    char *initbuf = buf;
  471|  6.48k|    uint32_t startOffset = 0;
  472|  6.48k|    bool hasrun = ra_has_run_container(ra);
  473|  6.48k|    if (hasrun) {
  ------------------
  |  Branch (473:9): [True: 0, False: 6.48k]
  ------------------
  474|      0|        uint32_t cookie = SERIAL_COOKIE | ((uint32_t)(ra->size - 1) << 16);
  475|      0|        uint32_t cookie_le = croaring_htole32(cookie);
  ------------------
  |  |  518|      0|#define croaring_htole32(x) (x)
  ------------------
  476|      0|        memcpy(buf, &cookie_le, sizeof(cookie_le));
  477|      0|        buf += sizeof(cookie_le);
  478|      0|        uint32_t s = (ra->size + 7) / 8;
  479|      0|        memset(buf, 0, s);
  480|      0|        for (int32_t i = 0; i < ra->size; ++i) {
  ------------------
  |  Branch (480:29): [True: 0, False: 0]
  ------------------
  481|      0|            if (get_container_type(ra->containers[i], ra->typecodes[i]) ==
  ------------------
  |  Branch (481:17): [True: 0, False: 0]
  ------------------
  482|      0|                RUN_CONTAINER_TYPE) {
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
  483|      0|                buf[i / 8] |= 1 << (i % 8);
  484|      0|            }
  485|      0|        }
  486|      0|        buf += s;
  487|      0|        if (ra->size < NO_OFFSET_THRESHOLD) {
  ------------------
  |  Branch (487:13): [True: 0, False: 0]
  ------------------
  488|      0|            startOffset = 4 + 4 * ra->size + s;
  489|      0|        } else {
  490|      0|            startOffset = 4 + 8 * ra->size + s;
  491|      0|        }
  492|  6.48k|    } else {  // backwards compatibility
  493|  6.48k|        uint32_t cookie = SERIAL_COOKIE_NO_RUNCONTAINER;
  494|  6.48k|        uint32_t cookie_le = croaring_htole32(cookie);
  ------------------
  |  |  518|  6.48k|#define croaring_htole32(x) (x)
  ------------------
  495|  6.48k|        memcpy(buf, &cookie_le, sizeof(cookie_le));
  496|  6.48k|        buf += sizeof(cookie_le);
  497|  6.48k|        uint32_t size_le = croaring_htole32((uint32_t)ra->size);
  ------------------
  |  |  518|  6.48k|#define croaring_htole32(x) (x)
  ------------------
  498|  6.48k|        memcpy(buf, &size_le, sizeof(size_le));
  499|  6.48k|        buf += sizeof(size_le);
  500|       |
  501|  6.48k|        startOffset = 4 + 4 + 4 * ra->size + 4 * ra->size;
  502|  6.48k|    }
  503|  87.6k|    for (int32_t k = 0; k < ra->size; ++k) {
  ------------------
  |  Branch (503:25): [True: 81.1k, False: 6.48k]
  ------------------
  504|  81.1k|        uint16_t key_le = croaring_htole16(ra->keys[k]);
  ------------------
  |  |  517|  81.1k|#define croaring_htole16(x) (x)
  ------------------
  505|  81.1k|        memcpy(buf, &key_le, sizeof(key_le));
  506|  81.1k|        buf += sizeof(key_le);
  507|       |        // get_cardinality returns a value in [1,1<<16], subtracting one
  508|       |        // we get [0,1<<16 - 1] which fits in 16 bits
  509|  81.1k|        uint16_t card = (uint16_t)(container_get_cardinality(ra->containers[k],
  510|  81.1k|                                                             ra->typecodes[k]) -
  511|  81.1k|                                   1);
  512|  81.1k|        uint16_t card_le = croaring_htole16(card);
  ------------------
  |  |  517|  81.1k|#define croaring_htole16(x) (x)
  ------------------
  513|  81.1k|        memcpy(buf, &card_le, sizeof(card_le));
  514|  81.1k|        buf += sizeof(card_le);
  515|  81.1k|    }
  516|  6.48k|    if ((!hasrun) || (ra->size >= NO_OFFSET_THRESHOLD)) {
  ------------------
  |  Branch (516:9): [True: 6.48k, False: 0]
  |  Branch (516:22): [True: 0, False: 0]
  ------------------
  517|       |        // writing the containers offsets
  518|  87.6k|        for (int32_t k = 0; k < ra->size; k++) {
  ------------------
  |  Branch (518:29): [True: 81.1k, False: 6.48k]
  ------------------
  519|  81.1k|            uint32_t off_le = croaring_htole32(startOffset);
  ------------------
  |  |  518|  81.1k|#define croaring_htole32(x) (x)
  ------------------
  520|  81.1k|            memcpy(buf, &off_le, sizeof(off_le));
  521|  81.1k|            buf += sizeof(off_le);
  522|  81.1k|            startOffset =
  523|  81.1k|                startOffset +
  524|  81.1k|                container_size_in_bytes(ra->containers[k], ra->typecodes[k]);
  525|  81.1k|        }
  526|  6.48k|    }
  527|  87.6k|    for (int32_t k = 0; k < ra->size; ++k) {
  ------------------
  |  Branch (527:25): [True: 81.1k, False: 6.48k]
  ------------------
  528|  81.1k|        buf += container_write(ra->containers[k], ra->typecodes[k], buf);
  529|  81.1k|    }
  530|  6.48k|    return buf - initbuf;
  531|  6.48k|}
ra_portable_deserialize:
  634|  12.9k|                             const size_t maxbytes, size_t *readbytes) {
  635|  12.9k|    *readbytes = sizeof(int32_t);  // for cookie
  636|  12.9k|    if (*readbytes > maxbytes) {
  ------------------
  |  Branch (636:9): [True: 6.10k, False: 6.85k]
  ------------------
  637|       |        // Ran out of bytes while reading first 4 bytes.
  638|  6.10k|        return false;
  639|  6.10k|    }
  640|  6.85k|    uint32_t cookie;
  641|  6.85k|    memcpy(&cookie, buf, sizeof(int32_t));
  642|  6.85k|    cookie = croaring_letoh32(cookie);
  ------------------
  |  |  524|  6.85k|#define croaring_letoh32(x) croaring_htole32(x)
  |  |  ------------------
  |  |  |  |  518|  6.85k|#define croaring_htole32(x) (x)
  |  |  ------------------
  ------------------
  643|  6.85k|    buf += sizeof(uint32_t);
  644|  6.85k|    if ((cookie & 0xFFFF) != SERIAL_COOKIE &&
  ------------------
  |  Branch (644:9): [True: 6.78k, False: 66]
  ------------------
  645|  6.78k|        cookie != SERIAL_COOKIE_NO_RUNCONTAINER) {
  ------------------
  |  Branch (645:9): [True: 252, False: 6.53k]
  ------------------
  646|       |        // "I failed to find one of the right cookies.
  647|    252|        return false;
  648|    252|    }
  649|  6.60k|    int32_t size;
  650|       |
  651|  6.60k|    if ((cookie & 0xFFFF) == SERIAL_COOKIE)
  ------------------
  |  Branch (651:9): [True: 66, False: 6.53k]
  ------------------
  652|     66|        size = (cookie >> 16) + 1;
  653|  6.53k|    else {
  654|  6.53k|        *readbytes += sizeof(int32_t);
  655|  6.53k|        if (*readbytes > maxbytes) {
  ------------------
  |  Branch (655:13): [True: 2, False: 6.53k]
  ------------------
  656|       |            // Ran out of bytes while reading second part of the cookie.
  657|      2|            return false;
  658|      2|        }
  659|  6.53k|        uint32_t size_le;
  660|  6.53k|        memcpy(&size_le, buf, sizeof(int32_t));
  661|  6.53k|        size = (int32_t)croaring_letoh32(size_le);
  ------------------
  |  |  524|  6.53k|#define croaring_letoh32(x) croaring_htole32(x)
  |  |  ------------------
  |  |  |  |  518|  6.53k|#define croaring_htole32(x) (x)
  |  |  ------------------
  ------------------
  662|  6.53k|        buf += sizeof(uint32_t);
  663|  6.53k|    }
  664|  6.60k|    if (size < 0) {
  ------------------
  |  Branch (664:9): [True: 19, False: 6.58k]
  ------------------
  665|       |        // You cannot have a negative number of containers, the data must be
  666|       |        // corrupted.
  667|     19|        return false;
  668|     19|    }
  669|  6.58k|    if (size > (1 << 16)) {
  ------------------
  |  Branch (669:9): [True: 19, False: 6.56k]
  ------------------
  670|       |        // You cannot have so many containers, the data must be corrupted.
  671|     19|        return false;
  672|     19|    }
  673|  6.56k|    const char *bitmapOfRunContainers = NULL;
  674|  6.56k|    bool hasrun = (cookie & 0xFFFF) == SERIAL_COOKIE;
  675|  6.56k|    if (hasrun) {
  ------------------
  |  Branch (675:9): [True: 66, False: 6.49k]
  ------------------
  676|     66|        int32_t s = (size + 7) / 8;
  677|     66|        *readbytes += s;
  678|     66|        if (*readbytes > maxbytes) {  // data is corrupted?
  ------------------
  |  Branch (678:13): [True: 19, False: 47]
  ------------------
  679|       |            // Ran out of bytes while reading run bitmap.
  680|     19|            return false;
  681|     19|        }
  682|     47|        bitmapOfRunContainers = buf;
  683|     47|        buf += s;
  684|     47|    }
  685|  6.54k|    const char *keyscards = buf;
  686|       |
  687|  6.54k|    *readbytes += size * 2 * sizeof(uint16_t);
  688|  6.54k|    if (*readbytes > maxbytes) {
  ------------------
  |  Branch (688:9): [True: 13, False: 6.53k]
  ------------------
  689|       |        // Ran out of bytes while reading key-cardinality array.
  690|     13|        return false;
  691|     13|    }
  692|  6.53k|    buf += size * 2 * sizeof(uint16_t);
  693|       |
  694|  6.53k|    bool is_ok = ra_init_with_capacity(answer, size);
  695|  6.53k|    if (!is_ok) {
  ------------------
  |  Branch (695:9): [True: 0, False: 6.53k]
  ------------------
  696|       |        // Failed to allocate memory for roaring array. Bailing out.
  697|      0|        return false;
  698|      0|    }
  699|       |
  700|  87.9k|    for (int32_t k = 0; k < size; ++k) {
  ------------------
  |  Branch (700:25): [True: 81.3k, False: 6.53k]
  ------------------
  701|  81.3k|        uint16_t tmp;
  702|  81.3k|        memcpy(&tmp, keyscards + 4 * k, sizeof(tmp));
  703|  81.3k|        answer->keys[k] = croaring_letoh16(tmp);
  ------------------
  |  |  523|  81.3k|#define croaring_letoh16(x) croaring_htole16(x)
  |  |  ------------------
  |  |  |  |  517|  81.3k|#define croaring_htole16(x) (x)
  |  |  ------------------
  ------------------
  704|  81.3k|    }
  705|  6.53k|    if ((!hasrun) || (size >= NO_OFFSET_THRESHOLD)) {
  ------------------
  |  Branch (705:9): [True: 6.48k, False: 46]
  |  Branch (705:22): [True: 20, False: 26]
  ------------------
  706|  6.50k|        *readbytes += size * 4;
  707|  6.50k|        if (*readbytes > maxbytes) {  // data is corrupted?
  ------------------
  |  Branch (707:13): [True: 5, False: 6.49k]
  ------------------
  708|       |            // Ran out of bytes while reading offsets.
  709|      5|            ra_clear(answer);  // we need to clear the containers already
  710|       |                               // allocated, and the roaring array
  711|      5|            return false;
  712|      5|        }
  713|       |
  714|       |        // skipping the offsets
  715|  6.49k|        buf += size * 4;
  716|  6.49k|    }
  717|       |    // Reading the containers
  718|  87.8k|    for (int32_t k = 0; k < size; ++k) {
  ------------------
  |  Branch (718:25): [True: 81.3k, False: 6.49k]
  ------------------
  719|  81.3k|        uint16_t tmp;
  720|  81.3k|        memcpy(&tmp, keyscards + 4 * k + 2, sizeof(tmp));
  721|  81.3k|        tmp = croaring_letoh16(tmp);
  ------------------
  |  |  523|  81.3k|#define croaring_letoh16(x) croaring_htole16(x)
  |  |  ------------------
  |  |  |  |  517|  81.3k|#define croaring_htole16(x) (x)
  |  |  ------------------
  ------------------
  722|  81.3k|        uint32_t thiscard = tmp + 1;
  723|  81.3k|        bool isbitmap = (thiscard > DEFAULT_MAX_SIZE);
  724|  81.3k|        bool isrun = false;
  725|  81.3k|        if (hasrun) {
  ------------------
  |  Branch (725:13): [True: 135, False: 81.1k]
  ------------------
  726|    135|            if ((bitmapOfRunContainers[k / 8] & (1 << (k % 8))) != 0) {
  ------------------
  |  Branch (726:17): [True: 66, False: 69]
  ------------------
  727|     66|                isbitmap = false;
  728|     66|                isrun = true;
  729|     66|            }
  730|    135|        }
  731|  81.3k|        if (isbitmap) {
  ------------------
  |  Branch (731:13): [True: 74.0k, False: 7.32k]
  ------------------
  732|       |            // we check that the read is allowed
  733|  74.0k|            size_t containersize =
  734|  74.0k|                BITSET_CONTAINER_SIZE_IN_WORDS * sizeof(uint64_t);
  735|  74.0k|            *readbytes += containersize;
  736|  74.0k|            if (*readbytes > maxbytes) {
  ------------------
  |  Branch (736:17): [True: 7, False: 73.9k]
  ------------------
  737|       |                // Running out of bytes while reading a bitset container.
  738|      7|                ra_clear(answer);  // we need to clear the containers already
  739|       |                                   // allocated, and the roaring array
  740|      7|                return false;
  741|      7|            }
  742|       |            // it is now safe to read
  743|  73.9k|            bitset_container_t *c = bitset_container_create();
  744|  73.9k|            if (c == NULL) {  // memory allocation failure
  ------------------
  |  Branch (744:17): [True: 0, False: 73.9k]
  ------------------
  745|       |                // Failed to allocate memory for a bitset container.
  746|      0|                ra_clear(answer);  // we need to clear the containers already
  747|       |                                   // allocated, and the roaring array
  748|      0|                return false;
  749|      0|            }
  750|  73.9k|            answer->size++;
  751|  73.9k|            buf += bitset_container_read(thiscard, c, buf);
  752|  73.9k|            answer->containers[k] = c;
  753|  73.9k|            answer->typecodes[k] = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|  73.9k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  754|  73.9k|        } else if (isrun) {
  ------------------
  |  Branch (754:20): [True: 66, False: 7.26k]
  ------------------
  755|       |            // we check that the read is allowed
  756|     66|            *readbytes += sizeof(uint16_t);
  757|     66|            if (*readbytes > maxbytes) {
  ------------------
  |  Branch (757:17): [True: 8, False: 58]
  ------------------
  758|       |                // Running out of bytes while reading a run container (header).
  759|      8|                ra_clear(answer);  // we need to clear the containers already
  760|       |                                   // allocated, and the roaring array
  761|      8|                return false;
  762|      8|            }
  763|     58|            uint16_t n_runs;
  764|     58|            memcpy(&n_runs, buf, sizeof(uint16_t));
  765|     58|            n_runs = croaring_letoh16(n_runs);
  ------------------
  |  |  523|     58|#define croaring_letoh16(x) croaring_htole16(x)
  |  |  ------------------
  |  |  |  |  517|     58|#define croaring_htole16(x) (x)
  |  |  ------------------
  ------------------
  766|     58|            size_t containersize = n_runs * sizeof(rle16_t);
  767|     58|            *readbytes += containersize;
  768|     58|            if (*readbytes > maxbytes) {  // data is corrupted?
  ------------------
  |  Branch (768:17): [True: 8, False: 50]
  ------------------
  769|       |                // Running out of bytes while reading a run container.
  770|      8|                ra_clear(answer);  // we need to clear the containers already
  771|       |                                   // allocated, and the roaring array
  772|      8|                return false;
  773|      8|            }
  774|       |            // it is now safe to read
  775|       |
  776|     50|            run_container_t *c = run_container_create();
  777|     50|            if (c == NULL) {  // memory allocation failure
  ------------------
  |  Branch (777:17): [True: 0, False: 50]
  ------------------
  778|       |                // Failed to allocate memory for a run container.
  779|      0|                ra_clear(answer);  // we need to clear the containers already
  780|       |                                   // allocated, and the roaring array
  781|      0|                return false;
  782|      0|            }
  783|     50|            answer->size++;
  784|     50|            buf += run_container_read(thiscard, c, buf);
  785|     50|            answer->containers[k] = c;
  786|     50|            answer->typecodes[k] = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|     50|#define RUN_CONTAINER_TYPE 3
  ------------------
  787|  7.26k|        } else {
  788|       |            // we check that the read is allowed
  789|  7.26k|            size_t containersize = thiscard * sizeof(uint16_t);
  790|  7.26k|            *readbytes += containersize;
  791|  7.26k|            if (*readbytes > maxbytes) {  // data is corrupted?
  ------------------
  |  Branch (791:17): [True: 9, False: 7.25k]
  ------------------
  792|       |                // Running out of bytes while reading an array container.
  793|      9|                ra_clear(answer);  // we need to clear the containers already
  794|       |                                   // allocated, and the roaring array
  795|      9|                return false;
  796|      9|            }
  797|       |            // it is now safe to read
  798|  7.25k|            array_container_t *c =
  799|  7.25k|                array_container_create_given_capacity(thiscard);
  800|  7.25k|            if (c == NULL) {  // memory allocation failure
  ------------------
  |  Branch (800:17): [True: 0, False: 7.25k]
  ------------------
  801|       |                // Failed to allocate memory for an array container.
  802|      0|                ra_clear(answer);  // we need to clear the containers already
  803|       |                                   // allocated, and the roaring array
  804|      0|                return false;
  805|      0|            }
  806|  7.25k|            answer->size++;
  807|  7.25k|            buf += array_container_read(thiscard, c, buf);
  808|  7.25k|            answer->containers[k] = c;
  809|  7.25k|            answer->typecodes[k] = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  7.25k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  810|  7.25k|        }
  811|  81.3k|    }
  812|  6.49k|    return true;
  813|  6.52k|}
roaring_array.c:realloc_array:
   42|   102k|static bool realloc_array(roaring_array_t *ra, int32_t new_capacity) {
   43|       |    //
   44|       |    // Note: not implemented using C's realloc(), because the memory layout is
   45|       |    // Struct-of-Arrays vs. Array-of-Structs:
   46|       |    // https://github.com/RoaringBitmap/CRoaring/issues/256
   47|       |
   48|   102k|    if (new_capacity == 0) {
  ------------------
  |  Branch (48:9): [True: 64.8k, False: 37.9k]
  ------------------
   49|  64.8k|        roaring_free(ra->containers);
   50|  64.8k|        ra->containers = NULL;
   51|  64.8k|        ra->keys = NULL;
   52|  64.8k|        ra->typecodes = NULL;
   53|  64.8k|        ra->allocation_size = 0;
   54|  64.8k|        return true;
   55|  64.8k|    }
   56|  37.9k|    const size_t memoryneeded =
   57|  37.9k|        new_capacity *
   58|  37.9k|        (sizeof(uint16_t) + sizeof(container_t *) + sizeof(uint8_t));
   59|  37.9k|    void *bigalloc = roaring_malloc(memoryneeded);
   60|  37.9k|    if (!bigalloc) return false;
  ------------------
  |  Branch (60:9): [True: 0, False: 37.9k]
  ------------------
   61|  37.9k|    void *oldbigalloc = ra->containers;
   62|  37.9k|    container_t **newcontainers = (container_t **)bigalloc;
   63|  37.9k|    uint16_t *newkeys = (uint16_t *)(newcontainers + new_capacity);
   64|  37.9k|    uint8_t *newtypecodes = (uint8_t *)(newkeys + new_capacity);
   65|  37.9k|    assert((char *)(newtypecodes + new_capacity) ==
   66|  37.9k|           (char *)bigalloc + memoryneeded);
   67|  37.9k|    if (ra->size > 0) {
  ------------------
  |  Branch (67:9): [True: 12.0k, False: 25.9k]
  ------------------
   68|  12.0k|        memcpy(newcontainers, ra->containers, sizeof(container_t *) * ra->size);
   69|  12.0k|        memcpy(newkeys, ra->keys, sizeof(uint16_t) * ra->size);
   70|  12.0k|        memcpy(newtypecodes, ra->typecodes, sizeof(uint8_t) * ra->size);
   71|  12.0k|    }
   72|  37.9k|    ra->containers = newcontainers;
   73|  37.9k|    ra->keys = newkeys;
   74|  37.9k|    ra->typecodes = newtypecodes;
   75|  37.9k|    ra->allocation_size = new_capacity;
   76|  37.9k|    roaring_free(oldbigalloc);
   77|       |    return true;
   78|  37.9k|}

_Z17ConsumeVecInRangeR18FuzzedDataProvidermjj:
   24|  12.9k|                                        uint32_t max_value) {
   25|  12.9k|    std::vector<uint32_t> result = {0};
   26|  12.9k|    result.resize(length);
   27|  12.9k|    std::generate(result.begin(), result.end(), [&]() {
   28|  12.9k|        return fdp.ConsumeIntegralInRange<uint32_t>(min_value, max_value);
   29|  12.9k|    });
   30|  12.9k|    return result;
   31|  12.9k|}
LLVMFuzzerTestOneInput:
   33|  6.48k|extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
   34|       |    /**
   35|       |     * A bitmap may contain up to 2**32 elements. Later this function will
   36|       |     * output the content to an array where each element uses 32 bits of
   37|       |     * storage. That would use 16 GB. Thus this function is bound to run out of
   38|       |     * memory.
   39|       |     *
   40|       |     * Even without the full serialization to a 32-bit array, a bitmap may still
   41|       |     * use over 512 MB in the normal course of operation: that is to be expected
   42|       |     * since it can represent all sets of integers in [0,2**32]. This function
   43|       |     * may hold several bitmaps in memory at once, so it can require gigabytes
   44|       |     * of memory (without bugs). Hence, unless it has a generous memory
   45|       |     * capacity, this function will run out of memory almost certainly.
   46|       |     *
   47|       |     * For sanity, we may limit the range to, say, 10,000,000 which will use 38
   48|       |     * MB or so. With such a limited range, if we run out of memory, then we can
   49|       |     * almost certain that it has to do with a genuine bug.
   50|       |     */
   51|       |
   52|  6.48k|    uint32_t range_start = 0;
   53|  6.48k|    uint32_t range_end = 10'000'000;
   54|       |
   55|       |    /**
   56|       |     * We are not solely dependent on the range [range_start, range_end) because
   57|       |     * ConsumeVecInRange below produce integers in a small range starting at 0.
   58|       |     */
   59|       |
   60|  6.48k|    FuzzedDataProvider fdp(data, size);
   61|       |    /**
   62|       |     * The next line was ConsumeVecInRange(fdp, 500, 0, 1000) but it would pick
   63|       |     * 500 values at random from 0, 1000, making almost certain that all of the
   64|       |     * values are picked. It seems more useful to pick 500 values in the range
   65|       |     * 0,1000.
   66|       |     */
   67|  6.48k|    std::vector<uint32_t> bitmap_data_a = ConsumeVecInRange(fdp, 500, 0, 1000);
   68|  6.48k|    roaring::Roaring a(bitmap_data_a.size(), bitmap_data_a.data());
   69|  6.48k|    a.runOptimize();
   70|  6.48k|    a.shrinkToFit();
   71|       |
   72|  6.48k|    std::vector<uint32_t> bitmap_data_b = ConsumeVecInRange(fdp, 500, 0, 1000);
   73|  6.48k|    roaring::Roaring b(bitmap_data_b.size(), bitmap_data_b.data());
   74|  6.48k|    b.runOptimize();
   75|  6.48k|    b.add(fdp.ConsumeIntegralInRange<uint32_t>(range_start, range_end));
   76|  6.48k|    b.addChecked(fdp.ConsumeIntegralInRange<uint32_t>(range_start, range_end));
   77|  6.48k|    b.addRange(fdp.ConsumeIntegralInRange<uint32_t>(range_start, range_end),
   78|  6.48k|               fdp.ConsumeIntegralInRange<uint32_t>(range_start, range_end));
   79|       |    // add half of a to b.
   80|  6.48k|    b.addMany(bitmap_data_a.size() / 2, bitmap_data_a.data());
   81|  6.48k|    b.remove(fdp.ConsumeIntegralInRange<uint32_t>(range_start, range_end));
   82|  6.48k|    b.removeChecked(
   83|  6.48k|        fdp.ConsumeIntegralInRange<uint32_t>(range_start, range_end));
   84|  6.48k|    b.removeRange(fdp.ConsumeIntegralInRange<uint32_t>(range_start, range_end),
   85|  6.48k|                  fdp.ConsumeIntegralInRange<uint32_t>(range_start, range_end));
   86|  6.48k|    b.removeRangeClosed(
   87|  6.48k|        fdp.ConsumeIntegralInRange<uint32_t>(range_start, range_end),
   88|  6.48k|        fdp.ConsumeIntegralInRange<uint32_t>(range_start, range_end));
   89|  6.48k|    b.maximum();
   90|  6.48k|    b.minimum();
   91|  6.48k|    b.contains(fdp.ConsumeIntegralInRange<uint32_t>(range_start, range_end));
   92|  6.48k|    b.containsRange(
   93|  6.48k|        fdp.ConsumeIntegralInRange<uint32_t>(range_start, range_end),
   94|  6.48k|        fdp.ConsumeIntegralInRange<uint32_t>(range_start, range_end));
   95|       |
   96|  6.48k|    uint32_t element = 0;
   97|  6.48k|    a.select(fdp.ConsumeIntegralInRange<uint32_t>(0, 1000), &element);
   98|  6.48k|    a.intersect(b);
   99|  6.48k|    a.jaccard_index(b);
  100|  6.48k|    a.or_cardinality(b);
  101|  6.48k|    a.andnot_cardinality(b);
  102|  6.48k|    a.xor_cardinality(b);
  103|  6.48k|    a.rank(fdp.ConsumeIntegralInRange<uint32_t>(0, 5000));
  104|  6.48k|    a.getSizeInBytes();
  105|       |
  106|  6.48k|    roaring::Roaring c = a & b;
  107|  6.48k|    roaring::Roaring d = a - b;
  108|  6.48k|    roaring::Roaring e = a | b;
  109|  6.48k|    roaring::Roaring f = a ^ b;
  110|  6.48k|    a |= e;
  111|  6.48k|    a &= b;
  112|  6.48k|    a -= c;
  113|  6.48k|    a ^= f;
  114|       |
  115|  6.48k|    volatile bool is_equal = (a == b);
  116|       |
  117|  6.48k|    std::vector<uint32_t> b_as_array = {0};
  118|  6.48k|    b_as_array.resize(b.cardinality());
  119|  6.48k|    b.isEmpty();
  120|  6.48k|    b.toUint32Array(b_as_array.data());
  121|       |
  122|  6.48k|    a.isSubset(b);
  123|  6.48k|    a.isStrictSubset(b);
  124|  6.48k|    b.flip(fdp.ConsumeIntegralInRange<uint32_t>(range_start, range_end),
  125|  6.48k|           fdp.ConsumeIntegralInRange<uint32_t>(range_start, range_end));
  126|  6.48k|    b.flipClosed(fdp.ConsumeIntegralInRange<uint32_t>(range_start, range_end),
  127|  6.48k|                 fdp.ConsumeIntegralInRange<uint32_t>(range_start, range_end));
  128|  6.48k|    b.removeRunCompression();
  129|       |
  130|       |    // Move/copy constructors
  131|  6.48k|    roaring::Roaring copied = b;
  132|  6.48k|    roaring::Roaring moved = std::move(b);
  133|       |
  134|       |    // Asignment operators
  135|  6.48k|    b = copied;
  136|  6.48k|    b = std::move(moved);
  137|       |
  138|       |    // Safe read from serialized
  139|  6.48k|    std::vector<char> read_buffer = fdp.ConsumeBytes<char>(100);
  140|  6.48k|    try {
  141|  6.48k|        roaring::Roaring read_safely =
  142|  6.48k|            roaring::Roaring::readSafe(read_buffer.data(), read_buffer.size());
  143|       |        // The above is guaranteed to be safe. However, read_safely is maybe
  144|       |        // in an improper state and it cannot be used safely (including for
  145|       |        // reserialization).
  146|  6.48k|    } catch (...) {
  147|  6.46k|    }
  148|       |
  149|       |    // The bitmap b can be serialized and re-read.
  150|  6.48k|    std::size_t expected_size_in_bytes = b.getSizeInBytes();
  151|  6.48k|    std::vector<char> buffer(expected_size_in_bytes);
  152|  6.48k|    std::size_t size_in_bytes = b.write(buffer.data());
  153|  6.48k|    assert(expected_size_in_bytes == size_in_bytes);
  ------------------
  |  Branch (153:5): [True: 6.48k, False: 0]
  ------------------
  154|  6.48k|    roaring::Roaring bread =
  155|  6.48k|        roaring::Roaring::readSafe(buffer.data(), size_in_bytes);
  156|  6.48k|    assert(bread == b);
  ------------------
  |  Branch (156:5): [True: 6.48k, False: 0]
  ------------------
  157|       |
  158|  6.48k|    f.toString();
  159|       |
  160|  6.48k|    volatile int unused = 0;
  161|       |
  162|   342k|    for (roaring::Roaring::const_iterator i = a.begin(); i != a.end(); i++) {
  ------------------
  |  Branch (162:58): [True: 335k, False: 6.48k]
  ------------------
  163|   335k|        unused++;
  164|   335k|    }
  165|       |
  166|  6.48k|    roaring::Roaring::const_iterator b_iter = b.begin();
  167|  6.48k|    b_iter.equalorlarger(
  168|  6.48k|        fdp.ConsumeIntegralInRange<uint32_t>(range_start, range_end));
  169|       |
  170|  6.48k|    return 0;
  171|  6.48k|}
croaring_fuzzer_cc.cc:_ZZ17ConsumeVecInRangeR18FuzzedDataProvidermjjENK3$_0clEv:
   27|  6.48M|    std::generate(result.begin(), result.end(), [&]() {
   28|  6.48M|        return fdp.ConsumeIntegralInRange<uint32_t>(min_value, max_value);
   29|  6.48M|    });

