_ZN7roaring7RoaringC2EmPKj:
   85|  12.8k|    Roaring(size_t n, const uint32_t *data) : Roaring() {
   86|  12.8k|        api::roaring_bitmap_add_many(&roaring, n, data);
   87|  12.8k|    }
_ZN7roaring7RoaringC2Ev:
   76|  19.3k|    Roaring() : roaring{} {
   77|       |        // The empty constructor roaring{} silences warnings from pedantic
   78|       |        // static analyzers.
   79|  19.3k|        api::roaring_bitmap_init_cleared(&roaring);
   80|  19.3k|    }
_ZN7roaring7RoaringD2Ev:
  913|  57.9k|    ~Roaring() {
  914|  57.9k|        if (!(roaring.high_low_container.flags & ROARING_FLAG_FROZEN)) {
  ------------------
  |  |   47|  57.9k|#define ROARING_FLAG_FROZEN UINT8_C(0x2)
  ------------------
  |  Branch (914:13): [True: 57.9k, False: 0]
  ------------------
  915|  57.9k|            api::roaring_bitmap_clear(&roaring);
  916|  57.9k|        } 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|  57.9k|    }
_ZN7roaring7Roaring11runOptimizeEv:
  493|  12.8k|    bool runOptimize() noexcept {
  494|  12.8k|        return api::roaring_bitmap_run_optimize(&roaring);
  495|  12.8k|    }
_ZN7roaring7Roaring11shrinkToFitEv:
  501|  6.44k|    size_t shrinkToFit() noexcept {
  502|  6.44k|        return api::roaring_bitmap_shrink_to_fit(&roaring);
  503|  6.44k|    }
_ZN7roaring7Roaring3addEj:
  198|  6.44k|    void add(uint32_t x) noexcept { api::roaring_bitmap_add(&roaring, x); }
_ZN7roaring7Roaring10addCheckedEj:
  205|  6.44k|    bool addChecked(uint32_t x) noexcept {
  206|  6.44k|        return api::roaring_bitmap_add_checked(&roaring, x);
  207|  6.44k|    }
_ZN7roaring7Roaring8addRangeEmm:
  212|  6.44k|    void addRange(const uint64_t min, const uint64_t max) noexcept {
  213|  6.44k|        return api::roaring_bitmap_add_range(&roaring, min, max);
  214|  6.44k|    }
_ZN7roaring7Roaring7addManyEmPKj:
  226|  6.44k|    void addMany(size_t n_args, const uint32_t *vals) noexcept {
  227|  6.44k|        api::roaring_bitmap_add_many(&roaring, n_args, vals);
  228|  6.44k|    }
_ZN7roaring7Roaring6removeEj:
  258|  6.44k|    void remove(uint32_t x) noexcept {
  259|  6.44k|        api::roaring_bitmap_remove(&roaring, x);
  260|  6.44k|    }
_ZN7roaring7Roaring13removeCheckedEj:
  267|  6.44k|    bool removeChecked(uint32_t x) noexcept {
  268|  6.44k|        return api::roaring_bitmap_remove_checked(&roaring, x);
  269|  6.44k|    }
_ZN7roaring7Roaring11removeRangeEmm:
  274|  6.44k|    void removeRange(uint64_t min, uint64_t max) noexcept {
  275|  6.44k|        return api::roaring_bitmap_remove_range(&roaring, min, max);
  276|  6.44k|    }
_ZN7roaring7Roaring17removeRangeClosedEjj:
  281|  6.44k|    void removeRangeClosed(uint32_t min, uint32_t max) noexcept {
  282|  6.44k|        return api::roaring_bitmap_remove_range_closed(&roaring, min, max);
  283|  6.44k|    }
_ZNK7roaring7Roaring7maximumEv:
  315|  6.44k|    uint32_t maximum() const noexcept {
  316|  6.44k|        return api::roaring_bitmap_maximum(&roaring);
  317|  6.44k|    }
_ZNK7roaring7Roaring7minimumEv:
  322|  6.44k|    uint32_t minimum() const noexcept {
  323|  6.44k|        return api::roaring_bitmap_minimum(&roaring);
  324|  6.44k|    }
_ZNK7roaring7Roaring8containsEj:
  329|  6.44k|    bool contains(uint32_t x) const noexcept {
  330|  6.44k|        return api::roaring_bitmap_contains(&roaring, x);
  331|  6.44k|    }
_ZNK7roaring7Roaring13containsRangeEmm:
  336|  6.44k|    bool containsRange(const uint64_t x, const uint64_t y) const noexcept {
  337|  6.44k|        return api::roaring_bitmap_contains_range(&roaring, x, y);
  338|  6.44k|    }
_ZNK7roaring7Roaring6selectEjPj:
  526|  6.44k|    bool select(uint32_t rnk, uint32_t *element) const noexcept {
  527|  6.44k|        return api::roaring_bitmap_select(&roaring, rnk, element);
  528|  6.44k|    }
_ZNK7roaring7Roaring9intersectERKS0_:
  540|  6.44k|    bool intersect(const Roaring &r) const noexcept {
  541|  6.44k|        return api::roaring_bitmap_intersect(&roaring, &r.roaring);
  542|  6.44k|    }
_ZNK7roaring7Roaring13jaccard_indexERKS0_:
  551|  6.44k|    double jaccard_index(const Roaring &r) const noexcept {
  552|  6.44k|        return api::roaring_bitmap_jaccard_index(&roaring, &r.roaring);
  553|  6.44k|    }
_ZNK7roaring7Roaring14or_cardinalityERKS0_:
  558|  6.44k|    uint64_t or_cardinality(const Roaring &r) const noexcept {
  559|  6.44k|        return api::roaring_bitmap_or_cardinality(&roaring, &r.roaring);
  560|  6.44k|    }
_ZNK7roaring7Roaring18andnot_cardinalityERKS0_:
  565|  6.44k|    uint64_t andnot_cardinality(const Roaring &r) const noexcept {
  566|  6.44k|        return api::roaring_bitmap_andnot_cardinality(&roaring, &r.roaring);
  567|  6.44k|    }
_ZNK7roaring7Roaring15xor_cardinalityERKS0_:
  573|  6.44k|    uint64_t xor_cardinality(const Roaring &r) const noexcept {
  574|  6.44k|        return api::roaring_bitmap_xor_cardinality(&roaring, &r.roaring);
  575|  6.44k|    }
_ZNK7roaring7Roaring4rankEj:
  585|  6.44k|    uint64_t rank(uint32_t x) const noexcept {
  586|  6.44k|        return api::roaring_bitmap_rank(&roaring, x);
  587|  6.44k|    }
_ZNK7roaring7Roaring14getSizeInBytesEb:
  732|  12.8k|    size_t getSizeInBytes(bool portable = true) const noexcept {
  733|  12.8k|        if (portable) {
  ------------------
  |  Branch (733:13): [True: 12.8k, False: 0]
  ------------------
  734|  12.8k|            return api::roaring_bitmap_portable_size_in_bytes(&roaring);
  735|  12.8k|        } else {
  736|      0|            return api::roaring_bitmap_size_in_bytes(&roaring);
  737|      0|        }
  738|  12.8k|    }
_ZNK7roaring7RoaringanERKS0_:
  794|  6.44k|    Roaring operator&(const Roaring &o) const {
  795|  6.44k|        roaring_bitmap_t *r = api::roaring_bitmap_and(&roaring, &o.roaring);
  796|  6.44k|        if (r == NULL) {
  ------------------
  |  Branch (796:13): [True: 0, False: 6.44k]
  ------------------
  797|      0|            ROARING_TERMINATE("failed materialization in and");
  ------------------
  |  |   27|      0|#define ROARING_TERMINATE(_s) throw std::runtime_error(_s)
  ------------------
  798|      0|        }
  799|  6.44k|        return Roaring(r);
  800|  6.44k|    }
_ZN7roaring7RoaringC2EPNS_3api16roaring_bitmap_sE:
  102|  32.2k|    explicit Roaring(roaring_bitmap_t *s) noexcept : roaring(*s) {
  103|  32.2k|        roaring_free(s);  // deallocate the passed-in pointer
  104|  32.2k|    }
_ZNK7roaring7RoaringmiERKS0_:
  807|  6.44k|    Roaring operator-(const Roaring &o) const {
  808|  6.44k|        roaring_bitmap_t *r = api::roaring_bitmap_andnot(&roaring, &o.roaring);
  809|  6.44k|        if (r == NULL) {
  ------------------
  |  Branch (809:13): [True: 0, False: 6.44k]
  ------------------
  810|      0|            ROARING_TERMINATE("failed materialization in andnot");
  ------------------
  |  |   27|      0|#define ROARING_TERMINATE(_s) throw std::runtime_error(_s)
  ------------------
  811|      0|        }
  812|  6.44k|        return Roaring(r);
  813|  6.44k|    }
_ZNK7roaring7RoaringorERKS0_:
  820|  6.44k|    Roaring operator|(const Roaring &o) const {
  821|  6.44k|        roaring_bitmap_t *r = api::roaring_bitmap_or(&roaring, &o.roaring);
  822|  6.44k|        if (r == NULL) {
  ------------------
  |  Branch (822:13): [True: 0, False: 6.44k]
  ------------------
  823|      0|            ROARING_TERMINATE("failed materialization in or");
  ------------------
  |  |   27|      0|#define ROARING_TERMINATE(_s) throw std::runtime_error(_s)
  ------------------
  824|      0|        }
  825|  6.44k|        return Roaring(r);
  826|  6.44k|    }
_ZNK7roaring7RoaringeoERKS0_:
  833|  6.44k|    Roaring operator^(const Roaring &o) const {
  834|  6.44k|        roaring_bitmap_t *r = api::roaring_bitmap_xor(&roaring, &o.roaring);
  835|  6.44k|        if (r == NULL) {
  ------------------
  |  Branch (835:13): [True: 0, False: 6.44k]
  ------------------
  836|      0|            ROARING_TERMINATE("failed materialization in xor");
  ------------------
  |  |   27|      0|#define ROARING_TERMINATE(_s) throw std::runtime_error(_s)
  ------------------
  837|      0|        }
  838|  6.44k|        return Roaring(r);
  839|  6.44k|    }
_ZN7roaring7RoaringoRERKS0_:
  378|  6.44k|    Roaring &operator|=(const Roaring &r) noexcept {
  379|  6.44k|        api::roaring_bitmap_or_inplace(&roaring, &r.roaring);
  380|  6.44k|        return *this;
  381|  6.44k|    }
_ZN7roaring7RoaringaNERKS0_:
  356|  6.44k|    Roaring &operator&=(const Roaring &r) noexcept {
  357|  6.44k|        api::roaring_bitmap_and_inplace(&roaring, &r.roaring);
  358|  6.44k|        return *this;
  359|  6.44k|    }
_ZN7roaring7RoaringmIERKS0_:
  366|  6.44k|    Roaring &operator-=(const Roaring &r) noexcept {
  367|  6.44k|        api::roaring_bitmap_andnot_inplace(&roaring, &r.roaring);
  368|  6.44k|        return *this;
  369|  6.44k|    }
_ZN7roaring7RoaringeOERKS0_:
  388|  6.44k|    Roaring &operator^=(const Roaring &r) noexcept {
  389|  6.44k|        api::roaring_bitmap_xor_inplace(&roaring, &r.roaring);
  390|  6.44k|        return *this;
  391|  6.44k|    }
_ZNK7roaring7RoaringeqERKS0_:
  458|  12.8k|    bool operator==(const Roaring &r) const noexcept {
  459|  12.8k|        return api::roaring_bitmap_equals(&roaring, &r.roaring);
  460|  12.8k|    }
_ZNK7roaring7Roaring11cardinalityEv:
  401|  6.44k|    uint64_t cardinality() const noexcept {
  402|  6.44k|        return api::roaring_bitmap_get_cardinality(&roaring);
  403|  6.44k|    }
_ZNK7roaring7Roaring7isEmptyEv:
  408|  12.8k|    bool isEmpty() const noexcept {
  409|  12.8k|        return api::roaring_bitmap_is_empty(&roaring);
  410|  12.8k|    }
_ZNK7roaring7Roaring13toUint32ArrayEPj:
  441|  6.44k|    void toUint32Array(uint32_t *ans) const noexcept {
  442|  6.44k|        api::roaring_bitmap_to_uint32_array(&roaring, ans);
  443|  6.44k|    }
_ZNK7roaring7Roaring8isSubsetERKS0_:
  425|  6.44k|    bool isSubset(const Roaring &r) const noexcept {
  426|  6.44k|        return api::roaring_bitmap_is_subset(&roaring, &r.roaring);
  427|  6.44k|    }
_ZNK7roaring7Roaring14isStrictSubsetERKS0_:
  432|  6.44k|    bool isStrictSubset(const Roaring &r) const noexcept {
  433|  6.44k|        return api::roaring_bitmap_is_strict_subset(&roaring, &r.roaring);
  434|  6.44k|    }
_ZN7roaring7Roaring4flipEmm:
  466|  6.44k|    void flip(uint64_t range_start, uint64_t range_end) noexcept {
  467|  6.44k|        api::roaring_bitmap_flip_inplace(&roaring, range_start, range_end);
  468|  6.44k|    }
_ZN7roaring7Roaring10flipClosedEjj:
  474|  6.44k|    void flipClosed(uint32_t range_start, uint32_t range_end) noexcept {
  475|  6.44k|        api::roaring_bitmap_flip_inplace_closed(&roaring, range_start,
  476|  6.44k|                                                range_end);
  477|  6.44k|    }
_ZN7roaring7Roaring20removeRunCompressionEv:
  483|  6.44k|    bool removeRunCompression() noexcept {
  484|  6.44k|        return api::roaring_bitmap_remove_run_compression(&roaring);
  485|  6.44k|    }
_ZN7roaring7RoaringC2ERKS0_:
  110|  6.44k|    Roaring(const Roaring &r) : Roaring() {
  111|  6.44k|        if (!api::roaring_bitmap_overwrite(&roaring, &r.roaring)) {
  ------------------
  |  Branch (111:13): [True: 0, False: 6.44k]
  ------------------
  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.44k|        api::roaring_bitmap_set_copy_on_write(
  115|  6.44k|            &roaring, api::roaring_bitmap_get_copy_on_write(&r.roaring));
  116|  6.44k|    }
_ZN7roaring7RoaringC2EOS0_:
  122|  6.44k|    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.44k|        api::roaring_bitmap_init_cleared(&r.roaring);
  131|  6.44k|    }
_ZN7roaring7RoaringaSERKS0_:
  152|  6.44k|    Roaring &operator=(const Roaring &r) {
  153|  6.44k|        if (!api::roaring_bitmap_overwrite(&roaring, &r.roaring)) {
  ------------------
  |  Branch (153:13): [True: 0, False: 6.44k]
  ------------------
  154|      0|            ROARING_TERMINATE("failed memory alloc in assignment");
  ------------------
  |  |   27|      0|#define ROARING_TERMINATE(_s) throw std::runtime_error(_s)
  ------------------
  155|      0|        }
  156|  6.44k|        api::roaring_bitmap_set_copy_on_write(
  157|  6.44k|            &roaring, api::roaring_bitmap_get_copy_on_write(&r.roaring));
  158|  6.44k|        return *this;
  159|  6.44k|    }
_ZN7roaring7RoaringaSEOS0_:
  165|  6.44k|    Roaring &operator=(Roaring &&r) noexcept {
  166|  6.44k|        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.44k|        roaring = r.roaring;
  171|  6.44k|        api::roaring_bitmap_init_cleared(&r.roaring);
  172|       |
  173|  6.44k|        return *this;
  174|  6.44k|    }
_ZN7roaring7Roaring8readSafeEPKcm:
  706|  12.8k|    static Roaring readSafe(const char *buf, size_t maxbytes) {
  707|  12.8k|        roaring_bitmap_t *r =
  708|  12.8k|            api::roaring_bitmap_portable_deserialize_safe(buf, maxbytes);
  709|  12.8k|        if (r == NULL) {
  ------------------
  |  Branch (709:13): [True: 6.42k, False: 6.45k]
  ------------------
  710|  6.42k|            ROARING_TERMINATE("failed alloc while reading");
  ------------------
  |  |   27|  6.42k|#define ROARING_TERMINATE(_s) throw std::runtime_error(_s)
  ------------------
  711|  6.42k|        }
  712|  6.45k|        return Roaring(r);
  713|  12.8k|    }
_ZNK7roaring7Roaring5writeEPcb:
  649|  6.44k|    size_t write(char *buf, bool portable = true) const noexcept {
  650|  6.44k|        if (portable) {
  ------------------
  |  Branch (650:13): [True: 6.44k, False: 0]
  ------------------
  651|  6.44k|            return api::roaring_bitmap_portable_serialize(&roaring, buf);
  652|  6.44k|        } else {
  653|      0|            return api::roaring_bitmap_serialize(&roaring, buf);
  654|      0|        }
  655|  6.44k|    }
_ZNK7roaring7Roaring8toStringEv:
  856|  6.44k|    std::string toString() const noexcept {
  857|  6.44k|        struct iter_data {
  858|  6.44k|            std::string str{};  // The empty constructor silences warnings from
  859|       |                                // pedantic static analyzers.
  860|  6.44k|            char first_char = '{';
  861|  6.44k|        } outer_iter_data;
  862|  6.44k|        if (!isEmpty()) {
  ------------------
  |  Branch (862:13): [True: 6.42k, False: 16]
  ------------------
  863|  6.42k|            iterate(
  864|  6.42k|                [](uint32_t value, void *inner_iter_data) -> bool {
  865|  6.42k|                    ((iter_data *)inner_iter_data)->str +=
  866|  6.42k|                        ((iter_data *)inner_iter_data)->first_char;
  867|  6.42k|                    ((iter_data *)inner_iter_data)->str +=
  868|  6.42k|                        std::to_string(value);
  869|  6.42k|                    ((iter_data *)inner_iter_data)->first_char = ',';
  870|  6.42k|                    return true;
  871|  6.42k|                },
  872|  6.42k|                (void *)&outer_iter_data);
  873|  6.42k|        } else
  874|     16|            outer_iter_data.str = '{';
  875|  6.44k|        outer_iter_data.str += '}';
  876|  6.44k|        return outer_iter_data.str;
  877|  6.44k|    }
_ZNK7roaring7Roaring7iterateEPFbjPvES1_:
  514|  6.42k|    void iterate(api::roaring_iterator iterator, void *ptr) const {
  515|  6.42k|        api::roaring_iterate(&roaring, iterator, ptr);
  516|  6.42k|    }
_ZZNK7roaring7Roaring8toStringEvENKUljPvE_clEjS1_:
  864|  3.93G|                [](uint32_t value, void *inner_iter_data) -> bool {
  865|  3.93G|                    ((iter_data *)inner_iter_data)->str +=
  866|  3.93G|                        ((iter_data *)inner_iter_data)->first_char;
  867|  3.93G|                    ((iter_data *)inner_iter_data)->str +=
  868|  3.93G|                        std::to_string(value);
  869|  3.93G|                    ((iter_data *)inner_iter_data)->first_char = ',';
  870|  3.93G|                    return true;
  871|  3.93G|                },
_ZNK7roaring7Roaring5beginEv:
 1073|  12.8k|inline RoaringSetBitBiDirectionalIterator Roaring::begin() const {
 1074|  12.8k|    return RoaringSetBitBiDirectionalIterator(*this);
 1075|  12.8k|}
_ZN7roaring34RoaringSetBitBiDirectionalIteratorC2ERKNS_7RoaringEb:
  967|  12.8k|                                                bool exhausted = false) {
  968|  12.8k|        if (exhausted) {
  ------------------
  |  Branch (968:13): [True: 1, False: 12.8k]
  ------------------
  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.8k|        } else {
  974|  12.8k|            api::roaring_iterator_init(&parent.roaring, &i);
  975|  12.8k|        }
  976|  12.8k|    }
_ZNK7roaring34RoaringSetBitBiDirectionalIteratorneERKS0_:
 1064|   340k|    bool operator!=(const RoaringSetBitBiDirectionalIterator &o) const {
 1065|   340k|        return i.current_value != *o || i.has_value != o.i.has_value;
  ------------------
  |  Branch (1065:16): [True: 333k, False: 6.44k]
  |  Branch (1065:41): [True: 0, False: 6.44k]
  ------------------
 1066|   340k|    }
_ZNK7roaring34RoaringSetBitBiDirectionalIteratordeEv:
  981|   340k|    value_type operator*() const { return i.current_value; }
_ZNK7roaring7Roaring3endEv:
 1077|   340k|inline RoaringSetBitBiDirectionalIterator &Roaring::end() const {
 1078|   340k|    static RoaringSetBitBiDirectionalIterator e(*this, true);
 1079|   340k|    return e;
 1080|   340k|}
_ZN7roaring34RoaringSetBitBiDirectionalIteratorppEi:
 1012|   333k|    type_of_iterator operator++(int) {  // i++, must return orig. value
 1013|   333k|        RoaringSetBitBiDirectionalIterator orig(*this);
 1014|   333k|        api::roaring_uint32_iterator_advance(&i);
 1015|   333k|        return orig;
 1016|   333k|    }
_ZN7roaring34RoaringSetBitBiDirectionalIterator13equalorlargerEj:
 1027|  6.44k|    CROARING_DEPRECATED void equalorlarger(uint32_t val) {
 1028|  6.44k|        api::roaring_uint32_iterator_move_equalorlarger(&i, val);
 1029|  6.44k|    }

binarySearch:
   52|  7.36M|                            uint16_t ikey) {
   53|  7.36M|    const int32_t gap = 16;
   54|  7.36M|    if (lenarray < gap) {
  ------------------
  |  Branch (54:9): [True: 2.83M, False: 4.52M]
  ------------------
   55|  4.38M|        for (int32_t j = 0; j < lenarray; j++) {
  ------------------
  |  Branch (55:29): [True: 4.38M, False: 7.40k]
  ------------------
   56|  4.38M|            if (array[j] >= ikey) {
  ------------------
  |  Branch (56:17): [True: 2.82M, False: 1.55M]
  ------------------
   57|  2.82M|                return (array[j] == ikey) ? j : -(j + 1);
  ------------------
  |  Branch (57:24): [True: 2.67M, False: 152k]
  ------------------
   58|  2.82M|            }
   59|  4.38M|        }
   60|  7.40k|        return -(lenarray + 1);
   61|  2.83M|    }
   62|  4.52M|    const int32_t num_blocks = lenarray / gap;
   63|  4.52M|    int32_t base = 0;
   64|  4.52M|    int32_t n = num_blocks;
   65|  9.08M|    while (n > 3) {
  ------------------
  |  Branch (65:12): [True: 4.56M, False: 4.52M]
  ------------------
   66|  4.56M|        int32_t quarter = n >> 2;
   67|       |
   68|  4.56M|        int32_t k1 = array[(base + quarter + 1) * gap - 1];
   69|  4.56M|        int32_t k2 = array[(base + 2 * quarter + 1) * gap - 1];
   70|  4.56M|        int32_t k3 = array[(base + 3 * quarter + 1) * gap - 1];
   71|       |
   72|  4.56M|        int32_t c1 = (k1 < ikey);
   73|  4.56M|        int32_t c2 = (k2 < ikey);
   74|  4.56M|        int32_t c3 = (k3 < ikey);
   75|       |
   76|  4.56M|        base += (c1 + c2 + c3) * quarter;
   77|  4.56M|        n -= 3 * quarter;
   78|  4.56M|    }
   79|  8.41M|    while (n > 1) {
  ------------------
  |  Branch (79:12): [True: 3.88M, False: 4.52M]
  ------------------
   80|  3.88M|        int32_t half = n >> 1;
   81|  3.88M|        base = (array[(base + half + 1) * gap - 1] < ikey) ? base + half : base;
  ------------------
  |  Branch (81:16): [True: 549k, False: 3.33M]
  ------------------
   82|  3.88M|        n -= half;
   83|  3.88M|    }
   84|  4.52M|    int32_t lo = (array[(base + 1) * gap - 1] < ikey) ? base + 1 : base;
  ------------------
  |  Branch (84:18): [True: 2.10M, False: 2.42M]
  ------------------
   85|       |
   86|  4.52M|    if (lo < num_blocks) {
  ------------------
  |  Branch (86:9): [True: 4.20M, False: 327k]
  ------------------
   87|  4.20M|        const int32_t start = lo * gap;
   88|  4.20M|#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.20M|        __m128i needle = _mm_set1_epi16((short)ikey);
   95|  4.20M|        __m128i zero = _mm_setzero_si128();
   96|  4.20M|        __m128i v0 = _mm_loadu_si128((const __m128i *)(array + start));
   97|  4.20M|        __m128i ge0 = _mm_cmpeq_epi16(_mm_subs_epu16(needle, v0), zero);
   98|  4.20M|        unsigned m0 = (unsigned)_mm_movemask_epi8(ge0);
   99|  4.20M|        if (m0 != 0) {
  ------------------
  |  Branch (99:13): [True: 2.99M, False: 1.20M]
  ------------------
  100|  2.99M|            int32_t j = start + (int32_t)(roaring_trailing_zeroes(m0) >> 1);
  101|  2.99M|            return (array[j] == ikey) ? j : -(j + 1);
  ------------------
  |  Branch (101:20): [True: 2.22M, False: 768k]
  ------------------
  102|  2.99M|        }
  103|  1.20M|        __m128i v1 = _mm_loadu_si128((const __m128i *)(array + start + 8));
  104|  1.20M|        __m128i ge1 = _mm_cmpeq_epi16(_mm_subs_epu16(needle, v1), zero);
  105|  1.20M|        unsigned m1 = (unsigned)_mm_movemask_epi8(ge1);
  106|  1.20M|        int32_t j = start + 8 + (int32_t)(roaring_trailing_zeroes(m1) >> 1);
  107|  1.20M|        return (array[j] == ikey) ? j : -(j + 1);
  ------------------
  |  Branch (107:16): [True: 525k, False: 681k]
  ------------------
  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.20M|    }
  120|       |
  121|  1.88M|    for (int32_t j = num_blocks * gap; j < lenarray; j++) {
  ------------------
  |  Branch (121:40): [True: 1.87M, False: 11.2k]
  ------------------
  122|  1.87M|        if (array[j] >= ikey) {
  ------------------
  |  Branch (122:13): [True: 316k, False: 1.55M]
  ------------------
  123|   316k|            return (array[j] == ikey) ? j : -(j + 1);
  ------------------
  |  Branch (123:20): [True: 178k, False: 138k]
  ------------------
  124|   316k|        }
  125|  1.87M|    }
  126|  11.2k|    return -(lenarray + 1);
  127|   327k|}
roaring.c:advanceUntil:
  137|    420|                                   int32_t length, uint16_t min) {
  138|    420|    int32_t lower = pos + 1;
  139|       |
  140|    420|    if ((lower >= length) || (array[lower] >= min)) {
  ------------------
  |  Branch (140:9): [True: 420, False: 0]
  |  Branch (140:30): [True: 0, False: 0]
  ------------------
  141|    420|        return lower;
  142|    420|    }
  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.21k|                                    uint16_t ikey) {
  198|  9.21k|    if (lenarray == 0) return 0;
  ------------------
  |  Branch (198:9): [True: 0, False: 9.21k]
  ------------------
  199|  9.21k|    int32_t pos = binarySearch(array, lenarray, ikey);
  200|  9.21k|    if (pos >= 0) {
  ------------------
  |  Branch (200:9): [True: 2.04k, False: 7.17k]
  ------------------
  201|  2.04k|        return lenarray - (pos + 1);
  202|  7.17k|    } else {
  203|  7.17k|        return lenarray - (-pos - 1);
  204|  7.17k|    }
  205|  9.21k|}
roaring.c:count_less:
  186|  15.8k|                                 uint16_t ikey) {
  187|  15.8k|    if (lenarray == 0) return 0;
  ------------------
  |  Branch (187:9): [True: 3.00k, 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.75k, False: 3.07k]
  ------------------
  190|  15.8k|}
array_util.c:advanceUntil:
  137|  19.5k|                                   int32_t length, uint16_t min) {
  138|  19.5k|    int32_t lower = pos + 1;
  139|       |
  140|  19.5k|    if ((lower >= length) || (array[lower] >= min)) {
  ------------------
  |  Branch (140:9): [True: 21, False: 19.5k]
  |  Branch (140:30): [True: 6.31k, False: 13.2k]
  ------------------
  141|  6.33k|        return lower;
  142|  6.33k|    }
  143|       |
  144|  13.2k|    int32_t spansize = 1;
  145|       |
  146|  59.5k|    while ((lower + spansize < length) && (array[lower + spansize] < min)) {
  ------------------
  |  Branch (146:12): [True: 58.1k, False: 1.40k]
  |  Branch (146:43): [True: 46.3k, False: 11.8k]
  ------------------
  147|  46.3k|        spansize <<= 1;
  148|  46.3k|    }
  149|  13.2k|    int32_t upper = (lower + spansize < length) ? lower + spansize : length - 1;
  ------------------
  |  Branch (149:21): [True: 11.8k, False: 1.40k]
  ------------------
  150|       |
  151|  13.2k|    if (array[upper] == min) {
  ------------------
  |  Branch (151:9): [True: 3.07k, False: 10.1k]
  ------------------
  152|  3.07k|        return upper;
  153|  3.07k|    }
  154|  10.1k|    if (array[upper] < min) {
  ------------------
  |  Branch (154:9): [True: 206, False: 9.92k]
  ------------------
  155|       |        // means
  156|       |        // array
  157|       |        // has no
  158|       |        // item
  159|       |        // >= min
  160|       |        // pos = array.length;
  161|    206|        return length;
  162|    206|    }
  163|       |
  164|       |    // we know that the next-smallest span was too small
  165|  9.92k|    lower += (spansize >> 1);
  166|       |
  167|  9.92k|    int32_t mid = 0;
  168|  32.8k|    while (lower + 1 != upper) {
  ------------------
  |  Branch (168:12): [True: 28.3k, False: 4.54k]
  ------------------
  169|  28.3k|        mid = (lower + upper) >> 1;
  170|  28.3k|        if (array[mid] == min) {
  ------------------
  |  Branch (170:13): [True: 5.38k, False: 22.9k]
  ------------------
  171|  5.38k|            return mid;
  172|  22.9k|        } else if (array[mid] < min) {
  ------------------
  |  Branch (172:20): [True: 11.2k, False: 11.6k]
  ------------------
  173|  11.2k|            lower = mid;
  174|  11.6k|        } else {
  175|  11.6k|            upper = mid;
  176|  11.6k|        }
  177|  28.3k|    }
  178|  4.54k|    return upper;
  179|  9.92k|}
mixed_intersection.c:advanceUntil:
  137|   137k|                                   int32_t length, uint16_t min) {
  138|   137k|    int32_t lower = pos + 1;
  139|       |
  140|   137k|    if ((lower >= length) || (array[lower] >= min)) {
  ------------------
  |  Branch (140:9): [True: 490, False: 136k]
  |  Branch (140:30): [True: 76.7k, False: 59.7k]
  ------------------
  141|  77.2k|        return lower;
  142|  77.2k|    }
  143|       |
  144|  59.7k|    int32_t spansize = 1;
  145|       |
  146|   139k|    while ((lower + spansize < length) && (array[lower + spansize] < min)) {
  ------------------
  |  Branch (146:12): [True: 138k, False: 1.25k]
  |  Branch (146:43): [True: 80.1k, False: 58.4k]
  ------------------
  147|  80.1k|        spansize <<= 1;
  148|  80.1k|    }
  149|  59.7k|    int32_t upper = (lower + spansize < length) ? lower + spansize : length - 1;
  ------------------
  |  Branch (149:21): [True: 58.4k, False: 1.25k]
  ------------------
  150|       |
  151|  59.7k|    if (array[upper] == min) {
  ------------------
  |  Branch (151:9): [True: 28.8k, False: 30.9k]
  ------------------
  152|  28.8k|        return upper;
  153|  28.8k|    }
  154|  30.9k|    if (array[upper] < min) {
  ------------------
  |  Branch (154:9): [True: 615, False: 30.3k]
  ------------------
  155|       |        // means
  156|       |        // array
  157|       |        // has no
  158|       |        // item
  159|       |        // >= min
  160|       |        // pos = array.length;
  161|    615|        return length;
  162|    615|    }
  163|       |
  164|       |    // we know that the next-smallest span was too small
  165|  30.3k|    lower += (spansize >> 1);
  166|       |
  167|  30.3k|    int32_t mid = 0;
  168|  52.9k|    while (lower + 1 != upper) {
  ------------------
  |  Branch (168:12): [True: 34.8k, False: 18.1k]
  ------------------
  169|  34.8k|        mid = (lower + upper) >> 1;
  170|  34.8k|        if (array[mid] == min) {
  ------------------
  |  Branch (170:13): [True: 12.1k, False: 22.6k]
  ------------------
  171|  12.1k|            return mid;
  172|  22.6k|        } else if (array[mid] < min) {
  ------------------
  |  Branch (172:20): [True: 8.62k, False: 14.0k]
  ------------------
  173|  8.62k|            lower = mid;
  174|  14.0k|        } else {
  175|  14.0k|            upper = mid;
  176|  14.0k|        }
  177|  34.8k|    }
  178|  18.1k|    return upper;
  179|  30.3k|}
mixed_subset.c:advanceUntil:
  137|    402|                                   int32_t length, uint16_t min) {
  138|    402|    int32_t lower = pos + 1;
  139|       |
  140|    402|    if ((lower >= length) || (array[lower] >= min)) {
  ------------------
  |  Branch (140:9): [True: 0, False: 402]
  |  Branch (140:30): [True: 194, False: 208]
  ------------------
  141|    194|        return lower;
  142|    194|    }
  143|       |
  144|    208|    int32_t spansize = 1;
  145|       |
  146|  1.01k|    while ((lower + spansize < length) && (array[lower + spansize] < min)) {
  ------------------
  |  Branch (146:12): [True: 922, False: 88]
  |  Branch (146:43): [True: 802, False: 120]
  ------------------
  147|    802|        spansize <<= 1;
  148|    802|    }
  149|    208|    int32_t upper = (lower + spansize < length) ? lower + spansize : length - 1;
  ------------------
  |  Branch (149:21): [True: 120, False: 88]
  ------------------
  150|       |
  151|    208|    if (array[upper] == min) {
  ------------------
  |  Branch (151:9): [True: 0, False: 208]
  ------------------
  152|      0|        return upper;
  153|      0|    }
  154|    208|    if (array[upper] < min) {
  ------------------
  |  Branch (154:9): [True: 10, False: 198]
  ------------------
  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|    198|    lower += (spansize >> 1);
  166|       |
  167|    198|    int32_t mid = 0;
  168|    708|    while (lower + 1 != upper) {
  ------------------
  |  Branch (168:12): [True: 510, False: 198]
  ------------------
  169|    510|        mid = (lower + upper) >> 1;
  170|    510|        if (array[mid] == min) {
  ------------------
  |  Branch (170:13): [True: 0, False: 510]
  ------------------
  171|      0|            return mid;
  172|    510|        } else if (array[mid] < min) {
  ------------------
  |  Branch (172:20): [True: 250, False: 260]
  ------------------
  173|    250|            lower = mid;
  174|    260|        } else {
  175|    260|            upper = mid;
  176|    260|        }
  177|    510|    }
  178|    198|    return upper;
  179|    198|}
mixed_andnot.c:advanceUntil:
  137|  95.0k|                                   int32_t length, uint16_t min) {
  138|  95.0k|    int32_t lower = pos + 1;
  139|       |
  140|  95.0k|    if ((lower >= length) || (array[lower] >= min)) {
  ------------------
  |  Branch (140:9): [True: 4.84k, False: 90.1k]
  |  Branch (140:30): [True: 76.1k, False: 13.9k]
  ------------------
  141|  81.0k|        return lower;
  142|  81.0k|    }
  143|       |
  144|  13.9k|    int32_t spansize = 1;
  145|       |
  146|  27.8k|    while ((lower + spansize < length) && (array[lower + spansize] < min)) {
  ------------------
  |  Branch (146:12): [True: 27.3k, False: 499]
  |  Branch (146:43): [True: 13.8k, False: 13.4k]
  ------------------
  147|  13.8k|        spansize <<= 1;
  148|  13.8k|    }
  149|  13.9k|    int32_t upper = (lower + spansize < length) ? lower + spansize : length - 1;
  ------------------
  |  Branch (149:21): [True: 13.4k, False: 499]
  ------------------
  150|       |
  151|  13.9k|    if (array[upper] == min) {
  ------------------
  |  Branch (151:9): [True: 6.67k, False: 7.31k]
  ------------------
  152|  6.67k|        return upper;
  153|  6.67k|    }
  154|  7.31k|    if (array[upper] < min) {
  ------------------
  |  Branch (154:9): [True: 461, False: 6.84k]
  ------------------
  155|       |        // means
  156|       |        // array
  157|       |        // has no
  158|       |        // item
  159|       |        // >= min
  160|       |        // pos = array.length;
  161|    461|        return length;
  162|    461|    }
  163|       |
  164|       |    // we know that the next-smallest span was too small
  165|  6.84k|    lower += (spansize >> 1);
  166|       |
  167|  6.84k|    int32_t mid = 0;
  168|  10.4k|    while (lower + 1 != upper) {
  ------------------
  |  Branch (168:12): [True: 5.79k, False: 4.65k]
  ------------------
  169|  5.79k|        mid = (lower + upper) >> 1;
  170|  5.79k|        if (array[mid] == min) {
  ------------------
  |  Branch (170:13): [True: 2.19k, False: 3.60k]
  ------------------
  171|  2.19k|            return mid;
  172|  3.60k|        } else if (array[mid] < min) {
  ------------------
  |  Branch (172:20): [True: 1.22k, False: 2.37k]
  ------------------
  173|  1.22k|            lower = mid;
  174|  2.37k|        } else {
  175|  2.37k|            upper = mid;
  176|  2.37k|        }
  177|  5.79k|    }
  178|  4.65k|    return upper;
  179|  6.84k|}

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

array_container_contains:
  343|  3.33k|                                     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.33k|    const int32_t gap = 16;
  351|  3.33k|    const uint16_t *carr = arr->array;
  352|  3.33k|    int32_t cardinality = arr->cardinality;
  353|  3.33k|    if (cardinality < gap) {
  ------------------
  |  Branch (353:9): [True: 965, False: 2.37k]
  ------------------
  354|  1.10k|        for (int32_t j = 0; j < cardinality; j++) {
  ------------------
  |  Branch (354:29): [True: 1.06k, False: 35]
  ------------------
  355|  1.06k|            if (carr[j] >= pos) return carr[j] == pos;
  ------------------
  |  Branch (355:17): [True: 930, False: 139]
  ------------------
  356|  1.06k|        }
  357|     35|        return false;
  358|    965|    }
  359|  2.37k|    int32_t num_blocks = cardinality / gap;
  360|  2.37k|    int32_t base = 0;
  361|  2.37k|    int32_t n = num_blocks;
  362|  5.52k|    while (n > 3) {
  ------------------
  |  Branch (362:12): [True: 3.15k, False: 2.37k]
  ------------------
  363|  3.15k|        int32_t quarter = n >> 2;
  364|       |
  365|  3.15k|        int32_t k1 = carr[(base + quarter + 1) * gap - 1];
  366|  3.15k|        int32_t k2 = carr[(base + 2 * quarter + 1) * gap - 1];
  367|  3.15k|        int32_t k3 = carr[(base + 3 * quarter + 1) * gap - 1];
  368|       |
  369|  3.15k|        int32_t c1 = (k1 < pos);
  370|  3.15k|        int32_t c2 = (k2 < pos);
  371|  3.15k|        int32_t c3 = (k3 < pos);
  372|       |
  373|  3.15k|        base += (c1 + c2 + c3) * quarter;
  374|  3.15k|        n -= 3 * quarter;
  375|  3.15k|    }
  376|  4.21k|    while (n > 1) {
  ------------------
  |  Branch (376:12): [True: 1.84k, False: 2.37k]
  ------------------
  377|  1.84k|        int32_t half = n >> 1;
  378|  1.84k|        base = (carr[(base + half + 1) * gap - 1] < pos) ? base + half : base;
  ------------------
  |  Branch (378:16): [True: 72, False: 1.77k]
  ------------------
  379|  1.84k|        n -= half;
  380|  1.84k|    }
  381|  2.37k|    int32_t lo = (carr[(base + 1) * gap - 1] < pos) ? base + 1 : base;
  ------------------
  |  Branch (381:18): [True: 109, False: 2.26k]
  ------------------
  382|       |
  383|  2.37k|    if (lo < num_blocks) {
  ------------------
  |  Branch (383:9): [True: 2.29k, False: 74]
  ------------------
  384|  2.29k|        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.29k|        __m128i v0 = _mm_loadu_si128((const __m128i *)blk);
  395|  2.29k|        __m128i v1 = _mm_loadu_si128((const __m128i *)(blk + 8));
  396|  2.29k|        __m128i hit = _mm_or_si128(_mm_cmpeq_epi16(v0, needle),
  397|  2.29k|                                   _mm_cmpeq_epi16(v1, needle));
  398|  2.29k|        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.29k|    }
  406|       |
  407|    555|    for (int32_t j = num_blocks * gap; j < cardinality; j++) {
  ------------------
  |  Branch (407:40): [True: 510, False: 45]
  ------------------
  408|    510|        uint16_t v = carr[j];
  409|    510|        if (v >= pos) return (v == pos);
  ------------------
  |  Branch (409:13): [True: 29, False: 481]
  ------------------
  410|    510|    }
  411|     45|    return false;
  412|     74|}
array_container_minimum:
  445|  3.61k|inline uint16_t array_container_minimum(const array_container_t *arr) {
  446|  3.61k|    if (arr->cardinality == 0) return 0;
  ------------------
  |  Branch (446:9): [True: 0, False: 3.61k]
  ------------------
  447|  3.61k|    return arr->array[0];
  448|  3.61k|}
array_container_maximum:
  451|  13.2k|inline uint16_t array_container_maximum(const array_container_t *arr) {
  452|  13.2k|    if (arr->cardinality == 0) return 0;
  ------------------
  |  Branch (452:9): [True: 0, False: 13.2k]
  ------------------
  453|  13.2k|    return arr->array[arr->cardinality - 1];
  454|  13.2k|}
array_container_rank:
  457|  3.82k|inline int array_container_rank(const array_container_t *arr, uint16_t x) {
  458|  3.82k|    const int32_t idx = binarySearch(arr->array, arr->cardinality, x);
  459|  3.82k|    const bool is_present = idx >= 0;
  460|  3.82k|    if (is_present) {
  ------------------
  |  Branch (460:9): [True: 3.23k, False: 588]
  ------------------
  461|  3.23k|        return idx + 1;
  462|  3.23k|    } else {
  463|    588|        return -idx - 1;
  464|    588|    }
  465|  3.82k|}
array_container_index_equalorlarger:
  507|  4.42k|                                               uint16_t x) {
  508|  4.42k|    const int32_t idx = binarySearch(arr->array, arr->cardinality, x);
  509|  4.42k|    const bool is_present = idx >= 0;
  510|  4.42k|    if (is_present) {
  ------------------
  |  Branch (510:9): [True: 4.05k, False: 377]
  ------------------
  511|  4.05k|        return idx;
  512|  4.05k|    } else {
  513|    377|        int32_t candidate = -idx - 1;
  514|    377|        if (candidate < arr->cardinality) return candidate;
  ------------------
  |  Branch (514:13): [True: 377, False: 0]
  ------------------
  515|      0|        return -1;
  516|    377|    }
  517|  4.42k|}
roaring.c:array_container_add_range_nvals:
  527|    639|                                                   int32_t nvals_greater) {
  528|    639|    int32_t union_cardinality = nvals_less + (max - min + 1) + nvals_greater;
  529|    639|    if (union_cardinality > array->capacity) {
  ------------------
  |  Branch (529:9): [True: 590, False: 49]
  ------------------
  530|    590|        array_container_grow(array, union_cardinality, true);
  531|    590|    }
  532|    639|    memmove(&(array->array[union_cardinality - nvals_greater]),
  533|    639|            &(array->array[array->cardinality - nvals_greater]),
  534|    639|            nvals_greater * sizeof(uint16_t));
  535|  1.55M|    for (uint32_t i = 0; i <= max - min; i++) {
  ------------------
  |  Branch (535:26): [True: 1.55M, False: 639]
  ------------------
  536|  1.55M|        array->array[nvals_less + i] = (uint16_t)(min + i);
  537|  1.55M|    }
  538|    639|    array->cardinality = union_cardinality;
  539|    639|}
roaring.c:array_container_remove_range:
  557|  3.19k|                                                uint32_t pos, uint32_t count) {
  558|  3.19k|    if (count != 0) {
  ------------------
  |  Branch (558:9): [True: 318, False: 2.87k]
  ------------------
  559|    318|        memmove(&(array->array[pos]), &(array->array[pos + count]),
  560|    318|                (array->cardinality - pos - count) * sizeof(uint16_t));
  561|    318|        array->cardinality -= count;
  562|    318|    }
  563|  3.19k|}
roaring.c:array_container_cardinality:
   82|  72.0k|static inline int array_container_cardinality(const array_container_t *array) {
   83|  72.0k|    return array->cardinality;
   84|  72.0k|}
roaring.c:array_container_try_add:
  293|  7.34M|                                          int32_t max_cardinality) {
  294|  7.34M|    const int32_t cardinality = arr->cardinality;
  295|       |
  296|       |    // best case, we can append.
  297|  7.34M|    if ((array_container_empty(arr) || arr->array[cardinality - 1] < value) &&
  ------------------
  |  Branch (297:10): [True: 16.2k, False: 7.32M]
  |  Branch (297:40): [True: 51.6k, False: 7.27M]
  ------------------
  298|  67.9k|        cardinality < max_cardinality) {
  ------------------
  |  Branch (298:9): [True: 67.9k, False: 0]
  ------------------
  299|  67.9k|        array_container_append(arr, value);
  300|  67.9k|        return 1;
  301|  67.9k|    }
  302|       |
  303|  7.27M|    const int32_t loc = binarySearch(arr->array, cardinality, value);
  304|       |
  305|  7.27M|    if (loc >= 0) {
  ------------------
  |  Branch (305:9): [True: 5.56M, False: 1.71M]
  ------------------
  306|  5.56M|        return 0;
  307|  5.56M|    } else if (cardinality < max_cardinality) {
  ------------------
  |  Branch (307:16): [True: 1.71M, False: 148]
  ------------------
  308|  1.71M|        if (array_container_full(arr)) {
  ------------------
  |  Branch (308:13): [True: 77.3k, False: 1.63M]
  ------------------
  309|  77.3k|            array_container_grow(arr, arr->capacity + 1, true);
  310|  77.3k|        }
  311|  1.71M|        const int32_t insert_idx = -loc - 1;
  312|  1.71M|        memmove(arr->array + insert_idx + 1, arr->array + insert_idx,
  313|  1.71M|                (cardinality - insert_idx) * sizeof(uint16_t));
  314|  1.71M|        arr->array[insert_idx] = value;
  315|  1.71M|        arr->cardinality++;
  316|  1.71M|        return 1;
  317|  1.71M|    } else {
  318|    148|        return -1;
  319|    148|    }
  320|  7.27M|}
roaring.c:array_container_empty:
  100|  7.34M|static inline bool array_container_empty(const array_container_t *array) {
  101|  7.34M|    return array->cardinality == 0;
  102|  7.34M|}
roaring.c:array_container_append:
  274|  67.9k|                                          uint16_t pos) {
  275|  67.9k|    const int32_t capacity = arr->capacity;
  276|       |
  277|  67.9k|    if (array_container_full(arr)) {
  ------------------
  |  Branch (277:9): [True: 32.5k, False: 35.3k]
  ------------------
  278|  32.5k|        array_container_grow(arr, capacity + 1, true);
  279|  32.5k|    }
  280|       |
  281|  67.9k|    arr->array[arr->cardinality++] = pos;
  282|  67.9k|}
roaring.c:array_container_full:
  106|  1.78M|static inline bool array_container_full(const array_container_t *array) {
  107|  1.78M|    return array->cardinality == array->capacity;
  108|  1.78M|}
roaring.c:array_container_remove:
  329|  6.13k|                                          uint16_t pos) {
  330|  6.13k|    const int32_t idx = binarySearch(arr->array, arr->cardinality, pos);
  331|  6.13k|    const bool is_present = idx >= 0;
  332|  6.13k|    if (is_present) {
  ------------------
  |  Branch (332:9): [True: 3.08k, False: 3.05k]
  ------------------
  333|  3.08k|        memmove(arr->array + idx, arr->array + idx + 1,
  334|  3.08k|                (arr->cardinality - idx - 1) * sizeof(uint16_t));
  335|  3.08k|        arr->cardinality--;
  336|  3.08k|    }
  337|       |
  338|  6.13k|    return is_present;
  339|  6.13k|}
roaring.c:array_container_nonzero_cardinality:
   87|   105k|    const array_container_t *array) {
   88|   105k|    return array->cardinality > 0;
   89|   105k|}
roaring.c:array_container_equals:
  230|  9.56k|                                          const array_container_t *container2) {
  231|  9.56k|    if (container1->cardinality != container2->cardinality) {
  ------------------
  |  Branch (231:9): [True: 2.29k, False: 7.27k]
  ------------------
  232|  2.29k|        return false;
  233|  2.29k|    }
  234|  7.27k|    return memequals(container1->array, container2->array,
  235|  7.27k|                     container1->cardinality * 2);
  236|  9.56k|}
roaring.c:array_container_select:
  252|  3.82k|                                          uint32_t *element) {
  253|  3.82k|    int card = array_container_cardinality(container);
  254|  3.82k|    if (*start_rank + card <= rank) {
  ------------------
  |  Branch (254:9): [True: 323, False: 3.50k]
  ------------------
  255|    323|        *start_rank += card;
  256|    323|        return false;
  257|  3.50k|    } else {
  258|  3.50k|        *element = container->array[rank - *start_rank];
  259|       |        return true;
  260|  3.50k|    }
  261|  3.82k|}
roaring.c:array_container_contains_range:
  421|     94|                                                  uint32_t range_end) {
  422|     94|    const int32_t range_count = range_end - range_start;
  423|     94|    const uint16_t rs_included = (uint16_t)range_start;
  424|     94|    const uint16_t re_included = (uint16_t)(range_end - 1);
  425|       |
  426|       |    // Empty range is always included
  427|     94|    if (range_count <= 0) {
  ------------------
  |  Branch (427:9): [True: 0, False: 94]
  ------------------
  428|      0|        return true;
  429|      0|    }
  430|     94|    if (range_count > arr->cardinality) {
  ------------------
  |  Branch (430:9): [True: 34, False: 60]
  ------------------
  431|     34|        return false;
  432|     34|    }
  433|       |
  434|     60|    const int32_t start =
  435|     60|        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|     60|    return (start >= 0) && (arr->cardinality >= start + range_count) &&
  ------------------
  |  Branch (440:12): [True: 42, False: 18]
  |  Branch (440:28): [True: 35, False: 7]
  ------------------
  441|     35|           (arr->array[start + range_count - 1] == re_included);
  ------------------
  |  Branch (441:12): [True: 7, False: 28]
  ------------------
  442|     94|}
roaring_array.c:array_container_size_in_bytes:
  221|  18.0k|    const array_container_t *container) {
  222|  18.0k|    return container->cardinality * sizeof(uint16_t);
  223|  18.0k|}
roaring_array.c:array_container_cardinality:
   82|  7.12k|static inline int array_container_cardinality(const array_container_t *array) {
   83|  7.12k|    return array->cardinality;
   84|  7.12k|}
array.c:array_container_size_in_bytes:
  221|  14.2k|    const array_container_t *container) {
  222|  14.2k|    return container->cardinality * sizeof(uint16_t);
  223|  14.2k|}
convert.c:array_container_cardinality:
   82|  15.2k|static inline int array_container_cardinality(const array_container_t *array) {
   83|  15.2k|    return array->cardinality;
   84|  15.2k|}
convert.c:array_container_serialized_size_in_bytes:
  173|   151k|static inline int32_t array_container_serialized_size_in_bytes(int32_t card) {
  174|   151k|    return card * sizeof(uint16_t);
  175|   151k|}
mixed_intersection.c:array_container_empty:
  100|     25|static inline bool array_container_empty(const array_container_t *array) {
  101|     25|    return array->cardinality == 0;
  102|     25|}
mixed_andnot.c:array_container_cardinality:
   82|    376|static inline int array_container_cardinality(const array_container_t *array) {
   83|    376|    return array->cardinality;
   84|    376|}

bitset_container_get:
  193|  1.09M|                                 uint16_t pos) {
  194|  1.09M|    const uint64_t word = bitset->words[pos >> 6];
  195|  1.09M|    return (word >> (pos & 63)) & 1;
  196|  1.09M|}
bitset_container_contains:
  232|   966k|                                      uint16_t pos) {
  233|   966k|    return bitset_container_get(bitset, pos);
  234|   966k|}
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|    148|                                        uint16_t pos) {
  169|    148|    const uint64_t old_word = bitset->words[pos >> 6];
  170|    148|    const int index = pos & 63;
  171|       |    const uint64_t new_word = old_word | (UINT64_C(1) << index);
  172|    148|    const uint64_t increment = (old_word ^ new_word) >> index;
  173|    148|    bitset->cardinality += (uint32_t)increment;
  174|    148|    bitset->words[pos >> 6] = new_word;
  175|    148|    return increment > 0;
  176|    148|}
roaring.c:bitset_container_remove:
  181|  2.33k|                                           uint16_t pos) {
  182|  2.33k|    const uint64_t old_word = bitset->words[pos >> 6];
  183|  2.33k|    const int index = pos & 63;
  184|       |    const uint64_t new_word = old_word & (~(UINT64_C(1) << index));
  185|  2.33k|    const uint64_t increment = (old_word ^ new_word) >> index;
  186|  2.33k|    bitset->cardinality -= (uint32_t)increment;
  187|  2.33k|    bitset->words[pos >> 6] = new_word;
  188|  2.33k|    return increment > 0;
  189|  2.33k|}
roaring.c:bitset_container_const_nonzero_cardinality:
  281|  7.14k|    const bitset_container_t *bitset) {
  282|  7.14k|    return !bitset_container_empty(bitset);
  283|  7.14k|}
roaring.c:bitset_container_empty:
  268|  7.14k|static inline bool bitset_container_empty(const bitset_container_t *bitset) {
  269|  7.14k|    if (bitset->cardinality == BITSET_UNKNOWN_CARDINALITY) {
  ------------------
  |  Branch (269:9): [True: 0, False: 7.14k]
  ------------------
  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.14k|    return bitset->cardinality == 0;
  276|  7.14k|}
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: 64, False: 199]
  ------------------
  214|     64|        return ((bitset->words[end] & first & last) == (first & last));
  215|    199|    if ((bitset->words[start] & first) != first) return false;
  ------------------
  |  Branch (215:9): [True: 71, False: 128]
  ------------------
  216|       |
  217|    128|    if ((end < BITSET_CONTAINER_SIZE_IN_WORDS) &&
  ------------------
  |  Branch (217:9): [True: 117, False: 11]
  ------------------
  218|    117|        ((bitset->words[end] & last) != last)) {
  ------------------
  |  Branch (218:9): [True: 101, False: 16]
  ------------------
  219|    101|        return false;
  220|    101|    }
  221|       |
  222|     27|    for (uint32_t i = start + 1;
  223|  8.36k|         (i < BITSET_CONTAINER_SIZE_IN_WORDS) && (i < end); ++i) {
  ------------------
  |  Branch (223:10): [True: 8.35k, False: 8]
  |  Branch (223:50): [True: 8.34k, False: 12]
  ------------------
  224|  8.34k|        if (bitset->words[i] != UINT64_C(0xFFFFFFFFFFFFFFFF)) return false;
  ------------------
  |  Branch (224:13): [True: 7, False: 8.33k]
  ------------------
  225|  8.34k|    }
  226|       |
  227|     20|    return true;
  228|     27|}
roaring_array.c:bitset_container_size_in_bytes:
  468|   145k|    const bitset_container_t *container) {
  469|   145k|    (void)container;
  470|   145k|    return BITSET_CONTAINER_SIZE_IN_WORDS * sizeof(uint64_t);
  471|   145k|}
roaring_array.c:bitset_container_cardinality:
  248|  72.9k|    const bitset_container_t *bitset) {
  249|  72.9k|    return bitset->cardinality;
  250|  72.9k|}
bitset.c:bitset_container_size_in_bytes:
  468|   145k|    const bitset_container_t *container) {
  469|   145k|    (void)container;
  470|   145k|    return BITSET_CONTAINER_SIZE_IN_WORDS * sizeof(uint64_t);
  471|   145k|}
convert.c:bitset_container_set:
  147|  2.45M|                                        uint16_t pos) {
  148|  2.45M|    const uint64_t old_word = bitset->words[pos >> 6];
  149|  2.45M|    const int index = pos & 63;
  150|       |    const uint64_t new_word = old_word | (UINT64_C(1) << index);
  151|  2.45M|    bitset->cardinality += (uint32_t)((old_word ^ new_word) >> index);
  152|  2.45M|    bitset->words[pos >> 6] = new_word;
  153|  2.45M|}
convert.c:bitset_container_serialized_size_in_bytes:
  427|   139k|static inline int32_t bitset_container_serialized_size_in_bytes(void) {
  428|   139k|    return BITSET_CONTAINER_SIZE_IN_WORDS * 8;
  429|   139k|}

container_iterator_next:
 2456|   333k|                                    uint16_t *value) {
 2457|   333k|    switch (typecode) {
 2458|      0|        case BITSET_CONTAINER_TYPE: {
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2458:9): [True: 0, False: 333k]
  ------------------
 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|   291k|        case ARRAY_CONTAINER_TYPE: {
  ------------------
  |  |   49|   291k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2482:9): [True: 291k, False: 42.3k]
  ------------------
 2483|   291k|            const array_container_t *ac = const_CAST_array(c);
  ------------------
  |  |   55|   291k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|   291k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2484|   291k|            it->index++;
 2485|   291k|            if (it->index < ac->cardinality) {
  ------------------
  |  Branch (2485:17): [True: 285k, False: 5.72k]
  ------------------
 2486|   285k|                *value = ac->array[it->index];
 2487|   285k|                return true;
 2488|   285k|            }
 2489|  5.72k|            return false;
 2490|   291k|        }
 2491|  42.3k|        case RUN_CONTAINER_TYPE: {
  ------------------
  |  |   50|  42.3k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2491:9): [True: 42.3k, False: 291k]
  ------------------
 2492|  42.3k|            if (*value == UINT16_MAX) {  // Avoid overflow to zero
  ------------------
  |  Branch (2492:17): [True: 0, False: 42.3k]
  ------------------
 2493|      0|                return false;
 2494|      0|            }
 2495|       |
 2496|  42.3k|            const run_container_t *rc = const_CAST_run(c);
  ------------------
  |  |   78|  42.3k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  42.3k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2497|  42.3k|            uint32_t limit =
 2498|  42.3k|                rc->runs[it->index].value + rc->runs[it->index].length;
 2499|  42.3k|            if (*value < limit) {
  ------------------
  |  Branch (2499:17): [True: 26.9k, False: 15.4k]
  ------------------
 2500|  26.9k|                (*value)++;
 2501|  26.9k|                return true;
 2502|  26.9k|            }
 2503|       |
 2504|  15.4k|            it->index++;
 2505|  15.4k|            if (it->index < rc->n_runs) {
  ------------------
  |  Branch (2505:17): [True: 14.9k, False: 477]
  ------------------
 2506|  14.9k|                *value = rc->runs[it->index].value;
 2507|  14.9k|                return true;
 2508|  14.9k|            }
 2509|    477|            return false;
 2510|  15.4k|        }
 2511|      0|        default:
  ------------------
  |  Branch (2511:9): [True: 0, False: 333k]
  ------------------
 2512|      0|            assert(false);
 2513|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2514|      0|            return false;
 2515|   333k|    }
 2516|   333k|}
roaring.c:container_from_range:
  317|  72.3k|                                                uint32_t max, uint16_t step) {
  318|  72.3k|    if (step == 0) return NULL;  // being paranoid
  ------------------
  |  Branch (318:9): [True: 0, False: 72.3k]
  ------------------
  319|  72.3k|    if (step == 1) {
  ------------------
  |  Branch (319:9): [True: 72.3k, False: 0]
  ------------------
  320|  72.3k|        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|  72.3k|    }
  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|  89.2k|                                                   uint8_t *result_type) {
  303|  89.2k|    assert(range_end >= range_start);
  304|  89.2k|    uint64_t cardinality = range_end - range_start + 1;
  305|  89.2k|    if (cardinality <= 2) {
  ------------------
  |  Branch (305:9): [True: 124, False: 89.1k]
  ------------------
  306|    124|        *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    124|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  307|    124|        return array_container_create_range(range_start, range_end);
  308|  89.1k|    } else {
  309|  89.1k|        *result_type = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|  89.1k|#define RUN_CONTAINER_TYPE 3
  ------------------
  310|  89.1k|        return run_container_create_range(range_start, range_end);
  311|  89.1k|    }
  312|  89.2k|}
roaring.c:container_add_range:
 2282|  3.28k|                                               uint8_t *result_type) {
 2283|       |    // NB: when selecting new container type, we perform only inexpensive checks
 2284|  3.28k|    switch (type) {
 2285|      0|        case BITSET_CONTAINER_TYPE: {
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2285:9): [True: 0, False: 3.28k]
  ------------------
 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.80k|        case ARRAY_CONTAINER_TYPE: {
  ------------------
  |  |   49|  2.80k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2304:9): [True: 2.80k, False: 477]
  ------------------
 2305|  2.80k|            array_container_t *array = CAST_array(c);
  ------------------
  |  |   54|  2.80k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  2.80k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2306|       |
 2307|  2.80k|            int32_t nvals_greater =
 2308|  2.80k|                count_greater(array->array, array->cardinality, (uint16_t)max);
 2309|  2.80k|            int32_t nvals_less =
 2310|  2.80k|                count_less(array->array, array->cardinality - nvals_greater,
 2311|  2.80k|                           (uint16_t)min);
 2312|  2.80k|            int32_t union_cardinality =
 2313|  2.80k|                nvals_less + (max - min + 1) + nvals_greater;
 2314|       |
 2315|  2.80k|            if (union_cardinality == INT32_C(0x10000)) {
  ------------------
  |  Branch (2315:17): [True: 644, False: 2.16k]
  ------------------
 2316|    644|                *result_type = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|    644|#define RUN_CONTAINER_TYPE 3
  ------------------
 2317|    644|                return run_container_create_range(0, INT32_C(0x10000));
 2318|  2.16k|            } else if (union_cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (2318:24): [True: 639, False: 1.52k]
  ------------------
 2319|    639|                *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    639|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 2320|    639|                array_container_add_range_nvals(array, min, max, nvals_less,
 2321|    639|                                                nvals_greater);
 2322|    639|                return array;
 2323|  1.52k|            } else {
 2324|  1.52k|                *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|  1.52k|#define BITSET_CONTAINER_TYPE 1
  ------------------
 2325|  1.52k|                bitset_container_t *bitset = bitset_container_from_array(array);
 2326|  1.52k|                bitset_set_lenrange(bitset->words, min, max - min);
 2327|  1.52k|                bitset->cardinality = union_cardinality;
 2328|  1.52k|                return bitset;
 2329|  1.52k|            }
 2330|  2.80k|        }
 2331|    477|        case RUN_CONTAINER_TYPE: {
  ------------------
  |  |   50|    477|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2331:9): [True: 477, False: 2.80k]
  ------------------
 2332|    477|            run_container_t *run = CAST_run(c);
  ------------------
  |  |   77|    477|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    477|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2333|       |
 2334|    477|            int32_t nruns_greater =
 2335|    477|                rle16_count_greater(run->runs, run->n_runs, (uint16_t)max);
 2336|    477|            int32_t nruns_less = rle16_count_less(
 2337|    477|                run->runs, run->n_runs - nruns_greater, (uint16_t)min);
 2338|       |
 2339|    477|            int32_t run_size_bytes =
 2340|    477|                (nruns_less + 1 + nruns_greater) * sizeof(rle16_t);
 2341|    477|            int32_t bitset_size_bytes =
 2342|    477|                BITSET_CONTAINER_SIZE_IN_WORDS * sizeof(uint64_t);
 2343|       |
 2344|    477|            if (run_size_bytes <= bitset_size_bytes) {
  ------------------
  |  Branch (2344:17): [True: 477, False: 0]
  ------------------
 2345|    477|                run_container_add_range_nruns(run, min, max, nruns_less,
 2346|    477|                                              nruns_greater);
 2347|    477|                *result_type = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|    477|#define RUN_CONTAINER_TYPE 3
  ------------------
 2348|    477|                return run;
 2349|    477|            } else {
 2350|      0|                return container_from_run_range(run, min, max, result_type);
 2351|      0|            }
 2352|    477|        }
 2353|      0|        default:
  ------------------
  |  Branch (2353:9): [True: 0, False: 3.28k]
  ------------------
 2354|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2355|  3.28k|    }
 2356|  3.28k|}
roaring.c:container_remove_range:
 2371|  19.9k|                                                  uint8_t *result_type) {
 2372|  19.9k|    switch (type) {
 2373|  1.33k|        case BITSET_CONTAINER_TYPE: {
  ------------------
  |  |   48|  1.33k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2373:9): [True: 1.33k, False: 18.5k]
  ------------------
 2374|  1.33k|            bitset_container_t *bitset = CAST_bitset(c);
  ------------------
  |  |   52|  1.33k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.33k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2375|       |
 2376|  1.33k|            int32_t result_cardinality =
 2377|  1.33k|                bitset->cardinality -
 2378|  1.33k|                bitset_lenrange_cardinality(bitset->words, min, max - min);
 2379|       |
 2380|  1.33k|            if (result_cardinality == 0) {
  ------------------
  |  Branch (2380:17): [True: 37, False: 1.29k]
  ------------------
 2381|     37|                return NULL;
 2382|  1.29k|            } else if (result_cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (2382:24): [True: 90, False: 1.20k]
  ------------------
 2383|     90|                *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|     90|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 2384|     90|                bitset_reset_range(bitset->words, min, max + 1);
 2385|     90|                bitset->cardinality = result_cardinality;
 2386|     90|                return array_container_from_bitset(bitset);
 2387|  1.20k|            } else {
 2388|  1.20k|                *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|  1.20k|#define BITSET_CONTAINER_TYPE 1
  ------------------
 2389|  1.20k|                bitset_reset_range(bitset->words, min, max + 1);
 2390|  1.20k|                bitset->cardinality = result_cardinality;
 2391|  1.20k|                return bitset;
 2392|  1.20k|            }
 2393|  1.33k|        }
 2394|  3.54k|        case ARRAY_CONTAINER_TYPE: {
  ------------------
  |  |   49|  3.54k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2394:9): [True: 3.54k, False: 16.3k]
  ------------------
 2395|  3.54k|            array_container_t *array = CAST_array(c);
  ------------------
  |  |   54|  3.54k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  3.54k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2396|       |
 2397|  3.54k|            int32_t nvals_greater =
 2398|  3.54k|                count_greater(array->array, array->cardinality, (uint16_t)max);
 2399|  3.54k|            int32_t nvals_less =
 2400|  3.54k|                count_less(array->array, array->cardinality - nvals_greater,
 2401|  3.54k|                           (uint16_t)min);
 2402|  3.54k|            int32_t result_cardinality = nvals_less + nvals_greater;
 2403|       |
 2404|  3.54k|            if (result_cardinality == 0) {
  ------------------
  |  Branch (2404:17): [True: 346, False: 3.19k]
  ------------------
 2405|    346|                return NULL;
 2406|  3.19k|            } else {
 2407|  3.19k|                *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  3.19k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 2408|  3.19k|                array_container_remove_range(
 2409|  3.19k|                    array, nvals_less, array->cardinality - result_cardinality);
 2410|  3.19k|                return array;
 2411|  3.19k|            }
 2412|  3.54k|        }
 2413|  15.0k|        case RUN_CONTAINER_TYPE: {
  ------------------
  |  |   50|  15.0k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2413:9): [True: 15.0k, False: 4.87k]
  ------------------
 2414|  15.0k|            run_container_t *run = CAST_run(c);
  ------------------
  |  |   77|  15.0k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  15.0k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2415|       |
 2416|  15.0k|            if (run->n_runs == 0) {
  ------------------
  |  Branch (2416:17): [True: 0, False: 15.0k]
  ------------------
 2417|      0|                return NULL;
 2418|      0|            }
 2419|  15.0k|            if (min <= run_container_minimum(run) &&
  ------------------
  |  Branch (2419:17): [True: 14.6k, False: 416]
  ------------------
 2420|  14.6k|                max >= run_container_maximum(run)) {
  ------------------
  |  Branch (2420:17): [True: 13.1k, False: 1.43k]
  ------------------
 2421|  13.1k|                return NULL;
 2422|  13.1k|            }
 2423|       |
 2424|  1.85k|            run_container_remove_range(run, min, max);
 2425|  1.85k|            return convert_run_to_efficient_container(run, result_type);
 2426|  15.0k|        }
 2427|      0|        default:
  ------------------
  |  Branch (2427:9): [True: 0, False: 19.9k]
  ------------------
 2428|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2429|  19.9k|    }
 2430|  19.9k|}
roaring.c:container_get_cardinality:
  244|   396k|                                            uint8_t typecode) {
  245|   396k|    c = container_unwrap_shared(c, &typecode);
  246|   396k|    switch (typecode) {
  ------------------
  |  Branch (246:13): [True: 396k, False: 0]
  ------------------
  247|  9.96k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  9.96k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (247:9): [True: 9.96k, False: 386k]
  ------------------
  248|  9.96k|            return bitset_container_cardinality(const_CAST_bitset(c));
  ------------------
  |  |   53|  9.96k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  9.96k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  249|  64.3k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  64.3k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (249:9): [True: 64.3k, False: 331k]
  ------------------
  250|  64.3k|            return array_container_cardinality(const_CAST_array(c));
  ------------------
  |  |   55|  64.3k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  64.3k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  251|   321k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|   321k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (251:9): [True: 321k, False: 74.3k]
  ------------------
  252|   321k|            return run_container_cardinality(const_CAST_run(c));
  ------------------
  |  |   78|   321k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|   321k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  253|   396k|    }
  254|   396k|    assert(false);
  255|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  256|      0|    return 0;  // unreached
  257|   396k|}
roaring.c:get_container_type:
  129|  80.0k|static inline uint8_t get_container_type(const container_t *c, uint8_t type) {
  130|  80.0k|    if (type == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|  80.0k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (130:9): [True: 0, False: 80.0k]
  ------------------
  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|  80.0k|    } else {
  133|  80.0k|        return type;
  134|  80.0k|    }
  135|  80.0k|}
roaring.c:get_writable_copy_if_shared:
  146|  8.31M|                                                       uint8_t *type) {
  147|  8.31M|    if (*type == SHARED_CONTAINER_TYPE) {  // shared, return enclosed container
  ------------------
  |  |   51|  8.31M|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (147:9): [True: 0, False: 8.31M]
  ------------------
  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.31M|    } else {
  150|  8.31M|        return c;  // not shared, so return as-is
  151|  8.31M|    }
  152|  8.31M|}
roaring.c:container_add:
  492|  8.08M|    uint8_t *new_typecode) {
  493|  8.08M|    c = get_writable_copy_if_shared(c, &typecode);
  494|  8.08M|    switch (typecode) {
  495|   326k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|   326k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (495:9): [True: 326k, False: 7.75M]
  ------------------
  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.34M|        case ARRAY_CONTAINER_TYPE: {
  ------------------
  |  |   49|  7.34M|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (499:9): [True: 7.34M, False: 738k]
  ------------------
  500|  7.34M|            array_container_t *ac = CAST_array(c);
  ------------------
  |  |   54|  7.34M|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  7.34M|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  501|  7.34M|            if (array_container_try_add(ac, val, DEFAULT_MAX_SIZE) != -1) {
  ------------------
  |  Branch (501:17): [True: 7.34M, False: 148]
  ------------------
  502|  7.34M|                *new_typecode = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  7.34M|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  503|  7.34M|                return ac;
  504|  7.34M|            } else {
  505|    148|                bitset_container_t *bitset = bitset_container_from_array(ac);
  506|    148|                bitset_container_add(bitset, val);
  507|    148|                *new_typecode = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|    148|#define BITSET_CONTAINER_TYPE 1
  ------------------
  508|    148|                return bitset;
  509|    148|            }
  510|  7.34M|        } break;
  511|   411k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|   411k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (511:9): [True: 411k, False: 7.67M]
  ------------------
  512|       |            // per Java, no container type adjustments are done (revisit?)
  513|   411k|            run_container_add(CAST_run(c), val);
  ------------------
  |  |   77|   411k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|   411k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  514|   411k|            *new_typecode = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|   411k|#define RUN_CONTAINER_TYPE 3
  ------------------
  515|   411k|            return c;
  516|      0|        default:
  ------------------
  |  Branch (516:9): [True: 0, False: 8.08M]
  ------------------
  517|      0|            assert(false);
  518|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  519|      0|            return NULL;
  520|  8.08M|    }
  521|  8.08M|}
roaring.c:container_remove:
  533|  11.5k|    uint8_t *new_typecode) {
  534|  11.5k|    c = get_writable_copy_if_shared(c, &typecode);
  535|  11.5k|    switch (typecode) {
  536|  2.33k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  2.33k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (536:9): [True: 2.33k, False: 9.24k]
  ------------------
  537|  2.33k|            if (bitset_container_remove(CAST_bitset(c), val)) {
  ------------------
  |  |   52|  2.33k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  2.33k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (537:17): [True: 1.40k, False: 935]
  ------------------
  538|  1.40k|                int card = bitset_container_cardinality(CAST_bitset(c));
  ------------------
  |  |   52|  1.40k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.40k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  539|  1.40k|                if (card <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (539:21): [True: 16, False: 1.38k]
  ------------------
  540|     16|                    *new_typecode = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|     16|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  541|     16|                    return array_container_from_bitset(CAST_bitset(c));
  ------------------
  |  |   52|     16|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     16|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  542|     16|                }
  543|  1.40k|            }
  544|  2.32k|            *new_typecode = typecode;
  545|  2.32k|            return c;
  546|  6.13k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  6.13k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (546:9): [True: 6.13k, False: 5.44k]
  ------------------
  547|  6.13k|            *new_typecode = typecode;
  548|  6.13k|            array_container_remove(CAST_array(c), val);
  ------------------
  |  |   54|  6.13k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  6.13k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  549|  6.13k|            return c;
  550|  3.10k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  3.10k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (550:9): [True: 3.10k, False: 8.47k]
  ------------------
  551|       |            // per Java, no container type adjustments are done (revisit?)
  552|  3.10k|            run_container_remove(CAST_run(c), val);
  ------------------
  |  |   77|  3.10k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  3.10k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  553|  3.10k|            *new_typecode = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|  3.10k|#define RUN_CONTAINER_TYPE 3
  ------------------
  554|  3.10k|            return c;
  555|      0|        default:
  ------------------
  |  Branch (555:9): [True: 0, False: 11.5k]
  ------------------
  556|      0|            assert(false);
  557|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  558|      0|            return NULL;
  559|  11.5k|    }
  560|  11.5k|}
roaring.c:container_nonzero_cardinality:
  437|   178k|                                                 uint8_t typecode) {
  438|   178k|    c = container_unwrap_shared(c, &typecode);
  439|   178k|    switch (typecode) {
  ------------------
  |  Branch (439:13): [True: 178k, False: 0]
  ------------------
  440|  7.14k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  7.14k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (440:9): [True: 7.14k, False: 171k]
  ------------------
  441|  7.14k|            return bitset_container_const_nonzero_cardinality(
  442|  7.14k|                const_CAST_bitset(c));
  ------------------
  |  |   53|  7.14k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  7.14k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  443|   105k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|   105k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (443:9): [True: 105k, False: 73.5k]
  ------------------
  444|   105k|            return array_container_nonzero_cardinality(const_CAST_array(c));
  ------------------
  |  |   55|   105k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|   105k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  445|  66.3k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  66.3k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (445:9): [True: 66.3k, False: 112k]
  ------------------
  446|  66.3k|            return run_container_nonzero_cardinality(const_CAST_run(c));
  ------------------
  |  |   78|  66.3k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  66.3k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  447|   178k|    }
  448|   178k|    assert(false);
  449|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  450|      0|    return 0;  // unreached
  451|   178k|}
roaring.c:container_and:
  728|  6.33k|                                         uint8_t *result_type) {
  729|  6.33k|    c1 = container_unwrap_shared(c1, &type1);
  730|  6.33k|    c2 = container_unwrap_shared(c2, &type2);
  731|  6.33k|    container_t *result = NULL;
  732|  6.33k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  6.33k|#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.33k]
  ------------------
  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.01k]
  ------------------
  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|    694|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    694|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    694|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    694|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (748:9): [True: 694, False: 5.64k]
  ------------------
  749|    694|            result = run_container_create();
  750|    694|            run_container_intersection(const_CAST_run(c1), const_CAST_run(c2),
  ------------------
  |  |   78|    694|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    694|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          run_container_intersection(const_CAST_run(c1), const_CAST_run(c2),
  ------------------
  |  |   78|    694|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    694|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  751|    694|                                       CAST_run(result));
  ------------------
  |  |   77|    694|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    694|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  752|    694|            return convert_run_to_efficient_container_and_free(CAST_run(result),
  ------------------
  |  |   77|    694|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    694|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  753|    694|                                                               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.33k]
  ------------------
  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|    640|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|    640|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    640|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    640|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (763:9): [True: 640, False: 5.69k]
  ------------------
  764|    640|            result = array_container_create();
  765|    640|            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
  ------------------
  |  |   49|    640|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  766|    640|            array_bitset_container_intersection(const_CAST_array(c1),
  ------------------
  |  |   55|    640|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    640|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  767|    640|                                                const_CAST_bitset(c2),
  ------------------
  |  |   53|    640|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    640|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  768|    640|                                                CAST_array(result));
  ------------------
  |  |   54|    640|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    640|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  769|    640|            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.33k]
  ------------------
  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|    648|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|    648|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    648|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    648|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (779:9): [True: 648, False: 5.68k]
  ------------------
  780|    648|            *result_type =
  781|    648|                run_bitset_container_intersection(
  ------------------
  |  Branch (781:17): [True: 0, False: 648]
  ------------------
  782|    648|                    const_CAST_run(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   78|    648|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    648|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                  const_CAST_run(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|    648|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    648|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  783|    648|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  784|    648|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  1.29k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  785|    648|            return result;
  786|       |
  787|    785|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    785|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    785|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    785|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (787:9): [True: 785, False: 5.55k]
  ------------------
  788|    785|            result = array_container_create();
  789|    785|            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
  ------------------
  |  |   49|    785|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  790|    785|            array_run_container_intersection(
  791|    785|                const_CAST_array(c1), const_CAST_run(c2), CAST_array(result));
  ------------------
  |  |   55|    785|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    785|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_run(c2), CAST_array(result));
  ------------------
  |  |   78|    785|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    785|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_run(c2), CAST_array(result));
  ------------------
  |  |   54|    785|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    785|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  792|    785|            return result;
  793|       |
  794|  1.24k|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|  1.24k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  1.24k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  1.24k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (794:9): [True: 1.24k, False: 5.09k]
  ------------------
  795|  1.24k|            result = array_container_create();
  796|  1.24k|            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
  ------------------
  |  |   49|  1.24k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  797|  1.24k|            array_run_container_intersection(
  798|  1.24k|                const_CAST_array(c2), const_CAST_run(c1), CAST_array(result));
  ------------------
  |  |   55|  1.24k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.24k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c2), const_CAST_run(c1), CAST_array(result));
  ------------------
  |  |   78|  1.24k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.24k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c2), const_CAST_run(c1), CAST_array(result));
  ------------------
  |  |   54|  1.24k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.24k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  799|  1.24k|            return result;
  800|       |
  801|      0|        default:
  ------------------
  |  Branch (801:9): [True: 0, False: 6.33k]
  ------------------
  802|      0|            assert(false);
  803|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  804|      0|            return NULL;
  805|  6.33k|    }
  806|  6.33k|}
roaring.c:container_iand:
  923|  68.5k|                                          uint8_t *result_type) {
  924|  68.5k|    c1 = get_writable_copy_if_shared(c1, &type1);
  925|  68.5k|    c2 = container_unwrap_shared(c2, &type2);
  926|  68.5k|    container_t *result = NULL;
  927|  68.5k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  68.5k|#define PAIR_CONTAINER_TYPES(type1, type2) (4 * (type1) + (type2))
  ------------------
  928|  1.53k|        case CONTAINER_PAIR(BITSET, BITSET):
  ------------------
  |  |   65|  1.53k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  1.53k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  1.53k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (928:9): [True: 1.53k, False: 67.0k]
  ------------------
  929|  1.53k|            *result_type = bitset_bitset_container_intersection_inplace(
  ------------------
  |  Branch (929:28): [True: 1.53k, False: 0]
  ------------------
  930|  1.53k|                               CAST_bitset(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   52|  1.53k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.53k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_bitset(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|  1.53k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.53k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  931|  1.53k|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|  1.53k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  932|  1.53k|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  1.53k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  933|  1.53k|            return result;
  934|       |
  935|  4.84k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  4.84k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  4.84k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  4.84k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (935:9): [True: 4.84k, False: 63.6k]
  ------------------
  936|  4.84k|            array_container_intersection_inplace(CAST_array(c1),
  ------------------
  |  |   54|  4.84k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  4.84k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  937|  4.84k|                                                 const_CAST_array(c2));
  ------------------
  |  |   55|  4.84k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  4.84k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  938|  4.84k|            *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  4.84k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  939|  4.84k|            return c1;
  940|       |
  941|  60.8k|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|  60.8k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  60.8k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  60.8k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (941:9): [True: 60.8k, False: 7.63k]
  ------------------
  942|  60.8k|            result = run_container_create();
  943|  60.8k|            run_container_intersection(const_CAST_run(c1), const_CAST_run(c2),
  ------------------
  |  |   78|  60.8k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  60.8k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          run_container_intersection(const_CAST_run(c1), const_CAST_run(c2),
  ------------------
  |  |   78|  60.8k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  60.8k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  944|  60.8k|                                       CAST_run(result));
  ------------------
  |  |   77|  60.8k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  60.8k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  945|       |            // as of January 2016, Java code used non-in-place intersection for
  946|       |            // two runcontainers
  947|  60.8k|            return convert_run_to_efficient_container_and_free(CAST_run(result),
  ------------------
  |  |   77|  60.8k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  60.8k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  948|  60.8k|                                                               result_type);
  949|       |
  950|     42|        case CONTAINER_PAIR(BITSET, ARRAY):
  ------------------
  |  |   65|     42|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|     42|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|     42|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (950:9): [True: 42, False: 68.4k]
  ------------------
  951|       |            // c1 is a bitmap so no inplace possible
  952|     42|            result = array_container_create();
  953|     42|            array_bitset_container_intersection(const_CAST_array(c2),
  ------------------
  |  |   55|     42|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|     42|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  954|     42|                                                const_CAST_bitset(c1),
  ------------------
  |  |   53|     42|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|     42|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  955|     42|                                                CAST_array(result));
  ------------------
  |  |   54|     42|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     42|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  956|     42|            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
  ------------------
  |  |   49|     42|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  957|     42|            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: 68.5k]
  ------------------
  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: 68.5k]
  ------------------
  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: 68.5k]
  ------------------
  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: 68.3k]
  ------------------
  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.03k|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|  1.03k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  1.03k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  1.03k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (989:9): [True: 1.03k, False: 67.5k]
  ------------------
  990|  1.03k|            result = array_container_create();
  991|  1.03k|            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
  ------------------
  |  |   49|  1.03k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  992|  1.03k|            array_run_container_intersection(
  993|  1.03k|                const_CAST_array(c2), const_CAST_run(c1), CAST_array(result));
  ------------------
  |  |   55|  1.03k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.03k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c2), const_CAST_run(c1), CAST_array(result));
  ------------------
  |  |   78|  1.03k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.03k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c2), const_CAST_run(c1), CAST_array(result));
  ------------------
  |  |   54|  1.03k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.03k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  994|  1.03k|            return result;
  995|       |
  996|      0|        default:
  ------------------
  |  Branch (996:9): [True: 0, False: 68.5k]
  ------------------
  997|      0|            assert(false);
  998|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  999|      0|            return NULL;
 1000|  68.5k|    }
 1001|  68.5k|}
roaring.c:container_or:
 1010|  6.33k|                                        uint8_t *result_type) {
 1011|  6.33k|    c1 = container_unwrap_shared(c1, &type1);
 1012|  6.33k|    c2 = container_unwrap_shared(c2, &type2);
 1013|  6.33k|    container_t *result = NULL;
 1014|  6.33k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  6.33k|#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.33k]
  ------------------
 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.01k]
  ------------------
 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: 42, False: 2.28k]
  ------------------
 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|     42|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1027|  2.32k|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  4.60k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1028|  2.32k|            return result;
 1029|       |
 1030|    694|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    694|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    694|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    694|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1030:9): [True: 694, False: 5.64k]
  ------------------
 1031|    694|            result = run_container_create();
 1032|    694|            run_container_union(const_CAST_run(c1), const_CAST_run(c2),
  ------------------
  |  |   78|    694|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    694|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          run_container_union(const_CAST_run(c1), const_CAST_run(c2),
  ------------------
  |  |   78|    694|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    694|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1033|    694|                                CAST_run(result));
  ------------------
  |  |   77|    694|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    694|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1034|    694|            *result_type = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|    694|#define RUN_CONTAINER_TYPE 3
  ------------------
 1035|       |            // todo: could be optimized since will never convert to array
 1036|    694|            result = convert_run_to_efficient_container_and_free(
 1037|    694|                CAST_run(result), result_type);
  ------------------
  |  |   77|    694|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    694|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1038|    694|            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.33k]
  ------------------
 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|    640|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|    640|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    640|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    640|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1048:9): [True: 640, False: 5.69k]
  ------------------
 1049|    640|            result = bitset_container_create();
 1050|    640|            array_bitset_container_union(const_CAST_array(c1),
  ------------------
  |  |   55|    640|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    640|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1051|    640|                                         const_CAST_bitset(c2),
  ------------------
  |  |   53|    640|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    640|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1052|    640|                                         CAST_bitset(result));
  ------------------
  |  |   52|    640|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    640|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1053|    640|            *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|    640|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1054|    640|            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.33k]
  ------------------
 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|    648|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|    648|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    648|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    648|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1069:9): [True: 648, False: 5.68k]
  ------------------
 1070|    648|            if (run_container_is_full(const_CAST_run(c1))) {
  ------------------
  |  |   78|    648|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    648|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1070:17): [True: 0, False: 648]
  ------------------
 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|    648|            result = bitset_container_create();
 1077|    648|            run_bitset_container_union(
 1078|    648|                const_CAST_run(c1), const_CAST_bitset(c2), CAST_bitset(result));
  ------------------
  |  |   78|    648|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    648|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c1), const_CAST_bitset(c2), CAST_bitset(result));
  ------------------
  |  |   53|    648|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    648|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c1), const_CAST_bitset(c2), CAST_bitset(result));
  ------------------
  |  |   52|    648|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    648|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1079|    648|            *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|    648|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1080|    648|            return result;
 1081|       |
 1082|    785|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    785|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    785|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    785|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1082:9): [True: 785, False: 5.55k]
  ------------------
 1083|    785|            result = run_container_create();
 1084|    785|            array_run_container_union(const_CAST_array(c1), const_CAST_run(c2),
  ------------------
  |  |   55|    785|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    785|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          array_run_container_union(const_CAST_array(c1), const_CAST_run(c2),
  ------------------
  |  |   78|    785|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    785|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1085|    785|                                      CAST_run(result));
  ------------------
  |  |   77|    785|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    785|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1086|    785|            result = convert_run_to_efficient_container_and_free(
 1087|    785|                CAST_run(result), result_type);
  ------------------
  |  |   77|    785|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    785|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1088|    785|            return result;
 1089|       |
 1090|  1.24k|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|  1.24k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  1.24k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  1.24k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1090:9): [True: 1.24k, False: 5.09k]
  ------------------
 1091|  1.24k|            result = run_container_create();
 1092|  1.24k|            array_run_container_union(const_CAST_array(c2), const_CAST_run(c1),
  ------------------
  |  |   55|  1.24k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.24k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          array_run_container_union(const_CAST_array(c2), const_CAST_run(c1),
  ------------------
  |  |   78|  1.24k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.24k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1093|  1.24k|                                      CAST_run(result));
  ------------------
  |  |   77|  1.24k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.24k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1094|  1.24k|            result = convert_run_to_efficient_container_and_free(
 1095|  1.24k|                CAST_run(result), result_type);
  ------------------
  |  |   77|  1.24k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.24k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1096|  1.24k|            return result;
 1097|       |
 1098|      0|        default:
  ------------------
  |  Branch (1098:9): [True: 0, False: 6.33k]
  ------------------
 1099|      0|            assert(false);
 1100|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1101|      0|            return NULL;  // unreached
 1102|  6.33k|    }
 1103|  6.33k|}
roaring.c:container_is_full:
  262|  7.25k|static inline bool container_is_full(const container_t *c, uint8_t typecode) {
  263|  7.25k|    c = container_unwrap_shared(c, &typecode);
  264|  7.25k|    switch (typecode) {
  ------------------
  |  Branch (264:13): [True: 7.25k, False: 0]
  ------------------
  265|      0|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (265:9): [True: 0, False: 7.25k]
  ------------------
  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.82k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  3.82k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (268:9): [True: 3.82k, False: 3.43k]
  ------------------
  269|  3.82k|            return array_container_cardinality(const_CAST_array(c)) ==
  ------------------
  |  |   55|  3.82k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.82k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  270|  3.82k|                   (1 << 16);
  271|  3.43k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  3.43k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (271:9): [True: 3.43k, False: 3.82k]
  ------------------
  272|  3.43k|            return run_container_is_full(const_CAST_run(c));
  ------------------
  |  |   78|  3.43k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.43k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  273|  7.25k|    }
  274|  7.25k|    assert(false);
  275|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  276|      0|    return 0;  // unreached
  277|  7.25k|}
roaring.c:container_ior:
 1228|  6.44k|                                         uint8_t *result_type) {
 1229|  6.44k|    c1 = get_writable_copy_if_shared(c1, &type1);
 1230|  6.44k|    c2 = container_unwrap_shared(c2, &type2);
 1231|  6.44k|    container_t *result = NULL;
 1232|  6.44k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  6.44k|#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.44k]
  ------------------
 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.50k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  2.50k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.50k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.50k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1246:9): [True: 2.50k, False: 3.93k]
  ------------------
 1247|  2.50k|            *result_type = array_array_container_inplace_union(
  ------------------
  |  Branch (1247:28): [True: 0, False: 2.50k]
  ------------------
 1248|  2.50k|                               CAST_array(c1), const_CAST_array(c2), &result)
  ------------------
  |  |   54|  2.50k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  2.50k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_array(c1), const_CAST_array(c2), &result)
  ------------------
  |  |   55|  2.50k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.50k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1249|  2.50k|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1250|  2.50k|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  5.01k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1251|  2.50k|            if ((result == NULL) && (*result_type == ARRAY_CONTAINER_TYPE)) {
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (1251:17): [True: 0, False: 2.50k]
  |  Branch (1251:37): [True: 0, False: 0]
  ------------------
 1252|      0|                return c1;  // the computation was done in-place!
 1253|      0|            }
 1254|  2.50k|            return result;
 1255|       |
 1256|  1.71k|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|  1.71k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  1.71k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  1.71k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1256:9): [True: 1.71k, False: 4.72k]
  ------------------
 1257|  1.71k|            run_container_union_inplace(CAST_run(c1), const_CAST_run(c2));
  ------------------
  |  |   77|  1.71k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.71k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          run_container_union_inplace(CAST_run(c1), const_CAST_run(c2));
  ------------------
  |  |   78|  1.71k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.71k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1258|  1.71k|            return convert_run_to_efficient_container(CAST_run(c1),
  ------------------
  |  |   77|  1.71k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.71k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1259|  1.71k|                                                      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.44k]
  ------------------
 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|    682|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|    682|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    682|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    682|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1267:9): [True: 682, False: 5.75k]
  ------------------
 1268|       |            // c1 is an array, so no in-place possible
 1269|    682|            result = bitset_container_create();
 1270|    682|            *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|    682|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1271|    682|            array_bitset_container_union(const_CAST_array(c1),
  ------------------
  |  |   55|    682|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    682|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1272|    682|                                         const_CAST_bitset(c2),
  ------------------
  |  |   53|    682|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    682|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1273|    682|                                         CAST_bitset(result));
  ------------------
  |  |   52|    682|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    682|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1274|    682|            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.44k]
  ------------------
 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|    648|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|    648|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    648|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    648|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1289:9): [True: 648, False: 5.79k]
  ------------------
 1290|    648|            if (run_container_is_full(const_CAST_run(c1))) {
  ------------------
  |  |   78|    648|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    648|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1290:17): [True: 0, False: 648]
  ------------------
 1291|      0|                *result_type = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
 1292|      0|                return c1;
 1293|      0|            }
 1294|    648|            result = bitset_container_create();
 1295|    648|            run_bitset_container_union(
 1296|    648|                const_CAST_run(c1), const_CAST_bitset(c2), CAST_bitset(result));
  ------------------
  |  |   78|    648|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    648|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c1), const_CAST_bitset(c2), CAST_bitset(result));
  ------------------
  |  |   53|    648|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    648|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c1), const_CAST_bitset(c2), CAST_bitset(result));
  ------------------
  |  |   52|    648|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    648|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1297|    648|            *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|    648|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1298|    648|            return result;
 1299|       |
 1300|    635|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    635|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    635|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    635|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1300:9): [True: 635, False: 5.80k]
  ------------------
 1301|    635|            result = run_container_create();
 1302|    635|            array_run_container_union(const_CAST_array(c1), const_CAST_run(c2),
  ------------------
  |  |   55|    635|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    635|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          array_run_container_union(const_CAST_array(c1), const_CAST_run(c2),
  ------------------
  |  |   78|    635|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    635|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1303|    635|                                      CAST_run(result));
  ------------------
  |  |   77|    635|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    635|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1304|    635|            result = convert_run_to_efficient_container_and_free(
 1305|    635|                CAST_run(result), result_type);
  ------------------
  |  |   77|    635|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    635|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1306|    635|            return result;
 1307|       |
 1308|    256|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|    256|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    256|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    256|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1308:9): [True: 256, False: 6.18k]
  ------------------
 1309|    256|            array_run_container_inplace_union(const_CAST_array(c2),
  ------------------
  |  |   55|    256|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    256|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1310|    256|                                              CAST_run(c1));
  ------------------
  |  |   77|    256|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    256|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1311|    256|            c1 = convert_run_to_efficient_container(CAST_run(c1), result_type);
  ------------------
  |  |   77|    256|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    256|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1312|    256|            return c1;
 1313|       |
 1314|      0|        default:
  ------------------
  |  Branch (1314:9): [True: 0, False: 6.44k]
  ------------------
 1315|      0|            assert(false);
 1316|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1317|      0|            return NULL;
 1318|  6.44k|    }
 1319|  6.44k|}
roaring.c:container_xor:
 1451|  6.33k|                                         uint8_t *result_type) {
 1452|  6.33k|    c1 = container_unwrap_shared(c1, &type1);
 1453|  6.33k|    c2 = container_unwrap_shared(c2, &type2);
 1454|  6.33k|    container_t *result = NULL;
 1455|  6.33k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  6.33k|#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.33k]
  ------------------
 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.01k]
  ------------------
 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: 12, 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|     12|#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|    694|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    694|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    694|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    694|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1472:9): [True: 694, False: 5.64k]
  ------------------
 1473|    694|            *result_type = (uint8_t)run_run_container_xor(
 1474|    694|                const_CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|    694|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    694|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|    694|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    694|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1475|    694|            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.33k]
  ------------------
 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|    640|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|    640|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    640|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    640|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1485:9): [True: 640, False: 5.69k]
  ------------------
 1486|    640|            *result_type =
 1487|    640|                array_bitset_container_xor(const_CAST_array(c1),
  ------------------
  |  |   55|    640|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    640|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1487:17): [True: 586, False: 54]
  ------------------
 1488|    640|                                           const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|    640|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    640|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1489|    640|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|    586|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1490|    640|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    694|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1491|    640|            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.33k]
  ------------------
 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|    648|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|    648|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    648|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    648|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1501:9): [True: 648, False: 5.68k]
  ------------------
 1502|    648|            *result_type =
 1503|    648|                run_bitset_container_xor(const_CAST_run(c1),
  ------------------
  |  |   78|    648|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    648|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1503:17): [True: 607, False: 41]
  ------------------
 1504|    648|                                         const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|    648|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    648|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1505|    648|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|    607|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1506|    648|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    689|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1507|    648|            return result;
 1508|       |
 1509|    785|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    785|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    785|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    785|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1509:9): [True: 785, False: 5.55k]
  ------------------
 1510|    785|            *result_type = (uint8_t)array_run_container_xor(
 1511|    785|                const_CAST_array(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   55|    785|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    785|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|    785|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    785|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1512|    785|            return result;
 1513|       |
 1514|  1.24k|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|  1.24k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  1.24k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  1.24k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1514:9): [True: 1.24k, False: 5.09k]
  ------------------
 1515|  1.24k|            *result_type = (uint8_t)array_run_container_xor(
 1516|  1.24k|                const_CAST_array(c2), const_CAST_run(c1), &result);
  ------------------
  |  |   55|  1.24k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.24k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c2), const_CAST_run(c1), &result);
  ------------------
  |  |   78|  1.24k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.24k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1517|  1.24k|            return result;
 1518|       |
 1519|      0|        default:
  ------------------
  |  Branch (1519:9): [True: 0, False: 6.33k]
  ------------------
 1520|      0|            assert(false);
 1521|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1522|      0|            return NULL;  // unreached
 1523|  6.33k|    }
 1524|  6.33k|}
roaring.c:container_ixor:
 1667|  67.0k|                                          uint8_t *result_type) {
 1668|  67.0k|    c1 = get_writable_copy_if_shared(c1, &type1);
 1669|  67.0k|    c2 = container_unwrap_shared(c2, &type2);
 1670|  67.0k|    container_t *result = NULL;
 1671|  67.0k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  67.0k|#define PAIR_CONTAINER_TYPES(type1, type2) (4 * (type1) + (type2))
  ------------------
 1672|  1.56k|        case CONTAINER_PAIR(BITSET, BITSET):
  ------------------
  |  |   65|  1.56k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  1.56k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  1.56k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1672:9): [True: 1.56k, False: 65.4k]
  ------------------
 1673|  1.56k|            *result_type = bitset_bitset_container_ixor(
  ------------------
  |  Branch (1673:28): [True: 0, False: 1.56k]
  ------------------
 1674|  1.56k|                               CAST_bitset(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   52|  1.56k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.56k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_bitset(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|  1.56k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.56k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1675|  1.56k|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1676|  1.56k|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  3.12k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1677|  1.56k|            return result;
 1678|       |
 1679|  5.04k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  5.04k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  5.04k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  5.04k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1679:9): [True: 5.04k, False: 61.9k]
  ------------------
 1680|  5.04k|            *result_type = array_array_container_ixor(
  ------------------
  |  Branch (1680:28): [True: 0, False: 5.04k]
  ------------------
 1681|  5.04k|                               CAST_array(c1), const_CAST_array(c2), &result)
  ------------------
  |  |   54|  5.04k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  5.04k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_array(c1), const_CAST_array(c2), &result)
  ------------------
  |  |   55|  5.04k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  5.04k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1682|  5.04k|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1683|  5.04k|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  10.0k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1684|  5.04k|            return result;
 1685|       |
 1686|  59.8k|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|  59.8k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  59.8k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  59.8k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1686:9): [True: 59.8k, False: 7.13k]
  ------------------
 1687|  59.8k|            *result_type = (uint8_t)run_run_container_ixor(
 1688|  59.8k|                CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   77|  59.8k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  59.8k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|  59.8k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  59.8k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1689|  59.8k|            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.0k]
  ------------------
 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|    117|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|    117|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    117|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    117|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1698:9): [True: 117, False: 66.8k]
  ------------------
 1699|    117|            *result_type = array_bitset_container_ixor(
  ------------------
  |  Branch (1699:28): [True: 0, False: 117]
  ------------------
 1700|    117|                               CAST_array(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   54|    117|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    117|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_array(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|    117|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    117|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1701|    117|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1702|    117|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    234|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1703|    117|            return result;
 1704|       |
 1705|     69|        case CONTAINER_PAIR(BITSET, RUN):
  ------------------
  |  |   65|     69|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|     69|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|     69|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1705:9): [True: 69, False: 66.9k]
  ------------------
 1706|     69|            *result_type = bitset_run_container_ixor(
  ------------------
  |  Branch (1706:28): [True: 0, False: 69]
  ------------------
 1707|     69|                               CAST_bitset(c1), const_CAST_run(c2), &result)
  ------------------
  |  |   52|     69|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     69|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_bitset(c1), const_CAST_run(c2), &result)
  ------------------
  |  |   78|     69|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|     69|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1708|     69|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1709|     69|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    138|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1710|       |
 1711|     69|            return result;
 1712|       |
 1713|     14|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|     14|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|     14|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|     14|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1713:9): [True: 14, False: 67.0k]
  ------------------
 1714|     14|            *result_type = run_bitset_container_ixor(
  ------------------
  |  Branch (1714:28): [True: 0, False: 14]
  ------------------
 1715|     14|                               CAST_run(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   77|     14|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     14|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_run(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|     14|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|     14|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1716|     14|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1717|     14|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|     28|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1718|     14|            return result;
 1719|       |
 1720|    271|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    271|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    271|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    271|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1720:9): [True: 271, False: 66.7k]
  ------------------
 1721|    271|            *result_type = (uint8_t)array_run_container_ixor(
 1722|    271|                CAST_array(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   54|    271|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    271|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              CAST_array(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|    271|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    271|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1723|    271|            return result;
 1724|       |
 1725|     58|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|     58|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|     58|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|     58|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1725:9): [True: 58, False: 66.9k]
  ------------------
 1726|     58|            *result_type = (uint8_t)run_array_container_ixor(
 1727|     58|                CAST_run(c1), const_CAST_array(c2), &result);
  ------------------
  |  |   77|     58|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     58|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              CAST_run(c1), const_CAST_array(c2), &result);
  ------------------
  |  |   55|     58|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|     58|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1728|     58|            return result;
 1729|       |
 1730|      0|        default:
  ------------------
  |  Branch (1730:9): [True: 0, False: 67.0k]
  ------------------
 1731|      0|            assert(false);
 1732|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1733|      0|            return NULL;
 1734|  67.0k|    }
 1735|  67.0k|}
roaring.c:container_andnot:
 1787|  6.33k|                                            uint8_t *result_type) {
 1788|  6.33k|    c1 = container_unwrap_shared(c1, &type1);
 1789|  6.33k|    c2 = container_unwrap_shared(c2, &type2);
 1790|  6.33k|    container_t *result = NULL;
 1791|  6.33k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  6.33k|#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.33k]
  ------------------
 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.01k]
  ------------------
 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|    694|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    694|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    694|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    694|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1807:9): [True: 694, False: 5.64k]
  ------------------
 1808|    694|            if (run_container_is_full(const_CAST_run(c2))) {
  ------------------
  |  |   78|    694|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    694|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1808:17): [True: 16, False: 678]
  ------------------
 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|    678|            *result_type = (uint8_t)run_run_container_andnot(
 1814|    678|                const_CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|    678|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    678|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|    678|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    678|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1815|    678|            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.33k]
  ------------------
 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|    640|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|    640|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    640|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    640|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1825:9): [True: 640, False: 5.69k]
  ------------------
 1826|    640|            result = array_container_create();
 1827|    640|            array_bitset_container_andnot(const_CAST_array(c1),
  ------------------
  |  |   55|    640|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    640|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1828|    640|                                          const_CAST_bitset(c2),
  ------------------
  |  |   53|    640|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    640|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1829|    640|                                          CAST_array(result));
  ------------------
  |  |   54|    640|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    640|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1830|    640|            *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    640|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1831|    640|            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.33k]
  ------------------
 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|    648|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|    648|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    648|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    648|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1846:9): [True: 648, False: 5.68k]
  ------------------
 1847|    648|            *result_type =
 1848|    648|                run_bitset_container_andnot(const_CAST_run(c1),
  ------------------
  |  |   78|    648|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    648|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1848:17): [True: 0, False: 648]
  ------------------
 1849|    648|                                            const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|    648|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    648|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1850|    648|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1851|    648|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  1.29k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1852|    648|            return result;
 1853|       |
 1854|    785|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    785|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    785|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    785|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1854:9): [True: 785, False: 5.55k]
  ------------------
 1855|    785|            if (run_container_is_full(const_CAST_run(c2))) {
  ------------------
  |  |   78|    785|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    785|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1855:17): [True: 25, False: 760]
  ------------------
 1856|     25|                result = array_container_create();
 1857|     25|                *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|     25|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1858|     25|                return result;
 1859|     25|            }
 1860|    760|            result = array_container_create();
 1861|    760|            array_run_container_andnot(const_CAST_array(c1), const_CAST_run(c2),
  ------------------
  |  |   55|    760|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    760|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          array_run_container_andnot(const_CAST_array(c1), const_CAST_run(c2),
  ------------------
  |  |   78|    760|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    760|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1862|    760|                                       CAST_array(result));
  ------------------
  |  |   54|    760|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    760|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1863|    760|            *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    760|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1864|    760|            return result;
 1865|       |
 1866|  1.24k|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|  1.24k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  1.24k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  1.24k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1866:9): [True: 1.24k, False: 5.09k]
  ------------------
 1867|  1.24k|            *result_type = (uint8_t)run_array_container_andnot(
 1868|  1.24k|                const_CAST_run(c1), const_CAST_array(c2), &result);
  ------------------
  |  |   78|  1.24k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.24k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c1), const_CAST_array(c2), &result);
  ------------------
  |  |   55|  1.24k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.24k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1869|  1.24k|            return result;
 1870|       |
 1871|      0|        default:
  ------------------
  |  Branch (1871:9): [True: 0, False: 6.33k]
  ------------------
 1872|      0|            assert(false);
 1873|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1874|      0|            return NULL;  // unreached
 1875|  6.33k|    }
 1876|  6.33k|}
roaring.c:container_iandnot:
 1891|  6.01k|                                             uint8_t *result_type) {
 1892|  6.01k|    c1 = get_writable_copy_if_shared(c1, &type1);
 1893|  6.01k|    c2 = container_unwrap_shared(c2, &type2);
 1894|  6.01k|    container_t *result = NULL;
 1895|  6.01k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  6.01k|#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.01k]
  ------------------
 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.50k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  3.50k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  3.50k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  3.50k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1903:9): [True: 3.50k, False: 2.50k]
  ------------------
 1904|  3.50k|            array_array_container_iandnot(CAST_array(c1), const_CAST_array(c2));
  ------------------
  |  |   54|  3.50k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  3.50k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          array_array_container_iandnot(CAST_array(c1), const_CAST_array(c2));
  ------------------
  |  |   55|  3.50k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.50k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1905|  3.50k|            *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  3.50k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1906|  3.50k|            return c1;
 1907|       |
 1908|    453|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    453|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    453|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    453|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1908:9): [True: 453, False: 5.56k]
  ------------------
 1909|    453|            *result_type = (uint8_t)run_run_container_iandnot(
 1910|    453|                CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   77|    453|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    453|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|    453|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    453|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1911|    453|            return result;
 1912|       |
 1913|  1.25k|        case CONTAINER_PAIR(BITSET, ARRAY):
  ------------------
  |  |   65|  1.25k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  1.25k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  1.25k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1913:9): [True: 1.25k, False: 4.76k]
  ------------------
 1914|  1.25k|            *result_type = bitset_array_container_iandnot(
  ------------------
  |  Branch (1914:28): [True: 1.06k, False: 191]
  ------------------
 1915|  1.25k|                               CAST_bitset(c1), const_CAST_array(c2), &result)
  ------------------
  |  |   52|  1.25k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.25k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_bitset(c1), const_CAST_array(c2), &result)
  ------------------
  |  |   55|  1.25k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.25k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1916|  1.25k|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|  1.06k|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1917|  1.25k|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  1.44k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1918|  1.25k|            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.01k]
  ------------------
 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.01k]
  ------------------
 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.01k]
  ------------------
 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|     43|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|     43|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|     43|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|     43|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1940:9): [True: 43, False: 5.97k]
  ------------------
 1941|     43|            *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|     43|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1942|     43|            array_run_container_iandnot(CAST_array(c1), const_CAST_run(c2));
  ------------------
  |  |   54|     43|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     43|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          array_run_container_iandnot(CAST_array(c1), const_CAST_run(c2));
  ------------------
  |  |   78|     43|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|     43|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1943|     43|            return c1;
 1944|       |
 1945|    759|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|    759|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    759|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    759|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1945:9): [True: 759, False: 5.25k]
  ------------------
 1946|    759|            *result_type = (uint8_t)run_array_container_iandnot(
 1947|    759|                CAST_run(c1), const_CAST_array(c2), &result);
  ------------------
  |  |   77|    759|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    759|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              CAST_run(c1), const_CAST_array(c2), &result);
  ------------------
  |  |   55|    759|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    759|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1948|    759|            return result;
 1949|       |
 1950|      0|        default:
  ------------------
  |  Branch (1950:9): [True: 0, False: 6.01k]
  ------------------
 1951|      0|            assert(false);
 1952|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1953|      0|            return NULL;
 1954|  6.01k|    }
 1955|  6.01k|}
roaring.c:container_rank:
 2209|  6.44k|                                 uint16_t x) {
 2210|  6.44k|    c = container_unwrap_shared(c, &type);
 2211|  6.44k|    switch (type) {
 2212|      0|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2212:9): [True: 0, False: 6.44k]
  ------------------
 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.82k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  3.82k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2214:9): [True: 3.82k, False: 2.61k]
  ------------------
 2215|  3.82k|            return array_container_rank(const_CAST_array(c), x);
  ------------------
  |  |   55|  3.82k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.82k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2216|  2.61k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  2.61k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2216:9): [True: 2.61k, False: 3.82k]
  ------------------
 2217|  2.61k|            return run_container_rank(const_CAST_run(c), x);
  ------------------
  |  |   78|  2.61k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.61k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2218|      0|        default:
  ------------------
  |  Branch (2218:9): [True: 0, False: 6.44k]
  ------------------
 2219|      0|            assert(false);
 2220|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2221|  6.44k|    }
 2222|  6.44k|    assert(false);
 2223|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2224|      0|    return false;
 2225|  6.44k|}
roaring.c:container_shrink_to_fit:
  279|  6.44k|static inline int container_shrink_to_fit(container_t *c, uint8_t type) {
  280|  6.44k|    c = container_mutable_unwrap_shared(c, &type);
  281|  6.44k|    switch (type) {
  ------------------
  |  Branch (281:13): [True: 6.44k, False: 0]
  ------------------
  282|      0|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (282:9): [True: 0, False: 6.44k]
  ------------------
  283|      0|            return 0;  // no shrinking possible
  284|  3.82k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  3.82k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (284:9): [True: 3.82k, False: 2.61k]
  ------------------
  285|  3.82k|            return array_container_shrink_to_fit(CAST_array(c));
  ------------------
  |  |   54|  3.82k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  3.82k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  286|  2.61k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  2.61k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (286:9): [True: 2.61k, False: 3.82k]
  ------------------
  287|  2.61k|            return run_container_shrink_to_fit(CAST_run(c));
  ------------------
  |  |   77|  2.61k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  2.61k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  288|  6.44k|    }
  289|  6.44k|    assert(false);
  290|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  291|      0|    return 0;  // unreached
  292|  6.44k|}
roaring.c:container_iterate:
 1964|  68.6k|                                     void *ptr) {
 1965|  68.6k|    c = container_unwrap_shared(c, &type);
 1966|  68.6k|    switch (type) {
 1967|  1.69k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  1.69k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (1967:9): [True: 1.69k, False: 66.9k]
  ------------------
 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.49k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  6.49k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (1970:9): [True: 6.49k, False: 62.1k]
  ------------------
 1971|  6.49k|            return array_container_iterate(const_CAST_array(c), base, iterator,
  ------------------
  |  |   55|  6.49k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  6.49k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1972|  6.49k|                                           ptr);
 1973|  60.4k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  60.4k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (1973:9): [True: 60.4k, False: 8.18k]
  ------------------
 1974|  60.4k|            return run_container_iterate(const_CAST_run(c), base, iterator,
  ------------------
  |  |   78|  60.4k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  60.4k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1975|  60.4k|                                         ptr);
 1976|      0|        default:
  ------------------
  |  Branch (1976:9): [True: 0, False: 68.6k]
  ------------------
 1977|      0|            assert(false);
 1978|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1979|  68.6k|    }
 1980|  68.6k|    assert(false);
 1981|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1982|      0|    return false;
 1983|  68.6k|}
roaring.c:container_maximum:
 2171|  12.7k|static inline uint16_t container_maximum(const container_t *c, uint8_t type) {
 2172|  12.7k|    c = container_unwrap_shared(c, &type);
 2173|  12.7k|    switch (type) {
 2174|  2.51k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  2.51k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2174:9): [True: 2.51k, False: 10.2k]
  ------------------
 2175|  2.51k|            return bitset_container_maximum(const_CAST_bitset(c));
  ------------------
  |  |   53|  2.51k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.51k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2176|  8.80k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  8.80k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2176:9): [True: 8.80k, False: 3.94k]
  ------------------
 2177|  8.80k|            return array_container_maximum(const_CAST_array(c));
  ------------------
  |  |   55|  8.80k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  8.80k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2178|  1.43k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  1.43k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2178:9): [True: 1.43k, False: 11.3k]
  ------------------
 2179|  1.43k|            return run_container_maximum(const_CAST_run(c));
  ------------------
  |  |   78|  1.43k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.43k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2180|      0|        default:
  ------------------
  |  Branch (2180:9): [True: 0, False: 12.7k]
  ------------------
 2181|      0|            assert(false);
 2182|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2183|  12.7k|    }
 2184|  12.7k|    assert(false);
 2185|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2186|      0|    return false;
 2187|  12.7k|}
roaring.c:container_equals:
  620|  83.8k|                                    const container_t *c2, uint8_t type2) {
  621|  83.8k|    c1 = container_unwrap_shared(c1, &type1);
  622|  83.8k|    c2 = container_unwrap_shared(c2, &type2);
  623|  83.8k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  83.8k|#define PAIR_CONTAINER_TYPES(type1, type2) (4 * (type1) + (type2))
  ------------------
  624|  72.9k|        case CONTAINER_PAIR(BITSET, BITSET):
  ------------------
  |  |   65|  72.9k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  72.9k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  72.9k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (624:9): [True: 72.9k, False: 10.9k]
  ------------------
  625|  72.9k|            return bitset_container_equals(const_CAST_bitset(c1),
  ------------------
  |  |   53|  72.9k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  72.9k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  626|  72.9k|                                           const_CAST_bitset(c2));
  ------------------
  |  |   53|  72.9k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  72.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: 83.8k]
  ------------------
  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: 83.8k]
  ------------------
  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: 83.8k]
  ------------------
  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|    427|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|    427|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    427|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    427|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (641:9): [True: 427, False: 83.4k]
  ------------------
  642|       |            // java would always return false?
  643|    427|            return array_container_equal_bitset(const_CAST_array(c1),
  ------------------
  |  |   55|    427|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    427|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  644|    427|                                                const_CAST_bitset(c2));
  ------------------
  |  |   53|    427|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    427|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  645|       |
  646|    620|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    620|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    620|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    620|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (646:9): [True: 620, False: 83.2k]
  ------------------
  647|    620|            return run_container_equals_array(const_CAST_run(c2),
  ------------------
  |  |   78|    620|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    620|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  648|    620|                                              const_CAST_array(c1));
  ------------------
  |  |   55|    620|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    620|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  649|       |
  650|    251|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|    251|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    251|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    251|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (650:9): [True: 251, False: 83.6k]
  ------------------
  651|    251|            return run_container_equals_array(const_CAST_run(c1),
  ------------------
  |  |   78|    251|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    251|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  652|    251|                                              const_CAST_array(c2));
  ------------------
  |  |   55|    251|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    251|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  653|       |
  654|  9.56k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  9.56k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  9.56k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  9.56k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (654:9): [True: 9.56k, False: 74.3k]
  ------------------
  655|  9.56k|            return array_container_equals(const_CAST_array(c1),
  ------------------
  |  |   55|  9.56k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  9.56k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  656|  9.56k|                                          const_CAST_array(c2));
  ------------------
  |  |   55|  9.56k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  9.56k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  657|       |
  658|    127|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    127|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    127|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    127|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (658:9): [True: 127, False: 83.7k]
  ------------------
  659|    127|            return run_container_equals(const_CAST_run(c1), const_CAST_run(c2));
  ------------------
  |  |   78|    127|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    127|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          return run_container_equals(const_CAST_run(c1), const_CAST_run(c2));
  ------------------
  |  |   78|    127|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    127|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  660|       |
  661|      0|        default:
  ------------------
  |  Branch (661:9): [True: 0, False: 83.8k]
  ------------------
  662|      0|            assert(false);
  663|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  664|      0|            return false;
  665|  83.8k|    }
  666|  83.8k|}
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.48k|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|  2.48k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.48k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  2.48k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (692:9): [True: 2.48k, False: 8.62k]
  ------------------
  693|  2.48k|            return array_container_is_subset_bitset(const_CAST_array(c1),
  ------------------
  |  |   55|  2.48k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.48k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  694|  2.48k|                                                    const_CAST_bitset(c2));
  ------------------
  |  |   53|  2.48k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.48k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  695|       |
  696|  2.26k|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|  2.26k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.26k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  2.26k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (696:9): [True: 2.26k, False: 8.84k]
  ------------------
  697|  2.26k|            return array_container_is_subset_run(const_CAST_array(c1),
  ------------------
  |  |   55|  2.26k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.26k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  698|  2.26k|                                                 const_CAST_run(c2));
  ------------------
  |  |   78|  2.26k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.26k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  699|       |
  700|    373|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|    373|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    373|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    373|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (700:9): [True: 373, False: 10.7k]
  ------------------
  701|    373|            return run_container_is_subset_array(const_CAST_run(c1),
  ------------------
  |  |   78|    373|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    373|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  702|    373|                                                 const_CAST_array(c2));
  ------------------
  |  |   55|    373|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    373|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  703|       |
  704|  5.72k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  5.72k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  5.72k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  5.72k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (704:9): [True: 5.72k, False: 5.38k]
  ------------------
  705|  5.72k|            return array_container_is_subset(const_CAST_array(c1),
  ------------------
  |  |   55|  5.72k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  5.72k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  706|  5.72k|                                             const_CAST_array(c2));
  ------------------
  |  |   55|  5.72k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  5.72k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  707|       |
  708|    259|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    259|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    259|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    259|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (708:9): [True: 259, False: 10.8k]
  ------------------
  709|    259|            return run_container_is_subset(const_CAST_run(c1),
  ------------------
  |  |   78|    259|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    259|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  710|    259|                                           const_CAST_run(c2));
  ------------------
  |  |   78|    259|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    259|#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.57k|                                                uint8_t *result_type) {
 2111|  6.57k|    c = get_writable_copy_if_shared(c, &type);
 2112|  6.57k|    container_t *result = NULL;
 2113|  6.57k|    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.22k]
  ------------------
 2115|  1.35k|            *result_type = bitset_container_negation_range_inplace(
  ------------------
  |  Branch (2115:28): [True: 1.33k, False: 24]
  ------------------
 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.38k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 2119|  1.35k|            return result;
 2120|  3.53k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  3.53k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2120:9): [True: 3.53k, False: 3.04k]
  ------------------
 2121|  3.53k|            *result_type = array_container_negation_range_inplace(
  ------------------
  |  Branch (2121:28): [True: 141, False: 3.39k]
  ------------------
 2122|  3.53k|                               CAST_array(c), range_start, range_end, &result)
  ------------------
  |  |   54|  3.53k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  3.53k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2123|  3.53k|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|    141|#define BITSET_CONTAINER_TYPE 1
  ------------------
 2124|  3.53k|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  6.93k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 2125|  3.53k|            return result;
 2126|  1.68k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  1.68k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2126:9): [True: 1.68k, False: 4.89k]
  ------------------
 2127|  1.68k|            *result_type = (uint8_t)run_container_negation_range_inplace(
 2128|  1.68k|                CAST_run(c), range_start, range_end, &result);
  ------------------
  |  |   77|  1.68k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.68k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2129|  1.68k|            return result;
 2130|       |
 2131|      0|        default:
  ------------------
  |  Branch (2131:9): [True: 0, False: 6.57k]
  ------------------
 2132|      0|            assert(false);
 2133|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2134|  6.57k|    }
 2135|  6.57k|    assert(false);
 2136|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2137|      0|    return NULL;
 2138|  6.57k|}
roaring.c:container_inot:
 2076|  5.84k|                                          uint8_t *result_type) {
 2077|  5.84k|    c = get_writable_copy_if_shared(c, &type);
 2078|  5.84k|    container_t *result = NULL;
 2079|  5.84k|    switch (type) {
 2080|     76|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|     76|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2080:9): [True: 76, False: 5.77k]
  ------------------
 2081|     76|            *result_type =
 2082|     76|                bitset_container_negation_inplace(CAST_bitset(c), &result)
  ------------------
  |  |   52|     76|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     76|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (2082:17): [True: 30, False: 46]
  ------------------
 2083|     76|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|     30|#define BITSET_CONTAINER_TYPE 1
  ------------------
 2084|     76|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    122|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 2085|     76|            return result;
 2086|    150|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|    150|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2086:9): [True: 150, False: 5.69k]
  ------------------
 2087|       |            // will never be inplace
 2088|    150|            result = bitset_container_create();
 2089|    150|            *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|    150|#define BITSET_CONTAINER_TYPE 1
  ------------------
 2090|    150|            array_container_negation(CAST_array(c), CAST_bitset(result));
  ------------------
  |  |   54|    150|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    150|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          array_container_negation(CAST_array(c), CAST_bitset(result));
  ------------------
  |  |   52|    150|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    150|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2091|    150|            array_container_free(CAST_array(c));
  ------------------
  |  |   54|    150|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    150|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2092|    150|            return result;
 2093|  5.62k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  5.62k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2093:9): [True: 5.62k, False: 226]
  ------------------
 2094|  5.62k|            *result_type =
 2095|  5.62k|                (uint8_t)run_container_negation_inplace(CAST_run(c), &result);
  ------------------
  |  |   77|  5.62k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  5.62k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2096|  5.62k|            return result;
 2097|       |
 2098|      0|        default:
  ------------------
  |  Branch (2098:9): [True: 0, False: 5.84k]
  ------------------
 2099|      0|            assert(false);
 2100|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2101|  5.84k|    }
 2102|  5.84k|    assert(false);
 2103|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2104|      0|    return NULL;
 2105|  5.84k|}
roaring.c:container_unwrap_shared:
  106|  1.15M|    const container_t *candidate_shared_container, uint8_t *type) {
  107|  1.15M|    if (*type == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|  1.15M|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (107:9): [True: 0, False: 1.15M]
  ------------------
  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.15M|    } else {
  112|  1.15M|        return candidate_shared_container;
  113|  1.15M|    }
  114|  1.15M|}
roaring.c:container_mutable_unwrap_shared:
  118|  6.44k|                                                           uint8_t *type) {
  119|  6.44k|    if (*type == SHARED_CONTAINER_TYPE) {  // the passed in container is shared
  ------------------
  |  |   51|  6.44k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (119:9): [True: 0, False: 6.44k]
  ------------------
  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.44k|    } else {
  124|  6.44k|        return c;  // wasn't shared, so return as-is
  125|  6.44k|    }
  126|  6.44k|}
roaring.c:container_minimum:
 2189|  6.39k|static inline uint16_t container_minimum(const container_t *c, uint8_t type) {
 2190|  6.39k|    c = container_unwrap_shared(c, &type);
 2191|  6.39k|    switch (type) {
 2192|  1.29k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  1.29k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2192:9): [True: 1.29k, False: 5.10k]
  ------------------
 2193|  1.29k|            return bitset_container_minimum(const_CAST_bitset(c));
  ------------------
  |  |   53|  1.29k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.29k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2194|  3.61k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  3.61k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2194:9): [True: 3.61k, False: 2.78k]
  ------------------
 2195|  3.61k|            return array_container_minimum(const_CAST_array(c));
  ------------------
  |  |   55|  3.61k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.61k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2196|  1.49k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  1.49k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2196:9): [True: 1.49k, False: 4.90k]
  ------------------
 2197|  1.49k|            return run_container_minimum(const_CAST_run(c));
  ------------------
  |  |   78|  1.49k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.49k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2198|      0|        default:
  ------------------
  |  Branch (2198:9): [True: 0, False: 6.39k]
  ------------------
 2199|      0|            assert(false);
 2200|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2201|  6.39k|    }
 2202|  6.39k|    assert(false);
 2203|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2204|      0|    return false;
 2205|  6.39k|}
roaring.c:container_select:
 2150|  6.44k|                                    uint32_t *element) {
 2151|  6.44k|    c = container_unwrap_shared(c, &type);
 2152|  6.44k|    switch (type) {
 2153|      0|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2153:9): [True: 0, False: 6.44k]
  ------------------
 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.82k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  3.82k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2156:9): [True: 3.82k, False: 2.61k]
  ------------------
 2157|  3.82k|            return array_container_select(const_CAST_array(c), start_rank, rank,
  ------------------
  |  |   55|  3.82k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.82k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2158|  3.82k|                                          element);
 2159|  2.61k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  2.61k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2159:9): [True: 2.61k, False: 3.82k]
  ------------------
 2160|  2.61k|            return run_container_select(const_CAST_run(c), start_rank, rank,
  ------------------
  |  |   78|  2.61k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.61k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2161|  2.61k|                                        element);
 2162|      0|        default:
  ------------------
  |  Branch (2162:9): [True: 0, False: 6.44k]
  ------------------
 2163|      0|            assert(false);
 2164|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2165|  6.44k|    }
 2166|  6.44k|    assert(false);
 2167|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2168|      0|    return false;
 2169|  6.44k|}
roaring.c:container_intersect:
  865|  6.33k|                                       const container_t *c2, uint8_t type2) {
  866|  6.33k|    c1 = container_unwrap_shared(c1, &type1);
  867|  6.33k|    c2 = container_unwrap_shared(c2, &type2);
  868|  6.33k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  6.33k|#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.33k]
  ------------------
  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.01k]
  ------------------
  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|    694|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    694|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    694|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    694|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (877:9): [True: 694, False: 5.64k]
  ------------------
  878|    694|            return run_container_intersect(const_CAST_run(c1),
  ------------------
  |  |   78|    694|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    694|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  879|    694|                                           const_CAST_run(c2));
  ------------------
  |  |   78|    694|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    694|#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.33k]
  ------------------
  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|    640|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|    640|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    640|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    640|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (885:9): [True: 640, False: 5.69k]
  ------------------
  886|    640|            return array_bitset_container_intersect(const_CAST_array(c1),
  ------------------
  |  |   55|    640|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    640|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  887|    640|                                                    const_CAST_bitset(c2));
  ------------------
  |  |   53|    640|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    640|#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.33k]
  ------------------
  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|    648|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|    648|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    648|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    648|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (893:9): [True: 648, False: 5.68k]
  ------------------
  894|    648|            return run_bitset_container_intersect(const_CAST_run(c1),
  ------------------
  |  |   78|    648|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    648|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  895|    648|                                                  const_CAST_bitset(c2));
  ------------------
  |  |   53|    648|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    648|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  896|       |
  897|    785|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    785|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    785|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    785|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (897:9): [True: 785, False: 5.55k]
  ------------------
  898|    785|            return array_run_container_intersect(const_CAST_array(c1),
  ------------------
  |  |   55|    785|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    785|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  899|    785|                                                 const_CAST_run(c2));
  ------------------
  |  |   78|    785|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    785|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  900|       |
  901|  1.24k|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|  1.24k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  1.24k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  1.24k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (901:9): [True: 1.24k, False: 5.09k]
  ------------------
  902|  1.24k|            return array_run_container_intersect(const_CAST_array(c2),
  ------------------
  |  |   55|  1.24k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.24k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  903|  1.24k|                                                 const_CAST_run(c1));
  ------------------
  |  |   78|  1.24k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.24k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  904|       |
  905|      0|        default:
  ------------------
  |  Branch (905:9): [True: 0, False: 6.33k]
  ------------------
  906|      0|            assert(false);
  907|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  908|      0|            return 0;
  909|  6.33k|    }
  910|  6.33k|}
roaring.c:container_and_cardinality:
  814|  25.3k|                                            uint8_t type2) {
  815|  25.3k|    c1 = container_unwrap_shared(c1, &type1);
  816|  25.3k|    c2 = container_unwrap_shared(c2, &type2);
  817|  25.3k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  25.3k|#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.3k]
  ------------------
  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.0k]
  ------------------
  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.77k|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|  2.77k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  2.77k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  2.77k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (826:9): [True: 2.77k, False: 22.5k]
  ------------------
  827|  2.77k|            return run_container_intersection_cardinality(const_CAST_run(c1),
  ------------------
  |  |   78|  2.77k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.77k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  828|  2.77k|                                                          const_CAST_run(c2));
  ------------------
  |  |   78|  2.77k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.77k|#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.3k]
  ------------------
  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.56k|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|  2.56k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.56k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  2.56k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (834:9): [True: 2.56k, False: 22.7k]
  ------------------
  835|  2.56k|            return array_bitset_container_intersection_cardinality(
  836|  2.56k|                const_CAST_array(c1), const_CAST_bitset(c2));
  ------------------
  |  |   55|  2.56k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.56k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_bitset(c2));
  ------------------
  |  |   53|  2.56k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.56k|#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.3k]
  ------------------
  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.59k|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|  2.59k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  2.59k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  2.59k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (842:9): [True: 2.59k, False: 22.7k]
  ------------------
  843|  2.59k|            return run_bitset_container_intersection_cardinality(
  844|  2.59k|                const_CAST_run(c1), const_CAST_bitset(c2));
  ------------------
  |  |   78|  2.59k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.59k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c1), const_CAST_bitset(c2));
  ------------------
  |  |   53|  2.59k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.59k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  845|       |
  846|  3.14k|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|  3.14k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  3.14k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  3.14k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (846:9): [True: 3.14k, False: 22.2k]
  ------------------
  847|  3.14k|            return array_run_container_intersection_cardinality(
  848|  3.14k|                const_CAST_array(c1), const_CAST_run(c2));
  ------------------
  |  |   55|  3.14k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.14k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_run(c2));
  ------------------
  |  |   78|  3.14k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.14k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  849|       |
  850|  4.98k|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|  4.98k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  4.98k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  4.98k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (850:9): [True: 4.98k, False: 20.3k]
  ------------------
  851|  4.98k|            return array_run_container_intersection_cardinality(
  852|  4.98k|                const_CAST_array(c2), const_CAST_run(c1));
  ------------------
  |  |   55|  4.98k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  4.98k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c2), const_CAST_run(c1));
  ------------------
  |  |   78|  4.98k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  4.98k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  853|       |
  854|      0|        default:
  ------------------
  |  Branch (854:9): [True: 0, False: 25.3k]
  ------------------
  855|      0|            assert(false);
  856|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  857|      0|            return 0;
  858|  25.3k|    }
  859|  25.3k|}
roaring.c:container_contains_range:
  596|    554|) {
  597|    554|    c = container_unwrap_shared(c, &typecode);
  598|    554|    switch (typecode) {
  599|    263|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|    263|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (599:9): [True: 263, False: 291]
  ------------------
  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|     94|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|     94|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (602:9): [True: 94, False: 460]
  ------------------
  603|     94|            return array_container_contains_range(const_CAST_array(c),
  ------------------
  |  |   55|     94|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|     94|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  604|     94|                                                  range_start, range_end);
  605|    197|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|    197|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (605:9): [True: 197, False: 357]
  ------------------
  606|    197|            return run_container_contains_range(const_CAST_run(c), range_start,
  ------------------
  |  |   78|    197|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    197|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  607|    197|                                                range_end);
  608|      0|        default:
  ------------------
  |  Branch (608:9): [True: 0, False: 554]
  ------------------
  609|      0|            assert(false);
  610|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  611|      0|            return false;
  612|    554|    }
  613|    554|}
roaring_array.c:container_to_uint32_array:
  465|  68.5k|                                            uint8_t typecode, uint32_t base) {
  466|  68.5k|    c = container_unwrap_shared(c, &typecode);
  467|  68.5k|    switch (typecode) {
  ------------------
  |  Branch (467:13): [True: 68.5k, False: 0]
  ------------------
  468|  1.53k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  1.53k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (468:9): [True: 1.53k, False: 67.0k]
  ------------------
  469|  1.53k|            return bitset_container_to_uint32_array(output,
  470|  1.53k|                                                    const_CAST_bitset(c), base);
  ------------------
  |  |   53|  1.53k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.53k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  471|  5.91k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  5.91k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (471:9): [True: 5.91k, False: 62.6k]
  ------------------
  472|  5.91k|            return array_container_to_uint32_array(output, const_CAST_array(c),
  ------------------
  |  |   55|  5.91k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  5.91k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  473|  5.91k|                                                   base);
  474|  61.0k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  61.0k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (474:9): [True: 61.0k, False: 7.44k]
  ------------------
  475|  61.0k|            return run_container_to_uint32_array(output, const_CAST_run(c),
  ------------------
  |  |   78|  61.0k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  61.0k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  476|  61.0k|                                                 base);
  477|  68.5k|    }
  478|  68.5k|    assert(false);
  479|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  480|      0|    return 0;  // unreached
  481|  68.5k|}
roaring_array.c:container_unwrap_shared:
  106|   395k|    const container_t *candidate_shared_container, uint8_t *type) {
  107|   395k|    if (*type == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|   395k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (107:9): [True: 0, False: 395k]
  ------------------
  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|   395k|    } else {
  112|   395k|        return candidate_shared_container;
  113|   395k|    }
  114|   395k|}
roaring_array.c:get_container_type:
  129|   166k|static inline uint8_t get_container_type(const container_t *c, uint8_t type) {
  130|   166k|    if (type == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|   166k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (130:9): [True: 0, False: 166k]
  ------------------
  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|   166k|    } else {
  133|   166k|        return type;
  134|   166k|    }
  135|   166k|}
roaring_array.c:container_size_in_bytes:
  403|   166k|                                              uint8_t typecode) {
  404|   166k|    c = container_unwrap_shared(c, &typecode);
  405|   166k|    switch (typecode) {
  ------------------
  |  Branch (405:13): [True: 166k, False: 0]
  ------------------
  406|   145k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|   145k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (406:9): [True: 145k, False: 20.6k]
  ------------------
  407|   145k|            return bitset_container_size_in_bytes(const_CAST_bitset(c));
  ------------------
  |  |   53|   145k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|   145k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  408|  18.0k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  18.0k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (408:9): [True: 18.0k, False: 148k]
  ------------------
  409|  18.0k|            return array_container_size_in_bytes(const_CAST_array(c));
  ------------------
  |  |   55|  18.0k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  18.0k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  410|  2.61k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  2.61k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (410:9): [True: 2.61k, False: 163k]
  ------------------
  411|  2.61k|            return run_container_size_in_bytes(const_CAST_run(c));
  ------------------
  |  |   78|  2.61k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.61k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  412|   166k|    }
  413|   166k|    assert(false);
  414|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  415|      0|    return 0;  // unreached
  416|   166k|}
roaring_array.c:container_get_cardinality:
  244|  80.0k|                                            uint8_t typecode) {
  245|  80.0k|    c = container_unwrap_shared(c, &typecode);
  246|  80.0k|    switch (typecode) {
  ------------------
  |  Branch (246:13): [True: 80.0k, False: 0]
  ------------------
  247|  72.9k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  72.9k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (247:9): [True: 72.9k, False: 7.12k]
  ------------------
  248|  72.9k|            return bitset_container_cardinality(const_CAST_bitset(c));
  ------------------
  |  |   53|  72.9k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  72.9k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  249|  7.12k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  7.12k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (249:9): [True: 7.12k, False: 72.9k]
  ------------------
  250|  7.12k|            return array_container_cardinality(const_CAST_array(c));
  ------------------
  |  |   55|  7.12k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  7.12k|#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: 80.0k]
  ------------------
  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|  80.0k|    }
  254|  80.0k|    assert(false);
  255|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  256|      0|    return 0;  // unreached
  257|  80.0k|}
roaring_array.c:container_write:
  382|  80.0k|                                      char *buf) {
  383|  80.0k|    c = container_unwrap_shared(c, &typecode);
  384|  80.0k|    switch (typecode) {
  ------------------
  |  Branch (384:13): [True: 80.0k, False: 0]
  ------------------
  385|  72.9k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  72.9k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (385:9): [True: 72.9k, False: 7.12k]
  ------------------
  386|  72.9k|            return bitset_container_write(const_CAST_bitset(c), buf);
  ------------------
  |  |   53|  72.9k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  72.9k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  387|  7.12k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  7.12k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (387:9): [True: 7.12k, False: 72.9k]
  ------------------
  388|  7.12k|            return array_container_write(const_CAST_array(c), buf);
  ------------------
  |  |   55|  7.12k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  7.12k|#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: 80.0k]
  ------------------
  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|  80.0k|    }
  392|  80.0k|    assert(false);
  393|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  394|      0|    return 0;  // unreached
  395|  80.0k|}
containers.c:container_unwrap_shared:
  106|  6.56k|    const container_t *candidate_shared_container, uint8_t *type) {
  107|  6.56k|    if (*type == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|  6.56k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (107:9): [True: 0, False: 6.56k]
  ------------------
  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.56k|    } else {
  112|  6.56k|        return candidate_shared_container;
  113|  6.56k|    }
  114|  6.56k|}
containers.c:container_maximum:
 2171|  6.33k|static inline uint16_t container_maximum(const container_t *c, uint8_t type) {
 2172|  6.33k|    c = container_unwrap_shared(c, &type);
 2173|  6.33k|    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.42k]
  ------------------
 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.42k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  4.42k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2176:9): [True: 4.42k, False: 1.91k]
  ------------------
 2177|  4.42k|            return array_container_maximum(const_CAST_array(c));
  ------------------
  |  |   55|  4.42k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  4.42k|#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.33k]
  ------------------
 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.33k]
  ------------------
 2181|      0|            assert(false);
 2182|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2183|  6.33k|    }
 2184|  6.33k|    assert(false);
 2185|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2186|      0|    return false;
 2187|  6.33k|}

run_container_contains:
  260|  8.47k|inline bool run_container_contains(const run_container_t *run, uint16_t pos) {
  261|  8.47k|    int32_t index = interleavedBinarySearch(run->runs, run->n_runs, pos);
  262|  8.47k|    if (index >= 0) return true;
  ------------------
  |  Branch (262:9): [True: 6.00k, False: 2.46k]
  ------------------
  263|  2.46k|    index = -index - 2;  // points to preceding value, possibly -1
  264|  2.46k|    if (index != -1) {   // possible match
  ------------------
  |  Branch (264:9): [True: 846, False: 1.62k]
  ------------------
  265|    846|        int32_t offset = pos - run->runs[index].value;
  266|    846|        int32_t le = run->runs[index].length;
  267|    846|        if (offset <= le) return true;
  ------------------
  |  Branch (267:13): [True: 537, False: 309]
  ------------------
  268|    846|    }
  269|  1.93k|    return false;
  270|  2.46k|}
interleavedBinarySearch:
  112|   423k|                                       uint16_t ikey) {
  113|   423k|    int32_t low = 0;
  114|   423k|    int32_t high = lenarray - 1;
  115|  1.96M|    while (low <= high) {
  ------------------
  |  Branch (115:12): [True: 1.73M, False: 226k]
  ------------------
  116|  1.73M|        int32_t middleIndex = (low + high) >> 1;
  117|  1.73M|        uint16_t middleValue = array[middleIndex].value;
  118|  1.73M|        if (middleValue < ikey) {
  ------------------
  |  Branch (118:13): [True: 668k, False: 1.06M]
  ------------------
  119|   668k|            low = middleIndex + 1;
  120|  1.06M|        } else if (middleValue > ikey) {
  ------------------
  |  Branch (120:20): [True: 872k, False: 197k]
  ------------------
  121|   872k|            high = middleIndex - 1;
  122|   872k|        } else {
  123|   197k|            return middleIndex;
  124|   197k|        }
  125|  1.73M|    }
  126|   226k|    return -(low + 1);
  127|   423k|}
run_container_minimum:
  563|  16.5k|inline uint16_t run_container_minimum(const run_container_t *run) {
  564|  16.5k|    if (run->n_runs == 0) return 0;
  ------------------
  |  Branch (564:9): [True: 0, False: 16.5k]
  ------------------
  565|  16.5k|    return run->runs[0].value;
  566|  16.5k|}
run_container_maximum:
  569|  16.0k|inline uint16_t run_container_maximum(const run_container_t *run) {
  570|  16.0k|    if (run->n_runs == 0) return 0;
  ------------------
  |  Branch (570:9): [True: 0, False: 16.0k]
  ------------------
  571|  16.0k|    return run->runs[run->n_runs - 1].value + run->runs[run->n_runs - 1].length;
  572|  16.0k|}
roaring.c:run_container_create_range:
  532|  89.8k|                                                          uint32_t stop) {
  533|  89.8k|    run_container_t *rc = run_container_create_given_capacity(1);
  534|  89.8k|    if (rc) {
  ------------------
  |  Branch (534:9): [True: 89.8k, False: 0]
  ------------------
  535|  89.8k|        rle16_t r;
  536|  89.8k|        r.value = (uint16_t)start;
  537|  89.8k|        r.length = (uint16_t)(stop - start - 1);
  538|  89.8k|        run_container_append_first(rc, r);
  539|  89.8k|    }
  540|  89.8k|    return rc;
  541|  89.8k|}
roaring.c:run_container_append_first:
  351|  89.8k|                                                 rle16_t vl) {
  352|  89.8k|    run->runs[run->n_runs] = vl;
  353|  89.8k|    run->n_runs++;
  354|  89.8k|    return vl;
  355|  89.8k|}
roaring.c:rle16_count_greater:
  178|    477|                                          int32_t lenarray, uint16_t key) {
  179|    477|    if (lenarray == 0) return 0;
  ------------------
  |  Branch (179:9): [True: 0, False: 477]
  ------------------
  180|    477|    int32_t low = 0;
  181|    477|    int32_t high = lenarray - 1;
  182|  3.62k|    while (low <= high) {
  ------------------
  |  Branch (182:12): [True: 3.18k, False: 440]
  ------------------
  183|  3.18k|        int32_t middleIndex = (low + high) >> 1;
  184|  3.18k|        uint16_t min_value = array[middleIndex].value;
  185|  3.18k|        uint16_t max_value =
  186|  3.18k|            array[middleIndex].value + array[middleIndex].length;
  187|  3.18k|        if (max_value < key) {
  ------------------
  |  Branch (187:13): [True: 2.92k, False: 251]
  ------------------
  188|  2.92k|            low = middleIndex + 1;
  189|  2.92k|        } else if (key + UINT32_C(1) < min_value) {  // uint32 arithmetic
  ------------------
  |  Branch (189:20): [True: 214, False: 37]
  ------------------
  190|    214|            high = middleIndex - 1;
  191|    214|        } else {
  192|     37|            return lenarray - (middleIndex + 1);
  193|     37|        }
  194|  3.18k|    }
  195|    440|    return lenarray - low;
  196|    477|}
roaring.c:rle16_count_less:
  157|    477|                                       uint16_t key) {
  158|    477|    if (lenarray == 0) return 0;
  ------------------
  |  Branch (158:9): [True: 2, False: 475]
  ------------------
  159|    475|    int32_t low = 0;
  160|    475|    int32_t high = lenarray - 1;
  161|  3.05k|    while (low <= high) {
  ------------------
  |  Branch (161:12): [True: 2.83k, False: 229]
  ------------------
  162|  2.83k|        int32_t middleIndex = (low + high) >> 1;
  163|  2.83k|        uint16_t min_value = array[middleIndex].value;
  164|  2.83k|        uint16_t max_value =
  165|  2.83k|            array[middleIndex].value + array[middleIndex].length;
  166|  2.83k|        if (max_value + UINT32_C(1) < key) {  // uint32 arithmetic
  ------------------
  |  Branch (166:13): [True: 1.32k, False: 1.50k]
  ------------------
  167|  1.32k|            low = middleIndex + 1;
  168|  1.50k|        } else if (key < min_value) {
  ------------------
  |  Branch (168:20): [True: 1.25k, False: 246]
  ------------------
  169|  1.25k|            high = middleIndex - 1;
  170|  1.25k|        } else {
  171|    246|            return middleIndex;
  172|    246|        }
  173|  2.83k|    }
  174|    229|    return low;
  175|    475|}
roaring.c:run_container_add_range_nruns:
  610|    477|                                                 int32_t nruns_greater) {
  611|    477|    int32_t nruns_common = run->n_runs - nruns_less - nruns_greater;
  612|    477|    if (nruns_common == 0) {
  ------------------
  |  Branch (612:9): [True: 138, False: 339]
  ------------------
  613|    138|        makeRoomAtIndex(run, (uint16_t)nruns_less);
  614|    138|        run->runs[nruns_less].value = (uint16_t)min;
  615|    138|        run->runs[nruns_less].length = (uint16_t)(max - min);
  616|    339|    } else {
  617|    339|        uint32_t common_min = run->runs[nruns_less].value;
  618|    339|        uint32_t common_max = run->runs[nruns_less + nruns_common - 1].value +
  619|    339|                              run->runs[nruns_less + nruns_common - 1].length;
  620|    339|        uint32_t result_min = (common_min < min) ? common_min : min;
  ------------------
  |  Branch (620:31): [True: 68, False: 271]
  ------------------
  621|    339|        uint32_t result_max = (common_max > max) ? common_max : max;
  ------------------
  |  Branch (621:31): [True: 30, False: 309]
  ------------------
  622|       |
  623|    339|        run->runs[nruns_less].value = (uint16_t)result_min;
  624|    339|        run->runs[nruns_less].length = (uint16_t)(result_max - result_min);
  625|       |
  626|    339|        memmove(&(run->runs[nruns_less + 1]),
  627|    339|                &(run->runs[run->n_runs - nruns_greater]),
  628|    339|                nruns_greater * sizeof(rle16_t));
  629|    339|        run->n_runs = nruns_less + 1 + nruns_greater;
  630|    339|    }
  631|    477|}
roaring.c:makeRoomAtIndex:
  208|    909|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|    909|    if (run->n_runs + 1 > run->capacity)
  ------------------
  |  Branch (212:9): [True: 746, False: 163]
  ------------------
  213|    746|        run_container_grow(run, run->n_runs + 1, true);
  214|    909|    memmove(run->runs + 1 + index, run->runs + index,
  215|    909|            (run->n_runs - index) * sizeof(rle16_t));
  216|    909|    run->n_runs++;
  217|    909|}
roaring.c:run_container_remove_range:
  667|  1.85k|                                              uint32_t min, uint32_t max) {
  668|  1.85k|    int32_t first = rle16_find_run(run->runs, run->n_runs, (uint16_t)min);
  669|  1.85k|    int32_t last = rle16_find_run(run->runs, run->n_runs, (uint16_t)max);
  670|       |
  671|  1.85k|    if (first >= 0 && min > run->runs[first].value &&
  ------------------
  |  Branch (671:9): [True: 700, False: 1.15k]
  |  Branch (671:23): [True: 306, False: 394]
  ------------------
  672|    306|        max < ((uint32_t)run->runs[first].value +
  ------------------
  |  Branch (672:9): [True: 49, False: 257]
  ------------------
  673|    306|               (uint32_t)run->runs[first].length)) {
  674|       |        // split this run into two adjacent runs
  675|       |
  676|       |        // right subinterval
  677|     49|        makeRoomAtIndex(run, (uint16_t)(first + 1));
  678|     49|        run->runs[first + 1].value = (uint16_t)(max + 1);
  679|     49|        run->runs[first + 1].length =
  680|     49|            (uint16_t)((run->runs[first].value + run->runs[first].length) -
  681|     49|                       (max + 1));
  682|       |
  683|       |        // left subinterval
  684|     49|        run->runs[first].length =
  685|     49|            (uint16_t)((min - 1) - run->runs[first].value);
  686|       |
  687|     49|        return;
  688|     49|    }
  689|       |
  690|       |    // update left-most partial run
  691|  1.80k|    if (first >= 0) {
  ------------------
  |  Branch (691:9): [True: 651, False: 1.15k]
  ------------------
  692|    651|        if (min > run->runs[first].value) {
  ------------------
  |  Branch (692:13): [True: 257, False: 394]
  ------------------
  693|    257|            run->runs[first].length =
  694|    257|                (uint16_t)((min - 1) - run->runs[first].value);
  695|    257|            first++;
  696|    257|        }
  697|  1.15k|    } else {
  698|  1.15k|        first = -first - 1;
  699|  1.15k|    }
  700|       |
  701|       |    // update right-most run
  702|  1.80k|    if (last >= 0) {
  ------------------
  |  Branch (702:9): [True: 613, False: 1.19k]
  ------------------
  703|    613|        uint16_t run_max = run->runs[last].value + run->runs[last].length;
  704|    613|        if (run_max > max) {
  ------------------
  |  Branch (704:13): [True: 385, False: 228]
  ------------------
  705|    385|            run->runs[last].value = (uint16_t)(max + 1);
  706|    385|            run->runs[last].length = (uint16_t)(run_max - (max + 1));
  707|    385|            last--;
  708|    385|        }
  709|  1.19k|    } else {
  710|  1.19k|        last = (-last - 1) - 1;
  711|  1.19k|    }
  712|       |
  713|       |    // remove intermediate runs
  714|  1.80k|    if (first <= last) {
  ------------------
  |  Branch (714:9): [True: 180, False: 1.62k]
  ------------------
  715|    180|        run_container_shift_tail(run, run->n_runs - (last + 1),
  716|    180|                                 -(last - first + 1));
  717|    180|    }
  718|  1.80k|}
roaring.c:rle16_find_run:
  133|  3.71k|                                     uint16_t ikey) {
  134|  3.71k|    int32_t low = 0;
  135|  3.71k|    int32_t high = lenarray - 1;
  136|  15.5k|    while (low <= high) {
  ------------------
  |  Branch (136:12): [True: 13.2k, False: 2.34k]
  ------------------
  137|  13.2k|        int32_t middleIndex = (low + high) >> 1;
  138|  13.2k|        uint16_t min = array[middleIndex].value;
  139|  13.2k|        uint16_t max = array[middleIndex].value + array[middleIndex].length;
  140|  13.2k|        if (ikey > max) {
  ------------------
  |  Branch (140:13): [True: 1.75k, False: 11.4k]
  ------------------
  141|  1.75k|            low = middleIndex + 1;
  142|  11.4k|        } else if (ikey < min) {
  ------------------
  |  Branch (142:20): [True: 10.1k, False: 1.36k]
  ------------------
  143|  10.1k|            high = middleIndex - 1;
  144|  10.1k|        } else {
  145|  1.36k|            return middleIndex;
  146|  1.36k|        }
  147|  13.2k|    }
  148|  2.34k|    return -(low + 1);
  149|  3.71k|}
roaring.c:run_container_shift_tail:
  650|    180|                                            int32_t distance) {
  651|    180|    if (distance > 0) {
  ------------------
  |  Branch (651:9): [True: 0, False: 180]
  ------------------
  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|    180|    int32_t srcpos = run->n_runs - count;
  657|    180|    int32_t dstpos = srcpos + distance;
  658|    180|    memmove(&(run->runs[dstpos]), &(run->runs[srcpos]),
  659|    180|            sizeof(rle16_t) * count);
  660|    180|    run->n_runs += distance;
  661|    180|}
roaring.c:run_container_remove:
  223|  3.10k|static inline bool run_container_remove(run_container_t *run, uint16_t pos) {
  224|  3.10k|    int32_t index = interleavedBinarySearch(run->runs, run->n_runs, pos);
  225|  3.10k|    if (index >= 0) {
  ------------------
  |  Branch (225:9): [True: 1.20k, False: 1.90k]
  ------------------
  226|  1.20k|        int32_t le = run->runs[index].length;
  227|  1.20k|        if (le == 0) {
  ------------------
  |  Branch (227:13): [True: 274, False: 926]
  ------------------
  228|    274|            recoverRoomAtIndex(run, (uint16_t)index);
  229|    926|        } else {
  230|    926|            run->runs[index].value++;
  231|    926|            run->runs[index].length--;
  232|    926|        }
  233|  1.20k|        return true;
  234|  1.20k|    }
  235|  1.90k|    index = -index - 2;  // points to preceding value, possibly -1
  236|  1.90k|    if (index >= 0) {    // possible match
  ------------------
  |  Branch (236:9): [True: 908, False: 1.00k]
  ------------------
  237|    908|        int32_t offset = pos - run->runs[index].value;
  238|    908|        int32_t le = run->runs[index].length;
  239|    908|        if (offset < le) {
  ------------------
  |  Branch (239:13): [True: 722, False: 186]
  ------------------
  240|       |            // need to break in two
  241|    722|            run->runs[index].length = (uint16_t)(offset - 1);
  242|       |            // need to insert
  243|    722|            uint16_t newvalue = pos + 1;
  244|    722|            int32_t newlength = le - offset - 1;
  245|    722|            makeRoomAtIndex(run, (uint16_t)(index + 1));
  246|    722|            run->runs[index + 1].value = newvalue;
  247|    722|            run->runs[index + 1].length = (uint16_t)newlength;
  248|    722|            return true;
  249|       |
  250|    722|        } else if (offset == le) {
  ------------------
  |  Branch (250:20): [True: 29, False: 157]
  ------------------
  251|     29|            run->runs[index].length--;
  252|     29|            return true;
  253|     29|        }
  254|    908|    }
  255|       |    // no match
  256|  1.15k|    return false;
  257|  1.90k|}
roaring.c:recoverRoomAtIndex:
  102|    274|static inline void recoverRoomAtIndex(run_container_t *run, uint16_t index) {
  103|    274|    memmove(run->runs + index, run->runs + (1 + index),
  104|    274|            (run->n_runs - index - 1) * sizeof(rle16_t));
  105|    274|    run->n_runs--;
  106|    274|}
roaring.c:run_container_nonzero_cardinality:
  309|  66.3k|    const run_container_t *run) {
  310|  66.3k|    return run->n_runs > 0;  // runs never empty
  311|  66.3k|}
roaring.c:run_container_is_full:
  394|  6.20k|static inline bool run_container_is_full(const run_container_t *run) {
  395|  6.20k|    rle16_t vl = run->runs[0];
  396|  6.20k|    return (run->n_runs == 1) && (vl.value == 0) && (vl.length == 0xFFFF);
  ------------------
  |  Branch (396:12): [True: 1.19k, False: 5.00k]
  |  Branch (396:34): [True: 968, False: 228]
  |  Branch (396:53): [True: 839, False: 129]
  ------------------
  397|  6.20k|}
roaring.c:run_container_equals:
  502|    127|                                        const run_container_t *container2) {
  503|    127|    if (container1->n_runs != container2->n_runs) {
  ------------------
  |  Branch (503:9): [True: 97, False: 30]
  ------------------
  504|     97|        return false;
  505|     97|    }
  506|     30|    return memequals(container1->runs, container2->runs,
  507|     30|                     container1->n_runs * sizeof(rle16_t));
  508|    127|}
roaring.c:run_container_contains_range:
  278|    197|                                                uint32_t pos_end) {
  279|    197|    uint32_t count = 0;
  280|    197|    int32_t index =
  281|    197|        interleavedBinarySearch(run->runs, run->n_runs, (uint16_t)pos_start);
  282|    197|    if (index < 0) {
  ------------------
  |  Branch (282:9): [True: 121, False: 76]
  ------------------
  283|    121|        index = -index - 2;
  284|    121|        if ((index == -1) ||
  ------------------
  |  Branch (284:13): [True: 19, False: 102]
  ------------------
  285|    102|            ((pos_start - run->runs[index].value) > run->runs[index].length)) {
  ------------------
  |  Branch (285:13): [True: 29, False: 73]
  ------------------
  286|     48|            return false;
  287|     48|        }
  288|    121|    }
  289|  3.06k|    for (int32_t i = index; i < run->n_runs; ++i) {
  ------------------
  |  Branch (289:29): [True: 3.00k, False: 60]
  ------------------
  290|  3.00k|        const uint32_t stop = run->runs[i].value + run->runs[i].length;
  291|  3.00k|        if (run->runs[i].value >= pos_end) break;
  ------------------
  |  Branch (291:13): [True: 20, False: 2.98k]
  ------------------
  292|  2.98k|        if (stop >= pos_end) {
  ------------------
  |  Branch (292:13): [True: 69, False: 2.91k]
  ------------------
  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|  2.91k|        const uint32_t min = (stop - pos_start) > 0 ? (stop - pos_start) : 0;
  ------------------
  |  Branch (298:30): [True: 2.89k, False: 13]
  ------------------
  299|  2.91k|        count += (min < run->runs[i].length) ? min : run->runs[i].length;
  ------------------
  |  Branch (299:18): [True: 54, False: 2.85k]
  ------------------
  300|  2.91k|    }
  301|    149|    return count >= (pos_end - pos_start - 1);
  302|    197|}
roaring_array.c:run_container_size_in_bytes:
  493|  2.61k|    const run_container_t *container) {
  494|  2.61k|    return run_container_serialized_size_in_bytes(container->n_runs);
  495|  2.61k|}
roaring_array.c:run_container_serialized_size_in_bytes:
  456|  2.61k|static inline int32_t run_container_serialized_size_in_bytes(int32_t num_runs) {
  457|  2.61k|    return sizeof(uint16_t) +
  458|  2.61k|           sizeof(rle16_t) * num_runs;  // each run requires 2 2-byte entries.
  459|  2.61k|}
convert.c:run_container_serialized_size_in_bytes:
  456|   151k|static inline int32_t run_container_serialized_size_in_bytes(int32_t num_runs) {
  457|   151k|    return sizeof(uint16_t) +
  458|   151k|           sizeof(rle16_t) * num_runs;  // each run requires 2 2-byte entries.
  459|   151k|}
mixed_intersection.c:run_container_is_full:
  394|  17.3k|static inline bool run_container_is_full(const run_container_t *run) {
  395|  17.3k|    rle16_t vl = run->runs[0];
  396|  17.3k|    return (run->n_runs == 1) && (vl.value == 0) && (vl.length == 0xFFFF);
  ------------------
  |  Branch (396:12): [True: 1.47k, False: 15.8k]
  |  Branch (396:34): [True: 635, False: 836]
  |  Branch (396:53): [True: 150, False: 485]
  ------------------
  397|  17.3k|}
mixed_union.c:run_container_is_full:
  394|  2.92k|static inline bool run_container_is_full(const run_container_t *run) {
  395|  2.92k|    rle16_t vl = run->runs[0];
  396|  2.92k|    return (run->n_runs == 1) && (vl.value == 0) && (vl.length == 0xFFFF);
  ------------------
  |  Branch (396:12): [True: 347, False: 2.57k]
  |  Branch (396:34): [True: 213, False: 134]
  |  Branch (396:53): [True: 85, False: 128]
  ------------------
  397|  2.92k|}
mixed_union.c:run_container_append_first:
  351|  2.16k|                                                 rle16_t vl) {
  352|  2.16k|    run->runs[run->n_runs] = vl;
  353|  2.16k|    run->n_runs++;
  354|  2.16k|    return vl;
  355|  2.16k|}
mixed_union.c:run_container_append_value_first:
  385|    668|                                                       uint16_t val) {
  386|    668|    rle16_t newrle = CROARING_MAKE_RLE16(val, 0);
  ------------------
  |  |   60|    668|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  387|    668|    run->runs[run->n_runs] = newrle;
  388|    668|    run->n_runs++;
  389|    668|    return newrle;
  390|    668|}
mixed_union.c:run_container_append:
  332|   166k|                                        rle16_t *previousrl) {
  333|   166k|    const uint32_t previousend = previousrl->value + previousrl->length;
  334|   166k|    if (vl.value > previousend + 1) {  // we add a new one
  ------------------
  |  Branch (334:9): [True: 154k, False: 11.9k]
  ------------------
  335|   154k|        run->runs[run->n_runs] = vl;
  336|   154k|        run->n_runs++;
  337|   154k|        *previousrl = vl;
  338|   154k|    } else {
  339|  11.9k|        uint32_t newend = vl.value + vl.length + UINT32_C(1);
  340|  11.9k|        if (newend > previousend) {  // we merge
  ------------------
  |  Branch (340:13): [True: 11.9k, False: 0]
  ------------------
  341|  11.9k|            previousrl->length = (uint16_t)(newend - 1 - previousrl->value);
  342|  11.9k|            run->runs[run->n_runs - 1] = *previousrl;
  343|  11.9k|        }
  344|  11.9k|    }
  345|   166k|}
mixed_union.c:run_container_append_value:
  368|   522k|                                              rle16_t *previousrl) {
  369|   522k|    const uint32_t previousend = previousrl->value + previousrl->length;
  370|   522k|    if (val > previousend + 1) {  // we add a new one
  ------------------
  |  Branch (370:9): [True: 57.7k, False: 464k]
  ------------------
  371|  57.7k|        *previousrl = CROARING_MAKE_RLE16(val, 0);
  ------------------
  |  |   60|  57.7k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  372|  57.7k|        run->runs[run->n_runs] = *previousrl;
  373|  57.7k|        run->n_runs++;
  374|   464k|    } else if (val == previousend + 1) {  // we merge
  ------------------
  |  Branch (374:16): [True: 167k, False: 296k]
  ------------------
  375|   167k|        previousrl->length++;
  376|   167k|        run->runs[run->n_runs - 1] = *previousrl;
  377|   167k|    }
  378|   522k|}
run.c:run_container_is_full:
  394|   134k|static inline bool run_container_is_full(const run_container_t *run) {
  395|   134k|    rle16_t vl = run->runs[0];
  396|   134k|    return (run->n_runs == 1) && (vl.value == 0) && (vl.length == 0xFFFF);
  ------------------
  |  Branch (396:12): [True: 119k, False: 15.0k]
  |  Branch (396:34): [True: 118k, False: 1.64k]
  |  Branch (396:53): [True: 115k, False: 2.32k]
  ------------------
  397|   134k|}
run.c:run_container_serialized_size_in_bytes:
  456|     60|static inline int32_t run_container_serialized_size_in_bytes(int32_t num_runs) {
  457|     60|    return sizeof(uint16_t) +
  458|     60|           sizeof(rle16_t) * num_runs;  // each run requires 2 2-byte entries.
  459|     60|}
run.c:recoverRoomAtIndex:
  102|  6.10k|static inline void recoverRoomAtIndex(run_container_t *run, uint16_t index) {
  103|  6.10k|    memmove(run->runs + index, run->runs + (1 + index),
  104|  6.10k|            (run->n_runs - index - 1) * sizeof(rle16_t));
  105|  6.10k|    run->n_runs--;
  106|  6.10k|}
run.c:makeRoomAtIndex:
  208|  46.0k|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|  46.0k|    if (run->n_runs + 1 > run->capacity)
  ------------------
  |  Branch (212:9): [True: 2.58k, False: 43.4k]
  ------------------
  213|  2.58k|        run_container_grow(run, run->n_runs + 1, true);
  214|  46.0k|    memmove(run->runs + 1 + index, run->runs + index,
  215|  46.0k|            (run->n_runs - index) * sizeof(rle16_t));
  216|  46.0k|    run->n_runs++;
  217|  46.0k|}
run.c:run_container_append_first:
  351|  2.36k|                                                 rle16_t vl) {
  352|  2.36k|    run->runs[run->n_runs] = vl;
  353|  2.36k|    run->n_runs++;
  354|  2.36k|    return vl;
  355|  2.36k|}
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: 158k, False: 145k]
  ------------------
  335|   158k|        run->runs[run->n_runs] = vl;
  336|   158k|        run->n_runs++;
  337|   158k|        *previousrl = vl;
  338|   158k|    } else {
  339|   145k|        uint32_t newend = vl.value + vl.length + UINT32_C(1);
  340|   145k|        if (newend > previousend) {  // we merge
  ------------------
  |  Branch (340:13): [True: 112k, False: 32.8k]
  ------------------
  341|   112k|            previousrl->length = (uint16_t)(newend - 1 - previousrl->value);
  342|   112k|            run->runs[run->n_runs - 1] = *previousrl;
  343|   112k|        }
  344|   145k|    }
  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|     60|    const run_container_t *container) {
  494|     60|    return run_container_serialized_size_in_bytes(container->n_runs);
  495|     60|}

roaring_trailing_zeroes:
  242|  71.5M|inline int roaring_trailing_zeroes(unsigned long long input_num) {
  243|  71.5M|    return __builtin_ctzll(input_num);
  244|  71.5M|}
roaring_leading_zeroes:
  246|  4.42k|inline int roaring_leading_zeroes(unsigned long long input_num) {
  247|  4.42k|    return __builtin_clzll(input_num);
  248|  4.42k|}
roaring.c:roaring_hamming:
  287|   156k|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|   156k|    return __builtin_popcountll(x);
  309|   156k|#endif
  310|   156k|}
mixed_intersection.c:roaring_hamming:
  287|   213k|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|   213k|    return __builtin_popcountll(x);
  309|   213k|#endif
  310|   213k|}

roaring_bitmap_init_cleared:
   72|  32.2k|inline void roaring_bitmap_init_cleared(roaring_bitmap_t *r) {
   73|  32.2k|    roaring_bitmap_init_with_capacity(r, 0);
   74|  32.2k|}
roaring_bitmap_add_range:
  434|  6.44k|                                     uint64_t max) {
  435|  6.44k|    if (max <= min || min > (uint64_t)UINT32_MAX + 1) {
  ------------------
  |  Branch (435:9): [True: 3.57k, False: 2.86k]
  |  Branch (435:23): [True: 0, False: 2.86k]
  ------------------
  436|  3.57k|        return;
  437|  3.57k|    }
  438|  2.86k|    roaring_bitmap_add_range_closed(r, (uint32_t)min, (uint32_t)(max - 1));
  439|  2.86k|}
roaring_bitmap_remove_range:
  456|  6.44k|                                        uint64_t max) {
  457|  6.44k|    if (max <= min || min > (uint64_t)UINT32_MAX + 1) {
  ------------------
  |  Branch (457:9): [True: 5.45k, False: 990]
  |  Branch (457:23): [True: 0, False: 990]
  ------------------
  458|  5.45k|        return;
  459|  5.45k|    }
  460|    990|    roaring_bitmap_remove_range_closed(r, (uint32_t)min, (uint32_t)(max - 1));
  461|    990|}
roaring_bitmap_contains:
  478|  6.50k|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.50k|#ifdef __cplusplus
  482|  6.50k|    using namespace ::roaring::internal;
  483|  6.50k|#endif
  484|  6.50k|    const uint16_t hb = val >> 16;
  485|       |    /*
  486|       |     * the next function call involves a binary search and lots of branching.
  487|       |     */
  488|  6.50k|    int32_t i = ra_get_index(&r->high_low_container, hb);
  489|  6.50k|    if (i < 0) return false;
  ------------------
  |  Branch (489:9): [True: 667, False: 5.83k]
  ------------------
  490|       |
  491|  5.83k|    uint8_t typecode;
  492|       |    // next call ought to be cheap
  493|  5.83k|    container_t *container = ra_get_container_at_index(&r->high_low_container,
  494|  5.83k|                                                       (uint16_t)i, &typecode);
  495|       |    // rest might be a tad expensive, possibly involving another round of binary
  496|       |    // search
  497|  5.83k|    return container_contains(container, val & 0xFFFF, typecode);
  498|  6.50k|}
roaring_bitmap_set_copy_on_write:
  117|  59.4k|inline void roaring_bitmap_set_copy_on_write(roaring_bitmap_t *r, bool cow) {
  118|  59.4k|    if (cow) {
  ------------------
  |  Branch (118:9): [True: 0, False: 59.4k]
  ------------------
  119|      0|        r->high_low_container.flags |= ROARING_FLAG_COW;
  ------------------
  |  |   46|      0|#define ROARING_FLAG_COW UINT8_C(0x1)
  ------------------
  120|  59.4k|    } else {
  121|  59.4k|        if (roaring_bitmap_get_copy_on_write(r)) {
  ------------------
  |  Branch (121:13): [True: 0, False: 59.4k]
  ------------------
  122|      0|            roaring_unshare_all(r);
  123|      0|        }
  124|       |        r->high_low_container.flags &= ~ROARING_FLAG_COW;
  ------------------
  |  |   46|  59.4k|#define ROARING_FLAG_COW UINT8_C(0x1)
  ------------------
  125|  59.4k|    }
  126|  59.4k|}
roaring_bitmap_get_copy_on_write:
  114|  72.3k|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.3k|#define ROARING_FLAG_COW UINT8_C(0x1)
  ------------------
  116|  72.3k|}

ra_get_index:
   93|  88.4k|inline int32_t ra_get_index(const roaring_array_t *ra, uint16_t x) {
   94|  88.4k|    if ((ra->size == 0) || ra->keys[ra->size - 1] == x) return ra->size - 1;
  ------------------
  |  Branch (94:9): [True: 12.9k, False: 75.5k]
  |  Branch (94:28): [True: 32.6k, False: 42.8k]
  ------------------
   95|  42.8k|    return binarySearch(ra->keys, (int32_t)ra->size, x);
   96|  88.4k|}
ra_get_container_at_index:
  102|   579k|                                              uint16_t i, uint8_t *typecode) {
  103|   579k|    *typecode = ra->typecodes[i];
  104|   579k|    return ra->containers[i];
  105|   579k|}
ra_get_key_at_index:
  110|   433k|inline uint16_t ra_get_key_at_index(const roaring_array_t *ra, uint16_t i) {
  111|   433k|    return ra->keys[i];
  112|   433k|}
ra_set_container_at_index:
  175|   114k|                                      container_t *c, uint8_t typecode) {
  176|       |    assert(i < ra->size);
  177|   114k|    ra->containers[i] = c;
  178|   114k|    ra->typecodes[i] = typecode;
  179|   114k|}
ra_get_size:
  191|  13.6k|inline int32_t ra_get_size(const roaring_array_t *ra) { return ra->size; }
ra_replace_key_and_container_at_index:
  205|   155k|                                                  uint8_t typecode) {
  206|   155k|    assert(i < ra->size);
  207|       |
  208|   155k|    ra->keys[i] = key;
  209|   155k|    ra->containers[i] = c;
  210|   155k|    ra->typecodes[i] = typecode;
  211|   155k|}
roaring.c:ra_advance_until:
  194|    420|                                       int32_t pos) {
  195|    420|    return advanceUntil(ra->keys, pos, ra->size, x);
  196|    420|}
roaring.c:ra_unshare_container_at_index:
  268|  63.6k|                                                 uint16_t i) {
  269|       |    assert(i < ra->size);
  270|  63.6k|    ra->containers[i] =
  271|  63.6k|        get_writable_copy_if_shared(ra->containers[i], &ra->typecodes[i]);
  272|  63.6k|}

intersect_vector16:
  386|  1.73k|                           size_t s_b, uint16_t *C) {
  387|  1.73k|    size_t count = 0;
  388|  1.73k|    size_t i_a = 0, i_b = 0;
  389|  1.73k|    const int vectorlength = sizeof(__m128i) / sizeof(uint16_t);
  390|  1.73k|    const size_t st_a = (s_a / vectorlength) * vectorlength;
  391|  1.73k|    const size_t st_b = (s_b / vectorlength) * vectorlength;
  392|  1.73k|    __m128i v_a, v_b;
  393|  1.73k|    if ((i_a < st_a) && (i_b < st_b)) {
  ------------------
  |  Branch (393:9): [True: 1.60k, False: 122]
  |  Branch (393:25): [True: 1.44k, False: 166]
  ------------------
  394|  1.44k|        v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  395|  1.44k|        v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  396|  3.96k|        while ((A[i_a] == 0) || (B[i_b] == 0)) {
  ------------------
  |  Branch (396:16): [True: 2.48k, False: 1.48k]
  |  Branch (396:33): [True: 178, False: 1.30k]
  ------------------
  397|  2.65k|            const __m128i res_v = _mm_cmpestrm(
  398|  2.65k|                v_b, vectorlength, v_a, vectorlength,
  399|  2.65k|                _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  400|  2.65k|            const int r = _mm_extract_epi32(res_v, 0);
  401|  2.65k|            __m128i sm16 = _mm_loadu_si128((const __m128i *)shuffle_mask16 + r);
  402|  2.65k|            __m128i p = _mm_shuffle_epi8(v_a, sm16);
  403|  2.65k|            _mm_storeu_si128((__m128i *)&C[count], p);  // can overflow
  404|  2.65k|            count += _mm_popcnt_u32(r);
  405|  2.65k|            const uint16_t a_max = A[i_a + vectorlength - 1];
  406|  2.65k|            const uint16_t b_max = B[i_b + vectorlength - 1];
  407|  2.65k|            if (a_max <= b_max) {
  ------------------
  |  Branch (407:17): [True: 1.48k, False: 1.17k]
  ------------------
  408|  1.48k|                i_a += vectorlength;
  409|  1.48k|                if (i_a == st_a) break;
  ------------------
  |  Branch (409:21): [True: 112, False: 1.37k]
  ------------------
  410|  1.37k|                v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  411|  1.37k|            }
  412|  2.54k|            if (b_max <= a_max) {
  ------------------
  |  Branch (412:17): [True: 1.26k, False: 1.27k]
  ------------------
  413|  1.26k|                i_b += vectorlength;
  414|  1.26k|                if (i_b == st_b) break;
  ------------------
  |  Branch (414:21): [True: 27, False: 1.24k]
  ------------------
  415|  1.24k|                v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  416|  1.24k|            }
  417|  2.54k|        }
  418|  1.44k|        if ((i_a < st_a) && (i_b < st_b))
  ------------------
  |  Branch (418:13): [True: 1.33k, False: 112]
  |  Branch (418:29): [True: 1.30k, False: 27]
  ------------------
  419|  42.5k|            while (true) {
  ------------------
  |  Branch (419:20): [True: 42.5k, Folded]
  ------------------
  420|  42.5k|                const __m128i res_v = _mm_cmpistrm(
  421|  42.5k|                    v_b, v_a,
  422|  42.5k|                    _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  423|  42.5k|                const int r = _mm_extract_epi32(res_v, 0);
  424|  42.5k|                __m128i sm16 =
  425|  42.5k|                    _mm_loadu_si128((const __m128i *)shuffle_mask16 + r);
  426|  42.5k|                __m128i p = _mm_shuffle_epi8(v_a, sm16);
  427|  42.5k|                _mm_storeu_si128((__m128i *)&C[count], p);  // can overflow
  428|  42.5k|                count += _mm_popcnt_u32(r);
  429|  42.5k|                const uint16_t a_max = A[i_a + vectorlength - 1];
  430|  42.5k|                const uint16_t b_max = B[i_b + vectorlength - 1];
  431|  42.5k|                if (a_max <= b_max) {
  ------------------
  |  Branch (431:21): [True: 18.8k, False: 23.6k]
  ------------------
  432|  18.8k|                    i_a += vectorlength;
  433|  18.8k|                    if (i_a == st_a) break;
  ------------------
  |  Branch (433:25): [True: 786, False: 18.0k]
  ------------------
  434|  18.0k|                    v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  435|  18.0k|                }
  436|  41.7k|                if (b_max <= a_max) {
  ------------------
  |  Branch (436:21): [True: 25.2k, False: 16.5k]
  ------------------
  437|  25.2k|                    i_b += vectorlength;
  438|  25.2k|                    if (i_b == st_b) break;
  ------------------
  |  Branch (438:25): [True: 518, False: 24.7k]
  ------------------
  439|  24.7k|                    v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  440|  24.7k|                }
  441|  41.7k|            }
  442|  1.44k|    }
  443|       |    // intersect the tail using scalar intersection
  444|  28.8k|    while (i_a < s_a && i_b < s_b) {
  ------------------
  |  Branch (444:12): [True: 27.5k, False: 1.38k]
  |  Branch (444:25): [True: 27.1k, False: 351]
  ------------------
  445|  27.1k|        uint16_t a = A[i_a];
  446|  27.1k|        uint16_t b = B[i_b];
  447|  27.1k|        if (a < b) {
  ------------------
  |  Branch (447:13): [True: 11.4k, False: 15.6k]
  ------------------
  448|  11.4k|            i_a++;
  449|  15.6k|        } else if (b < a) {
  ------------------
  |  Branch (449:20): [True: 10.1k, False: 5.51k]
  ------------------
  450|  10.1k|            i_b++;
  451|  10.1k|        } else {
  452|  5.51k|            C[count] = a;  //==b;
  453|  5.51k|            count++;
  454|  5.51k|            i_a++;
  455|  5.51k|            i_b++;
  456|  5.51k|        }
  457|  27.1k|    }
  458|  1.73k|    return (int32_t)count;
  459|  1.73k|}
array_container_to_uint32_array_vector16:
  464|  5.91k|                                             uint32_t base) {
  465|  5.91k|    int outpos = 0;
  466|  5.91k|    uint32_t *out = (uint32_t *)vout;
  467|  5.91k|    size_t i = 0;
  468|   190k|    for (; i + sizeof(__m128i) / sizeof(uint16_t) <= cardinality;
  ------------------
  |  Branch (468:12): [True: 184k, False: 5.91k]
  ------------------
  469|   184k|         i += sizeof(__m128i) / sizeof(uint16_t)) {
  470|   184k|        __m128i vinput = _mm_loadu_si128((const __m128i *)(array + i));
  471|   184k|        __m256i voutput = _mm256_add_epi32(_mm256_cvtepu16_epi32(vinput),
  472|   184k|                                           _mm256_set1_epi32(base));
  473|   184k|        _mm256_storeu_si256((__m256i *)(out + outpos), voutput);
  474|   184k|        outpos += sizeof(__m256i) / sizeof(uint32_t);
  475|   184k|    }
  476|  20.2k|    for (; i < cardinality; ++i) {
  ------------------
  |  Branch (476:12): [True: 14.2k, False: 5.91k]
  ------------------
  477|  14.2k|        const uint32_t val = base + array[i];
  478|  14.2k|        memcpy(out + outpos, &val,
  479|  14.2k|               sizeof(uint32_t));  // should be compiled as a MOV on x64
  480|  14.2k|        outpos++;
  481|  14.2k|    }
  482|  5.91k|    return outpos;
  483|  5.91k|}
intersect_vector16_inplace:
  486|  4.61k|                                   size_t s_b) {
  487|  4.61k|    size_t count = 0;
  488|  4.61k|    size_t i_a = 0, i_b = 0;
  489|  4.61k|    const int vectorlength = sizeof(__m128i) / sizeof(uint16_t);
  490|  4.61k|    const size_t st_a = (s_a / vectorlength) * vectorlength;
  491|  4.61k|    const size_t st_b = (s_b / vectorlength) * vectorlength;
  492|  4.61k|    __m128i v_a, v_b;
  493|  4.61k|    if ((i_a < st_a) && (i_b < st_b)) {
  ------------------
  |  Branch (493:9): [True: 2.29k, False: 2.32k]
  |  Branch (493:25): [True: 2.09k, False: 199]
  ------------------
  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.08k|        while ((A[i_a] == 0) || (B[i_b] == 0)) {
  ------------------
  |  Branch (498:16): [True: 1.81k, False: 2.26k]
  |  Branch (498:33): [True: 265, False: 2.00k]
  ------------------
  499|  2.07k|            const __m128i res_v = _mm_cmpestrm(
  500|  2.07k|                v_b, vectorlength, v_a, vectorlength,
  501|  2.07k|                _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  502|  2.07k|            const int r = _mm_extract_epi32(res_v, 0);
  503|  2.07k|            __m128i sm16 = _mm_loadu_si128((const __m128i *)shuffle_mask16 + r);
  504|  2.07k|            __m128i p = _mm_shuffle_epi8(v_a, sm16);
  505|  2.07k|            _mm_storeu_si128((__m128i *)&((uint16_t *)tmp)[tmp_count], p);
  506|  2.07k|            tmp_count += _mm_popcnt_u32(r);
  507|  2.07k|            const uint16_t a_max = A[i_a + vectorlength - 1];
  508|  2.07k|            const uint16_t b_max = B[i_b + vectorlength - 1];
  509|  2.07k|            if (a_max <= b_max) {
  ------------------
  |  Branch (509:17): [True: 1.95k, False: 125]
  ------------------
  510|  1.95k|                _mm_storeu_si128((__m128i *)&A[count], tmp[0]);
  511|  1.95k|                _mm_storeu_si128(tmp, _mm_setzero_si128());
  512|  1.95k|                count += tmp_count;
  513|  1.95k|                tmp_count = 0;
  514|  1.95k|                i_a += vectorlength;
  515|  1.95k|                if (i_a == st_a) break;
  ------------------
  |  Branch (515:21): [True: 80, False: 1.87k]
  ------------------
  516|  1.87k|                v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  517|  1.87k|            }
  518|  1.99k|            if (b_max <= a_max) {
  ------------------
  |  Branch (518:17): [True: 314, False: 1.68k]
  ------------------
  519|    314|                i_b += vectorlength;
  520|    314|                if (i_b == st_b) break;
  ------------------
  |  Branch (520:21): [True: 9, False: 305]
  ------------------
  521|    305|                v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  522|    305|            }
  523|  1.99k|        }
  524|  2.09k|        if ((i_a < st_a) && (i_b < st_b)) {
  ------------------
  |  Branch (524:13): [True: 2.01k, False: 80]
  |  Branch (524:29): [True: 2.00k, False: 9]
  ------------------
  525|   234k|            while (true) {
  ------------------
  |  Branch (525:20): [True: 234k, Folded]
  ------------------
  526|   234k|                const __m128i res_v = _mm_cmpistrm(
  527|   234k|                    v_b, v_a,
  528|   234k|                    _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  529|   234k|                const int r = _mm_extract_epi32(res_v, 0);
  530|   234k|                __m128i sm16 =
  531|   234k|                    _mm_loadu_si128((const __m128i *)shuffle_mask16 + r);
  532|   234k|                __m128i p = _mm_shuffle_epi8(v_a, sm16);
  533|   234k|                _mm_storeu_si128((__m128i *)&((uint16_t *)tmp)[tmp_count], p);
  534|   234k|                tmp_count += _mm_popcnt_u32(r);
  535|   234k|                const uint16_t a_max = A[i_a + vectorlength - 1];
  536|   234k|                const uint16_t b_max = B[i_b + vectorlength - 1];
  537|   234k|                if (a_max <= b_max) {
  ------------------
  |  Branch (537:21): [True: 139k, False: 95.0k]
  ------------------
  538|   139k|                    _mm_storeu_si128((__m128i *)&A[count], tmp[0]);
  539|   139k|                    _mm_storeu_si128(tmp, _mm_setzero_si128());
  540|   139k|                    count += tmp_count;
  541|   139k|                    tmp_count = 0;
  542|   139k|                    i_a += vectorlength;
  543|   139k|                    if (i_a == st_a) break;
  ------------------
  |  Branch (543:25): [True: 1.14k, False: 138k]
  ------------------
  544|   138k|                    v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  545|   138k|                }
  546|   233k|                if (b_max <= a_max) {
  ------------------
  |  Branch (546:21): [True: 133k, False: 99.7k]
  ------------------
  547|   133k|                    i_b += vectorlength;
  548|   133k|                    if (i_b == st_b) break;
  ------------------
  |  Branch (548:25): [True: 863, False: 132k]
  ------------------
  549|   132k|                    v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  550|   132k|                }
  551|   233k|            }
  552|  2.00k|        }
  553|       |        // tmp_count <= 8, so this does not affect efficiency so much
  554|  4.60k|        for (size_t i = 0; i < tmp_count; i++) {
  ------------------
  |  Branch (554:28): [True: 2.50k, False: 2.09k]
  ------------------
  555|  2.50k|            A[count] = ((uint16_t *)tmp)[i];
  556|  2.50k|            count++;
  557|  2.50k|        }
  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.8k|    while (i_a < s_a && i_b < s_b) {
  ------------------
  |  Branch (561:12): [True: 29.6k, False: 4.21k]
  |  Branch (561:25): [True: 29.2k, False: 400]
  ------------------
  562|  29.2k|        uint16_t a = A[i_a];
  563|  29.2k|        uint16_t b = B[i_b];
  564|  29.2k|        if (a < b) {
  ------------------
  |  Branch (564:13): [True: 10.2k, False: 18.9k]
  ------------------
  565|  10.2k|            i_a++;
  566|  18.9k|        } else if (b < a) {
  ------------------
  |  Branch (566:20): [True: 7.29k, False: 11.6k]
  ------------------
  567|  7.29k|            i_b++;
  568|  11.6k|        } else {
  569|  11.6k|            A[count] = a;  //==b;
  570|  11.6k|            count++;
  571|  11.6k|            i_a++;
  572|  11.6k|            i_b++;
  573|  11.6k|        }
  574|  29.2k|    }
  575|  4.61k|    return (int32_t)count;
  576|  4.61k|}
intersect_vector16_cardinality:
  581|  6.92k|                                       const uint16_t *B, size_t s_b) {
  582|  6.92k|    size_t count = 0;
  583|  6.92k|    size_t i_a = 0, i_b = 0;
  584|  6.92k|    const int vectorlength = sizeof(__m128i) / sizeof(uint16_t);
  585|  6.92k|    const size_t st_a = (s_a / vectorlength) * vectorlength;
  586|  6.92k|    const size_t st_b = (s_b / vectorlength) * vectorlength;
  587|  6.92k|    __m128i v_a, v_b;
  588|  6.92k|    if ((i_a < st_a) && (i_b < st_b)) {
  ------------------
  |  Branch (588:9): [True: 6.43k, False: 488]
  |  Branch (588:25): [True: 5.77k, False: 664]
  ------------------
  589|  5.77k|        v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  590|  5.77k|        v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  591|  15.8k|        while ((A[i_a] == 0) || (B[i_b] == 0)) {
  ------------------
  |  Branch (591:16): [True: 9.92k, False: 5.92k]
  |  Branch (591:33): [True: 712, False: 5.21k]
  ------------------
  592|  10.6k|            const __m128i res_v = _mm_cmpestrm(
  593|  10.6k|                v_b, vectorlength, v_a, vectorlength,
  594|  10.6k|                _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  595|  10.6k|            const int r = _mm_extract_epi32(res_v, 0);
  596|  10.6k|            count += _mm_popcnt_u32(r);
  597|  10.6k|            const uint16_t a_max = A[i_a + vectorlength - 1];
  598|  10.6k|            const uint16_t b_max = B[i_b + vectorlength - 1];
  599|  10.6k|            if (a_max <= b_max) {
  ------------------
  |  Branch (599:17): [True: 5.93k, False: 4.70k]
  ------------------
  600|  5.93k|                i_a += vectorlength;
  601|  5.93k|                if (i_a == st_a) break;
  ------------------
  |  Branch (601:21): [True: 448, False: 5.48k]
  ------------------
  602|  5.48k|                v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  603|  5.48k|            }
  604|  10.1k|            if (b_max <= a_max) {
  ------------------
  |  Branch (604:17): [True: 5.07k, False: 5.11k]
  ------------------
  605|  5.07k|                i_b += vectorlength;
  606|  5.07k|                if (i_b == st_b) break;
  ------------------
  |  Branch (606:21): [True: 108, False: 4.96k]
  ------------------
  607|  4.96k|                v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  608|  4.96k|            }
  609|  10.1k|        }
  610|  5.77k|        if ((i_a < st_a) && (i_b < st_b))
  ------------------
  |  Branch (610:13): [True: 5.32k, False: 448]
  |  Branch (610:29): [True: 5.21k, False: 108]
  ------------------
  611|   170k|            while (true) {
  ------------------
  |  Branch (611:20): [True: 170k, Folded]
  ------------------
  612|   170k|                const __m128i res_v = _mm_cmpistrm(
  613|   170k|                    v_b, v_a,
  614|   170k|                    _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  615|   170k|                const int r = _mm_extract_epi32(res_v, 0);
  616|   170k|                count += _mm_popcnt_u32(r);
  617|   170k|                const uint16_t a_max = A[i_a + vectorlength - 1];
  618|   170k|                const uint16_t b_max = B[i_b + vectorlength - 1];
  619|   170k|                if (a_max <= b_max) {
  ------------------
  |  Branch (619:21): [True: 75.3k, False: 94.7k]
  ------------------
  620|  75.3k|                    i_a += vectorlength;
  621|  75.3k|                    if (i_a == st_a) break;
  ------------------
  |  Branch (621:25): [True: 3.14k, False: 72.1k]
  ------------------
  622|  72.1k|                    v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  623|  72.1k|                }
  624|   166k|                if (b_max <= a_max) {
  ------------------
  |  Branch (624:21): [True: 100k, False: 66.0k]
  ------------------
  625|   100k|                    i_b += vectorlength;
  626|   100k|                    if (i_b == st_b) break;
  ------------------
  |  Branch (626:25): [True: 2.07k, False: 98.8k]
  ------------------
  627|  98.8k|                    v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  628|  98.8k|                }
  629|   166k|            }
  630|  5.77k|    }
  631|       |    // intersect the tail using scalar intersection
  632|   115k|    while (i_a < s_a && i_b < s_b) {
  ------------------
  |  Branch (632:12): [True: 110k, False: 5.52k]
  |  Branch (632:25): [True: 108k, False: 1.40k]
  ------------------
  633|   108k|        uint16_t a = A[i_a];
  634|   108k|        uint16_t b = B[i_b];
  635|   108k|        if (a < b) {
  ------------------
  |  Branch (635:13): [True: 45.9k, False: 62.7k]
  ------------------
  636|  45.9k|            i_a++;
  637|  62.7k|        } else if (b < a) {
  ------------------
  |  Branch (637:20): [True: 40.6k, False: 22.0k]
  ------------------
  638|  40.6k|            i_b++;
  639|  40.6k|        } else {
  640|  22.0k|            count++;
  641|  22.0k|            i_a++;
  642|  22.0k|            i_b++;
  643|  22.0k|        }
  644|   108k|    }
  645|  6.92k|    return (int32_t)count;
  646|  6.92k|}
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.10k, False: 214]
  |  Branch (665:24): [True: 6, False: 208]
  ------------------
  666|  2.11k|        if ((A[0] == 0) && (B[0] == 0)) {
  ------------------
  |  Branch (666:13): [True: 2.10k, False: 6]
  |  Branch (666:28): [True: 289, False: 1.82k]
  ------------------
  667|    289|            A++;
  668|    289|            s_a--;
  669|    289|            B++;
  670|    289|            s_b--;
  671|  1.82k|        } else if (A[0] == 0) {
  ------------------
  |  Branch (671:20): [True: 1.82k, False: 6]
  ------------------
  672|  1.82k|            C[count++] = 0;
  673|  1.82k|            A++;
  674|  1.82k|            s_a--;
  675|  1.82k|        } else {
  676|      6|            B++;
  677|      6|            s_b--;
  678|      6|        }
  679|  2.11k|    }
  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: 427]
  |  Branch (686:25): [True: 1.56k, False: 328]
  ------------------
  687|  1.56k|        __m128i v_a, v_b;                //, v_bmax;
  688|       |        // we load a vector from A and a vector from B
  689|  1.56k|        v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  690|  1.56k|        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.56k|        __m128i runningmask_a_found_in_b = _mm_setzero_si128();
  694|       |        /****
  695|       |         * start of the main vectorized loop
  696|       |         *****/
  697|  46.9k|        while (true) {
  ------------------
  |  Branch (697:16): [True: 46.9k, Folded]
  ------------------
  698|       |            // afoundinb will contain a mask indicate for each entry in A
  699|       |            // whether it is seen
  700|       |            // in B
  701|  46.9k|            const __m128i a_found_in_b = _mm_cmpistrm(
  702|  46.9k|                v_b, v_a,
  703|  46.9k|                _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  704|  46.9k|            runningmask_a_found_in_b =
  705|  46.9k|                _mm_or_si128(runningmask_a_found_in_b, a_found_in_b);
  706|       |            // we always compare the last values of A and B
  707|  46.9k|            const uint16_t a_max = A[i_a + vectorlength - 1];
  708|  46.9k|            const uint16_t b_max = B[i_b + vectorlength - 1];
  709|  46.9k|            if (a_max <= b_max) {
  ------------------
  |  Branch (709:17): [True: 20.6k, False: 26.3k]
  ------------------
  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|  20.6k|                const int bitmask_belongs_to_difference =
  714|  20.6k|                    _mm_extract_epi32(runningmask_a_found_in_b, 0) ^ 0xFF;
  715|       |                /*** next few lines are probably expensive *****/
  716|  20.6k|                __m128i sm16 = _mm_loadu_si128((const __m128i *)shuffle_mask16 +
  717|  20.6k|                                               bitmask_belongs_to_difference);
  718|  20.6k|                __m128i p = _mm_shuffle_epi8(v_a, sm16);
  719|  20.6k|                _mm_storeu_si128((__m128i *)&C[count], p);  // can overflow
  720|  20.6k|                count += _mm_popcnt_u32(bitmask_belongs_to_difference);
  721|       |                // we advance a
  722|  20.6k|                i_a += vectorlength;
  723|  20.6k|                if (i_a == st_a)  // no more
  ------------------
  |  Branch (723:21): [True: 1.15k, False: 19.5k]
  ------------------
  724|  1.15k|                    break;
  725|  19.5k|                runningmask_a_found_in_b = _mm_setzero_si128();
  726|  19.5k|                v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  727|  19.5k|            }
  728|  45.8k|            if (b_max <= a_max) {
  ------------------
  |  Branch (728:17): [True: 29.4k, False: 16.4k]
  ------------------
  729|       |                // in this code path, the current v_b has become useless
  730|  29.4k|                i_b += vectorlength;
  731|  29.4k|                if (i_b == st_b) break;
  ------------------
  |  Branch (731:21): [True: 418, False: 29.0k]
  ------------------
  732|  29.0k|                v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  733|  29.0k|            }
  734|  45.8k|        }
  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.56k|        if (i_a < st_a) {        // we have unfinished business...
  ------------------
  |  Branch (739:13): [True: 418, False: 1.15k]
  ------------------
  740|    418|            uint16_t buffer[8];  // buffer to do a masked load
  741|    418|            memset(buffer, 0, 8 * sizeof(uint16_t));
  742|    418|            memcpy(buffer, B + i_b, (s_b - i_b) * sizeof(uint16_t));
  743|    418|            v_b = _mm_lddqu_si128((__m128i *)buffer);
  744|    418|            const __m128i a_found_in_b = _mm_cmpistrm(
  745|    418|                v_b, v_a,
  746|    418|                _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  747|    418|            runningmask_a_found_in_b =
  748|    418|                _mm_or_si128(runningmask_a_found_in_b, a_found_in_b);
  749|    418|            const int bitmask_belongs_to_difference =
  750|    418|                _mm_extract_epi32(runningmask_a_found_in_b, 0) ^ 0xFF;
  751|    418|            __m128i sm16 = _mm_loadu_si128((const __m128i *)shuffle_mask16 +
  752|    418|                                           bitmask_belongs_to_difference);
  753|    418|            __m128i p = _mm_shuffle_epi8(v_a, sm16);
  754|    418|            _mm_storeu_si128((__m128i *)&C[count], p);  // can overflow
  755|    418|            count += _mm_popcnt_u32(bitmask_belongs_to_difference);
  756|    418|            i_a += vectorlength;
  757|    418|        }
  758|       |        // at this point we should have i_a == st_a and i_b == st_b
  759|  1.56k|    }
  760|       |    // do the tail using scalar code
  761|   116k|    while (i_a < s_a && i_b < s_b) {
  ------------------
  |  Branch (761:12): [True: 114k, False: 1.81k]
  |  Branch (761:25): [True: 114k, False: 511]
  ------------------
  762|   114k|        uint16_t a = A[i_a];
  763|   114k|        uint16_t b = B[i_b];
  764|   114k|        if (b < a) {
  ------------------
  |  Branch (764:13): [True: 81.7k, False: 32.4k]
  ------------------
  765|  81.7k|            i_b++;
  766|  81.7k|        } else if (a < b) {
  ------------------
  |  Branch (766:20): [True: 26.9k, False: 5.54k]
  ------------------
  767|  26.9k|            C[count] = a;
  768|  26.9k|            count++;
  769|  26.9k|            i_a++;
  770|  26.9k|        } else {  //==
  771|  5.54k|            i_a++;
  772|  5.54k|            i_b++;
  773|  5.54k|        }
  774|   114k|    }
  775|  2.32k|    if (i_a < s_a) {
  ------------------
  |  Branch (775:9): [True: 511, False: 1.81k]
  ------------------
  776|    511|        if (C == A) {
  ------------------
  |  Branch (776:13): [True: 0, False: 511]
  ------------------
  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|    511|        } else {
  782|  27.7k|            for (size_t i = 0; i < (s_a - i_a); i++) {
  ------------------
  |  Branch (782:32): [True: 27.2k, False: 511]
  ------------------
  783|  27.2k|                C[count + i] = A[i + i_a];
  784|  27.2k|            }
  785|    511|        }
  786|    511|        count += (int32_t)(s_a - i_a);
  787|    511|    }
  788|  2.32k|    return count;
  789|  2.32k|}
intersect_skewed_uint16:
  855|    814|                                uint16_t *buffer) {
  856|    814|    size_t pos = 0, idx_l = 0, idx_s = 0;
  857|       |
  858|    814|    if (0 == size_s) {
  ------------------
  |  Branch (858:9): [True: 0, False: 814]
  ------------------
  859|      0|        return 0;
  860|      0|    }
  861|    814|    int32_t index1 = 0, index2 = 0, index3 = 0, index4 = 0;
  862|  2.16k|    while ((idx_s + 4 <= size_s) && (idx_l < size_l)) {
  ------------------
  |  Branch (862:12): [True: 1.34k, False: 814]
  |  Branch (862:37): [True: 1.34k, False: 0]
  ------------------
  863|  1.34k|        uint16_t target1 = small[idx_s];
  864|  1.34k|        uint16_t target2 = small[idx_s + 1];
  865|  1.34k|        uint16_t target3 = small[idx_s + 2];
  866|  1.34k|        uint16_t target4 = small[idx_s + 3];
  867|  1.34k|        binarySearch4(large + idx_l, (int32_t)(size_l - idx_l), target1,
  868|  1.34k|                      target2, target3, target4, &index1, &index2, &index3,
  869|  1.34k|                      &index4);
  870|  1.34k|        if ((index1 + idx_l < size_l) && (large[idx_l + index1] == target1)) {
  ------------------
  |  Branch (870:13): [True: 1.34k, False: 1]
  |  Branch (870:42): [True: 672, False: 674]
  ------------------
  871|    672|            buffer[pos++] = target1;
  872|    672|        }
  873|  1.34k|        if ((index2 + idx_l < size_l) && (large[idx_l + index2] == target2)) {
  ------------------
  |  Branch (873:13): [True: 1.34k, False: 2]
  |  Branch (873:42): [True: 830, False: 515]
  ------------------
  874|    830|            buffer[pos++] = target2;
  875|    830|        }
  876|  1.34k|        if ((index3 + idx_l < size_l) && (large[idx_l + index3] == target3)) {
  ------------------
  |  Branch (876:13): [True: 1.34k, False: 3]
  |  Branch (876:42): [True: 786, False: 558]
  ------------------
  877|    786|            buffer[pos++] = target3;
  878|    786|        }
  879|  1.34k|        if ((index4 + idx_l < size_l) && (large[idx_l + index4] == target4)) {
  ------------------
  |  Branch (879:13): [True: 1.34k, False: 5]
  |  Branch (879:42): [True: 758, False: 584]
  ------------------
  880|    758|            buffer[pos++] = target4;
  881|    758|        }
  882|  1.34k|        idx_s += 4;
  883|  1.34k|        idx_l += index4;
  884|  1.34k|    }
  885|    814|    if ((idx_s + 2 <= size_s) && (idx_l < size_l)) {
  ------------------
  |  Branch (885:9): [True: 420, False: 394]
  |  Branch (885:34): [True: 419, False: 1]
  ------------------
  886|    419|        uint16_t target1 = small[idx_s];
  887|    419|        uint16_t target2 = small[idx_s + 1];
  888|    419|        binarySearch2(large + idx_l, (int32_t)(size_l - idx_l), target1,
  889|    419|                      target2, &index1, &index2);
  890|    419|        if ((index1 + idx_l < size_l) && (large[idx_l + index1] == target1)) {
  ------------------
  |  Branch (890:13): [True: 415, False: 4]
  |  Branch (890:42): [True: 269, False: 146]
  ------------------
  891|    269|            buffer[pos++] = target1;
  892|    269|        }
  893|    419|        if ((index2 + idx_l < size_l) && (large[idx_l + index2] == target2)) {
  ------------------
  |  Branch (893:13): [True: 406, False: 13]
  |  Branch (893:42): [True: 277, False: 129]
  ------------------
  894|    277|            buffer[pos++] = target2;
  895|    277|        }
  896|    419|        idx_s += 2;
  897|    419|        idx_l += index2;
  898|    419|    }
  899|    814|    if ((idx_s < size_s) && (idx_l < size_l)) {
  ------------------
  |  Branch (899:9): [True: 398, False: 416]
  |  Branch (899:29): [True: 395, False: 3]
  ------------------
  900|    395|        uint16_t val_s = small[idx_s];
  901|    395|        int32_t index =
  902|    395|            binarySearch(large + idx_l, (int32_t)(size_l - idx_l), val_s);
  903|    395|        if (index >= 0) buffer[pos++] = val_s;
  ------------------
  |  Branch (903:13): [True: 287, False: 108]
  ------------------
  904|    395|    }
  905|    814|    return (int32_t)pos;
  906|    814|}
intersect_skewed_uint16_cardinality:
  912|  2.36k|                                            size_t size_l) {
  913|  2.36k|    size_t pos = 0, idx_l = 0, idx_s = 0;
  914|       |
  915|  2.36k|    if (0 == size_s) {
  ------------------
  |  Branch (915:9): [True: 0, False: 2.36k]
  ------------------
  916|      0|        return 0;
  917|      0|    }
  918|       |
  919|  2.36k|    uint16_t val_l = large[idx_l], val_s = small[idx_s];
  920|       |
  921|  30.6k|    while (true) {
  ------------------
  |  Branch (921:12): [True: 30.6k, Folded]
  ------------------
  922|  30.6k|        if (val_l < val_s) {
  ------------------
  |  Branch (922:13): [True: 6.08k, False: 24.5k]
  ------------------
  923|  6.08k|            idx_l = advanceUntil(large, (int32_t)idx_l, (int32_t)size_l, val_s);
  924|  6.08k|            if (idx_l == size_l) break;
  ------------------
  |  Branch (924:17): [True: 120, False: 5.96k]
  ------------------
  925|  5.96k|            val_l = large[idx_l];
  926|  24.5k|        } else if (val_s < val_l) {
  ------------------
  |  Branch (926:20): [True: 10.7k, False: 13.8k]
  ------------------
  927|  10.7k|            idx_s++;
  928|  10.7k|            if (idx_s == size_s) break;
  ------------------
  |  Branch (928:17): [True: 948, False: 9.78k]
  ------------------
  929|  9.78k|            val_s = small[idx_s];
  930|  13.8k|        } else {
  931|  13.8k|            pos++;
  932|  13.8k|            idx_s++;
  933|  13.8k|            if (idx_s == size_s) break;
  ------------------
  |  Branch (933:17): [True: 1.22k, False: 12.5k]
  ------------------
  934|  12.5k|            val_s = small[idx_s];
  935|  12.5k|            idx_l = advanceUntil(large, (int32_t)idx_l, (int32_t)size_l, val_s);
  936|  12.5k|            if (idx_l == size_l) break;
  ------------------
  |  Branch (936:17): [True: 80, False: 12.5k]
  ------------------
  937|  12.5k|            val_l = large[idx_l];
  938|  12.5k|        }
  939|  30.6k|    }
  940|       |
  941|  2.36k|    return (int32_t)pos;
  942|  2.36k|}
intersect_skewed_uint16_nonempty:
  945|    592|                                      const uint16_t *large, size_t size_l) {
  946|    592|    size_t idx_l = 0, idx_s = 0;
  947|       |
  948|    592|    if (0 == size_s) {
  ------------------
  |  Branch (948:9): [True: 0, False: 592]
  ------------------
  949|      0|        return false;
  950|      0|    }
  951|       |
  952|    592|    uint16_t val_l = large[idx_l], val_s = small[idx_s];
  953|       |
  954|  2.31k|    while (true) {
  ------------------
  |  Branch (954:12): [True: 2.31k, Folded]
  ------------------
  955|  2.31k|        if (val_l < val_s) {
  ------------------
  |  Branch (955:13): [True: 871, False: 1.44k]
  ------------------
  956|    871|            idx_l = advanceUntil(large, (int32_t)idx_l, (int32_t)size_l, val_s);
  957|    871|            if (idx_l == size_l) break;
  ------------------
  |  Branch (957:17): [True: 27, False: 844]
  ------------------
  958|    844|            val_l = large[idx_l];
  959|  1.44k|        } else if (val_s < val_l) {
  ------------------
  |  Branch (959:20): [True: 958, False: 483]
  ------------------
  960|    958|            idx_s++;
  961|    958|            if (idx_s == size_s) break;
  ------------------
  |  Branch (961:17): [True: 82, False: 876]
  ------------------
  962|    876|            val_s = small[idx_s];
  963|    876|        } else {
  964|    483|            return true;
  965|    483|        }
  966|  2.31k|    }
  967|       |
  968|    109|    return false;
  969|    592|}
intersect_uint16_nonempty:
 1025|  1.73k|                               const uint16_t *B, const size_t lenB) {
 1026|  1.73k|    if (lenA == 0 || lenB == 0) return 0;
  ------------------
  |  Branch (1026:9): [True: 0, False: 1.73k]
  |  Branch (1026:22): [True: 0, False: 1.73k]
  ------------------
 1027|  1.73k|    const uint16_t *endA = A + lenA;
 1028|  1.73k|    const uint16_t *endB = B + lenB;
 1029|       |
 1030|  1.73k|    while (1) {
  ------------------
  |  Branch (1030:12): [True: 1.73k, Folded]
  ------------------
 1031|  9.96k|        while (*A < *B) {
  ------------------
  |  Branch (1031:16): [True: 7.77k, False: 2.19k]
  ------------------
 1032|  8.27k|        SKIP_FIRST_COMPARE:
 1033|  8.27k|            if (++A == endA) return false;
  ------------------
  |  Branch (1033:17): [True: 39, False: 8.23k]
  ------------------
 1034|  8.27k|        }
 1035|  4.44k|        while (*A > *B) {
  ------------------
  |  Branch (1035:16): [True: 2.27k, False: 2.17k]
  ------------------
 1036|  2.27k|            if (++B == endB) return false;
  ------------------
  |  Branch (1036:17): [True: 12, False: 2.25k]
  ------------------
 1037|  2.27k|        }
 1038|  2.17k|        if (*A == *B) {
  ------------------
  |  Branch (1038:13): [True: 1.68k, False: 499]
  ------------------
 1039|  1.68k|            return true;
 1040|  1.68k|        } else {
 1041|    499|            goto SKIP_FIRST_COMPARE;
 1042|    499|        }
 1043|  2.17k|    }
 1044|      0|    return false;  // NOTREACHED
 1045|  1.73k|}
union_uint16:
 1105|  4.64k|                    size_t size_2, uint16_t *buffer) {
 1106|  4.64k|    size_t pos = 0, idx_1 = 0, idx_2 = 0;
 1107|       |
 1108|  4.64k|    if (0 == size_2) {
  ------------------
  |  Branch (1108:9): [True: 61, False: 4.58k]
  ------------------
 1109|     61|        memmove(buffer, set_1, size_1 * sizeof(uint16_t));
 1110|     61|        return size_1;
 1111|     61|    }
 1112|  4.58k|    if (0 == size_1) {
  ------------------
  |  Branch (1112:9): [True: 0, False: 4.58k]
  ------------------
 1113|      0|        memmove(buffer, set_2, size_2 * sizeof(uint16_t));
 1114|      0|        return size_2;
 1115|      0|    }
 1116|       |
 1117|  4.58k|    uint16_t val_1 = set_1[idx_1], val_2 = set_2[idx_2];
 1118|       |
 1119|   229k|    while (true) {
  ------------------
  |  Branch (1119:12): [True: 229k, Folded]
  ------------------
 1120|   229k|        if (val_1 < val_2) {
  ------------------
  |  Branch (1120:13): [True: 7.63k, False: 221k]
  ------------------
 1121|  7.63k|            buffer[pos++] = val_1;
 1122|  7.63k|            ++idx_1;
 1123|  7.63k|            if (idx_1 >= size_1) break;
  ------------------
  |  Branch (1123:17): [True: 397, False: 7.23k]
  ------------------
 1124|  7.23k|            val_1 = set_1[idx_1];
 1125|   221k|        } else if (val_2 < val_1) {
  ------------------
  |  Branch (1125:20): [True: 189k, False: 31.9k]
  ------------------
 1126|   189k|            buffer[pos++] = val_2;
 1127|   189k|            ++idx_2;
 1128|   189k|            if (idx_2 >= size_2) break;
  ------------------
  |  Branch (1128:17): [True: 189, False: 189k]
  ------------------
 1129|   189k|            val_2 = set_2[idx_2];
 1130|   189k|        } else {
 1131|  31.9k|            buffer[pos++] = val_1;
 1132|  31.9k|            ++idx_1;
 1133|  31.9k|            ++idx_2;
 1134|  31.9k|            if (idx_1 >= size_1 || idx_2 >= size_2) break;
  ------------------
  |  Branch (1134:17): [True: 3.88k, False: 28.0k]
  |  Branch (1134:36): [True: 113, False: 27.9k]
  ------------------
 1135|  27.9k|            val_1 = set_1[idx_1];
 1136|  27.9k|            val_2 = set_2[idx_2];
 1137|  27.9k|        }
 1138|   229k|    }
 1139|       |
 1140|  4.58k|    if (idx_1 < size_1) {
  ------------------
  |  Branch (1140:9): [True: 302, False: 4.28k]
  ------------------
 1141|    302|        const size_t n_elems = size_1 - idx_1;
 1142|    302|        memmove(buffer + pos, set_1 + idx_1, n_elems * sizeof(uint16_t));
 1143|    302|        pos += n_elems;
 1144|  4.28k|    } else if (idx_2 < size_2) {
  ------------------
  |  Branch (1144:16): [True: 1.83k, False: 2.45k]
  ------------------
 1145|  1.83k|        const size_t n_elems = size_2 - idx_2;
 1146|  1.83k|        memmove(buffer + pos, set_2 + idx_2, n_elems * sizeof(uint16_t));
 1147|  1.83k|        pos += n_elems;
 1148|  1.83k|    }
 1149|       |
 1150|  4.58k|    return pos;
 1151|  4.58k|}
difference_uint16:
 1154|  3.50k|                      int length2, uint16_t *a_out) {
 1155|  3.50k|    int out_card = 0;
 1156|  3.50k|    int k1 = 0, k2 = 0;
 1157|  3.50k|    if (length1 == 0) return 0;
  ------------------
  |  Branch (1157:9): [True: 0, False: 3.50k]
  ------------------
 1158|  3.50k|    if (length2 == 0) {
  ------------------
  |  Branch (1158:9): [True: 0, False: 3.50k]
  ------------------
 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.50k|    uint16_t s1 = a1[k1];
 1163|  3.50k|    uint16_t s2 = a2[k2];
 1164|   447k|    while (true) {
  ------------------
  |  Branch (1164:12): [True: 447k, Folded]
  ------------------
 1165|   447k|        if (s1 < s2) {
  ------------------
  |  Branch (1165:13): [True: 227k, False: 220k]
  ------------------
 1166|   227k|            a_out[out_card++] = s1;
 1167|   227k|            ++k1;
 1168|   227k|            if (k1 >= length1) {
  ------------------
  |  Branch (1168:17): [True: 0, False: 227k]
  ------------------
 1169|      0|                break;
 1170|      0|            }
 1171|   227k|            s1 = a1[k1];
 1172|   227k|        } else if (s1 == s2) {
  ------------------
  |  Branch (1172:20): [True: 220k, False: 0]
  ------------------
 1173|   220k|            ++k1;
 1174|   220k|            ++k2;
 1175|   220k|            if (k1 >= length1) {
  ------------------
  |  Branch (1175:17): [True: 2.27k, False: 218k]
  ------------------
 1176|  2.27k|                break;
 1177|  2.27k|            }
 1178|   218k|            if (k2 >= length2) {
  ------------------
  |  Branch (1178:17): [True: 1.23k, False: 217k]
  ------------------
 1179|  1.23k|                memmove(a_out + out_card, a1 + k1,
 1180|  1.23k|                        sizeof(uint16_t) * (length1 - k1));
 1181|  1.23k|                return out_card + length1 - k1;
 1182|  1.23k|            }
 1183|   217k|            s1 = a1[k1];
 1184|   217k|            s2 = a2[k2];
 1185|   217k|        } 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|   447k|    }
 1195|  2.27k|    return out_card;
 1196|  3.50k|}
xor_uint16:
 1199|  8.01k|                   const uint16_t *array_2, int32_t card_2, uint16_t *out) {
 1200|  8.01k|    int32_t pos1 = 0, pos2 = 0, pos_out = 0;
 1201|   230k|    while (pos1 < card_1 && pos2 < card_2) {
  ------------------
  |  Branch (1201:12): [True: 223k, False: 7.43k]
  |  Branch (1201:29): [True: 222k, False: 578]
  ------------------
 1202|   222k|        const uint16_t v1 = array_1[pos1];
 1203|   222k|        const uint16_t v2 = array_2[pos2];
 1204|   222k|        if (v1 == v2) {
  ------------------
  |  Branch (1204:13): [True: 40.0k, False: 182k]
  ------------------
 1205|  40.0k|            ++pos1;
 1206|  40.0k|            ++pos2;
 1207|  40.0k|            continue;
 1208|  40.0k|        }
 1209|   182k|        if (v1 < v2) {
  ------------------
  |  Branch (1209:13): [True: 32.1k, False: 150k]
  ------------------
 1210|  32.1k|            out[pos_out++] = v1;
 1211|  32.1k|            ++pos1;
 1212|   150k|        } else {
 1213|   150k|            out[pos_out++] = v2;
 1214|   150k|            ++pos2;
 1215|   150k|        }
 1216|   182k|    }
 1217|  8.01k|    if (pos1 < card_1) {
  ------------------
  |  Branch (1217:9): [True: 578, False: 7.43k]
  ------------------
 1218|    578|        const size_t n_elems = card_1 - pos1;
 1219|    578|        memcpy(out + pos_out, array_1 + pos1, n_elems * sizeof(uint16_t));
 1220|    578|        pos_out += (int32_t)n_elems;
 1221|  7.43k|    } else if (pos2 < card_2) {
  ------------------
  |  Branch (1221:16): [True: 2.27k, False: 5.15k]
  ------------------
 1222|  2.27k|        const size_t n_elems = card_2 - pos2;
 1223|  2.27k|        memcpy(out + pos_out, array_2 + pos2, n_elems * sizeof(uint16_t));
 1224|  2.27k|        pos_out += (int32_t)n_elems;
 1225|  2.27k|    }
 1226|  8.01k|    return pos_out;
 1227|  8.01k|}
union_vector16:
 1654|  4.64k|                        uint16_t *output) {
 1655|  4.64k|    if ((length1 < 8) || (length2 < 8)) {
  ------------------
  |  Branch (1655:9): [True: 1.08k, False: 3.56k]
  |  Branch (1655:26): [True: 0, False: 3.56k]
  ------------------
 1656|  1.08k|        return (uint32_t)union_uint16(array1, length1, array2, length2, output);
 1657|  1.08k|    }
 1658|  3.56k|    __m128i vA, vB, V, vecMin, vecMax;
 1659|  3.56k|    __m128i laststore;
 1660|  3.56k|    uint16_t *initoutput = output;
 1661|  3.56k|    uint32_t len1 = length1 / 8;
 1662|  3.56k|    uint32_t len2 = length2 / 8;
 1663|  3.56k|    uint32_t pos1 = 0;
 1664|  3.56k|    uint32_t pos2 = 0;
 1665|       |    // we start the machine
 1666|  3.56k|    vA = _mm_lddqu_si128((const __m128i *)array1 + pos1);
 1667|  3.56k|    pos1++;
 1668|  3.56k|    vB = _mm_lddqu_si128((const __m128i *)array2 + pos2);
 1669|  3.56k|    pos2++;
 1670|  3.56k|    sse_merge(&vA, &vB, &vecMin, &vecMax);
 1671|  3.56k|    laststore = _mm_set1_epi16(-1);
 1672|  3.56k|    output += store_unique(laststore, vecMin, output);
 1673|  3.56k|    laststore = vecMin;
 1674|  3.56k|    if ((pos1 < len1) && (pos2 < len2)) {
  ------------------
  |  Branch (1674:9): [True: 3.04k, False: 525]
  |  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|   104k|        while (true) {
  ------------------
  |  Branch (1678:16): [True: 104k, Folded]
  ------------------
 1679|   104k|            if (curA <= curB) {
  ------------------
  |  Branch (1679:17): [True: 44.3k, False: 60.3k]
  ------------------
 1680|  44.3k|                V = _mm_lddqu_si128((const __m128i *)array1 + pos1);
 1681|  44.3k|                pos1++;
 1682|  44.3k|                if (pos1 < len1) {
  ------------------
  |  Branch (1682:21): [True: 42.0k, False: 2.27k]
  ------------------
 1683|  42.0k|                    curA = array1[8 * pos1];
 1684|  42.0k|                } else {
 1685|  2.27k|                    break;
 1686|  2.27k|                }
 1687|  60.3k|            } else {
 1688|  60.3k|                V = _mm_lddqu_si128((const __m128i *)array2 + pos2);
 1689|  60.3k|                pos2++;
 1690|  60.3k|                if (pos2 < len2) {
  ------------------
  |  Branch (1690:21): [True: 59.5k, False: 771]
  ------------------
 1691|  59.5k|                    curB = array2[8 * pos2];
 1692|  59.5k|                } else {
 1693|    771|                    break;
 1694|    771|                }
 1695|  60.3k|            }
 1696|   101k|            sse_merge(&V, &vecMax, &vecMin, &vecMax);
 1697|   101k|            output += store_unique(laststore, vecMin, output);
 1698|   101k|            laststore = vecMin;
 1699|   101k|        }
 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.56k|    uint32_t len = (uint32_t)(output - initoutput);
 1709|  3.56k|    uint16_t buffer[16];
 1710|  3.56k|    uint32_t leftoversize = store_unique(laststore, vecMax, buffer);
 1711|  3.56k|    if (pos1 == len1) {
  ------------------
  |  Branch (1711:9): [True: 2.79k, False: 771]
  ------------------
 1712|  2.79k|        memcpy(buffer + leftoversize, array1 + 8 * pos1,
 1713|  2.79k|               (length1 - 8 * len1) * sizeof(uint16_t));
 1714|  2.79k|        leftoversize += length1 - 8 * len1;
 1715|  2.79k|        qsort(buffer, leftoversize, sizeof(uint16_t), uint16_compare);
 1716|       |
 1717|  2.79k|        leftoversize = unique(buffer, leftoversize);
 1718|  2.79k|        len += (uint32_t)union_uint16(buffer, leftoversize, array2 + 8 * pos2,
 1719|  2.79k|                                      length2 - 8 * pos2, output);
 1720|  2.79k|    } else {
 1721|    771|        memcpy(buffer + leftoversize, array2 + 8 * pos2,
 1722|    771|               (length2 - 8 * len2) * sizeof(uint16_t));
 1723|    771|        leftoversize += length2 - 8 * len2;
 1724|    771|        qsort(buffer, leftoversize, sizeof(uint16_t), uint16_compare);
 1725|    771|        leftoversize = unique(buffer, leftoversize);
 1726|    771|        len += (uint32_t)union_uint16(buffer, leftoversize, array1 + 8 * pos1,
 1727|    771|                                      length1 - 8 * pos1, output);
 1728|    771|    }
 1729|  3.56k|    return len;
 1730|  4.64k|}
xor_vector16:
 1778|  8.02k|                      uint16_t *output) {
 1779|  8.02k|    if ((length1 < 8) || (length2 < 8)) {
  ------------------
  |  Branch (1779:9): [True: 3.26k, False: 4.75k]
  |  Branch (1779:26): [True: 380, False: 4.37k]
  ------------------
 1780|  3.64k|        return xor_uint16(array1, length1, array2, length2, output);
 1781|  3.64k|    }
 1782|  4.37k|    __m128i vA, vB, V, vecMin, vecMax;
 1783|  4.37k|    __m128i laststore;
 1784|  4.37k|    uint16_t *initoutput = output;
 1785|  4.37k|    uint32_t len1 = length1 / 8;
 1786|  4.37k|    uint32_t len2 = length2 / 8;
 1787|  4.37k|    uint32_t pos1 = 0;
 1788|  4.37k|    uint32_t pos2 = 0;
 1789|       |    // we start the machine
 1790|  4.37k|    vA = _mm_lddqu_si128((const __m128i *)array1 + pos1);
 1791|  4.37k|    pos1++;
 1792|  4.37k|    vB = _mm_lddqu_si128((const __m128i *)array2 + pos2);
 1793|  4.37k|    pos2++;
 1794|  4.37k|    sse_merge(&vA, &vB, &vecMin, &vecMax);
 1795|  4.37k|    laststore = _mm_set1_epi16(-1);
 1796|  4.37k|    uint16_t buffer[17];
 1797|  4.37k|    output += store_unique_xor(laststore, vecMin, output);
 1798|       |
 1799|  4.37k|    laststore = vecMin;
 1800|  4.37k|    if ((pos1 < len1) && (pos2 < len2)) {
  ------------------
  |  Branch (1800:9): [True: 4.01k, False: 362]
  |  Branch (1800:26): [True: 3.90k, False: 108]
  ------------------
 1801|  3.90k|        uint16_t curA, curB;
 1802|  3.90k|        curA = array1[8 * pos1];
 1803|  3.90k|        curB = array2[8 * pos2];
 1804|   184k|        while (true) {
  ------------------
  |  Branch (1804:16): [True: 184k, Folded]
  ------------------
 1805|   184k|            if (curA <= curB) {
  ------------------
  |  Branch (1805:17): [True: 87.9k, False: 96.8k]
  ------------------
 1806|  87.9k|                V = _mm_lddqu_si128((const __m128i *)array1 + pos1);
 1807|  87.9k|                pos1++;
 1808|  87.9k|                if (pos1 < len1) {
  ------------------
  |  Branch (1808:21): [True: 85.3k, False: 2.60k]
  ------------------
 1809|  85.3k|                    curA = array1[8 * pos1];
 1810|  85.3k|                } else {
 1811|  2.60k|                    break;
 1812|  2.60k|                }
 1813|  96.8k|            } else {
 1814|  96.8k|                V = _mm_lddqu_si128((const __m128i *)array2 + pos2);
 1815|  96.8k|                pos2++;
 1816|  96.8k|                if (pos2 < len2) {
  ------------------
  |  Branch (1816:21): [True: 95.5k, False: 1.29k]
  ------------------
 1817|  95.5k|                    curB = array2[8 * pos2];
 1818|  95.5k|                } else {
 1819|  1.29k|                    break;
 1820|  1.29k|                }
 1821|  96.8k|            }
 1822|   180k|            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|   180k|            output += store_unique_xor(laststore, vecMin, output);
 1827|   180k|            laststore = vecMin;
 1828|   180k|        }
 1829|  3.90k|        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.90k|        output += store_unique_xor(laststore, vecMin, output);
 1834|  3.90k|        laststore = vecMin;
 1835|  3.90k|    }
 1836|  4.37k|    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.37k|    int leftoversize = store_unique_xor(laststore, vecMax, buffer);
 1844|  4.37k|    uint16_t vec7 = (uint16_t)_mm_extract_epi16(vecMax, 7);
 1845|  4.37k|    uint16_t vec6 = (uint16_t)_mm_extract_epi16(vecMax, 6);
 1846|  4.37k|    if (vec7 != vec6) buffer[leftoversize++] = vec7;
  ------------------
  |  Branch (1846:9): [True: 4.32k, False: 58]
  ------------------
 1847|  4.37k|    if (pos1 == len1) {
  ------------------
  |  Branch (1847:9): [True: 2.97k, False: 1.40k]
  ------------------
 1848|  2.97k|        memcpy(buffer + leftoversize, array1 + 8 * pos1,
 1849|  2.97k|               (length1 - 8 * len1) * sizeof(uint16_t));
 1850|  2.97k|        leftoversize += length1 - 8 * len1;
 1851|  2.97k|        if (leftoversize == 0) {  // trivial case
  ------------------
  |  Branch (1851:13): [True: 8, False: 2.96k]
  ------------------
 1852|      8|            memcpy(output, array2 + 8 * pos2,
 1853|      8|                   (length2 - 8 * pos2) * sizeof(uint16_t));
 1854|      8|            len += (length2 - 8 * pos2);
 1855|  2.96k|        } else {
 1856|  2.96k|            qsort(buffer, leftoversize, sizeof(uint16_t), uint16_compare);
 1857|  2.96k|            leftoversize = unique_xor(buffer, leftoversize);
 1858|  2.96k|            len += xor_uint16(buffer, leftoversize, array2 + 8 * pos2,
 1859|  2.96k|                              length2 - 8 * pos2, output);
 1860|  2.96k|        }
 1861|  2.97k|    } else {
 1862|  1.40k|        memcpy(buffer + leftoversize, array2 + 8 * pos2,
 1863|  1.40k|               (length2 - 8 * len2) * sizeof(uint16_t));
 1864|  1.40k|        leftoversize += length2 - 8 * len2;
 1865|  1.40k|        if (leftoversize == 0) {  // trivial case
  ------------------
  |  Branch (1865:13): [True: 1, False: 1.40k]
  ------------------
 1866|      1|            memcpy(output, array1 + 8 * pos1,
 1867|      1|                   (length1 - 8 * pos1) * sizeof(uint16_t));
 1868|      1|            len += (length1 - 8 * pos1);
 1869|  1.40k|        } else {
 1870|  1.40k|            qsort(buffer, leftoversize, sizeof(uint16_t), uint16_compare);
 1871|  1.40k|            leftoversize = unique_xor(buffer, leftoversize);
 1872|  1.40k|            len += xor_uint16(buffer, leftoversize, array1 + 8 * pos1,
 1873|  1.40k|                              length1 - 8 * pos1, output);
 1874|  1.40k|        }
 1875|  1.40k|    }
 1876|  4.37k|    return len;
 1877|  8.02k|}
fast_union_uint16:
 1980|  4.64k|                         uint16_t *buffer) {
 1981|  4.64k|#if CROARING_IS_X64
 1982|  4.64k|    if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (1982:9): [True: 4.64k, False: 0]
  ------------------
 1983|       |        // compute union with smallest array first
 1984|  4.64k|        if (size_1 < size_2) {
  ------------------
  |  Branch (1984:13): [True: 2.40k, False: 2.24k]
  ------------------
 1985|  2.40k|            return union_vector16(set_1, (uint32_t)size_1, set_2,
 1986|  2.40k|                                  (uint32_t)size_2, buffer);
 1987|  2.40k|        } 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.64k|    } 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.64k|}
memequals:
 2111|  7.30k|bool memequals(const void *s1, const void *s2, size_t n) {
 2112|  7.30k|    if (n == 0) {
  ------------------
  |  Branch (2112:9): [True: 0, False: 7.30k]
  ------------------
 2113|      0|        return true;
 2114|      0|    }
 2115|  7.30k|#if CROARING_IS_X64
 2116|  7.30k|    int support = croaring_hardware_support();
 2117|  7.30k|#if CROARING_COMPILER_SUPPORTS_AVX512
 2118|  7.30k|    if (support & ROARING_SUPPORTS_AVX512) {
  ------------------
  |  Branch (2118:9): [True: 0, False: 7.30k]
  ------------------
 2119|      0|        return _avx512_memequals(s1, s2, n);
 2120|      0|    } else
 2121|  7.30k|#endif  // CROARING_COMPILER_SUPPORTS_AVX512
 2122|  7.30k|        if (support & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (2122:13): [True: 7.30k, False: 0]
  ------------------
 2123|  7.30k|            return _avx2_memequals(s1, s2, n);
 2124|  7.30k|        } else {
 2125|      0|            return memcmp(s1, s2, n) == 0;
 2126|      0|        }
 2127|       |#else
 2128|       |    return memcmp(s1, s2, n) == 0;
 2129|       |#endif
 2130|  7.30k|}
array_util.c:binarySearch4:
  804|  1.34k|                          int32_t *index4) {
  805|  1.34k|    const uint16_t *base1 = array;
  806|  1.34k|    const uint16_t *base2 = array;
  807|  1.34k|    const uint16_t *base3 = array;
  808|  1.34k|    const uint16_t *base4 = array;
  809|  1.34k|    if (n == 0) return;
  ------------------
  |  Branch (809:9): [True: 0, False: 1.34k]
  ------------------
  810|  16.7k|    while (n > 1) {
  ------------------
  |  Branch (810:12): [True: 15.4k, False: 1.34k]
  ------------------
  811|  15.4k|        int32_t half = n >> 1;
  812|  15.4k|        base1 = (base1[half] < target1) ? &base1[half] : base1;
  ------------------
  |  Branch (812:17): [True: 1.25k, False: 14.1k]
  ------------------
  813|  15.4k|        base2 = (base2[half] < target2) ? &base2[half] : base2;
  ------------------
  |  Branch (813:17): [True: 2.27k, False: 13.1k]
  ------------------
  814|  15.4k|        base3 = (base3[half] < target3) ? &base3[half] : base3;
  ------------------
  |  Branch (814:17): [True: 2.96k, False: 12.4k]
  ------------------
  815|  15.4k|        base4 = (base4[half] < target4) ? &base4[half] : base4;
  ------------------
  |  Branch (815:17): [True: 3.47k, False: 11.9k]
  ------------------
  816|  15.4k|        n -= half;
  817|  15.4k|    }
  818|  1.34k|    *index1 = (int32_t)((*base1 < target1) + base1 - array);
  819|  1.34k|    *index2 = (int32_t)((*base2 < target2) + base2 - array);
  820|  1.34k|    *index3 = (int32_t)((*base3 < target3) + base3 - array);
  821|  1.34k|    *index4 = (int32_t)((*base4 < target4) + base4 - array);
  822|  1.34k|}
array_util.c:binarySearch2:
  833|    419|                          uint16_t target2, int32_t *index1, int32_t *index2) {
  834|    419|    const uint16_t *base1 = array;
  835|    419|    const uint16_t *base2 = array;
  836|    419|    if (n == 0) return;
  ------------------
  |  Branch (836:9): [True: 0, False: 419]
  ------------------
  837|  3.97k|    while (n > 1) {
  ------------------
  |  Branch (837:12): [True: 3.55k, False: 419]
  ------------------
  838|  3.55k|        int32_t half = n >> 1;
  839|  3.55k|        base1 = (base1[half] < target1) ? &base1[half] : base1;
  ------------------
  |  Branch (839:17): [True: 858, False: 2.69k]
  ------------------
  840|  3.55k|        base2 = (base2[half] < target2) ? &base2[half] : base2;
  ------------------
  |  Branch (840:17): [True: 1.43k, False: 2.12k]
  ------------------
  841|  3.55k|        n -= half;
  842|  3.55k|    }
  843|    419|    *index1 = (int32_t)((*base1 < target1) + base1 - array);
  844|    419|    *index2 = (int32_t)((*base2 < target2) + base2 - array);
  845|    419|}
array_util.c:sse_merge:
 1244|   297k|                             __m128i *vecMin, __m128i *vecMax) {  // output
 1245|   297k|    __m128i vecTmp;
 1246|   297k|    vecTmp = _mm_min_epu16(*vInput1, *vInput2);
 1247|   297k|    *vecMax = _mm_max_epu16(*vInput1, *vInput2);
 1248|   297k|    vecTmp = _mm_alignr_epi8(vecTmp, vecTmp, 2);
 1249|   297k|    *vecMin = _mm_min_epu16(vecTmp, *vecMax);
 1250|   297k|    *vecMax = _mm_max_epu16(vecTmp, *vecMax);
 1251|   297k|    vecTmp = _mm_alignr_epi8(*vecMin, *vecMin, 2);
 1252|   297k|    *vecMin = _mm_min_epu16(vecTmp, *vecMax);
 1253|   297k|    *vecMax = _mm_max_epu16(vecTmp, *vecMax);
 1254|   297k|    vecTmp = _mm_alignr_epi8(*vecMin, *vecMin, 2);
 1255|   297k|    *vecMin = _mm_min_epu16(vecTmp, *vecMax);
 1256|   297k|    *vecMax = _mm_max_epu16(vecTmp, *vecMax);
 1257|   297k|    vecTmp = _mm_alignr_epi8(*vecMin, *vecMin, 2);
 1258|   297k|    *vecMin = _mm_min_epu16(vecTmp, *vecMax);
 1259|   297k|    *vecMax = _mm_max_epu16(vecTmp, *vecMax);
 1260|   297k|    vecTmp = _mm_alignr_epi8(*vecMin, *vecMin, 2);
 1261|   297k|    *vecMin = _mm_min_epu16(vecTmp, *vecMax);
 1262|   297k|    *vecMax = _mm_max_epu16(vecTmp, *vecMax);
 1263|   297k|    vecTmp = _mm_alignr_epi8(*vecMin, *vecMin, 2);
 1264|   297k|    *vecMin = _mm_min_epu16(vecTmp, *vecMax);
 1265|   297k|    *vecMax = _mm_max_epu16(vecTmp, *vecMax);
 1266|   297k|    vecTmp = _mm_alignr_epi8(*vecMin, *vecMin, 2);
 1267|   297k|    *vecMin = _mm_min_epu16(vecTmp, *vecMax);
 1268|   297k|    *vecMax = _mm_max_epu16(vecTmp, *vecMax);
 1269|       |    *vecMin = _mm_alignr_epi8(*vecMin, *vecMin, 2);
 1270|   297k|}
array_util.c:store_unique:
 1619|   111k|static inline int store_unique(__m128i old, __m128i newval, uint16_t *output) {
 1620|   111k|    __m128i vecTmp = _mm_alignr_epi8(newval, old, 16 - 2);
 1621|       |    // lots of high latency instructions follow (optimize?)
 1622|   111k|    int M = _mm_movemask_epi8(
 1623|   111k|        _mm_packs_epi16(_mm_cmpeq_epi16(vecTmp, newval), _mm_setzero_si128()));
 1624|   111k|    int numberofnewvalues = 8 - _mm_popcnt_u32(M);
 1625|   111k|    __m128i key = _mm_lddqu_si128((const __m128i *)uniqshuf + M);
 1626|   111k|    __m128i val = _mm_shuffle_epi8(newval, key);
 1627|   111k|    _mm_storeu_si128((__m128i *)output, val);
 1628|   111k|    return numberofnewvalues;
 1629|   111k|}
array_util.c:uint16_compare:
 1645|   127k|static int uint16_compare(const void *a, const void *b) {
 1646|   127k|    return (*(uint16_t *)a - *(uint16_t *)b);
 1647|   127k|}
array_util.c:unique:
 1634|  3.56k|static inline uint32_t unique(uint16_t *out, uint32_t len) {
 1635|  3.56k|    uint32_t pos = 1;
 1636|  36.5k|    for (uint32_t i = 1; i < len; ++i) {
  ------------------
  |  Branch (1636:26): [True: 32.9k, False: 3.56k]
  ------------------
 1637|  32.9k|        if (out[i] != out[i - 1]) {
  ------------------
  |  Branch (1637:13): [True: 32.8k, False: 86]
  ------------------
 1638|  32.8k|            out[pos++] = out[i];
 1639|  32.8k|        }
 1640|  32.9k|    }
 1641|  3.56k|    return pos;
 1642|  3.56k|}
array_util.c:store_unique_xor:
 1746|   193k|                                   uint16_t *output) {
 1747|   193k|    __m128i vecTmp1 = _mm_alignr_epi8(newval, old, 16 - 4);
 1748|       |    __m128i vecTmp2 = _mm_alignr_epi8(newval, old, 16 - 2);
 1749|   193k|    __m128i equalleft = _mm_cmpeq_epi16(vecTmp2, vecTmp1);
 1750|   193k|    __m128i equalright = _mm_cmpeq_epi16(vecTmp2, newval);
 1751|   193k|    __m128i equalleftoright = _mm_or_si128(equalleft, equalright);
 1752|   193k|    int M = _mm_movemask_epi8(
 1753|   193k|        _mm_packs_epi16(equalleftoright, _mm_setzero_si128()));
 1754|   193k|    int numberofnewvalues = 8 - _mm_popcnt_u32(M);
 1755|   193k|    __m128i key = _mm_lddqu_si128((const __m128i *)uniqshuf + M);
 1756|   193k|    __m128i val = _mm_shuffle_epi8(vecTmp2, key);
 1757|   193k|    _mm_storeu_si128((__m128i *)output, val);
 1758|   193k|    return numberofnewvalues;
 1759|   193k|}
array_util.c:unique_xor:
 1764|  4.36k|static inline uint32_t unique_xor(uint16_t *out, uint32_t len) {
 1765|  4.36k|    uint32_t pos = 1;
 1766|  43.6k|    for (uint32_t i = 1; i < len; ++i) {
  ------------------
  |  Branch (1766:26): [True: 39.2k, False: 4.36k]
  ------------------
 1767|  39.2k|        if (out[i] != out[i - 1]) {
  ------------------
  |  Branch (1767:13): [True: 39.0k, False: 215]
  ------------------
 1768|  39.0k|            out[pos++] = out[i];
 1769|  39.0k|        } else
 1770|    215|            pos--;  // if it is identical to previous, delete it
 1771|  39.2k|    }
 1772|  4.36k|    return pos;
 1773|  4.36k|}
array_util.c:_avx2_memequals:
 2069|  7.30k|static inline bool _avx2_memequals(const void *s1, const void *s2, size_t n) {
 2070|  7.30k|    const uint8_t *ptr1 = (const uint8_t *)s1;
 2071|  7.30k|    const uint8_t *ptr2 = (const uint8_t *)s2;
 2072|  7.30k|    const uint8_t *end1 = ptr1 + n;
 2073|  7.30k|    const uint8_t *end8 = ptr1 + n / 8 * 8;
 2074|  7.30k|    const uint8_t *end32 = ptr1 + n / 32 * 32;
 2075|       |
 2076|   137k|    while (ptr1 < end32) {
  ------------------
  |  Branch (2076:12): [True: 130k, False: 7.24k]
  ------------------
 2077|   130k|        __m256i r1 = _mm256_loadu_si256((const __m256i *)ptr1);
 2078|   130k|        __m256i r2 = _mm256_loadu_si256((const __m256i *)ptr2);
 2079|   130k|        int mask = _mm256_movemask_epi8(_mm256_cmpeq_epi8(r1, r2));
 2080|   130k|        if ((uint32_t)mask != UINT32_MAX) {
  ------------------
  |  Branch (2080:13): [True: 63, False: 129k]
  ------------------
 2081|     63|            return false;
 2082|     63|        }
 2083|   129k|        ptr1 += 32;
 2084|   129k|        ptr2 += 32;
 2085|   129k|    }
 2086|       |
 2087|  13.0k|    while (ptr1 < end8) {
  ------------------
  |  Branch (2087:12): [True: 5.88k, False: 7.16k]
  ------------------
 2088|  5.88k|        uint64_t v1, v2;
 2089|  5.88k|        memcpy(&v1, ptr1, sizeof(uint64_t));
 2090|  5.88k|        memcpy(&v2, ptr2, sizeof(uint64_t));
 2091|  5.88k|        if (v1 != v2) {
  ------------------
  |  Branch (2091:13): [True: 82, False: 5.79k]
  ------------------
 2092|     82|            return false;
 2093|     82|        }
 2094|  5.79k|        ptr1 += 8;
 2095|  5.79k|        ptr2 += 8;
 2096|  5.79k|    }
 2097|       |
 2098|  25.5k|    while (ptr1 < end1) {
  ------------------
  |  Branch (2098:12): [True: 18.3k, False: 7.12k]
  ------------------
 2099|  18.3k|        if (*ptr1 != *ptr2) {
  ------------------
  |  Branch (2099:13): [True: 38, False: 18.3k]
  ------------------
 2100|     38|            return false;
 2101|     38|        }
 2102|  18.3k|        ptr1++;
 2103|  18.3k|        ptr2++;
 2104|  18.3k|    }
 2105|       |
 2106|  7.12k|    return true;
 2107|  7.16k|}

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

array_container_create_given_capacity:
   49|   148k|array_container_t *array_container_create_given_capacity(int32_t size) {
   50|   148k|    array_container_t *container;
   51|       |
   52|   148k|    if ((container = (array_container_t *)roaring_malloc(
  ------------------
  |  Branch (52:9): [True: 0, False: 148k]
  ------------------
   53|   148k|             sizeof(array_container_t))) == NULL) {
   54|      0|        return NULL;
   55|      0|    }
   56|       |
   57|   148k|    if (size <= 0) {  // we don't want to rely on malloc(0)
  ------------------
  |  Branch (57:9): [True: 91.8k, False: 56.4k]
  ------------------
   58|  91.8k|        container->array = NULL;
   59|  91.8k|    } else if ((container->array = (uint16_t *)roaring_malloc(sizeof(uint16_t) *
  ------------------
  |  Branch (59:16): [True: 0, False: 56.4k]
  ------------------
   60|  56.4k|                                                              size)) == NULL) {
   61|      0|        roaring_free(container);
   62|      0|        return NULL;
   63|      0|    }
   64|       |
   65|   148k|    container->capacity = size;
   66|   148k|    container->cardinality = 0;
   67|       |
   68|   148k|    return container;
   69|   148k|}
array_container_create:
   72|  26.2k|array_container_t *array_container_create(void) {
   73|  26.2k|    return array_container_create_given_capacity(ARRAY_DEFAULT_INIT_SIZE);
   74|  26.2k|}
array_container_create_range:
   77|    124|array_container_t *array_container_create_range(uint32_t min, uint32_t max) {
   78|    124|    array_container_t *answer =
   79|    124|        array_container_create_given_capacity(max - min + 1);
   80|    124|    if (answer == NULL) return answer;
  ------------------
  |  Branch (80:9): [True: 0, False: 124]
  ------------------
   81|    124|    answer->cardinality = 0;
   82|    248|    for (uint32_t k = min; k < max; k++) {
  ------------------
  |  Branch (82:28): [True: 124, False: 124]
  ------------------
   83|    124|        answer->array[answer->cardinality++] = k;
   84|    124|    }
   85|    124|    return answer;
   86|    124|}
array_container_clone:
   90|  22.9k|array_container_t *array_container_clone(const array_container_t *src) {
   91|  22.9k|    array_container_t *newcontainer =
   92|  22.9k|        array_container_create_given_capacity(src->capacity);
   93|  22.9k|    if (newcontainer == NULL) return NULL;
  ------------------
  |  Branch (93:9): [True: 0, False: 22.9k]
  ------------------
   94|       |
   95|  22.9k|    newcontainer->cardinality = src->cardinality;
   96|       |
   97|  22.9k|    memcpy(newcontainer->array, src->array,
   98|  22.9k|           src->cardinality * sizeof(uint16_t));
   99|       |
  100|  22.9k|    return newcontainer;
  101|  22.9k|}
array_container_shrink_to_fit:
  131|  3.82k|int array_container_shrink_to_fit(array_container_t *src) {
  132|  3.82k|    if (src->cardinality == src->capacity) return 0;  // nothing to do
  ------------------
  |  Branch (132:9): [True: 499, False: 3.32k]
  ------------------
  133|  3.32k|    int savings = src->capacity - src->cardinality;
  134|  3.32k|    src->capacity = src->cardinality;
  135|  3.32k|    if (src->capacity ==
  ------------------
  |  Branch (135:9): [True: 0, False: 3.32k]
  ------------------
  136|  3.32k|        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.32k|    } else {
  140|  3.32k|        uint16_t *oldarray = src->array;
  141|  3.32k|        src->array = (uint16_t *)roaring_realloc(
  142|  3.32k|            oldarray, src->capacity * sizeof(uint16_t));
  143|  3.32k|        if (src->array == NULL) roaring_free(oldarray);  // should never happen?
  ------------------
  |  Branch (143:13): [True: 0, False: 3.32k]
  ------------------
  144|  3.32k|    }
  145|  3.32k|    return savings;
  146|  3.82k|}
array_container_free:
  149|   148k|void array_container_free(array_container_t *arr) {
  150|   148k|    if (arr == NULL) return;
  ------------------
  |  Branch (150:9): [True: 0, False: 148k]
  ------------------
  151|   148k|    roaring_free(arr->array);
  152|   148k|    roaring_free(arr);
  153|   148k|}
array_container_grow:
  167|   120k|                          bool preserve) {
  168|   120k|    int32_t max = (min <= DEFAULT_MAX_SIZE ? DEFAULT_MAX_SIZE : 65536);
  ------------------
  |  Branch (168:20): [True: 120k, False: 0]
  ------------------
  169|   120k|    int32_t new_capacity = clamp(grow_capacity(container->capacity), min, max);
  170|       |
  171|   120k|    container->capacity = new_capacity;
  172|   120k|    uint16_t *array = container->array;
  173|       |
  174|   120k|    if (preserve) {
  ------------------
  |  Branch (174:9): [True: 110k, False: 10.0k]
  ------------------
  175|   110k|        container->array =
  176|   110k|            (uint16_t *)roaring_realloc(array, new_capacity * sizeof(uint16_t));
  177|   110k|        if (container->array == NULL) roaring_free(array);
  ------------------
  |  Branch (177:13): [True: 0, False: 110k]
  ------------------
  178|   110k|    } 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|   120k|}
array_container_copy:
  189|     25|                          array_container_t *dst) {
  190|     25|    const int32_t cardinality = src->cardinality;
  191|     25|    if (cardinality > dst->capacity) {
  ------------------
  |  Branch (191:9): [True: 25, False: 0]
  ------------------
  192|     25|        array_container_grow(dst, cardinality, false);
  193|     25|    }
  194|       |
  195|     25|    dst->cardinality = cardinality;
  196|     25|    memcpy(dst->array, src->array, cardinality * sizeof(uint16_t));
  197|     25|}
array_container_union:
  211|  4.64k|                           array_container_t *out) {
  212|  4.64k|    const int32_t card_1 = array_1->cardinality, card_2 = array_2->cardinality;
  213|  4.64k|    const int32_t max_cardinality = card_1 + card_2;
  214|       |
  215|  4.64k|    if (out->capacity < max_cardinality) {
  ------------------
  |  Branch (215:9): [True: 0, False: 4.64k]
  ------------------
  216|       |        array_container_grow(out, max_cardinality, false);
  217|      0|    }
  218|  4.64k|    out->cardinality = (int32_t)fast_union_uint16(
  219|  4.64k|        array_1->array, card_1, array_2->array, card_2, out->array);
  220|  4.64k|}
array_container_andnot:
  228|  5.83k|                            array_container_t *out) {
  229|  5.83k|    if (out->capacity < array_1->cardinality)
  ------------------
  |  Branch (229:9): [True: 2.32k, False: 3.50k]
  ------------------
  230|  2.32k|        array_container_grow(out, array_1->cardinality, false);
  231|  5.83k|#if CROARING_IS_X64
  232|  5.83k|    if ((croaring_hardware_support() & ROARING_SUPPORTS_AVX2) &&
  ------------------
  |  Branch (232:9): [True: 5.83k, False: 0]
  ------------------
  233|  5.83k|        (out != array_1) && (out != array_2)) {
  ------------------
  |  Branch (233:9): [True: 2.32k, False: 3.50k]
  |  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.50k|    } else {
  238|  3.50k|        out->cardinality =
  239|  3.50k|            difference_uint16(array_1->array, array_1->cardinality,
  240|  3.50k|                              array_2->array, array_2->cardinality, out->array);
  241|  3.50k|    }
  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.83k|}
array_container_xor:
  256|  8.02k|                         array_container_t *out) {
  257|  8.02k|    const int32_t card_1 = array_1->cardinality, card_2 = array_2->cardinality;
  258|  8.02k|    const int32_t max_cardinality = card_1 + card_2;
  259|  8.02k|    if (out->capacity < max_cardinality) {
  ------------------
  |  Branch (259:9): [True: 0, False: 8.02k]
  ------------------
  260|      0|        array_container_grow(out, max_cardinality, false);
  261|      0|    }
  262|       |
  263|  8.02k|#if CROARING_IS_X64
  264|  8.02k|    if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (264:9): [True: 8.02k, False: 0]
  ------------------
  265|  8.02k|        out->cardinality =
  266|  8.02k|            xor_vector16(array_1->array, array_1->cardinality, array_2->array,
  267|  8.02k|                         array_2->cardinality, out->array);
  268|  8.02k|    } 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.02k|}
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: 378, False: 1.94k]
  ------------------
  306|    378|        out->cardinality = intersect_skewed_uint16(
  307|    378|            array1->array, card_1, array2->array, card_2, out->array);
  308|  1.94k|    } else if (card_2 * threshold < card_1) {
  ------------------
  |  Branch (308:16): [True: 214, False: 1.73k]
  ------------------
  309|    214|        out->cardinality = intersect_skewed_uint16(
  310|    214|            array2->array, card_2, array1->array, card_1, out->array);
  311|  1.73k|    } else {
  312|  1.73k|#if CROARING_IS_X64
  313|  1.73k|        if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (313:13): [True: 1.73k, False: 0]
  ------------------
  314|  1.73k|            out->cardinality = intersect_vector16(
  315|  1.73k|                array1->array, card_1, array2->array, card_2, out->array);
  316|  1.73k|        } 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.73k|    }
  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.51k, False: 7.78k]
  ------------------
  334|  1.51k|        return intersect_skewed_uint16_cardinality(array1->array, card_1,
  335|  1.51k|                                                   array2->array, card_2);
  336|  7.78k|    } else if (card_2 * threshold < card_1) {
  ------------------
  |  Branch (336:16): [True: 856, False: 6.92k]
  ------------------
  337|    856|        return intersect_skewed_uint16_cardinality(array2->array, card_2,
  338|    856|                                                   array1->array, card_1);
  339|  6.92k|    } else {
  340|  6.92k|#if CROARING_IS_X64
  341|  6.92k|        if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (341:13): [True: 6.92k, False: 0]
  ------------------
  342|  6.92k|            return intersect_vector16_cardinality(array1->array, card_1,
  343|  6.92k|                                                  array2->array, card_2);
  344|  6.92k|        } 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|  6.92k|    }
  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: 378, False: 1.94k]
  ------------------
  360|    378|        return intersect_skewed_uint16_nonempty(array1->array, card_1,
  361|    378|                                                array2->array, card_2);
  362|  1.94k|    } else if (card_2 * threshold < card_1) {
  ------------------
  |  Branch (362:16): [True: 214, False: 1.73k]
  ------------------
  363|    214|        return intersect_skewed_uint16_nonempty(array2->array, card_2,
  364|    214|                                                array1->array, card_1);
  365|  1.73k|    } else {
  366|       |        // we do not bother vectorizing
  367|  1.73k|        return intersect_uint16_nonempty(array1->array, card_1, array2->array,
  368|  1.73k|                                         card_2);
  369|  1.73k|    }
  370|  2.32k|}
array_container_intersection_inplace:
  376|  4.84k|                                          const array_container_t *src_2) {
  377|  4.84k|    int32_t card_1 = src_1->cardinality, card_2 = src_2->cardinality;
  378|  4.84k|    const int threshold = 64;  // subject to tuning
  379|  4.84k|    if (card_1 * threshold < card_2) {
  ------------------
  |  Branch (379:9): [True: 0, False: 4.84k]
  ------------------
  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.84k|    } else if (card_2 * threshold < card_1) {
  ------------------
  |  Branch (382:16): [True: 222, False: 4.61k]
  ------------------
  383|    222|        src_1->cardinality = intersect_skewed_uint16(
  384|    222|            src_2->array, card_2, src_1->array, card_1, src_1->array);
  385|  4.61k|    } else {
  386|  4.61k|#if CROARING_IS_X64
  387|  4.61k|        if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (387:13): [True: 4.61k, False: 0]
  ------------------
  388|  4.61k|            src_1->cardinality = intersect_vector16_inplace(
  389|  4.61k|                src_1->array, card_1, src_2->array, card_2);
  390|  4.61k|        } 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.61k|    }
  399|  4.84k|}
array_container_to_uint32_array:
  403|  5.91k|                                    uint32_t base) {
  404|  5.91k|#if CROARING_IS_X64
  405|  5.91k|    int support = croaring_hardware_support();
  406|  5.91k|#if CROARING_COMPILER_SUPPORTS_AVX512
  407|  5.91k|    if (support & ROARING_SUPPORTS_AVX512) {
  ------------------
  |  Branch (407:9): [True: 0, False: 5.91k]
  ------------------
  408|      0|        return avx512_array_container_to_uint32_array(vout, cont->array,
  409|      0|                                                      cont->cardinality, base);
  410|      0|    }
  411|  5.91k|#endif
  412|  5.91k|    if (support & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (412:9): [True: 5.91k, False: 0]
  ------------------
  413|  5.91k|        return array_container_to_uint32_array_vector16(
  414|  5.91k|            vout, cont->array, cont->cardinality, base);
  415|  5.91k|    }
  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.91k|}
array_container_number_of_runs:
  495|  12.8k|int32_t array_container_number_of_runs(const array_container_t *ac) {
  496|       |    // Can SIMD work here?
  497|  12.8k|    int32_t nr_runs = 0;
  498|  12.8k|    int32_t prev = -2;
  499|  1.63M|    for (const uint16_t *p = ac->array; p != ac->array + ac->cardinality; ++p) {
  ------------------
  |  Branch (499:41): [True: 1.62M, False: 12.8k]
  ------------------
  500|  1.62M|        if (*p != prev + 1) nr_runs++;
  ------------------
  |  Branch (500:13): [True: 888k, False: 737k]
  ------------------
  501|  1.62M|        prev = *p;
  502|  1.62M|    }
  503|  12.8k|    return nr_runs;
  504|  12.8k|}
array_container_write:
  512|  7.12k|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.12k|    memcpy(buf, container->array, container->cardinality * sizeof(uint16_t));
  520|  7.12k|#endif
  521|  7.12k|    return array_container_size_in_bytes(container);
  522|  7.12k|}
array_container_is_subset:
  525|  5.72k|                               const array_container_t *container2) {
  526|  5.72k|    if (container1->cardinality > container2->cardinality) {
  ------------------
  |  Branch (526:9): [True: 625, False: 5.09k]
  ------------------
  527|    625|        return false;
  528|    625|    }
  529|  5.09k|    int i1 = 0, i2 = 0;
  530|  54.0k|    while (i1 < container1->cardinality && i2 < container2->cardinality) {
  ------------------
  |  Branch (530:12): [True: 54.0k, False: 0]
  |  Branch (530:44): [True: 54.0k, False: 27]
  ------------------
  531|  54.0k|        if (container1->array[i1] == container2->array[i2]) {
  ------------------
  |  Branch (531:13): [True: 0, False: 54.0k]
  ------------------
  532|      0|            i1++;
  533|      0|            i2++;
  534|  54.0k|        } else if (container1->array[i1] > container2->array[i2]) {
  ------------------
  |  Branch (534:20): [True: 48.9k, False: 5.07k]
  ------------------
  535|  48.9k|            i2++;
  536|  48.9k|        } else {  // container1->array[i1] < container2->array[i2]
  537|  5.07k|            return false;
  538|  5.07k|        }
  539|  54.0k|    }
  540|     27|    if (i1 == container1->cardinality) {
  ------------------
  |  Branch (540:9): [True: 0, False: 27]
  ------------------
  541|      0|        return true;
  542|     27|    } else {
  543|       |        return false;
  544|     27|    }
  545|     27|}
array_container_read:
  548|  7.16k|                             const char *buf) {
  549|  7.16k|    if (container->capacity < cardinality) {
  ------------------
  |  Branch (549:9): [True: 0, False: 7.16k]
  ------------------
  550|      0|        array_container_grow(container, cardinality, false);
  551|      0|    }
  552|  7.16k|    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.16k|    memcpy(container->array, buf, container->cardinality * sizeof(uint16_t));
  561|  7.16k|#endif
  562|       |
  563|  7.16k|    return array_container_size_in_bytes(container);
  564|  7.16k|}
array_container_iterate:
  567|  6.49k|                             roaring_iterator iterator, void *ptr) {
  568|  2.03M|    for (int i = 0; i < cont->cardinality; i++)
  ------------------
  |  Branch (568:21): [True: 2.02M, False: 6.49k]
  ------------------
  569|  2.02M|        if (!iterator(cont->array[i] + base, ptr)) return false;
  ------------------
  |  Branch (569:13): [True: 0, False: 2.02M]
  ------------------
  570|  6.49k|    return true;
  571|  6.49k|}
array.c:clamp:
  162|   120k|static inline int32_t clamp(int32_t val, int32_t min, int32_t max) {
  163|   120k|    return ((val < min) ? min : (val > max) ? max : val);
  ------------------
  |  Branch (163:13): [True: 26.8k, False: 93.7k]
  |  Branch (163:33): [True: 257, False: 93.4k]
  ------------------
  164|   120k|}
array.c:grow_capacity:
  155|   120k|static inline int32_t grow_capacity(int32_t capacity) {
  156|   120k|    return (capacity <= 0)   ? ARRAY_DEFAULT_INIT_SIZE
  ------------------
  |  Branch (156:12): [True: 26.2k, False: 94.3k]
  ------------------
  157|   120k|           : capacity < 64   ? capacity * 2
  ------------------
  |  Branch (157:14): [True: 68.6k, False: 25.7k]
  ------------------
  158|  94.3k|           : capacity < 1024 ? capacity * 3 / 2
  ------------------
  |  Branch (158:14): [True: 25.4k, False: 298]
  ------------------
  159|  25.7k|                             : capacity * 5 / 4;
  160|   120k|}
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.00k, False: 1.31k]
  ------------------
  282|  2.32k|}

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

container_free:
   58|   628k|void container_free(container_t *c, uint8_t type) {
   59|   628k|    switch (type) {
   60|   295k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|   295k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (60:9): [True: 295k, False: 333k]
  ------------------
   61|   295k|            bitset_container_free(CAST_bitset(c));
  ------------------
  |  |   52|   295k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|   295k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
   62|   295k|            break;
   63|   133k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|   133k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (63:9): [True: 133k, False: 495k]
  ------------------
   64|   133k|            array_container_free(CAST_array(c));
  ------------------
  |  |   54|   133k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|   133k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
   65|   133k|            break;
   66|   200k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|   200k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (66:9): [True: 200k, False: 428k]
  ------------------
   67|   200k|            run_container_free(CAST_run(c));
  ------------------
  |  |   77|   200k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|   200k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
   68|   200k|            break;
   69|      0|        case SHARED_CONTAINER_TYPE:
  ------------------
  |  |   51|      0|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (69:9): [True: 0, False: 628k]
  ------------------
   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: 628k]
  ------------------
   73|      0|            assert(false);
   74|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
   75|   628k|    }
   76|   628k|}
get_copy_of_container:
  181|    229|                                   bool copy_on_write) {
  182|    229|    if (copy_on_write) {
  ------------------
  |  Branch (182:9): [True: 0, False: 229]
  ------------------
  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|    229|    const container_t *actual_container = container_unwrap_shared(c, typecode);
  209|       |    assert(*typecode != SHARED_CONTAINER_TYPE);
  210|    229|    return container_clone(actual_container, *typecode);
  211|    229|}
container_clone:
  217|   348k|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|   348k|    switch (typecode) {
  221|   146k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|   146k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (221:9): [True: 146k, False: 202k]
  ------------------
  222|   146k|            return bitset_container_clone(const_CAST_bitset(c));
  ------------------
  |  |   53|   146k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|   146k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  223|  22.9k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  22.9k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (223:9): [True: 22.9k, False: 325k]
  ------------------
  224|  22.9k|            return array_container_clone(const_CAST_array(c));
  ------------------
  |  |   55|  22.9k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  22.9k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  225|   179k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|   179k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (225:9): [True: 179k, False: 169k]
  ------------------
  226|   179k|            return run_container_clone(const_CAST_run(c));
  ------------------
  |  |   78|   179k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|   179k|#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: 348k]
  ------------------
  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: 348k]
  ------------------
  232|      0|            assert(false);
  233|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  234|      0|            return NULL;
  235|   348k|    }
  236|   348k|}
container_init_iterator:
  304|  19.0k|                                                     uint16_t *value) {
  305|  19.0k|    switch (typecode) {
  306|  3.89k|        case BITSET_CONTAINER_TYPE: {
  ------------------
  |  |   48|  3.89k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (306:9): [True: 3.89k, False: 15.1k]
  ------------------
  307|  3.89k|            const bitset_container_t *bc = const_CAST_bitset(c);
  ------------------
  |  |   53|  3.89k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.89k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  308|  3.89k|            uint32_t wordindex = 0;
  309|  3.89k|            uint64_t word;
  310|  32.2k|            while ((word = bc->words[wordindex]) == 0) {
  ------------------
  |  Branch (310:20): [True: 28.3k, False: 3.89k]
  ------------------
  311|  28.3k|                wordindex++;
  312|  28.3k|            }
  313|       |            // word is non-zero
  314|  3.89k|            int32_t index = wordindex * 64 + roaring_trailing_zeroes(word);
  315|  3.89k|            *value = index;
  316|  3.89k|            return ROARING_INIT_ROARING_CONTAINER_ITERATOR_T{
  ------------------
  |  |   13|  3.89k|#define ROARING_INIT_ROARING_CONTAINER_ITERATOR_T (roaring_container_iterator_t)
  ------------------
  317|  3.89k|                .index = index,
  318|  3.89k|            };
  319|      0|        }
  320|  14.6k|        case ARRAY_CONTAINER_TYPE: {
  ------------------
  |  |   49|  14.6k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (320:9): [True: 14.6k, False: 4.36k]
  ------------------
  321|  14.6k|            const array_container_t *ac = const_CAST_array(c);
  ------------------
  |  |   55|  14.6k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  14.6k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  322|  14.6k|            *value = ac->array[0];
  323|  14.6k|            return ROARING_INIT_ROARING_CONTAINER_ITERATOR_T{
  ------------------
  |  |   13|  14.6k|#define ROARING_INIT_ROARING_CONTAINER_ITERATOR_T (roaring_container_iterator_t)
  ------------------
  324|  14.6k|                .index = 0,
  325|  14.6k|            };
  326|      0|        }
  327|    477|        case RUN_CONTAINER_TYPE: {
  ------------------
  |  |   50|    477|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (327:9): [True: 477, False: 18.5k]
  ------------------
  328|    477|            const run_container_t *rc = const_CAST_run(c);
  ------------------
  |  |   78|    477|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    477|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  329|    477|            *value = rc->runs[0].value;
  330|    477|            return ROARING_INIT_ROARING_CONTAINER_ITERATOR_T{
  ------------------
  |  |   13|    477|#define ROARING_INIT_ROARING_CONTAINER_ITERATOR_T (roaring_container_iterator_t)
  ------------------
  331|    477|                .index = 0,
  332|    477|            };
  333|      0|        }
  334|      0|        default:
  ------------------
  |  Branch (334:9): [True: 0, False: 19.0k]
  ------------------
  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.0k|    }
  339|  19.0k|}
container_iterator_lower_bound:
  386|  6.33k|                                    uint16_t *value_out, uint16_t val) {
  387|  6.33k|    if (val > container_maximum(c, typecode)) {
  ------------------
  |  Branch (387:9): [True: 0, False: 6.33k]
  ------------------
  388|      0|        return false;
  389|      0|    }
  390|  6.33k|    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.42k]
  ------------------
  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.42k|        case ARRAY_CONTAINER_TYPE: {
  ------------------
  |  |   49|  4.42k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (397:9): [True: 4.42k, False: 1.91k]
  ------------------
  398|  4.42k|            const array_container_t *ac = const_CAST_array(c);
  ------------------
  |  |   55|  4.42k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  4.42k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  399|  4.42k|            it->index = array_container_index_equalorlarger(ac, val);
  400|  4.42k|            *value_out = ac->array[it->index];
  401|  4.42k|            return true;
  402|      0|        }
  403|      0|        case RUN_CONTAINER_TYPE: {
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (403:9): [True: 0, False: 6.33k]
  ------------------
  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.33k]
  ------------------
  414|      0|            assert(false);
  415|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  416|      0|            return false;
  417|  6.33k|    }
  418|  6.33k|}

bitset_container_from_array:
   22|  2.34k|bitset_container_t *bitset_container_from_array(const array_container_t *ac) {
   23|  2.34k|    bitset_container_t *ans = bitset_container_create();
   24|  2.34k|    int limit = array_container_cardinality(ac);
   25|  2.45M|    for (int i = 0; i < limit; ++i) bitset_container_set(ans, ac->array[i]);
  ------------------
  |  Branch (25:21): [True: 2.45M, False: 2.34k]
  ------------------
   26|  2.34k|    return ans;
   27|  2.34k|}
bitset_container_from_run:
   29|    565|bitset_container_t *bitset_container_from_run(const run_container_t *arr) {
   30|    565|    int card = run_container_cardinality(arr);
   31|    565|    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: 565]
  ------------------
   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|    565|    answer->cardinality = card;
   37|    565|    return answer;
   38|    565|}
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|  85.7k|    for (int rlepos = 0; rlepos < arr->n_runs; ++rlepos) {
  ------------------
  |  Branch (44:26): [True: 84.5k, False: 1.18k]
  ------------------
   45|  84.5k|        int run_start = arr->runs[rlepos].value;
   46|  84.5k|        int run_end = run_start + arr->runs[rlepos].length;
   47|       |
   48|   456k|        for (int run_value = run_start; run_value <= run_end; ++run_value) {
  ------------------
  |  Branch (48:41): [True: 372k, False: 84.5k]
  ------------------
   49|   372k|            answer->array[answer->cardinality++] = (uint16_t)run_value;
   50|   372k|        }
   51|  84.5k|    }
   52|  1.18k|    return answer;
   53|  1.18k|}
array_container_from_bitset:
   55|  2.83k|array_container_t *array_container_from_bitset(const bitset_container_t *bits) {
   56|  2.83k|    array_container_t *result =
   57|  2.83k|        array_container_create_given_capacity(bits->cardinality);
   58|  2.83k|    result->cardinality = bits->cardinality;
   59|  2.83k|#if CROARING_IS_X64
   60|  2.83k|#if CROARING_COMPILER_SUPPORTS_AVX512
   61|  2.83k|    if (croaring_hardware_support() & ROARING_SUPPORTS_AVX512) {
  ------------------
  |  Branch (61:9): [True: 0, False: 2.83k]
  ------------------
   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.83k|#endif
   67|  2.83k|    {
   68|       |        //  sse version ends up being slower here
   69|       |        // (bitset_extract_setbits_sse_uint16)
   70|       |        // because of the sparsity of the data
   71|  2.83k|        bitset_extract_setbits_uint16(
   72|  2.83k|            bits->words, BITSET_CONTAINER_SIZE_IN_WORDS, result->array, 0);
   73|  2.83k|    }
   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.83k|    return result;
   81|  2.83k|}
convert_to_bitset_or_array_container:
  120|  72.3k|                                                  uint8_t *resulttype) {
  121|  72.3k|    if (card <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (121:9): [True: 1.21k, False: 71.1k]
  ------------------
  122|  1.21k|        array_container_t *answer = array_container_create_given_capacity(card);
  123|  1.21k|        answer->cardinality = 0;
  124|  64.6k|        for (int rlepos = 0; rlepos < rc->n_runs; ++rlepos) {
  ------------------
  |  Branch (124:30): [True: 63.4k, False: 1.21k]
  ------------------
  125|  63.4k|            uint16_t run_start = rc->runs[rlepos].value;
  126|  63.4k|            uint16_t run_end = run_start + rc->runs[rlepos].length;
  127|   630k|            for (uint16_t run_value = run_start; run_value < run_end;
  ------------------
  |  Branch (127:50): [True: 567k, False: 63.4k]
  ------------------
  128|   567k|                 ++run_value) {
  129|   567k|                answer->array[answer->cardinality++] = run_value;
  130|   567k|            }
  131|  63.4k|            answer->array[answer->cardinality++] = run_end;
  132|  63.4k|        }
  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|  71.1k|    bitset_container_t *answer = bitset_container_create();
  139|   161k|    for (int rlepos = 0; rlepos < rc->n_runs; ++rlepos) {
  ------------------
  |  Branch (139:26): [True: 90.8k, False: 71.1k]
  ------------------
  140|  90.8k|        uint16_t run_start = rc->runs[rlepos].value;
  141|  90.8k|        bitset_set_lenrange(answer->words, run_start, rc->runs[rlepos].length);
  142|  90.8k|    }
  143|  71.1k|    answer->cardinality = card;
  144|  71.1k|    *resulttype = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|  71.1k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  145|       |    // run_container_free(r);
  146|  71.1k|    return answer;
  147|  72.3k|}
convert_run_to_efficient_container:
  155|   139k|                                                uint8_t *typecode_after) {
  156|   139k|    int32_t size_as_run_container =
  157|   139k|        run_container_serialized_size_in_bytes(c->n_runs);
  158|       |
  159|   139k|    int32_t size_as_bitset_container =
  160|   139k|        bitset_container_serialized_size_in_bytes();
  161|   139k|    int32_t card = run_container_cardinality(c);
  162|   139k|    int32_t size_as_array_container =
  163|   139k|        array_container_serialized_size_in_bytes(card);
  164|       |
  165|   139k|    int32_t min_size_non_run =
  166|   139k|        size_as_bitset_container < size_as_array_container
  ------------------
  |  Branch (166:9): [True: 62.7k, False: 76.3k]
  ------------------
  167|   139k|            ? size_as_bitset_container
  168|   139k|            : size_as_array_container;
  169|   139k|    if (size_as_run_container <= min_size_non_run) {  // no conversion
  ------------------
  |  Branch (169:9): [True: 71.2k, False: 67.8k]
  ------------------
  170|  71.2k|        *typecode_after = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|  71.2k|#define RUN_CONTAINER_TYPE 3
  ------------------
  171|  71.2k|        return c;
  172|  71.2k|    }
  173|  67.8k|    if (card <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (173:9): [True: 67.8k, False: 0]
  ------------------
  174|       |        // to array
  175|  67.8k|        array_container_t *answer = array_container_create_given_capacity(card);
  176|  67.8k|        answer->cardinality = 0;
  177|   210k|        for (int rlepos = 0; rlepos < c->n_runs; ++rlepos) {
  ------------------
  |  Branch (177:30): [True: 142k, False: 67.8k]
  ------------------
  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|  67.8k|        *typecode_after = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  67.8k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  186|  67.8k|        return answer;
  187|  67.8k|    }
  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|  67.8k|}
convert_run_to_efficient_container_and_free:
  204|   127k|    run_container_t *c, uint8_t *typecode_after) {
  205|   127k|    container_t *answer = convert_run_to_efficient_container(c, typecode_after);
  206|   127k|    if (answer != c) run_container_free(c);
  ------------------
  |  Branch (206:9): [True: 61.7k, False: 65.8k]
  ------------------
  207|   127k|    return answer;
  208|   127k|}
convert_run_optimize:
  218|  12.8k|                                  uint8_t *typecode_after) {
  219|  12.8k|    if (typecode_original == RUN_CONTAINER_TYPE) {
  ------------------
  |  |   50|  12.8k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (219:9): [True: 0, False: 12.8k]
  ------------------
  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.8k|    } else if (typecode_original == ARRAY_CONTAINER_TYPE) {
  ------------------
  |  |   49|  12.8k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (226:16): [True: 12.8k, False: 0]
  ------------------
  227|       |        // it might need to be converted to a run container.
  228|  12.8k|        array_container_t *c_qua_array = CAST_array(c);
  ------------------
  |  |   54|  12.8k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  12.8k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  229|  12.8k|        int32_t n_runs = array_container_number_of_runs(c_qua_array);
  230|  12.8k|        int32_t size_as_run_container =
  231|  12.8k|            run_container_serialized_size_in_bytes(n_runs);
  232|  12.8k|        int32_t card = array_container_cardinality(c_qua_array);
  233|  12.8k|        int32_t size_as_array_container =
  234|  12.8k|            array_container_serialized_size_in_bytes(card);
  235|       |
  236|  12.8k|        if (size_as_run_container >= size_as_array_container) {
  ------------------
  |  Branch (236:13): [True: 8.83k, False: 4.05k]
  ------------------
  237|  8.83k|            *typecode_after = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  8.83k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  238|  8.83k|            return c;
  239|  8.83k|        }
  240|       |        // else convert array to run container
  241|  4.05k|        run_container_t *answer = run_container_create_given_capacity(n_runs);
  242|  4.05k|        int prev = -2;
  243|  4.05k|        int run_start = -1;
  244|       |
  245|  4.05k|        assert(card > 0);
  246|   647k|        for (int i = 0; i < card; ++i) {
  ------------------
  |  Branch (246:25): [True: 643k, False: 4.05k]
  ------------------
  247|   643k|            uint16_t cur_val = c_qua_array->array[i];
  248|   643k|            if (cur_val != prev + 1) {
  ------------------
  |  Branch (248:17): [True: 261k, False: 381k]
  ------------------
  249|       |                // new run starts; flush old one, if any
  250|   261k|                if (run_start != -1) add_run(answer, run_start, prev);
  ------------------
  |  Branch (250:21): [True: 257k, False: 4.05k]
  ------------------
  251|   261k|                run_start = cur_val;
  252|   261k|            }
  253|   643k|            prev = c_qua_array->array[i];
  254|   643k|        }
  255|  4.05k|        assert(run_start >= 0);
  256|       |        // now prev is the last seen value
  257|  4.05k|        add_run(answer, run_start, prev);
  258|  4.05k|        *typecode_after = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|  4.05k|#define RUN_CONTAINER_TYPE 3
  ------------------
  259|  4.05k|        array_container_free(c_qua_array);
  260|  4.05k|        return answer;
  261|  12.8k|    } 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.8k|}
convert.c:add_run:
   84|   261k|static void add_run(run_container_t *rc, int s, int e) {
   85|   261k|    rc->runs[rc->n_runs].value = s;
   86|   261k|    rc->runs[rc->n_runs].length = e - s;
   87|   261k|    rc->n_runs++;
   88|   261k|}

array_bitset_container_andnot:
   26|    640|                                   array_container_t *dst) {
   27|       |    // follows Java implementation as of June 2016
   28|    640|    if (dst->capacity < src_1->cardinality) {
  ------------------
  |  Branch (28:9): [True: 640, False: 0]
  ------------------
   29|    640|        array_container_grow(dst, src_1->cardinality, false);
   30|    640|    }
   31|    640|    int32_t newcard = 0;
   32|    640|    const int32_t origcard = src_1->cardinality;
   33|   109k|    for (int i = 0; i < origcard; ++i) {
  ------------------
  |  Branch (33:21): [True: 109k, False: 640]
  ------------------
   34|   109k|        uint16_t key = src_1->array[i];
   35|   109k|        dst->array[newcard] = key;
   36|   109k|        newcard += 1 - bitset_container_contains(src_2, key);
   37|   109k|    }
   38|    640|    dst->cardinality = newcard;
   39|    640|}
bitset_array_container_iandnot:
   83|  1.56k|                                    container_t **dst) {
   84|  1.56k|    *dst = src_1;
   85|  1.56k|    src_1->cardinality =
   86|  1.56k|        (int32_t)bitset_clear_list(src_1->words, (uint64_t)src_1->cardinality,
   87|  1.56k|                                   src_2->array, (uint64_t)src_2->cardinality);
   88|       |
   89|  1.56k|    if (src_1->cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (89:9): [True: 211, False: 1.35k]
  ------------------
   90|    211|        *dst = array_container_from_bitset(src_1);
   91|    211|        bitset_container_free(src_1);
   92|    211|        return false;  // not bitset
   93|    211|    } else
   94|  1.35k|        return true;
   95|  1.56k|}
run_bitset_container_andnot:
  106|    648|                                 container_t **dst) {
  107|       |    // follows the Java implementation as of June 2016
  108|    648|    int card = run_container_cardinality(src_1);
  109|    648|    if (card <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (109:9): [True: 648, False: 0]
  ------------------
  110|       |        // must be an array
  111|    648|        array_container_t *answer = array_container_create_given_capacity(card);
  112|    648|        answer->cardinality = 0;
  113|  52.3k|        for (int32_t rlepos = 0; rlepos < src_1->n_runs; ++rlepos) {
  ------------------
  |  Branch (113:34): [True: 51.7k, False: 648]
  ------------------
  114|  51.7k|            rle16_t rle = src_1->runs[rlepos];
  115|   183k|            for (int run_value = rle.value; run_value <= rle.value + rle.length;
  ------------------
  |  Branch (115:45): [True: 131k, False: 51.7k]
  ------------------
  116|   131k|                 ++run_value) {
  117|   131k|                if (!bitset_container_get(src_2, (uint16_t)run_value)) {
  ------------------
  |  Branch (117:21): [True: 39.1k, False: 92.8k]
  ------------------
  118|  39.1k|                    answer->array[answer->cardinality++] = (uint16_t)run_value;
  119|  39.1k|                }
  120|   131k|            }
  121|  51.7k|        }
  122|    648|        *dst = answer;
  123|    648|        return false;
  124|    648|    } 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|    648|}
run_array_container_andnot:
  279|  2.00k|                               container_t **dst) {
  280|       |    // follows the Java impl as of June 2016
  281|       |
  282|  2.00k|    int card = run_container_cardinality(src_1);
  283|  2.00k|    const int arbitrary_threshold = 32;
  284|       |
  285|  2.00k|    if (card <= arbitrary_threshold) {
  ------------------
  |  Branch (285:9): [True: 376, False: 1.62k]
  ------------------
  286|    376|        if (src_2->cardinality == 0) {
  ------------------
  |  Branch (286:13): [True: 0, False: 376]
  ------------------
  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|    376|        run_container_t *answer = run_container_create_given_capacity(
  292|    376|            card + array_container_cardinality(src_2));
  293|       |
  294|    376|        int rlepos = 0;
  295|    376|        int xrlepos = 0;  // "x" is src_2
  296|    376|        rle16_t rle = src_1->runs[rlepos];
  297|    376|        int32_t start = rle.value;
  298|    376|        int32_t end = start + rle.length + 1;
  299|    376|        int32_t xstart = src_2->array[xrlepos];
  300|       |
  301|  12.6k|        while ((rlepos < src_1->n_runs) && (xrlepos < src_2->cardinality)) {
  ------------------
  |  Branch (301:16): [True: 12.3k, False: 306]
  |  Branch (301:44): [True: 12.3k, False: 70]
  ------------------
  302|  12.3k|            if (end <= xstart) {
  ------------------
  |  Branch (302:17): [True: 695, False: 11.6k]
  ------------------
  303|       |                // output the first run
  304|    695|                answer->runs[answer->n_runs++] =
  305|    695|                    CROARING_MAKE_RLE16(start, end - start - 1);
  ------------------
  |  |   60|    695|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  306|    695|                rlepos++;
  307|    695|                if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (307:21): [True: 645, False: 50]
  ------------------
  308|    645|                    start = src_1->runs[rlepos].value;
  309|    645|                    end = start + src_1->runs[rlepos].length + 1;
  310|    645|                }
  311|  11.6k|            } else if (xstart + 1 <= start) {
  ------------------
  |  Branch (311:24): [True: 7.36k, False: 4.24k]
  ------------------
  312|       |                // exit the second run
  313|  7.36k|                xrlepos++;
  314|  7.36k|                if (xrlepos < src_2->cardinality) {
  ------------------
  |  Branch (314:21): [True: 7.29k, False: 70]
  ------------------
  315|  7.29k|                    xstart = src_2->array[xrlepos];
  316|  7.29k|                }
  317|  7.36k|            } else {
  318|  4.24k|                if (start < xstart) {
  ------------------
  |  Branch (318:21): [True: 338, False: 3.91k]
  ------------------
  319|    338|                    answer->runs[answer->n_runs++] =
  320|    338|                        CROARING_MAKE_RLE16(start, xstart - start - 1);
  ------------------
  |  |   60|    338|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  321|    338|                }
  322|  4.24k|                if (xstart + 1 < end) {
  ------------------
  |  Branch (322:21): [True: 2.58k, False: 1.66k]
  ------------------
  323|  2.58k|                    start = xstart + 1;
  324|  2.58k|                } else {
  325|  1.66k|                    rlepos++;
  326|  1.66k|                    if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (326:25): [True: 1.40k, False: 256]
  ------------------
  327|  1.40k|                        start = src_1->runs[rlepos].value;
  328|  1.40k|                        end = start + src_1->runs[rlepos].length + 1;
  329|  1.40k|                    }
  330|  1.66k|                }
  331|  4.24k|            }
  332|  12.3k|        }
  333|    376|        if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (333:13): [True: 70, False: 306]
  ------------------
  334|     70|            answer->runs[answer->n_runs++] =
  335|     70|                CROARING_MAKE_RLE16(start, end - start - 1);
  ------------------
  |  |   60|     70|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  336|     70|            rlepos++;
  337|     70|            if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (337:17): [True: 22, False: 48]
  ------------------
  338|     22|                memcpy(answer->runs + answer->n_runs, src_1->runs + rlepos,
  339|     22|                       (src_1->n_runs - rlepos) * sizeof(rle16_t));
  340|     22|                answer->n_runs += (src_1->n_runs - rlepos);
  341|     22|            }
  342|     70|        }
  343|    376|        uint8_t return_type;
  344|    376|        *dst = convert_run_to_efficient_container(answer, &return_type);
  345|    376|        if (answer != *dst) run_container_free(answer);
  ------------------
  |  Branch (345:13): [True: 235, False: 141]
  ------------------
  346|    376|        return return_type;
  347|    376|    }
  348|       |    // else it's a bitmap or array
  349|       |
  350|  1.62k|    if (card <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (350:9): [True: 1.31k, False: 310]
  ------------------
  351|  1.31k|        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.31k|        ac->cardinality = run_array_array_subtract(src_1, src_2, ac);
  355|  1.31k|        *dst = ac;
  356|  1.31k|        return ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  1.31k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  357|  1.31k|    }
  358|    310|    bitset_container_t *ans = bitset_container_from_run(src_1);
  359|    310|    bool result_is_bitset = bitset_array_container_iandnot(ans, src_2, dst);
  360|    310|    return (result_is_bitset ? BITSET_CONTAINER_TYPE : ARRAY_CONTAINER_TYPE);
  ------------------
  |  |   48|    290|#define BITSET_CONTAINER_TYPE 1
  ------------------
                  return (result_is_bitset ? BITSET_CONTAINER_TYPE : ARRAY_CONTAINER_TYPE);
  ------------------
  |  |   49|     20|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (360:13): [True: 290, False: 20]
  ------------------
  361|  1.62k|}
run_array_container_iandnot:
  372|    759|                                container_t **dst) {
  373|       |    // dummy implementation same as June 2016 Java
  374|    759|    int ans = run_array_container_andnot(src_1, src_2, dst);
  375|    759|    run_container_free(src_1);
  376|    759|    return ans;
  377|    759|}
array_run_container_andnot:
  383|    803|                                array_container_t *dst) {
  384|       |    // basically following Java impl as of June 2016
  385|    803|    if (src_1->cardinality > dst->capacity) {
  ------------------
  |  Branch (385:9): [True: 760, False: 43]
  ------------------
  386|    760|        array_container_grow(dst, src_1->cardinality, false);
  387|    760|    }
  388|       |
  389|    803|    if (src_2->n_runs == 0) {
  ------------------
  |  Branch (389:9): [True: 0, False: 803]
  ------------------
  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|    803|    int32_t run_start = src_2->runs[0].value;
  396|    803|    int32_t run_end = run_start + src_2->runs[0].length;
  397|    803|    int which_run = 0;
  398|       |
  399|    803|    uint16_t val = 0;
  400|    803|    int dest_card = 0;
  401|   171k|    for (int i = 0; i < src_1->cardinality; ++i) {
  ------------------
  |  Branch (401:21): [True: 170k, False: 803]
  ------------------
  402|   170k|        val = src_1->array[i];
  403|   170k|        if (val < run_start)
  ------------------
  |  Branch (403:13): [True: 45.7k, False: 125k]
  ------------------
  404|  45.7k|            dst->array[dest_card++] = val;
  405|   125k|        else if (val <= run_end) {
  ------------------
  |  Branch (405:18): [True: 90.9k, False: 34.0k]
  ------------------
  406|  90.9k|            ;  // omitted item
  407|  90.9k|        } else {
  408|  47.0k|            do {
  409|  47.0k|                if (which_run + 1 < src_2->n_runs) {
  ------------------
  |  Branch (409:21): [True: 46.8k, False: 187]
  ------------------
  410|  46.8k|                    ++which_run;
  411|  46.8k|                    run_start = src_2->runs[which_run].value;
  412|  46.8k|                    run_end = run_start + src_2->runs[which_run].length;
  413|       |
  414|  46.8k|                } else
  415|    187|                    run_start = run_end = (1 << 16) + 1;
  416|  47.0k|            } while (val > run_end);
  ------------------
  |  Branch (416:22): [True: 12.9k, False: 34.0k]
  ------------------
  417|  34.0k|            --i;
  418|  34.0k|        }
  419|   170k|    }
  420|    803|    dst->cardinality = dest_card;
  421|    803|}
array_run_container_iandnot:
  428|     43|                                 const run_container_t *src_2) {
  429|     43|    array_run_container_andnot(src_1, src_2, src_1);
  430|     43|}
run_run_container_andnot:
  437|  1.13k|                             const run_container_t *src_2, container_t **dst) {
  438|  1.13k|    run_container_t *ans = run_container_create();
  439|  1.13k|    run_container_andnot(src_1, src_2, ans);
  440|  1.13k|    uint8_t typecode_after;
  441|  1.13k|    *dst = convert_run_to_efficient_container_and_free(ans, &typecode_after);
  442|  1.13k|    return typecode_after;
  443|  1.13k|}
run_run_container_iandnot:
  453|    453|                              const run_container_t *src_2, container_t **dst) {
  454|       |    // following Java impl as of June 2016 (dummy)
  455|    453|    int ans = run_run_container_andnot(src_1, src_2, dst);
  456|    453|    run_container_free(src_1);
  457|    453|    return ans;
  458|    453|}
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.50k|                                   const array_container_t *src_2) {
  474|  3.50k|    array_container_andnot(src_1, src_2, src_1);
  475|  3.50k|}
mixed_andnot.c:run_array_array_subtract:
  235|  1.31k|                                    array_container_t *a_out) {
  236|  1.31k|    int out_card = 0;
  237|  1.31k|    int32_t in_array_pos =
  238|  1.31k|        -1;  // since advanceUntil always assumes we start the search AFTER this
  239|       |
  240|  96.3k|    for (int rlepos = 0; rlepos < rc->n_runs; rlepos++) {
  ------------------
  |  Branch (240:26): [True: 95.0k, False: 1.31k]
  ------------------
  241|  95.0k|        int32_t start = rc->runs[rlepos].value;
  242|  95.0k|        int32_t end = start + rc->runs[rlepos].length + 1;
  243|       |
  244|  95.0k|        in_array_pos = advanceUntil(a_in->array, in_array_pos,
  245|  95.0k|                                    a_in->cardinality, (uint16_t)start);
  246|       |
  247|  95.0k|        if (in_array_pos >= a_in->cardinality) {  // run has no items subtracted
  ------------------
  |  Branch (247:13): [True: 5.30k, False: 89.7k]
  ------------------
  248|  84.1k|            for (int32_t i = start; i < end; ++i)
  ------------------
  |  Branch (248:37): [True: 78.8k, False: 5.30k]
  ------------------
  249|  78.8k|                a_out->array[out_card++] = (uint16_t)i;
  250|  89.7k|        } else {
  251|  89.7k|            uint16_t next_nonincluded = a_in->array[in_array_pos];
  252|  89.7k|            if (next_nonincluded >= end) {
  ------------------
  |  Branch (252:17): [True: 30.6k, False: 59.0k]
  ------------------
  253|       |                // another case when run goes unaltered
  254|  82.8k|                for (int32_t i = start; i < end; ++i)
  ------------------
  |  Branch (254:41): [True: 52.1k, False: 30.6k]
  ------------------
  255|  52.1k|                    a_out->array[out_card++] = (uint16_t)i;
  256|  30.6k|                in_array_pos--;  // ensure we see this item again if necessary
  257|  59.0k|            } else {
  258|   312k|                for (int32_t i = start; i < end; ++i)
  ------------------
  |  Branch (258:41): [True: 253k, False: 59.0k]
  ------------------
  259|   253k|                    if (i != next_nonincluded)
  ------------------
  |  Branch (259:25): [True: 120k, False: 132k]
  ------------------
  260|   120k|                        a_out->array[out_card++] = (uint16_t)i;
  261|   132k|                    else  // 0 should ensure  we don't match
  262|   132k|                        next_nonincluded =
  263|   132k|                            (in_array_pos + 1 >= a_in->cardinality)
  ------------------
  |  Branch (263:29): [True: 1.03k, False: 131k]
  ------------------
  264|   132k|                                ? 0
  265|   132k|                                : a_in->array[++in_array_pos];
  266|  59.0k|                in_array_pos--;  // see again
  267|  59.0k|            }
  268|  89.7k|        }
  269|  95.0k|    }
  270|  1.31k|    return out_card;
  271|  1.31k|}

array_container_equal_bitset:
   10|    427|                                  const bitset_container_t* container2) {
   11|    427|    if (container2->cardinality != BITSET_UNKNOWN_CARDINALITY) {
  ------------------
  |  Branch (11:9): [True: 427, False: 0]
  ------------------
   12|    427|        if (container2->cardinality != container1->cardinality) {
  ------------------
  |  Branch (12:13): [True: 427, False: 0]
  ------------------
   13|    427|            return false;
   14|    427|        }
   15|    427|    }
   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|    871|                                const array_container_t* container2) {
   37|    871|    if (run_container_cardinality(container1) != container2->cardinality)
  ------------------
  |  Branch (37:9): [True: 824, False: 47]
  ------------------
   38|    824|        return false;
   39|     47|    int32_t pos = 0;
   40|     47|    for (int i = 0; i < container1->n_runs; ++i) {
  ------------------
  |  Branch (40:21): [True: 47, False: 0]
  ------------------
   41|     47|        const uint32_t run_start = container1->runs[i].value;
   42|     47|        const uint32_t le = container1->runs[i].length;
   43|       |
   44|     47|        if (container2->array[pos] != run_start) {
  ------------------
  |  Branch (44:13): [True: 47, False: 0]
  ------------------
   45|     47|            return false;
   46|     47|        }
   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|     47|}

array_bitset_container_intersection:
   21|    682|                                         array_container_t *dst) {
   22|    682|    if (dst->capacity < src_1->cardinality) {
  ------------------
  |  Branch (22:9): [True: 682, False: 0]
  ------------------
   23|    682|        array_container_grow(dst, src_1->cardinality, false);
   24|    682|    }
   25|    682|    int32_t newcard = 0;  // dst could be src_1
   26|    682|    const int32_t origcard = src_1->cardinality;
   27|   280k|    for (int i = 0; i < origcard; ++i) {
  ------------------
  |  Branch (27:21): [True: 280k, False: 682]
  ------------------
   28|   280k|        uint16_t key = src_1->array[i];
   29|       |        // this branchless approach is much faster...
   30|   280k|        dst->array[newcard] = key;
   31|   280k|        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|   280k|    }
   45|    682|    dst->cardinality = newcard;
   46|    682|}
array_bitset_container_intersection_cardinality:
   50|  2.56k|    const array_container_t *src_1, const bitset_container_t *src_2) {
   51|  2.56k|    int32_t newcard = 0;
   52|  2.56k|    const int32_t origcard = src_1->cardinality;
   53|   439k|    for (int i = 0; i < origcard; ++i) {
  ------------------
  |  Branch (53:21): [True: 436k, False: 2.56k]
  ------------------
   54|   436k|        uint16_t key = src_1->array[i];
   55|   436k|        newcard += bitset_container_contains(src_2, key);
   56|   436k|    }
   57|  2.56k|    return newcard;
   58|  2.56k|}
array_bitset_container_intersect:
   61|    640|                                      const bitset_container_t *src_2) {
   62|    640|    const int32_t origcard = src_1->cardinality;
   63|  6.03k|    for (int i = 0; i < origcard; ++i) {
  ------------------
  |  Branch (63:21): [True: 6.01k, False: 23]
  ------------------
   64|  6.01k|        uint16_t key = src_1->array[i];
   65|  6.01k|        if (bitset_container_contains(src_2, key)) return true;
  ------------------
  |  Branch (65:13): [True: 617, False: 5.39k]
  ------------------
   66|  6.01k|    }
   67|     23|    return false;
   68|    640|}
array_run_container_intersection:
   75|  3.25k|                                      array_container_t *dst) {
   76|  3.25k|    if (run_container_is_full(src_2)) {
  ------------------
  |  Branch (76:9): [True: 25, False: 3.23k]
  ------------------
   77|     25|        if (dst != src_1) array_container_copy(src_1, dst);
  ------------------
  |  Branch (77:13): [True: 25, False: 0]
  ------------------
   78|     25|        return;
   79|     25|    }
   80|  3.23k|    if (dst->capacity < src_1->cardinality) {
  ------------------
  |  Branch (80:9): [True: 3.23k, False: 0]
  ------------------
   81|  3.23k|        array_container_grow(dst, src_1->cardinality, false);
   82|  3.23k|    }
   83|  3.23k|    if (src_2->n_runs == 0) {
  ------------------
  |  Branch (83:9): [True: 0, False: 3.23k]
  ------------------
   84|      0|        return;
   85|      0|    }
   86|  3.23k|    int32_t rlepos = 0;
   87|  3.23k|    int32_t arraypos = 0;
   88|  3.23k|    rle16_t rle = src_2->runs[rlepos];
   89|  3.23k|    int32_t newcard = 0;
   90|   449k|    while (arraypos < src_1->cardinality) {
  ------------------
  |  Branch (90:12): [True: 446k, False: 2.66k]
  ------------------
   91|   446k|        const uint16_t arrayval = src_1->array[arraypos];
   92|   597k|        while (rle.value + rle.length <
  ------------------
  |  Branch (92:16): [True: 151k, False: 445k]
  ------------------
   93|   597k|               arrayval) {  // this will frequently be false
   94|   151k|            ++rlepos;
   95|   151k|            if (rlepos == src_2->n_runs) {
  ------------------
  |  Branch (95:17): [True: 568, False: 150k]
  ------------------
   96|    568|                dst->cardinality = newcard;
   97|    568|                return;  // we are done
   98|    568|            }
   99|   150k|            rle = src_2->runs[rlepos];
  100|   150k|        }
  101|   445k|        if (rle.value > arrayval) {
  ------------------
  |  Branch (101:13): [True: 29.8k, False: 415k]
  ------------------
  102|  29.8k|            arraypos = advanceUntil(src_1->array, arraypos, src_1->cardinality,
  103|  29.8k|                                    rle.value);
  104|   415k|        } else {
  105|   415k|            dst->array[newcard] = arrayval;
  106|   415k|            newcard++;
  107|   415k|            arraypos++;
  108|   415k|        }
  109|   445k|    }
  110|  2.66k|    dst->cardinality = newcard;
  111|  2.66k|}
run_bitset_container_intersection:
  119|    648|                                       container_t **dst) {
  120|    648|    if (run_container_is_full(src_1)) {
  ------------------
  |  Branch (120:9): [True: 0, False: 648]
  ------------------
  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|    648|    int32_t card = run_container_cardinality(src_1);
  125|    648|    if (card <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (125:9): [True: 648, False: 0]
  ------------------
  126|       |        // result can only be an array (assuming that we never make a
  127|       |        // RunContainer)
  128|    648|        if (card > src_2->cardinality) {
  ------------------
  |  Branch (128:13): [True: 0, False: 648]
  ------------------
  129|      0|            card = src_2->cardinality;
  130|      0|        }
  131|    648|        array_container_t *answer = array_container_create_given_capacity(card);
  132|    648|        *dst = answer;
  133|    648|        if (*dst == NULL) {
  ------------------
  |  Branch (133:13): [True: 0, False: 648]
  ------------------
  134|      0|            return false;
  135|      0|        }
  136|  52.3k|        for (int32_t rlepos = 0; rlepos < src_1->n_runs; ++rlepos) {
  ------------------
  |  Branch (136:34): [True: 51.7k, False: 648]
  ------------------
  137|  51.7k|            rle16_t rle = src_1->runs[rlepos];
  138|  51.7k|            uint32_t endofrun = (uint32_t)rle.value + rle.length;
  139|   183k|            for (uint32_t runValue = rle.value; runValue <= endofrun;
  ------------------
  |  Branch (139:49): [True: 131k, False: 51.7k]
  ------------------
  140|   131k|                 ++runValue) {
  141|   131k|                answer->array[answer->cardinality] = (uint16_t)runValue;
  142|   131k|                answer->cardinality +=
  143|   131k|                    bitset_container_contains(src_2, runValue);
  144|   131k|            }
  145|  51.7k|        }
  146|    648|        return false;
  147|    648|    }
  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.12k|                                                 const run_container_t *src_2) {
  207|  8.12k|    if (run_container_is_full(src_2)) {
  ------------------
  |  Branch (207:9): [True: 100, False: 8.02k]
  ------------------
  208|    100|        return src_1->cardinality;
  209|    100|    }
  210|  8.02k|    if (src_2->n_runs == 0) {
  ------------------
  |  Branch (210:9): [True: 0, False: 8.02k]
  ------------------
  211|      0|        return 0;
  212|      0|    }
  213|  8.02k|    int32_t rlepos = 0;
  214|  8.02k|    int32_t arraypos = 0;
  215|  8.02k|    rle16_t rle = src_2->runs[rlepos];
  216|  8.02k|    int32_t newcard = 0;
  217|   783k|    while (arraypos < src_1->cardinality) {
  ------------------
  |  Branch (217:12): [True: 777k, False: 6.15k]
  ------------------
  218|   777k|        const uint16_t arrayval = src_1->array[arraypos];
  219|  1.15M|        while (rle.value + rle.length <
  ------------------
  |  Branch (219:16): [True: 381k, False: 775k]
  ------------------
  220|  1.15M|               arrayval) {  // this will frequently be false
  221|   381k|            ++rlepos;
  222|   381k|            if (rlepos == src_2->n_runs) {
  ------------------
  |  Branch (222:17): [True: 1.87k, False: 380k]
  ------------------
  223|  1.87k|                return newcard;  // we are done
  224|  1.87k|            }
  225|   380k|            rle = src_2->runs[rlepos];
  226|   380k|        }
  227|   775k|        if (rle.value > arrayval) {
  ------------------
  |  Branch (227:13): [True: 105k, False: 670k]
  ------------------
  228|   105k|            arraypos = advanceUntil(src_1->array, arraypos, src_1->cardinality,
  229|   105k|                                    rle.value);
  230|   670k|        } else {
  231|   670k|            newcard++;
  232|   670k|            arraypos++;
  233|   670k|        }
  234|   775k|    }
  235|  6.15k|    return newcard;
  236|  8.02k|}
run_bitset_container_intersection_cardinality:
  241|  2.59k|    const run_container_t *src_1, const bitset_container_t *src_2) {
  242|  2.59k|    if (run_container_is_full(src_1)) {
  ------------------
  |  Branch (242:9): [True: 0, False: 2.59k]
  ------------------
  243|      0|        return bitset_container_cardinality(src_2);
  244|      0|    }
  245|  2.59k|    int answer = 0;
  246|   209k|    for (int32_t rlepos = 0; rlepos < src_1->n_runs; ++rlepos) {
  ------------------
  |  Branch (246:30): [True: 206k, False: 2.59k]
  ------------------
  247|   206k|        rle16_t rle = src_1->runs[rlepos];
  248|   206k|        answer +=
  249|   206k|            bitset_lenrange_cardinality(src_2->words, rle.value, rle.length);
  250|   206k|    }
  251|  2.59k|    return answer;
  252|  2.59k|}
array_run_container_intersect:
  255|  2.03k|                                   const run_container_t *src_2) {
  256|  2.03k|    if (run_container_is_full(src_2)) {
  ------------------
  |  Branch (256:9): [True: 25, False: 2.00k]
  ------------------
  257|     25|        return !array_container_empty(src_1);
  258|     25|    }
  259|  2.00k|    if (src_2->n_runs == 0) {
  ------------------
  |  Branch (259:9): [True: 0, False: 2.00k]
  ------------------
  260|      0|        return false;
  261|      0|    }
  262|  2.00k|    int32_t rlepos = 0;
  263|  2.00k|    int32_t arraypos = 0;
  264|  2.00k|    rle16_t rle = src_2->runs[rlepos];
  265|  3.51k|    while (arraypos < src_1->cardinality) {
  ------------------
  |  Branch (265:12): [True: 3.46k, False: 55]
  ------------------
  266|  3.46k|        const uint16_t arrayval = src_1->array[arraypos];
  267|  8.44k|        while (rle.value + rle.length <
  ------------------
  |  Branch (267:16): [True: 5.02k, False: 3.41k]
  ------------------
  268|  8.44k|               arrayval) {  // this will frequently be false
  269|  5.02k|            ++rlepos;
  270|  5.02k|            if (rlepos == src_2->n_runs) {
  ------------------
  |  Branch (270:17): [True: 45, False: 4.98k]
  ------------------
  271|     45|                return false;  // we are done
  272|     45|            }
  273|  4.98k|            rle = src_2->runs[rlepos];
  274|  4.98k|        }
  275|  3.41k|        if (rle.value > arrayval) {
  ------------------
  |  Branch (275:13): [True: 1.50k, False: 1.90k]
  ------------------
  276|  1.50k|            arraypos = advanceUntil(src_1->array, arraypos, src_1->cardinality,
  277|  1.50k|                                    rle.value);
  278|  1.90k|        } else {
  279|  1.90k|            return true;
  280|  1.90k|        }
  281|  3.41k|    }
  282|     55|    return false;
  283|  2.00k|}
run_bitset_container_intersect:
  288|    648|                                    const bitset_container_t *src_2) {
  289|    648|    if (run_container_is_full(src_1)) {
  ------------------
  |  Branch (289:9): [True: 0, False: 648]
  ------------------
  290|      0|        return !bitset_container_empty(src_2);
  291|      0|    }
  292|  4.08k|    for (int32_t rlepos = 0; rlepos < src_1->n_runs; ++rlepos) {
  ------------------
  |  Branch (292:30): [True: 4.07k, False: 11]
  ------------------
  293|  4.07k|        rle16_t rle = src_1->runs[rlepos];
  294|  4.07k|        if (!bitset_lenrange_empty(src_2->words, rle.value, rle.length))
  ------------------
  |  Branch (294:13): [True: 637, False: 3.43k]
  ------------------
  295|    637|            return true;
  296|  4.07k|    }
  297|     11|    return false;
  298|    648|}
bitset_bitset_container_intersection_inplace:
  329|  1.53k|    container_t **dst) {
  330|  1.53k|    const int newCardinality = bitset_container_and_justcard(src_1, src_2);
  331|  1.53k|    if (newCardinality > DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (331:9): [True: 1.53k, False: 0]
  ------------------
  332|  1.53k|        *dst = src_1;
  333|  1.53k|        bitset_container_and_nocard(src_1, src_2, src_1);
  334|  1.53k|        CAST_bitset(*dst)->cardinality = newCardinality;
  ------------------
  |  |   52|  1.53k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.53k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  335|  1.53k|        return true;  // it is a bitset
  336|  1.53k|    }
  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.53k|}

array_container_negation:
   33|    150|                              bitset_container_t *dst) {
   34|    150|    uint64_t card = UINT64_C(1 << 16);
   35|    150|    bitset_container_set_all(dst);
   36|       |
   37|    150|    if (src->cardinality == 0) {
  ------------------
  |  Branch (37:9): [True: 0, False: 150]
  ------------------
   38|      0|        return;
   39|      0|    }
   40|       |
   41|    150|    dst->cardinality = (int32_t)bitset_clear_list(dst->words, card, src->array,
   42|    150|                                                  (uint64_t)src->cardinality);
   43|    150|}
bitset_container_negation_inplace:
   67|     76|                                       container_t **dst) {
   68|     76|    return bitset_container_negation_range_inplace(src, 0, (1 << 16), dst);
   69|     76|}
run_container_negation_inplace:
   88|  5.62k|int run_container_negation_inplace(run_container_t *src, container_t **dst) {
   89|  5.62k|    return run_container_negation_range_inplace(src, 0, (1 << 16), dst);
   90|  5.62k|}
array_container_negation_range:
   99|  3.53k|                                    container_t **dst) {
  100|       |    /* close port of the Java implementation */
  101|  3.53k|    if (range_start >= range_end) {
  ------------------
  |  Branch (101:9): [True: 0, False: 3.53k]
  ------------------
  102|      0|        *dst = array_container_clone(src);
  103|      0|        return false;
  104|      0|    }
  105|       |
  106|  3.53k|    int32_t start_index =
  107|  3.53k|        binarySearch(src->array, src->cardinality, (uint16_t)range_start);
  108|  3.53k|    if (start_index < 0) start_index = -start_index - 1;
  ------------------
  |  Branch (108:9): [True: 3.24k, False: 289]
  ------------------
  109|       |
  110|  3.53k|    int32_t last_index =
  111|  3.53k|        binarySearch(src->array, src->cardinality, (uint16_t)(range_end - 1));
  112|  3.53k|    if (last_index < 0) last_index = -last_index - 2;
  ------------------
  |  Branch (112:9): [True: 3.29k, False: 239]
  ------------------
  113|       |
  114|  3.53k|    const int32_t current_values_in_range = last_index - start_index + 1;
  115|  3.53k|    const int32_t span_to_be_flipped = range_end - range_start;
  116|  3.53k|    const int32_t new_values_in_range =
  117|  3.53k|        span_to_be_flipped - current_values_in_range;
  118|  3.53k|    const int32_t cardinality_change =
  119|  3.53k|        new_values_in_range - current_values_in_range;
  120|  3.53k|    const int32_t new_cardinality = src->cardinality + cardinality_change;
  121|       |
  122|  3.53k|    if (new_cardinality > DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (122:9): [True: 141, False: 3.39k]
  ------------------
  123|    141|        bitset_container_t *temp = bitset_container_from_array(src);
  124|    141|        bitset_flip_range(temp->words, (uint32_t)range_start,
  125|    141|                          (uint32_t)range_end);
  126|    141|        temp->cardinality = new_cardinality;
  127|    141|        *dst = temp;
  128|    141|        return true;
  129|    141|    }
  130|       |
  131|  3.39k|    array_container_t *arr =
  132|  3.39k|        array_container_create_given_capacity(new_cardinality);
  133|  3.39k|    *dst = (container_t *)arr;
  134|  3.39k|    if (new_cardinality == 0) {
  ------------------
  |  Branch (134:9): [True: 17, False: 3.37k]
  ------------------
  135|     17|        arr->cardinality = new_cardinality;
  136|     17|        return false;  // we are done.
  137|     17|    }
  138|       |    // copy stuff before the active area
  139|  3.37k|    memcpy(arr->array, src->array, start_index * sizeof(uint16_t));
  140|       |
  141|       |    // work on the range
  142|  3.37k|    int32_t out_pos = start_index, in_pos = start_index;
  143|  3.37k|    int32_t val_in_range = range_start;
  144|  39.6k|    for (; val_in_range < range_end && in_pos <= last_index; ++val_in_range) {
  ------------------
  |  Branch (144:12): [True: 39.4k, False: 219]
  |  Branch (144:40): [True: 36.2k, False: 3.15k]
  ------------------
  145|  36.2k|        if ((uint16_t)val_in_range != src->array[in_pos]) {
  ------------------
  |  Branch (145:13): [True: 24.1k, False: 12.1k]
  ------------------
  146|  24.1k|            arr->array[out_pos++] = (uint16_t)val_in_range;
  147|  24.1k|        } else {
  148|  12.1k|            ++in_pos;
  149|  12.1k|        }
  150|  36.2k|    }
  151|  58.8k|    for (; val_in_range < range_end; ++val_in_range)
  ------------------
  |  Branch (151:12): [True: 55.4k, False: 3.37k]
  ------------------
  152|  55.4k|        arr->array[out_pos++] = (uint16_t)val_in_range;
  153|       |
  154|       |    // content after the active range
  155|  3.37k|    memcpy(arr->array + out_pos, src->array + (last_index + 1),
  156|  3.37k|           (src->cardinality - (last_index + 1)) * sizeof(uint16_t));
  157|  3.37k|    arr->cardinality = new_cardinality;
  158|       |    return false;
  159|  3.39k|}
array_container_negation_range_inplace:
  168|  3.53k|                                            container_t **dst) {
  169|  3.53k|    bool ans = array_container_negation_range(src, range_start, range_end, dst);
  170|       |    // TODO : try a real inplace version
  171|  3.53k|    array_container_free(src);
  172|  3.53k|    return ans;
  173|  3.53k|}
bitset_container_negation_range_inplace:
  217|  1.43k|                                             container_t **dst) {
  218|  1.43k|    bitset_flip_range(src->words, (uint32_t)range_start, (uint32_t)range_end);
  219|  1.43k|    src->cardinality = bitset_container_compute_cardinality(src);
  220|  1.43k|    if (src->cardinality > DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (220:9): [True: 1.36k, False: 70]
  ------------------
  221|  1.36k|        *dst = src;
  222|  1.36k|        return true;
  223|  1.36k|    }
  224|     70|    *dst = array_container_from_bitset(src);
  225|     70|    bitset_container_free(src);
  226|       |    return false;
  227|  1.43k|}
run_container_negation_range:
  237|    139|                                 container_t **dst) {
  238|    139|    uint8_t return_typecode;
  239|       |
  240|       |    // follows the Java implementation
  241|    139|    if (range_end <= range_start) {
  ------------------
  |  Branch (241:9): [True: 0, False: 139]
  ------------------
  242|      0|        *dst = run_container_clone(src);
  243|      0|        return RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
  244|      0|    }
  245|       |
  246|    139|    run_container_t *ans = run_container_create_given_capacity(
  247|    139|        src->n_runs + 1);  // src->n_runs + 1);
  248|    139|    int k = 0;
  249|  2.77k|    for (; k < src->n_runs && src->runs[k].value < range_start; ++k) {
  ------------------
  |  Branch (249:12): [True: 2.73k, False: 46]
  |  Branch (249:31): [True: 2.63k, False: 93]
  ------------------
  250|  2.63k|        ans->runs[k] = src->runs[k];
  251|  2.63k|        ans->n_runs++;
  252|  2.63k|    }
  253|       |
  254|    139|    run_container_smart_append_exclusive(
  255|    139|        ans, (uint16_t)range_start, (uint16_t)(range_end - range_start - 1));
  256|       |
  257|  3.32k|    for (; k < src->n_runs; ++k) {
  ------------------
  |  Branch (257:12): [True: 3.19k, False: 139]
  ------------------
  258|  3.19k|        run_container_smart_append_exclusive(ans, src->runs[k].value,
  259|  3.19k|                                             src->runs[k].length);
  260|  3.19k|    }
  261|       |
  262|    139|    *dst = convert_run_to_efficient_container(ans, &return_typecode);
  263|    139|    if (return_typecode != RUN_CONTAINER_TYPE) run_container_free(ans);
  ------------------
  |  |   50|    139|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (263:9): [True: 7, False: 132]
  ------------------
  264|       |
  265|    139|    return return_typecode;
  266|    139|}
run_container_negation_range_inplace:
  278|  7.30k|                                         container_t **dst) {
  279|  7.30k|    uint8_t return_typecode;
  280|       |
  281|  7.30k|    if (range_end <= range_start) {
  ------------------
  |  Branch (281:9): [True: 0, False: 7.30k]
  ------------------
  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|  7.30k|    if (src->capacity == src->n_runs) {
  ------------------
  |  Branch (288:9): [True: 6.14k, False: 1.16k]
  ------------------
  289|       |        // no excess room.  More checking to see if result can fit
  290|  6.14k|        bool last_val_before_range = false;
  291|  6.14k|        bool first_val_in_range = false;
  292|  6.14k|        bool last_val_in_range = false;
  293|  6.14k|        bool first_val_past_range = false;
  294|       |
  295|  6.14k|        if (range_start > 0)
  ------------------
  |  Branch (295:13): [True: 174, False: 5.96k]
  ------------------
  296|    174|            last_val_before_range =
  297|    174|                run_container_contains(src, (uint16_t)(range_start - 1));
  298|  6.14k|        first_val_in_range = run_container_contains(src, (uint16_t)range_start);
  299|       |
  300|  6.14k|        if (last_val_before_range == first_val_in_range) {
  ------------------
  |  Branch (300:13): [True: 449, False: 5.69k]
  ------------------
  301|    449|            last_val_in_range =
  302|    449|                run_container_contains(src, (uint16_t)(range_end - 1));
  303|    449|            if (range_end != 0x10000)
  ------------------
  |  Branch (303:17): [True: 277, False: 172]
  ------------------
  304|    277|                first_val_past_range =
  305|    277|                    run_container_contains(src, (uint16_t)range_end);
  306|       |
  307|    449|            if (last_val_in_range ==
  ------------------
  |  Branch (307:17): [True: 139, False: 310]
  ------------------
  308|    449|                first_val_past_range) {  // no space for inplace
  309|    139|                int ans = run_container_negation_range(src, range_start,
  310|    139|                                                       range_end, dst);
  311|    139|                run_container_free(src);
  312|    139|                return ans;
  313|    139|            }
  314|    449|        }
  315|  6.14k|    }
  316|       |    // all other cases: result will fit
  317|       |
  318|  7.16k|    run_container_t *ans = src;
  319|  7.16k|    int my_nbr_runs = src->n_runs;
  320|       |
  321|  7.16k|    ans->n_runs = 0;
  322|  7.16k|    int k = 0;
  323|  8.41k|    for (; (k < my_nbr_runs) && (src->runs[k].value < range_start); ++k) {
  ------------------
  |  Branch (323:12): [True: 8.33k, False: 73]
  |  Branch (323:33): [True: 1.24k, False: 7.09k]
  ------------------
  324|       |        // ans->runs[k] = src->runs[k]; (would be self-copy)
  325|  1.24k|        ans->n_runs++;
  326|  1.24k|    }
  327|       |
  328|       |    // as with Java implementation, use locals to give self a buffer of depth 1
  329|  7.16k|    rle16_t buffered = CROARING_MAKE_RLE16(0, 0);
  ------------------
  |  |   60|  7.16k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  330|  7.16k|    rle16_t next = buffered;
  331|  7.16k|    if (k < my_nbr_runs) buffered = src->runs[k];
  ------------------
  |  Branch (331:9): [True: 7.09k, False: 73]
  ------------------
  332|       |
  333|  7.16k|    run_container_smart_append_exclusive(
  334|  7.16k|        ans, (uint16_t)range_start, (uint16_t)(range_end - range_start - 1));
  335|       |
  336|  95.9k|    for (; k < my_nbr_runs; ++k) {
  ------------------
  |  Branch (336:12): [True: 88.7k, False: 7.16k]
  ------------------
  337|  88.7k|        if (k + 1 < my_nbr_runs) next = src->runs[k + 1];
  ------------------
  |  Branch (337:13): [True: 81.7k, False: 7.09k]
  ------------------
  338|       |
  339|  88.7k|        run_container_smart_append_exclusive(ans, buffered.value,
  340|  88.7k|                                             buffered.length);
  341|  88.7k|        buffered = next;
  342|  88.7k|    }
  343|       |
  344|  7.16k|    *dst = convert_run_to_efficient_container(ans, &return_typecode);
  345|  7.16k|    if (return_typecode != RUN_CONTAINER_TYPE) run_container_free(ans);
  ------------------
  |  |   50|  7.16k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (345:9): [True: 5.50k, False: 1.66k]
  ------------------
  346|       |
  347|  7.16k|    return return_typecode;
  348|  7.30k|}

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

array_bitset_container_union:
   24|  1.32k|                                  bitset_container_t *dst) {
   25|  1.32k|    if (src_2 != dst) bitset_container_copy(src_2, dst);
  ------------------
  |  Branch (25:9): [True: 1.32k, False: 0]
  ------------------
   26|  1.32k|    dst->cardinality = (int32_t)bitset_set_list_withcard(
   27|  1.32k|        dst->words, dst->cardinality, src_1->array, src_1->cardinality);
   28|  1.32k|}
run_bitset_container_union:
   43|  1.29k|                                bitset_container_t *dst) {
   44|  1.29k|    assert(!run_container_is_full(src_1));  // catch this case upstream
   45|  1.29k|    if (src_2 != dst) bitset_container_copy(src_2, dst);
  ------------------
  |  Branch (45:9): [True: 1.29k, False: 0]
  ------------------
   46|   104k|    for (int32_t rlepos = 0; rlepos < src_1->n_runs; ++rlepos) {
  ------------------
  |  Branch (46:30): [True: 103k, False: 1.29k]
  ------------------
   47|   103k|        rle16_t rle = src_1->runs[rlepos];
   48|   103k|        bitset_set_lenrange(dst->words, rle.value, rle.length);
   49|   103k|    }
   50|  1.29k|    dst->cardinality = bitset_container_compute_cardinality(dst);
   51|  1.29k|}
array_run_container_union:
   68|  2.66k|                               run_container_t *dst) {
   69|  2.66k|    if (run_container_is_full(src_2)) {
  ------------------
  |  Branch (69:9): [True: 85, False: 2.58k]
  ------------------
   70|     85|        run_container_copy(src_2, dst);
   71|     85|        return;
   72|     85|    }
   73|       |    // TODO: see whether the "2*" is spurious
   74|  2.58k|    run_container_grow(dst, 2 * (src_1->cardinality + src_2->n_runs), false);
   75|  2.58k|    int32_t rlepos = 0;
   76|  2.58k|    int32_t arraypos = 0;
   77|  2.58k|    rle16_t previousrle;
   78|  2.58k|    if (src_2->runs[rlepos].value <= src_1->array[arraypos]) {
  ------------------
  |  Branch (78:9): [True: 1.95k, False: 622]
  ------------------
   79|  1.95k|        previousrle = run_container_append_first(dst, src_2->runs[rlepos]);
   80|  1.95k|        rlepos++;
   81|  1.95k|    } else {
   82|    622|        previousrle =
   83|    622|            run_container_append_value_first(dst, src_1->array[arraypos]);
   84|    622|        arraypos++;
   85|    622|    }
   86|   458k|    while ((rlepos < src_2->n_runs) && (arraypos < src_1->cardinality)) {
  ------------------
  |  Branch (86:12): [True: 457k, False: 1.64k]
  |  Branch (86:40): [True: 456k, False: 934]
  ------------------
   87|   456k|        if (src_2->runs[rlepos].value <= src_1->array[arraypos]) {
  ------------------
  |  Branch (87:13): [True: 147k, False: 308k]
  ------------------
   88|   147k|            run_container_append(dst, src_2->runs[rlepos], &previousrle);
   89|   147k|            rlepos++;
   90|   308k|        } else {
   91|   308k|            run_container_append_value(dst, src_1->array[arraypos],
   92|   308k|                                       &previousrle);
   93|   308k|            arraypos++;
   94|   308k|        }
   95|   456k|    }
   96|  2.58k|    if (arraypos < src_1->cardinality) {
  ------------------
  |  Branch (96:9): [True: 1.64k, False: 934]
  ------------------
   97|   174k|        while (arraypos < src_1->cardinality) {
  ------------------
  |  Branch (97:16): [True: 172k, False: 1.64k]
  ------------------
   98|   172k|            run_container_append_value(dst, src_1->array[arraypos],
   99|   172k|                                       &previousrle);
  100|   172k|            arraypos++;
  101|   172k|        }
  102|  1.64k|    } else {
  103|  6.68k|        while (rlepos < src_2->n_runs) {
  ------------------
  |  Branch (103:16): [True: 5.75k, False: 934]
  ------------------
  104|  5.75k|            run_container_append(dst, src_2->runs[rlepos], &previousrle);
  105|  5.75k|            rlepos++;
  106|  5.75k|        }
  107|    934|    }
  108|  2.58k|}
array_run_container_inplace_union:
  111|    256|                                       run_container_t *src_2) {
  112|    256|    if (run_container_is_full(src_2)) {
  ------------------
  |  Branch (112:9): [True: 0, False: 256]
  ------------------
  113|      0|        return;
  114|      0|    }
  115|    256|    const int32_t maxoutput = src_1->cardinality + src_2->n_runs;
  116|    256|    const int32_t neededcapacity = maxoutput + src_2->n_runs;
  117|    256|    if (src_2->capacity < neededcapacity)
  ------------------
  |  Branch (117:9): [True: 256, False: 0]
  ------------------
  118|    256|        run_container_grow(src_2, neededcapacity, true);
  119|    256|    memmove(src_2->runs + maxoutput, src_2->runs,
  120|    256|            src_2->n_runs * sizeof(rle16_t));
  121|    256|    rle16_t *inputsrc2 = src_2->runs + maxoutput;
  122|    256|    int32_t rlepos = 0;
  123|    256|    int32_t arraypos = 0;
  124|    256|    int src2nruns = src_2->n_runs;
  125|    256|    src_2->n_runs = 0;
  126|       |
  127|    256|    rle16_t previousrle;
  128|       |
  129|    256|    if (inputsrc2[rlepos].value <= src_1->array[arraypos]) {
  ------------------
  |  Branch (129:9): [True: 210, False: 46]
  ------------------
  130|    210|        previousrle = run_container_append_first(src_2, inputsrc2[rlepos]);
  131|    210|        rlepos++;
  132|    210|    } else {
  133|     46|        previousrle =
  134|     46|            run_container_append_value_first(src_2, src_1->array[arraypos]);
  135|     46|        arraypos++;
  136|     46|    }
  137|       |
  138|  51.3k|    while ((rlepos < src2nruns) && (arraypos < src_1->cardinality)) {
  ------------------
  |  Branch (138:12): [True: 51.1k, False: 256]
  |  Branch (138:36): [True: 51.1k, False: 0]
  ------------------
  139|  51.1k|        if (inputsrc2[rlepos].value <= src_1->array[arraypos]) {
  ------------------
  |  Branch (139:13): [True: 12.9k, False: 38.1k]
  ------------------
  140|  12.9k|            run_container_append(src_2, inputsrc2[rlepos], &previousrle);
  141|  12.9k|            rlepos++;
  142|  38.1k|        } else {
  143|  38.1k|            run_container_append_value(src_2, src_1->array[arraypos],
  144|  38.1k|                                       &previousrle);
  145|  38.1k|            arraypos++;
  146|  38.1k|        }
  147|  51.1k|    }
  148|    256|    if (arraypos < src_1->cardinality) {
  ------------------
  |  Branch (148:9): [True: 256, False: 0]
  ------------------
  149|  2.51k|        while (arraypos < src_1->cardinality) {
  ------------------
  |  Branch (149:16): [True: 2.25k, False: 256]
  ------------------
  150|  2.25k|            run_container_append_value(src_2, src_1->array[arraypos],
  151|  2.25k|                                       &previousrle);
  152|  2.25k|            arraypos++;
  153|  2.25k|        }
  154|    256|    } 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|    256|}
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.22k, False: 103]
  ------------------
  167|  2.22k|        *dst = array_container_create_given_capacity(totalCardinality);
  168|  2.22k|        if (*dst != NULL) {
  ------------------
  |  Branch (168:13): [True: 2.22k, False: 0]
  ------------------
  169|  2.22k|            array_container_union(src_1, src_2, CAST_array(*dst));
  ------------------
  |  |   54|  2.22k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  2.22k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  170|  2.22k|        } else {
  171|      0|            return true;  // otherwise failure won't be caught
  172|      0|        }
  173|  2.22k|        return false;  // not a bitset
  174|  2.22k|    }
  175|    103|    *dst = bitset_container_create();
  176|    103|    bool returnval = true;  // expect a bitset
  177|    103|    if (*dst != NULL) {
  ------------------
  |  Branch (177:9): [True: 103, False: 0]
  ------------------
  178|    103|        bitset_container_t *ourbitset = CAST_bitset(*dst);
  ------------------
  |  |   52|    103|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    103|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  179|    103|        bitset_set_list(ourbitset->words, src_1->array, src_1->cardinality);
  180|    103|        ourbitset->cardinality = (int32_t)bitset_set_list_withcard(
  181|    103|            ourbitset->words, src_1->cardinality, src_2->array,
  182|    103|            src_2->cardinality);
  183|    103|        if (ourbitset->cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (183:13): [True: 61, False: 42]
  ------------------
  184|       |            // need to convert!
  185|     61|            *dst = array_container_from_bitset(ourbitset);
  186|     61|            bitset_container_free(ourbitset);
  187|       |            returnval = false;  // not going to be a bitset
  188|     61|        }
  189|    103|    }
  190|    103|    return returnval;
  191|  2.32k|}
array_array_container_inplace_union:
  195|  2.50k|                                         container_t **dst) {
  196|  2.50k|    int totalCardinality = src_1->cardinality + src_2->cardinality;
  197|  2.50k|    *dst = NULL;
  198|  2.50k|    if (totalCardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (198:9): [True: 2.42k, False: 77]
  ------------------
  199|  2.42k|        if (src_1->capacity < totalCardinality) {
  ------------------
  |  Branch (199:13): [True: 2.42k, False: 0]
  ------------------
  200|  2.42k|            *dst = array_container_create_given_capacity(
  201|  2.42k|                2 * totalCardinality);  // be purposefully generous
  202|  2.42k|            if (*dst != NULL) {
  ------------------
  |  Branch (202:17): [True: 2.42k, False: 0]
  ------------------
  203|  2.42k|                array_container_union(src_1, src_2, CAST_array(*dst));
  ------------------
  |  |   54|  2.42k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  2.42k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  204|  2.42k|            } else {
  205|      0|                return true;  // otherwise failure won't be caught
  206|      0|            }
  207|  2.42k|            return false;  // not a bitset
  208|  2.42k|        } 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.42k|    }
  221|     77|    *dst = bitset_container_create();
  222|     77|    bool returnval = true;  // expect a bitset
  223|     77|    if (*dst != NULL) {
  ------------------
  |  Branch (223:9): [True: 77, False: 0]
  ------------------
  224|     77|        bitset_container_t *ourbitset = CAST_bitset(*dst);
  ------------------
  |  |   52|     77|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     77|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  225|     77|        bitset_set_list(ourbitset->words, src_1->array, src_1->cardinality);
  226|     77|        ourbitset->cardinality = (int32_t)bitset_set_list_withcard(
  227|     77|            ourbitset->words, src_1->cardinality, src_2->array,
  228|     77|            src_2->cardinality);
  229|     77|        if (ourbitset->cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (229:13): [True: 77, False: 0]
  ------------------
  230|       |            // need to convert!
  231|     77|            if (src_1->capacity < ourbitset->cardinality) {
  ------------------
  |  Branch (231:17): [True: 77, False: 0]
  ------------------
  232|     77|                array_container_grow(src_1, ourbitset->cardinality, false);
  233|     77|            }
  234|       |
  235|     77|            bitset_extract_setbits_uint16(ourbitset->words,
  236|     77|                                          BITSET_CONTAINER_SIZE_IN_WORDS,
  237|     77|                                          src_1->array, 0);
  238|     77|            src_1->cardinality = ourbitset->cardinality;
  239|     77|            *dst = src_1;
  240|     77|            bitset_container_free(ourbitset);
  241|       |            returnval = false;  // not going to be a bitset
  242|     77|        }
  243|     77|    }
  244|     77|    return returnval;
  245|  2.50k|}

array_bitset_container_xor:
   25|    757|                                container_t **dst) {
   26|    757|    bitset_container_t *result = bitset_container_create();
   27|    757|    bitset_container_copy(src_2, result);
   28|    757|    result->cardinality = (int32_t)bitset_flip_list_withcard(
   29|    757|        result->words, result->cardinality, src_1->array, src_1->cardinality);
   30|       |
   31|       |    // do required type conversions.
   32|    757|    if (result->cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (32:9): [True: 171, False: 586]
  ------------------
   33|    171|        *dst = array_container_from_bitset(result);
   34|    171|        bitset_container_free(result);
   35|    171|        return false;  // not bitset
   36|    171|    }
   37|    586|    *dst = result;
   38|       |    return true;  // bitset
   39|    757|}
run_bitset_container_xor:
   63|    731|                              container_t **dst) {
   64|    731|    bitset_container_t *result = bitset_container_create();
   65|       |
   66|    731|    bitset_container_copy(src_2, result);
   67|  56.3k|    for (int32_t rlepos = 0; rlepos < src_1->n_runs; ++rlepos) {
  ------------------
  |  Branch (67:30): [True: 55.5k, False: 731]
  ------------------
   68|  55.5k|        rle16_t rle = src_1->runs[rlepos];
   69|  55.5k|        bitset_flip_range(result->words, rle.value,
   70|  55.5k|                          rle.value + rle.length + UINT32_C(1));
   71|  55.5k|    }
   72|    731|    result->cardinality = bitset_container_compute_cardinality(result);
   73|       |
   74|    731|    if (result->cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (74:9): [True: 124, False: 607]
  ------------------
   75|    124|        *dst = array_container_from_bitset(result);
   76|    124|        bitset_container_free(result);
   77|    124|        return false;  // not bitset
   78|    124|    }
   79|    607|    *dst = result;
   80|       |    return true;  // bitset
   81|    731|}
array_run_container_xor:
  105|  2.36k|                            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.36k|    const int arbitrary_threshold = 32;
  113|  2.36k|    if (src_1->cardinality < arbitrary_threshold) {
  ------------------
  |  Branch (113:9): [True: 919, False: 1.44k]
  ------------------
  114|    919|        run_container_t *ans = run_container_create();
  115|    919|        array_run_container_lazy_xor(src_1, src_2, ans);  // keeps runs.
  116|    919|        uint8_t typecode_after;
  117|    919|        *dst =
  118|    919|            convert_run_to_efficient_container_and_free(ans, &typecode_after);
  119|    919|        return typecode_after;
  120|    919|    }
  121|       |
  122|  1.44k|    int card = run_container_cardinality(src_2);
  123|  1.44k|    if (card <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (123:9): [True: 1.18k, False: 255]
  ------------------
  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|      8|#define BITSET_CONTAINER_TYPE 1
  ------------------
                      return ret_is_bitset ? BITSET_CONTAINER_TYPE : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  1.17k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (129:16): [True: 8, False: 1.17k]
  ------------------
  130|       |
  131|  1.18k|    } else {  // guess that it will end up as a bitset
  132|    255|        bitset_container_t *result = bitset_container_from_run(src_2);
  133|    255|        bool is_bitset = bitset_array_container_ixor(result, src_1, dst);
  134|       |        // any necessary type conversion has been done by the ixor
  135|    255|        int retval = (is_bitset ? BITSET_CONTAINER_TYPE : ARRAY_CONTAINER_TYPE);
  ------------------
  |  |   48|    236|#define BITSET_CONTAINER_TYPE 1
  ------------------
                      int retval = (is_bitset ? BITSET_CONTAINER_TYPE : ARRAY_CONTAINER_TYPE);
  ------------------
  |  |   49|     19|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (135:23): [True: 236, False: 19]
  ------------------
  136|    255|        return retval;
  137|    255|    }
  138|  1.44k|}
array_run_container_lazy_xor:
  147|    919|                                  run_container_t *dst) {
  148|    919|    run_container_grow(dst, src_1->cardinality + src_2->n_runs, false);
  149|    919|    int32_t rlepos = 0;
  150|    919|    int32_t arraypos = 0;
  151|    919|    dst->n_runs = 0;
  152|       |
  153|  28.2k|    while ((rlepos < src_2->n_runs) && (arraypos < src_1->cardinality)) {
  ------------------
  |  Branch (153:12): [True: 27.6k, False: 554]
  |  Branch (153:40): [True: 27.3k, False: 365]
  ------------------
  154|  27.3k|        if (src_2->runs[rlepos].value <= src_1->array[arraypos]) {
  ------------------
  |  Branch (154:13): [True: 16.4k, False: 10.8k]
  ------------------
  155|  16.4k|            run_container_smart_append_exclusive(dst, src_2->runs[rlepos].value,
  156|  16.4k|                                                 src_2->runs[rlepos].length);
  157|  16.4k|            rlepos++;
  158|  16.4k|        } else {
  159|  10.8k|            run_container_smart_append_exclusive(dst, src_1->array[arraypos],
  160|  10.8k|                                                 0);
  161|  10.8k|            arraypos++;
  162|  10.8k|        }
  163|  27.3k|    }
  164|  3.06k|    while (arraypos < src_1->cardinality) {
  ------------------
  |  Branch (164:12): [True: 2.14k, False: 919]
  ------------------
  165|  2.14k|        run_container_smart_append_exclusive(dst, src_1->array[arraypos], 0);
  166|  2.14k|        arraypos++;
  167|  2.14k|    }
  168|  7.86k|    while (rlepos < src_2->n_runs) {
  ------------------
  |  Branch (168:12): [True: 6.94k, False: 919]
  ------------------
  169|  6.94k|        run_container_smart_append_exclusive(dst, src_2->runs[rlepos].value,
  170|  6.94k|                                             src_2->runs[rlepos].length);
  171|  6.94k|        rlepos++;
  172|  6.94k|    }
  173|    919|}
run_run_container_xor:
  180|  60.5k|                          const run_container_t *src_2, container_t **dst) {
  181|  60.5k|    run_container_t *ans = run_container_create();
  182|  60.5k|    run_container_xor(src_1, src_2, ans);
  183|  60.5k|    uint8_t typecode_after;
  184|  60.5k|    *dst = convert_run_to_efficient_container_and_free(ans, &typecode_after);
  185|  60.5k|    return typecode_after;
  186|  60.5k|}
array_array_container_xor:
  198|  8.55k|                               container_t **dst) {
  199|  8.55k|    int totalCardinality =
  200|  8.55k|        src_1->cardinality + src_2->cardinality;  // upper bound
  201|  8.55k|    if (totalCardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (201:9): [True: 8.02k, False: 529]
  ------------------
  202|  8.02k|        *dst = array_container_create_given_capacity(totalCardinality);
  203|  8.02k|        array_container_xor(src_1, src_2, CAST_array(*dst));
  ------------------
  |  |   54|  8.02k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  8.02k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  204|  8.02k|        return false;  // not a bitset
  205|  8.02k|    }
  206|    529|    *dst = bitset_container_from_array(src_1);
  207|    529|    bool returnval = true;  // expect a bitset
  208|    529|    bitset_container_t *ourbitset = CAST_bitset(*dst);
  ------------------
  |  |   52|    529|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    529|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  209|    529|    ourbitset->cardinality = (uint32_t)bitset_flip_list_withcard(
  210|    529|        ourbitset->words, src_1->cardinality, src_2->array, src_2->cardinality);
  211|    529|    if (ourbitset->cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (211:9): [True: 509, False: 20]
  ------------------
  212|       |        // need to convert!
  213|    509|        *dst = array_container_from_bitset(ourbitset);
  214|    509|        bitset_container_free(ourbitset);
  215|    509|        returnval = false;  // not going to be a bitset
  216|    509|    }
  217|       |
  218|    529|    return returnval;
  219|  8.55k|}
bitset_array_container_ixor:
  284|    255|                                 container_t **dst) {
  285|    255|    *dst = src_1;
  286|    255|    src_1->cardinality = (uint32_t)bitset_flip_list_withcard(
  287|    255|        src_1->words, src_1->cardinality, src_2->array, src_2->cardinality);
  288|       |
  289|    255|    if (src_1->cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (289:9): [True: 19, False: 236]
  ------------------
  290|     19|        *dst = array_container_from_bitset(src_1);
  291|     19|        bitset_container_free(src_1);
  292|     19|        return false;  // not bitset
  293|     19|    } else
  294|    236|        return true;
  295|    255|}
bitset_bitset_container_ixor:
  304|  1.56k|                                  container_t **dst) {
  305|  1.56k|    int card = bitset_container_xor(src_1, src_2, src_1);
  306|  1.56k|    if (card <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (306:9): [True: 1.56k, False: 0]
  ------------------
  307|  1.56k|        *dst = array_container_from_bitset(src_1);
  308|  1.56k|        bitset_container_free(src_1);
  309|  1.56k|        return false;  // not bitset
  310|  1.56k|    } else {
  311|      0|        *dst = src_1;
  312|       |        return true;
  313|      0|    }
  314|  1.56k|}
array_bitset_container_ixor:
  318|    117|                                 container_t **dst) {
  319|       |    bool ans = array_bitset_container_xor(src_1, src_2, dst);
  320|    117|    array_container_free(src_1);
  321|    117|    return ans;
  322|    117|}
run_bitset_container_ixor:
  333|     14|                               container_t **dst) {
  334|       |    bool ans = run_bitset_container_xor(src_1, src_2, dst);
  335|     14|    run_container_free(src_1);
  336|     14|    return ans;
  337|     14|}
bitset_run_container_ixor:
  341|     69|                               container_t **dst) {
  342|       |    bool ans = run_bitset_container_xor(src_2, src_1, dst);
  343|     69|    bitset_container_free(src_1);
  344|     69|    return ans;
  345|     69|}
array_run_container_ixor:
  352|    271|                             const run_container_t *src_2, container_t **dst) {
  353|    271|    int ans = array_run_container_xor(src_1, src_2, dst);
  354|    271|    array_container_free(src_1);
  355|    271|    return ans;
  356|    271|}
run_array_container_ixor:
  360|     58|                             container_t **dst) {
  361|     58|    int ans = array_run_container_xor(src_2, src_1, dst);
  362|     58|    run_container_free(src_1);
  363|     58|    return ans;
  364|     58|}
array_array_container_ixor:
  368|  5.04k|                                container_t **dst) {
  369|       |    bool ans = array_array_container_xor(src_1, src_2, dst);
  370|  5.04k|    array_container_free(src_1);
  371|  5.04k|    return ans;
  372|  5.04k|}
run_run_container_ixor:
  375|  59.8k|                           container_t **dst) {
  376|  59.8k|    int ans = run_run_container_xor(src_1, src_2, dst);
  377|  59.8k|    run_container_free(src_1);
  378|  59.8k|    return ans;
  379|  59.8k|}

run_container_add:
   39|   411k|bool run_container_add(run_container_t *run, uint16_t pos) {
   40|   411k|    int32_t index = interleavedBinarySearch(run->runs, run->n_runs, pos);
   41|   411k|    if (index >= 0) return false;  // already there
  ------------------
  |  Branch (41:9): [True: 190k, False: 221k]
  ------------------
   42|   221k|    index = -index - 2;            // points to preceding value, possibly -1
   43|   221k|    if (index >= 0) {              // possible match
  ------------------
  |  Branch (43:9): [True: 221k, False: 329]
  ------------------
   44|   221k|        int32_t offset = pos - run->runs[index].value;
   45|   221k|        int32_t le = run->runs[index].length;
   46|   221k|        if (offset <= le) return false;  // already there
  ------------------
  |  Branch (46:13): [True: 129k, False: 92.2k]
  ------------------
   47|  92.2k|        if (offset == le + 1) {
  ------------------
  |  Branch (47:13): [True: 13.8k, False: 78.4k]
  ------------------
   48|       |            // we may need to fuse
   49|  13.8k|            if (index + 1 < run->n_runs) {
  ------------------
  |  Branch (49:17): [True: 13.5k, False: 255]
  ------------------
   50|  13.5k|                if (run->runs[index + 1].value == pos + 1) {
  ------------------
  |  Branch (50:21): [True: 6.10k, False: 7.43k]
  ------------------
   51|       |                    // indeed fusion is needed
   52|  6.10k|                    run->runs[index].length = run->runs[index + 1].value +
   53|  6.10k|                                              run->runs[index + 1].length -
   54|  6.10k|                                              run->runs[index].value;
   55|  6.10k|                    recoverRoomAtIndex(run, (uint16_t)(index + 1));
   56|  6.10k|                    return true;
   57|  6.10k|                }
   58|  13.5k|            }
   59|  7.69k|            run->runs[index].length++;
   60|  7.69k|            return true;
   61|  13.8k|        }
   62|  78.4k|        if (index + 1 < run->n_runs) {
  ------------------
  |  Branch (62:13): [True: 76.6k, False: 1.79k]
  ------------------
   63|       |            // we may need to fuse
   64|  76.6k|            if (run->runs[index + 1].value == pos + 1) {
  ------------------
  |  Branch (64:17): [True: 32.5k, False: 44.1k]
  ------------------
   65|       |                // indeed fusion is needed
   66|  32.5k|                run->runs[index + 1].value = pos;
   67|  32.5k|                run->runs[index + 1].length = run->runs[index + 1].length + 1;
   68|  32.5k|                return true;
   69|  32.5k|            }
   70|  76.6k|        }
   71|  78.4k|    }
   72|  46.2k|    if (index == -1) {
  ------------------
  |  Branch (72:9): [True: 329, False: 45.9k]
  ------------------
   73|       |        // we may need to extend the first run
   74|    329|        if (0 < run->n_runs) {
  ------------------
  |  Branch (74:13): [True: 329, False: 0]
  ------------------
   75|    329|            if (run->runs[0].value == pos + 1) {
  ------------------
  |  Branch (75:17): [True: 217, False: 112]
  ------------------
   76|    217|                run->runs[0].length++;
   77|    217|                run->runs[0].value--;
   78|    217|                return true;
   79|    217|            }
   80|    329|        }
   81|    329|    }
   82|  46.0k|    makeRoomAtIndex(run, (uint16_t)(index + 1));
   83|  46.0k|    run->runs[index + 1].value = pos;
   84|  46.0k|    run->runs[index + 1].length = 0;
   85|       |    return true;
   86|  46.2k|}
run_container_create_given_capacity:
   89|   401k|run_container_t *run_container_create_given_capacity(int32_t size) {
   90|   401k|    run_container_t *run;
   91|       |    /* Allocate the run container itself. */
   92|   401k|    if ((run = (run_container_t *)roaring_malloc(sizeof(run_container_t))) ==
  ------------------
  |  Branch (92:9): [True: 0, False: 401k]
  ------------------
   93|   401k|        NULL) {
   94|      0|        return NULL;
   95|      0|    }
   96|   401k|    if (size <= 0) {  // we don't want to rely on malloc(0)
  ------------------
  |  Branch (96:9): [True: 127k, False: 273k]
  ------------------
   97|   127k|        run->runs = NULL;
   98|   273k|    } else if ((run->runs = (rle16_t *)roaring_malloc(sizeof(rle16_t) *
  ------------------
  |  Branch (98:16): [True: 0, False: 273k]
  ------------------
   99|   273k|                                                      size)) == NULL) {
  100|      0|        roaring_free(run);
  101|      0|        return NULL;
  102|      0|    }
  103|   401k|    run->capacity = size;
  104|   401k|    run->n_runs = 0;
  105|   401k|    return run;
  106|   401k|}
run_container_shrink_to_fit:
  108|  2.61k|int run_container_shrink_to_fit(run_container_t *src) {
  109|  2.61k|    if (src->n_runs == src->capacity) return 0;  // nothing to do
  ------------------
  |  Branch (109:9): [True: 2.61k, 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.61k|}
run_container_create:
  119|   127k|run_container_t *run_container_create(void) {
  120|   127k|    return run_container_create_given_capacity(RUN_DEFAULT_INIT_SIZE);
  121|   127k|}
run_container_clone:
  124|   179k|run_container_t *run_container_clone(const run_container_t *src) {
  125|   179k|    run_container_t *run = run_container_create_given_capacity(src->capacity);
  126|   179k|    if (run == NULL) return NULL;
  ------------------
  |  Branch (126:9): [True: 0, False: 179k]
  ------------------
  127|   179k|    run->capacity = src->capacity;
  128|   179k|    run->n_runs = src->n_runs;
  129|   179k|    memcpy(run->runs, src->runs, src->n_runs * sizeof(rle16_t));
  130|   179k|    return run;
  131|   179k|}
run_container_free:
  193|   401k|void run_container_free(run_container_t *run) {
  194|   401k|    if (run == NULL) return;
  ------------------
  |  Branch (194:9): [True: 0, False: 401k]
  ------------------
  195|   401k|    roaring_free(run->runs);
  196|   401k|    roaring_free(run);
  197|   401k|}
run_container_grow:
  199|   132k|void run_container_grow(run_container_t *run, int32_t min, bool copy) {
  200|   132k|    int32_t newCapacity = (run->capacity == 0)   ? RUN_DEFAULT_INIT_SIZE
  ------------------
  |  Branch (200:27): [True: 127k, False: 5.27k]
  ------------------
  201|   132k|                          : run->capacity < 64   ? run->capacity * 2
  ------------------
  |  Branch (201:29): [True: 3.65k, False: 1.61k]
  ------------------
  202|  5.27k|                          : run->capacity < 1024 ? run->capacity * 3 / 2
  ------------------
  |  Branch (202:29): [True: 1.61k, False: 0]
  ------------------
  203|  1.61k|                                                 : run->capacity * 5 / 4;
  204|   132k|    if (newCapacity < min) newCapacity = min;
  ------------------
  |  Branch (204:9): [True: 129k, False: 3.32k]
  ------------------
  205|   132k|    run->capacity = newCapacity;
  206|   132k|    assert(run->capacity >= min);
  207|   132k|    if (copy) {
  ------------------
  |  Branch (207:9): [True: 5.27k, False: 127k]
  ------------------
  208|  5.27k|        rle16_t *oldruns = run->runs;
  209|  5.27k|        run->runs = (rle16_t *)roaring_realloc(oldruns,
  210|  5.27k|                                               run->capacity * sizeof(rle16_t));
  211|  5.27k|        if (run->runs == NULL) roaring_free(oldruns);
  ------------------
  |  Branch (211:13): [True: 0, False: 5.27k]
  ------------------
  212|   127k|    } else {
  213|   127k|        roaring_free(run->runs);
  214|   127k|        run->runs = (rle16_t *)roaring_malloc(run->capacity * sizeof(rle16_t));
  215|   127k|    }
  216|       |    // We may have run->runs == NULL.
  217|   132k|}
run_container_copy:
  220|  58.0k|void run_container_copy(const run_container_t *src, run_container_t *dst) {
  221|  58.0k|    const int32_t n_runs = src->n_runs;
  222|  58.0k|    if (src->n_runs > dst->capacity) {
  ------------------
  |  Branch (222:9): [True: 58.0k, False: 26]
  ------------------
  223|       |        run_container_grow(dst, n_runs, false);
  224|  58.0k|    }
  225|  58.0k|    dst->n_runs = n_runs;
  226|  58.0k|    memcpy(dst->runs, src->runs, sizeof(rle16_t) * n_runs);
  227|  58.0k|}
run_container_union:
  232|    694|                         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|    694|    const bool if1 = run_container_is_full(src_1);
  237|    694|    const bool if2 = run_container_is_full(src_2);
  238|    694|    if (if1 || if2) {
  ------------------
  |  Branch (238:9): [True: 0, False: 694]
  |  Branch (238:16): [True: 16, False: 678]
  ------------------
  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|    678|    const int32_t neededcapacity = src_1->n_runs + src_2->n_runs;
  249|    678|    if (dst->capacity < neededcapacity)
  ------------------
  |  Branch (249:9): [True: 678, False: 0]
  ------------------
  250|    678|        run_container_grow(dst, neededcapacity, false);
  251|    678|    dst->n_runs = 0;
  252|    678|    int32_t rlepos = 0;
  253|    678|    int32_t xrlepos = 0;
  254|       |
  255|    678|    rle16_t previousrle;
  256|    678|    if (src_1->runs[rlepos].value <= src_2->runs[xrlepos].value) {
  ------------------
  |  Branch (256:9): [True: 632, False: 46]
  ------------------
  257|    632|        previousrle = run_container_append_first(dst, src_1->runs[rlepos]);
  258|    632|        rlepos++;
  259|    632|    } else {
  260|     46|        previousrle = run_container_append_first(dst, src_2->runs[xrlepos]);
  261|     46|        xrlepos++;
  262|     46|    }
  263|       |
  264|  85.8k|    while ((xrlepos < src_2->n_runs) && (rlepos < src_1->n_runs)) {
  ------------------
  |  Branch (264:12): [True: 85.5k, False: 266]
  |  Branch (264:41): [True: 85.1k, False: 412]
  ------------------
  265|  85.1k|        rle16_t newrl;
  266|  85.1k|        if (src_1->runs[rlepos].value <= src_2->runs[xrlepos].value) {
  ------------------
  |  Branch (266:13): [True: 45.8k, False: 39.3k]
  ------------------
  267|  45.8k|            newrl = src_1->runs[rlepos];
  268|  45.8k|            rlepos++;
  269|  45.8k|        } else {
  270|  39.3k|            newrl = src_2->runs[xrlepos];
  271|  39.3k|            xrlepos++;
  272|  39.3k|        }
  273|  85.1k|        run_container_append(dst, newrl, &previousrle);
  274|  85.1k|    }
  275|  1.82k|    while (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (275:12): [True: 1.14k, False: 678]
  ------------------
  276|  1.14k|        run_container_append(dst, src_2->runs[xrlepos], &previousrle);
  277|  1.14k|        xrlepos++;
  278|  1.14k|    }
  279|  12.2k|    while (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (279:12): [True: 11.5k, False: 678]
  ------------------
  280|  11.5k|        run_container_append(dst, src_1->runs[rlepos], &previousrle);
  281|  11.5k|        rlepos++;
  282|  11.5k|    }
  283|    678|}
run_container_union_inplace:
  288|  1.71k|                                 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.71k|    const bool if1 = run_container_is_full(src_1);
  293|  1.71k|    const bool if2 = run_container_is_full(src_2);
  294|  1.71k|    if (if1 || if2) {
  ------------------
  |  Branch (294:9): [True: 0, False: 1.71k]
  |  Branch (294:16): [True: 26, False: 1.68k]
  ------------------
  295|     26|        if (if1) {
  ------------------
  |  Branch (295:13): [True: 0, False: 26]
  ------------------
  296|      0|            return;
  297|      0|        }
  298|     26|        if (if2) {
  ------------------
  |  Branch (298:13): [True: 26, False: 0]
  ------------------
  299|     26|            run_container_copy(src_2, src_1);
  300|     26|            return;
  301|     26|        }
  302|     26|    }
  303|       |    // we move the data to the end of the current array
  304|  1.68k|    const int32_t maxoutput = src_1->n_runs + src_2->n_runs;
  305|  1.68k|    const int32_t neededcapacity = maxoutput + src_1->n_runs;
  306|  1.68k|    if (src_1->capacity < neededcapacity)
  ------------------
  |  Branch (306:9): [True: 1.68k, False: 0]
  ------------------
  307|  1.68k|        run_container_grow(src_1, neededcapacity, true);
  308|  1.68k|    memmove(src_1->runs + maxoutput, src_1->runs,
  309|  1.68k|            src_1->n_runs * sizeof(rle16_t));
  310|  1.68k|    rle16_t *inputsrc1 = src_1->runs + maxoutput;
  311|  1.68k|    const int32_t input1nruns = src_1->n_runs;
  312|  1.68k|    src_1->n_runs = 0;
  313|  1.68k|    int32_t rlepos = 0;
  314|  1.68k|    int32_t xrlepos = 0;
  315|       |
  316|  1.68k|    rle16_t previousrle;
  317|  1.68k|    if (inputsrc1[rlepos].value <= src_2->runs[xrlepos].value) {
  ------------------
  |  Branch (317:9): [True: 1.61k, False: 74]
  ------------------
  318|  1.61k|        previousrle = run_container_append_first(src_1, inputsrc1[rlepos]);
  319|  1.61k|        rlepos++;
  320|  1.61k|    } else {
  321|     74|        previousrle = run_container_append_first(src_1, src_2->runs[xrlepos]);
  322|     74|        xrlepos++;
  323|     74|    }
  324|   197k|    while ((xrlepos < src_2->n_runs) && (rlepos < input1nruns)) {
  ------------------
  |  Branch (324:12): [True: 197k, False: 147]
  |  Branch (324:41): [True: 196k, False: 1.54k]
  ------------------
  325|   196k|        rle16_t newrl;
  326|   196k|        if (inputsrc1[rlepos].value <= src_2->runs[xrlepos].value) {
  ------------------
  |  Branch (326:13): [True: 92.7k, False: 103k]
  ------------------
  327|  92.7k|            newrl = inputsrc1[rlepos];
  328|  92.7k|            rlepos++;
  329|   103k|        } else {
  330|   103k|            newrl = src_2->runs[xrlepos];
  331|   103k|            xrlepos++;
  332|   103k|        }
  333|   196k|        run_container_append(src_1, newrl, &previousrle);
  334|   196k|    }
  335|  4.42k|    while (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (335:12): [True: 2.73k, False: 1.68k]
  ------------------
  336|  2.73k|        run_container_append(src_1, src_2->runs[xrlepos], &previousrle);
  337|  2.73k|        xrlepos++;
  338|  2.73k|    }
  339|  9.51k|    while (rlepos < input1nruns) {
  ------------------
  |  Branch (339:12): [True: 7.83k, False: 1.68k]
  ------------------
  340|  7.83k|        run_container_append(src_1, inputsrc1[rlepos], &previousrle);
  341|  7.83k|        rlepos++;
  342|  7.83k|    }
  343|  1.68k|}
run_container_xor:
  349|  60.5k|                       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|  60.5k|    const int32_t neededcapacity = src_1->n_runs + src_2->n_runs;
  354|  60.5k|    if (dst->capacity < neededcapacity)
  ------------------
  |  Branch (354:9): [True: 60.5k, False: 0]
  ------------------
  355|  60.5k|        run_container_grow(dst, neededcapacity, false);
  356|       |
  357|  60.5k|    int32_t pos1 = 0;
  358|  60.5k|    int32_t pos2 = 0;
  359|  60.5k|    dst->n_runs = 0;
  360|       |
  361|   243k|    while ((pos1 < src_1->n_runs) && (pos2 < src_2->n_runs)) {
  ------------------
  |  Branch (361:12): [True: 182k, False: 60.2k]
  |  Branch (361:38): [True: 182k, False: 288]
  ------------------
  362|   182k|        if (src_1->runs[pos1].value <= src_2->runs[pos2].value) {
  ------------------
  |  Branch (362:13): [True: 122k, False: 60.0k]
  ------------------
  363|   122k|            run_container_smart_append_exclusive(dst, src_1->runs[pos1].value,
  364|   122k|                                                 src_1->runs[pos1].length);
  365|   122k|            pos1++;
  366|   122k|        } else {
  367|  60.0k|            run_container_smart_append_exclusive(dst, src_2->runs[pos2].value,
  368|  60.0k|                                                 src_2->runs[pos2].length);
  369|  60.0k|            pos2++;
  370|  60.0k|        }
  371|   182k|    }
  372|  73.4k|    while (pos1 < src_1->n_runs) {
  ------------------
  |  Branch (372:12): [True: 12.8k, False: 60.5k]
  ------------------
  373|  12.8k|        run_container_smart_append_exclusive(dst, src_1->runs[pos1].value,
  374|  12.8k|                                             src_1->runs[pos1].length);
  375|  12.8k|        pos1++;
  376|  12.8k|    }
  377|       |
  378|   123k|    while (pos2 < src_2->n_runs) {
  ------------------
  |  Branch (378:12): [True: 62.7k, False: 60.5k]
  ------------------
  379|  62.7k|        run_container_smart_append_exclusive(dst, src_2->runs[pos2].value,
  380|  62.7k|                                             src_2->runs[pos2].length);
  381|  62.7k|        pos2++;
  382|  62.7k|    }
  383|  60.5k|}
run_container_intersection:
  389|  61.5k|                                run_container_t *dst) {
  390|  61.5k|    const bool if1 = run_container_is_full(src_1);
  391|  61.5k|    const bool if2 = run_container_is_full(src_2);
  392|  61.5k|    if (if1 || if2) {
  ------------------
  |  Branch (392:9): [True: 57.9k, False: 3.66k]
  |  Branch (392:16): [True: 16, False: 3.64k]
  ------------------
  393|  57.9k|        if (if1) {
  ------------------
  |  Branch (393:13): [True: 57.9k, False: 16]
  ------------------
  394|  57.9k|            run_container_copy(src_2, dst);
  395|  57.9k|            return;
  396|  57.9k|        }
  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.64k|    const int32_t neededcapacity = src_1->n_runs + src_2->n_runs;
  404|  3.64k|    if (dst->capacity < neededcapacity)
  ------------------
  |  Branch (404:9): [True: 3.64k, False: 0]
  ------------------
  405|  3.64k|        run_container_grow(dst, neededcapacity, false);
  406|  3.64k|    dst->n_runs = 0;
  407|  3.64k|    int32_t rlepos = 0;
  408|  3.64k|    int32_t xrlepos = 0;
  409|  3.64k|    int32_t start = src_1->runs[rlepos].value;
  410|  3.64k|    int32_t end = start + src_1->runs[rlepos].length + 1;
  411|  3.64k|    int32_t xstart = src_2->runs[xrlepos].value;
  412|  3.64k|    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.22k]
  |  Branch (413:40): [True: 183k, False: 426]
  ------------------
  414|   183k|        if (end <= xstart) {
  ------------------
  |  Branch (414:13): [True: 47.3k, False: 136k]
  ------------------
  415|  47.3k|            ++rlepos;
  416|  47.3k|            if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (416:17): [True: 47.2k, False: 102]
  ------------------
  417|  47.2k|                start = src_1->runs[rlepos].value;
  418|  47.2k|                end = start + src_1->runs[rlepos].length + 1;
  419|  47.2k|            }
  420|   136k|        } else if (xend <= start) {
  ------------------
  |  Branch (420:20): [True: 13.7k, False: 122k]
  ------------------
  421|  13.7k|            ++xrlepos;
  422|  13.7k|            if (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (422:17): [True: 13.7k, False: 47]
  ------------------
  423|  13.7k|                xstart = src_2->runs[xrlepos].value;
  424|  13.7k|                xend = xstart + src_2->runs[xrlepos].length + 1;
  425|  13.7k|            }
  426|   122k|        } else {  // they overlap
  427|   122k|            const int32_t lateststart = start > xstart ? start : xstart;
  ------------------
  |  Branch (427:41): [True: 15.2k, False: 107k]
  ------------------
  428|   122k|            int32_t earliestend;
  429|   122k|            if (end == xend) {  // improbable
  ------------------
  |  Branch (429:17): [True: 92.4k, False: 30.0k]
  ------------------
  430|  92.4k|                earliestend = end;
  431|  92.4k|                rlepos++;
  432|  92.4k|                xrlepos++;
  433|  92.4k|                if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (433:21): [True: 89.4k, False: 2.97k]
  ------------------
  434|  89.4k|                    start = src_1->runs[rlepos].value;
  435|  89.4k|                    end = start + src_1->runs[rlepos].length + 1;
  436|  89.4k|                }
  437|  92.4k|                if (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (437:21): [True: 89.2k, False: 3.12k]
  ------------------
  438|  89.2k|                    xstart = src_2->runs[xrlepos].value;
  439|  89.2k|                    xend = xstart + src_2->runs[xrlepos].length + 1;
  440|  89.2k|                }
  441|  92.4k|            } else if (end < xend) {
  ------------------
  |  Branch (441:24): [True: 15.7k, False: 14.2k]
  ------------------
  442|  15.7k|                earliestend = end;
  443|  15.7k|                rlepos++;
  444|  15.7k|                if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (444:21): [True: 15.6k, False: 147]
  ------------------
  445|  15.6k|                    start = src_1->runs[rlepos].value;
  446|  15.6k|                    end = start + src_1->runs[rlepos].length + 1;
  447|  15.6k|                }
  448|       |
  449|  15.7k|            } else {  // end > xend
  450|  14.2k|                earliestend = xend;
  451|  14.2k|                xrlepos++;
  452|  14.2k|                if (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (452:21): [True: 14.1k, False: 141]
  ------------------
  453|  14.1k|                    xstart = src_2->runs[xrlepos].value;
  454|  14.1k|                    xend = xstart + src_2->runs[xrlepos].length + 1;
  455|  14.1k|                }
  456|  14.2k|            }
  457|   122k|            dst->runs[dst->n_runs].value = (uint16_t)lateststart;
  458|   122k|            dst->runs[dst->n_runs].length =
  459|   122k|                (uint16_t)(earliestend - lateststart - 1);
  460|   122k|            dst->n_runs++;
  461|   122k|        }
  462|   183k|    }
  463|  3.64k|}
run_container_intersection_cardinality:
  467|  2.77k|                                           const run_container_t *src_2) {
  468|  2.77k|    const bool if1 = run_container_is_full(src_1);
  469|  2.77k|    const bool if2 = run_container_is_full(src_2);
  470|  2.77k|    if (if1 || if2) {
  ------------------
  |  Branch (470:9): [True: 0, False: 2.77k]
  |  Branch (470:16): [True: 64, False: 2.71k]
  ------------------
  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.71k|    int answer = 0;
  479|  2.71k|    int32_t rlepos = 0;
  480|  2.71k|    int32_t xrlepos = 0;
  481|  2.71k|    int32_t start = src_1->runs[rlepos].value;
  482|  2.71k|    int32_t end = start + src_1->runs[rlepos].length + 1;
  483|  2.71k|    int32_t xstart = src_2->runs[xrlepos].value;
  484|  2.71k|    int32_t xend = xstart + src_2->runs[xrlepos].length + 1;
  485|   295k|    while ((rlepos < src_1->n_runs) && (xrlepos < src_2->n_runs)) {
  ------------------
  |  Branch (485:12): [True: 293k, False: 1.97k]
  |  Branch (485:40): [True: 292k, False: 736]
  ------------------
  486|   292k|        if (end <= xstart) {
  ------------------
  |  Branch (486:13): [True: 70.8k, False: 221k]
  ------------------
  487|  70.8k|            ++rlepos;
  488|  70.8k|            if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (488:17): [True: 70.4k, False: 408]
  ------------------
  489|  70.4k|                start = src_1->runs[rlepos].value;
  490|  70.4k|                end = start + src_1->runs[rlepos].length + 1;
  491|  70.4k|            }
  492|   221k|        } else if (xend <= start) {
  ------------------
  |  Branch (492:20): [True: 55.1k, False: 166k]
  ------------------
  493|  55.1k|            ++xrlepos;
  494|  55.1k|            if (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (494:17): [True: 54.9k, False: 188]
  ------------------
  495|  54.9k|                xstart = src_2->runs[xrlepos].value;
  496|  54.9k|                xend = xstart + src_2->runs[xrlepos].length + 1;
  497|  54.9k|            }
  498|   166k|        } else {  // they overlap
  499|   166k|            const int32_t lateststart = start > xstart ? start : xstart;
  ------------------
  |  Branch (499:41): [True: 61.1k, False: 105k]
  ------------------
  500|   166k|            int32_t earliestend;
  501|   166k|            if (end == xend) {  // improbable
  ------------------
  |  Branch (501:17): [True: 84.4k, False: 81.9k]
  ------------------
  502|  84.4k|                earliestend = end;
  503|  84.4k|                rlepos++;
  504|  84.4k|                xrlepos++;
  505|  84.4k|                if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (505:21): [True: 83.4k, False: 980]
  ------------------
  506|  83.4k|                    start = src_1->runs[rlepos].value;
  507|  83.4k|                    end = start + src_1->runs[rlepos].length + 1;
  508|  83.4k|                }
  509|  84.4k|                if (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (509:21): [True: 83.3k, False: 1.00k]
  ------------------
  510|  83.3k|                    xstart = src_2->runs[xrlepos].value;
  511|  83.3k|                    xend = xstart + src_2->runs[xrlepos].length + 1;
  512|  83.3k|                }
  513|  84.4k|            } else if (end < xend) {
  ------------------
  |  Branch (513:24): [True: 63.0k, False: 18.9k]
  ------------------
  514|  63.0k|                earliestend = end;
  515|  63.0k|                rlepos++;
  516|  63.0k|                if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (516:21): [True: 62.4k, False: 588]
  ------------------
  517|  62.4k|                    start = src_1->runs[rlepos].value;
  518|  62.4k|                    end = start + src_1->runs[rlepos].length + 1;
  519|  62.4k|                }
  520|       |
  521|  63.0k|            } else {  // end > xend
  522|  18.9k|                earliestend = xend;
  523|  18.9k|                xrlepos++;
  524|  18.9k|                if (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (524:21): [True: 18.7k, False: 184]
  ------------------
  525|  18.7k|                    xstart = src_2->runs[xrlepos].value;
  526|  18.7k|                    xend = xstart + src_2->runs[xrlepos].length + 1;
  527|  18.7k|                }
  528|  18.9k|            }
  529|   166k|            answer += earliestend - lateststart;
  530|   166k|        }
  531|   292k|    }
  532|  2.71k|    return answer;
  533|  2.77k|}
run_container_intersect:
  536|    694|                             const run_container_t *src_2) {
  537|    694|    const bool if1 = run_container_is_full(src_1);
  538|    694|    const bool if2 = run_container_is_full(src_2);
  539|    694|    if (if1 || if2) {
  ------------------
  |  Branch (539:9): [True: 0, False: 694]
  |  Branch (539:16): [True: 16, False: 678]
  ------------------
  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|    678|    int32_t rlepos = 0;
  548|    678|    int32_t xrlepos = 0;
  549|    678|    int32_t start = src_1->runs[rlepos].value;
  550|    678|    int32_t end = start + src_1->runs[rlepos].length + 1;
  551|    678|    int32_t xstart = src_2->runs[xrlepos].value;
  552|    678|    int32_t xend = xstart + src_2->runs[xrlepos].length + 1;
  553|  4.13k|    while ((rlepos < src_1->n_runs) && (xrlepos < src_2->n_runs)) {
  ------------------
  |  Branch (553:12): [True: 4.11k, False: 20]
  |  Branch (553:40): [True: 4.10k, False: 6]
  ------------------
  554|  4.10k|        if (end <= xstart) {
  ------------------
  |  Branch (554:13): [True: 2.81k, False: 1.29k]
  ------------------
  555|  2.81k|            ++rlepos;
  556|  2.81k|            if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (556:17): [True: 2.79k, False: 20]
  ------------------
  557|  2.79k|                start = src_1->runs[rlepos].value;
  558|  2.79k|                end = start + src_1->runs[rlepos].length + 1;
  559|  2.79k|            }
  560|  2.81k|        } else if (xend <= start) {
  ------------------
  |  Branch (560:20): [True: 644, False: 652]
  ------------------
  561|    644|            ++xrlepos;
  562|    644|            if (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (562:17): [True: 638, False: 6]
  ------------------
  563|    638|                xstart = src_2->runs[xrlepos].value;
  564|    638|                xend = xstart + src_2->runs[xrlepos].length + 1;
  565|    638|            }
  566|    652|        } else {  // they overlap
  567|    652|            return true;
  568|    652|        }
  569|  4.10k|    }
  570|     26|    return false;
  571|    678|}
run_container_andnot:
  576|  1.13k|                          const run_container_t *src_2, run_container_t *dst) {
  577|       |    // following Java implementation as of June 2016
  578|       |
  579|  1.13k|    if (dst->capacity < src_1->n_runs + src_2->n_runs)
  ------------------
  |  Branch (579:9): [True: 1.13k, False: 0]
  ------------------
  580|  1.13k|        run_container_grow(dst, src_1->n_runs + src_2->n_runs, false);
  581|       |
  582|  1.13k|    dst->n_runs = 0;
  583|       |
  584|  1.13k|    int rlepos1 = 0;
  585|  1.13k|    int rlepos2 = 0;
  586|  1.13k|    int32_t start = src_1->runs[rlepos1].value;
  587|  1.13k|    int32_t end = start + src_1->runs[rlepos1].length + 1;
  588|  1.13k|    int32_t start2 = src_2->runs[rlepos2].value;
  589|  1.13k|    int32_t end2 = start2 + src_2->runs[rlepos2].length + 1;
  590|       |
  591|   162k|    while ((rlepos1 < src_1->n_runs) && (rlepos2 < src_2->n_runs)) {
  ------------------
  |  Branch (591:12): [True: 161k, False: 698]
  |  Branch (591:41): [True: 161k, False: 433]
  ------------------
  592|   161k|        if (end <= start2) {
  ------------------
  |  Branch (592:13): [True: 25.1k, False: 136k]
  ------------------
  593|       |            // output the first run
  594|  25.1k|            dst->runs[dst->n_runs++] =
  595|  25.1k|                CROARING_MAKE_RLE16(start, end - start - 1);
  ------------------
  |  |   60|  25.1k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  596|  25.1k|            rlepos1++;
  597|  25.1k|            if (rlepos1 < src_1->n_runs) {
  ------------------
  |  Branch (597:17): [True: 25.0k, False: 102]
  ------------------
  598|  25.0k|                start = src_1->runs[rlepos1].value;
  599|  25.0k|                end = start + src_1->runs[rlepos1].length + 1;
  600|  25.0k|            }
  601|   136k|        } else if (end2 <= start) {
  ------------------
  |  Branch (601:20): [True: 66.9k, False: 69.3k]
  ------------------
  602|       |            // exit the second run
  603|  66.9k|            rlepos2++;
  604|  66.9k|            if (rlepos2 < src_2->n_runs) {
  ------------------
  |  Branch (604:17): [True: 66.5k, False: 433]
  ------------------
  605|  66.5k|                start2 = src_2->runs[rlepos2].value;
  606|  66.5k|                end2 = start2 + src_2->runs[rlepos2].length + 1;
  607|  66.5k|            }
  608|  69.3k|        } else {
  609|  69.3k|            if (start < start2) {
  ------------------
  |  Branch (609:17): [True: 18.5k, False: 50.8k]
  ------------------
  610|  18.5k|                dst->runs[dst->n_runs++] =
  611|  18.5k|                    CROARING_MAKE_RLE16(start, start2 - start - 1);
  ------------------
  |  |   60|  18.5k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  612|  18.5k|            }
  613|  69.3k|            if (end2 < end) {
  ------------------
  |  Branch (613:17): [True: 18.3k, False: 50.9k]
  ------------------
  614|  18.3k|                start = end2;
  615|  50.9k|            } else {
  616|  50.9k|                rlepos1++;
  617|  50.9k|                if (rlepos1 < src_1->n_runs) {
  ------------------
  |  Branch (617:21): [True: 50.3k, False: 596]
  ------------------
  618|  50.3k|                    start = src_1->runs[rlepos1].value;
  619|  50.3k|                    end = start + src_1->runs[rlepos1].length + 1;
  620|  50.3k|                }
  621|  50.9k|            }
  622|  69.3k|        }
  623|   161k|    }
  624|  1.13k|    if (rlepos1 < src_1->n_runs) {
  ------------------
  |  Branch (624:9): [True: 433, False: 698]
  ------------------
  625|    433|        dst->runs[dst->n_runs++] = CROARING_MAKE_RLE16(start, end - start - 1);
  ------------------
  |  |   60|    433|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  626|    433|        rlepos1++;
  627|    433|        if (rlepos1 < src_1->n_runs) {
  ------------------
  |  Branch (627:13): [True: 199, False: 234]
  ------------------
  628|    199|            memcpy(dst->runs + dst->n_runs, src_1->runs + rlepos1,
  629|    199|                   sizeof(rle16_t) * (src_1->n_runs - rlepos1));
  630|    199|            dst->n_runs += src_1->n_runs - rlepos1;
  631|    199|        }
  632|    433|    }
  633|  1.13k|}
run_container_read:
  739|     60|                           const char *buf) {
  740|     60|    (void)cardinality;
  741|     60|    uint16_t cast_16;
  742|     60|    memcpy(&cast_16, buf, sizeof(uint16_t));
  743|     60|    container->n_runs = croaring_letoh16(cast_16);
  ------------------
  |  |  523|     60|#define croaring_letoh16(x) croaring_htole16(x)
  |  |  ------------------
  |  |  |  |  517|     60|#define croaring_htole16(x) (x)
  |  |  ------------------
  ------------------
  744|     60|    if (container->n_runs > container->capacity)
  ------------------
  |  Branch (744:9): [True: 7, False: 53]
  ------------------
  745|      7|        run_container_grow(container, container->n_runs, false);
  746|     60|    if (container->n_runs > 0) {
  ------------------
  |  Branch (746:9): [True: 7, False: 53]
  ------------------
  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|     60|    return run_container_size_in_bytes(container);
  763|     60|}
run_container_iterate:
  766|  60.4k|                           roaring_iterator iterator, void *ptr) {
  767|   165k|    for (int i = 0; i < cont->n_runs; ++i) {
  ------------------
  |  Branch (767:21): [True: 105k, False: 60.4k]
  ------------------
  768|   105k|        uint32_t run_start = base + cont->runs[i].value;
  769|   105k|        uint16_t le = cont->runs[i].length;
  770|       |
  771|  3.87G|        for (int j = 0; j <= le; ++j)
  ------------------
  |  Branch (771:25): [True: 3.87G, False: 105k]
  ------------------
  772|  3.87G|            if (!iterator(run_start + j, ptr)) return false;
  ------------------
  |  Branch (772:17): [True: 0, False: 3.87G]
  ------------------
  773|   105k|    }
  774|  60.4k|    return true;
  775|  60.4k|}
run_container_is_subset:
  792|    259|                             const run_container_t *container2) {
  793|    259|    int i1 = 0, i2 = 0;
  794|    761|    while (i1 < container1->n_runs && i2 < container2->n_runs) {
  ------------------
  |  Branch (794:12): [True: 761, False: 0]
  |  Branch (794:39): [True: 751, False: 10]
  ------------------
  795|    751|        int start1 = container1->runs[i1].value;
  796|    751|        int stop1 = start1 + container1->runs[i1].length;
  797|    751|        int start2 = container2->runs[i2].value;
  798|    751|        int stop2 = start2 + container2->runs[i2].length;
  799|    751|        if (start1 < start2) {
  ------------------
  |  Branch (799:13): [True: 249, False: 502]
  ------------------
  800|    249|            return false;
  801|    502|        } else {  // start1 >= start2
  802|    502|            if (stop1 < stop2) {
  ------------------
  |  Branch (802:17): [True: 0, False: 502]
  ------------------
  803|      0|                i1++;
  804|    502|            } else if (stop1 == stop2) {
  ------------------
  |  Branch (804:24): [True: 0, False: 502]
  ------------------
  805|      0|                i1++;
  806|      0|                i2++;
  807|    502|            } else {  // stop1 > stop2
  808|    502|                i2++;
  809|    502|            }
  810|    502|        }
  811|    751|    }
  812|     10|    if (i1 == container1->n_runs) {
  ------------------
  |  Branch (812:9): [True: 0, False: 10]
  ------------------
  813|      0|        return true;
  814|     10|    } else {
  815|       |        return false;
  816|     10|    }
  817|     10|}
run_container_smart_append_exclusive:
  826|   394k|                                          const uint16_t length) {
  827|   394k|    int old_end;
  828|   394k|    rle16_t *last_run = src->n_runs ? src->runs + (src->n_runs - 1) : NULL;
  ------------------
  |  Branch (828:25): [True: 320k, False: 73.9k]
  ------------------
  829|   394k|    rle16_t *appended_last_run = src->runs + src->n_runs;
  830|       |
  831|   394k|    if (!src->n_runs ||
  ------------------
  |  Branch (831:9): [True: 73.9k, False: 320k]
  ------------------
  832|   320k|        (start > (old_end = last_run->value + last_run->length + 1))) {
  ------------------
  |  Branch (832:9): [True: 175k, False: 144k]
  ------------------
  833|   249k|        *appended_last_run = CROARING_MAKE_RLE16(start, length);
  ------------------
  |  |   60|   249k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  834|   249k|        src->n_runs++;
  835|   249k|        return;
  836|   249k|    }
  837|   144k|    if (old_end == start) {
  ------------------
  |  Branch (837:9): [True: 3.62k, False: 141k]
  ------------------
  838|       |        // we merge
  839|  3.62k|        last_run->length += (length + 1);
  840|  3.62k|        return;
  841|  3.62k|    }
  842|   141k|    int new_end = start + length + 1;
  843|       |
  844|   141k|    if (start == last_run->value) {
  ------------------
  |  Branch (844:9): [True: 112k, False: 28.8k]
  ------------------
  845|       |        // wipe out previous
  846|   112k|        if (new_end < old_end) {
  ------------------
  |  Branch (846:13): [True: 6.97k, False: 105k]
  ------------------
  847|  6.97k|            *last_run = CROARING_MAKE_RLE16(new_end, old_end - new_end - 1);
  ------------------
  |  |   60|  6.97k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  848|  6.97k|            return;
  849|   105k|        } else if (new_end > old_end) {
  ------------------
  |  Branch (849:20): [True: 2.50k, False: 102k]
  ------------------
  850|  2.50k|            *last_run = CROARING_MAKE_RLE16(old_end, new_end - old_end - 1);
  ------------------
  |  |   60|  2.50k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  851|  2.50k|            return;
  852|   102k|        } else {
  853|   102k|            src->n_runs--;
  854|   102k|            return;
  855|   102k|        }
  856|   112k|    }
  857|  28.8k|    last_run->length = start - last_run->value - 1;
  858|  28.8k|    if (new_end < old_end) {
  ------------------
  |  Branch (858:9): [True: 23.1k, False: 5.71k]
  ------------------
  859|  23.1k|        *appended_last_run =
  860|  23.1k|            CROARING_MAKE_RLE16(new_end, old_end - new_end - 1);
  ------------------
  |  |   60|  23.1k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  861|  23.1k|        src->n_runs++;
  862|  23.1k|    } else if (new_end > old_end) {
  ------------------
  |  Branch (862:16): [True: 1.01k, False: 4.70k]
  ------------------
  863|  1.01k|        *appended_last_run =
  864|  1.01k|            CROARING_MAKE_RLE16(old_end, new_end - old_end - 1);
  ------------------
  |  |   60|  1.01k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  865|  1.01k|        src->n_runs++;
  866|  1.01k|    }
  867|  28.8k|}
run_container_select:
  871|  2.61k|                          uint32_t *element) {
  872|  12.9k|    for (int i = 0; i < container->n_runs; i++) {
  ------------------
  |  Branch (872:21): [True: 12.8k, False: 92]
  ------------------
  873|  12.8k|        uint16_t length = container->runs[i].length;
  874|  12.8k|        if (rank <= *start_rank + length) {
  ------------------
  |  Branch (874:13): [True: 2.52k, False: 10.3k]
  ------------------
  875|  2.52k|            uint16_t value = container->runs[i].value;
  876|  2.52k|            *element = value + rank - (*start_rank);
  877|  2.52k|            return true;
  878|  2.52k|        } else
  879|  10.3k|            *start_rank += length + 1;
  880|  12.8k|    }
  881|     92|    return false;
  882|  2.61k|}
run_container_rank:
  884|  2.61k|int run_container_rank(const run_container_t *container, uint16_t x) {
  885|  2.61k|    int sum = 0;
  886|  2.61k|    uint32_t x32 = x;
  887|  10.9k|    for (int i = 0; i < container->n_runs; i++) {
  ------------------
  |  Branch (887:21): [True: 10.8k, False: 64]
  ------------------
  888|  10.8k|        uint32_t startpoint = container->runs[i].value;
  889|  10.8k|        uint32_t length = container->runs[i].length;
  890|  10.8k|        uint32_t endpoint = length + startpoint;
  891|  10.8k|        if (x <= endpoint) {
  ------------------
  |  Branch (891:13): [True: 2.55k, False: 8.29k]
  ------------------
  892|  2.55k|            if (x < startpoint) break;
  ------------------
  |  Branch (892:17): [True: 250, False: 2.30k]
  ------------------
  893|  2.30k|            return sum + (x32 - startpoint) + 1;
  894|  8.29k|        } else {
  895|  8.29k|            sum += length + 1;
  896|  8.29k|        }
  897|  10.8k|    }
  898|    314|    return sum;
  899|  2.61k|}
_avx2_run_container_to_uint32_array:
 1021|  61.0k|                                        uint32_t base) {
 1022|  61.0k|    int outpos = 0;
 1023|  61.0k|    uint32_t *out = (uint32_t *)vout;
 1024|       |
 1025|   207k|    for (int i = 0; i < cont->n_runs; ++i) {
  ------------------
  |  Branch (1025:21): [True: 146k, False: 61.0k]
  ------------------
 1026|   146k|        uint32_t run_start = base + cont->runs[i].value;
 1027|   146k|        uint16_t le = cont->runs[i].length;
 1028|   146k|        if (le < 8) {
  ------------------
  |  Branch (1028:13): [True: 81.9k, False: 64.8k]
  ------------------
 1029|   211k|            for (int j = 0; j <= le; ++j) {
  ------------------
  |  Branch (1029:29): [True: 129k, False: 81.9k]
  ------------------
 1030|   129k|                uint32_t val = run_start + j;
 1031|   129k|                memcpy(out + outpos, &val,
 1032|   129k|                       sizeof(uint32_t));  // should be compiled as a MOV on x64
 1033|   129k|                outpos++;
 1034|   129k|            }
 1035|  81.9k|        } else {
 1036|  64.8k|            int j = 0;
 1037|  64.8k|            __m256i run_start_v = _mm256_set1_epi32(run_start);
 1038|       |            // [8,8,8,8....]
 1039|  64.8k|            __m256i inc = _mm256_set1_epi32(8);
 1040|       |            // used for generate sequence:
 1041|       |            // [0, 1, 2, 3...], [8, 9, 10,...]
 1042|  64.8k|            __m256i delta = _mm256_setr_epi32(0, 1, 2, 3, 4, 5, 6, 7);
 1043|   485M|            for (j = 0; j + 8 <= le; j += 8) {
  ------------------
  |  Branch (1043:25): [True: 485M, False: 64.8k]
  ------------------
 1044|   485M|                __m256i val_v = _mm256_add_epi32(run_start_v, delta);
 1045|   485M|                _mm256_storeu_si256((__m256i *)(out + outpos), val_v);
 1046|   485M|                delta = _mm256_add_epi32(inc, delta);
 1047|   485M|                outpos += 8;
 1048|   485M|            }
 1049|   558k|            for (; j <= le; ++j) {
  ------------------
  |  Branch (1049:20): [True: 493k, False: 64.8k]
  ------------------
 1050|   493k|                uint32_t val = run_start + j;
 1051|   493k|                memcpy(out + outpos, &val,
 1052|   493k|                       sizeof(uint32_t));  // should be compiled as a MOV on x64
 1053|   493k|                outpos++;
 1054|   493k|            }
 1055|  64.8k|        }
 1056|   146k|    }
 1057|  61.0k|    return outpos;
 1058|  61.0k|}
run_container_cardinality:
 1077|   543k|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|   543k|        if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (1085:13): [True: 543k, False: 0]
  ------------------
 1086|   543k|        return _avx2_run_container_cardinality(run);
 1087|   543k|    } else {
 1088|      0|        return _scalar_run_container_cardinality(run);
 1089|      0|    }
 1090|   543k|}
run_container_to_uint32_array:
 1111|  61.0k|                                  uint32_t base) {
 1112|  61.0k|    if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (1112:9): [True: 61.0k, False: 0]
  ------------------
 1113|  61.0k|        return _avx2_run_container_to_uint32_array(vout, cont, base);
 1114|  61.0k|    } else {
 1115|      0|        return _scalar_run_container_to_uint32_array(vout, cont, base);
 1116|      0|    }
 1117|  61.0k|}
run.c:_avx2_run_container_cardinality:
  991|   543k|static inline int _avx2_run_container_cardinality(const run_container_t *run) {
  992|   543k|    const int32_t n_runs = run->n_runs;
  993|   543k|    const rle16_t *runs = run->runs;
  994|       |
  995|       |    /* by initializing with n_runs, we omit counting the +1 for each pair. */
  996|   543k|    int sum = n_runs;
  997|   543k|    int32_t k = 0;
  998|   543k|    const int32_t step = sizeof(__m256i) / sizeof(rle16_t);
  999|   543k|    if (n_runs > step) {
  ------------------
  |  Branch (999:9): [True: 33.4k, False: 509k]
  ------------------
 1000|  33.4k|        __m256i total = _mm256_setzero_si256();
 1001|   375k|        for (; k + step <= n_runs; k += step) {
  ------------------
  |  Branch (1001:16): [True: 342k, False: 33.4k]
  ------------------
 1002|   342k|            __m256i ymm1 = _mm256_lddqu_si256((const __m256i *)(runs + k));
 1003|   342k|            __m256i justlengths = _mm256_srli_epi32(ymm1, 16);
 1004|   342k|            total = _mm256_add_epi32(total, justlengths);
 1005|   342k|        }
 1006|       |        // a store might be faster than extract?
 1007|  33.4k|        uint32_t buffer[sizeof(__m256i) / sizeof(rle16_t)];
 1008|  33.4k|        _mm256_storeu_si256((__m256i *)buffer, total);
 1009|  33.4k|        sum += (buffer[0] + buffer[1]) + (buffer[2] + buffer[3]) +
 1010|  33.4k|               (buffer[4] + buffer[5]) + (buffer[6] + buffer[7]);
 1011|  33.4k|    }
 1012|  1.13M|    for (; k < n_runs; ++k) {
  ------------------
  |  Branch (1012:12): [True: 587k, False: 543k]
  ------------------
 1013|   587k|        sum += runs[k].length;
 1014|   587k|    }
 1015|       |
 1016|   543k|    return sum;
 1017|   543k|}

croaring_hardware_support:
  321|   967k|int croaring_hardware_support(void) {
  322|   967k|    static
  323|   967k|#if CROARING_ATOMIC_IMPL == CROARING_ATOMIC_IMPL_C
  324|   967k|        _Atomic
  325|   967k|#endif
  326|   967k|        int support = 0xFFFFFFF;
  327|   967k|    if (support == 0xFFFFFFF) {
  ------------------
  |  Branch (327:9): [True: 1, False: 967k]
  ------------------
  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|   967k|    return support;
  339|   967k|}
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.42M|void* roaring_malloc(size_t n) { return global_memory_hook.malloc(n); }
roaring_realloc:
   50|   119k|void* roaring_realloc(void* p, size_t new_sz) {
   51|   119k|    return global_memory_hook.realloc(p, new_sz);
   52|   119k|}
roaring_free:
   58|  1.67M|void roaring_free(void* p) { global_memory_hook.free(p); }
roaring_aligned_malloc:
   60|   297k|void* roaring_aligned_malloc(size_t alignment, size_t size) {
   61|   297k|    return global_memory_hook.aligned_malloc(alignment, size);
   62|   297k|}
roaring_aligned_free:
   64|   297k|void roaring_aligned_free(void* p) { global_memory_hook.aligned_free(p); }
memory.c:roaring_bitmap_aligned_malloc:
   11|   297k|static void* roaring_bitmap_aligned_malloc(size_t alignment, size_t size) {
   12|   297k|    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|   297k|    if (posix_memalign(&p, alignment, size) != 0) return NULL;
  ------------------
  |  Branch (20:9): [True: 0, False: 297k]
  ------------------
   21|   297k|#endif
   22|   297k|    return p;
   23|   297k|}
memory.c:roaring_bitmap_aligned_free:
   25|   297k|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|   297k|    free(memblock);
   32|   297k|#endif
   33|   297k|}

roaring_bitmap_create_with_capacity:
   86|  25.6k|roaring_bitmap_t *roaring_bitmap_create_with_capacity(uint32_t cap) {
   87|  25.6k|    roaring_bitmap_t *ans =
   88|  25.6k|        (roaring_bitmap_t *)roaring_malloc(sizeof(roaring_bitmap_t));
   89|  25.6k|    if (!ans) {
  ------------------
  |  Branch (89:9): [True: 0, False: 25.6k]
  ------------------
   90|      0|        return NULL;
   91|      0|    }
   92|  25.6k|    bool is_ok = ra_init_with_capacity(&ans->high_low_container, cap);
   93|  25.6k|    if (!is_ok) {
  ------------------
  |  Branch (93:9): [True: 0, False: 25.6k]
  ------------------
   94|      0|        roaring_free(ans);
   95|      0|        return NULL;
   96|      0|    }
   97|  25.6k|    return ans;
   98|  25.6k|}
roaring_bitmap_init_with_capacity:
  100|  32.2k|bool roaring_bitmap_init_with_capacity(roaring_bitmap_t *r, uint32_t cap) {
  101|  32.2k|    return ra_init_with_capacity(&r->high_low_container, cap);
  102|  32.2k|}
roaring_bitmap_add_many:
  135|  19.3k|                             const uint32_t *vals) {
  136|  19.3k|    uint32_t val;
  137|  19.3k|    const uint32_t *start = vals;
  138|  19.3k|    const uint32_t *end = vals + n_args;
  139|  19.3k|    const uint32_t *current_val = start;
  140|       |
  141|  19.3k|    if (n_args == 0) {
  ------------------
  |  Branch (141:9): [True: 0, False: 19.3k]
  ------------------
  142|      0|        return;
  143|      0|    }
  144|       |
  145|  19.3k|    uint8_t typecode;
  146|  19.3k|    int idx;
  147|  19.3k|    container_t *container;
  148|  19.3k|    val = *current_val;
  149|  19.3k|    container = containerptr_roaring_bitmap_add(r, val, &typecode, &idx);
  150|  19.3k|    roaring_bulk_context_t context = {container, idx, (uint16_t)(val >> 16),
  151|  19.3k|                                      typecode};
  152|       |
  153|  8.07M|    for (; current_val != end; current_val++) {
  ------------------
  |  Branch (153:12): [True: 8.05M, False: 19.3k]
  ------------------
  154|  8.05M|        memcpy(&val, current_val, sizeof(val));
  155|  8.05M|        add_bulk_impl(r, &context, val);
  156|  8.05M|    }
  157|  19.3k|}
roaring_bitmap_add_range_closed:
  252|  2.86k|                                     uint32_t max) {
  253|  2.86k|    if (min > max) {
  ------------------
  |  Branch (253:9): [True: 0, False: 2.86k]
  ------------------
  254|      0|        return;
  255|      0|    }
  256|       |
  257|  2.86k|    roaring_array_t *ra = &r->high_low_container;
  258|       |
  259|  2.86k|    uint32_t min_key = min >> 16;
  260|  2.86k|    uint32_t max_key = max >> 16;
  261|       |
  262|  2.86k|    int32_t num_required_containers = max_key - min_key + 1;
  263|  2.86k|    int32_t suffix_length =
  264|  2.86k|        count_greater(ra->keys, ra->size, (uint16_t)max_key);
  265|  2.86k|    int32_t prefix_length =
  266|  2.86k|        count_less(ra->keys, ra->size - suffix_length, (uint16_t)min_key);
  267|  2.86k|    int32_t common_length = ra->size - prefix_length - suffix_length;
  268|       |
  269|  2.86k|    if (num_required_containers > common_length) {
  ------------------
  |  Branch (269:9): [True: 1.31k, False: 1.55k]
  ------------------
  270|  1.31k|        ra_shift_tail(ra, suffix_length,
  271|  1.31k|                      num_required_containers - common_length);
  272|  1.31k|    }
  273|       |
  274|  2.86k|    int32_t src = prefix_length + common_length - 1;
  275|  2.86k|    int32_t dst = ra->size - suffix_length - 1;
  276|  78.5k|    for (uint32_t key = max_key; key != min_key - 1;
  ------------------
  |  Branch (276:34): [True: 75.6k, False: 2.86k]
  ------------------
  277|  75.6k|         key--) {  // beware of min_key==0
  278|  75.6k|        uint32_t container_min = (min_key == key) ? (min & 0xffff) : 0;
  ------------------
  |  Branch (278:34): [True: 2.86k, False: 72.8k]
  ------------------
  279|  75.6k|        uint32_t container_max = (max_key == key) ? (max & 0xffff) : 0xffff;
  ------------------
  |  Branch (279:34): [True: 2.86k, False: 72.8k]
  ------------------
  280|  75.6k|        container_t *new_container;
  281|  75.6k|        uint8_t new_type;
  282|       |
  283|  75.6k|        if (src >= 0 && ra->keys[src] == key) {
  ------------------
  |  Branch (283:13): [True: 75.6k, False: 0]
  |  Branch (283:25): [True: 3.28k, False: 72.3k]
  ------------------
  284|  3.28k|            ra_unshare_container_at_index(ra, (uint16_t)src);
  285|  3.28k|            new_container =
  286|  3.28k|                container_add_range(ra->containers[src], ra->typecodes[src],
  287|  3.28k|                                    container_min, container_max, &new_type);
  288|  3.28k|            if (new_container != ra->containers[src]) {
  ------------------
  |  Branch (288:17): [True: 2.16k, False: 1.11k]
  ------------------
  289|  2.16k|                container_free(ra->containers[src], ra->typecodes[src]);
  290|  2.16k|            }
  291|  3.28k|            src--;
  292|  72.3k|        } else {
  293|  72.3k|            new_container = container_from_range(&new_type, container_min,
  294|  72.3k|                                                 container_max + 1, 1);
  295|  72.3k|        }
  296|  75.6k|        ra_replace_key_and_container_at_index(ra, dst, (uint16_t)key,
  297|  75.6k|                                              new_container, new_type);
  298|  75.6k|        dst--;
  299|  75.6k|    }
  300|  2.86k|}
roaring_bitmap_remove_range_closed:
  303|  7.43k|                                        uint32_t max) {
  304|  7.43k|    if (min > max) {
  ------------------
  |  Branch (304:9): [True: 812, False: 6.61k]
  ------------------
  305|    812|        return;
  306|    812|    }
  307|       |
  308|  6.61k|    roaring_array_t *ra = &r->high_low_container;
  309|       |
  310|  6.61k|    uint32_t min_key = min >> 16;
  311|  6.61k|    uint32_t max_key = max >> 16;
  312|       |
  313|  6.61k|    int32_t src = count_less(ra->keys, ra->size, (uint16_t)min_key);
  314|  6.61k|    int32_t dst = src;
  315|  26.5k|    while (src < ra->size && ra->keys[src] <= max_key) {
  ------------------
  |  Branch (315:12): [True: 22.1k, False: 4.37k]
  |  Branch (315:30): [True: 19.9k, False: 2.24k]
  ------------------
  316|  19.9k|        uint32_t container_min =
  317|  19.9k|            (min_key == ra->keys[src]) ? (min & 0xffff) : 0;
  ------------------
  |  Branch (317:13): [True: 6.15k, False: 13.7k]
  ------------------
  318|  19.9k|        uint32_t container_max =
  319|  19.9k|            (max_key == ra->keys[src]) ? (max & 0xffff) : 0xffff;
  ------------------
  |  Branch (319:13): [True: 5.83k, False: 14.0k]
  ------------------
  320|  19.9k|        ra_unshare_container_at_index(ra, (uint16_t)src);
  321|  19.9k|        container_t *new_container;
  322|  19.9k|        uint8_t new_type;
  323|  19.9k|        new_container =
  324|  19.9k|            container_remove_range(ra->containers[src], ra->typecodes[src],
  325|  19.9k|                                   container_min, container_max, &new_type);
  326|  19.9k|        if (new_container != ra->containers[src]) {
  ------------------
  |  Branch (326:13): [True: 13.8k, False: 6.09k]
  ------------------
  327|  13.8k|            container_free(ra->containers[src], ra->typecodes[src]);
  328|  13.8k|        }
  329|  19.9k|        if (new_container) {
  ------------------
  |  Branch (329:13): [True: 6.34k, False: 13.5k]
  ------------------
  330|  6.34k|            ra_replace_key_and_container_at_index(ra, dst, ra->keys[src],
  331|  6.34k|                                                  new_container, new_type);
  332|  6.34k|            dst++;
  333|  6.34k|        }
  334|  19.9k|        src++;
  335|  19.9k|    }
  336|  6.61k|    if (src > dst) {
  ------------------
  |  Branch (336:9): [True: 646, False: 5.97k]
  ------------------
  337|    646|        ra_shift_tail(ra, ra->size - src, dst - src);
  338|    646|    }
  339|  6.61k|}
roaring_bitmap_copy:
  525|    135|roaring_bitmap_t *roaring_bitmap_copy(const roaring_bitmap_t *r) {
  526|    135|    roaring_bitmap_t *ans =
  527|    135|        (roaring_bitmap_t *)roaring_malloc(sizeof(roaring_bitmap_t));
  528|    135|    if (!ans) {
  ------------------
  |  Branch (528:9): [True: 0, False: 135]
  ------------------
  529|      0|        return NULL;
  530|      0|    }
  531|    135|    if (!ra_init_with_capacity(  // allocation of list of containers can fail
  ------------------
  |  Branch (531:9): [True: 0, False: 135]
  ------------------
  532|    135|            &ans->high_low_container, r->high_low_container.size)) {
  533|      0|        roaring_free(ans);
  534|      0|        return NULL;
  535|      0|    }
  536|    135|    if (!ra_overwrite(  // memory allocation of individual containers may fail
  ------------------
  |  Branch (536:9): [True: 0, False: 135]
  ------------------
  537|    135|            &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|    135|    roaring_bitmap_set_copy_on_write(ans, is_cow(r));
  542|    135|    return ans;
  543|    135|}
roaring_bitmap_overwrite:
  546|  14.3k|                              const roaring_bitmap_t *src) {
  547|  14.3k|    roaring_bitmap_set_copy_on_write(dest, is_cow(src));
  548|  14.3k|    return ra_overwrite(&src->high_low_container, &dest->high_low_container,
  549|  14.3k|                        is_cow(src));
  550|  14.3k|}
roaring_bitmap_clear:
  562|  64.4k|void roaring_bitmap_clear(roaring_bitmap_t *r) {
  563|  64.4k|    ra_reset(&r->high_low_container);
  564|  64.4k|}
roaring_bitmap_add:
  566|  6.44k|void roaring_bitmap_add(roaring_bitmap_t *r, uint32_t val) {
  567|  6.44k|    roaring_array_t *ra = &r->high_low_container;
  568|       |
  569|  6.44k|    const uint16_t hb = val >> 16;
  570|  6.44k|    const int i = ra_get_index(ra, hb);
  571|  6.44k|    uint8_t typecode;
  572|  6.44k|    if (i >= 0) {
  ------------------
  |  Branch (572:9): [True: 4.65k, False: 1.78k]
  ------------------
  573|  4.65k|        ra_unshare_container_at_index(ra, (uint16_t)i);
  574|  4.65k|        container_t *container =
  575|  4.65k|            ra_get_container_at_index(ra, (uint16_t)i, &typecode);
  576|  4.65k|        uint8_t newtypecode = typecode;
  577|  4.65k|        container_t *container2 =
  578|  4.65k|            container_add(container, val & 0xFFFF, typecode, &newtypecode);
  579|  4.65k|        if (container2 != container) {
  ------------------
  |  Branch (579:13): [True: 0, False: 4.65k]
  ------------------
  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.65k|    } else {
  585|  1.78k|        array_container_t *newac = array_container_create();
  586|  1.78k|        container_t *container =
  587|  1.78k|            container_add(newac, val & 0xFFFF, ARRAY_CONTAINER_TYPE, &typecode);
  ------------------
  |  |   49|  1.78k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  588|       |        // we could just assume that it stays an array container
  589|  1.78k|        ra_insert_new_key_value_at(&r->high_low_container, -i - 1, hb,
  590|  1.78k|                                   container, typecode);
  591|  1.78k|    }
  592|  6.44k|}
roaring_bitmap_add_checked:
  594|  6.44k|bool roaring_bitmap_add_checked(roaring_bitmap_t *r, uint32_t val) {
  595|  6.44k|    const uint16_t hb = val >> 16;
  596|  6.44k|    const int i = ra_get_index(&r->high_low_container, hb);
  597|  6.44k|    uint8_t typecode;
  598|  6.44k|    bool result = false;
  599|  6.44k|    if (i >= 0) {
  ------------------
  |  Branch (599:9): [True: 4.87k, False: 1.56k]
  ------------------
  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.56k|        array_container_t *newac = array_container_create();
  623|  1.56k|        container_t *container =
  624|  1.56k|            container_add(newac, val & 0xFFFF, ARRAY_CONTAINER_TYPE, &typecode);
  ------------------
  |  |   49|  1.56k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  625|       |        // we could just assume that it stays an array container
  626|  1.56k|        ra_insert_new_key_value_at(&r->high_low_container, -i - 1, hb,
  627|  1.56k|                                   container, typecode);
  628|  1.56k|        result = true;
  629|  1.56k|    }
  630|       |
  631|  6.44k|    return result;
  632|  6.44k|}
roaring_bitmap_remove:
  634|  6.44k|void roaring_bitmap_remove(roaring_bitmap_t *r, uint32_t val) {
  635|  6.44k|    const uint16_t hb = val >> 16;
  636|  6.44k|    const int i = ra_get_index(&r->high_low_container, hb);
  637|  6.44k|    uint8_t typecode;
  638|  6.44k|    if (i >= 0) {
  ------------------
  |  Branch (638:9): [True: 5.75k, False: 682]
  ------------------
  639|  5.75k|        ra_unshare_container_at_index(&r->high_low_container, (uint16_t)i);
  640|  5.75k|        container_t *container = ra_get_container_at_index(
  641|  5.75k|            &r->high_low_container, (uint16_t)i, &typecode);
  642|  5.75k|        uint8_t newtypecode = typecode;
  643|  5.75k|        container_t *container2 =
  644|  5.75k|            container_remove(container, val & 0xFFFF, typecode, &newtypecode);
  645|  5.75k|        if (container2 != container) {
  ------------------
  |  Branch (645:13): [True: 13, False: 5.74k]
  ------------------
  646|     13|            container_free(container, typecode);
  647|     13|            ra_set_container_at_index(&r->high_low_container, i, container2,
  648|     13|                                      newtypecode);
  649|     13|        }
  650|  5.75k|        if (container_nonzero_cardinality(container2, newtypecode)) {
  ------------------
  |  Branch (650:13): [True: 5.70k, False: 59]
  ------------------
  651|  5.70k|            ra_set_container_at_index(&r->high_low_container, i, container2,
  652|  5.70k|                                      newtypecode);
  653|  5.70k|        } else {
  654|     59|            ra_remove_at_index_and_free(&r->high_low_container, i);
  655|     59|        }
  656|  5.75k|    }
  657|  6.44k|}
roaring_bitmap_remove_checked:
  659|  6.44k|bool roaring_bitmap_remove_checked(roaring_bitmap_t *r, uint32_t val) {
  660|  6.44k|    const uint16_t hb = val >> 16;
  661|  6.44k|    const int i = ra_get_index(&r->high_low_container, hb);
  662|  6.44k|    uint8_t typecode;
  663|  6.44k|    bool result = false;
  664|  6.44k|    if (i >= 0) {
  ------------------
  |  Branch (664:9): [True: 5.82k, False: 618]
  ------------------
  665|  5.82k|        ra_unshare_container_at_index(&r->high_low_container, (uint16_t)i);
  666|  5.82k|        container_t *container = ra_get_container_at_index(
  667|  5.82k|            &r->high_low_container, (uint16_t)i, &typecode);
  668|       |
  669|  5.82k|        const int oldCardinality =
  670|  5.82k|            container_get_cardinality(container, typecode);
  671|       |
  672|  5.82k|        uint8_t newtypecode = typecode;
  673|  5.82k|        container_t *container2 =
  674|  5.82k|            container_remove(container, val & 0xFFFF, typecode, &newtypecode);
  675|  5.82k|        if (container2 != container) {
  ------------------
  |  Branch (675:13): [True: 3, False: 5.82k]
  ------------------
  676|      3|            container_free(container, typecode);
  677|      3|            ra_set_container_at_index(&r->high_low_container, i, container2,
  678|      3|                                      newtypecode);
  679|      3|        }
  680|       |
  681|  5.82k|        const int newCardinality =
  682|  5.82k|            container_get_cardinality(container2, newtypecode);
  683|       |
  684|  5.82k|        if (newCardinality != 0) {
  ------------------
  |  Branch (684:13): [True: 5.81k, False: 8]
  ------------------
  685|  5.81k|            ra_set_container_at_index(&r->high_low_container, i, container2,
  686|  5.81k|                                      newtypecode);
  687|  5.81k|        } else {
  688|      8|            ra_remove_at_index_and_free(&r->high_low_container, i);
  689|      8|        }
  690|       |
  691|  5.82k|        result = oldCardinality != newCardinality;
  692|  5.82k|    }
  693|  6.44k|    return result;
  694|  6.44k|}
roaring_bitmap_and:
  732|  6.44k|                                     const roaring_bitmap_t *x2) {
  733|  6.44k|    uint8_t result_type = 0;
  734|  6.44k|    const int length1 = x1->high_low_container.size,
  735|  6.44k|              length2 = x2->high_low_container.size;
  736|  6.44k|    uint32_t neededcap = length1 > length2 ? length2 : length1;
  ------------------
  |  Branch (736:26): [True: 45, False: 6.39k]
  ------------------
  737|  6.44k|    roaring_bitmap_t *answer = roaring_bitmap_create_with_capacity(neededcap);
  738|  6.44k|    roaring_bitmap_set_copy_on_write(answer, is_cow(x1) || is_cow(x2));
  ------------------
  |  Branch (738:46): [True: 0, False: 6.44k]
  |  Branch (738:60): [True: 0, False: 6.44k]
  ------------------
  739|       |
  740|  6.44k|    int pos1 = 0, pos2 = 0;
  741|       |
  742|  12.8k|    while (pos1 < length1 && pos2 < length2) {
  ------------------
  |  Branch (742:12): [True: 6.44k, False: 6.39k]
  |  Branch (742:30): [True: 6.39k, False: 45]
  ------------------
  743|  6.39k|        const uint16_t s1 =
  744|  6.39k|            ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
  745|  6.39k|        const uint16_t s2 =
  746|  6.39k|            ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
  747|       |
  748|  6.39k|        if (s1 == s2) {
  ------------------
  |  Branch (748:13): [True: 6.33k, False: 60]
  ------------------
  749|  6.33k|            uint8_t type1, type2;
  750|  6.33k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
  751|  6.33k|                                                        (uint16_t)pos1, &type1);
  752|  6.33k|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
  753|  6.33k|                                                        (uint16_t)pos2, &type2);
  754|  6.33k|            container_t *c = container_and(c1, type1, c2, type2, &result_type);
  755|       |
  756|  6.33k|            if (container_nonzero_cardinality(c, result_type)) {
  ------------------
  |  Branch (756:17): [True: 6.01k, False: 320]
  ------------------
  757|  6.01k|                ra_append(&answer->high_low_container, s1, c, result_type);
  758|  6.01k|            } else {
  759|    320|                container_free(c, result_type);  // otherwise: memory leak!
  760|    320|            }
  761|  6.33k|            ++pos1;
  762|  6.33k|            ++pos2;
  763|  6.33k|        } else if (s1 < s2) {  // s1 < s2
  ------------------
  |  Branch (763:20): [True: 60, False: 0]
  ------------------
  764|     60|            pos1 = ra_advance_until(&x1->high_low_container, s2, pos1);
  765|     60|        } else {  // s1 > s2
  766|      0|            pos2 = ra_advance_until(&x2->high_low_container, s1, pos2);
  767|      0|        }
  768|  6.39k|    }
  769|  6.44k|    return answer;
  770|  6.44k|}
roaring_bitmap_and_inplace:
  813|  6.44k|                                const roaring_bitmap_t *x2) {
  814|  6.44k|    if (x1 == x2) return;
  ------------------
  |  Branch (814:9): [True: 0, False: 6.44k]
  ------------------
  815|  6.44k|    int pos1 = 0, pos2 = 0, intersection_size = 0;
  816|  6.44k|    const int length1 = ra_get_size(&x1->high_low_container);
  817|  6.44k|    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.0k|    while (pos1 < length1 && pos2 < length2) {
  ------------------
  |  Branch (821:12): [True: 68.6k, False: 6.39k]
  |  Branch (821:30): [True: 68.5k, False: 45]
  ------------------
  822|  68.5k|        const uint16_t s1 =
  823|  68.5k|            ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
  824|  68.5k|        const uint16_t s2 =
  825|  68.5k|            ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
  826|       |
  827|  68.5k|        if (s1 == s2) {
  ------------------
  |  Branch (827:13): [True: 68.5k, False: 60]
  ------------------
  828|  68.5k|            uint8_t type1, type2, result_type;
  829|  68.5k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
  830|  68.5k|                                                        (uint16_t)pos1, &type1);
  831|  68.5k|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
  832|  68.5k|                                                        (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|  68.5k|            container_t *c =
  840|  68.5k|                (type1 == SHARED_CONTAINER_TYPE)
  ------------------
  |  |   51|  68.5k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (840:17): [True: 0, False: 68.5k]
  ------------------
  841|  68.5k|                    ? container_and(c1, type1, c2, type2, &result_type)
  842|  68.5k|                    : container_iand(c1, type1, c2, type2, &result_type);
  843|       |
  844|  68.5k|            if (c != c1) {  // in this instance a new container was created, and
  ------------------
  |  Branch (844:17): [True: 62.1k, False: 6.37k]
  ------------------
  845|       |                            // we need to free the old one
  846|  62.1k|                container_free(c1, type1);
  847|  62.1k|            }
  848|  68.5k|            if (container_nonzero_cardinality(c, result_type)) {
  ------------------
  |  Branch (848:17): [True: 68.5k, False: 0]
  ------------------
  849|  68.5k|                ra_replace_key_and_container_at_index(&x1->high_low_container,
  850|  68.5k|                                                      intersection_size, s1, c,
  851|  68.5k|                                                      result_type);
  852|  68.5k|                intersection_size++;
  853|  68.5k|            } else {
  854|      0|                container_free(c, result_type);
  855|      0|            }
  856|  68.5k|            ++pos1;
  857|  68.5k|            ++pos2;
  858|  68.5k|        } else if (s1 < s2) {
  ------------------
  |  Branch (858:20): [True: 60, False: 0]
  ------------------
  859|     60|            pos1 = ra_advance_until_freeing(&x1->high_low_container, s2, pos1);
  860|     60|        } else {  // s1 > s2
  861|      0|            pos2 = ra_advance_until(&x2->high_low_container, s1, pos2);
  862|      0|        }
  863|  68.5k|    }
  864|       |
  865|       |    // if we ended early because x2 ran out, then all remaining in x1 should be
  866|       |    // freed
  867|  6.48k|    while (pos1 < length1) {
  ------------------
  |  Branch (867:12): [True: 45, False: 6.44k]
  ------------------
  868|     45|        container_free(x1->high_low_container.containers[pos1],
  869|     45|                       x1->high_low_container.typecodes[pos1]);
  870|     45|        ++pos1;
  871|     45|    }
  872|       |
  873|       |    // all containers after this have either been copied or freed
  874|  6.44k|    ra_downsize(&x1->high_low_container, intersection_size);
  875|  6.44k|}
roaring_bitmap_or:
  878|  6.44k|                                    const roaring_bitmap_t *x2) {
  879|  6.44k|    uint8_t result_type = 0;
  880|  6.44k|    const int length1 = x1->high_low_container.size,
  881|  6.44k|              length2 = x2->high_low_container.size;
  882|  6.44k|    if (0 == length1) {
  ------------------
  |  Branch (882:9): [True: 0, False: 6.44k]
  ------------------
  883|      0|        return roaring_bitmap_copy(x2);
  884|      0|    }
  885|  6.44k|    if (0 == length2) {
  ------------------
  |  Branch (885:9): [True: 45, False: 6.39k]
  ------------------
  886|     45|        return roaring_bitmap_copy(x1);
  887|     45|    }
  888|  6.39k|    roaring_bitmap_t *answer =
  889|  6.39k|        roaring_bitmap_create_with_capacity(length1 + length2);
  890|  6.39k|    roaring_bitmap_set_copy_on_write(answer, is_cow(x1) || is_cow(x2));
  ------------------
  |  Branch (890:46): [True: 0, False: 6.39k]
  |  Branch (890:60): [True: 0, False: 6.39k]
  ------------------
  891|  6.39k|    int pos1 = 0, pos2 = 0;
  892|  6.39k|    uint8_t type1, type2;
  893|  6.39k|    uint16_t s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
  894|  6.39k|    uint16_t s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
  895|  6.39k|    while (true) {
  ------------------
  |  Branch (895:12): [True: 6.39k, Folded]
  ------------------
  896|  6.39k|        if (s1 == s2) {
  ------------------
  |  Branch (896:13): [True: 6.33k, False: 60]
  ------------------
  897|  6.33k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
  898|  6.33k|                                                        (uint16_t)pos1, &type1);
  899|  6.33k|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
  900|  6.33k|                                                        (uint16_t)pos2, &type2);
  901|  6.33k|            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.33k|            ra_append(&answer->high_low_container, s1, c, result_type);
  907|  6.33k|            ++pos1;
  908|  6.33k|            ++pos2;
  909|  6.33k|            if (pos1 == length1) break;
  ------------------
  |  Branch (909:17): [True: 6.33k, 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|     60|        } else if (s1 < s2) {  // s1 < s2
  ------------------
  |  Branch (914:20): [True: 60, False: 0]
  ------------------
  915|     60|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
  916|     60|                                                        (uint16_t)pos1, &type1);
  917|       |            // c1 = container_clone(c1, type1);
  918|     60|            c1 = get_copy_of_container(c1, &type1, is_cow(x1));
  919|     60|            if (is_cow(x1)) {
  ------------------
  |  Branch (919:17): [True: 0, False: 60]
  ------------------
  920|      0|                ra_set_container_at_index(&x1->high_low_container, pos1, c1,
  921|      0|                                          type1);
  922|      0|            }
  923|     60|            ra_append(&answer->high_low_container, s1, c1, type1);
  924|     60|            pos1++;
  925|     60|            if (pos1 == length1) break;
  ------------------
  |  Branch (925:17): [True: 60, 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.39k|    }
  943|  6.39k|    if (pos1 == length1) {
  ------------------
  |  Branch (943:9): [True: 6.39k, False: 0]
  ------------------
  944|  6.39k|        ra_append_copy_range(&answer->high_low_container,
  945|  6.39k|                             &x2->high_low_container, pos2, length2,
  946|  6.39k|                             is_cow(x2));
  947|  6.39k|    } 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.39k|    return answer;
  953|  6.44k|}
roaring_bitmap_or_inplace:
  957|  6.44k|                               const roaring_bitmap_t *x2) {
  958|  6.44k|    uint8_t result_type = 0;
  959|  6.44k|    int length1 = x1->high_low_container.size;
  960|  6.44k|    const int length2 = x2->high_low_container.size;
  961|       |
  962|  6.44k|    if (0 == length2) return;
  ------------------
  |  Branch (962:9): [True: 0, False: 6.44k]
  ------------------
  963|       |
  964|  6.44k|    if (0 == length1) {
  ------------------
  |  Branch (964:9): [True: 0, False: 6.44k]
  ------------------
  965|      0|        roaring_bitmap_overwrite(x1, x2);
  966|      0|        return;
  967|      0|    }
  968|  6.44k|    int pos1 = 0, pos2 = 0;
  969|  6.44k|    uint8_t type1, type2;
  970|  6.44k|    uint16_t s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
  971|  6.44k|    uint16_t s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
  972|  6.44k|    while (true) {
  ------------------
  |  Branch (972:12): [True: 6.44k, Folded]
  ------------------
  973|  6.44k|        if (s1 == s2) {
  ------------------
  |  Branch (973:13): [True: 6.44k, False: 0]
  ------------------
  974|  6.44k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
  975|  6.44k|                                                        (uint16_t)pos1, &type1);
  976|  6.44k|            if (!container_is_full(c1, type1)) {
  ------------------
  |  Branch (976:17): [True: 6.44k, False: 0]
  ------------------
  977|  6.44k|                container_t *c2 = ra_get_container_at_index(
  978|  6.44k|                    &x2->high_low_container, (uint16_t)pos2, &type2);
  979|  6.44k|                container_t *c =
  980|  6.44k|                    (type1 == SHARED_CONTAINER_TYPE)
  ------------------
  |  |   51|  6.44k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (980:21): [True: 0, False: 6.44k]
  ------------------
  981|  6.44k|                        ? container_or(c1, type1, c2, type2, &result_type)
  982|  6.44k|                        : container_ior(c1, type1, c2, type2, &result_type);
  983|       |
  984|  6.44k|                if (c != c1) {  // in this instance a new container was created,
  ------------------
  |  Branch (984:21): [True: 4.65k, False: 1.79k]
  ------------------
  985|       |                                // and we need to free the old one
  986|  4.65k|                    container_free(c1, type1);
  987|  4.65k|                }
  988|  6.44k|                ra_set_container_at_index(&x1->high_low_container, pos1, c,
  989|  6.44k|                                          result_type);
  990|  6.44k|            }
  991|  6.44k|            ++pos1;
  992|  6.44k|            ++pos2;
  993|  6.44k|            if (pos1 == length1) break;
  ------------------
  |  Branch (993:17): [True: 6.44k, False: 0]
  ------------------
  994|      0|            if (pos2 == length2) break;
  ------------------
  |  Branch (994:17): [True: 0, False: 0]
  ------------------
  995|      0|            s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
  996|      0|            s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
  997|       |
  998|      0|        } else if (s1 < s2) {  // s1 < s2
  ------------------
  |  Branch (998:20): [True: 0, False: 0]
  ------------------
  999|      0|            pos1++;
 1000|      0|            if (pos1 == length1) break;
  ------------------
  |  Branch (1000:17): [True: 0, False: 0]
  ------------------
 1001|      0|            s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1002|       |
 1003|      0|        } else {  // s1 > s2
 1004|      0|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
 1005|      0|                                                        (uint16_t)pos2, &type2);
 1006|      0|            c2 = get_copy_of_container(c2, &type2, is_cow(x2));
 1007|      0|            if (is_cow(x2)) {
  ------------------
  |  Branch (1007:17): [True: 0, False: 0]
  ------------------
 1008|      0|                ra_set_container_at_index(&x2->high_low_container, pos2, c2,
 1009|      0|                                          type2);
 1010|      0|            }
 1011|       |
 1012|       |            // container_t *c2_clone = container_clone(c2, type2);
 1013|      0|            ra_insert_new_key_value_at(&x1->high_low_container, pos1, s2, c2,
 1014|      0|                                       type2);
 1015|      0|            pos1++;
 1016|      0|            length1++;
 1017|      0|            pos2++;
 1018|      0|            if (pos2 == length2) break;
  ------------------
  |  Branch (1018:17): [True: 0, False: 0]
  ------------------
 1019|      0|            s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 1020|      0|        }
 1021|  6.44k|    }
 1022|  6.44k|    if (pos1 == length1) {
  ------------------
  |  Branch (1022:9): [True: 6.44k, False: 0]
  ------------------
 1023|  6.44k|        ra_append_copy_range(&x1->high_low_container, &x2->high_low_container,
 1024|  6.44k|                             pos2, length2, is_cow(x2));
 1025|  6.44k|    }
 1026|  6.44k|}
roaring_bitmap_xor:
 1029|  6.44k|                                     const roaring_bitmap_t *x2) {
 1030|  6.44k|    uint8_t result_type = 0;
 1031|  6.44k|    const int length1 = x1->high_low_container.size,
 1032|  6.44k|              length2 = x2->high_low_container.size;
 1033|  6.44k|    if (0 == length1) {
  ------------------
  |  Branch (1033:9): [True: 0, False: 6.44k]
  ------------------
 1034|      0|        return roaring_bitmap_copy(x2);
 1035|      0|    }
 1036|  6.44k|    if (0 == length2) {
  ------------------
  |  Branch (1036:9): [True: 45, False: 6.39k]
  ------------------
 1037|     45|        return roaring_bitmap_copy(x1);
 1038|     45|    }
 1039|  6.39k|    roaring_bitmap_t *answer =
 1040|  6.39k|        roaring_bitmap_create_with_capacity(length1 + length2);
 1041|  6.39k|    roaring_bitmap_set_copy_on_write(answer, is_cow(x1) || is_cow(x2));
  ------------------
  |  Branch (1041:46): [True: 0, False: 6.39k]
  |  Branch (1041:60): [True: 0, False: 6.39k]
  ------------------
 1042|  6.39k|    int pos1 = 0, pos2 = 0;
 1043|  6.39k|    uint8_t type1, type2;
 1044|  6.39k|    uint16_t s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1045|  6.39k|    uint16_t s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 1046|  6.39k|    while (true) {
  ------------------
  |  Branch (1046:12): [True: 6.39k, Folded]
  ------------------
 1047|  6.39k|        if (s1 == s2) {
  ------------------
  |  Branch (1047:13): [True: 6.33k, False: 60]
  ------------------
 1048|  6.33k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
 1049|  6.33k|                                                        (uint16_t)pos1, &type1);
 1050|  6.33k|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
 1051|  6.33k|                                                        (uint16_t)pos2, &type2);
 1052|  6.33k|            container_t *c = container_xor(c1, type1, c2, type2, &result_type);
 1053|       |
 1054|  6.33k|            if (container_nonzero_cardinality(c, result_type)) {
  ------------------
  |  Branch (1054:17): [True: 6.31k, False: 20]
  ------------------
 1055|  6.31k|                ra_append(&answer->high_low_container, s1, c, result_type);
 1056|  6.31k|            } else {
 1057|     20|                container_free(c, result_type);
 1058|     20|            }
 1059|  6.33k|            ++pos1;
 1060|  6.33k|            ++pos2;
 1061|  6.33k|            if (pos1 == length1) break;
  ------------------
  |  Branch (1061:17): [True: 6.33k, False: 0]
  ------------------
 1062|      0|            if (pos2 == length2) break;
  ------------------
  |  Branch (1062:17): [True: 0, False: 0]
  ------------------
 1063|      0|            s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1064|      0|            s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 1065|       |
 1066|     60|        } else if (s1 < s2) {  // s1 < s2
  ------------------
  |  Branch (1066:20): [True: 60, False: 0]
  ------------------
 1067|     60|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
 1068|     60|                                                        (uint16_t)pos1, &type1);
 1069|     60|            c1 = get_copy_of_container(c1, &type1, is_cow(x1));
 1070|     60|            if (is_cow(x1)) {
  ------------------
  |  Branch (1070:17): [True: 0, False: 60]
  ------------------
 1071|      0|                ra_set_container_at_index(&x1->high_low_container, pos1, c1,
 1072|      0|                                          type1);
 1073|      0|            }
 1074|     60|            ra_append(&answer->high_low_container, s1, c1, type1);
 1075|     60|            pos1++;
 1076|     60|            if (pos1 == length1) break;
  ------------------
  |  Branch (1076:17): [True: 60, False: 0]
  ------------------
 1077|      0|            s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1078|       |
 1079|      0|        } else {  // s1 > s2
 1080|      0|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
 1081|      0|                                                        (uint16_t)pos2, &type2);
 1082|      0|            c2 = get_copy_of_container(c2, &type2, is_cow(x2));
 1083|      0|            if (is_cow(x2)) {
  ------------------
  |  Branch (1083:17): [True: 0, False: 0]
  ------------------
 1084|      0|                ra_set_container_at_index(&x2->high_low_container, pos2, c2,
 1085|      0|                                          type2);
 1086|      0|            }
 1087|      0|            ra_append(&answer->high_low_container, s2, c2, type2);
 1088|      0|            pos2++;
 1089|      0|            if (pos2 == length2) break;
  ------------------
  |  Branch (1089:17): [True: 0, False: 0]
  ------------------
 1090|      0|            s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 1091|      0|        }
 1092|  6.39k|    }
 1093|  6.39k|    if (pos1 == length1) {
  ------------------
  |  Branch (1093:9): [True: 6.39k, False: 0]
  ------------------
 1094|  6.39k|        ra_append_copy_range(&answer->high_low_container,
 1095|  6.39k|                             &x2->high_low_container, pos2, length2,
 1096|  6.39k|                             is_cow(x2));
 1097|  6.39k|    } else if (pos2 == length2) {
  ------------------
  |  Branch (1097:16): [True: 0, False: 0]
  ------------------
 1098|      0|        ra_append_copy_range(&answer->high_low_container,
 1099|      0|                             &x1->high_low_container, pos1, length1,
 1100|      0|                             is_cow(x1));
 1101|      0|    }
 1102|  6.39k|    return answer;
 1103|  6.44k|}
roaring_bitmap_xor_inplace:
 1108|  6.44k|                                const roaring_bitmap_t *x2) {
 1109|  6.44k|    assert(x1 != x2);
 1110|  6.44k|    uint8_t result_type = 0;
 1111|  6.44k|    int length1 = x1->high_low_container.size;
 1112|  6.44k|    const int length2 = x2->high_low_container.size;
 1113|       |
 1114|  6.44k|    if (0 == length2) return;
  ------------------
  |  Branch (1114:9): [True: 16, False: 6.42k]
  ------------------
 1115|       |
 1116|  6.42k|    if (0 == length1) {
  ------------------
  |  Branch (1116:9): [True: 1.49k, False: 4.92k]
  ------------------
 1117|  1.49k|        roaring_bitmap_overwrite(x1, x2);
 1118|  1.49k|        return;
 1119|  1.49k|    }
 1120|       |
 1121|       |    // XOR can have new containers inserted from x2, but can also
 1122|       |    // lose containers when x1 and x2 are nonempty and identical.
 1123|       |
 1124|  4.92k|    int pos1 = 0, pos2 = 0;
 1125|  4.92k|    uint8_t type1, type2;
 1126|  4.92k|    uint16_t s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1127|  4.92k|    uint16_t s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 1128|  67.1k|    while (true) {
  ------------------
  |  Branch (1128:12): [True: 67.1k, Folded]
  ------------------
 1129|  67.1k|        if (s1 == s2) {
  ------------------
  |  Branch (1129:13): [True: 67.0k, False: 109]
  ------------------
 1130|  67.0k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
 1131|  67.0k|                                                        (uint16_t)pos1, &type1);
 1132|  67.0k|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
 1133|  67.0k|                                                        (uint16_t)pos2, &type2);
 1134|       |
 1135|       |            // We do the computation "in place" only when c1 is not a shared
 1136|       |            // container. Rationale: using a shared container safely with in
 1137|       |            // place computation would require making a copy and then doing the
 1138|       |            // computation in place which is likely less efficient than avoiding
 1139|       |            // in place entirely and always generating a new container.
 1140|       |
 1141|  67.0k|            container_t *c;
 1142|  67.0k|            if (type1 == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|  67.0k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (1142:17): [True: 0, False: 67.0k]
  ------------------
 1143|      0|                c = container_xor(c1, type1, c2, type2, &result_type);
 1144|      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)
  |  |  ------------------
  ------------------
 1145|  67.0k|            } else {
 1146|  67.0k|                c = container_ixor(c1, type1, c2, type2, &result_type);
 1147|  67.0k|            }
 1148|       |
 1149|  67.0k|            if (container_nonzero_cardinality(c, result_type)) {
  ------------------
  |  Branch (1149:17): [True: 4.59k, False: 62.4k]
  ------------------
 1150|  4.59k|                ra_set_container_at_index(&x1->high_low_container, pos1, c,
 1151|  4.59k|                                          result_type);
 1152|  4.59k|                ++pos1;
 1153|  62.4k|            } else {
 1154|  62.4k|                container_free(c, result_type);
 1155|  62.4k|                ra_remove_at_index(&x1->high_low_container, pos1);
 1156|  62.4k|                --length1;
 1157|  62.4k|            }
 1158|       |
 1159|  67.0k|            ++pos2;
 1160|  67.0k|            if (pos1 == length1) break;
  ------------------
  |  Branch (1160:17): [True: 4.92k, False: 62.0k]
  ------------------
 1161|  62.0k|            if (pos2 == length2) break;
  ------------------
  |  Branch (1161:17): [True: 0, False: 62.0k]
  ------------------
 1162|  62.0k|            s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1163|  62.0k|            s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 1164|       |
 1165|  62.0k|        } else if (s1 < s2) {  // s1 < s2
  ------------------
  |  Branch (1165:20): [True: 0, False: 109]
  ------------------
 1166|      0|            pos1++;
 1167|      0|            if (pos1 == length1) break;
  ------------------
  |  Branch (1167:17): [True: 0, False: 0]
  ------------------
 1168|      0|            s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1169|       |
 1170|    109|        } else {  // s1 > s2
 1171|    109|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
 1172|    109|                                                        (uint16_t)pos2, &type2);
 1173|    109|            c2 = get_copy_of_container(c2, &type2, is_cow(x2));
 1174|    109|            if (is_cow(x2)) {
  ------------------
  |  Branch (1174:17): [True: 0, False: 109]
  ------------------
 1175|      0|                ra_set_container_at_index(&x2->high_low_container, pos2, c2,
 1176|      0|                                          type2);
 1177|      0|            }
 1178|       |
 1179|    109|            ra_insert_new_key_value_at(&x1->high_low_container, pos1, s2, c2,
 1180|    109|                                       type2);
 1181|    109|            pos1++;
 1182|    109|            length1++;
 1183|    109|            pos2++;
 1184|    109|            if (pos2 == length2) break;
  ------------------
  |  Branch (1184:17): [True: 0, False: 109]
  ------------------
 1185|    109|            s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 1186|    109|        }
 1187|  67.1k|    }
 1188|  4.92k|    if (pos1 == length1) {
  ------------------
  |  Branch (1188:9): [True: 4.92k, False: 0]
  ------------------
 1189|  4.92k|        ra_append_copy_range(&x1->high_low_container, &x2->high_low_container,
 1190|  4.92k|                             pos2, length2, is_cow(x2));
 1191|  4.92k|    }
 1192|  4.92k|}
roaring_bitmap_andnot:
 1195|  6.44k|                                        const roaring_bitmap_t *x2) {
 1196|  6.44k|    uint8_t result_type = 0;
 1197|  6.44k|    const int length1 = x1->high_low_container.size,
 1198|  6.44k|              length2 = x2->high_low_container.size;
 1199|  6.44k|    if (0 == length1) {
  ------------------
  |  Branch (1199:9): [True: 0, False: 6.44k]
  ------------------
 1200|      0|        roaring_bitmap_t *empty_bitmap = roaring_bitmap_create();
 1201|      0|        roaring_bitmap_set_copy_on_write(empty_bitmap,
 1202|      0|                                         is_cow(x1) || is_cow(x2));
  ------------------
  |  Branch (1202:42): [True: 0, False: 0]
  |  Branch (1202:56): [True: 0, False: 0]
  ------------------
 1203|      0|        return empty_bitmap;
 1204|      0|    }
 1205|  6.44k|    if (0 == length2) {
  ------------------
  |  Branch (1205:9): [True: 45, False: 6.39k]
  ------------------
 1206|     45|        return roaring_bitmap_copy(x1);
 1207|     45|    }
 1208|  6.39k|    roaring_bitmap_t *answer = roaring_bitmap_create_with_capacity(length1);
 1209|  6.39k|    roaring_bitmap_set_copy_on_write(answer, is_cow(x1) || is_cow(x2));
  ------------------
  |  Branch (1209:46): [True: 0, False: 6.39k]
  |  Branch (1209:60): [True: 0, False: 6.39k]
  ------------------
 1210|       |
 1211|  6.39k|    int pos1 = 0, pos2 = 0;
 1212|  6.39k|    uint8_t type1, type2;
 1213|  6.39k|    uint16_t s1 = 0;
 1214|  6.39k|    uint16_t s2 = 0;
 1215|  6.39k|    while (true) {
  ------------------
  |  Branch (1215:12): [True: 6.39k, Folded]
  ------------------
 1216|  6.39k|        s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1217|  6.39k|        s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 1218|       |
 1219|  6.39k|        if (s1 == s2) {
  ------------------
  |  Branch (1219:13): [True: 6.33k, False: 60]
  ------------------
 1220|  6.33k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
 1221|  6.33k|                                                        (uint16_t)pos1, &type1);
 1222|  6.33k|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
 1223|  6.33k|                                                        (uint16_t)pos2, &type2);
 1224|  6.33k|            container_t *c =
 1225|  6.33k|                container_andnot(c1, type1, c2, type2, &result_type);
 1226|       |
 1227|  6.33k|            if (container_nonzero_cardinality(c, result_type)) {
  ------------------
  |  Branch (1227:17): [True: 6.09k, False: 239]
  ------------------
 1228|  6.09k|                ra_append(&answer->high_low_container, s1, c, result_type);
 1229|  6.09k|            } else {
 1230|    239|                container_free(c, result_type);
 1231|    239|            }
 1232|  6.33k|            ++pos1;
 1233|  6.33k|            ++pos2;
 1234|  6.33k|            if (pos1 == length1) break;
  ------------------
  |  Branch (1234:17): [True: 6.33k, False: 0]
  ------------------
 1235|      0|            if (pos2 == length2) break;
  ------------------
  |  Branch (1235:17): [True: 0, False: 0]
  ------------------
 1236|     60|        } else if (s1 < s2) {  // s1 < s2
  ------------------
  |  Branch (1236:20): [True: 60, False: 0]
  ------------------
 1237|     60|            const int next_pos1 =
 1238|     60|                ra_advance_until(&x1->high_low_container, s2, pos1);
 1239|     60|            ra_append_copy_range(&answer->high_low_container,
 1240|     60|                                 &x1->high_low_container, pos1, next_pos1,
 1241|     60|                                 is_cow(x1));
 1242|       |            // TODO : perhaps some of the copy_on_write should be based on
 1243|       |            // answer rather than x1 (more stringent?).  Many similar cases
 1244|     60|            pos1 = next_pos1;
 1245|     60|            if (pos1 == length1) break;
  ------------------
  |  Branch (1245:17): [True: 60, False: 0]
  ------------------
 1246|     60|        } else {  // s1 > s2
 1247|      0|            pos2 = ra_advance_until(&x2->high_low_container, s1, pos2);
 1248|      0|            if (pos2 == length2) break;
  ------------------
  |  Branch (1248:17): [True: 0, False: 0]
  ------------------
 1249|      0|        }
 1250|  6.39k|    }
 1251|  6.39k|    if (pos2 == length2) {
  ------------------
  |  Branch (1251:9): [True: 3.96k, False: 2.42k]
  ------------------
 1252|  3.96k|        ra_append_copy_range(&answer->high_low_container,
 1253|  3.96k|                             &x1->high_low_container, pos1, length1,
 1254|  3.96k|                             is_cow(x1));
 1255|  3.96k|    }
 1256|  6.39k|    return answer;
 1257|  6.44k|}
roaring_bitmap_andnot_inplace:
 1262|  6.44k|                                   const roaring_bitmap_t *x2) {
 1263|  6.44k|    assert(x1 != x2);
 1264|       |
 1265|  6.44k|    uint8_t result_type = 0;
 1266|  6.44k|    int length1 = x1->high_low_container.size;
 1267|  6.44k|    const int length2 = x2->high_low_container.size;
 1268|  6.44k|    int intersection_size = 0;
 1269|       |
 1270|  6.44k|    if (0 == length2) return;
  ------------------
  |  Branch (1270:9): [True: 425, False: 6.01k]
  ------------------
 1271|       |
 1272|  6.01k|    if (0 == length1) {
  ------------------
  |  Branch (1272:9): [True: 0, False: 6.01k]
  ------------------
 1273|      0|        roaring_bitmap_clear(x1);
 1274|      0|        return;
 1275|      0|    }
 1276|       |
 1277|  6.01k|    int pos1 = 0, pos2 = 0;
 1278|  6.01k|    uint8_t type1, type2;
 1279|  6.01k|    uint16_t s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1280|  6.01k|    uint16_t s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 1281|  6.01k|    while (true) {
  ------------------
  |  Branch (1281:12): [True: 6.01k, Folded]
  ------------------
 1282|  6.01k|        if (s1 == s2) {
  ------------------
  |  Branch (1282:13): [True: 6.01k, False: 0]
  ------------------
 1283|  6.01k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
 1284|  6.01k|                                                        (uint16_t)pos1, &type1);
 1285|  6.01k|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
 1286|  6.01k|                                                        (uint16_t)pos2, &type2);
 1287|       |
 1288|       |            // We do the computation "in place" only when c1 is not a shared
 1289|       |            // container. Rationale: using a shared container safely with in
 1290|       |            // place computation would require making a copy and then doing the
 1291|       |            // computation in place which is likely less efficient than avoiding
 1292|       |            // in place entirely and always generating a new container.
 1293|       |
 1294|  6.01k|            container_t *c;
 1295|  6.01k|            if (type1 == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|  6.01k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (1295:17): [True: 0, False: 6.01k]
  ------------------
 1296|      0|                c = container_andnot(c1, type1, c2, type2, &result_type);
 1297|      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)
  |  |  ------------------
  ------------------
 1298|  6.01k|            } else {
 1299|  6.01k|                c = container_iandnot(c1, type1, c2, type2, &result_type);
 1300|  6.01k|            }
 1301|       |
 1302|  6.01k|            if (container_nonzero_cardinality(c, result_type)) {
  ------------------
  |  Branch (1302:17): [True: 4.49k, False: 1.52k]
  ------------------
 1303|  4.49k|                ra_replace_key_and_container_at_index(&x1->high_low_container,
 1304|  4.49k|                                                      intersection_size++, s1,
 1305|  4.49k|                                                      c, result_type);
 1306|  4.49k|            } else {
 1307|  1.52k|                container_free(c, result_type);
 1308|  1.52k|            }
 1309|       |
 1310|  6.01k|            ++pos1;
 1311|  6.01k|            ++pos2;
 1312|  6.01k|            if (pos1 == length1) break;
  ------------------
  |  Branch (1312:17): [True: 3.74k, False: 2.27k]
  ------------------
 1313|  2.27k|            if (pos2 == length2) break;
  ------------------
  |  Branch (1313:17): [True: 2.27k, False: 0]
  ------------------
 1314|      0|            s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1315|      0|            s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 1316|       |
 1317|      0|        } else if (s1 < s2) {  // s1 < s2
  ------------------
  |  Branch (1317:20): [True: 0, False: 0]
  ------------------
 1318|      0|            if (pos1 != intersection_size) {
  ------------------
  |  Branch (1318:17): [True: 0, False: 0]
  ------------------
 1319|      0|                container_t *c1 = ra_get_container_at_index(
 1320|      0|                    &x1->high_low_container, (uint16_t)pos1, &type1);
 1321|       |
 1322|      0|                ra_replace_key_and_container_at_index(
 1323|      0|                    &x1->high_low_container, intersection_size, s1, c1, type1);
 1324|      0|            }
 1325|      0|            intersection_size++;
 1326|      0|            pos1++;
 1327|      0|            if (pos1 == length1) break;
  ------------------
  |  Branch (1327:17): [True: 0, False: 0]
  ------------------
 1328|      0|            s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1329|       |
 1330|      0|        } else {  // s1 > s2
 1331|      0|            pos2 = ra_advance_until(&x2->high_low_container, s1, pos2);
 1332|      0|            if (pos2 == length2) break;
  ------------------
  |  Branch (1332:17): [True: 0, False: 0]
  ------------------
 1333|      0|            s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 1334|      0|        }
 1335|  6.01k|    }
 1336|       |
 1337|  6.01k|    if (pos1 < length1) {
  ------------------
  |  Branch (1337:9): [True: 2.27k, False: 3.74k]
  ------------------
 1338|       |        // all containers between intersection_size and
 1339|       |        // pos1 are junk.  However, they have either been moved
 1340|       |        // (thus still referenced) or involved in an iandnot
 1341|       |        // that will clean up all containers that could not be reused.
 1342|       |        // Thus we should not free the junk containers between
 1343|       |        // intersection_size and pos1.
 1344|  2.27k|        if (pos1 > intersection_size) {
  ------------------
  |  Branch (1344:13): [True: 53, False: 2.21k]
  ------------------
 1345|       |            // left slide of remaining items
 1346|     53|            ra_copy_range(&x1->high_low_container, pos1, length1,
 1347|     53|                          intersection_size);
 1348|     53|        }
 1349|       |        // else current placement is fine
 1350|  2.27k|        intersection_size += (length1 - pos1);
 1351|  2.27k|    }
 1352|  6.01k|    ra_downsize(&x1->high_low_container, intersection_size);
 1353|  6.01k|}
roaring_bitmap_get_cardinality:
 1355|  64.4k|uint64_t roaring_bitmap_get_cardinality(const roaring_bitmap_t *r) {
 1356|  64.4k|    const roaring_array_t *ra = &r->high_low_container;
 1357|       |
 1358|  64.4k|    uint64_t card = 0;
 1359|   439k|    for (int i = 0; i < ra->size; ++i)
  ------------------
  |  Branch (1359:21): [True: 374k, False: 64.4k]
  ------------------
 1360|   374k|        card += container_get_cardinality(ra->containers[i], ra->typecodes[i]);
 1361|  64.4k|    return card;
 1362|  64.4k|}
roaring_bitmap_is_empty:
 1425|  12.8k|bool roaring_bitmap_is_empty(const roaring_bitmap_t *r) {
 1426|  12.8k|    return r->high_low_container.size == 0;
 1427|  12.8k|}
roaring_bitmap_to_uint32_array:
 1429|  6.44k|void roaring_bitmap_to_uint32_array(const roaring_bitmap_t *r, uint32_t *ans) {
 1430|  6.44k|    ra_to_uint32_array(&r->high_low_container, ans);
 1431|  6.44k|}
roaring_bitmap_run_optimize:
 1449|  12.8k|bool roaring_bitmap_run_optimize(roaring_bitmap_t *r) {
 1450|  12.8k|    bool answer = false;
 1451|  25.7k|    for (int i = 0; i < r->high_low_container.size; i++) {
  ------------------
  |  Branch (1451:21): [True: 12.8k, False: 12.8k]
  ------------------
 1452|  12.8k|        uint8_t type_original, type_after;
 1453|  12.8k|        ra_unshare_container_at_index(
 1454|  12.8k|            &r->high_low_container,
 1455|  12.8k|            (uint16_t)i);  // TODO: this introduces extra cloning!
 1456|  12.8k|        container_t *c = ra_get_container_at_index(&r->high_low_container,
 1457|  12.8k|                                                   (uint16_t)i, &type_original);
 1458|  12.8k|        container_t *c1 = convert_run_optimize(c, type_original, &type_after);
 1459|  12.8k|        if (type_after == RUN_CONTAINER_TYPE) {
  ------------------
  |  |   50|  12.8k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (1459:13): [True: 4.05k, False: 8.83k]
  ------------------
 1460|       |            answer = true;
 1461|  4.05k|        }
 1462|  12.8k|        ra_set_container_at_index(&r->high_low_container, i, c1, type_after);
 1463|  12.8k|    }
 1464|  12.8k|    return answer;
 1465|  12.8k|}
roaring_bitmap_shrink_to_fit:
 1467|  6.44k|size_t roaring_bitmap_shrink_to_fit(roaring_bitmap_t *r) {
 1468|  6.44k|    size_t answer = 0;
 1469|  12.8k|    for (int i = 0; i < r->high_low_container.size; i++) {
  ------------------
  |  Branch (1469:21): [True: 6.44k, False: 6.44k]
  ------------------
 1470|  6.44k|        uint8_t type_original;
 1471|  6.44k|        container_t *c = ra_get_container_at_index(&r->high_low_container,
 1472|  6.44k|                                                   (uint16_t)i, &type_original);
 1473|  6.44k|        answer += container_shrink_to_fit(c, type_original);
 1474|  6.44k|    }
 1475|  6.44k|    answer += ra_shrink_to_fit(&r->high_low_container);
 1476|  6.44k|    return answer;
 1477|  6.44k|}
roaring_bitmap_remove_run_compression:
 1483|  6.44k|bool roaring_bitmap_remove_run_compression(roaring_bitmap_t *r) {
 1484|  6.44k|    bool answer = false;
 1485|  86.4k|    for (int i = 0; i < r->high_low_container.size; i++) {
  ------------------
  |  Branch (1485:21): [True: 80.0k, False: 6.44k]
  ------------------
 1486|  80.0k|        uint8_t type_original, type_after;
 1487|  80.0k|        container_t *c = ra_get_container_at_index(&r->high_low_container,
 1488|  80.0k|                                                   (uint16_t)i, &type_original);
 1489|  80.0k|        if (get_container_type(c, type_original) == RUN_CONTAINER_TYPE) {
  ------------------
  |  |   50|  80.0k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (1489:13): [True: 72.3k, False: 7.65k]
  ------------------
 1490|  72.3k|            answer = true;
 1491|  72.3k|            if (type_original == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|  72.3k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (1491:17): [True: 0, False: 72.3k]
  ------------------
 1492|      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)
  |  |  ------------------
  ------------------
 1493|      0|                int32_t card = run_container_cardinality(truec);
 1494|      0|                container_t *c1 = convert_to_bitset_or_array_container(
 1495|      0|                    truec, card, &type_after);
 1496|      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)
  |  |  ------------------
  ------------------
 1497|      0|                ra_set_container_at_index(&r->high_low_container, i, c1,
 1498|      0|                                          type_after);
 1499|       |
 1500|  72.3k|            } else {
 1501|  72.3k|                int32_t card = run_container_cardinality(CAST_run(c));
  ------------------
  |  |   77|  72.3k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  72.3k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1502|  72.3k|                container_t *c1 = convert_to_bitset_or_array_container(
 1503|  72.3k|                    CAST_run(c), card, &type_after);
  ------------------
  |  |   77|  72.3k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  72.3k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1504|  72.3k|                run_container_free(CAST_run(c));
  ------------------
  |  |   77|  72.3k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  72.3k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1505|  72.3k|                ra_set_container_at_index(&r->high_low_container, i, c1,
 1506|  72.3k|                                          type_after);
 1507|  72.3k|            }
 1508|  72.3k|        }
 1509|  80.0k|    }
 1510|  6.44k|    return answer;
 1511|  6.44k|}
roaring_bitmap_portable_size_in_bytes:
 1546|  12.8k|size_t roaring_bitmap_portable_size_in_bytes(const roaring_bitmap_t *r) {
 1547|  12.8k|    return ra_portable_size_in_bytes(&r->high_low_container);
 1548|  12.8k|}
roaring_bitmap_portable_deserialize_safe:
 1551|  12.8k|                                                           size_t maxbytes) {
 1552|  12.8k|    roaring_bitmap_t *ans =
 1553|  12.8k|        (roaring_bitmap_t *)roaring_malloc(sizeof(roaring_bitmap_t));
 1554|  12.8k|    if (ans == NULL) {
  ------------------
  |  Branch (1554:9): [True: 0, False: 12.8k]
  ------------------
 1555|      0|        return NULL;
 1556|      0|    }
 1557|  12.8k|    size_t bytesread;
 1558|  12.8k|    bool is_ok = ra_portable_deserialize(&ans->high_low_container, buf,
 1559|  12.8k|                                         maxbytes, &bytesread);
 1560|  12.8k|    if (!is_ok) {
  ------------------
  |  Branch (1560:9): [True: 6.42k, False: 6.45k]
  ------------------
 1561|  6.42k|        roaring_free(ans);
 1562|  6.42k|        return NULL;
 1563|  6.42k|    }
 1564|  6.45k|    roaring_bitmap_set_copy_on_write(ans, false);
 1565|  6.45k|    if (!is_ok) {
  ------------------
  |  Branch (1565:9): [True: 0, False: 6.45k]
  ------------------
 1566|      0|        roaring_free(ans);
 1567|      0|        return NULL;
 1568|      0|    }
 1569|  6.45k|    return ans;
 1570|  6.45k|}
roaring_bitmap_portable_serialize:
 1581|  6.44k|size_t roaring_bitmap_portable_serialize(const roaring_bitmap_t *r, char *buf) {
 1582|  6.44k|    return ra_portable_serialize(&r->high_low_container, buf);
 1583|  6.44k|}
roaring_iterate:
 1664|  6.42k|                     void *ptr) {
 1665|  6.42k|    const roaring_array_t *ra = &r->high_low_container;
 1666|       |
 1667|  75.0k|    for (int i = 0; i < ra->size; ++i)
  ------------------
  |  Branch (1667:21): [True: 68.6k, False: 6.42k]
  ------------------
 1668|  68.6k|        if (!container_iterate(ra->containers[i], ra->typecodes[i],
  ------------------
  |  Branch (1668:13): [True: 0, False: 68.6k]
  ------------------
 1669|  68.6k|                               ((uint32_t)ra->keys[i]) << 16, iterator, ptr)) {
 1670|      0|            return false;
 1671|      0|        }
 1672|  6.42k|    return true;
 1673|  6.42k|}
roaring_iterator_init:
 1780|  12.8k|                           roaring_uint32_iterator_t *newit) {
 1781|  12.8k|    newit->parent = r;
 1782|  12.8k|    newit->container_index = 0;
 1783|  12.8k|    newit->has_value = loadfirstvalue(newit);
 1784|  12.8k|}
roaring_uint32_iterator_move_equalorlarger:
 1812|  6.44k|                                                uint32_t val) {
 1813|  6.44k|    uint16_t hb = val >> 16;
 1814|  6.44k|    const int i = ra_get_index(&it->parent->high_low_container, hb);
 1815|  6.44k|    if (i >= 0) {
  ------------------
  |  Branch (1815:9): [True: 6.35k, False: 85]
  ------------------
 1816|  6.35k|        uint32_t lowvalue =
 1817|  6.35k|            container_maximum(it->parent->high_low_container.containers[i],
 1818|  6.35k|                              it->parent->high_low_container.typecodes[i]);
 1819|  6.35k|        uint16_t lb = val & 0xFFFF;
 1820|  6.35k|        if (lowvalue < lb) {
  ------------------
  |  Branch (1820:13): [True: 19, False: 6.33k]
  ------------------
 1821|       |            // will have to load first value of next container
 1822|     19|            it->container_index = i + 1;
 1823|  6.33k|        } else {
 1824|       |            // the value is necessarily within the range of the container
 1825|  6.33k|            it->container_index = i;
 1826|  6.33k|            it->has_value = loadfirstvalue_largeorequal(it, val);
 1827|  6.33k|            return it->has_value;
 1828|  6.33k|        }
 1829|  6.35k|    } else {
 1830|       |        // there is no matching, so we are going for the next container
 1831|     85|        it->container_index = -i - 1;
 1832|     85|    }
 1833|    104|    it->has_value = loadfirstvalue(it);
 1834|    104|    return it->has_value;
 1835|  6.44k|}
roaring_uint32_iterator_advance:
 1837|   333k|bool roaring_uint32_iterator_advance(roaring_uint32_iterator_t *it) {
 1838|   333k|    if (it->container_index >= it->parent->high_low_container.size) {
  ------------------
  |  Branch (1838:9): [True: 0, False: 333k]
  ------------------
 1839|      0|        return (it->has_value = false);
 1840|      0|    }
 1841|   333k|    if (it->container_index < 0) {
  ------------------
  |  Branch (1841:9): [True: 0, False: 333k]
  ------------------
 1842|      0|        it->container_index = 0;
 1843|      0|        return (it->has_value = loadfirstvalue(it));
 1844|      0|    }
 1845|   333k|    uint16_t low16 = (uint16_t)it->current_value;
 1846|   333k|    if (container_iterator_next(it->container, it->typecode, &it->container_it,
  ------------------
  |  Branch (1846:9): [True: 327k, False: 6.20k]
  ------------------
 1847|   333k|                                &low16)) {
 1848|   327k|        it->current_value = it->highbits | low16;
 1849|   327k|        return (it->has_value = true);
 1850|   327k|    }
 1851|  6.20k|    it->container_index++;
 1852|  6.20k|    return (it->has_value = loadfirstvalue(it));
 1853|   333k|}
roaring_bitmap_equals:
 2048|  12.8k|                           const roaring_bitmap_t *r2) {
 2049|  12.8k|    const roaring_array_t *ra1 = &r1->high_low_container;
 2050|  12.8k|    const roaring_array_t *ra2 = &r2->high_low_container;
 2051|       |
 2052|  12.8k|    if (ra1->size != ra2->size) {
  ------------------
  |  Branch (2052:9): [True: 2.54k, False: 10.3k]
  ------------------
 2053|  2.54k|        return false;
 2054|  2.54k|    }
 2055|  94.2k|    for (int i = 0; i < ra1->size; ++i) {
  ------------------
  |  Branch (2055:21): [True: 83.9k, False: 10.3k]
  ------------------
 2056|  83.9k|        if (ra1->keys[i] != ra2->keys[i]) {
  ------------------
  |  Branch (2056:13): [True: 27, False: 83.8k]
  ------------------
 2057|     27|            return false;
 2058|     27|        }
 2059|  83.9k|    }
 2060|  90.3k|    for (int i = 0; i < ra1->size; ++i) {
  ------------------
  |  Branch (2060:21): [True: 83.8k, False: 6.44k]
  ------------------
 2061|  83.8k|        bool areequal = container_equals(ra1->containers[i], ra1->typecodes[i],
 2062|  83.8k|                                         ra2->containers[i], ra2->typecodes[i]);
 2063|  83.8k|        if (!areequal) {
  ------------------
  |  Branch (2063:13): [True: 3.86k, False: 80.0k]
  ------------------
 2064|  3.86k|            return false;
 2065|  3.86k|        }
 2066|  83.8k|    }
 2067|  6.44k|    return true;
 2068|  10.3k|}
roaring_bitmap_is_subset:
 2071|  11.7k|                              const roaring_bitmap_t *r2) {
 2072|  11.7k|    const roaring_array_t *ra1 = &r1->high_low_container;
 2073|  11.7k|    const roaring_array_t *ra2 = &r2->high_low_container;
 2074|       |
 2075|  11.7k|    const int length1 = ra1->size, length2 = ra2->size;
 2076|       |
 2077|  11.7k|    int pos1 = 0, pos2 = 0;
 2078|       |
 2079|  11.7k|    while (pos1 < length1 && pos2 < length2) {
  ------------------
  |  Branch (2079:12): [True: 11.2k, False: 478]
  |  Branch (2079:30): [True: 11.1k, False: 45]
  ------------------
 2080|  11.1k|        const uint16_t s1 = ra_get_key_at_index(ra1, (uint16_t)pos1);
 2081|  11.1k|        const uint16_t s2 = ra_get_key_at_index(ra2, (uint16_t)pos2);
 2082|       |
 2083|  11.1k|        if (s1 == s2) {
  ------------------
  |  Branch (2083:13): [True: 11.1k, False: 84]
  ------------------
 2084|  11.1k|            uint8_t type1, type2;
 2085|  11.1k|            container_t *c1 =
 2086|  11.1k|                ra_get_container_at_index(ra1, (uint16_t)pos1, &type1);
 2087|  11.1k|            container_t *c2 =
 2088|  11.1k|                ra_get_container_at_index(ra2, (uint16_t)pos2, &type2);
 2089|  11.1k|            if (!container_is_subset(c1, type1, c2, type2)) return false;
  ------------------
  |  Branch (2089:17): [True: 11.1k, False: 0]
  ------------------
 2090|      0|            ++pos1;
 2091|      0|            ++pos2;
 2092|     84|        } else if (s1 < s2) {  // s1 < s2
  ------------------
  |  Branch (2092:20): [True: 84, False: 0]
  ------------------
 2093|     84|            return false;
 2094|     84|        } else {  // s1 > s2
 2095|      0|            pos2 = ra_advance_until(ra2, s1, pos2);
 2096|      0|        }
 2097|  11.1k|    }
 2098|    523|    if (pos1 == length1)
  ------------------
  |  Branch (2098:9): [True: 478, False: 45]
  ------------------
 2099|    478|        return true;
 2100|     45|    else
 2101|     45|        return false;
 2102|    523|}
roaring_bitmap_flip_inplace:
 2271|  6.44k|                                 uint64_t range_end) {
 2272|  6.44k|    if (range_start >= range_end || range_start > (uint64_t)UINT32_MAX + 1) {
  ------------------
  |  Branch (2272:9): [True: 5.98k, False: 459]
  |  Branch (2272:37): [True: 0, False: 459]
  ------------------
 2273|  5.98k|        return;
 2274|  5.98k|    }
 2275|    459|    roaring_bitmap_flip_inplace_closed(x1, (uint32_t)range_start,
 2276|    459|                                       (uint32_t)(range_end - 1));
 2277|    459|}
roaring_bitmap_flip_inplace_closed:
 2281|  6.90k|                                        uint32_t range_end) {
 2282|  6.90k|    if (range_start > range_end) {
  ------------------
  |  Branch (2282:9): [True: 153, False: 6.74k]
  ------------------
 2283|    153|        return;  // empty range
 2284|    153|    }
 2285|       |
 2286|  6.74k|    uint16_t hb_start = (uint16_t)(range_start >> 16);
 2287|  6.74k|    const uint16_t lb_start = (uint16_t)range_start;
 2288|  6.74k|    uint16_t hb_end = (uint16_t)(range_end >> 16);
 2289|  6.74k|    const uint16_t lb_end = (uint16_t)range_end;
 2290|       |
 2291|  6.74k|    if (hb_start == hb_end) {
  ------------------
  |  Branch (2291:9): [True: 6.31k, False: 434]
  ------------------
 2292|  6.31k|        inplace_flip_container(&x1->high_low_container, hb_start, lb_start,
 2293|  6.31k|                               lb_end);
 2294|  6.31k|    } else {
 2295|       |        // start and end containers are distinct
 2296|    434|        if (lb_start > 0) {
  ------------------
  |  Branch (2296:13): [True: 357, False: 77]
  ------------------
 2297|       |            // handle first (partial) container
 2298|    357|            inplace_flip_container(&x1->high_low_container, hb_start, lb_start,
 2299|    357|                                   0xFFFF);
 2300|    357|            ++hb_start;  // for the full containers.  Can't wrap.
 2301|    357|        }
 2302|       |
 2303|    434|        if (lb_end != 0xFFFF) --hb_end;
  ------------------
  |  Branch (2303:13): [True: 418, False: 16]
  ------------------
 2304|       |
 2305|  22.6k|        for (uint32_t hb = hb_start; hb <= hb_end; ++hb) {
  ------------------
  |  Branch (2305:38): [True: 22.2k, False: 434]
  ------------------
 2306|  22.2k|            inplace_fully_flip_container(&x1->high_low_container, (uint16_t)hb);
 2307|  22.2k|        }
 2308|       |        // handle a partial final container
 2309|    434|        if (lb_end != 0xFFFF) {
  ------------------
  |  Branch (2309:13): [True: 418, False: 16]
  ------------------
 2310|    418|            inplace_flip_container(&x1->high_low_container, hb_end + 1, 0,
 2311|    418|                                   lb_end);
 2312|    418|            ++hb_end;
 2313|    418|        }
 2314|    434|    }
 2315|  6.74k|}
roaring_bitmap_rank:
 2781|  6.44k|uint64_t roaring_bitmap_rank(const roaring_bitmap_t *bm, uint32_t x) {
 2782|  6.44k|    uint64_t size = 0;
 2783|  6.44k|    uint32_t xhigh = x >> 16;
 2784|  6.44k|    for (int i = 0; i < bm->high_low_container.size; i++) {
  ------------------
  |  Branch (2784:21): [True: 6.44k, False: 0]
  ------------------
 2785|  6.44k|        uint32_t key = bm->high_low_container.keys[i];
 2786|  6.44k|        if (xhigh > key) {
  ------------------
  |  Branch (2786:13): [True: 0, False: 6.44k]
  ------------------
 2787|      0|            size +=
 2788|      0|                container_get_cardinality(bm->high_low_container.containers[i],
 2789|      0|                                          bm->high_low_container.typecodes[i]);
 2790|  6.44k|        } else if (xhigh == key) {
  ------------------
  |  Branch (2790:20): [True: 6.44k, False: 0]
  ------------------
 2791|  6.44k|            return size + container_rank(bm->high_low_container.containers[i],
 2792|  6.44k|                                         bm->high_low_container.typecodes[i],
 2793|  6.44k|                                         x & 0xFFFF);
 2794|  6.44k|        } else {
 2795|      0|            return size;
 2796|      0|        }
 2797|  6.44k|    }
 2798|      0|    return size;
 2799|  6.44k|}
roaring_bitmap_minimum:
 2860|  6.44k|uint32_t roaring_bitmap_minimum(const roaring_bitmap_t *bm) {
 2861|  6.44k|    if (bm->high_low_container.size > 0) {
  ------------------
  |  Branch (2861:9): [True: 6.39k, False: 45]
  ------------------
 2862|  6.39k|        container_t *c = bm->high_low_container.containers[0];
 2863|  6.39k|        uint8_t type = bm->high_low_container.typecodes[0];
 2864|  6.39k|        uint32_t key = bm->high_low_container.keys[0];
 2865|  6.39k|        uint32_t lowvalue = container_minimum(c, type);
 2866|  6.39k|        return lowvalue | (key << 16);
 2867|  6.39k|    }
 2868|     45|    return UINT32_MAX;
 2869|  6.44k|}
roaring_bitmap_maximum:
 2875|  6.44k|uint32_t roaring_bitmap_maximum(const roaring_bitmap_t *bm) {
 2876|  6.44k|    if (bm->high_low_container.size > 0) {
  ------------------
  |  Branch (2876:9): [True: 6.39k, False: 45]
  ------------------
 2877|  6.39k|        container_t *container =
 2878|  6.39k|            bm->high_low_container.containers[bm->high_low_container.size - 1];
 2879|  6.39k|        uint8_t typecode =
 2880|  6.39k|            bm->high_low_container.typecodes[bm->high_low_container.size - 1];
 2881|  6.39k|        uint32_t key =
 2882|  6.39k|            bm->high_low_container.keys[bm->high_low_container.size - 1];
 2883|  6.39k|        uint32_t lowvalue = container_maximum(container, typecode);
 2884|  6.39k|        return lowvalue | (key << 16);
 2885|  6.39k|    }
 2886|     45|    return 0;
 2887|  6.44k|}
roaring_bitmap_select:
 2890|  6.44k|                           uint32_t *element) {
 2891|  6.44k|    container_t *container;
 2892|  6.44k|    uint8_t typecode;
 2893|  6.44k|    uint16_t key;
 2894|  6.44k|    uint32_t start_rank = 0;
 2895|  6.44k|    int i = 0;
 2896|  6.44k|    bool valid = false;
 2897|  12.8k|    while (!valid && i < bm->high_low_container.size) {
  ------------------
  |  Branch (2897:12): [True: 6.85k, False: 6.02k]
  |  Branch (2897:22): [True: 6.44k, False: 415]
  ------------------
 2898|  6.44k|        container = bm->high_low_container.containers[i];
 2899|  6.44k|        typecode = bm->high_low_container.typecodes[i];
 2900|  6.44k|        valid =
 2901|  6.44k|            container_select(container, typecode, &start_rank, rank, element);
 2902|  6.44k|        i++;
 2903|  6.44k|    }
 2904|       |
 2905|  6.44k|    if (valid) {
  ------------------
  |  Branch (2905:9): [True: 6.02k, False: 415]
  ------------------
 2906|  6.02k|        key = bm->high_low_container.keys[i - 1];
 2907|  6.02k|        *element |= (((uint32_t)key) << 16);  // w/o cast, key promotes signed
 2908|  6.02k|        return true;
 2909|  6.02k|    } else
 2910|    415|        return false;
 2911|  6.44k|}
roaring_bitmap_intersect:
 2914|  6.44k|                              const roaring_bitmap_t *x2) {
 2915|  6.44k|    const int length1 = x1->high_low_container.size,
 2916|  6.44k|              length2 = x2->high_low_container.size;
 2917|  6.44k|    uint64_t answer = 0;
 2918|  6.44k|    int pos1 = 0, pos2 = 0;
 2919|       |
 2920|  6.82k|    while (pos1 < length1 && pos2 < length2) {
  ------------------
  |  Branch (2920:12): [True: 6.44k, False: 380]
  |  Branch (2920:30): [True: 6.39k, False: 45]
  ------------------
 2921|  6.39k|        const uint16_t s1 =
 2922|  6.39k|            ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 2923|  6.39k|        const uint16_t s2 =
 2924|  6.39k|            ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 2925|       |
 2926|  6.39k|        if (s1 == s2) {
  ------------------
  |  Branch (2926:13): [True: 6.33k, False: 60]
  ------------------
 2927|  6.33k|            uint8_t type1, type2;
 2928|  6.33k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
 2929|  6.33k|                                                        (uint16_t)pos1, &type1);
 2930|  6.33k|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
 2931|  6.33k|                                                        (uint16_t)pos2, &type2);
 2932|  6.33k|            if (container_intersect(c1, type1, c2, type2)) return true;
  ------------------
  |  Branch (2932:17): [True: 6.01k, False: 320]
  ------------------
 2933|    320|            ++pos1;
 2934|    320|            ++pos2;
 2935|    320|        } else if (s1 < s2) {  // s1 < s2
  ------------------
  |  Branch (2935:20): [True: 60, False: 0]
  ------------------
 2936|     60|            pos1 = ra_advance_until(&x1->high_low_container, s2, pos1);
 2937|     60|        } else {  // s1 > s2
 2938|      0|            pos2 = ra_advance_until(&x2->high_low_container, s1, pos2);
 2939|      0|        }
 2940|  6.39k|    }
 2941|    425|    return answer != 0;
 2942|  6.44k|}
roaring_bitmap_and_cardinality:
 2964|  25.7k|                                        const roaring_bitmap_t *x2) {
 2965|  25.7k|    const int length1 = x1->high_low_container.size,
 2966|  25.7k|              length2 = x2->high_low_container.size;
 2967|  25.7k|    uint64_t answer = 0;
 2968|  25.7k|    int pos1 = 0, pos2 = 0;
 2969|  51.3k|    while (pos1 < length1 && pos2 < length2) {
  ------------------
  |  Branch (2969:12): [True: 25.7k, False: 25.5k]
  |  Branch (2969:30): [True: 25.5k, False: 180]
  ------------------
 2970|  25.5k|        const uint16_t s1 =
 2971|  25.5k|            ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 2972|  25.5k|        const uint16_t s2 =
 2973|  25.5k|            ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 2974|       |
 2975|  25.5k|        if (s1 == s2) {
  ------------------
  |  Branch (2975:13): [True: 25.3k, False: 240]
  ------------------
 2976|  25.3k|            uint8_t type1, type2;
 2977|  25.3k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
 2978|  25.3k|                                                        (uint16_t)pos1, &type1);
 2979|  25.3k|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
 2980|  25.3k|                                                        (uint16_t)pos2, &type2);
 2981|  25.3k|            answer += container_and_cardinality(c1, type1, c2, type2);
 2982|  25.3k|            ++pos1;
 2983|  25.3k|            ++pos2;
 2984|  25.3k|        } else if (s1 < s2) {  // s1 < s2
  ------------------
  |  Branch (2984:20): [True: 240, False: 0]
  ------------------
 2985|    240|            pos1 = ra_advance_until(&x1->high_low_container, s2, pos1);
 2986|    240|        } else {  // s1 > s2
 2987|      0|            pos2 = ra_advance_until(&x2->high_low_container, s1, pos2);
 2988|      0|        }
 2989|  25.5k|    }
 2990|  25.7k|    return answer;
 2991|  25.7k|}
roaring_bitmap_jaccard_index:
 2994|  6.44k|                                    const roaring_bitmap_t *x2) {
 2995|  6.44k|    const uint64_t c1 = roaring_bitmap_get_cardinality(x1);
 2996|  6.44k|    const uint64_t c2 = roaring_bitmap_get_cardinality(x2);
 2997|  6.44k|    const uint64_t inter = roaring_bitmap_and_cardinality(x1, x2);
 2998|  6.44k|    return (double)inter / (double)(c1 + c2 - inter);
 2999|  6.44k|}
roaring_bitmap_or_cardinality:
 3002|  6.44k|                                       const roaring_bitmap_t *x2) {
 3003|  6.44k|    const uint64_t c1 = roaring_bitmap_get_cardinality(x1);
 3004|  6.44k|    const uint64_t c2 = roaring_bitmap_get_cardinality(x2);
 3005|  6.44k|    const uint64_t inter = roaring_bitmap_and_cardinality(x1, x2);
 3006|  6.44k|    return c1 + c2 - inter;
 3007|  6.44k|}
roaring_bitmap_andnot_cardinality:
 3010|  6.44k|                                           const roaring_bitmap_t *x2) {
 3011|  6.44k|    const uint64_t c1 = roaring_bitmap_get_cardinality(x1);
 3012|  6.44k|    const uint64_t inter = roaring_bitmap_and_cardinality(x1, x2);
 3013|  6.44k|    return c1 - inter;
 3014|  6.44k|}
roaring_bitmap_xor_cardinality:
 3017|  6.44k|                                        const roaring_bitmap_t *x2) {
 3018|  6.44k|    const uint64_t c1 = roaring_bitmap_get_cardinality(x1);
 3019|  6.44k|    const uint64_t c2 = roaring_bitmap_get_cardinality(x2);
 3020|  6.44k|    const uint64_t inter = roaring_bitmap_and_cardinality(x1, x2);
 3021|  6.44k|    return c1 + c2 - 2 * inter;
 3022|  6.44k|}
roaring_bitmap_contains_range:
 3029|  6.44k|                                   uint64_t range_start, uint64_t range_end) {
 3030|  6.44k|    if (range_start >= range_end || range_start > (uint64_t)UINT32_MAX + 1) {
  ------------------
  |  Branch (3030:9): [True: 5.61k, False: 828]
  |  Branch (3030:37): [True: 0, False: 828]
  ------------------
 3031|  5.61k|        return true;
 3032|  5.61k|    }
 3033|    828|    return roaring_bitmap_contains_range_closed(r, (uint32_t)range_start,
 3034|    828|                                                (uint32_t)(range_end - 1));
 3035|  6.44k|}
roaring_bitmap_contains_range_closed:
 3043|    828|                                          uint32_t range_end) {
 3044|    828|    if (range_start > range_end) {
  ------------------
  |  Branch (3044:9): [True: 0, False: 828]
  ------------------
 3045|      0|        return true;
 3046|      0|    }  // empty range are always contained!
 3047|    828|    if (range_end == range_start) {
  ------------------
  |  Branch (3047:9): [True: 64, False: 764]
  ------------------
 3048|     64|        return roaring_bitmap_contains(r, (uint32_t)range_start);
 3049|     64|    }
 3050|    764|    uint16_t hb_rs = (uint16_t)(range_start >> 16);
 3051|    764|    uint16_t hb_re = (uint16_t)(range_end >> 16);
 3052|    764|    const int32_t span = hb_re - hb_rs;
 3053|    764|    const int32_t hlc_sz = ra_get_size(&r->high_low_container);
 3054|    764|    if (hlc_sz < span + 1) {
  ------------------
  |  Branch (3054:9): [True: 191, False: 573]
  ------------------
 3055|    191|        return false;
 3056|    191|    }
 3057|    573|    int32_t is = ra_get_index(&r->high_low_container, hb_rs);
 3058|    573|    int32_t ie = ra_get_index(&r->high_low_container, hb_re);
 3059|    573|    if ((ie < 0) || (is < 0) || ((ie - is) != span) || ie >= hlc_sz) {
  ------------------
  |  Branch (3059:9): [True: 42, False: 531]
  |  Branch (3059:21): [True: 12, False: 519]
  |  Branch (3059:33): [True: 7, False: 512]
  |  Branch (3059:56): [True: 0, False: 512]
  ------------------
 3060|     61|        return false;
 3061|     61|    }
 3062|    512|    const uint32_t lb_rs = range_start & 0xFFFF;
 3063|    512|    const uint32_t lb_re = (range_end & 0xFFFF) + 1;
 3064|    512|    uint8_t type;
 3065|    512|    container_t *c =
 3066|    512|        ra_get_container_at_index(&r->high_low_container, (uint16_t)is, &type);
 3067|    512|    if (hb_rs == hb_re) {
  ------------------
  |  Branch (3067:9): [True: 451, False: 61]
  ------------------
 3068|    451|        return container_contains_range(c, lb_rs, lb_re, type);
 3069|    451|    }
 3070|     61|    if (!container_contains_range(c, lb_rs, 1 << 16, type)) {
  ------------------
  |  Branch (3070:9): [True: 19, False: 42]
  ------------------
 3071|     19|        return false;
 3072|     19|    }
 3073|     42|    c = ra_get_container_at_index(&r->high_low_container, (uint16_t)ie, &type);
 3074|     42|    if (!container_contains_range(c, 0, lb_re, type)) {
  ------------------
  |  Branch (3074:9): [True: 3, False: 39]
  ------------------
 3075|      3|        return false;
 3076|      3|    }
 3077|    837|    for (int32_t i = is + 1; i < ie; ++i) {
  ------------------
  |  Branch (3077:30): [True: 813, False: 24]
  ------------------
 3078|    813|        c = ra_get_container_at_index(&r->high_low_container, (uint16_t)i,
 3079|    813|                                      &type);
 3080|    813|        if (!container_is_full(c, type)) {
  ------------------
  |  Branch (3080:13): [True: 15, False: 798]
  ------------------
 3081|     15|            return false;
 3082|     15|        }
 3083|    813|    }
 3084|     24|    return true;
 3085|     39|}
roaring_bitmap_is_strict_subset:
 3088|  6.44k|                                     const roaring_bitmap_t *r2) {
 3089|  6.44k|    return (roaring_bitmap_get_cardinality(r2) >
  ------------------
  |  Branch (3089:13): [True: 5.27k, False: 1.16k]
  ------------------
 3090|  6.44k|                roaring_bitmap_get_cardinality(r1) &&
 3091|  5.27k|            roaring_bitmap_is_subset(r1, r2));
  ------------------
  |  Branch (3091:13): [True: 239, False: 5.03k]
  ------------------
 3092|  6.44k|}
roaring.c:containerptr_roaring_bitmap_add:
   56|  19.3k|                                                           int *index) {
   57|  19.3k|    roaring_array_t *ra = &r->high_low_container;
   58|       |
   59|  19.3k|    uint16_t hb = val >> 16;
   60|  19.3k|    const int i = ra_get_index(ra, hb);
   61|  19.3k|    if (i >= 0) {
  ------------------
  |  Branch (61:9): [True: 6.44k, False: 12.8k]
  ------------------
   62|  6.44k|        ra_unshare_container_at_index(ra, (uint16_t)i);
   63|  6.44k|        container_t *c = ra_get_container_at_index(ra, (uint16_t)i, type);
   64|  6.44k|        uint8_t new_type = *type;
   65|  6.44k|        container_t *c2 = container_add(c, val & 0xFFFF, *type, &new_type);
   66|  6.44k|        *index = i;
   67|  6.44k|        if (c2 != c) {
  ------------------
  |  Branch (67:13): [True: 2, False: 6.43k]
  ------------------
   68|      2|            container_free(c, *type);
   69|      2|            ra_set_container_at_index(ra, i, c2, new_type);
   70|      2|            *type = new_type;
   71|      2|            return c2;
   72|  6.43k|        } else {
   73|  6.43k|            return c;
   74|  6.43k|        }
   75|  12.8k|    } else {
   76|  12.8k|        array_container_t *new_ac = array_container_create();
   77|  12.8k|        container_t *c =
   78|  12.8k|            container_add(new_ac, val & 0xFFFF, ARRAY_CONTAINER_TYPE, type);
  ------------------
  |  |   49|  12.8k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
   79|       |        // we could just assume that it stays an array container
   80|  12.8k|        ra_insert_new_key_value_at(ra, -i - 1, hb, c, *type);
   81|  12.8k|        *index = -i - 1;
   82|  12.8k|        return c;
   83|  12.8k|    }
   84|  19.3k|}
roaring.c:add_bulk_impl:
  106|  8.05M|                                 uint32_t val) {
  107|  8.05M|    uint16_t key = val >> 16;
  108|  8.05M|    if (context->container == NULL || context->key != key) {
  ------------------
  |  Branch (108:9): [True: 0, False: 8.05M]
  |  Branch (108:39): [True: 0, False: 8.05M]
  ------------------
  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.05M|    } 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.05M|        uint8_t new_typecode;
  121|  8.05M|        container_t *container2 = container_add(
  122|  8.05M|            context->container, val & 0xFFFF, context->typecode, &new_typecode);
  123|  8.05M|        if (container2 != context->container) {
  ------------------
  |  Branch (123:13): [True: 146, False: 8.05M]
  ------------------
  124|       |            // rare instance when we need to change the container type
  125|    146|            container_free(context->container, context->typecode);
  126|    146|            ra_set_container_at_index(&r->high_low_container, context->idx,
  127|    146|                                      container2, new_typecode);
  128|    146|            context->typecode = new_typecode;
  129|    146|            context->container = container2;
  130|    146|        }
  131|  8.05M|    }
  132|  8.05M|}
roaring.c:is_cow:
   41|   108k|static inline bool is_cow(const roaring_bitmap_t *r) {
   42|       |    return r->high_low_container.flags & ROARING_FLAG_COW;
  ------------------
  |  |   46|   108k|#define ROARING_FLAG_COW UINT8_C(0x1)
  ------------------
   43|   108k|}
roaring.c:loadfirstvalue:
 1728|  19.1k|    roaring_uint32_iterator_t *newit) {
 1729|  19.1k|    if (iter_new_container_partial_init(newit)) {
  ------------------
  |  Branch (1729:9): [True: 12.7k, False: 6.48k]
  ------------------
 1730|  12.7k|        uint16_t value = 0;
 1731|  12.7k|        newit->container_it =
 1732|  12.7k|            container_init_iterator(newit->container, newit->typecode, &value);
 1733|  12.7k|        newit->current_value = newit->highbits | value;
 1734|  12.7k|    }
 1735|  19.1k|    return newit->has_value;
 1736|  19.1k|}
roaring.c:iter_new_container_partial_init:
 1698|  25.5k|    roaring_uint32_iterator_t *newit) {
 1699|  25.5k|    newit->current_value = 0;
 1700|  25.5k|    if (newit->container_index >= newit->parent->high_low_container.size ||
  ------------------
  |  Branch (1700:9): [True: 6.48k, False: 19.0k]
  ------------------
 1701|  19.0k|        newit->container_index < 0) {
  ------------------
  |  Branch (1701:9): [True: 0, False: 19.0k]
  ------------------
 1702|  6.48k|        newit->current_value = UINT32_MAX;
 1703|  6.48k|        return (newit->has_value = false);
 1704|  6.48k|    }
 1705|  19.0k|    newit->has_value = true;
 1706|       |    // we precompute container, typecode and highbits so that successive
 1707|       |    // iterators do not have to grab them from odd memory locations
 1708|       |    // and have to worry about the (easily predicted) container_unwrap_shared
 1709|       |    // call.
 1710|  19.0k|    newit->container =
 1711|  19.0k|        newit->parent->high_low_container.containers[newit->container_index];
 1712|  19.0k|    newit->typecode =
 1713|  19.0k|        newit->parent->high_low_container.typecodes[newit->container_index];
 1714|  19.0k|    newit->highbits =
 1715|  19.0k|        ((uint32_t)
 1716|  19.0k|             newit->parent->high_low_container.keys[newit->container_index])
 1717|  19.0k|        << 16;
 1718|  19.0k|    newit->container =
 1719|  19.0k|        container_unwrap_shared(newit->container, &(newit->typecode));
 1720|       |    return true;
 1721|  25.5k|}
roaring.c:loadfirstvalue_largeorequal:
 1759|  6.33k|    roaring_uint32_iterator_t *newit, uint32_t val) {
 1760|  6.33k|    bool partial_init = iter_new_container_partial_init(newit);
 1761|  6.33k|    assert(partial_init);
 1762|  6.33k|    if (!partial_init) {
  ------------------
  |  Branch (1762:9): [True: 0, False: 6.33k]
  ------------------
 1763|      0|        return false;
 1764|      0|    }
 1765|  6.33k|    uint16_t value = 0;
 1766|  6.33k|    newit->container_it =
 1767|  6.33k|        container_init_iterator(newit->container, newit->typecode, &value);
 1768|  6.33k|    bool found = container_iterator_lower_bound(
 1769|  6.33k|        newit->container, newit->typecode, &newit->container_it, &value,
 1770|  6.33k|        val & 0xFFFF);
 1771|  6.33k|    assert(found);
 1772|  6.33k|    if (!found) {
  ------------------
  |  Branch (1772:9): [True: 0, False: 6.33k]
  ------------------
 1773|      0|        return false;
 1774|      0|    }
 1775|  6.33k|    newit->current_value = newit->highbits | value;
 1776|       |    return true;
 1777|  6.33k|}
roaring.c:inplace_flip_container:
 2133|  7.08k|                                   uint16_t lb_start, uint16_t lb_end) {
 2134|  7.08k|    const int i = ra_get_index(x1_arr, hb);
 2135|  7.08k|    uint8_t ctype_in, ctype_out;
 2136|  7.08k|    container_t *flipped_container = NULL;
 2137|  7.08k|    if (i >= 0) {
  ------------------
  |  Branch (2137:9): [True: 6.57k, False: 509]
  ------------------
 2138|  6.57k|        container_t *container_to_flip =
 2139|  6.57k|            ra_get_container_at_index(x1_arr, (uint16_t)i, &ctype_in);
 2140|  6.57k|        flipped_container = container_inot_range(
 2141|  6.57k|            container_to_flip, ctype_in, (uint32_t)lb_start,
 2142|  6.57k|            (uint32_t)(lb_end + 1), &ctype_out);
 2143|       |        // if a new container was created, the old one was already freed
 2144|  6.57k|        if (container_nonzero_cardinality(flipped_container, ctype_out)) {
  ------------------
  |  Branch (2144:13): [True: 6.55k, False: 26]
  ------------------
 2145|  6.55k|            ra_set_container_at_index(x1_arr, i, flipped_container, ctype_out);
 2146|  6.55k|        } else {
 2147|     26|            container_free(flipped_container, ctype_out);
 2148|     26|            ra_remove_at_index(x1_arr, i);
 2149|     26|        }
 2150|       |
 2151|  6.57k|    } else {
 2152|    509|        flipped_container = container_range_of_ones(
 2153|    509|            (uint32_t)lb_start, (uint32_t)(lb_end + 1), &ctype_out);
 2154|    509|        ra_insert_new_key_value_at(x1_arr, -i - 1, hb, flipped_container,
 2155|    509|                                   ctype_out);
 2156|    509|    }
 2157|  7.08k|}
roaring.c:inplace_fully_flip_container:
 2184|  22.2k|static void inplace_fully_flip_container(roaring_array_t *x1_arr, uint16_t hb) {
 2185|  22.2k|    const int i = ra_get_index(x1_arr, hb);
 2186|  22.2k|    uint8_t ctype_in, ctype_out;
 2187|  22.2k|    container_t *flipped_container = NULL;
 2188|  22.2k|    if (i >= 0) {
  ------------------
  |  Branch (2188:9): [True: 5.84k, False: 16.3k]
  ------------------
 2189|  5.84k|        container_t *container_to_flip =
 2190|  5.84k|            ra_get_container_at_index(x1_arr, (uint16_t)i, &ctype_in);
 2191|  5.84k|        flipped_container =
 2192|  5.84k|            container_inot(container_to_flip, ctype_in, &ctype_out);
 2193|       |
 2194|  5.84k|        if (container_nonzero_cardinality(flipped_container, ctype_out)) {
  ------------------
  |  Branch (2194:13): [True: 476, False: 5.37k]
  ------------------
 2195|    476|            ra_set_container_at_index(x1_arr, i, flipped_container, ctype_out);
 2196|  5.37k|        } else {
 2197|  5.37k|            container_free(flipped_container, ctype_out);
 2198|  5.37k|            ra_remove_at_index(x1_arr, i);
 2199|  5.37k|        }
 2200|       |
 2201|  16.3k|    } else {
 2202|  16.3k|        flipped_container = container_range_of_ones(0U, 0x10000U, &ctype_out);
 2203|  16.3k|        ra_insert_new_key_value_at(x1_arr, -i - 1, hb, flipped_container,
 2204|  16.3k|                                   ctype_out);
 2205|  16.3k|    }
 2206|  22.2k|}

ra_init_with_capacity:
   80|  64.4k|bool ra_init_with_capacity(roaring_array_t *new_ra, uint32_t cap) {
   81|  64.4k|    if (!new_ra) return false;
  ------------------
  |  Branch (81:9): [True: 0, False: 64.4k]
  ------------------
   82|  64.4k|    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|  64.4k|    if (cap > 0x10000) {
  ------------------
  |  Branch (86:9): [True: 0, False: 64.4k]
  ------------------
   87|      0|        cap = 0x10000;
   88|      0|    }
   89|       |
   90|  64.4k|    if (cap > 0) {
  ------------------
  |  Branch (90:9): [True: 32.2k, False: 32.2k]
  ------------------
   91|  32.2k|        void *bigalloc = roaring_malloc(
   92|  32.2k|            cap * (sizeof(uint16_t) + sizeof(container_t *) + sizeof(uint8_t)));
   93|  32.2k|        if (bigalloc == NULL) return false;
  ------------------
  |  Branch (93:13): [True: 0, False: 32.2k]
  ------------------
   94|  32.2k|        new_ra->containers = (container_t **)bigalloc;
   95|  32.2k|        new_ra->keys = (uint16_t *)(new_ra->containers + cap);
   96|  32.2k|        new_ra->typecodes = (uint8_t *)(new_ra->keys + cap);
   97|       |        // Narrowing is safe because of above check
   98|  32.2k|        new_ra->allocation_size = (int32_t)cap;
   99|  32.2k|    }
  100|  64.4k|    return true;
  101|  64.4k|}
ra_shrink_to_fit:
  103|  70.8k|int ra_shrink_to_fit(roaring_array_t *ra) {
  104|  70.8k|    int savings = (ra->allocation_size - ra->size) *
  105|  70.8k|                  (sizeof(uint16_t) + sizeof(container_t *) + sizeof(uint8_t));
  106|  70.8k|    if (!realloc_array(ra, ra->size)) {
  ------------------
  |  Branch (106:9): [True: 0, False: 70.8k]
  ------------------
  107|      0|        return 0;
  108|      0|    }
  109|  70.8k|    ra->allocation_size = ra->size;
  110|  70.8k|    return savings;
  111|  70.8k|}
ra_init:
  113|  64.4k|void ra_init(roaring_array_t *new_ra) {
  114|  64.4k|    if (!new_ra) {
  ------------------
  |  Branch (114:9): [True: 0, False: 64.4k]
  ------------------
  115|      0|        return;
  116|      0|    }
  117|  64.4k|    new_ra->keys = NULL;
  118|  64.4k|    new_ra->containers = NULL;
  119|  64.4k|    new_ra->typecodes = NULL;
  120|       |
  121|  64.4k|    new_ra->allocation_size = 0;
  122|  64.4k|    new_ra->size = 0;
  123|  64.4k|    new_ra->flags = 0;
  124|  64.4k|}
ra_overwrite:
  127|  14.5k|                  bool copy_on_write) {
  128|  14.5k|    ra_clear_containers(dest);  // we are going to overwrite them
  129|  14.5k|    if (source->size == 0) {    // Note: can't call memcpy(NULL), even w/size
  ------------------
  |  Branch (129:9): [True: 18, False: 14.4k]
  ------------------
  130|     18|        dest->size = 0;         // <--- This is important.
  131|     18|        return true;            // output was just cleared, so they match
  132|     18|    }
  133|  14.4k|    if (dest->allocation_size < source->size) {
  ------------------
  |  Branch (133:9): [True: 12.8k, False: 1.63k]
  ------------------
  134|  12.8k|        if (!realloc_array(dest, source->size)) {
  ------------------
  |  Branch (134:13): [True: 0, False: 12.8k]
  ------------------
  135|      0|            return false;
  136|      0|        }
  137|  12.8k|    }
  138|  14.4k|    dest->size = source->size;
  139|  14.4k|    memcpy(dest->keys, source->keys, dest->size * sizeof(uint16_t));
  140|       |    // we go through the containers, turning them into shared containers...
  141|  14.4k|    if (copy_on_write) {
  ------------------
  |  Branch (141:9): [True: 0, False: 14.4k]
  ------------------
  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.4k|    } else {
  152|  14.4k|        memcpy(dest->typecodes, source->typecodes,
  153|  14.4k|               dest->size * sizeof(uint8_t));
  154|   176k|        for (int32_t i = 0; i < dest->size; i++) {
  ------------------
  |  Branch (154:29): [True: 161k, False: 14.4k]
  ------------------
  155|   161k|            dest->containers[i] =
  156|   161k|                container_clone(source->containers[i], source->typecodes[i]);
  157|   161k|            if (dest->containers[i] == NULL) {
  ------------------
  |  Branch (157:17): [True: 0, False: 161k]
  ------------------
  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|   161k|        }
  165|  14.4k|    }
  166|  14.4k|    return true;
  167|  14.4k|}
ra_clear_containers:
  169|  78.9k|void ra_clear_containers(roaring_array_t *ra) {
  170|   554k|    for (int32_t i = 0; i < ra->size; ++i) {
  ------------------
  |  Branch (170:25): [True: 475k, False: 78.9k]
  ------------------
  171|   475k|        container_free(ra->containers[i], ra->typecodes[i]);
  172|   475k|    }
  173|  78.9k|}
ra_reset:
  175|  64.4k|void ra_reset(roaring_array_t *ra) {
  176|  64.4k|    ra_clear_containers(ra);
  177|  64.4k|    ra->size = 0;
  178|  64.4k|    ra_shrink_to_fit(ra);
  179|  64.4k|}
ra_clear_without_containers:
  181|     37|void ra_clear_without_containers(roaring_array_t *ra) {
  182|     37|    roaring_free(
  183|     37|        ra->containers);  // keys and typecodes are allocated with containers
  184|     37|    ra->size = 0;
  185|     37|    ra->allocation_size = 0;
  186|     37|    ra->containers = NULL;
  187|     37|    ra->keys = NULL;
  188|       |    ra->typecodes = NULL;
  189|     37|}
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|  87.6k|bool extend_array(roaring_array_t *ra, int32_t k) {
  197|  87.6k|    int32_t desired_size = ra->size + k;
  198|  87.6k|    const int32_t max_containers = 65536;
  199|  87.6k|    assert(desired_size <= max_containers);
  200|  87.6k|    if (desired_size > ra->allocation_size) {
  ------------------
  |  Branch (200:9): [True: 18.3k, False: 69.2k]
  ------------------
  201|  18.3k|        int32_t new_capacity =
  202|  18.3k|            (ra->size < 1024) ? 2 * desired_size : 5 * desired_size / 4;
  ------------------
  |  Branch (202:13): [True: 18.3k, False: 0]
  ------------------
  203|  18.3k|        if (new_capacity > max_containers) {
  ------------------
  |  Branch (203:13): [True: 0, False: 18.3k]
  ------------------
  204|      0|            new_capacity = max_containers;
  205|      0|        }
  206|       |
  207|  18.3k|        return realloc_array(ra, new_capacity);
  208|  18.3k|    }
  209|  69.2k|    return true;
  210|  87.6k|}
ra_append:
  213|  24.8k|               uint8_t typecode) {
  214|  24.8k|    extend_array(ra, 1);
  215|  24.8k|    const int32_t pos = ra->size;
  216|       |
  217|  24.8k|    ra->keys[pos] = key;
  218|  24.8k|    ra->containers[pos] = c;
  219|  24.8k|    ra->typecodes[pos] = typecode;
  220|  24.8k|    ra->size++;
  221|  24.8k|}
ra_append_copy_range:
  254|  28.1k|                          bool copy_on_write) {
  255|  28.1k|    extend_array(ra, end_index - start_index);
  256|   214k|    for (int32_t i = start_index; i < end_index; ++i) {
  ------------------
  |  Branch (256:35): [True: 186k, False: 28.1k]
  ------------------
  257|   186k|        const int32_t pos = ra->size;
  258|   186k|        ra->keys[pos] = sa->keys[i];
  259|   186k|        if (copy_on_write) {
  ------------------
  |  Branch (259:13): [True: 0, False: 186k]
  ------------------
  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|   186k|        } else {
  265|   186k|            ra->containers[pos] =
  266|   186k|                container_clone(sa->containers[i], sa->typecodes[i]);
  267|   186k|            ra->typecodes[pos] = sa->typecodes[i];
  268|   186k|        }
  269|   186k|        ra->size++;
  270|   186k|    }
  271|  28.1k|}
ra_advance_until_freeing:
  340|     60|int32_t ra_advance_until_freeing(roaring_array_t *ra, uint16_t x, int32_t pos) {
  341|    120|    while (pos < ra->size && ra->keys[pos] < x) {
  ------------------
  |  Branch (341:12): [True: 120, False: 0]
  |  Branch (341:30): [True: 60, False: 60]
  ------------------
  342|     60|        container_free(ra->containers[pos], ra->typecodes[pos]);
  343|     60|        ++pos;
  344|     60|    }
  345|     60|    return pos;
  346|     60|}
ra_insert_new_key_value_at:
  349|  33.2k|                                container_t *c, uint8_t typecode) {
  350|  33.2k|    extend_array(ra, 1);
  351|       |    // May be an optimization opportunity with DIY memmove
  352|  33.2k|    memmove(&(ra->keys[i + 1]), &(ra->keys[i]),
  353|  33.2k|            sizeof(uint16_t) * (ra->size - i));
  354|  33.2k|    memmove(&(ra->containers[i + 1]), &(ra->containers[i]),
  355|  33.2k|            sizeof(container_t *) * (ra->size - i));
  356|  33.2k|    memmove(&(ra->typecodes[i + 1]), &(ra->typecodes[i]),
  357|  33.2k|            sizeof(uint8_t) * (ra->size - i));
  358|  33.2k|    ra->keys[i] = key;
  359|  33.2k|    ra->containers[i] = c;
  360|  33.2k|    ra->typecodes[i] = typecode;
  361|  33.2k|    ra->size++;
  362|  33.2k|}
ra_downsize:
  369|  12.4k|void ra_downsize(roaring_array_t *ra, int32_t new_length) {
  370|       |    assert(new_length <= ra->size);
  371|  12.4k|    ra->size = new_length;
  372|  12.4k|}
ra_remove_at_index:
  374|  67.8k|void ra_remove_at_index(roaring_array_t *ra, int32_t i) {
  375|  67.8k|    memmove(&(ra->containers[i]), &(ra->containers[i + 1]),
  376|  67.8k|            sizeof(container_t *) * (ra->size - i - 1));
  377|  67.8k|    memmove(&(ra->keys[i]), &(ra->keys[i + 1]),
  378|  67.8k|            sizeof(uint16_t) * (ra->size - i - 1));
  379|  67.8k|    memmove(&(ra->typecodes[i]), &(ra->typecodes[i + 1]),
  380|  67.8k|            sizeof(uint8_t) * (ra->size - i - 1));
  381|  67.8k|    ra->size--;
  382|  67.8k|}
ra_remove_at_index_and_free:
  384|     67|void ra_remove_at_index_and_free(roaring_array_t *ra, int32_t i) {
  385|     67|    container_free(ra->containers[i], ra->typecodes[i]);
  386|     67|    ra_remove_at_index(ra, i);
  387|     67|}
ra_copy_range:
  395|     53|                   uint32_t new_begin) {
  396|     53|    assert(begin <= end);
  397|     53|    assert(new_begin < begin);
  398|       |
  399|     53|    const int range = end - begin;
  400|       |
  401|       |    // We ensure to previously have freed overwritten containers
  402|       |    // that are not copied elsewhere
  403|       |
  404|     53|    memmove(&(ra->containers[new_begin]), &(ra->containers[begin]),
  405|     53|            sizeof(container_t *) * range);
  406|     53|    memmove(&(ra->keys[new_begin]), &(ra->keys[begin]),
  407|     53|            sizeof(uint16_t) * range);
  408|     53|    memmove(&(ra->typecodes[new_begin]), &(ra->typecodes[begin]),
  409|     53|            sizeof(uint8_t) * range);
  410|     53|}
ra_shift_tail:
  412|  1.95k|void ra_shift_tail(roaring_array_t *ra, int32_t count, int32_t distance) {
  413|  1.95k|    if (distance > 0) {
  ------------------
  |  Branch (413:9): [True: 1.31k, False: 646]
  ------------------
  414|  1.31k|        extend_array(ra, distance);
  415|  1.31k|    }
  416|  1.95k|    int32_t srcpos = ra->size - count;
  417|  1.95k|    int32_t dstpos = srcpos + distance;
  418|  1.95k|    memmove(&(ra->keys[dstpos]), &(ra->keys[srcpos]), sizeof(uint16_t) * count);
  419|  1.95k|    memmove(&(ra->containers[dstpos]), &(ra->containers[srcpos]),
  420|  1.95k|            sizeof(container_t *) * count);
  421|  1.95k|    memmove(&(ra->typecodes[dstpos]), &(ra->typecodes[srcpos]),
  422|  1.95k|            sizeof(uint8_t) * count);
  423|  1.95k|    ra->size += distance;
  424|  1.95k|}
ra_to_uint32_array:
  426|  6.44k|void ra_to_uint32_array(const roaring_array_t *ra, uint32_t *ans) {
  427|  6.44k|    size_t ctr = 0;
  428|  74.9k|    for (int32_t i = 0; i < ra->size; ++i) {
  ------------------
  |  Branch (428:25): [True: 68.5k, False: 6.44k]
  ------------------
  429|  68.5k|        int num_added = container_to_uint32_array(
  430|  68.5k|            ans + ctr, ra->containers[i], ra->typecodes[i],
  431|  68.5k|            ((uint32_t)ra->keys[i]) << 16);
  432|  68.5k|        ctr += num_added;
  433|  68.5k|    }
  434|  6.44k|}
ra_has_run_container:
  436|  19.3k|bool ra_has_run_container(const roaring_array_t *ra) {
  437|   183k|    for (int32_t k = 0; k < ra->size; ++k) {
  ------------------
  |  Branch (437:25): [True: 166k, False: 16.7k]
  ------------------
  438|   166k|        if (get_container_type(ra->containers[k], ra->typecodes[k]) ==
  ------------------
  |  Branch (438:13): [True: 2.61k, False: 163k]
  ------------------
  439|   166k|            RUN_CONTAINER_TYPE)
  ------------------
  |  |   50|   166k|#define RUN_CONTAINER_TYPE 3
  ------------------
  440|  2.61k|            return true;
  441|   166k|    }
  442|  16.7k|    return false;
  443|  19.3k|}
ra_portable_header_size:
  445|  12.8k|uint32_t ra_portable_header_size(const roaring_array_t *ra) {
  446|  12.8k|    if (ra_has_run_container(ra)) {
  ------------------
  |  Branch (446:9): [True: 2.61k, False: 10.2k]
  ------------------
  447|  2.61k|        if (ra->size <
  ------------------
  |  Branch (447:13): [True: 2.61k, False: 0]
  ------------------
  448|  2.61k|            NO_OFFSET_THRESHOLD) {  // for small bitmaps, we omit the offsets
  449|  2.61k|            return 4 + (ra->size + 7) / 8 + 4 * ra->size;
  450|  2.61k|        }
  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.8k|}
ra_portable_size_in_bytes:
  458|  12.8k|size_t ra_portable_size_in_bytes(const roaring_array_t *ra) {
  459|  12.8k|    size_t count = ra_portable_header_size(ra);
  460|       |
  461|  99.3k|    for (int32_t k = 0; k < ra->size; ++k) {
  ------------------
  |  Branch (461:25): [True: 86.4k, False: 12.8k]
  ------------------
  462|  86.4k|        count += container_size_in_bytes(ra->containers[k], ra->typecodes[k]);
  463|  86.4k|    }
  464|  12.8k|    return count;
  465|  12.8k|}
ra_portable_serialize:
  469|  6.44k|size_t ra_portable_serialize(const roaring_array_t *ra, char *buf) {
  470|  6.44k|    char *initbuf = buf;
  471|  6.44k|    uint32_t startOffset = 0;
  472|  6.44k|    bool hasrun = ra_has_run_container(ra);
  473|  6.44k|    if (hasrun) {
  ------------------
  |  Branch (473:9): [True: 0, False: 6.44k]
  ------------------
  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.44k|    } else {  // backwards compatibility
  493|  6.44k|        uint32_t cookie = SERIAL_COOKIE_NO_RUNCONTAINER;
  494|  6.44k|        uint32_t cookie_le = croaring_htole32(cookie);
  ------------------
  |  |  518|  6.44k|#define croaring_htole32(x) (x)
  ------------------
  495|  6.44k|        memcpy(buf, &cookie_le, sizeof(cookie_le));
  496|  6.44k|        buf += sizeof(cookie_le);
  497|  6.44k|        uint32_t size_le = croaring_htole32((uint32_t)ra->size);
  ------------------
  |  |  518|  6.44k|#define croaring_htole32(x) (x)
  ------------------
  498|  6.44k|        memcpy(buf, &size_le, sizeof(size_le));
  499|  6.44k|        buf += sizeof(size_le);
  500|       |
  501|  6.44k|        startOffset = 4 + 4 + 4 * ra->size + 4 * ra->size;
  502|  6.44k|    }
  503|  86.4k|    for (int32_t k = 0; k < ra->size; ++k) {
  ------------------
  |  Branch (503:25): [True: 80.0k, False: 6.44k]
  ------------------
  504|  80.0k|        uint16_t key_le = croaring_htole16(ra->keys[k]);
  ------------------
  |  |  517|  80.0k|#define croaring_htole16(x) (x)
  ------------------
  505|  80.0k|        memcpy(buf, &key_le, sizeof(key_le));
  506|  80.0k|        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|  80.0k|        uint16_t card = (uint16_t)(container_get_cardinality(ra->containers[k],
  510|  80.0k|                                                             ra->typecodes[k]) -
  511|  80.0k|                                   1);
  512|  80.0k|        uint16_t card_le = croaring_htole16(card);
  ------------------
  |  |  517|  80.0k|#define croaring_htole16(x) (x)
  ------------------
  513|  80.0k|        memcpy(buf, &card_le, sizeof(card_le));
  514|  80.0k|        buf += sizeof(card_le);
  515|  80.0k|    }
  516|  6.44k|    if ((!hasrun) || (ra->size >= NO_OFFSET_THRESHOLD)) {
  ------------------
  |  Branch (516:9): [True: 6.44k, False: 0]
  |  Branch (516:22): [True: 0, False: 0]
  ------------------
  517|       |        // writing the containers offsets
  518|  86.4k|        for (int32_t k = 0; k < ra->size; k++) {
  ------------------
  |  Branch (518:29): [True: 80.0k, False: 6.44k]
  ------------------
  519|  80.0k|            uint32_t off_le = croaring_htole32(startOffset);
  ------------------
  |  |  518|  80.0k|#define croaring_htole32(x) (x)
  ------------------
  520|  80.0k|            memcpy(buf, &off_le, sizeof(off_le));
  521|  80.0k|            buf += sizeof(off_le);
  522|  80.0k|            startOffset =
  523|  80.0k|                startOffset +
  524|  80.0k|                container_size_in_bytes(ra->containers[k], ra->typecodes[k]);
  525|  80.0k|        }
  526|  6.44k|    }
  527|  86.4k|    for (int32_t k = 0; k < ra->size; ++k) {
  ------------------
  |  Branch (527:25): [True: 80.0k, False: 6.44k]
  ------------------
  528|  80.0k|        buf += container_write(ra->containers[k], ra->typecodes[k], buf);
  529|  80.0k|    }
  530|  6.44k|    return buf - initbuf;
  531|  6.44k|}
ra_portable_deserialize:
  634|  12.8k|                             const size_t maxbytes, size_t *readbytes) {
  635|  12.8k|    *readbytes = sizeof(int32_t);  // for cookie
  636|  12.8k|    if (*readbytes > maxbytes) {
  ------------------
  |  Branch (636:9): [True: 6.07k, False: 6.80k]
  ------------------
  637|       |        // Ran out of bytes while reading first 4 bytes.
  638|  6.07k|        return false;
  639|  6.07k|    }
  640|  6.80k|    uint32_t cookie;
  641|  6.80k|    memcpy(&cookie, buf, sizeof(int32_t));
  642|  6.80k|    cookie = croaring_letoh32(cookie);
  ------------------
  |  |  524|  6.80k|#define croaring_letoh32(x) croaring_htole32(x)
  |  |  ------------------
  |  |  |  |  518|  6.80k|#define croaring_htole32(x) (x)
  |  |  ------------------
  ------------------
  643|  6.80k|    buf += sizeof(uint32_t);
  644|  6.80k|    if ((cookie & 0xFFFF) != SERIAL_COOKIE &&
  ------------------
  |  Branch (644:9): [True: 6.75k, False: 48]
  ------------------
  645|  6.75k|        cookie != SERIAL_COOKIE_NO_RUNCONTAINER) {
  ------------------
  |  Branch (645:9): [True: 256, False: 6.50k]
  ------------------
  646|       |        // "I failed to find one of the right cookies.
  647|    256|        return false;
  648|    256|    }
  649|  6.55k|    int32_t size;
  650|       |
  651|  6.55k|    if ((cookie & 0xFFFF) == SERIAL_COOKIE)
  ------------------
  |  Branch (651:9): [True: 48, False: 6.50k]
  ------------------
  652|     48|        size = (cookie >> 16) + 1;
  653|  6.50k|    else {
  654|  6.50k|        *readbytes += sizeof(int32_t);
  655|  6.50k|        if (*readbytes > maxbytes) {
  ------------------
  |  Branch (655:13): [True: 3, False: 6.49k]
  ------------------
  656|       |            // Ran out of bytes while reading second part of the cookie.
  657|      3|            return false;
  658|      3|        }
  659|  6.49k|        uint32_t size_le;
  660|  6.49k|        memcpy(&size_le, buf, sizeof(int32_t));
  661|  6.49k|        size = (int32_t)croaring_letoh32(size_le);
  ------------------
  |  |  524|  6.49k|#define croaring_letoh32(x) croaring_htole32(x)
  |  |  ------------------
  |  |  |  |  518|  6.49k|#define croaring_htole32(x) (x)
  |  |  ------------------
  ------------------
  662|  6.49k|        buf += sizeof(uint32_t);
  663|  6.49k|    }
  664|  6.54k|    if (size < 0) {
  ------------------
  |  Branch (664:9): [True: 22, False: 6.52k]
  ------------------
  665|       |        // You cannot have a negative number of containers, the data must be
  666|       |        // corrupted.
  667|     22|        return false;
  668|     22|    }
  669|  6.52k|    if (size > (1 << 16)) {
  ------------------
  |  Branch (669:9): [True: 18, False: 6.50k]
  ------------------
  670|       |        // You cannot have so many containers, the data must be corrupted.
  671|     18|        return false;
  672|     18|    }
  673|  6.50k|    const char *bitmapOfRunContainers = NULL;
  674|  6.50k|    bool hasrun = (cookie & 0xFFFF) == SERIAL_COOKIE;
  675|  6.50k|    if (hasrun) {
  ------------------
  |  Branch (675:9): [True: 48, False: 6.45k]
  ------------------
  676|     48|        int32_t s = (size + 7) / 8;
  677|     48|        *readbytes += s;
  678|     48|        if (*readbytes > maxbytes) {  // data is corrupted?
  ------------------
  |  Branch (678:13): [True: 1, False: 47]
  ------------------
  679|       |            // Ran out of bytes while reading run bitmap.
  680|      1|            return false;
  681|      1|        }
  682|     47|        bitmapOfRunContainers = buf;
  683|     47|        buf += s;
  684|     47|    }
  685|  6.50k|    const char *keyscards = buf;
  686|       |
  687|  6.50k|    *readbytes += size * 2 * sizeof(uint16_t);
  688|  6.50k|    if (*readbytes > maxbytes) {
  ------------------
  |  Branch (688:9): [True: 15, False: 6.49k]
  ------------------
  689|       |        // Ran out of bytes while reading key-cardinality array.
  690|     15|        return false;
  691|     15|    }
  692|  6.49k|    buf += size * 2 * sizeof(uint16_t);
  693|       |
  694|  6.49k|    bool is_ok = ra_init_with_capacity(answer, size);
  695|  6.49k|    if (!is_ok) {
  ------------------
  |  Branch (695:9): [True: 0, False: 6.49k]
  ------------------
  696|       |        // Failed to allocate memory for roaring array. Bailing out.
  697|      0|        return false;
  698|      0|    }
  699|       |
  700|  86.7k|    for (int32_t k = 0; k < size; ++k) {
  ------------------
  |  Branch (700:25): [True: 80.2k, False: 6.49k]
  ------------------
  701|  80.2k|        uint16_t tmp;
  702|  80.2k|        memcpy(&tmp, keyscards + 4 * k, sizeof(tmp));
  703|  80.2k|        answer->keys[k] = croaring_letoh16(tmp);
  ------------------
  |  |  523|  80.2k|#define croaring_letoh16(x) croaring_htole16(x)
  |  |  ------------------
  |  |  |  |  517|  80.2k|#define croaring_htole16(x) (x)
  |  |  ------------------
  ------------------
  704|  80.2k|    }
  705|  6.49k|    if ((!hasrun) || (size >= NO_OFFSET_THRESHOLD)) {
  ------------------
  |  Branch (705:9): [True: 6.44k, False: 46]
  |  Branch (705:22): [True: 19, False: 27]
  ------------------
  706|  6.46k|        *readbytes += size * 4;
  707|  6.46k|        if (*readbytes > maxbytes) {  // data is corrupted?
  ------------------
  |  Branch (707:13): [True: 5, False: 6.45k]
  ------------------
  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.45k|        buf += size * 4;
  716|  6.45k|    }
  717|       |    // Reading the containers
  718|  86.6k|    for (int32_t k = 0; k < size; ++k) {
  ------------------
  |  Branch (718:25): [True: 80.1k, False: 6.45k]
  ------------------
  719|  80.1k|        uint16_t tmp;
  720|  80.1k|        memcpy(&tmp, keyscards + 4 * k + 2, sizeof(tmp));
  721|  80.1k|        tmp = croaring_letoh16(tmp);
  ------------------
  |  |  523|  80.1k|#define croaring_letoh16(x) croaring_htole16(x)
  |  |  ------------------
  |  |  |  |  517|  80.1k|#define croaring_htole16(x) (x)
  |  |  ------------------
  ------------------
  722|  80.1k|        uint32_t thiscard = tmp + 1;
  723|  80.1k|        bool isbitmap = (thiscard > DEFAULT_MAX_SIZE);
  724|  80.1k|        bool isrun = false;
  725|  80.1k|        if (hasrun) {
  ------------------
  |  Branch (725:13): [True: 135, False: 80.0k]
  ------------------
  726|    135|            if ((bitmapOfRunContainers[k / 8] & (1 << (k % 8))) != 0) {
  ------------------
  |  Branch (726:17): [True: 77, False: 58]
  ------------------
  727|     77|                isbitmap = false;
  728|     77|                isrun = true;
  729|     77|            }
  730|    135|        }
  731|  80.1k|        if (isbitmap) {
  ------------------
  |  Branch (731:13): [True: 72.9k, False: 7.25k]
  ------------------
  732|       |            // we check that the read is allowed
  733|  72.9k|            size_t containersize =
  734|  72.9k|                BITSET_CONTAINER_SIZE_IN_WORDS * sizeof(uint64_t);
  735|  72.9k|            *readbytes += containersize;
  736|  72.9k|            if (*readbytes > maxbytes) {
  ------------------
  |  Branch (736:17): [True: 7, False: 72.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|  72.9k|            bitset_container_t *c = bitset_container_create();
  744|  72.9k|            if (c == NULL) {  // memory allocation failure
  ------------------
  |  Branch (744:17): [True: 0, False: 72.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|  72.9k|            answer->size++;
  751|  72.9k|            buf += bitset_container_read(thiscard, c, buf);
  752|  72.9k|            answer->containers[k] = c;
  753|  72.9k|            answer->typecodes[k] = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|  72.9k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  754|  72.9k|        } else if (isrun) {
  ------------------
  |  Branch (754:20): [True: 77, False: 7.17k]
  ------------------
  755|       |            // we check that the read is allowed
  756|     77|            *readbytes += sizeof(uint16_t);
  757|     77|            if (*readbytes > maxbytes) {
  ------------------
  |  Branch (757:17): [True: 10, False: 67]
  ------------------
  758|       |                // Running out of bytes while reading a run container (header).
  759|     10|                ra_clear(answer);  // we need to clear the containers already
  760|       |                                   // allocated, and the roaring array
  761|     10|                return false;
  762|     10|            }
  763|     67|            uint16_t n_runs;
  764|     67|            memcpy(&n_runs, buf, sizeof(uint16_t));
  765|     67|            n_runs = croaring_letoh16(n_runs);
  ------------------
  |  |  523|     67|#define croaring_letoh16(x) croaring_htole16(x)
  |  |  ------------------
  |  |  |  |  517|     67|#define croaring_htole16(x) (x)
  |  |  ------------------
  ------------------
  766|     67|            size_t containersize = n_runs * sizeof(rle16_t);
  767|     67|            *readbytes += containersize;
  768|     67|            if (*readbytes > maxbytes) {  // data is corrupted?
  ------------------
  |  Branch (768:17): [True: 7, False: 60]
  ------------------
  769|       |                // Running out of bytes while reading a run container.
  770|      7|                ra_clear(answer);  // we need to clear the containers already
  771|       |                                   // allocated, and the roaring array
  772|      7|                return false;
  773|      7|            }
  774|       |            // it is now safe to read
  775|       |
  776|     60|            run_container_t *c = run_container_create();
  777|     60|            if (c == NULL) {  // memory allocation failure
  ------------------
  |  Branch (777:17): [True: 0, False: 60]
  ------------------
  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|     60|            answer->size++;
  784|     60|            buf += run_container_read(thiscard, c, buf);
  785|     60|            answer->containers[k] = c;
  786|     60|            answer->typecodes[k] = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|     60|#define RUN_CONTAINER_TYPE 3
  ------------------
  787|  7.17k|        } else {
  788|       |            // we check that the read is allowed
  789|  7.17k|            size_t containersize = thiscard * sizeof(uint16_t);
  790|  7.17k|            *readbytes += containersize;
  791|  7.17k|            if (*readbytes > maxbytes) {  // data is corrupted?
  ------------------
  |  Branch (791:17): [True: 8, False: 7.16k]
  ------------------
  792|       |                // Running out of bytes while reading an array container.
  793|      8|                ra_clear(answer);  // we need to clear the containers already
  794|       |                                   // allocated, and the roaring array
  795|      8|                return false;
  796|      8|            }
  797|       |            // it is now safe to read
  798|  7.16k|            array_container_t *c =
  799|  7.16k|                array_container_create_given_capacity(thiscard);
  800|  7.16k|            if (c == NULL) {  // memory allocation failure
  ------------------
  |  Branch (800:17): [True: 0, False: 7.16k]
  ------------------
  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.16k|            answer->size++;
  807|  7.16k|            buf += array_container_read(thiscard, c, buf);
  808|  7.16k|            answer->containers[k] = c;
  809|  7.16k|            answer->typecodes[k] = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  7.16k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  810|  7.16k|        }
  811|  80.1k|    }
  812|  6.45k|    return true;
  813|  6.48k|}
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.4k, False: 37.6k]
  ------------------
   49|  64.4k|        roaring_free(ra->containers);
   50|  64.4k|        ra->containers = NULL;
   51|  64.4k|        ra->keys = NULL;
   52|  64.4k|        ra->typecodes = NULL;
   53|  64.4k|        ra->allocation_size = 0;
   54|  64.4k|        return true;
   55|  64.4k|    }
   56|  37.6k|    const size_t memoryneeded =
   57|  37.6k|        new_capacity *
   58|  37.6k|        (sizeof(uint16_t) + sizeof(container_t *) + sizeof(uint8_t));
   59|  37.6k|    void *bigalloc = roaring_malloc(memoryneeded);
   60|  37.6k|    if (!bigalloc) return false;
  ------------------
  |  Branch (60:9): [True: 0, False: 37.6k]
  ------------------
   61|  37.6k|    void *oldbigalloc = ra->containers;
   62|  37.6k|    container_t **newcontainers = (container_t **)bigalloc;
   63|  37.6k|    uint16_t *newkeys = (uint16_t *)(newcontainers + new_capacity);
   64|  37.6k|    uint8_t *newtypecodes = (uint8_t *)(newkeys + new_capacity);
   65|  37.6k|    assert((char *)(newtypecodes + new_capacity) ==
   66|  37.6k|           (char *)bigalloc + memoryneeded);
   67|  37.6k|    if (ra->size > 0) {
  ------------------
  |  Branch (67:9): [True: 11.8k, False: 25.7k]
  ------------------
   68|  11.8k|        memcpy(newcontainers, ra->containers, sizeof(container_t *) * ra->size);
   69|  11.8k|        memcpy(newkeys, ra->keys, sizeof(uint16_t) * ra->size);
   70|  11.8k|        memcpy(newtypecodes, ra->typecodes, sizeof(uint8_t) * ra->size);
   71|  11.8k|    }
   72|  37.6k|    ra->containers = newcontainers;
   73|  37.6k|    ra->keys = newkeys;
   74|  37.6k|    ra->typecodes = newtypecodes;
   75|  37.6k|    ra->allocation_size = new_capacity;
   76|  37.6k|    roaring_free(oldbigalloc);
   77|       |    return true;
   78|  37.6k|}

_Z17ConsumeVecInRangeR18FuzzedDataProvidermjj:
   24|  12.8k|                                        uint32_t max_value) {
   25|  12.8k|    std::vector<uint32_t> result = {0};
   26|  12.8k|    result.resize(length);
   27|  12.8k|    std::generate(result.begin(), result.end(), [&]() {
   28|  12.8k|        return fdp.ConsumeIntegralInRange<uint32_t>(min_value, max_value);
   29|  12.8k|    });
   30|  12.8k|    return result;
   31|  12.8k|}
LLVMFuzzerTestOneInput:
   33|  6.44k|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.44k|    uint32_t range_start = 0;
   53|  6.44k|    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.44k|    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.44k|    std::vector<uint32_t> bitmap_data_a = ConsumeVecInRange(fdp, 500, 0, 1000);
   68|  6.44k|    roaring::Roaring a(bitmap_data_a.size(), bitmap_data_a.data());
   69|  6.44k|    a.runOptimize();
   70|  6.44k|    a.shrinkToFit();
   71|       |
   72|  6.44k|    std::vector<uint32_t> bitmap_data_b = ConsumeVecInRange(fdp, 500, 0, 1000);
   73|  6.44k|    roaring::Roaring b(bitmap_data_b.size(), bitmap_data_b.data());
   74|  6.44k|    b.runOptimize();
   75|  6.44k|    b.add(fdp.ConsumeIntegralInRange<uint32_t>(range_start, range_end));
   76|  6.44k|    b.addChecked(fdp.ConsumeIntegralInRange<uint32_t>(range_start, range_end));
   77|  6.44k|    b.addRange(fdp.ConsumeIntegralInRange<uint32_t>(range_start, range_end),
   78|  6.44k|               fdp.ConsumeIntegralInRange<uint32_t>(range_start, range_end));
   79|       |    // add half of a to b.
   80|  6.44k|    b.addMany(bitmap_data_a.size() / 2, bitmap_data_a.data());
   81|  6.44k|    b.remove(fdp.ConsumeIntegralInRange<uint32_t>(range_start, range_end));
   82|  6.44k|    b.removeChecked(
   83|  6.44k|        fdp.ConsumeIntegralInRange<uint32_t>(range_start, range_end));
   84|  6.44k|    b.removeRange(fdp.ConsumeIntegralInRange<uint32_t>(range_start, range_end),
   85|  6.44k|                  fdp.ConsumeIntegralInRange<uint32_t>(range_start, range_end));
   86|  6.44k|    b.removeRangeClosed(
   87|  6.44k|        fdp.ConsumeIntegralInRange<uint32_t>(range_start, range_end),
   88|  6.44k|        fdp.ConsumeIntegralInRange<uint32_t>(range_start, range_end));
   89|  6.44k|    b.maximum();
   90|  6.44k|    b.minimum();
   91|  6.44k|    b.contains(fdp.ConsumeIntegralInRange<uint32_t>(range_start, range_end));
   92|  6.44k|    b.containsRange(
   93|  6.44k|        fdp.ConsumeIntegralInRange<uint32_t>(range_start, range_end),
   94|  6.44k|        fdp.ConsumeIntegralInRange<uint32_t>(range_start, range_end));
   95|       |
   96|  6.44k|    uint32_t element = 0;
   97|  6.44k|    a.select(fdp.ConsumeIntegralInRange<uint32_t>(0, 1000), &element);
   98|  6.44k|    a.intersect(b);
   99|  6.44k|    a.jaccard_index(b);
  100|  6.44k|    a.or_cardinality(b);
  101|  6.44k|    a.andnot_cardinality(b);
  102|  6.44k|    a.xor_cardinality(b);
  103|  6.44k|    a.rank(fdp.ConsumeIntegralInRange<uint32_t>(0, 5000));
  104|  6.44k|    a.getSizeInBytes();
  105|       |
  106|  6.44k|    roaring::Roaring c = a & b;
  107|  6.44k|    roaring::Roaring d = a - b;
  108|  6.44k|    roaring::Roaring e = a | b;
  109|  6.44k|    roaring::Roaring f = a ^ b;
  110|  6.44k|    a |= e;
  111|  6.44k|    a &= b;
  112|  6.44k|    a -= c;
  113|  6.44k|    a ^= f;
  114|       |
  115|  6.44k|    volatile bool is_equal = (a == b);
  116|       |
  117|  6.44k|    std::vector<uint32_t> b_as_array = {0};
  118|  6.44k|    b_as_array.resize(b.cardinality());
  119|  6.44k|    b.isEmpty();
  120|  6.44k|    b.toUint32Array(b_as_array.data());
  121|       |
  122|  6.44k|    a.isSubset(b);
  123|  6.44k|    a.isStrictSubset(b);
  124|  6.44k|    b.flip(fdp.ConsumeIntegralInRange<uint32_t>(range_start, range_end),
  125|  6.44k|           fdp.ConsumeIntegralInRange<uint32_t>(range_start, range_end));
  126|  6.44k|    b.flipClosed(fdp.ConsumeIntegralInRange<uint32_t>(range_start, range_end),
  127|  6.44k|                 fdp.ConsumeIntegralInRange<uint32_t>(range_start, range_end));
  128|  6.44k|    b.removeRunCompression();
  129|       |
  130|       |    // Move/copy constructors
  131|  6.44k|    roaring::Roaring copied = b;
  132|  6.44k|    roaring::Roaring moved = std::move(b);
  133|       |
  134|       |    // Asignment operators
  135|  6.44k|    b = copied;
  136|  6.44k|    b = std::move(moved);
  137|       |
  138|       |    // Safe read from serialized
  139|  6.44k|    std::vector<char> read_buffer = fdp.ConsumeBytes<char>(100);
  140|  6.44k|    try {
  141|  6.44k|        roaring::Roaring read_safely =
  142|  6.44k|            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.44k|    } catch (...) {
  147|  6.42k|    }
  148|       |
  149|       |    // The bitmap b can be serialized and re-read.
  150|  6.44k|    std::size_t expected_size_in_bytes = b.getSizeInBytes();
  151|  6.44k|    std::vector<char> buffer(expected_size_in_bytes);
  152|  6.44k|    std::size_t size_in_bytes = b.write(buffer.data());
  153|  6.44k|    assert(expected_size_in_bytes == size_in_bytes);
  ------------------
  |  Branch (153:5): [True: 6.44k, False: 0]
  ------------------
  154|  6.44k|    roaring::Roaring bread =
  155|  6.44k|        roaring::Roaring::readSafe(buffer.data(), size_in_bytes);
  156|  6.44k|    assert(bread == b);
  ------------------
  |  Branch (156:5): [True: 6.44k, False: 0]
  ------------------
  157|       |
  158|  6.44k|    f.toString();
  159|       |
  160|  6.44k|    volatile int unused = 0;
  161|       |
  162|   340k|    for (roaring::Roaring::const_iterator i = a.begin(); i != a.end(); i++) {
  ------------------
  |  Branch (162:58): [True: 333k, False: 6.44k]
  ------------------
  163|   333k|        unused++;
  164|   333k|    }
  165|       |
  166|  6.44k|    roaring::Roaring::const_iterator b_iter = b.begin();
  167|  6.44k|    b_iter.equalorlarger(
  168|  6.44k|        fdp.ConsumeIntegralInRange<uint32_t>(range_start, range_end));
  169|       |
  170|  6.44k|    return 0;
  171|  6.44k|}
croaring_fuzzer_cc.cc:_ZZ17ConsumeVecInRangeR18FuzzedDataProvidermjjENK3$_0clEv:
   27|  6.44M|    std::generate(result.begin(), result.end(), [&]() {
   28|  6.44M|        return fdp.ConsumeIntegralInRange<uint32_t>(min_value, max_value);
   29|  6.44M|    });

