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

binarySearch:
   52|  7.23M|                            uint16_t ikey) {
   53|  7.23M|    const int32_t gap = 16;
   54|  7.23M|    if (lenarray < gap) {
  ------------------
  |  Branch (54:9): [True: 2.81M, False: 4.42M]
  ------------------
   55|  4.35M|        for (int32_t j = 0; j < lenarray; j++) {
  ------------------
  |  Branch (55:29): [True: 4.34M, False: 7.19k]
  ------------------
   56|  4.34M|            if (array[j] >= ikey) {
  ------------------
  |  Branch (56:17): [True: 2.80M, False: 1.53M]
  ------------------
   57|  2.80M|                return (array[j] == ikey) ? j : -(j + 1);
  ------------------
  |  Branch (57:24): [True: 2.65M, False: 149k]
  ------------------
   58|  2.80M|            }
   59|  4.34M|        }
   60|  7.19k|        return -(lenarray + 1);
   61|  2.81M|    }
   62|  4.42M|    const int32_t num_blocks = lenarray / gap;
   63|  4.42M|    int32_t base = 0;
   64|  4.42M|    int32_t n = num_blocks;
   65|  8.95M|    while (n > 3) {
  ------------------
  |  Branch (65:12): [True: 4.53M, False: 4.42M]
  ------------------
   66|  4.53M|        int32_t quarter = n >> 2;
   67|       |
   68|  4.53M|        int32_t k1 = array[(base + quarter + 1) * gap - 1];
   69|  4.53M|        int32_t k2 = array[(base + 2 * quarter + 1) * gap - 1];
   70|  4.53M|        int32_t k3 = array[(base + 3 * quarter + 1) * gap - 1];
   71|       |
   72|  4.53M|        int32_t c1 = (k1 < ikey);
   73|  4.53M|        int32_t c2 = (k2 < ikey);
   74|  4.53M|        int32_t c3 = (k3 < ikey);
   75|       |
   76|  4.53M|        base += (c1 + c2 + c3) * quarter;
   77|  4.53M|        n -= 3 * quarter;
   78|  4.53M|    }
   79|  8.21M|    while (n > 1) {
  ------------------
  |  Branch (79:12): [True: 3.79M, False: 4.42M]
  ------------------
   80|  3.79M|        int32_t half = n >> 1;
   81|  3.79M|        base = (array[(base + half + 1) * gap - 1] < ikey) ? base + half : base;
  ------------------
  |  Branch (81:16): [True: 534k, False: 3.25M]
  ------------------
   82|  3.79M|        n -= half;
   83|  3.79M|    }
   84|  4.42M|    int32_t lo = (array[(base + 1) * gap - 1] < ikey) ? base + 1 : base;
  ------------------
  |  Branch (84:18): [True: 2.07M, False: 2.34M]
  ------------------
   85|       |
   86|  4.42M|    if (lo < num_blocks) {
  ------------------
  |  Branch (86:9): [True: 4.10M, False: 318k]
  ------------------
   87|  4.10M|        const int32_t start = lo * gap;
   88|  4.10M|#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.10M|        __m128i needle = _mm_set1_epi16((short)ikey);
   95|  4.10M|        __m128i zero = _mm_setzero_si128();
   96|  4.10M|        __m128i v0 = _mm_loadu_si128((const __m128i *)(array + start));
   97|  4.10M|        __m128i ge0 = _mm_cmpeq_epi16(_mm_subs_epu16(needle, v0), zero);
   98|  4.10M|        unsigned m0 = (unsigned)_mm_movemask_epi8(ge0);
   99|  4.10M|        if (m0 != 0) {
  ------------------
  |  Branch (99:13): [True: 2.92M, False: 1.17M]
  ------------------
  100|  2.92M|            int32_t j = start + (int32_t)(roaring_trailing_zeroes(m0) >> 1);
  101|  2.92M|            return (array[j] == ikey) ? j : -(j + 1);
  ------------------
  |  Branch (101:20): [True: 2.16M, False: 762k]
  ------------------
  102|  2.92M|        }
  103|  1.17M|        __m128i v1 = _mm_loadu_si128((const __m128i *)(array + start + 8));
  104|  1.17M|        __m128i ge1 = _mm_cmpeq_epi16(_mm_subs_epu16(needle, v1), zero);
  105|  1.17M|        unsigned m1 = (unsigned)_mm_movemask_epi8(ge1);
  106|  1.17M|        int32_t j = start + 8 + (int32_t)(roaring_trailing_zeroes(m1) >> 1);
  107|  1.17M|        return (array[j] == ikey) ? j : -(j + 1);
  ------------------
  |  Branch (107:16): [True: 499k, False: 680k]
  ------------------
  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.10M|    }
  120|       |
  121|  1.84M|    for (int32_t j = num_blocks * gap; j < lenarray; j++) {
  ------------------
  |  Branch (121:40): [True: 1.83M, False: 10.5k]
  ------------------
  122|  1.83M|        if (array[j] >= ikey) {
  ------------------
  |  Branch (122:13): [True: 307k, False: 1.53M]
  ------------------
  123|   307k|            return (array[j] == ikey) ? j : -(j + 1);
  ------------------
  |  Branch (123:20): [True: 172k, False: 135k]
  ------------------
  124|   307k|        }
  125|  1.83M|    }
  126|  10.5k|    return -(lenarray + 1);
  127|   318k|}
roaring.c:advanceUntil:
  137|    567|                                   int32_t length, uint16_t min) {
  138|    567|    int32_t lower = pos + 1;
  139|       |
  140|    567|    if ((lower >= length) || (array[lower] >= min)) {
  ------------------
  |  Branch (140:9): [True: 567, False: 0]
  |  Branch (140:30): [True: 0, False: 0]
  ------------------
  141|    567|        return lower;
  142|    567|    }
  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.02k|                                    uint16_t ikey) {
  198|  9.02k|    if (lenarray == 0) return 0;
  ------------------
  |  Branch (198:9): [True: 0, False: 9.02k]
  ------------------
  199|  9.02k|    int32_t pos = binarySearch(array, lenarray, ikey);
  200|  9.02k|    if (pos >= 0) {
  ------------------
  |  Branch (200:9): [True: 1.94k, False: 7.07k]
  ------------------
  201|  1.94k|        return lenarray - (pos + 1);
  202|  7.07k|    } else {
  203|  7.07k|        return lenarray - (-pos - 1);
  204|  7.07k|    }
  205|  9.02k|}
roaring.c:count_less:
  186|  15.5k|                                 uint16_t ikey) {
  187|  15.5k|    if (lenarray == 0) return 0;
  ------------------
  |  Branch (187:9): [True: 3.03k, False: 12.4k]
  ------------------
  188|  12.4k|    int32_t pos = binarySearch(array, lenarray, ikey);
  189|  12.4k|    return pos >= 0 ? pos : -(pos + 1);
  ------------------
  |  Branch (189:12): [True: 9.55k, False: 2.91k]
  ------------------
  190|  15.5k|}
array_util.c:advanceUntil:
  137|  19.0k|                                   int32_t length, uint16_t min) {
  138|  19.0k|    int32_t lower = pos + 1;
  139|       |
  140|  19.0k|    if ((lower >= length) || (array[lower] >= min)) {
  ------------------
  |  Branch (140:9): [True: 21, False: 18.9k]
  |  Branch (140:30): [True: 5.63k, False: 13.3k]
  ------------------
  141|  5.66k|        return lower;
  142|  5.66k|    }
  143|       |
  144|  13.3k|    int32_t spansize = 1;
  145|       |
  146|  57.1k|    while ((lower + spansize < length) && (array[lower + spansize] < min)) {
  ------------------
  |  Branch (146:12): [True: 55.7k, False: 1.44k]
  |  Branch (146:43): [True: 43.8k, False: 11.8k]
  ------------------
  147|  43.8k|        spansize <<= 1;
  148|  43.8k|    }
  149|  13.3k|    int32_t upper = (lower + spansize < length) ? lower + spansize : length - 1;
  ------------------
  |  Branch (149:21): [True: 11.8k, False: 1.44k]
  ------------------
  150|       |
  151|  13.3k|    if (array[upper] == min) {
  ------------------
  |  Branch (151:9): [True: 3.43k, False: 9.90k]
  ------------------
  152|  3.43k|        return upper;
  153|  3.43k|    }
  154|  9.90k|    if (array[upper] < min) {
  ------------------
  |  Branch (154:9): [True: 232, False: 9.67k]
  ------------------
  155|       |        // means
  156|       |        // array
  157|       |        // has no
  158|       |        // item
  159|       |        // >= min
  160|       |        // pos = array.length;
  161|    232|        return length;
  162|    232|    }
  163|       |
  164|       |    // we know that the next-smallest span was too small
  165|  9.67k|    lower += (spansize >> 1);
  166|       |
  167|  9.67k|    int32_t mid = 0;
  168|  29.8k|    while (lower + 1 != upper) {
  ------------------
  |  Branch (168:12): [True: 25.4k, False: 4.43k]
  ------------------
  169|  25.4k|        mid = (lower + upper) >> 1;
  170|  25.4k|        if (array[mid] == min) {
  ------------------
  |  Branch (170:13): [True: 5.23k, False: 20.2k]
  ------------------
  171|  5.23k|            return mid;
  172|  20.2k|        } else if (array[mid] < min) {
  ------------------
  |  Branch (172:20): [True: 9.92k, False: 10.2k]
  ------------------
  173|  9.92k|            lower = mid;
  174|  10.2k|        } else {
  175|  10.2k|            upper = mid;
  176|  10.2k|        }
  177|  25.4k|    }
  178|  4.43k|    return upper;
  179|  9.67k|}
mixed_intersection.c:advanceUntil:
  137|   140k|                                   int32_t length, uint16_t min) {
  138|   140k|    int32_t lower = pos + 1;
  139|       |
  140|   140k|    if ((lower >= length) || (array[lower] >= min)) {
  ------------------
  |  Branch (140:9): [True: 473, False: 139k]
  |  Branch (140:30): [True: 79.9k, False: 59.8k]
  ------------------
  141|  80.4k|        return lower;
  142|  80.4k|    }
  143|       |
  144|  59.8k|    int32_t spansize = 1;
  145|       |
  146|   141k|    while ((lower + spansize < length) && (array[lower + spansize] < min)) {
  ------------------
  |  Branch (146:12): [True: 140k, False: 1.29k]
  |  Branch (146:43): [True: 81.6k, False: 58.5k]
  ------------------
  147|  81.6k|        spansize <<= 1;
  148|  81.6k|    }
  149|  59.8k|    int32_t upper = (lower + spansize < length) ? lower + spansize : length - 1;
  ------------------
  |  Branch (149:21): [True: 58.5k, False: 1.29k]
  ------------------
  150|       |
  151|  59.8k|    if (array[upper] == min) {
  ------------------
  |  Branch (151:9): [True: 29.4k, False: 30.3k]
  ------------------
  152|  29.4k|        return upper;
  153|  29.4k|    }
  154|  30.3k|    if (array[upper] < min) {
  ------------------
  |  Branch (154:9): [True: 596, False: 29.7k]
  ------------------
  155|       |        // means
  156|       |        // array
  157|       |        // has no
  158|       |        // item
  159|       |        // >= min
  160|       |        // pos = array.length;
  161|    596|        return length;
  162|    596|    }
  163|       |
  164|       |    // we know that the next-smallest span was too small
  165|  29.7k|    lower += (spansize >> 1);
  166|       |
  167|  29.7k|    int32_t mid = 0;
  168|  52.0k|    while (lower + 1 != upper) {
  ------------------
  |  Branch (168:12): [True: 35.6k, False: 16.4k]
  ------------------
  169|  35.6k|        mid = (lower + upper) >> 1;
  170|  35.6k|        if (array[mid] == min) {
  ------------------
  |  Branch (170:13): [True: 13.3k, False: 22.2k]
  ------------------
  171|  13.3k|            return mid;
  172|  22.2k|        } else if (array[mid] < min) {
  ------------------
  |  Branch (172:20): [True: 7.99k, False: 14.2k]
  ------------------
  173|  7.99k|            lower = mid;
  174|  14.2k|        } else {
  175|  14.2k|            upper = mid;
  176|  14.2k|        }
  177|  35.6k|    }
  178|  16.4k|    return upper;
  179|  29.7k|}
mixed_subset.c:advanceUntil:
  137|    460|                                   int32_t length, uint16_t min) {
  138|    460|    int32_t lower = pos + 1;
  139|       |
  140|    460|    if ((lower >= length) || (array[lower] >= min)) {
  ------------------
  |  Branch (140:9): [True: 0, False: 460]
  |  Branch (140:30): [True: 250, False: 210]
  ------------------
  141|    250|        return lower;
  142|    250|    }
  143|       |
  144|    210|    int32_t spansize = 1;
  145|       |
  146|  1.04k|    while ((lower + spansize < length) && (array[lower + spansize] < min)) {
  ------------------
  |  Branch (146:12): [True: 950, False: 98]
  |  Branch (146:43): [True: 838, False: 112]
  ------------------
  147|    838|        spansize <<= 1;
  148|    838|    }
  149|    210|    int32_t upper = (lower + spansize < length) ? lower + spansize : length - 1;
  ------------------
  |  Branch (149:21): [True: 112, False: 98]
  ------------------
  150|       |
  151|    210|    if (array[upper] == min) {
  ------------------
  |  Branch (151:9): [True: 0, False: 210]
  ------------------
  152|      0|        return upper;
  153|      0|    }
  154|    210|    if (array[upper] < min) {
  ------------------
  |  Branch (154:9): [True: 12, False: 198]
  ------------------
  155|       |        // means
  156|       |        // array
  157|       |        // has no
  158|       |        // item
  159|       |        // >= min
  160|       |        // pos = array.length;
  161|     12|        return length;
  162|     12|    }
  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|    740|    while (lower + 1 != upper) {
  ------------------
  |  Branch (168:12): [True: 542, False: 198]
  ------------------
  169|    542|        mid = (lower + upper) >> 1;
  170|    542|        if (array[mid] == min) {
  ------------------
  |  Branch (170:13): [True: 0, False: 542]
  ------------------
  171|      0|            return mid;
  172|    542|        } else if (array[mid] < min) {
  ------------------
  |  Branch (172:20): [True: 272, False: 270]
  ------------------
  173|    272|            lower = mid;
  174|    272|        } else {
  175|    270|            upper = mid;
  176|    270|        }
  177|    542|    }
  178|    198|    return upper;
  179|    198|}
mixed_andnot.c:advanceUntil:
  137|  96.3k|                                   int32_t length, uint16_t min) {
  138|  96.3k|    int32_t lower = pos + 1;
  139|       |
  140|  96.3k|    if ((lower >= length) || (array[lower] >= min)) {
  ------------------
  |  Branch (140:9): [True: 4.58k, False: 91.7k]
  |  Branch (140:30): [True: 77.6k, False: 14.0k]
  ------------------
  141|  82.2k|        return lower;
  142|  82.2k|    }
  143|       |
  144|  14.0k|    int32_t spansize = 1;
  145|       |
  146|  28.3k|    while ((lower + spansize < length) && (array[lower + spansize] < min)) {
  ------------------
  |  Branch (146:12): [True: 27.8k, False: 514]
  |  Branch (146:43): [True: 14.3k, False: 13.5k]
  ------------------
  147|  14.3k|        spansize <<= 1;
  148|  14.3k|    }
  149|  14.0k|    int32_t upper = (lower + spansize < length) ? lower + spansize : length - 1;
  ------------------
  |  Branch (149:21): [True: 13.5k, False: 514]
  ------------------
  150|       |
  151|  14.0k|    if (array[upper] == min) {
  ------------------
  |  Branch (151:9): [True: 7.25k, False: 6.80k]
  ------------------
  152|  7.25k|        return upper;
  153|  7.25k|    }
  154|  6.80k|    if (array[upper] < min) {
  ------------------
  |  Branch (154:9): [True: 461, False: 6.34k]
  ------------------
  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.34k|    lower += (spansize >> 1);
  166|       |
  167|  6.34k|    int32_t mid = 0;
  168|  9.74k|    while (lower + 1 != upper) {
  ------------------
  |  Branch (168:12): [True: 5.83k, False: 3.90k]
  ------------------
  169|  5.83k|        mid = (lower + upper) >> 1;
  170|  5.83k|        if (array[mid] == min) {
  ------------------
  |  Branch (170:13): [True: 2.44k, False: 3.39k]
  ------------------
  171|  2.44k|            return mid;
  172|  3.39k|        } else if (array[mid] < min) {
  ------------------
  |  Branch (172:20): [True: 1.16k, False: 2.22k]
  ------------------
  173|  1.16k|            lower = mid;
  174|  2.22k|        } else {
  175|  2.22k|            upper = mid;
  176|  2.22k|        }
  177|  5.83k|    }
  178|  3.90k|    return upper;
  179|  6.34k|}

roaring.c:bitset_lenrange_cardinality:
   63|  1.24k|                                              uint32_t lenminusone) {
   64|  1.24k|    uint32_t firstword = start / 64;
   65|  1.24k|    uint32_t endword = (start + lenminusone) / 64;
   66|  1.24k|    if (firstword == endword) {
  ------------------
  |  Branch (66:9): [True: 906, False: 334]
  ------------------
   67|    906|        return roaring_hamming(words[firstword] &
   68|    906|                               ((~UINT64_C(0)) >> ((63 - lenminusone) % 64))
   69|    906|                                   << (start % 64));
   70|    906|    }
   71|    334|    int answer =
   72|    334|        roaring_hamming(words[firstword] & ((~UINT64_C(0)) << (start % 64)));
   73|   149k|    for (uint32_t i = firstword + 1; i < endword; i++) {
  ------------------
  |  Branch (73:38): [True: 148k, False: 334]
  ------------------
   74|   148k|        answer += roaring_hamming(words[i]);
   75|   148k|    }
   76|    334|    answer += roaring_hamming(words[endword] &
   77|       |                              (~UINT64_C(0)) >>
   78|    334|                                  (((~start + 1) - lenminusone - 1) % 64));
   79|    334|    return answer;
   80|  1.24k|}
roaring.c:bitset_reset_range:
  147|  1.20k|                                      uint32_t end) {
  148|  1.20k|    if (start == end) return;
  ------------------
  |  Branch (148:9): [True: 0, False: 1.20k]
  ------------------
  149|  1.20k|    uint32_t firstword = start / 64;
  150|  1.20k|    uint32_t endword = (end - 1) / 64;
  151|  1.20k|    if (firstword == endword) {
  ------------------
  |  Branch (151:9): [True: 906, False: 302]
  ------------------
  152|    906|        words[firstword] &= ~(((~UINT64_C(0)) << (start % 64)) &
  153|    906|                              ((~UINT64_C(0)) >> ((~end + 1) % 64)));
  154|    906|        return;
  155|    906|    }
  156|    302|    words[firstword] &= ~((~UINT64_C(0)) << (start % 64));
  157|   121k|    for (uint32_t i = firstword + 1; i < endword; i++) {
  ------------------
  |  Branch (157:38): [True: 120k, False: 302]
  ------------------
  158|   120k|        words[i] = UINT64_C(0);
  159|   120k|    }
  160|       |    words[endword] &= ~((~UINT64_C(0)) >> ((~end + 1) % 64));
  161|    302|}
roaring.c:bitset_set_lenrange:
  112|  1.43k|                                       uint32_t lenminusone) {
  113|  1.43k|    uint32_t firstword = start / 64;
  114|  1.43k|    uint32_t endword = (start + lenminusone) / 64;
  115|  1.43k|    if (firstword == endword) {
  ------------------
  |  Branch (115:9): [True: 0, False: 1.43k]
  ------------------
  116|      0|        words[firstword] |= ((~UINT64_C(0)) >> ((63 - lenminusone) % 64))
  117|      0|                            << (start % 64);
  118|      0|        return;
  119|      0|    }
  120|  1.43k|    uint64_t temp = words[endword];
  121|  1.43k|    words[firstword] |= (~UINT64_C(0)) << (start % 64);
  122|   430k|    for (uint32_t i = firstword + 1; i < endword; i += 2)
  ------------------
  |  Branch (122:38): [True: 428k, False: 1.43k]
  ------------------
  123|   428k|        words[i] = words[i + 1] = ~UINT64_C(0);
  124|  1.43k|    words[endword] =
  125|       |        temp | (~UINT64_C(0)) >> (((~start + 1) - lenminusone - 1) % 64);
  126|  1.43k|}
bitset.c:avx2_harley_seal_popcount256:
  355|  3.40k|                                                    const uint64_t size) {
  356|  3.40k|    __m256i total = _mm256_setzero_si256();
  357|  3.40k|    __m256i ones = _mm256_setzero_si256();
  358|  3.40k|    __m256i twos = _mm256_setzero_si256();
  359|  3.40k|    __m256i fours = _mm256_setzero_si256();
  360|  3.40k|    __m256i eights = _mm256_setzero_si256();
  361|  3.40k|    __m256i sixteens = _mm256_setzero_si256();
  362|  3.40k|    __m256i twosA, twosB, foursA, foursB, eightsA, eightsB;
  363|       |
  364|  3.40k|    const uint64_t limit = size - size % 16;
  365|  3.40k|    uint64_t i = 0;
  366|       |
  367|  57.8k|    for (; i < limit; i += 16) {
  ------------------
  |  Branch (367:12): [True: 54.4k, False: 3.40k]
  ------------------
  368|  54.4k|        CSA(&twosA, &ones, ones, _mm256_loadu_si256(data + i),
  369|  54.4k|            _mm256_loadu_si256(data + i + 1));
  370|  54.4k|        CSA(&twosB, &ones, ones, _mm256_loadu_si256(data + i + 2),
  371|  54.4k|            _mm256_loadu_si256(data + i + 3));
  372|  54.4k|        CSA(&foursA, &twos, twos, twosA, twosB);
  373|  54.4k|        CSA(&twosA, &ones, ones, _mm256_loadu_si256(data + i + 4),
  374|  54.4k|            _mm256_loadu_si256(data + i + 5));
  375|  54.4k|        CSA(&twosB, &ones, ones, _mm256_loadu_si256(data + i + 6),
  376|  54.4k|            _mm256_loadu_si256(data + i + 7));
  377|  54.4k|        CSA(&foursB, &twos, twos, twosA, twosB);
  378|  54.4k|        CSA(&eightsA, &fours, fours, foursA, foursB);
  379|  54.4k|        CSA(&twosA, &ones, ones, _mm256_loadu_si256(data + i + 8),
  380|  54.4k|            _mm256_loadu_si256(data + i + 9));
  381|  54.4k|        CSA(&twosB, &ones, ones, _mm256_loadu_si256(data + i + 10),
  382|  54.4k|            _mm256_loadu_si256(data + i + 11));
  383|  54.4k|        CSA(&foursA, &twos, twos, twosA, twosB);
  384|  54.4k|        CSA(&twosA, &ones, ones, _mm256_loadu_si256(data + i + 12),
  385|  54.4k|            _mm256_loadu_si256(data + i + 13));
  386|  54.4k|        CSA(&twosB, &ones, ones, _mm256_loadu_si256(data + i + 14),
  387|  54.4k|            _mm256_loadu_si256(data + i + 15));
  388|  54.4k|        CSA(&foursB, &twos, twos, twosA, twosB);
  389|  54.4k|        CSA(&eightsB, &fours, fours, foursA, foursB);
  390|  54.4k|        CSA(&sixteens, &eights, eights, eightsA, eightsB);
  391|       |
  392|  54.4k|        total = _mm256_add_epi64(total, popcount256(sixteens));
  393|  54.4k|    }
  394|       |
  395|  3.40k|    total = _mm256_slli_epi64(total, 4);  // * 16
  396|  3.40k|    total = _mm256_add_epi64(
  397|  3.40k|        total, _mm256_slli_epi64(popcount256(eights), 3));  // += 8 * ...
  398|  3.40k|    total = _mm256_add_epi64(
  399|  3.40k|        total, _mm256_slli_epi64(popcount256(fours), 2));  // += 4 * ...
  400|  3.40k|    total = _mm256_add_epi64(
  401|  3.40k|        total, _mm256_slli_epi64(popcount256(twos), 1));  // += 2 * ...
  402|  3.40k|    total = _mm256_add_epi64(total, popcount256(ones));
  403|  3.40k|    for (; i < size; i++)
  ------------------
  |  Branch (403:12): [True: 0, False: 3.40k]
  ------------------
  404|      0|        total =
  405|      0|            _mm256_add_epi64(total, popcount256(_mm256_loadu_si256(data + i)));
  406|       |
  407|  3.40k|    return (uint64_t)(_mm256_extract_epi64(total, 0)) +
  408|  3.40k|           (uint64_t)(_mm256_extract_epi64(total, 1)) +
  409|  3.40k|           (uint64_t)(_mm256_extract_epi64(total, 2)) +
  410|       |           (uint64_t)(_mm256_extract_epi64(total, 3));
  411|  3.40k|}
bitset.c:CSA:
  343|  1.50M|                       __m256i c) {
  344|  1.50M|    const __m256i u = _mm256_xor_si256(a, b);
  345|  1.50M|    *h = _mm256_or_si256(_mm256_and_si256(a, b), _mm256_and_si256(u, c));
  346|  1.50M|    *l = _mm256_xor_si256(u, c);
  347|  1.50M|}
bitset.c:popcount256:
  307|   125k|static inline __m256i popcount256(__m256i v) {
  308|   125k|    const __m256i lookuppos = _mm256_setr_epi8(
  309|   125k|        /* 0 */ 4 + 0, /* 1 */ 4 + 1, /* 2 */ 4 + 1, /* 3 */ 4 + 2,
  310|   125k|        /* 4 */ 4 + 1, /* 5 */ 4 + 2, /* 6 */ 4 + 2, /* 7 */ 4 + 3,
  311|   125k|        /* 8 */ 4 + 1, /* 9 */ 4 + 2, /* a */ 4 + 2, /* b */ 4 + 3,
  312|   125k|        /* c */ 4 + 2, /* d */ 4 + 3, /* e */ 4 + 3, /* f */ 4 + 4,
  313|       |
  314|       |        /* 0 */ 4 + 0, /* 1 */ 4 + 1, /* 2 */ 4 + 1, /* 3 */ 4 + 2,
  315|   125k|        /* 4 */ 4 + 1, /* 5 */ 4 + 2, /* 6 */ 4 + 2, /* 7 */ 4 + 3,
  316|   125k|        /* 8 */ 4 + 1, /* 9 */ 4 + 2, /* a */ 4 + 2, /* b */ 4 + 3,
  317|   125k|        /* c */ 4 + 2, /* d */ 4 + 3, /* e */ 4 + 3, /* f */ 4 + 4);
  318|   125k|    const __m256i lookupneg = _mm256_setr_epi8(
  319|   125k|        /* 0 */ 4 - 0, /* 1 */ 4 - 1, /* 2 */ 4 - 1, /* 3 */ 4 - 2,
  320|   125k|        /* 4 */ 4 - 1, /* 5 */ 4 - 2, /* 6 */ 4 - 2, /* 7 */ 4 - 3,
  321|   125k|        /* 8 */ 4 - 1, /* 9 */ 4 - 2, /* a */ 4 - 2, /* b */ 4 - 3,
  322|   125k|        /* c */ 4 - 2, /* d */ 4 - 3, /* e */ 4 - 3, /* f */ 4 - 4,
  323|       |
  324|       |        /* 0 */ 4 - 0, /* 1 */ 4 - 1, /* 2 */ 4 - 1, /* 3 */ 4 - 2,
  325|   125k|        /* 4 */ 4 - 1, /* 5 */ 4 - 2, /* 6 */ 4 - 2, /* 7 */ 4 - 3,
  326|   125k|        /* 8 */ 4 - 1, /* 9 */ 4 - 2, /* a */ 4 - 2, /* b */ 4 - 3,
  327|   125k|        /* c */ 4 - 2, /* d */ 4 - 3, /* e */ 4 - 3, /* f */ 4 - 4);
  328|   125k|    const __m256i low_mask = _mm256_set1_epi8(0x0f);
  329|       |
  330|   125k|    const __m256i lo = _mm256_and_si256(v, low_mask);
  331|   125k|    const __m256i hi = _mm256_and_si256(_mm256_srli_epi16(v, 4), low_mask);
  332|   125k|    const __m256i popcnt1 = _mm256_shuffle_epi8(lookuppos, lo);
  333|   125k|    const __m256i popcnt2 = _mm256_shuffle_epi8(lookupneg, hi);
  334|   125k|    return _mm256_sad_epu8(popcnt1, popcnt2);
  335|   125k|}
convert.c:bitset_set_lenrange:
  112|   106k|                                       uint32_t lenminusone) {
  113|   106k|    uint32_t firstword = start / 64;
  114|   106k|    uint32_t endword = (start + lenminusone) / 64;
  115|   106k|    if (firstword == endword) {
  ------------------
  |  Branch (115:9): [True: 38.8k, False: 67.7k]
  ------------------
  116|  38.8k|        words[firstword] |= ((~UINT64_C(0)) >> ((63 - lenminusone) % 64))
  117|  38.8k|                            << (start % 64);
  118|  38.8k|        return;
  119|  38.8k|    }
  120|  67.7k|    uint64_t temp = words[endword];
  121|  67.7k|    words[firstword] |= (~UINT64_C(0)) << (start % 64);
  122|  33.4M|    for (uint32_t i = firstword + 1; i < endword; i += 2)
  ------------------
  |  Branch (122:38): [True: 33.3M, False: 67.7k]
  ------------------
  123|  33.3M|        words[i] = words[i + 1] = ~UINT64_C(0);
  124|  67.7k|    words[endword] =
  125|       |        temp | (~UINT64_C(0)) >> (((~start + 1) - lenminusone - 1) % 64);
  126|  67.7k|}
mixed_intersection.c:bitset_lenrange_cardinality:
   63|   204k|                                              uint32_t lenminusone) {
   64|   204k|    uint32_t firstword = start / 64;
   65|   204k|    uint32_t endword = (start + lenminusone) / 64;
   66|   204k|    if (firstword == endword) {
  ------------------
  |  Branch (66:9): [True: 198k, False: 5.75k]
  ------------------
   67|   198k|        return roaring_hamming(words[firstword] &
   68|   198k|                               ((~UINT64_C(0)) >> ((63 - lenminusone) % 64))
   69|   198k|                                   << (start % 64));
   70|   198k|    }
   71|  5.75k|    int answer =
   72|  5.75k|        roaring_hamming(words[firstword] & ((~UINT64_C(0)) << (start % 64)));
   73|  6.08k|    for (uint32_t i = firstword + 1; i < endword; i++) {
  ------------------
  |  Branch (73:38): [True: 328, False: 5.75k]
  ------------------
   74|    328|        answer += roaring_hamming(words[i]);
   75|    328|    }
   76|  5.75k|    answer += roaring_hamming(words[endword] &
   77|       |                              (~UINT64_C(0)) >>
   78|  5.75k|                                  (((~start + 1) - lenminusone - 1) % 64));
   79|  5.75k|    return answer;
   80|   204k|}
mixed_intersection.c:bitset_lenrange_empty:
   86|  4.34k|                                         uint32_t lenminusone) {
   87|  4.34k|    uint32_t firstword = start / 64;
   88|  4.34k|    uint32_t endword = (start + lenminusone) / 64;
   89|  4.34k|    if (firstword == endword) {
  ------------------
  |  Branch (89:9): [True: 4.03k, False: 312]
  ------------------
   90|  4.03k|        return (words[firstword] & ((~UINT64_C(0)) >> ((63 - lenminusone) % 64))
   91|  4.03k|                                       << (start % 64)) == 0;
   92|  4.03k|    }
   93|    312|    if (((words[firstword] & ((~UINT64_C(0)) << (start % 64)))) != 0) {
  ------------------
  |  Branch (93:9): [True: 88, False: 224]
  ------------------
   94|     88|        return false;
   95|     88|    }
   96|    238|    for (uint32_t i = firstword + 1; i < endword; i++) {
  ------------------
  |  Branch (96:38): [True: 17, False: 221]
  ------------------
   97|     17|        if (words[i] != 0) {
  ------------------
  |  Branch (97:13): [True: 3, False: 14]
  ------------------
   98|      3|            return false;
   99|      3|        }
  100|     17|    }
  101|    221|    if ((words[endword] &
  ------------------
  |  Branch (101:9): [True: 118, False: 103]
  ------------------
  102|    221|         (~UINT64_C(0)) >> (((~start + 1) - lenminusone - 1) % 64)) != 0) {
  103|    118|        return false;
  104|    118|    }
  105|    103|    return true;
  106|    221|}
mixed_union.c:bitset_set_lenrange:
  112|   102k|                                       uint32_t lenminusone) {
  113|   102k|    uint32_t firstword = start / 64;
  114|   102k|    uint32_t endword = (start + lenminusone) / 64;
  115|   102k|    if (firstword == endword) {
  ------------------
  |  Branch (115:9): [True: 99.4k, False: 2.87k]
  ------------------
  116|  99.4k|        words[firstword] |= ((~UINT64_C(0)) >> ((63 - lenminusone) % 64))
  117|  99.4k|                            << (start % 64);
  118|  99.4k|        return;
  119|  99.4k|    }
  120|  2.87k|    uint64_t temp = words[endword];
  121|  2.87k|    words[firstword] |= (~UINT64_C(0)) << (start % 64);
  122|  3.00k|    for (uint32_t i = firstword + 1; i < endword; i += 2)
  ------------------
  |  Branch (122:38): [True: 126, False: 2.87k]
  ------------------
  123|    126|        words[i] = words[i + 1] = ~UINT64_C(0);
  124|  2.87k|    words[endword] =
  125|       |        temp | (~UINT64_C(0)) >> (((~start + 1) - lenminusone - 1) % 64);
  126|  2.87k|}
mixed_negation.c:bitset_flip_range:
  132|  1.47k|                                     uint32_t end) {
  133|  1.47k|    if (start == end) return;
  ------------------
  |  Branch (133:9): [True: 0, False: 1.47k]
  ------------------
  134|  1.47k|    uint32_t firstword = start / 64;
  135|  1.47k|    uint32_t endword = (end - 1) / 64;
  136|  1.47k|    words[firstword] ^= ~((~UINT64_C(0)) << (start % 64));
  137|   203k|    for (uint32_t i = firstword; i < endword; i++) {
  ------------------
  |  Branch (137:34): [True: 202k, False: 1.47k]
  ------------------
  138|   202k|        words[i] = ~words[i];
  139|   202k|    }
  140|       |    words[endword] ^= ((~UINT64_C(0)) >> ((~end + 1) % 64));
  141|  1.47k|}
mixed_xor.c:bitset_flip_range:
  132|  55.7k|                                     uint32_t end) {
  133|  55.7k|    if (start == end) return;
  ------------------
  |  Branch (133:9): [True: 0, False: 55.7k]
  ------------------
  134|  55.7k|    uint32_t firstword = start / 64;
  135|  55.7k|    uint32_t endword = (end - 1) / 64;
  136|  55.7k|    words[firstword] ^= ~((~UINT64_C(0)) << (start % 64));
  137|   118k|    for (uint32_t i = firstword; i < endword; i++) {
  ------------------
  |  Branch (137:34): [True: 63.0k, False: 55.7k]
  ------------------
  138|  63.0k|        words[i] = ~words[i];
  139|  63.0k|    }
  140|       |    words[endword] ^= ((~UINT64_C(0)) >> ((~end + 1) % 64));
  141|  55.7k|}

array_container_contains:
  343|  3.39k|                                     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.39k|    const int32_t gap = 16;
  351|  3.39k|    const uint16_t *carr = arr->array;
  352|  3.39k|    int32_t cardinality = arr->cardinality;
  353|  3.39k|    if (cardinality < gap) {
  ------------------
  |  Branch (353:9): [True: 990, False: 2.40k]
  ------------------
  354|  1.12k|        for (int32_t j = 0; j < cardinality; j++) {
  ------------------
  |  Branch (354:29): [True: 1.10k, False: 24]
  ------------------
  355|  1.10k|            if (carr[j] >= pos) return carr[j] == pos;
  ------------------
  |  Branch (355:17): [True: 966, False: 137]
  ------------------
  356|  1.10k|        }
  357|     24|        return false;
  358|    990|    }
  359|  2.40k|    int32_t num_blocks = cardinality / gap;
  360|  2.40k|    int32_t base = 0;
  361|  2.40k|    int32_t n = num_blocks;
  362|  5.52k|    while (n > 3) {
  ------------------
  |  Branch (362:12): [True: 3.12k, False: 2.40k]
  ------------------
  363|  3.12k|        int32_t quarter = n >> 2;
  364|       |
  365|  3.12k|        int32_t k1 = carr[(base + quarter + 1) * gap - 1];
  366|  3.12k|        int32_t k2 = carr[(base + 2 * quarter + 1) * gap - 1];
  367|  3.12k|        int32_t k3 = carr[(base + 3 * quarter + 1) * gap - 1];
  368|       |
  369|  3.12k|        int32_t c1 = (k1 < pos);
  370|  3.12k|        int32_t c2 = (k2 < pos);
  371|  3.12k|        int32_t c3 = (k3 < pos);
  372|       |
  373|  3.12k|        base += (c1 + c2 + c3) * quarter;
  374|  3.12k|        n -= 3 * quarter;
  375|  3.12k|    }
  376|  4.28k|    while (n > 1) {
  ------------------
  |  Branch (376:12): [True: 1.88k, False: 2.40k]
  ------------------
  377|  1.88k|        int32_t half = n >> 1;
  378|  1.88k|        base = (carr[(base + half + 1) * gap - 1] < pos) ? base + half : base;
  ------------------
  |  Branch (378:16): [True: 72, False: 1.81k]
  ------------------
  379|  1.88k|        n -= half;
  380|  1.88k|    }
  381|  2.40k|    int32_t lo = (carr[(base + 1) * gap - 1] < pos) ? base + 1 : base;
  ------------------
  |  Branch (381:18): [True: 117, False: 2.28k]
  ------------------
  382|       |
  383|  2.40k|    if (lo < num_blocks) {
  ------------------
  |  Branch (383:9): [True: 2.32k, False: 75]
  ------------------
  384|  2.32k|        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|       |#ifdef __arm__
  392|       |        uint16x4_t hit8 = vmax_u16(vget_low_u16(hit), vget_high_u16(hit));
  393|       |        uint16x4_t hit4 = vpmax_u16(hit8, hit8);
  394|       |        return vget_lane_u32(hit4, 0) != 0;
  395|       |#else /* __aarch64__ */
  396|       |        return vmaxvq_u16(hit) != 0;
  397|       |#endif
  398|       |#elif defined(CROARING_IS_X64)
  399|       |        __m128i needle = _mm_set1_epi16((short)pos);
  400|  2.32k|        __m128i v0 = _mm_loadu_si128((const __m128i *)blk);
  401|  2.32k|        __m128i v1 = _mm_loadu_si128((const __m128i *)(blk + 8));
  402|  2.32k|        __m128i hit = _mm_or_si128(_mm_cmpeq_epi16(v0, needle),
  403|  2.32k|                                   _mm_cmpeq_epi16(v1, needle));
  404|  2.32k|        return _mm_movemask_epi8(hit) != 0;
  405|       |#else
  406|       |        for (int32_t j = 0; j < gap; j++) {
  407|       |            if (blk[j] >= pos) return blk[j] == pos;
  408|       |        }
  409|       |        return false;
  410|       |#endif
  411|  2.32k|    }
  412|       |
  413|    618|    for (int32_t j = num_blocks * gap; j < cardinality; j++) {
  ------------------
  |  Branch (413:40): [True: 574, False: 44]
  ------------------
  414|    574|        uint16_t v = carr[j];
  415|    574|        if (v >= pos) return (v == pos);
  ------------------
  |  Branch (415:13): [True: 31, False: 543]
  ------------------
  416|    574|    }
  417|     44|    return false;
  418|     75|}
array_container_minimum:
  451|  3.65k|inline uint16_t array_container_minimum(const array_container_t *arr) {
  452|  3.65k|    if (arr->cardinality == 0) return 0;
  ------------------
  |  Branch (452:9): [True: 0, False: 3.65k]
  ------------------
  453|  3.65k|    return arr->array[0];
  454|  3.65k|}
array_container_maximum:
  457|  13.1k|inline uint16_t array_container_maximum(const array_container_t *arr) {
  458|  13.1k|    if (arr->cardinality == 0) return 0;
  ------------------
  |  Branch (458:9): [True: 0, False: 13.1k]
  ------------------
  459|  13.1k|    return arr->array[arr->cardinality - 1];
  460|  13.1k|}
array_container_rank:
  463|  3.75k|inline int array_container_rank(const array_container_t *arr, uint16_t x) {
  464|  3.75k|    const int32_t idx = binarySearch(arr->array, arr->cardinality, x);
  465|  3.75k|    const bool is_present = idx >= 0;
  466|  3.75k|    if (is_present) {
  ------------------
  |  Branch (466:9): [True: 3.18k, False: 568]
  ------------------
  467|  3.18k|        return idx + 1;
  468|  3.18k|    } else {
  469|    568|        return -idx - 1;
  470|    568|    }
  471|  3.75k|}
array_container_index_equalorlarger:
  513|  4.42k|                                               uint16_t x) {
  514|  4.42k|    const int32_t idx = binarySearch(arr->array, arr->cardinality, x);
  515|  4.42k|    const bool is_present = idx >= 0;
  516|  4.42k|    if (is_present) {
  ------------------
  |  Branch (516:9): [True: 4.07k, False: 353]
  ------------------
  517|  4.07k|        return idx;
  518|  4.07k|    } else {
  519|    353|        int32_t candidate = -idx - 1;
  520|    353|        if (candidate < arr->cardinality) return candidate;
  ------------------
  |  Branch (520:13): [True: 353, False: 0]
  ------------------
  521|      0|        return -1;
  522|    353|    }
  523|  4.42k|}
roaring.c:array_container_add_range_nvals:
  533|    620|                                                   int32_t nvals_greater) {
  534|    620|    int32_t union_cardinality = nvals_less + (max - min + 1) + nvals_greater;
  535|    620|    if (union_cardinality > array->capacity) {
  ------------------
  |  Branch (535:9): [True: 576, False: 44]
  ------------------
  536|    576|        array_container_grow(array, union_cardinality, true);
  537|    576|    }
  538|    620|    memmove(&(array->array[union_cardinality - nvals_greater]),
  539|    620|            &(array->array[array->cardinality - nvals_greater]),
  540|    620|            nvals_greater * sizeof(uint16_t));
  541|  1.51M|    for (uint32_t i = 0; i <= max - min; i++) {
  ------------------
  |  Branch (541:26): [True: 1.51M, False: 620]
  ------------------
  542|  1.51M|        array->array[nvals_less + i] = (uint16_t)(min + i);
  543|  1.51M|    }
  544|    620|    array->cardinality = union_cardinality;
  545|    620|}
roaring.c:array_container_remove_range:
  563|  3.24k|                                                uint32_t pos, uint32_t count) {
  564|  3.24k|    if (count != 0) {
  ------------------
  |  Branch (564:9): [True: 330, False: 2.91k]
  ------------------
  565|    330|        memmove(&(array->array[pos]), &(array->array[pos + count]),
  566|    330|                (array->cardinality - pos - count) * sizeof(uint16_t));
  567|    330|        array->cardinality -= count;
  568|    330|    }
  569|  3.24k|}
roaring.c:array_container_cardinality:
   82|  70.9k|static inline int array_container_cardinality(const array_container_t *array) {
   83|  70.9k|    return array->cardinality;
   84|  70.9k|}
roaring.c:array_container_try_add:
  293|  7.22M|                                          int32_t max_cardinality) {
  294|  7.22M|    const int32_t cardinality = arr->cardinality;
  295|       |
  296|       |    // best case, we can append.
  297|  7.22M|    if ((array_container_empty(arr) || arr->array[cardinality - 1] < value) &&
  ------------------
  |  Branch (297:10): [True: 15.8k, False: 7.20M]
  |  Branch (297:40): [True: 50.9k, False: 7.15M]
  ------------------
  298|  66.7k|        cardinality < max_cardinality) {
  ------------------
  |  Branch (298:9): [True: 66.7k, False: 0]
  ------------------
  299|  66.7k|        array_container_append(arr, value);
  300|  66.7k|        return 1;
  301|  66.7k|    }
  302|       |
  303|  7.15M|    const int32_t loc = binarySearch(arr->array, cardinality, value);
  304|       |
  305|  7.15M|    if (loc >= 0) {
  ------------------
  |  Branch (305:9): [True: 5.45M, False: 1.70M]
  ------------------
  306|  5.45M|        return 0;
  307|  5.45M|    } else if (cardinality < max_cardinality) {
  ------------------
  |  Branch (307:16): [True: 1.70M, False: 126]
  ------------------
  308|  1.70M|        if (array_container_full(arr)) {
  ------------------
  |  Branch (308:13): [True: 75.8k, False: 1.62M]
  ------------------
  309|  75.8k|            array_container_grow(arr, arr->capacity + 1, true);
  310|  75.8k|        }
  311|  1.70M|        const int32_t insert_idx = -loc - 1;
  312|  1.70M|        memmove(arr->array + insert_idx + 1, arr->array + insert_idx,
  313|  1.70M|                (cardinality - insert_idx) * sizeof(uint16_t));
  314|  1.70M|        arr->array[insert_idx] = value;
  315|  1.70M|        arr->cardinality++;
  316|  1.70M|        return 1;
  317|  1.70M|    } else {
  318|    126|        return -1;
  319|    126|    }
  320|  7.15M|}
roaring.c:array_container_empty:
  100|  7.22M|static inline bool array_container_empty(const array_container_t *array) {
  101|  7.22M|    return array->cardinality == 0;
  102|  7.22M|}
roaring.c:array_container_append:
  274|  66.7k|                                          uint16_t pos) {
  275|  66.7k|    const int32_t capacity = arr->capacity;
  276|       |
  277|  66.7k|    if (array_container_full(arr)) {
  ------------------
  |  Branch (277:9): [True: 31.9k, False: 34.8k]
  ------------------
  278|  31.9k|        array_container_grow(arr, capacity + 1, true);
  279|  31.9k|    }
  280|       |
  281|  66.7k|    arr->array[arr->cardinality++] = pos;
  282|  66.7k|}
roaring.c:array_container_full:
  106|  1.76M|static inline bool array_container_full(const array_container_t *array) {
  107|  1.76M|    return array->cardinality == array->capacity;
  108|  1.76M|}
roaring.c:array_container_remove:
  329|  6.20k|                                          uint16_t pos) {
  330|  6.20k|    const int32_t idx = binarySearch(arr->array, arr->cardinality, pos);
  331|  6.20k|    const bool is_present = idx >= 0;
  332|  6.20k|    if (is_present) {
  ------------------
  |  Branch (332:9): [True: 3.11k, False: 3.09k]
  ------------------
  333|  3.11k|        memmove(arr->array + idx, arr->array + idx + 1,
  334|  3.11k|                (arr->cardinality - idx - 1) * sizeof(uint16_t));
  335|  3.11k|        arr->cardinality--;
  336|  3.11k|    }
  337|       |
  338|  6.20k|    return is_present;
  339|  6.20k|}
roaring.c:array_container_nonzero_cardinality:
   87|   100k|    const array_container_t *array) {
   88|   100k|    return array->cardinality > 0;
   89|   100k|}
roaring.c:array_container_equals:
  230|  9.44k|                                          const array_container_t *container2) {
  231|  9.44k|    if (container1->cardinality != container2->cardinality) {
  ------------------
  |  Branch (231:9): [True: 2.31k, False: 7.13k]
  ------------------
  232|  2.31k|        return false;
  233|  2.31k|    }
  234|  7.13k|    return memequals(container1->array, container2->array,
  235|  7.13k|                     container1->cardinality * 2);
  236|  9.44k|}
roaring.c:array_container_select:
  252|  3.75k|                                          uint32_t *element) {
  253|  3.75k|    int card = array_container_cardinality(container);
  254|  3.75k|    if (*start_rank + card <= rank) {
  ------------------
  |  Branch (254:9): [True: 325, False: 3.43k]
  ------------------
  255|    325|        *start_rank += card;
  256|    325|        return false;
  257|  3.43k|    } else {
  258|  3.43k|        *element = container->array[rank - *start_rank];
  259|       |        return true;
  260|  3.43k|    }
  261|  3.75k|}
roaring.c:array_container_contains_range:
  427|     96|                                                  uint32_t range_end) {
  428|     96|    const int32_t range_count = range_end - range_start;
  429|     96|    const uint16_t rs_included = (uint16_t)range_start;
  430|     96|    const uint16_t re_included = (uint16_t)(range_end - 1);
  431|       |
  432|       |    // Empty range is always included
  433|     96|    if (range_count <= 0) {
  ------------------
  |  Branch (433:9): [True: 0, False: 96]
  ------------------
  434|      0|        return true;
  435|      0|    }
  436|     96|    if (range_count > arr->cardinality) {
  ------------------
  |  Branch (436:9): [True: 42, False: 54]
  ------------------
  437|     42|        return false;
  438|     42|    }
  439|       |
  440|     54|    const int32_t start =
  441|     54|        binarySearch(arr->array, arr->cardinality, rs_included);
  442|       |    // If this sorted array contains all items in the range:
  443|       |    // * the start item must be found
  444|       |    // * the last item in range range_count must exist, and be the expected end
  445|       |    // value
  446|     54|    return (start >= 0) && (arr->cardinality >= start + range_count) &&
  ------------------
  |  Branch (446:12): [True: 39, False: 15]
  |  Branch (446:28): [True: 35, False: 4]
  ------------------
  447|     35|           (arr->array[start + range_count - 1] == re_included);
  ------------------
  |  Branch (447:12): [True: 12, False: 23]
  ------------------
  448|     96|}
roaring_array.c:array_container_size_in_bytes:
  221|  17.7k|    const array_container_t *container) {
  222|  17.7k|    return container->cardinality * sizeof(uint16_t);
  223|  17.7k|}
roaring_array.c:array_container_cardinality:
   82|  6.97k|static inline int array_container_cardinality(const array_container_t *array) {
   83|  6.97k|    return array->cardinality;
   84|  6.97k|}
array.c:array_container_size_in_bytes:
  221|  13.9k|    const array_container_t *container) {
  222|  13.9k|    return container->cardinality * sizeof(uint16_t);
  223|  13.9k|}
convert.c:array_container_cardinality:
   82|  14.8k|static inline int array_container_cardinality(const array_container_t *array) {
   83|  14.8k|    return array->cardinality;
   84|  14.8k|}
convert.c:array_container_serialized_size_in_bytes:
  173|   143k|static inline int32_t array_container_serialized_size_in_bytes(int32_t card) {
  174|   143k|    return card * sizeof(uint16_t);
  175|   143k|}
mixed_intersection.c:array_container_empty:
  100|     22|static inline bool array_container_empty(const array_container_t *array) {
  101|     22|    return array->cardinality == 0;
  102|     22|}
mixed_andnot.c:array_container_cardinality:
   82|    362|static inline int array_container_cardinality(const array_container_t *array) {
   83|    362|    return array->cardinality;
   84|    362|}

bitset_container_get:
  197|  1.02M|                                 uint16_t pos) {
  198|  1.02M|    const uint64_t word = bitset->words[pos >> 6];
  199|  1.02M|    return (word >> (pos & 63)) & 1;
  200|  1.02M|}
bitset_container_contains:
  236|   883k|                                      uint16_t pos) {
  237|   883k|    return bitset_container_get(bitset, pos);
  238|   883k|}
roaring.c:bitset_container_cardinality:
  252|  10.5k|    const bitset_container_t *bitset) {
  253|  10.5k|    return bitset->cardinality;
  254|  10.5k|}
roaring.c:bitset_container_set:
  151|   304k|                                        uint16_t pos) {
  152|   304k|    const uint64_t old_word = bitset->words[pos >> 6];
  153|   304k|    const int index = pos & 63;
  154|       |    const uint64_t new_word = old_word | (UINT64_C(1) << index);
  155|   304k|    bitset->cardinality += (uint32_t)((old_word ^ new_word) >> index);
  156|   304k|    bitset->words[pos >> 6] = new_word;
  157|   304k|}
roaring.c:bitset_container_add:
  172|    126|                                        uint16_t pos) {
  173|    126|    const uint64_t old_word = bitset->words[pos >> 6];
  174|    126|    const int index = pos & 63;
  175|       |    const uint64_t new_word = old_word | (UINT64_C(1) << index);
  176|    126|    const uint64_t increment = (old_word ^ new_word) >> index;
  177|    126|    bitset->cardinality += (uint32_t)increment;
  178|    126|    bitset->words[pos >> 6] = new_word;
  179|    126|    return increment > 0;
  180|    126|}
roaring.c:bitset_container_remove:
  185|  2.17k|                                           uint16_t pos) {
  186|  2.17k|    const uint64_t old_word = bitset->words[pos >> 6];
  187|  2.17k|    const int index = pos & 63;
  188|       |    const uint64_t new_word = old_word & (~(UINT64_C(1) << index));
  189|  2.17k|    const uint64_t increment = (old_word ^ new_word) >> index;
  190|  2.17k|    bitset->cardinality -= (uint32_t)increment;
  191|  2.17k|    bitset->words[pos >> 6] = new_word;
  192|  2.17k|    return increment > 0;
  193|  2.17k|}
roaring.c:bitset_container_const_nonzero_cardinality:
  285|  6.64k|    const bitset_container_t *bitset) {
  286|  6.64k|    return !bitset_container_empty(bitset);
  287|  6.64k|}
roaring.c:bitset_container_empty:
  272|  6.64k|static inline bool bitset_container_empty(const bitset_container_t *bitset) {
  273|  6.64k|    if (bitset->cardinality == BITSET_UNKNOWN_CARDINALITY) {
  ------------------
  |  Branch (273:9): [True: 0, False: 6.64k]
  ------------------
  274|      0|        for (int i = 0; i < BITSET_CONTAINER_SIZE_IN_WORDS; i++) {
  ------------------
  |  Branch (274:25): [True: 0, False: 0]
  ------------------
  275|      0|            if ((bitset->words[i]) != 0) return false;
  ------------------
  |  Branch (275:17): [True: 0, False: 0]
  ------------------
  276|      0|        }
  277|      0|        return true;
  278|      0|    }
  279|  6.64k|    return bitset->cardinality == 0;
  280|  6.64k|}
roaring.c:bitset_container_get_range:
  210|    206|                                              uint32_t pos_end) {
  211|    206|    const uint32_t start = pos_start >> 6;
  212|    206|    const uint32_t end = pos_end >> 6;
  213|       |
  214|    206|    const uint64_t first = ~((1ULL << (pos_start & 0x3F)) - 1);
  215|    206|    const uint64_t last = (1ULL << (pos_end & 0x3F)) - 1;
  216|       |
  217|    206|    if (start == end)
  ------------------
  |  Branch (217:9): [True: 3, False: 203]
  ------------------
  218|      3|        return ((bitset->words[end] & first & last) == (first & last));
  219|    203|    if ((bitset->words[start] & first) != first) return false;
  ------------------
  |  Branch (219:9): [True: 78, False: 125]
  ------------------
  220|       |
  221|    125|    if ((end < BITSET_CONTAINER_SIZE_IN_WORDS) &&
  ------------------
  |  Branch (221:9): [True: 111, False: 14]
  ------------------
  222|    111|        ((bitset->words[end] & last) != last)) {
  ------------------
  |  Branch (222:9): [True: 93, False: 18]
  ------------------
  223|     93|        return false;
  224|     93|    }
  225|       |
  226|     32|    for (uint32_t i = start + 1;
  227|  9.84k|         (i < BITSET_CONTAINER_SIZE_IN_WORDS) && (i < end); ++i) {
  ------------------
  |  Branch (227:10): [True: 9.83k, False: 7]
  |  Branch (227:50): [True: 9.82k, False: 15]
  ------------------
  228|  9.82k|        if (bitset->words[i] != UINT64_C(0xFFFFFFFFFFFFFFFF)) return false;
  ------------------
  |  Branch (228:13): [True: 10, False: 9.81k]
  ------------------
  229|  9.82k|    }
  230|       |
  231|     22|    return true;
  232|     32|}
roaring_array.c:bitset_container_size_in_bytes:
  472|   134k|    const bitset_container_t *container) {
  473|   134k|    (void)container;
  474|   134k|    return BITSET_CONTAINER_SIZE_IN_WORDS * sizeof(uint64_t);
  475|   134k|}
roaring_array.c:bitset_container_cardinality:
  252|  67.1k|    const bitset_container_t *bitset) {
  253|  67.1k|    return bitset->cardinality;
  254|  67.1k|}
bitset.c:bitset_container_size_in_bytes:
  472|   134k|    const bitset_container_t *container) {
  473|   134k|    (void)container;
  474|   134k|    return BITSET_CONTAINER_SIZE_IN_WORDS * sizeof(uint64_t);
  475|   134k|}
convert.c:bitset_container_set:
  151|  2.38M|                                        uint16_t pos) {
  152|  2.38M|    const uint64_t old_word = bitset->words[pos >> 6];
  153|  2.38M|    const int index = pos & 63;
  154|       |    const uint64_t new_word = old_word | (UINT64_C(1) << index);
  155|  2.38M|    bitset->cardinality += (uint32_t)((old_word ^ new_word) >> index);
  156|  2.38M|    bitset->words[pos >> 6] = new_word;
  157|  2.38M|}
convert.c:bitset_container_serialized_size_in_bytes:
  431|   130k|static inline int32_t bitset_container_serialized_size_in_bytes(void) {
  432|   130k|    return BITSET_CONTAINER_SIZE_IN_WORDS * 8;
  433|   130k|}

container_iterator_next:
 2457|   332k|                                    uint16_t *value) {
 2458|   332k|    switch (typecode) {
 2459|      0|        case BITSET_CONTAINER_TYPE: {
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2459:9): [True: 0, False: 332k]
  ------------------
 2460|      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)
  |  |  ------------------
  ------------------
 2461|      0|            it->index++;
 2462|       |
 2463|      0|            uint32_t wordindex = it->index / 64;
 2464|      0|            if (wordindex >= BITSET_CONTAINER_SIZE_IN_WORDS) {
  ------------------
  |  Branch (2464:17): [True: 0, False: 0]
  ------------------
 2465|      0|                return false;
 2466|      0|            }
 2467|       |
 2468|      0|            uint64_t word =
 2469|      0|                bc->words[wordindex] & (UINT64_MAX << (it->index % 64));
 2470|       |            // next part could be optimized/simplified
 2471|      0|            while (word == 0 &&
  ------------------
  |  Branch (2471:20): [True: 0, False: 0]
  ------------------
 2472|      0|                   (wordindex + 1 < BITSET_CONTAINER_SIZE_IN_WORDS)) {
  ------------------
  |  Branch (2472:20): [True: 0, False: 0]
  ------------------
 2473|      0|                wordindex++;
 2474|      0|                word = bc->words[wordindex];
 2475|      0|            }
 2476|      0|            if (word != 0) {
  ------------------
  |  Branch (2476:17): [True: 0, False: 0]
  ------------------
 2477|      0|                it->index = wordindex * 64 + roaring_trailing_zeroes(word);
 2478|      0|                *value = it->index;
 2479|      0|                return true;
 2480|      0|            }
 2481|      0|            return false;
 2482|      0|        }
 2483|   287k|        case ARRAY_CONTAINER_TYPE: {
  ------------------
  |  |   49|   287k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2483:9): [True: 287k, False: 45.4k]
  ------------------
 2484|   287k|            const array_container_t *ac = const_CAST_array(c);
  ------------------
  |  |   55|   287k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|   287k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2485|   287k|            it->index++;
 2486|   287k|            if (it->index < ac->cardinality) {
  ------------------
  |  Branch (2486:17): [True: 281k, False: 5.59k]
  ------------------
 2487|   281k|                *value = ac->array[it->index];
 2488|   281k|                return true;
 2489|   281k|            }
 2490|  5.59k|            return false;
 2491|   287k|        }
 2492|  45.4k|        case RUN_CONTAINER_TYPE: {
  ------------------
  |  |   50|  45.4k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2492:9): [True: 45.4k, False: 287k]
  ------------------
 2493|  45.4k|            if (*value == UINT16_MAX) {  // Avoid overflow to zero
  ------------------
  |  Branch (2493:17): [True: 0, False: 45.4k]
  ------------------
 2494|      0|                return false;
 2495|      0|            }
 2496|       |
 2497|  45.4k|            const run_container_t *rc = const_CAST_run(c);
  ------------------
  |  |   78|  45.4k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  45.4k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2498|  45.4k|            uint32_t limit =
 2499|  45.4k|                rc->runs[it->index].value + rc->runs[it->index].length;
 2500|  45.4k|            if (*value < limit) {
  ------------------
  |  Branch (2500:17): [True: 29.0k, False: 16.3k]
  ------------------
 2501|  29.0k|                (*value)++;
 2502|  29.0k|                return true;
 2503|  29.0k|            }
 2504|       |
 2505|  16.3k|            it->index++;
 2506|  16.3k|            if (it->index < rc->n_runs) {
  ------------------
  |  Branch (2506:17): [True: 15.8k, False: 497]
  ------------------
 2507|  15.8k|                *value = rc->runs[it->index].value;
 2508|  15.8k|                return true;
 2509|  15.8k|            }
 2510|    497|            return false;
 2511|  16.3k|        }
 2512|      0|        default:
  ------------------
  |  Branch (2512:9): [True: 0, False: 332k]
  ------------------
 2513|      0|            assert(false);
 2514|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2515|      0|            return false;
 2516|   332k|    }
 2517|   332k|}
roaring.c:container_from_range:
  317|  67.1k|                                                uint32_t max, uint16_t step) {
  318|  67.1k|    if (step == 0) return NULL;  // being paranoid
  ------------------
  |  Branch (318:9): [True: 0, False: 67.1k]
  ------------------
  319|  67.1k|    if (step == 1) {
  ------------------
  |  Branch (319:9): [True: 67.1k, False: 0]
  ------------------
  320|  67.1k|        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|  67.1k|    }
  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|  83.4k|                                                   uint8_t *result_type) {
  303|  83.4k|    assert(range_end >= range_start);
  304|  83.4k|    uint64_t cardinality = range_end - range_start + 1;
  305|  83.4k|    if (cardinality <= 2) {
  ------------------
  |  Branch (305:9): [True: 133, False: 83.2k]
  ------------------
  306|    133|        *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    133|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  307|    133|        return array_container_create_range(range_start, range_end);
  308|  83.2k|    } else {
  309|  83.2k|        *result_type = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|  83.2k|#define RUN_CONTAINER_TYPE 3
  ------------------
  310|  83.2k|        return run_container_create_range(range_start, range_end);
  311|  83.2k|    }
  312|  83.4k|}
roaring.c:container_add_range:
 2282|  3.13k|                                               uint8_t *result_type) {
 2283|       |    // NB: when selecting new container type, we perform only inexpensive checks
 2284|  3.13k|    switch (type) {
 2285|      0|        case BITSET_CONTAINER_TYPE: {
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2285:9): [True: 0, False: 3.13k]
  ------------------
 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.66k|        case ARRAY_CONTAINER_TYPE: {
  ------------------
  |  |   49|  2.66k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2304:9): [True: 2.66k, False: 470]
  ------------------
 2305|  2.66k|            array_container_t *array = CAST_array(c);
  ------------------
  |  |   54|  2.66k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  2.66k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2306|       |
 2307|  2.66k|            int32_t nvals_greater =
 2308|  2.66k|                count_greater(array->array, array->cardinality, (uint16_t)max);
 2309|  2.66k|            int32_t nvals_less =
 2310|  2.66k|                count_less(array->array, array->cardinality - nvals_greater,
 2311|  2.66k|                           (uint16_t)min);
 2312|  2.66k|            int32_t union_cardinality =
 2313|  2.66k|                nvals_less + (max - min + 1) + nvals_greater;
 2314|       |
 2315|  2.66k|            if (union_cardinality == INT32_C(0x10000)) {
  ------------------
  |  Branch (2315:17): [True: 602, False: 2.05k]
  ------------------
 2316|    602|                *result_type = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|    602|#define RUN_CONTAINER_TYPE 3
  ------------------
 2317|    602|                return run_container_create_range(0, INT32_C(0x10000));
 2318|  2.05k|            } else if (union_cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (2318:24): [True: 620, False: 1.43k]
  ------------------
 2319|    620|                *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    620|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 2320|    620|                array_container_add_range_nvals(array, min, max, nvals_less,
 2321|    620|                                                nvals_greater);
 2322|    620|                return array;
 2323|  1.43k|            } else {
 2324|  1.43k|                *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|  1.43k|#define BITSET_CONTAINER_TYPE 1
  ------------------
 2325|  1.43k|                bitset_container_t *bitset = bitset_container_from_array(array);
 2326|  1.43k|                bitset_set_lenrange(bitset->words, min, max - min);
 2327|  1.43k|                bitset->cardinality = union_cardinality;
 2328|  1.43k|                return bitset;
 2329|  1.43k|            }
 2330|  2.66k|        }
 2331|    470|        case RUN_CONTAINER_TYPE: {
  ------------------
  |  |   50|    470|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2331:9): [True: 470, False: 2.66k]
  ------------------
 2332|    470|            run_container_t *run = CAST_run(c);
  ------------------
  |  |   77|    470|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    470|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2333|       |
 2334|    470|            int32_t nruns_greater =
 2335|    470|                rle16_count_greater(run->runs, run->n_runs, (uint16_t)max);
 2336|    470|            int32_t nruns_less = rle16_count_less(
 2337|    470|                run->runs, run->n_runs - nruns_greater, (uint16_t)min);
 2338|       |
 2339|    470|            int32_t run_size_bytes =
 2340|    470|                (nruns_less + 1 + nruns_greater) * sizeof(rle16_t);
 2341|    470|            int32_t bitset_size_bytes =
 2342|    470|                BITSET_CONTAINER_SIZE_IN_WORDS * sizeof(uint64_t);
 2343|       |
 2344|    470|            if (run_size_bytes <= bitset_size_bytes) {
  ------------------
  |  Branch (2344:17): [True: 470, False: 0]
  ------------------
 2345|    470|                run_container_add_range_nruns(run, min, max, nruns_less,
 2346|    470|                                              nruns_greater);
 2347|    470|                *result_type = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|    470|#define RUN_CONTAINER_TYPE 3
  ------------------
 2348|    470|                return run;
 2349|    470|            } else {
 2350|      0|                return container_from_run_range(run, min, max, result_type);
 2351|      0|            }
 2352|    470|        }
 2353|      0|        default:
  ------------------
  |  Branch (2353:9): [True: 0, False: 3.13k]
  ------------------
 2354|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2355|  3.13k|    }
 2356|  3.13k|}
roaring.c:container_remove_range:
 2371|  18.9k|                                                  uint8_t *result_type) {
 2372|  18.9k|    switch (type) {
 2373|  1.24k|        case BITSET_CONTAINER_TYPE: {
  ------------------
  |  |   48|  1.24k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2373:9): [True: 1.24k, False: 17.6k]
  ------------------
 2374|  1.24k|            bitset_container_t *bitset = CAST_bitset(c);
  ------------------
  |  |   52|  1.24k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.24k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2375|       |
 2376|  1.24k|            int32_t result_cardinality =
 2377|  1.24k|                bitset->cardinality -
 2378|  1.24k|                bitset_lenrange_cardinality(bitset->words, min, max - min);
 2379|       |
 2380|  1.24k|            if (result_cardinality == 0) {
  ------------------
  |  Branch (2380:17): [True: 32, False: 1.20k]
  ------------------
 2381|     32|                return NULL;
 2382|  1.20k|            } else if (result_cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (2382:24): [True: 102, False: 1.10k]
  ------------------
 2383|    102|                *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    102|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 2384|    102|                bitset_reset_range(bitset->words, min, max + 1);
 2385|    102|                bitset->cardinality = result_cardinality;
 2386|    102|                return array_container_from_bitset(bitset);
 2387|  1.10k|            } else {
 2388|  1.10k|                *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|  1.10k|#define BITSET_CONTAINER_TYPE 1
  ------------------
 2389|  1.10k|                bitset_reset_range(bitset->words, min, max + 1);
 2390|  1.10k|                bitset->cardinality = result_cardinality;
 2391|  1.10k|                return bitset;
 2392|  1.10k|            }
 2393|  1.24k|        }
 2394|  3.61k|        case ARRAY_CONTAINER_TYPE: {
  ------------------
  |  |   49|  3.61k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2394:9): [True: 3.61k, False: 15.2k]
  ------------------
 2395|  3.61k|            array_container_t *array = CAST_array(c);
  ------------------
  |  |   54|  3.61k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  3.61k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2396|       |
 2397|  3.61k|            int32_t nvals_greater =
 2398|  3.61k|                count_greater(array->array, array->cardinality, (uint16_t)max);
 2399|  3.61k|            int32_t nvals_less =
 2400|  3.61k|                count_less(array->array, array->cardinality - nvals_greater,
 2401|  3.61k|                           (uint16_t)min);
 2402|  3.61k|            int32_t result_cardinality = nvals_less + nvals_greater;
 2403|       |
 2404|  3.61k|            if (result_cardinality == 0) {
  ------------------
  |  Branch (2404:17): [True: 377, False: 3.24k]
  ------------------
 2405|    377|                return NULL;
 2406|  3.24k|            } else {
 2407|  3.24k|                *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  3.24k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 2408|  3.24k|                array_container_remove_range(
 2409|  3.24k|                    array, nvals_less, array->cardinality - result_cardinality);
 2410|  3.24k|                return array;
 2411|  3.24k|            }
 2412|  3.61k|        }
 2413|  14.0k|        case RUN_CONTAINER_TYPE: {
  ------------------
  |  |   50|  14.0k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2413:9): [True: 14.0k, False: 4.85k]
  ------------------
 2414|  14.0k|            run_container_t *run = CAST_run(c);
  ------------------
  |  |   77|  14.0k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  14.0k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2415|       |
 2416|  14.0k|            if (run->n_runs == 0) {
  ------------------
  |  Branch (2416:17): [True: 0, False: 14.0k]
  ------------------
 2417|      0|                return NULL;
 2418|      0|            }
 2419|  14.0k|            if (min <= run_container_minimum(run) &&
  ------------------
  |  Branch (2419:17): [True: 13.6k, False: 425]
  ------------------
 2420|  13.6k|                max >= run_container_maximum(run)) {
  ------------------
  |  Branch (2420:17): [True: 12.2k, False: 1.37k]
  ------------------
 2421|  12.2k|                return NULL;
 2422|  12.2k|            }
 2423|       |
 2424|  1.80k|            run_container_remove_range(run, min, max);
 2425|  1.80k|            return convert_run_to_efficient_container(run, result_type);
 2426|  14.0k|        }
 2427|      0|        default:
  ------------------
  |  Branch (2427:9): [True: 0, False: 18.9k]
  ------------------
 2428|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2429|  18.9k|    }
 2430|  18.9k|}
roaring.c:container_get_cardinality:
  244|   372k|                                            uint8_t typecode) {
  245|   372k|    c = container_unwrap_shared(c, &typecode);
  246|   372k|    switch (typecode) {
  ------------------
  |  Branch (246:13): [True: 372k, False: 0]
  ------------------
  247|  9.21k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  9.21k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (247:9): [True: 9.21k, False: 362k]
  ------------------
  248|  9.21k|            return bitset_container_cardinality(const_CAST_bitset(c));
  ------------------
  |  |   53|  9.21k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  9.21k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  249|  63.3k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  63.3k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (249:9): [True: 63.3k, False: 308k]
  ------------------
  250|  63.3k|            return array_container_cardinality(const_CAST_array(c));
  ------------------
  |  |   55|  63.3k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  63.3k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  251|   299k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|   299k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (251:9): [True: 299k, False: 72.6k]
  ------------------
  252|   299k|            return run_container_cardinality(const_CAST_run(c));
  ------------------
  |  |   78|   299k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|   299k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  253|   372k|    }
  254|   372k|    assert(false);
  255|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  256|      0|    return 0;  // unreached
  257|   372k|}
roaring.c:get_container_type:
  129|  74.1k|static inline uint8_t get_container_type(const container_t *c, uint8_t type) {
  130|  74.1k|    if (type == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|  74.1k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (130:9): [True: 0, False: 74.1k]
  ------------------
  131|      0|        return const_CAST_shared(c)->typecode;
  ------------------
  |  |   80|      0|#define const_CAST_shared(c) CAST(const shared_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  132|  74.1k|    } else {
  133|  74.1k|        return type;
  134|  74.1k|    }
  135|  74.1k|}
roaring.c:get_writable_copy_if_shared:
  146|  8.15M|                                                       uint8_t *type) {
  147|  8.15M|    if (*type == SHARED_CONTAINER_TYPE) {  // shared, return enclosed container
  ------------------
  |  |   51|  8.15M|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (147:9): [True: 0, False: 8.15M]
  ------------------
  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.15M|    } else {
  150|  8.15M|        return c;  // not shared, so return as-is
  151|  8.15M|    }
  152|  8.15M|}
roaring.c:container_add:
  492|  7.92M|    uint8_t *new_typecode) {
  493|  7.92M|    c = get_writable_copy_if_shared(c, &typecode);
  494|  7.92M|    switch (typecode) {
  495|   304k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|   304k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (495:9): [True: 304k, False: 7.62M]
  ------------------
  496|   304k|            bitset_container_set(CAST_bitset(c), val);
  ------------------
  |  |   52|   304k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|   304k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  497|   304k|            *new_typecode = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|   304k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  498|   304k|            return c;
  499|  7.22M|        case ARRAY_CONTAINER_TYPE: {
  ------------------
  |  |   49|  7.22M|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (499:9): [True: 7.22M, False: 705k]
  ------------------
  500|  7.22M|            array_container_t *ac = CAST_array(c);
  ------------------
  |  |   54|  7.22M|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  7.22M|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  501|  7.22M|            if (array_container_try_add(ac, val, DEFAULT_MAX_SIZE) != -1) {
  ------------------
  |  Branch (501:17): [True: 7.22M, False: 126]
  ------------------
  502|  7.22M|                *new_typecode = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  7.22M|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  503|  7.22M|                return ac;
  504|  7.22M|            } else {
  505|    126|                bitset_container_t *bitset = bitset_container_from_array(ac);
  506|    126|                bitset_container_add(bitset, val);
  507|    126|                *new_typecode = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|    126|#define BITSET_CONTAINER_TYPE 1
  ------------------
  508|    126|                return bitset;
  509|    126|            }
  510|  7.22M|        } break;
  511|   401k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|   401k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (511:9): [True: 401k, False: 7.52M]
  ------------------
  512|       |            // per Java, no container type adjustments are done (revisit?)
  513|   401k|            run_container_add(CAST_run(c), val);
  ------------------
  |  |   77|   401k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|   401k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  514|   401k|            *new_typecode = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|   401k|#define RUN_CONTAINER_TYPE 3
  ------------------
  515|   401k|            return c;
  516|      0|        default:
  ------------------
  |  Branch (516:9): [True: 0, False: 7.92M]
  ------------------
  517|      0|            assert(false);
  518|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  519|      0|            return NULL;
  520|  7.92M|    }
  521|  7.92M|}
roaring.c:container_remove:
  533|  11.4k|    uint8_t *new_typecode) {
  534|  11.4k|    c = get_writable_copy_if_shared(c, &typecode);
  535|  11.4k|    switch (typecode) {
  536|  2.17k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  2.17k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (536:9): [True: 2.17k, False: 9.24k]
  ------------------
  537|  2.17k|            if (bitset_container_remove(CAST_bitset(c), val)) {
  ------------------
  |  |   52|  2.17k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  2.17k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (537:17): [True: 1.33k, False: 836]
  ------------------
  538|  1.33k|                int card = bitset_container_cardinality(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)
  |  |  ------------------
  ------------------
  539|  1.33k|                if (card <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (539:21): [True: 11, False: 1.32k]
  ------------------
  540|     11|                    *new_typecode = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|     11|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  541|     11|                    return array_container_from_bitset(CAST_bitset(c));
  ------------------
  |  |   52|     11|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     11|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  542|     11|                }
  543|  1.33k|            }
  544|  2.16k|            *new_typecode = typecode;
  545|  2.16k|            return c;
  546|  6.20k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  6.20k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (546:9): [True: 6.20k, False: 5.21k]
  ------------------
  547|  6.20k|            *new_typecode = typecode;
  548|  6.20k|            array_container_remove(CAST_array(c), val);
  ------------------
  |  |   54|  6.20k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  6.20k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  549|  6.20k|            return c;
  550|  3.04k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  3.04k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (550:9): [True: 3.04k, False: 8.37k]
  ------------------
  551|       |            // per Java, no container type adjustments are done (revisit?)
  552|  3.04k|            run_container_remove(CAST_run(c), val);
  ------------------
  |  |   77|  3.04k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  3.04k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  553|  3.04k|            *new_typecode = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|  3.04k|#define RUN_CONTAINER_TYPE 3
  ------------------
  554|  3.04k|            return c;
  555|      0|        default:
  ------------------
  |  Branch (555:9): [True: 0, False: 11.4k]
  ------------------
  556|      0|            assert(false);
  557|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  558|      0|            return NULL;
  559|  11.4k|    }
  560|  11.4k|}
roaring.c:container_nonzero_cardinality:
  437|   169k|                                                 uint8_t typecode) {
  438|   169k|    c = container_unwrap_shared(c, &typecode);
  439|   169k|    switch (typecode) {
  ------------------
  |  Branch (439:13): [True: 169k, False: 0]
  ------------------
  440|  6.64k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  6.64k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (440:9): [True: 6.64k, False: 162k]
  ------------------
  441|  6.64k|            return bitset_container_const_nonzero_cardinality(
  442|  6.64k|                const_CAST_bitset(c));
  ------------------
  |  |   53|  6.64k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  6.64k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  443|   100k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|   100k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (443:9): [True: 100k, False: 68.5k]
  ------------------
  444|   100k|            return array_container_nonzero_cardinality(const_CAST_array(c));
  ------------------
  |  |   55|   100k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|   100k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  445|  61.8k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  61.8k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (445:9): [True: 61.8k, False: 107k]
  ------------------
  446|  61.8k|            return run_container_nonzero_cardinality(const_CAST_run(c));
  ------------------
  |  |   78|  61.8k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  61.8k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  447|   169k|    }
  448|   169k|    assert(false);
  449|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  450|      0|    return 0;  // unreached
  451|   169k|}
roaring.c:container_and:
  728|  6.18k|                                         uint8_t *result_type) {
  729|  6.18k|    c1 = container_unwrap_shared(c1, &type1);
  730|  6.18k|    c2 = container_unwrap_shared(c2, &type2);
  731|  6.18k|    container_t *result = NULL;
  732|  6.18k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  6.18k|#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.18k]
  ------------------
  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.39k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  2.39k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.39k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.39k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (741:9): [True: 2.39k, False: 3.79k]
  ------------------
  742|  2.39k|            result = array_container_create();
  743|  2.39k|            array_container_intersection(
  744|  2.39k|                const_CAST_array(c1), const_CAST_array(c2), CAST_array(result));
  ------------------
  |  |   55|  2.39k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.39k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_array(c2), CAST_array(result));
  ------------------
  |  |   55|  2.39k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.39k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_array(c2), CAST_array(result));
  ------------------
  |  |   54|  2.39k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  2.39k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  745|  2.39k|            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
  ------------------
  |  |   49|  2.39k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  746|  2.39k|            return result;
  747|       |
  748|    655|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    655|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    655|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    655|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (748:9): [True: 655, False: 5.53k]
  ------------------
  749|    655|            result = run_container_create();
  750|    655|            run_container_intersection(const_CAST_run(c1), const_CAST_run(c2),
  ------------------
  |  |   78|    655|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    655|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          run_container_intersection(const_CAST_run(c1), const_CAST_run(c2),
  ------------------
  |  |   78|    655|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    655|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  751|    655|                                       CAST_run(result));
  ------------------
  |  |   77|    655|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    655|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  752|    655|            return convert_run_to_efficient_container_and_free(CAST_run(result),
  ------------------
  |  |   77|    655|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    655|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  753|    655|                                                               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.18k]
  ------------------
  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|    519|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|    519|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    519|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    519|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (763:9): [True: 519, False: 5.66k]
  ------------------
  764|    519|            result = array_container_create();
  765|    519|            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
  ------------------
  |  |   49|    519|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  766|    519|            array_bitset_container_intersection(const_CAST_array(c1),
  ------------------
  |  |   55|    519|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    519|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  767|    519|                                                const_CAST_bitset(c2),
  ------------------
  |  |   53|    519|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    519|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  768|    519|                                                CAST_array(result));
  ------------------
  |  |   54|    519|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    519|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  769|    519|            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.18k]
  ------------------
  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|    654|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|    654|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    654|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    654|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (779:9): [True: 654, False: 5.53k]
  ------------------
  780|    654|            *result_type =
  781|    654|                run_bitset_container_intersection(
  ------------------
  |  Branch (781:17): [True: 0, False: 654]
  ------------------
  782|    654|                    const_CAST_run(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   78|    654|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    654|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                  const_CAST_run(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|    654|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    654|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  783|    654|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  784|    654|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  1.30k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  785|    654|            return result;
  786|       |
  787|    747|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    747|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    747|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    747|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (787:9): [True: 747, False: 5.43k]
  ------------------
  788|    747|            result = array_container_create();
  789|    747|            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
  ------------------
  |  |   49|    747|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  790|    747|            array_run_container_intersection(
  791|    747|                const_CAST_array(c1), const_CAST_run(c2), CAST_array(result));
  ------------------
  |  |   55|    747|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    747|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_run(c2), CAST_array(result));
  ------------------
  |  |   78|    747|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    747|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_run(c2), CAST_array(result));
  ------------------
  |  |   54|    747|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    747|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  792|    747|            return result;
  793|       |
  794|  1.21k|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|  1.21k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  1.21k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  1.21k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (794:9): [True: 1.21k, False: 4.96k]
  ------------------
  795|  1.21k|            result = array_container_create();
  796|  1.21k|            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
  ------------------
  |  |   49|  1.21k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  797|  1.21k|            array_run_container_intersection(
  798|  1.21k|                const_CAST_array(c2), const_CAST_run(c1), CAST_array(result));
  ------------------
  |  |   55|  1.21k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.21k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c2), const_CAST_run(c1), CAST_array(result));
  ------------------
  |  |   78|  1.21k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.21k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c2), const_CAST_run(c1), CAST_array(result));
  ------------------
  |  |   54|  1.21k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.21k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  799|  1.21k|            return result;
  800|       |
  801|      0|        default:
  ------------------
  |  Branch (801:9): [True: 0, False: 6.18k]
  ------------------
  802|      0|            assert(false);
  803|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  804|      0|            return NULL;
  805|  6.18k|    }
  806|  6.18k|}
roaring.c:container_iand:
  923|  63.9k|                                          uint8_t *result_type) {
  924|  63.9k|    c1 = get_writable_copy_if_shared(c1, &type1);
  925|  63.9k|    c2 = container_unwrap_shared(c2, &type2);
  926|  63.9k|    container_t *result = NULL;
  927|  63.9k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  63.9k|#define PAIR_CONTAINER_TYPES(type1, type2) (4 * (type1) + (type2))
  ------------------
  928|  1.41k|        case CONTAINER_PAIR(BITSET, BITSET):
  ------------------
  |  |   65|  1.41k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  1.41k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  1.41k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (928:9): [True: 1.41k, False: 62.4k]
  ------------------
  929|  1.41k|            *result_type = bitset_bitset_container_intersection_inplace(
  ------------------
  |  Branch (929:28): [True: 1.41k, False: 0]
  ------------------
  930|  1.41k|                               CAST_bitset(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   52|  1.41k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.41k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_bitset(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|  1.41k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.41k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  931|  1.41k|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|  1.41k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  932|  1.41k|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  1.41k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  933|  1.41k|            return result;
  934|       |
  935|  4.70k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  4.70k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  4.70k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  4.70k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (935:9): [True: 4.70k, False: 59.2k]
  ------------------
  936|  4.70k|            array_container_intersection_inplace(CAST_array(c1),
  ------------------
  |  |   54|  4.70k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  4.70k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  937|  4.70k|                                                 const_CAST_array(c2));
  ------------------
  |  |   55|  4.70k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  4.70k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  938|  4.70k|            *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  4.70k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  939|  4.70k|            return c1;
  940|       |
  941|  56.5k|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|  56.5k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  56.5k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  56.5k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (941:9): [True: 56.5k, False: 7.37k]
  ------------------
  942|  56.5k|            result = run_container_create();
  943|  56.5k|            run_container_intersection(const_CAST_run(c1), const_CAST_run(c2),
  ------------------
  |  |   78|  56.5k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  56.5k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          run_container_intersection(const_CAST_run(c1), const_CAST_run(c2),
  ------------------
  |  |   78|  56.5k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  56.5k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  944|  56.5k|                                       CAST_run(result));
  ------------------
  |  |   77|  56.5k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  56.5k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  945|       |            // as of January 2016, Java code used non-in-place intersection for
  946|       |            // two runcontainers
  947|  56.5k|            return convert_run_to_efficient_container_and_free(CAST_run(result),
  ------------------
  |  |   77|  56.5k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  56.5k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  948|  56.5k|                                                               result_type);
  949|       |
  950|     49|        case CONTAINER_PAIR(BITSET, ARRAY):
  ------------------
  |  |   65|     49|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|     49|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|     49|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (950:9): [True: 49, False: 63.8k]
  ------------------
  951|       |            // c1 is a bitmap so no inplace possible
  952|     49|            result = array_container_create();
  953|     49|            array_bitset_container_intersection(const_CAST_array(c2),
  ------------------
  |  |   55|     49|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|     49|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  954|     49|                                                const_CAST_bitset(c1),
  ------------------
  |  |   53|     49|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|     49|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  955|     49|                                                CAST_array(result));
  ------------------
  |  |   54|     49|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     49|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  956|     49|            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
  ------------------
  |  |   49|     49|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  957|     49|            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: 63.9k]
  ------------------
  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: 63.9k]
  ------------------
  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: 63.9k]
  ------------------
  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|    171|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    171|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    171|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    171|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (982:9): [True: 171, False: 63.7k]
  ------------------
  983|    171|            result = array_container_create();
  984|    171|            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
  ------------------
  |  |   49|    171|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  985|    171|            array_run_container_intersection(
  986|    171|                const_CAST_array(c1), const_CAST_run(c2), CAST_array(result));
  ------------------
  |  |   55|    171|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    171|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_run(c2), CAST_array(result));
  ------------------
  |  |   78|    171|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    171|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_run(c2), CAST_array(result));
  ------------------
  |  |   54|    171|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    171|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  987|    171|            return result;
  988|       |
  989|  1.02k|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|  1.02k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  1.02k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  1.02k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (989:9): [True: 1.02k, False: 62.8k]
  ------------------
  990|  1.02k|            result = array_container_create();
  991|  1.02k|            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
  ------------------
  |  |   49|  1.02k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  992|  1.02k|            array_run_container_intersection(
  993|  1.02k|                const_CAST_array(c2), const_CAST_run(c1), CAST_array(result));
  ------------------
  |  |   55|  1.02k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.02k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c2), const_CAST_run(c1), CAST_array(result));
  ------------------
  |  |   78|  1.02k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.02k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c2), const_CAST_run(c1), CAST_array(result));
  ------------------
  |  |   54|  1.02k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.02k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  994|  1.02k|            return result;
  995|       |
  996|      0|        default:
  ------------------
  |  Branch (996:9): [True: 0, False: 63.9k]
  ------------------
  997|      0|            assert(false);
  998|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  999|      0|            return NULL;
 1000|  63.9k|    }
 1001|  63.9k|}
roaring.c:container_or:
 1010|  6.18k|                                        uint8_t *result_type) {
 1011|  6.18k|    c1 = container_unwrap_shared(c1, &type1);
 1012|  6.18k|    c2 = container_unwrap_shared(c2, &type2);
 1013|  6.18k|    container_t *result = NULL;
 1014|  6.18k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  6.18k|#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.18k]
  ------------------
 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.39k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  2.39k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.39k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.39k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1022:9): [True: 2.39k, False: 3.79k]
  ------------------
 1023|  2.39k|            *result_type =
 1024|  2.39k|                array_array_container_union(const_CAST_array(c1),
  ------------------
  |  |   55|  2.39k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.39k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1024:17): [True: 49, False: 2.34k]
  ------------------
 1025|  2.39k|                                            const_CAST_array(c2), &result)
  ------------------
  |  |   55|  2.39k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.39k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1026|  2.39k|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|     49|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1027|  2.39k|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  4.73k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1028|  2.39k|            return result;
 1029|       |
 1030|    655|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    655|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    655|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    655|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1030:9): [True: 655, False: 5.53k]
  ------------------
 1031|    655|            result = run_container_create();
 1032|    655|            run_container_union(const_CAST_run(c1), const_CAST_run(c2),
  ------------------
  |  |   78|    655|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    655|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          run_container_union(const_CAST_run(c1), const_CAST_run(c2),
  ------------------
  |  |   78|    655|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    655|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1033|    655|                                CAST_run(result));
  ------------------
  |  |   77|    655|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    655|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1034|    655|            *result_type = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|    655|#define RUN_CONTAINER_TYPE 3
  ------------------
 1035|       |            // todo: could be optimized since will never convert to array
 1036|    655|            result = convert_run_to_efficient_container_and_free(
 1037|    655|                CAST_run(result), result_type);
  ------------------
  |  |   77|    655|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    655|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1038|    655|            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.18k]
  ------------------
 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|    519|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|    519|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    519|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    519|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1048:9): [True: 519, False: 5.66k]
  ------------------
 1049|    519|            result = bitset_container_create();
 1050|    519|            array_bitset_container_union(const_CAST_array(c1),
  ------------------
  |  |   55|    519|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    519|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1051|    519|                                         const_CAST_bitset(c2),
  ------------------
  |  |   53|    519|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    519|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1052|    519|                                         CAST_bitset(result));
  ------------------
  |  |   52|    519|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    519|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1053|    519|            *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|    519|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1054|    519|            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.18k]
  ------------------
 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|    654|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|    654|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    654|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    654|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1069:9): [True: 654, False: 5.53k]
  ------------------
 1070|    654|            if (run_container_is_full(const_CAST_run(c1))) {
  ------------------
  |  |   78|    654|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    654|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1070:17): [True: 0, False: 654]
  ------------------
 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|    654|            result = bitset_container_create();
 1077|    654|            run_bitset_container_union(
 1078|    654|                const_CAST_run(c1), const_CAST_bitset(c2), CAST_bitset(result));
  ------------------
  |  |   78|    654|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    654|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c1), const_CAST_bitset(c2), CAST_bitset(result));
  ------------------
  |  |   53|    654|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    654|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c1), const_CAST_bitset(c2), CAST_bitset(result));
  ------------------
  |  |   52|    654|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    654|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1079|    654|            *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|    654|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1080|    654|            return result;
 1081|       |
 1082|    747|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    747|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    747|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    747|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1082:9): [True: 747, False: 5.43k]
  ------------------
 1083|    747|            result = run_container_create();
 1084|    747|            array_run_container_union(const_CAST_array(c1), const_CAST_run(c2),
  ------------------
  |  |   55|    747|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    747|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          array_run_container_union(const_CAST_array(c1), const_CAST_run(c2),
  ------------------
  |  |   78|    747|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    747|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1085|    747|                                      CAST_run(result));
  ------------------
  |  |   77|    747|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    747|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1086|    747|            result = convert_run_to_efficient_container_and_free(
 1087|    747|                CAST_run(result), result_type);
  ------------------
  |  |   77|    747|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    747|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1088|    747|            return result;
 1089|       |
 1090|  1.21k|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|  1.21k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  1.21k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  1.21k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1090:9): [True: 1.21k, False: 4.96k]
  ------------------
 1091|  1.21k|            result = run_container_create();
 1092|  1.21k|            array_run_container_union(const_CAST_array(c2), const_CAST_run(c1),
  ------------------
  |  |   55|  1.21k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.21k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          array_run_container_union(const_CAST_array(c2), const_CAST_run(c1),
  ------------------
  |  |   78|  1.21k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.21k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1093|  1.21k|                                      CAST_run(result));
  ------------------
  |  |   77|  1.21k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.21k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1094|  1.21k|            result = convert_run_to_efficient_container_and_free(
 1095|  1.21k|                CAST_run(result), result_type);
  ------------------
  |  |   77|  1.21k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.21k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1096|  1.21k|            return result;
 1097|       |
 1098|      0|        default:
  ------------------
  |  Branch (1098:9): [True: 0, False: 6.18k]
  ------------------
 1099|      0|            assert(false);
 1100|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1101|      0|            return NULL;  // unreached
 1102|  6.18k|    }
 1103|  6.18k|}
roaring.c:container_is_full:
  262|  6.95k|static inline bool container_is_full(const container_t *c, uint8_t typecode) {
  263|  6.95k|    c = container_unwrap_shared(c, &typecode);
  264|  6.95k|    switch (typecode) {
  ------------------
  |  Branch (264:13): [True: 6.95k, False: 0]
  ------------------
  265|      0|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (265:9): [True: 0, False: 6.95k]
  ------------------
  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.75k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  3.75k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (268:9): [True: 3.75k, False: 3.19k]
  ------------------
  269|  3.75k|            return array_container_cardinality(const_CAST_array(c)) ==
  ------------------
  |  |   55|  3.75k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.75k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  270|  3.75k|                   (1 << 16);
  271|  3.19k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  3.19k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (271:9): [True: 3.19k, False: 3.75k]
  ------------------
  272|  3.19k|            return run_container_is_full(const_CAST_run(c));
  ------------------
  |  |   78|  3.19k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.19k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  273|  6.95k|    }
  274|  6.95k|    assert(false);
  275|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  276|      0|    return 0;  // unreached
  277|  6.95k|}
roaring.c:container_ior:
 1228|  6.31k|                                         uint8_t *result_type) {
 1229|  6.31k|    c1 = get_writable_copy_if_shared(c1, &type1);
 1230|  6.31k|    c2 = container_unwrap_shared(c2, &type2);
 1231|  6.31k|    container_t *result = NULL;
 1232|  6.31k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  6.31k|#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.31k]
  ------------------
 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.57k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  2.57k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.57k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.57k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1246:9): [True: 2.57k, False: 3.74k]
  ------------------
 1247|  2.57k|            *result_type = array_array_container_inplace_union(
  ------------------
  |  Branch (1247:28): [True: 0, False: 2.57k]
  ------------------
 1248|  2.57k|                               CAST_array(c1), const_CAST_array(c2), &result)
  ------------------
  |  |   54|  2.57k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  2.57k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_array(c1), const_CAST_array(c2), &result)
  ------------------
  |  |   55|  2.57k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.57k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1249|  2.57k|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1250|  2.57k|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  5.14k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1251|  2.57k|            if ((result == NULL) && (*result_type == ARRAY_CONTAINER_TYPE)) {
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (1251:17): [True: 0, False: 2.57k]
  |  Branch (1251:37): [True: 0, False: 0]
  ------------------
 1252|      0|                return c1;  // the computation was done in-place!
 1253|      0|            }
 1254|  2.57k|            return result;
 1255|       |
 1256|  1.67k|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|  1.67k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  1.67k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  1.67k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1256:9): [True: 1.67k, False: 4.64k]
  ------------------
 1257|  1.67k|            run_container_union_inplace(CAST_run(c1), const_CAST_run(c2));
  ------------------
  |  |   77|  1.67k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.67k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          run_container_union_inplace(CAST_run(c1), const_CAST_run(c2));
  ------------------
  |  |   78|  1.67k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.67k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1258|  1.67k|            return convert_run_to_efficient_container(CAST_run(c1),
  ------------------
  |  |   77|  1.67k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.67k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1259|  1.67k|                                                      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.31k]
  ------------------
 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|    568|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|    568|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    568|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    568|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1267:9): [True: 568, False: 5.74k]
  ------------------
 1268|       |            // c1 is an array, so no in-place possible
 1269|    568|            result = bitset_container_create();
 1270|    568|            *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|    568|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1271|    568|            array_bitset_container_union(const_CAST_array(c1),
  ------------------
  |  |   55|    568|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    568|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1272|    568|                                         const_CAST_bitset(c2),
  ------------------
  |  |   53|    568|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    568|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1273|    568|                                         CAST_bitset(result));
  ------------------
  |  |   52|    568|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    568|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1274|    568|            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.31k]
  ------------------
 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|    654|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|    654|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    654|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    654|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1289:9): [True: 654, False: 5.66k]
  ------------------
 1290|    654|            if (run_container_is_full(const_CAST_run(c1))) {
  ------------------
  |  |   78|    654|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    654|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1290:17): [True: 0, False: 654]
  ------------------
 1291|      0|                *result_type = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
 1292|      0|                return c1;
 1293|      0|            }
 1294|    654|            result = bitset_container_create();
 1295|    654|            run_bitset_container_union(
 1296|    654|                const_CAST_run(c1), const_CAST_bitset(c2), CAST_bitset(result));
  ------------------
  |  |   78|    654|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    654|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c1), const_CAST_bitset(c2), CAST_bitset(result));
  ------------------
  |  |   53|    654|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    654|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c1), const_CAST_bitset(c2), CAST_bitset(result));
  ------------------
  |  |   52|    654|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    654|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1297|    654|            *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|    654|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1298|    654|            return result;
 1299|       |
 1300|    617|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    617|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    617|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    617|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1300:9): [True: 617, False: 5.69k]
  ------------------
 1301|    617|            result = run_container_create();
 1302|    617|            array_run_container_union(const_CAST_array(c1), const_CAST_run(c2),
  ------------------
  |  |   55|    617|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    617|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          array_run_container_union(const_CAST_array(c1), const_CAST_run(c2),
  ------------------
  |  |   78|    617|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    617|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1303|    617|                                      CAST_run(result));
  ------------------
  |  |   77|    617|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    617|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1304|    617|            result = convert_run_to_efficient_container_and_free(
 1305|    617|                CAST_run(result), result_type);
  ------------------
  |  |   77|    617|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    617|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1306|    617|            return result;
 1307|       |
 1308|    230|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|    230|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    230|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    230|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1308:9): [True: 230, False: 6.08k]
  ------------------
 1309|    230|            array_run_container_inplace_union(const_CAST_array(c2),
  ------------------
  |  |   55|    230|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    230|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1310|    230|                                              CAST_run(c1));
  ------------------
  |  |   77|    230|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    230|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1311|    230|            c1 = convert_run_to_efficient_container(CAST_run(c1), result_type);
  ------------------
  |  |   77|    230|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    230|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1312|    230|            return c1;
 1313|       |
 1314|      0|        default:
  ------------------
  |  Branch (1314:9): [True: 0, False: 6.31k]
  ------------------
 1315|      0|            assert(false);
 1316|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1317|      0|            return NULL;
 1318|  6.31k|    }
 1319|  6.31k|}
roaring.c:container_xor:
 1451|  6.18k|                                         uint8_t *result_type) {
 1452|  6.18k|    c1 = container_unwrap_shared(c1, &type1);
 1453|  6.18k|    c2 = container_unwrap_shared(c2, &type2);
 1454|  6.18k|    container_t *result = NULL;
 1455|  6.18k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  6.18k|#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.18k]
  ------------------
 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.39k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  2.39k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.39k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.39k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1464:9): [True: 2.39k, False: 3.79k]
  ------------------
 1465|  2.39k|            *result_type =
 1466|  2.39k|                array_array_container_xor(const_CAST_array(c1),
  ------------------
  |  |   55|  2.39k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.39k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1466:17): [True: 13, False: 2.37k]
  ------------------
 1467|  2.39k|                                          const_CAST_array(c2), &result)
  ------------------
  |  |   55|  2.39k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.39k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1468|  2.39k|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|     13|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1469|  2.39k|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  4.77k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1470|  2.39k|            return result;
 1471|       |
 1472|    655|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    655|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    655|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    655|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1472:9): [True: 655, False: 5.53k]
  ------------------
 1473|    655|            *result_type = (uint8_t)run_run_container_xor(
 1474|    655|                const_CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|    655|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    655|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|    655|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    655|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1475|    655|            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.18k]
  ------------------
 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|    519|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|    519|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    519|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    519|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1485:9): [True: 519, False: 5.66k]
  ------------------
 1486|    519|            *result_type =
 1487|    519|                array_bitset_container_xor(const_CAST_array(c1),
  ------------------
  |  |   55|    519|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    519|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1487:17): [True: 476, False: 43]
  ------------------
 1488|    519|                                           const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|    519|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    519|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1489|    519|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|    476|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1490|    519|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    562|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1491|    519|            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.18k]
  ------------------
 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|    654|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|    654|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    654|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    654|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1501:9): [True: 654, False: 5.53k]
  ------------------
 1502|    654|            *result_type =
 1503|    654|                run_bitset_container_xor(const_CAST_run(c1),
  ------------------
  |  |   78|    654|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    654|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1503:17): [True: 595, False: 59]
  ------------------
 1504|    654|                                         const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|    654|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    654|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1505|    654|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|    595|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1506|    654|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    713|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1507|    654|            return result;
 1508|       |
 1509|    747|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    747|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    747|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    747|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1509:9): [True: 747, False: 5.43k]
  ------------------
 1510|    747|            *result_type = (uint8_t)array_run_container_xor(
 1511|    747|                const_CAST_array(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   55|    747|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    747|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|    747|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    747|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1512|    747|            return result;
 1513|       |
 1514|  1.21k|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|  1.21k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  1.21k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  1.21k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1514:9): [True: 1.21k, False: 4.96k]
  ------------------
 1515|  1.21k|            *result_type = (uint8_t)array_run_container_xor(
 1516|  1.21k|                const_CAST_array(c2), const_CAST_run(c1), &result);
  ------------------
  |  |   55|  1.21k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.21k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c2), const_CAST_run(c1), &result);
  ------------------
  |  |   78|  1.21k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.21k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1517|  1.21k|            return result;
 1518|       |
 1519|      0|        default:
  ------------------
  |  Branch (1519:9): [True: 0, False: 6.18k]
  ------------------
 1520|      0|            assert(false);
 1521|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1522|      0|            return NULL;  // unreached
 1523|  6.18k|    }
 1524|  6.18k|}
roaring.c:container_ixor:
 1667|  62.3k|                                          uint8_t *result_type) {
 1668|  62.3k|    c1 = get_writable_copy_if_shared(c1, &type1);
 1669|  62.3k|    c2 = container_unwrap_shared(c2, &type2);
 1670|  62.3k|    container_t *result = NULL;
 1671|  62.3k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  62.3k|#define PAIR_CONTAINER_TYPES(type1, type2) (4 * (type1) + (type2))
  ------------------
 1672|  1.45k|        case CONTAINER_PAIR(BITSET, BITSET):
  ------------------
  |  |   65|  1.45k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  1.45k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  1.45k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1672:9): [True: 1.45k, False: 60.9k]
  ------------------
 1673|  1.45k|            *result_type = bitset_bitset_container_ixor(
  ------------------
  |  Branch (1673:28): [True: 0, False: 1.45k]
  ------------------
 1674|  1.45k|                               CAST_bitset(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   52|  1.45k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.45k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_bitset(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|  1.45k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.45k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1675|  1.45k|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1676|  1.45k|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  2.90k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1677|  1.45k|            return result;
 1678|       |
 1679|  4.85k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  4.85k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  4.85k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  4.85k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1679:9): [True: 4.85k, False: 57.5k]
  ------------------
 1680|  4.85k|            *result_type = array_array_container_ixor(
  ------------------
  |  Branch (1680:28): [True: 0, False: 4.85k]
  ------------------
 1681|  4.85k|                               CAST_array(c1), const_CAST_array(c2), &result)
  ------------------
  |  |   54|  4.85k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  4.85k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_array(c1), const_CAST_array(c2), &result)
  ------------------
  |  |   55|  4.85k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  4.85k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1682|  4.85k|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1683|  4.85k|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  9.70k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1684|  4.85k|            return result;
 1685|       |
 1686|  55.5k|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|  55.5k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  55.5k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  55.5k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1686:9): [True: 55.5k, False: 6.84k]
  ------------------
 1687|  55.5k|            *result_type = (uint8_t)run_run_container_ixor(
 1688|  55.5k|                CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   77|  55.5k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  55.5k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|  55.5k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  55.5k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1689|  55.5k|            return result;
 1690|       |
 1691|      0|        case CONTAINER_PAIR(BITSET, ARRAY):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1691:9): [True: 0, False: 62.3k]
  ------------------
 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|    103|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|    103|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    103|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    103|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1698:9): [True: 103, False: 62.2k]
  ------------------
 1699|    103|            *result_type = array_bitset_container_ixor(
  ------------------
  |  Branch (1699:28): [True: 0, False: 103]
  ------------------
 1700|    103|                               CAST_array(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   54|    103|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    103|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_array(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|    103|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    103|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1701|    103|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1702|    103|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    206|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1703|    103|            return result;
 1704|       |
 1705|     71|        case CONTAINER_PAIR(BITSET, RUN):
  ------------------
  |  |   65|     71|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|     71|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|     71|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1705:9): [True: 71, False: 62.3k]
  ------------------
 1706|     71|            *result_type = bitset_run_container_ixor(
  ------------------
  |  Branch (1706:28): [True: 0, False: 71]
  ------------------
 1707|     71|                               CAST_bitset(c1), const_CAST_run(c2), &result)
  ------------------
  |  |   52|     71|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     71|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_bitset(c1), const_CAST_run(c2), &result)
  ------------------
  |  |   78|     71|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|     71|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1708|     71|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1709|     71|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    142|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1710|       |
 1711|     71|            return result;
 1712|       |
 1713|     15|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|     15|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|     15|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|     15|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1713:9): [True: 15, False: 62.3k]
  ------------------
 1714|     15|            *result_type = run_bitset_container_ixor(
  ------------------
  |  Branch (1714:28): [True: 0, False: 15]
  ------------------
 1715|     15|                               CAST_run(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   77|     15|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     15|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_run(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|     15|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|     15|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1716|     15|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1717|     15|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|     30|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1718|     15|            return result;
 1719|       |
 1720|    290|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    290|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    290|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    290|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1720:9): [True: 290, False: 62.1k]
  ------------------
 1721|    290|            *result_type = (uint8_t)array_run_container_ixor(
 1722|    290|                CAST_array(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   54|    290|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    290|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              CAST_array(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|    290|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    290|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1723|    290|            return result;
 1724|       |
 1725|     61|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|     61|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|     61|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|     61|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1725:9): [True: 61, False: 62.3k]
  ------------------
 1726|     61|            *result_type = (uint8_t)run_array_container_ixor(
 1727|     61|                CAST_run(c1), const_CAST_array(c2), &result);
  ------------------
  |  |   77|     61|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     61|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              CAST_run(c1), const_CAST_array(c2), &result);
  ------------------
  |  |   55|     61|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|     61|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1728|     61|            return result;
 1729|       |
 1730|      0|        default:
  ------------------
  |  Branch (1730:9): [True: 0, False: 62.3k]
  ------------------
 1731|      0|            assert(false);
 1732|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1733|      0|            return NULL;
 1734|  62.3k|    }
 1735|  62.3k|}
roaring.c:container_andnot:
 1787|  6.18k|                                            uint8_t *result_type) {
 1788|  6.18k|    c1 = container_unwrap_shared(c1, &type1);
 1789|  6.18k|    c2 = container_unwrap_shared(c2, &type2);
 1790|  6.18k|    container_t *result = NULL;
 1791|  6.18k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  6.18k|#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.18k]
  ------------------
 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.39k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  2.39k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.39k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.39k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1800:9): [True: 2.39k, False: 3.79k]
  ------------------
 1801|  2.39k|            result = array_container_create();
 1802|  2.39k|            array_array_container_andnot(
 1803|  2.39k|                const_CAST_array(c1), const_CAST_array(c2), CAST_array(result));
  ------------------
  |  |   55|  2.39k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.39k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_array(c2), CAST_array(result));
  ------------------
  |  |   55|  2.39k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.39k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_array(c2), CAST_array(result));
  ------------------
  |  |   54|  2.39k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  2.39k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1804|  2.39k|            *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  2.39k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1805|  2.39k|            return result;
 1806|       |
 1807|    655|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    655|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    655|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    655|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1807:9): [True: 655, False: 5.53k]
  ------------------
 1808|    655|            if (run_container_is_full(const_CAST_run(c2))) {
  ------------------
  |  |   78|    655|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    655|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1808:17): [True: 8, False: 647]
  ------------------
 1809|      8|                result = array_container_create();
 1810|      8|                *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      8|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1811|      8|                return result;
 1812|      8|            }
 1813|    647|            *result_type = (uint8_t)run_run_container_andnot(
 1814|    647|                const_CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|    647|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    647|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|    647|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    647|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1815|    647|            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.18k]
  ------------------
 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|    519|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|    519|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    519|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    519|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1825:9): [True: 519, False: 5.66k]
  ------------------
 1826|    519|            result = array_container_create();
 1827|    519|            array_bitset_container_andnot(const_CAST_array(c1),
  ------------------
  |  |   55|    519|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    519|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1828|    519|                                          const_CAST_bitset(c2),
  ------------------
  |  |   53|    519|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    519|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1829|    519|                                          CAST_array(result));
  ------------------
  |  |   54|    519|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    519|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1830|    519|            *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    519|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1831|    519|            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.18k]
  ------------------
 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|    654|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|    654|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    654|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    654|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1846:9): [True: 654, False: 5.53k]
  ------------------
 1847|    654|            *result_type =
 1848|    654|                run_bitset_container_andnot(const_CAST_run(c1),
  ------------------
  |  |   78|    654|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    654|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1848:17): [True: 0, False: 654]
  ------------------
 1849|    654|                                            const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|    654|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    654|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1850|    654|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1851|    654|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  1.30k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1852|    654|            return result;
 1853|       |
 1854|    747|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    747|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    747|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    747|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1854:9): [True: 747, False: 5.43k]
  ------------------
 1855|    747|            if (run_container_is_full(const_CAST_run(c2))) {
  ------------------
  |  |   78|    747|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    747|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1855:17): [True: 22, False: 725]
  ------------------
 1856|     22|                result = array_container_create();
 1857|     22|                *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|     22|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1858|     22|                return result;
 1859|     22|            }
 1860|    725|            result = array_container_create();
 1861|    725|            array_run_container_andnot(const_CAST_array(c1), const_CAST_run(c2),
  ------------------
  |  |   55|    725|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    725|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          array_run_container_andnot(const_CAST_array(c1), const_CAST_run(c2),
  ------------------
  |  |   78|    725|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    725|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1862|    725|                                       CAST_array(result));
  ------------------
  |  |   54|    725|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    725|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1863|    725|            *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    725|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1864|    725|            return result;
 1865|       |
 1866|  1.21k|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|  1.21k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  1.21k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  1.21k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1866:9): [True: 1.21k, False: 4.96k]
  ------------------
 1867|  1.21k|            *result_type = (uint8_t)run_array_container_andnot(
 1868|  1.21k|                const_CAST_run(c1), const_CAST_array(c2), &result);
  ------------------
  |  |   78|  1.21k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.21k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c1), const_CAST_array(c2), &result);
  ------------------
  |  |   55|  1.21k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.21k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1869|  1.21k|            return result;
 1870|       |
 1871|      0|        default:
  ------------------
  |  Branch (1871:9): [True: 0, False: 6.18k]
  ------------------
 1872|      0|            assert(false);
 1873|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1874|      0|            return NULL;  // unreached
 1875|  6.18k|    }
 1876|  6.18k|}
roaring.c:container_iandnot:
 1891|  5.86k|                                             uint8_t *result_type) {
 1892|  5.86k|    c1 = get_writable_copy_if_shared(c1, &type1);
 1893|  5.86k|    c2 = container_unwrap_shared(c2, &type2);
 1894|  5.86k|    container_t *result = NULL;
 1895|  5.86k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  5.86k|#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: 5.86k]
  ------------------
 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.51k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  3.51k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  3.51k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  3.51k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1903:9): [True: 3.51k, False: 2.34k]
  ------------------
 1904|  3.51k|            array_array_container_iandnot(CAST_array(c1), const_CAST_array(c2));
  ------------------
  |  |   54|  3.51k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  3.51k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          array_array_container_iandnot(CAST_array(c1), const_CAST_array(c2));
  ------------------
  |  |   55|  3.51k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.51k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1905|  3.51k|            *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  3.51k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1906|  3.51k|            return c1;
 1907|       |
 1908|    412|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    412|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    412|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    412|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1908:9): [True: 412, False: 5.44k]
  ------------------
 1909|    412|            *result_type = (uint8_t)run_run_container_iandnot(
 1910|    412|                CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   77|    412|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    412|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|    412|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    412|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1911|    412|            return result;
 1912|       |
 1913|  1.14k|        case CONTAINER_PAIR(BITSET, ARRAY):
  ------------------
  |  |   65|  1.14k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  1.14k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  1.14k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1913:9): [True: 1.14k, False: 4.72k]
  ------------------
 1914|  1.14k|            *result_type = bitset_array_container_iandnot(
  ------------------
  |  Branch (1914:28): [True: 956, False: 184]
  ------------------
 1915|  1.14k|                               CAST_bitset(c1), const_CAST_array(c2), &result)
  ------------------
  |  |   52|  1.14k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.14k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_bitset(c1), const_CAST_array(c2), &result)
  ------------------
  |  |   55|  1.14k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.14k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1916|  1.14k|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|    956|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1917|  1.14k|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  1.32k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1918|  1.14k|            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: 5.86k]
  ------------------
 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: 5.86k]
  ------------------
 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: 5.86k]
  ------------------
 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|     41|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|     41|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|     41|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|     41|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1940:9): [True: 41, False: 5.82k]
  ------------------
 1941|     41|            *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|     41|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1942|     41|            array_run_container_iandnot(CAST_array(c1), const_CAST_run(c2));
  ------------------
  |  |   54|     41|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     41|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          array_run_container_iandnot(CAST_array(c1), const_CAST_run(c2));
  ------------------
  |  |   78|     41|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|     41|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1943|     41|            return c1;
 1944|       |
 1945|    753|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|    753|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    753|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    753|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1945:9): [True: 753, False: 5.10k]
  ------------------
 1946|    753|            *result_type = (uint8_t)run_array_container_iandnot(
 1947|    753|                CAST_run(c1), const_CAST_array(c2), &result);
  ------------------
  |  |   77|    753|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    753|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              CAST_run(c1), const_CAST_array(c2), &result);
  ------------------
  |  |   55|    753|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    753|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1948|    753|            return result;
 1949|       |
 1950|      0|        default:
  ------------------
  |  Branch (1950:9): [True: 0, False: 5.86k]
  ------------------
 1951|      0|            assert(false);
 1952|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1953|      0|            return NULL;
 1954|  5.86k|    }
 1955|  5.86k|}
roaring.c:container_rank:
 2209|  6.31k|                                 uint16_t x) {
 2210|  6.31k|    c = container_unwrap_shared(c, &type);
 2211|  6.31k|    switch (type) {
 2212|      0|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2212:9): [True: 0, False: 6.31k]
  ------------------
 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.75k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  3.75k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2214:9): [True: 3.75k, False: 2.55k]
  ------------------
 2215|  3.75k|            return array_container_rank(const_CAST_array(c), x);
  ------------------
  |  |   55|  3.75k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.75k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2216|  2.55k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  2.55k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2216:9): [True: 2.55k, False: 3.75k]
  ------------------
 2217|  2.55k|            return run_container_rank(const_CAST_run(c), x);
  ------------------
  |  |   78|  2.55k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.55k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2218|      0|        default:
  ------------------
  |  Branch (2218:9): [True: 0, False: 6.31k]
  ------------------
 2219|      0|            assert(false);
 2220|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2221|  6.31k|    }
 2222|  6.31k|    assert(false);
 2223|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2224|      0|    return false;
 2225|  6.31k|}
roaring.c:container_shrink_to_fit:
  279|  6.31k|static inline int container_shrink_to_fit(container_t *c, uint8_t type) {
  280|  6.31k|    c = container_mutable_unwrap_shared(c, &type);
  281|  6.31k|    switch (type) {
  ------------------
  |  Branch (281:13): [True: 6.31k, False: 0]
  ------------------
  282|      0|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (282:9): [True: 0, False: 6.31k]
  ------------------
  283|      0|            return 0;  // no shrinking possible
  284|  3.75k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  3.75k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (284:9): [True: 3.75k, False: 2.55k]
  ------------------
  285|  3.75k|            return array_container_shrink_to_fit(CAST_array(c));
  ------------------
  |  |   54|  3.75k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  3.75k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  286|  2.55k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  2.55k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (286:9): [True: 2.55k, False: 3.75k]
  ------------------
  287|  2.55k|            return run_container_shrink_to_fit(CAST_run(c));
  ------------------
  |  |   77|  2.55k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  2.55k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  288|  6.31k|    }
  289|  6.31k|    assert(false);
  290|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  291|      0|    return 0;  // unreached
  292|  6.31k|}
roaring.c:container_iterate:
 1964|  64.0k|                                     void *ptr) {
 1965|  64.0k|    c = container_unwrap_shared(c, &type);
 1966|  64.0k|    switch (type) {
 1967|  1.56k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  1.56k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (1967:9): [True: 1.56k, False: 62.4k]
  ------------------
 1968|  1.56k|            return bitset_container_iterate(const_CAST_bitset(c), base,
  ------------------
  |  |   53|  1.56k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.56k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1969|  1.56k|                                            iterator, ptr);
 1970|  6.33k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  6.33k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (1970:9): [True: 6.33k, False: 57.6k]
  ------------------
 1971|  6.33k|            return array_container_iterate(const_CAST_array(c), base, iterator,
  ------------------
  |  |   55|  6.33k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  6.33k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1972|  6.33k|                                           ptr);
 1973|  56.1k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  56.1k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (1973:9): [True: 56.1k, False: 7.90k]
  ------------------
 1974|  56.1k|            return run_container_iterate(const_CAST_run(c), base, iterator,
  ------------------
  |  |   78|  56.1k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  56.1k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1975|  56.1k|                                         ptr);
 1976|      0|        default:
  ------------------
  |  Branch (1976:9): [True: 0, False: 64.0k]
  ------------------
 1977|      0|            assert(false);
 1978|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1979|  64.0k|    }
 1980|  64.0k|    assert(false);
 1981|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1982|      0|    return false;
 1983|  64.0k|}
roaring.c:container_maximum:
 2171|  12.5k|static inline uint16_t container_maximum(const container_t *c, uint8_t type) {
 2172|  12.5k|    c = container_unwrap_shared(c, &type);
 2173|  12.5k|    switch (type) {
 2174|  2.44k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  2.44k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2174:9): [True: 2.44k, False: 10.0k]
  ------------------
 2175|  2.44k|            return bitset_container_maximum(const_CAST_bitset(c));
  ------------------
  |  |   53|  2.44k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.44k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2176|  8.76k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  8.76k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2176:9): [True: 8.76k, False: 3.73k]
  ------------------
 2177|  8.76k|            return array_container_maximum(const_CAST_array(c));
  ------------------
  |  |   55|  8.76k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  8.76k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2178|  1.29k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  1.29k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2178:9): [True: 1.29k, False: 11.2k]
  ------------------
 2179|  1.29k|            return run_container_maximum(const_CAST_run(c));
  ------------------
  |  |   78|  1.29k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.29k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2180|      0|        default:
  ------------------
  |  Branch (2180:9): [True: 0, False: 12.5k]
  ------------------
 2181|      0|            assert(false);
 2182|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2183|  12.5k|    }
 2184|  12.5k|    assert(false);
 2185|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2186|      0|    return false;
 2187|  12.5k|}
roaring.c:container_equals:
  620|  78.0k|                                    const container_t *c2, uint8_t type2) {
  621|  78.0k|    c1 = container_unwrap_shared(c1, &type1);
  622|  78.0k|    c2 = container_unwrap_shared(c2, &type2);
  623|  78.0k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  78.0k|#define PAIR_CONTAINER_TYPES(type1, type2) (4 * (type1) + (type2))
  ------------------
  624|  67.1k|        case CONTAINER_PAIR(BITSET, BITSET):
  ------------------
  |  |   65|  67.1k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  67.1k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  67.1k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (624:9): [True: 67.1k, False: 10.8k]
  ------------------
  625|  67.1k|            return bitset_container_equals(const_CAST_bitset(c1),
  ------------------
  |  |   53|  67.1k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  67.1k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  626|  67.1k|                                           const_CAST_bitset(c2));
  ------------------
  |  |   53|  67.1k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  67.1k|#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: 78.0k]
  ------------------
  629|      0|            return run_container_equals_bitset(const_CAST_run(c2),
  ------------------
  |  |   78|      0|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  630|      0|                                               const_CAST_bitset(c1));
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  631|       |
  632|      0|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (632:9): [True: 0, False: 78.0k]
  ------------------
  633|      0|            return run_container_equals_bitset(const_CAST_run(c1),
  ------------------
  |  |   78|      0|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  634|      0|                                               const_CAST_bitset(c2));
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  635|       |
  636|      0|        case CONTAINER_PAIR(BITSET, ARRAY):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (636:9): [True: 0, False: 78.0k]
  ------------------
  637|       |            // java would always return false?
  638|      0|            return array_container_equal_bitset(const_CAST_array(c2),
  ------------------
  |  |   55|      0|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  639|      0|                                                const_CAST_bitset(c1));
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  640|       |
  641|    476|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|    476|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    476|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    476|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (641:9): [True: 476, False: 77.6k]
  ------------------
  642|       |            // java would always return false?
  643|    476|            return array_container_equal_bitset(const_CAST_array(c1),
  ------------------
  |  |   55|    476|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    476|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  644|    476|                                                const_CAST_bitset(c2));
  ------------------
  |  |   53|    476|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    476|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  645|       |
  646|    572|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    572|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    572|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    572|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (646:9): [True: 572, False: 77.5k]
  ------------------
  647|    572|            return run_container_equals_array(const_CAST_run(c2),
  ------------------
  |  |   78|    572|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    572|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  648|    572|                                              const_CAST_array(c1));
  ------------------
  |  |   55|    572|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    572|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  649|       |
  650|    274|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|    274|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    274|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    274|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (650:9): [True: 274, False: 77.8k]
  ------------------
  651|    274|            return run_container_equals_array(const_CAST_run(c1),
  ------------------
  |  |   78|    274|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    274|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  652|    274|                                              const_CAST_array(c2));
  ------------------
  |  |   55|    274|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    274|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  653|       |
  654|  9.44k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  9.44k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  9.44k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  9.44k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (654:9): [True: 9.44k, False: 68.6k]
  ------------------
  655|  9.44k|            return array_container_equals(const_CAST_array(c1),
  ------------------
  |  |   55|  9.44k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  9.44k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  656|  9.44k|                                          const_CAST_array(c2));
  ------------------
  |  |   55|  9.44k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  9.44k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  657|       |
  658|    120|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    120|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    120|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    120|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (658:9): [True: 120, False: 77.9k]
  ------------------
  659|    120|            return run_container_equals(const_CAST_run(c1), const_CAST_run(c2));
  ------------------
  |  |   78|    120|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    120|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          return run_container_equals(const_CAST_run(c1), const_CAST_run(c2));
  ------------------
  |  |   78|    120|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    120|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  660|       |
  661|      0|        default:
  ------------------
  |  Branch (661:9): [True: 0, False: 78.0k]
  ------------------
  662|      0|            assert(false);
  663|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  664|      0|            return false;
  665|  78.0k|    }
  666|  78.0k|}
roaring.c:container_is_subset:
  673|  10.8k|                                       const container_t *c2, uint8_t type2) {
  674|  10.8k|    c1 = container_unwrap_shared(c1, &type1);
  675|  10.8k|    c2 = container_unwrap_shared(c2, &type2);
  676|  10.8k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  10.8k|#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: 10.8k]
  ------------------
  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: 10.8k]
  ------------------
  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: 10.8k]
  ------------------
  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: 10.8k]
  ------------------
  690|      0|            return false;  // by construction, size(c1) > size(c2)
  691|       |
  692|  2.26k|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   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))
  |  |  ------------------
  |  |  |  |   48|  2.26k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (692:9): [True: 2.26k, False: 8.54k]
  ------------------
  693|  2.26k|            return array_container_is_subset_bitset(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)
  |  |  ------------------
  ------------------
  694|  2.26k|                                                    const_CAST_bitset(c2));
  ------------------
  |  |   53|  2.26k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.26k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  695|       |
  696|  2.12k|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|  2.12k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.12k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  2.12k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (696:9): [True: 2.12k, False: 8.68k]
  ------------------
  697|  2.12k|            return array_container_is_subset_run(const_CAST_array(c1),
  ------------------
  |  |   55|  2.12k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.12k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  698|  2.12k|                                                 const_CAST_run(c2));
  ------------------
  |  |   78|  2.12k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.12k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  699|       |
  700|    409|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|    409|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    409|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    409|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (700:9): [True: 409, False: 10.3k]
  ------------------
  701|    409|            return run_container_is_subset_array(const_CAST_run(c1),
  ------------------
  |  |   78|    409|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    409|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  702|    409|                                                 const_CAST_array(c2));
  ------------------
  |  |   55|    409|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    409|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  703|       |
  704|  5.75k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  5.75k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  5.75k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  5.75k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (704:9): [True: 5.75k, False: 5.05k]
  ------------------
  705|  5.75k|            return array_container_is_subset(const_CAST_array(c1),
  ------------------
  |  |   55|  5.75k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  5.75k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  706|  5.75k|                                             const_CAST_array(c2));
  ------------------
  |  |   55|  5.75k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  5.75k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  707|       |
  708|    255|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    255|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    255|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    255|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (708:9): [True: 255, False: 10.5k]
  ------------------
  709|    255|            return run_container_is_subset(const_CAST_run(c1),
  ------------------
  |  |   78|    255|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    255|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  710|    255|                                           const_CAST_run(c2));
  ------------------
  |  |   78|    255|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    255|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  711|       |
  712|      0|        default:
  ------------------
  |  Branch (712:9): [True: 0, False: 10.8k]
  ------------------
  713|      0|            assert(false);
  714|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  715|      0|            return false;
  716|  10.8k|    }
  717|  10.8k|}
roaring.c:container_inot_range:
 2110|  6.51k|                                                uint8_t *result_type) {
 2111|  6.51k|    c = get_writable_copy_if_shared(c, &type);
 2112|  6.51k|    container_t *result = NULL;
 2113|  6.51k|    switch (type) {
 2114|  1.27k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  1.27k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2114:9): [True: 1.27k, False: 5.23k]
  ------------------
 2115|  1.27k|            *result_type = bitset_container_negation_range_inplace(
  ------------------
  |  Branch (2115:28): [True: 1.24k, False: 35]
  ------------------
 2116|  1.27k|                               CAST_bitset(c), range_start, range_end, &result)
  ------------------
  |  |   52|  1.27k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.27k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2117|  1.27k|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|  1.24k|#define BITSET_CONTAINER_TYPE 1
  ------------------
 2118|  1.27k|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  1.31k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 2119|  1.27k|            return result;
 2120|  3.58k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  3.58k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2120:9): [True: 3.58k, False: 2.93k]
  ------------------
 2121|  3.58k|            *result_type = array_container_negation_range_inplace(
  ------------------
  |  Branch (2121:28): [True: 127, False: 3.45k]
  ------------------
 2122|  3.58k|                               CAST_array(c), range_start, range_end, &result)
  ------------------
  |  |   54|  3.58k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  3.58k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2123|  3.58k|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|    127|#define BITSET_CONTAINER_TYPE 1
  ------------------
 2124|  3.58k|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  7.04k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 2125|  3.58k|            return result;
 2126|  1.65k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  1.65k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2126:9): [True: 1.65k, False: 4.86k]
  ------------------
 2127|  1.65k|            *result_type = (uint8_t)run_container_negation_range_inplace(
 2128|  1.65k|                CAST_run(c), range_start, range_end, &result);
  ------------------
  |  |   77|  1.65k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.65k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2129|  1.65k|            return result;
 2130|       |
 2131|      0|        default:
  ------------------
  |  Branch (2131:9): [True: 0, False: 6.51k]
  ------------------
 2132|      0|            assert(false);
 2133|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2134|  6.51k|    }
 2135|  6.51k|    assert(false);
 2136|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2137|      0|    return NULL;
 2138|  6.51k|}
roaring.c:container_inot:
 2076|  6.47k|                                          uint8_t *result_type) {
 2077|  6.47k|    c = get_writable_copy_if_shared(c, &type);
 2078|  6.47k|    container_t *result = NULL;
 2079|  6.47k|    switch (type) {
 2080|     74|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|     74|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2080:9): [True: 74, False: 6.40k]
  ------------------
 2081|     74|            *result_type =
 2082|     74|                bitset_container_negation_inplace(CAST_bitset(c), &result)
  ------------------
  |  |   52|     74|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     74|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (2082:17): [True: 30, False: 44]
  ------------------
 2083|     74|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|     30|#define BITSET_CONTAINER_TYPE 1
  ------------------
 2084|     74|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    118|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 2085|     74|            return result;
 2086|    153|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|    153|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2086:9): [True: 153, False: 6.32k]
  ------------------
 2087|       |            // will never be inplace
 2088|    153|            result = bitset_container_create();
 2089|    153|            *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|    153|#define BITSET_CONTAINER_TYPE 1
  ------------------
 2090|    153|            array_container_negation(CAST_array(c), CAST_bitset(result));
  ------------------
  |  |   54|    153|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    153|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          array_container_negation(CAST_array(c), CAST_bitset(result));
  ------------------
  |  |   52|    153|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    153|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2091|    153|            array_container_free(CAST_array(c));
  ------------------
  |  |   54|    153|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    153|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2092|    153|            return result;
 2093|  6.24k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  6.24k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2093:9): [True: 6.24k, False: 227]
  ------------------
 2094|  6.24k|            *result_type =
 2095|  6.24k|                (uint8_t)run_container_negation_inplace(CAST_run(c), &result);
  ------------------
  |  |   77|  6.24k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  6.24k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2096|  6.24k|            return result;
 2097|       |
 2098|      0|        default:
  ------------------
  |  Branch (2098:9): [True: 0, False: 6.47k]
  ------------------
 2099|      0|            assert(false);
 2100|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2101|  6.47k|    }
 2102|  6.47k|    assert(false);
 2103|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2104|      0|    return NULL;
 2105|  6.47k|}
roaring.c:container_unwrap_shared:
  106|  1.09M|    const container_t *candidate_shared_container, uint8_t *type) {
  107|  1.09M|    if (*type == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|  1.09M|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (107:9): [True: 0, False: 1.09M]
  ------------------
  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.09M|    } else {
  112|  1.09M|        return candidate_shared_container;
  113|  1.09M|    }
  114|  1.09M|}
roaring.c:container_mutable_unwrap_shared:
  118|  6.31k|                                                           uint8_t *type) {
  119|  6.31k|    if (*type == SHARED_CONTAINER_TYPE) {  // the passed in container is shared
  ------------------
  |  |   51|  6.31k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (119:9): [True: 0, False: 6.31k]
  ------------------
  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.31k|    } else {
  124|  6.31k|        return c;  // wasn't shared, so return as-is
  125|  6.31k|    }
  126|  6.31k|}
roaring.c:container_minimum:
 2189|  6.26k|static inline uint16_t container_minimum(const container_t *c, uint8_t type) {
 2190|  6.26k|    c = container_unwrap_shared(c, &type);
 2191|  6.26k|    switch (type) {
 2192|  1.18k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  1.18k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2192:9): [True: 1.18k, False: 5.08k]
  ------------------
 2193|  1.18k|            return bitset_container_minimum(const_CAST_bitset(c));
  ------------------
  |  |   53|  1.18k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.18k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2194|  3.65k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  3.65k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2194:9): [True: 3.65k, False: 2.61k]
  ------------------
 2195|  3.65k|            return array_container_minimum(const_CAST_array(c));
  ------------------
  |  |   55|  3.65k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.65k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2196|  1.43k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  1.43k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2196:9): [True: 1.43k, False: 4.83k]
  ------------------
 2197|  1.43k|            return run_container_minimum(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)
  |  |  ------------------
  ------------------
 2198|      0|        default:
  ------------------
  |  Branch (2198:9): [True: 0, False: 6.26k]
  ------------------
 2199|      0|            assert(false);
 2200|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2201|  6.26k|    }
 2202|  6.26k|    assert(false);
 2203|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2204|      0|    return false;
 2205|  6.26k|}
roaring.c:container_select:
 2150|  6.31k|                                    uint32_t *element) {
 2151|  6.31k|    c = container_unwrap_shared(c, &type);
 2152|  6.31k|    switch (type) {
 2153|      0|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2153:9): [True: 0, False: 6.31k]
  ------------------
 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.75k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  3.75k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2156:9): [True: 3.75k, False: 2.55k]
  ------------------
 2157|  3.75k|            return array_container_select(const_CAST_array(c), start_rank, rank,
  ------------------
  |  |   55|  3.75k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.75k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2158|  3.75k|                                          element);
 2159|  2.55k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  2.55k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2159:9): [True: 2.55k, False: 3.75k]
  ------------------
 2160|  2.55k|            return run_container_select(const_CAST_run(c), start_rank, rank,
  ------------------
  |  |   78|  2.55k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.55k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2161|  2.55k|                                        element);
 2162|      0|        default:
  ------------------
  |  Branch (2162:9): [True: 0, False: 6.31k]
  ------------------
 2163|      0|            assert(false);
 2164|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2165|  6.31k|    }
 2166|  6.31k|    assert(false);
 2167|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2168|      0|    return false;
 2169|  6.31k|}
roaring.c:container_intersect:
  865|  6.18k|                                       const container_t *c2, uint8_t type2) {
  866|  6.18k|    c1 = container_unwrap_shared(c1, &type1);
  867|  6.18k|    c2 = container_unwrap_shared(c2, &type2);
  868|  6.18k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  6.18k|#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.18k]
  ------------------
  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.39k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  2.39k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.39k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.39k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (873:9): [True: 2.39k, False: 3.79k]
  ------------------
  874|  2.39k|            return array_container_intersect(const_CAST_array(c1),
  ------------------
  |  |   55|  2.39k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.39k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  875|  2.39k|                                             const_CAST_array(c2));
  ------------------
  |  |   55|  2.39k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.39k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  876|       |
  877|    655|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    655|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    655|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    655|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (877:9): [True: 655, False: 5.53k]
  ------------------
  878|    655|            return run_container_intersect(const_CAST_run(c1),
  ------------------
  |  |   78|    655|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    655|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  879|    655|                                           const_CAST_run(c2));
  ------------------
  |  |   78|    655|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    655|#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.18k]
  ------------------
  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|    519|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|    519|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    519|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    519|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (885:9): [True: 519, False: 5.66k]
  ------------------
  886|    519|            return array_bitset_container_intersect(const_CAST_array(c1),
  ------------------
  |  |   55|    519|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    519|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  887|    519|                                                    const_CAST_bitset(c2));
  ------------------
  |  |   53|    519|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    519|#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.18k]
  ------------------
  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|    654|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|    654|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    654|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    654|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (893:9): [True: 654, False: 5.53k]
  ------------------
  894|    654|            return run_bitset_container_intersect(const_CAST_run(c1),
  ------------------
  |  |   78|    654|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    654|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  895|    654|                                                  const_CAST_bitset(c2));
  ------------------
  |  |   53|    654|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    654|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  896|       |
  897|    747|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    747|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    747|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    747|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (897:9): [True: 747, False: 5.43k]
  ------------------
  898|    747|            return array_run_container_intersect(const_CAST_array(c1),
  ------------------
  |  |   55|    747|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    747|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  899|    747|                                                 const_CAST_run(c2));
  ------------------
  |  |   78|    747|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    747|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  900|       |
  901|  1.21k|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|  1.21k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  1.21k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  1.21k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (901:9): [True: 1.21k, False: 4.96k]
  ------------------
  902|  1.21k|            return array_run_container_intersect(const_CAST_array(c2),
  ------------------
  |  |   55|  1.21k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.21k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  903|  1.21k|                                                 const_CAST_run(c1));
  ------------------
  |  |   78|  1.21k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.21k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  904|       |
  905|      0|        default:
  ------------------
  |  Branch (905:9): [True: 0, False: 6.18k]
  ------------------
  906|      0|            assert(false);
  907|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  908|      0|            return 0;
  909|  6.18k|    }
  910|  6.18k|}
roaring.c:container_and_cardinality:
  814|  24.7k|                                            uint8_t type2) {
  815|  24.7k|    c1 = container_unwrap_shared(c1, &type1);
  816|  24.7k|    c2 = container_unwrap_shared(c2, &type2);
  817|  24.7k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  24.7k|#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: 24.7k]
  ------------------
  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.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 (822:9): [True: 9.56k, False: 15.1k]
  ------------------
  823|  9.56k|            return array_container_intersection_cardinality(
  824|  9.56k|                const_CAST_array(c1), 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)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), 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)
  |  |  ------------------
  ------------------
  825|       |
  826|  2.62k|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|  2.62k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  2.62k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  2.62k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (826:9): [True: 2.62k, False: 22.1k]
  ------------------
  827|  2.62k|            return run_container_intersection_cardinality(const_CAST_run(c1),
  ------------------
  |  |   78|  2.62k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.62k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  828|  2.62k|                                                          const_CAST_run(c2));
  ------------------
  |  |   78|  2.62k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.62k|#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: 24.7k]
  ------------------
  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.07k|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|  2.07k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.07k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  2.07k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (834:9): [True: 2.07k, False: 22.6k]
  ------------------
  835|  2.07k|            return array_bitset_container_intersection_cardinality(
  836|  2.07k|                const_CAST_array(c1), const_CAST_bitset(c2));
  ------------------
  |  |   55|  2.07k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.07k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_bitset(c2));
  ------------------
  |  |   53|  2.07k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.07k|#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: 24.7k]
  ------------------
  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.61k|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|  2.61k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  2.61k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  2.61k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (842:9): [True: 2.61k, False: 22.1k]
  ------------------
  843|  2.61k|            return run_bitset_container_intersection_cardinality(
  844|  2.61k|                const_CAST_run(c1), const_CAST_bitset(c2));
  ------------------
  |  |   78|  2.61k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.61k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c1), const_CAST_bitset(c2));
  ------------------
  |  |   53|  2.61k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.61k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  845|       |
  846|  2.98k|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|  2.98k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.98k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  2.98k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (846:9): [True: 2.98k, False: 21.7k]
  ------------------
  847|  2.98k|            return array_run_container_intersection_cardinality(
  848|  2.98k|                const_CAST_array(c1), const_CAST_run(c2));
  ------------------
  |  |   55|  2.98k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.98k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_run(c2));
  ------------------
  |  |   78|  2.98k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.98k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  849|       |
  850|  4.87k|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|  4.87k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  4.87k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  4.87k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (850:9): [True: 4.87k, False: 19.8k]
  ------------------
  851|  4.87k|            return array_run_container_intersection_cardinality(
  852|  4.87k|                const_CAST_array(c2), const_CAST_run(c1));
  ------------------
  |  |   55|  4.87k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  4.87k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c2), const_CAST_run(c1));
  ------------------
  |  |   78|  4.87k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  4.87k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  853|       |
  854|      0|        default:
  ------------------
  |  Branch (854:9): [True: 0, False: 24.7k]
  ------------------
  855|      0|            assert(false);
  856|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  857|      0|            return 0;
  858|  24.7k|    }
  859|  24.7k|}
roaring.c:container_contains_range:
  596|    487|) {
  597|    487|    c = container_unwrap_shared(c, &typecode);
  598|    487|    switch (typecode) {
  599|    206|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|    206|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (599:9): [True: 206, False: 281]
  ------------------
  600|    206|            return bitset_container_get_range(const_CAST_bitset(c), range_start,
  ------------------
  |  |   53|    206|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    206|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  601|    206|                                              range_end);
  602|     96|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|     96|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (602:9): [True: 96, False: 391]
  ------------------
  603|     96|            return array_container_contains_range(const_CAST_array(c),
  ------------------
  |  |   55|     96|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|     96|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  604|     96|                                                  range_start, range_end);
  605|    185|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|    185|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (605:9): [True: 185, False: 302]
  ------------------
  606|    185|            return run_container_contains_range(const_CAST_run(c), range_start,
  ------------------
  |  |   78|    185|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    185|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  607|    185|                                                range_end);
  608|      0|        default:
  ------------------
  |  Branch (608:9): [True: 0, False: 487]
  ------------------
  609|      0|            assert(false);
  610|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  611|      0|            return false;
  612|    487|    }
  613|    487|}
roaring_array.c:container_to_uint32_array:
  465|  63.9k|                                            uint8_t typecode, uint32_t base) {
  466|  63.9k|    c = container_unwrap_shared(c, &typecode);
  467|  63.9k|    switch (typecode) {
  ------------------
  |  Branch (467:13): [True: 63.9k, False: 0]
  ------------------
  468|  1.41k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  1.41k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (468:9): [True: 1.41k, False: 62.4k]
  ------------------
  469|  1.41k|            return bitset_container_to_uint32_array(output,
  470|  1.41k|                                                    const_CAST_bitset(c), base);
  ------------------
  |  |   53|  1.41k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.41k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  471|  5.78k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  5.78k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (471:9): [True: 5.78k, False: 58.1k]
  ------------------
  472|  5.78k|            return array_container_to_uint32_array(output, const_CAST_array(c),
  ------------------
  |  |   55|  5.78k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  5.78k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  473|  5.78k|                                                   base);
  474|  56.7k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  56.7k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (474:9): [True: 56.7k, False: 7.20k]
  ------------------
  475|  56.7k|            return run_container_to_uint32_array(output, const_CAST_run(c),
  ------------------
  |  |   78|  56.7k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  56.7k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  476|  56.7k|                                                 base);
  477|  63.9k|    }
  478|  63.9k|    assert(false);
  479|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  480|      0|    return 0;  // unreached
  481|  63.9k|}
roaring_array.c:container_unwrap_shared:
  106|   366k|    const container_t *candidate_shared_container, uint8_t *type) {
  107|   366k|    if (*type == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|   366k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (107:9): [True: 0, False: 366k]
  ------------------
  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|   366k|    } else {
  112|   366k|        return candidate_shared_container;
  113|   366k|    }
  114|   366k|}
roaring_array.c:get_container_type:
  129|   154k|static inline uint8_t get_container_type(const container_t *c, uint8_t type) {
  130|   154k|    if (type == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|   154k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (130:9): [True: 0, False: 154k]
  ------------------
  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|   154k|    } else {
  133|   154k|        return type;
  134|   154k|    }
  135|   154k|}
roaring_array.c:container_size_in_bytes:
  403|   154k|                                              uint8_t typecode) {
  404|   154k|    c = container_unwrap_shared(c, &typecode);
  405|   154k|    switch (typecode) {
  ------------------
  |  Branch (405:13): [True: 154k, False: 0]
  ------------------
  406|   134k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|   134k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (406:9): [True: 134k, False: 20.2k]
  ------------------
  407|   134k|            return bitset_container_size_in_bytes(const_CAST_bitset(c));
  ------------------
  |  |   53|   134k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|   134k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  408|  17.7k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  17.7k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (408:9): [True: 17.7k, False: 136k]
  ------------------
  409|  17.7k|            return array_container_size_in_bytes(const_CAST_array(c));
  ------------------
  |  |   55|  17.7k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  17.7k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  410|  2.55k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  2.55k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (410:9): [True: 2.55k, False: 152k]
  ------------------
  411|  2.55k|            return run_container_size_in_bytes(const_CAST_run(c));
  ------------------
  |  |   78|  2.55k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.55k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  412|   154k|    }
  413|   154k|    assert(false);
  414|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  415|      0|    return 0;  // unreached
  416|   154k|}
roaring_array.c:container_get_cardinality:
  244|  74.1k|                                            uint8_t typecode) {
  245|  74.1k|    c = container_unwrap_shared(c, &typecode);
  246|  74.1k|    switch (typecode) {
  ------------------
  |  Branch (246:13): [True: 74.1k, False: 0]
  ------------------
  247|  67.1k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  67.1k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (247:9): [True: 67.1k, False: 6.97k]
  ------------------
  248|  67.1k|            return bitset_container_cardinality(const_CAST_bitset(c));
  ------------------
  |  |   53|  67.1k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  67.1k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  249|  6.97k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  6.97k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (249:9): [True: 6.97k, False: 67.1k]
  ------------------
  250|  6.97k|            return array_container_cardinality(const_CAST_array(c));
  ------------------
  |  |   55|  6.97k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  6.97k|#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: 74.1k]
  ------------------
  252|      0|            return run_container_cardinality(const_CAST_run(c));
  ------------------
  |  |   78|      0|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  253|  74.1k|    }
  254|  74.1k|    assert(false);
  255|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  256|      0|    return 0;  // unreached
  257|  74.1k|}
roaring_array.c:container_write:
  382|  74.1k|                                      char *buf) {
  383|  74.1k|    c = container_unwrap_shared(c, &typecode);
  384|  74.1k|    switch (typecode) {
  ------------------
  |  Branch (384:13): [True: 74.1k, False: 0]
  ------------------
  385|  67.1k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  67.1k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (385:9): [True: 67.1k, False: 6.97k]
  ------------------
  386|  67.1k|            return bitset_container_write(const_CAST_bitset(c), buf);
  ------------------
  |  |   53|  67.1k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  67.1k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  387|  6.97k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  6.97k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (387:9): [True: 6.97k, False: 67.1k]
  ------------------
  388|  6.97k|            return array_container_write(const_CAST_array(c), buf);
  ------------------
  |  |   55|  6.97k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  6.97k|#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: 74.1k]
  ------------------
  390|      0|            return run_container_write(const_CAST_run(c), buf);
  ------------------
  |  |   78|      0|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  391|  74.1k|    }
  392|  74.1k|    assert(false);
  393|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  394|      0|    return 0;  // unreached
  395|  74.1k|}
containers.c:container_unwrap_shared:
  106|  6.48k|    const container_t *candidate_shared_container, uint8_t *type) {
  107|  6.48k|    if (*type == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|  6.48k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (107:9): [True: 0, False: 6.48k]
  ------------------
  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.48k|    } else {
  112|  6.48k|        return candidate_shared_container;
  113|  6.48k|    }
  114|  6.48k|}
containers.c:container_maximum:
 2171|  6.21k|static inline uint16_t container_maximum(const container_t *c, uint8_t type) {
 2172|  6.21k|    c = container_unwrap_shared(c, &type);
 2173|  6.21k|    switch (type) {
 2174|  1.78k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  1.78k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2174:9): [True: 1.78k, False: 4.42k]
  ------------------
 2175|  1.78k|            return bitset_container_maximum(const_CAST_bitset(c));
  ------------------
  |  |   53|  1.78k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.78k|#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.78k]
  ------------------
 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.21k]
  ------------------
 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.21k]
  ------------------
 2181|      0|            assert(false);
 2182|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2183|  6.21k|    }
 2184|  6.21k|    assert(false);
 2185|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2186|      0|    return false;
 2187|  6.21k|}

run_container_contains:
  260|  9.03k|inline bool run_container_contains(const run_container_t *run, uint16_t pos) {
  261|  9.03k|    int32_t index = interleavedBinarySearch(run->runs, run->n_runs, pos);
  262|  9.03k|    if (index >= 0) return true;
  ------------------
  |  Branch (262:9): [True: 6.59k, False: 2.44k]
  ------------------
  263|  2.44k|    index = -index - 2;  // points to preceding value, possibly -1
  264|  2.44k|    if (index != -1) {   // possible match
  ------------------
  |  Branch (264:9): [True: 845, False: 1.59k]
  ------------------
  265|    845|        int32_t offset = pos - run->runs[index].value;
  266|    845|        int32_t le = run->runs[index].length;
  267|    845|        if (offset <= le) return true;
  ------------------
  |  Branch (267:13): [True: 572, False: 273]
  ------------------
  268|    845|    }
  269|  1.86k|    return false;
  270|  2.44k|}
interleavedBinarySearch:
  112|   413k|                                       uint16_t ikey) {
  113|   413k|    int32_t low = 0;
  114|   413k|    int32_t high = lenarray - 1;
  115|  1.94M|    while (low <= high) {
  ------------------
  |  Branch (115:12): [True: 1.71M, False: 231k]
  ------------------
  116|  1.71M|        int32_t middleIndex = (low + high) >> 1;
  117|  1.71M|        uint16_t middleValue = array[middleIndex].value;
  118|  1.71M|        if (middleValue < ikey) {
  ------------------
  |  Branch (118:13): [True: 676k, False: 1.03M]
  ------------------
  119|   676k|            low = middleIndex + 1;
  120|  1.03M|        } else if (middleValue > ikey) {
  ------------------
  |  Branch (120:20): [True: 857k, False: 182k]
  ------------------
  121|   857k|            high = middleIndex - 1;
  122|   857k|        } else {
  123|   182k|            return middleIndex;
  124|   182k|        }
  125|  1.71M|    }
  126|   231k|    return -(low + 1);
  127|   413k|}
run_container_minimum:
  563|  15.4k|inline uint16_t run_container_minimum(const run_container_t *run) {
  564|  15.4k|    if (run->n_runs == 0) return 0;
  ------------------
  |  Branch (564:9): [True: 0, False: 15.4k]
  ------------------
  565|  15.4k|    return run->runs[0].value;
  566|  15.4k|}
run_container_maximum:
  569|  14.9k|inline uint16_t run_container_maximum(const run_container_t *run) {
  570|  14.9k|    if (run->n_runs == 0) return 0;
  ------------------
  |  Branch (570:9): [True: 0, False: 14.9k]
  ------------------
  571|  14.9k|    return run->runs[run->n_runs - 1].value + run->runs[run->n_runs - 1].length;
  572|  14.9k|}
roaring.c:run_container_create_range:
  532|  83.8k|                                                          uint32_t stop) {
  533|  83.8k|    run_container_t *rc = run_container_create_given_capacity(1);
  534|  83.8k|    if (rc) {
  ------------------
  |  Branch (534:9): [True: 83.8k, False: 0]
  ------------------
  535|  83.8k|        rle16_t r;
  536|  83.8k|        r.value = (uint16_t)start;
  537|  83.8k|        r.length = (uint16_t)(stop - start - 1);
  538|  83.8k|        run_container_append_first(rc, r);
  539|  83.8k|    }
  540|  83.8k|    return rc;
  541|  83.8k|}
roaring.c:run_container_append_first:
  351|  83.8k|                                                 rle16_t vl) {
  352|  83.8k|    run->runs[run->n_runs] = vl;
  353|  83.8k|    run->n_runs++;
  354|  83.8k|    return vl;
  355|  83.8k|}
roaring.c:rle16_count_greater:
  178|    470|                                          int32_t lenarray, uint16_t key) {
  179|    470|    if (lenarray == 0) return 0;
  ------------------
  |  Branch (179:9): [True: 0, False: 470]
  ------------------
  180|    470|    int32_t low = 0;
  181|    470|    int32_t high = lenarray - 1;
  182|  3.65k|    while (low <= high) {
  ------------------
  |  Branch (182:12): [True: 3.21k, False: 441]
  ------------------
  183|  3.21k|        int32_t middleIndex = (low + high) >> 1;
  184|  3.21k|        uint16_t min_value = array[middleIndex].value;
  185|  3.21k|        uint16_t max_value =
  186|  3.21k|            array[middleIndex].value + array[middleIndex].length;
  187|  3.21k|        if (max_value < key) {
  ------------------
  |  Branch (187:13): [True: 3.00k, False: 206]
  ------------------
  188|  3.00k|            low = middleIndex + 1;
  189|  3.00k|        } else if (key + UINT32_C(1) < min_value) {  // uint32 arithmetic
  ------------------
  |  Branch (189:20): [True: 177, False: 29]
  ------------------
  190|    177|            high = middleIndex - 1;
  191|    177|        } else {
  192|     29|            return lenarray - (middleIndex + 1);
  193|     29|        }
  194|  3.21k|    }
  195|    441|    return lenarray - low;
  196|    470|}
roaring.c:rle16_count_less:
  157|    470|                                       uint16_t key) {
  158|    470|    if (lenarray == 0) return 0;
  ------------------
  |  Branch (158:9): [True: 2, False: 468]
  ------------------
  159|    468|    int32_t low = 0;
  160|    468|    int32_t high = lenarray - 1;
  161|  3.09k|    while (low <= high) {
  ------------------
  |  Branch (161:12): [True: 2.87k, False: 222]
  ------------------
  162|  2.87k|        int32_t middleIndex = (low + high) >> 1;
  163|  2.87k|        uint16_t min_value = array[middleIndex].value;
  164|  2.87k|        uint16_t max_value =
  165|  2.87k|            array[middleIndex].value + array[middleIndex].length;
  166|  2.87k|        if (max_value + UINT32_C(1) < key) {  // uint32 arithmetic
  ------------------
  |  Branch (166:13): [True: 1.40k, False: 1.46k]
  ------------------
  167|  1.40k|            low = middleIndex + 1;
  168|  1.46k|        } else if (key < min_value) {
  ------------------
  |  Branch (168:20): [True: 1.21k, False: 246]
  ------------------
  169|  1.21k|            high = middleIndex - 1;
  170|  1.21k|        } else {
  171|    246|            return middleIndex;
  172|    246|        }
  173|  2.87k|    }
  174|    222|    return low;
  175|    468|}
roaring.c:run_container_add_range_nruns:
  610|    470|                                                 int32_t nruns_greater) {
  611|    470|    int32_t nruns_common = run->n_runs - nruns_less - nruns_greater;
  612|    470|    if (nruns_common == 0) {
  ------------------
  |  Branch (612:9): [True: 147, False: 323]
  ------------------
  613|    147|        makeRoomAtIndex(run, (uint16_t)nruns_less);
  614|    147|        run->runs[nruns_less].value = (uint16_t)min;
  615|    147|        run->runs[nruns_less].length = (uint16_t)(max - min);
  616|    323|    } else {
  617|    323|        uint32_t common_min = run->runs[nruns_less].value;
  618|    323|        uint32_t common_max = run->runs[nruns_less + nruns_common - 1].value +
  619|    323|                              run->runs[nruns_less + nruns_common - 1].length;
  620|    323|        uint32_t result_min = (common_min < min) ? common_min : min;
  ------------------
  |  Branch (620:31): [True: 76, False: 247]
  ------------------
  621|    323|        uint32_t result_max = (common_max > max) ? common_max : max;
  ------------------
  |  Branch (621:31): [True: 22, False: 301]
  ------------------
  622|       |
  623|    323|        run->runs[nruns_less].value = (uint16_t)result_min;
  624|    323|        run->runs[nruns_less].length = (uint16_t)(result_max - result_min);
  625|       |
  626|    323|        memmove(&(run->runs[nruns_less + 1]),
  627|    323|                &(run->runs[run->n_runs - nruns_greater]),
  628|    323|                nruns_greater * sizeof(rle16_t));
  629|    323|        run->n_runs = nruns_less + 1 + nruns_greater;
  630|    323|    }
  631|    470|}
roaring.c:makeRoomAtIndex:
  208|    868|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|    868|    if (run->n_runs + 1 > run->capacity)
  ------------------
  |  Branch (212:9): [True: 694, False: 174]
  ------------------
  213|    694|        run_container_grow(run, run->n_runs + 1, true);
  214|    868|    memmove(run->runs + 1 + index, run->runs + index,
  215|    868|            (run->n_runs - index) * sizeof(rle16_t));
  216|    868|    run->n_runs++;
  217|    868|}
roaring.c:run_container_remove_range:
  667|  1.80k|                                              uint32_t min, uint32_t max) {
  668|  1.80k|    int32_t first = rle16_find_run(run->runs, run->n_runs, (uint16_t)min);
  669|  1.80k|    int32_t last = rle16_find_run(run->runs, run->n_runs, (uint16_t)max);
  670|       |
  671|  1.80k|    if (first >= 0 && min > run->runs[first].value &&
  ------------------
  |  Branch (671:9): [True: 674, False: 1.12k]
  |  Branch (671:23): [True: 310, False: 364]
  ------------------
  672|    310|        max < ((uint32_t)run->runs[first].value +
  ------------------
  |  Branch (672:9): [True: 41, False: 269]
  ------------------
  673|    310|               (uint32_t)run->runs[first].length)) {
  674|       |        // split this run into two adjacent runs
  675|       |
  676|       |        // right subinterval
  677|     41|        makeRoomAtIndex(run, (uint16_t)(first + 1));
  678|     41|        run->runs[first + 1].value = (uint16_t)(max + 1);
  679|     41|        run->runs[first + 1].length =
  680|     41|            (uint16_t)((run->runs[first].value + run->runs[first].length) -
  681|     41|                       (max + 1));
  682|       |
  683|       |        // left subinterval
  684|     41|        run->runs[first].length =
  685|     41|            (uint16_t)((min - 1) - run->runs[first].value);
  686|       |
  687|     41|        return;
  688|     41|    }
  689|       |
  690|       |    // update left-most partial run
  691|  1.75k|    if (first >= 0) {
  ------------------
  |  Branch (691:9): [True: 633, False: 1.12k]
  ------------------
  692|    633|        if (min > run->runs[first].value) {
  ------------------
  |  Branch (692:13): [True: 269, False: 364]
  ------------------
  693|    269|            run->runs[first].length =
  694|    269|                (uint16_t)((min - 1) - run->runs[first].value);
  695|    269|            first++;
  696|    269|        }
  697|  1.12k|    } else {
  698|  1.12k|        first = -first - 1;
  699|  1.12k|    }
  700|       |
  701|       |    // update right-most run
  702|  1.75k|    if (last >= 0) {
  ------------------
  |  Branch (702:9): [True: 603, False: 1.15k]
  ------------------
  703|    603|        uint16_t run_max = run->runs[last].value + run->runs[last].length;
  704|    603|        if (run_max > max) {
  ------------------
  |  Branch (704:13): [True: 360, False: 243]
  ------------------
  705|    360|            run->runs[last].value = (uint16_t)(max + 1);
  706|    360|            run->runs[last].length = (uint16_t)(run_max - (max + 1));
  707|    360|            last--;
  708|    360|        }
  709|  1.15k|    } else {
  710|  1.15k|        last = (-last - 1) - 1;
  711|  1.15k|    }
  712|       |
  713|       |    // remove intermediate runs
  714|  1.75k|    if (first <= last) {
  ------------------
  |  Branch (714:9): [True: 171, False: 1.58k]
  ------------------
  715|    171|        run_container_shift_tail(run, run->n_runs - (last + 1),
  716|    171|                                 -(last - first + 1));
  717|    171|    }
  718|  1.75k|}
roaring.c:rle16_find_run:
  133|  3.60k|                                     uint16_t ikey) {
  134|  3.60k|    int32_t low = 0;
  135|  3.60k|    int32_t high = lenarray - 1;
  136|  15.3k|    while (low <= high) {
  ------------------
  |  Branch (136:12): [True: 13.1k, False: 2.28k]
  ------------------
  137|  13.1k|        int32_t middleIndex = (low + high) >> 1;
  138|  13.1k|        uint16_t min = array[middleIndex].value;
  139|  13.1k|        uint16_t max = array[middleIndex].value + array[middleIndex].length;
  140|  13.1k|        if (ikey > max) {
  ------------------
  |  Branch (140:13): [True: 1.82k, False: 11.2k]
  ------------------
  141|  1.82k|            low = middleIndex + 1;
  142|  11.2k|        } else if (ikey < min) {
  ------------------
  |  Branch (142:20): [True: 9.96k, False: 1.31k]
  ------------------
  143|  9.96k|            high = middleIndex - 1;
  144|  9.96k|        } else {
  145|  1.31k|            return middleIndex;
  146|  1.31k|        }
  147|  13.1k|    }
  148|  2.28k|    return -(low + 1);
  149|  3.60k|}
roaring.c:run_container_shift_tail:
  650|    171|                                            int32_t distance) {
  651|    171|    if (distance > 0) {
  ------------------
  |  Branch (651:9): [True: 0, False: 171]
  ------------------
  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|    171|    int32_t srcpos = run->n_runs - count;
  657|    171|    int32_t dstpos = srcpos + distance;
  658|    171|    memmove(&(run->runs[dstpos]), &(run->runs[srcpos]),
  659|    171|            sizeof(rle16_t) * count);
  660|    171|    run->n_runs += distance;
  661|    171|}
roaring.c:run_container_remove:
  223|  3.04k|static inline bool run_container_remove(run_container_t *run, uint16_t pos) {
  224|  3.04k|    int32_t index = interleavedBinarySearch(run->runs, run->n_runs, pos);
  225|  3.04k|    if (index >= 0) {
  ------------------
  |  Branch (225:9): [True: 1.17k, False: 1.86k]
  ------------------
  226|  1.17k|        int32_t le = run->runs[index].length;
  227|  1.17k|        if (le == 0) {
  ------------------
  |  Branch (227:13): [True: 230, False: 945]
  ------------------
  228|    230|            recoverRoomAtIndex(run, (uint16_t)index);
  229|    945|        } else {
  230|    945|            run->runs[index].value++;
  231|    945|            run->runs[index].length--;
  232|    945|        }
  233|  1.17k|        return true;
  234|  1.17k|    }
  235|  1.86k|    index = -index - 2;  // points to preceding value, possibly -1
  236|  1.86k|    if (index >= 0) {    // possible match
  ------------------
  |  Branch (236:9): [True: 890, False: 978]
  ------------------
  237|    890|        int32_t offset = pos - run->runs[index].value;
  238|    890|        int32_t le = run->runs[index].length;
  239|    890|        if (offset < le) {
  ------------------
  |  Branch (239:13): [True: 680, False: 210]
  ------------------
  240|       |            // need to break in two
  241|    680|            run->runs[index].length = (uint16_t)(offset - 1);
  242|       |            // need to insert
  243|    680|            uint16_t newvalue = pos + 1;
  244|    680|            int32_t newlength = le - offset - 1;
  245|    680|            makeRoomAtIndex(run, (uint16_t)(index + 1));
  246|    680|            run->runs[index + 1].value = newvalue;
  247|    680|            run->runs[index + 1].length = (uint16_t)newlength;
  248|    680|            return true;
  249|       |
  250|    680|        } else if (offset == le) {
  ------------------
  |  Branch (250:20): [True: 22, False: 188]
  ------------------
  251|     22|            run->runs[index].length--;
  252|     22|            return true;
  253|     22|        }
  254|    890|    }
  255|       |    // no match
  256|  1.16k|    return false;
  257|  1.86k|}
roaring.c:recoverRoomAtIndex:
  102|    230|static inline void recoverRoomAtIndex(run_container_t *run, uint16_t index) {
  103|    230|    memmove(run->runs + index, run->runs + (1 + index),
  104|    230|            (run->n_runs - index - 1) * sizeof(rle16_t));
  105|    230|    run->n_runs--;
  106|    230|}
roaring.c:run_container_nonzero_cardinality:
  309|  61.8k|    const run_container_t *run) {
  310|  61.8k|    return run->n_runs > 0;  // runs never empty
  311|  61.8k|}
roaring.c:run_container_is_full:
  394|  5.90k|static inline bool run_container_is_full(const run_container_t *run) {
  395|  5.90k|    rle16_t vl = run->runs[0];
  396|  5.90k|    return (run->n_runs == 1) && (vl.value == 0) && (vl.length == 0xFFFF);
  ------------------
  |  Branch (396:12): [True: 1.00k, False: 4.90k]
  |  Branch (396:34): [True: 779, False: 223]
  |  Branch (396:53): [True: 653, False: 126]
  ------------------
  397|  5.90k|}
roaring.c:run_container_equals:
  502|    120|                                        const run_container_t *container2) {
  503|    120|    if (container1->n_runs != container2->n_runs) {
  ------------------
  |  Branch (503:9): [True: 98, False: 22]
  ------------------
  504|     98|        return false;
  505|     98|    }
  506|     22|    return memequals(container1->runs, container2->runs,
  507|     22|                     container1->n_runs * sizeof(rle16_t));
  508|    120|}
roaring.c:run_container_contains_range:
  278|    185|                                                uint32_t pos_end) {
  279|    185|    uint32_t count = 0;
  280|    185|    int32_t index =
  281|    185|        interleavedBinarySearch(run->runs, run->n_runs, (uint16_t)pos_start);
  282|    185|    if (index < 0) {
  ------------------
  |  Branch (282:9): [True: 114, False: 71]
  ------------------
  283|    114|        index = -index - 2;
  284|    114|        if ((index == -1) ||
  ------------------
  |  Branch (284:13): [True: 13, False: 101]
  ------------------
  285|    101|            ((pos_start - run->runs[index].value) > run->runs[index].length)) {
  ------------------
  |  Branch (285:13): [True: 31, False: 70]
  ------------------
  286|     44|            return false;
  287|     44|        }
  288|    114|    }
  289|  3.07k|    for (int32_t i = index; i < run->n_runs; ++i) {
  ------------------
  |  Branch (289:29): [True: 3.01k, False: 57]
  ------------------
  290|  3.01k|        const uint32_t stop = run->runs[i].value + run->runs[i].length;
  291|  3.01k|        if (run->runs[i].value >= pos_end) break;
  ------------------
  |  Branch (291:13): [True: 18, False: 3.00k]
  ------------------
  292|  3.00k|        if (stop >= pos_end) {
  ------------------
  |  Branch (292:13): [True: 66, False: 2.93k]
  ------------------
  293|     66|            count += (((pos_end - run->runs[i].value) > 0)
  ------------------
  |  Branch (293:23): [True: 66, False: 0]
  ------------------
  294|     66|                          ? (pos_end - run->runs[i].value)
  295|     66|                          : 0);
  296|     66|            break;
  297|     66|        }
  298|  2.93k|        const uint32_t min = (stop - pos_start) > 0 ? (stop - pos_start) : 0;
  ------------------
  |  Branch (298:30): [True: 2.91k, False: 18]
  ------------------
  299|  2.93k|        count += (min < run->runs[i].length) ? min : run->runs[i].length;
  ------------------
  |  Branch (299:18): [True: 44, False: 2.89k]
  ------------------
  300|  2.93k|    }
  301|    141|    return count >= (pos_end - pos_start - 1);
  302|    185|}
roaring_array.c:run_container_size_in_bytes:
  493|  2.55k|    const run_container_t *container) {
  494|  2.55k|    return run_container_serialized_size_in_bytes(container->n_runs);
  495|  2.55k|}
roaring_array.c:run_container_serialized_size_in_bytes:
  456|  2.55k|static inline int32_t run_container_serialized_size_in_bytes(int32_t num_runs) {
  457|  2.55k|    return sizeof(uint16_t) +
  458|  2.55k|           sizeof(rle16_t) * num_runs;  // each run requires 2 2-byte entries.
  459|  2.55k|}
convert.c:run_container_serialized_size_in_bytes:
  456|   143k|static inline int32_t run_container_serialized_size_in_bytes(int32_t num_runs) {
  457|   143k|    return sizeof(uint16_t) +
  458|   143k|           sizeof(rle16_t) * num_runs;  // each run requires 2 2-byte entries.
  459|   143k|}
mixed_intersection.c:run_container_is_full:
  394|  16.9k|static inline bool run_container_is_full(const run_container_t *run) {
  395|  16.9k|    rle16_t vl = run->runs[0];
  396|  16.9k|    return (run->n_runs == 1) && (vl.value == 0) && (vl.length == 0xFFFF);
  ------------------
  |  Branch (396:12): [True: 1.25k, False: 15.6k]
  |  Branch (396:34): [True: 566, False: 692]
  |  Branch (396:53): [True: 132, False: 434]
  ------------------
  397|  16.9k|}
mixed_union.c:run_container_is_full:
  394|  2.81k|static inline bool run_container_is_full(const run_container_t *run) {
  395|  2.81k|    rle16_t vl = run->runs[0];
  396|  2.81k|    return (run->n_runs == 1) && (vl.value == 0) && (vl.length == 0xFFFF);
  ------------------
  |  Branch (396:12): [True: 305, False: 2.50k]
  |  Branch (396:34): [True: 192, False: 113]
  |  Branch (396:53): [True: 73, False: 119]
  ------------------
  397|  2.81k|}
mixed_union.c:run_container_append_first:
  351|  2.12k|                                                 rle16_t vl) {
  352|  2.12k|    run->runs[run->n_runs] = vl;
  353|  2.12k|    run->n_runs++;
  354|  2.12k|    return vl;
  355|  2.12k|}
mixed_union.c:run_container_append_value_first:
  385|    611|                                                       uint16_t val) {
  386|    611|    rle16_t newrle = CROARING_MAKE_RLE16(val, 0);
  ------------------
  |  |   60|    611|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  387|    611|    run->runs[run->n_runs] = newrle;
  388|    611|    run->n_runs++;
  389|    611|    return newrle;
  390|    611|}
mixed_union.c:run_container_append:
  332|   169k|                                        rle16_t *previousrl) {
  333|   169k|    const uint32_t previousend = previousrl->value + previousrl->length;
  334|   169k|    if (vl.value > previousend + 1) {  // we add a new one
  ------------------
  |  Branch (334:9): [True: 155k, False: 13.1k]
  ------------------
  335|   155k|        run->runs[run->n_runs] = vl;
  336|   155k|        run->n_runs++;
  337|   155k|        *previousrl = vl;
  338|   155k|    } else {
  339|  13.1k|        uint32_t newend = vl.value + vl.length + UINT32_C(1);
  340|  13.1k|        if (newend > previousend) {  // we merge
  ------------------
  |  Branch (340:13): [True: 13.1k, False: 0]
  ------------------
  341|  13.1k|            previousrl->length = (uint16_t)(newend - 1 - previousrl->value);
  342|  13.1k|            run->runs[run->n_runs - 1] = *previousrl;
  343|  13.1k|        }
  344|  13.1k|    }
  345|   169k|}
mixed_union.c:run_container_append_value:
  368|   491k|                                              rle16_t *previousrl) {
  369|   491k|    const uint32_t previousend = previousrl->value + previousrl->length;
  370|   491k|    if (val > previousend + 1) {  // we add a new one
  ------------------
  |  Branch (370:9): [True: 52.2k, False: 439k]
  ------------------
  371|  52.2k|        *previousrl = CROARING_MAKE_RLE16(val, 0);
  ------------------
  |  |   60|  52.2k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  372|  52.2k|        run->runs[run->n_runs] = *previousrl;
  373|  52.2k|        run->n_runs++;
  374|   439k|    } else if (val == previousend + 1) {  // we merge
  ------------------
  |  Branch (374:16): [True: 137k, False: 301k]
  ------------------
  375|   137k|        previousrl->length++;
  376|   137k|        run->runs[run->n_runs - 1] = *previousrl;
  377|   137k|    }
  378|   491k|}
run.c:run_container_is_full:
  394|   125k|static inline bool run_container_is_full(const run_container_t *run) {
  395|   125k|    rle16_t vl = run->runs[0];
  396|   125k|    return (run->n_runs == 1) && (vl.value == 0) && (vl.length == 0xFFFF);
  ------------------
  |  Branch (396:12): [True: 111k, False: 14.1k]
  |  Branch (396:34): [True: 109k, False: 1.78k]
  |  Branch (396:53): [True: 107k, False: 2.20k]
  ------------------
  397|   125k|}
run.c:run_container_serialized_size_in_bytes:
  456|     49|static inline int32_t run_container_serialized_size_in_bytes(int32_t num_runs) {
  457|     49|    return sizeof(uint16_t) +
  458|     49|           sizeof(rle16_t) * num_runs;  // each run requires 2 2-byte entries.
  459|     49|}
run.c:recoverRoomAtIndex:
  102|  6.86k|static inline void recoverRoomAtIndex(run_container_t *run, uint16_t index) {
  103|  6.86k|    memmove(run->runs + index, run->runs + (1 + index),
  104|  6.86k|            (run->n_runs - index - 1) * sizeof(rle16_t));
  105|  6.86k|    run->n_runs--;
  106|  6.86k|}
run.c:makeRoomAtIndex:
  208|  42.9k|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|  42.9k|    if (run->n_runs + 1 > run->capacity)
  ------------------
  |  Branch (212:9): [True: 2.45k, False: 40.5k]
  ------------------
  213|  2.45k|        run_container_grow(run, run->n_runs + 1, true);
  214|  42.9k|    memmove(run->runs + 1 + index, run->runs + index,
  215|  42.9k|            (run->n_runs - index) * sizeof(rle16_t));
  216|  42.9k|    run->n_runs++;
  217|  42.9k|}
run.c:run_container_append_first:
  351|  2.28k|                                                 rle16_t vl) {
  352|  2.28k|    run->runs[run->n_runs] = vl;
  353|  2.28k|    run->n_runs++;
  354|  2.28k|    return vl;
  355|  2.28k|}
run.c:run_container_append:
  332|   290k|                                        rle16_t *previousrl) {
  333|   290k|    const uint32_t previousend = previousrl->value + previousrl->length;
  334|   290k|    if (vl.value > previousend + 1) {  // we add a new one
  ------------------
  |  Branch (334:9): [True: 148k, False: 142k]
  ------------------
  335|   148k|        run->runs[run->n_runs] = vl;
  336|   148k|        run->n_runs++;
  337|   148k|        *previousrl = vl;
  338|   148k|    } else {
  339|   142k|        uint32_t newend = vl.value + vl.length + UINT32_C(1);
  340|   142k|        if (newend > previousend) {  // we merge
  ------------------
  |  Branch (340:13): [True: 108k, False: 34.3k]
  ------------------
  341|   108k|            previousrl->length = (uint16_t)(newend - 1 - previousrl->value);
  342|   108k|            run->runs[run->n_runs - 1] = *previousrl;
  343|   108k|        }
  344|   142k|    }
  345|   290k|}
run.c:run_container_empty:
  314|      8|static inline bool run_container_empty(const run_container_t *run) {
  315|      8|    return run->n_runs == 0;  // runs never empty
  316|      8|}
run.c:run_container_size_in_bytes:
  493|     49|    const run_container_t *container) {
  494|     49|    return run_container_serialized_size_in_bytes(container->n_runs);
  495|     49|}

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

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

ra_get_index:
   93|  87.1k|inline int32_t ra_get_index(const roaring_array_t *ra, uint16_t x) {
   94|  87.1k|    if ((ra->size == 0) || ra->keys[ra->size - 1] == x) return ra->size - 1;
  ------------------
  |  Branch (94:9): [True: 12.7k, False: 74.4k]
  |  Branch (94:28): [True: 32.8k, False: 41.5k]
  ------------------
   95|  41.5k|    return binarySearch(ra->keys, (int32_t)ra->size, x);
   96|  87.1k|}
ra_get_container_at_index:
  102|   438k|                                              uint16_t i, uint8_t *typecode) {
  103|   438k|    *typecode = ra->typecodes[i];
  104|   438k|    return ra->containers[i];
  105|   438k|}
ra_get_key_at_index:
  110|   300k|inline uint16_t ra_get_key_at_index(const roaring_array_t *ra, uint16_t i) {
  111|   300k|    return ra->keys[i];
  112|   300k|}
ra_set_container_at_index:
  175|   108k|                                      container_t *c, uint8_t typecode) {
  176|       |    assert(i < ra->size);
  177|   108k|    ra->containers[i] = c;
  178|   108k|    ra->typecodes[i] = typecode;
  179|   108k|}
ra_get_size:
  191|  13.3k|inline int32_t ra_get_size(const roaring_array_t *ra) { return ra->size; }
ra_replace_key_and_container_at_index:
  205|   144k|                                                  uint8_t typecode) {
  206|   144k|    assert(i < ra->size);
  207|       |
  208|   144k|    ra->keys[i] = key;
  209|   144k|    ra->containers[i] = c;
  210|   144k|    ra->typecodes[i] = typecode;
  211|   144k|}
roaring.c:ra_advance_until:
  194|    567|                                       int32_t pos) {
  195|    567|    return advanceUntil(ra->keys, pos, ra->size, x);
  196|    567|}
roaring.c:ra_unshare_container_at_index:
  268|  61.8k|                                                 uint16_t i) {
  269|       |    assert(i < ra->size);
  270|  61.8k|    ra->containers[i] =
  271|  61.8k|        get_writable_copy_if_shared(ra->containers[i], &ra->typecodes[i]);
  272|  61.8k|}

intersect_vector16:
  386|  1.83k|                           size_t s_b, uint16_t *C) {
  387|  1.83k|    size_t count = 0;
  388|  1.83k|    size_t i_a = 0, i_b = 0;
  389|  1.83k|    const int vectorlength = sizeof(__m128i) / sizeof(uint16_t);
  390|  1.83k|    const size_t st_a = (s_a / vectorlength) * vectorlength;
  391|  1.83k|    const size_t st_b = (s_b / vectorlength) * vectorlength;
  392|  1.83k|    __m128i v_a, v_b;
  393|  1.83k|    if ((i_a < st_a) && (i_b < st_b)) {
  ------------------
  |  Branch (393:9): [True: 1.70k, False: 126]
  |  Branch (393:25): [True: 1.54k, False: 164]
  ------------------
  394|  1.54k|        v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  395|  1.54k|        v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  396|  4.25k|        while ((A[i_a] == 0) || (B[i_b] == 0)) {
  ------------------
  |  Branch (396:16): [True: 2.68k, False: 1.56k]
  |  Branch (396:33): [True: 182, False: 1.38k]
  ------------------
  397|  2.86k|            const __m128i res_v = _mm_cmpestrm(
  398|  2.86k|                v_b, vectorlength, v_a, vectorlength,
  399|  2.86k|                _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  400|  2.86k|            const int r = _mm_extract_epi32(res_v, 0);
  401|  2.86k|            __m128i sm16 = _mm_loadu_si128((const __m128i *)shuffle_mask16 + r);
  402|  2.86k|            __m128i p = _mm_shuffle_epi8(v_a, sm16);
  403|  2.86k|            _mm_storeu_si128((__m128i *)&C[count], p);  // can overflow
  404|  2.86k|            count += _mm_popcnt_u32(r);
  405|  2.86k|            const uint16_t a_max = A[i_a + vectorlength - 1];
  406|  2.86k|            const uint16_t b_max = B[i_b + vectorlength - 1];
  407|  2.86k|            if (a_max <= b_max) {
  ------------------
  |  Branch (407:17): [True: 1.56k, False: 1.30k]
  ------------------
  408|  1.56k|                i_a += vectorlength;
  409|  1.56k|                if (i_a == st_a) break;
  ------------------
  |  Branch (409:21): [True: 124, False: 1.43k]
  ------------------
  410|  1.43k|                v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  411|  1.43k|            }
  412|  2.74k|            if (b_max <= a_max) {
  ------------------
  |  Branch (412:17): [True: 1.39k, False: 1.34k]
  ------------------
  413|  1.39k|                i_b += vectorlength;
  414|  1.39k|                if (i_b == st_b) break;
  ------------------
  |  Branch (414:21): [True: 32, False: 1.36k]
  ------------------
  415|  1.36k|                v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  416|  1.36k|            }
  417|  2.74k|        }
  418|  1.54k|        if ((i_a < st_a) && (i_b < st_b))
  ------------------
  |  Branch (418:13): [True: 1.41k, False: 124]
  |  Branch (418:29): [True: 1.38k, False: 32]
  ------------------
  419|  43.3k|            while (true) {
  ------------------
  |  Branch (419:20): [True: 43.3k, Folded]
  ------------------
  420|  43.3k|                const __m128i res_v = _mm_cmpistrm(
  421|  43.3k|                    v_b, v_a,
  422|  43.3k|                    _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  423|  43.3k|                const int r = _mm_extract_epi32(res_v, 0);
  424|  43.3k|                __m128i sm16 =
  425|  43.3k|                    _mm_loadu_si128((const __m128i *)shuffle_mask16 + r);
  426|  43.3k|                __m128i p = _mm_shuffle_epi8(v_a, sm16);
  427|  43.3k|                _mm_storeu_si128((__m128i *)&C[count], p);  // can overflow
  428|  43.3k|                count += _mm_popcnt_u32(r);
  429|  43.3k|                const uint16_t a_max = A[i_a + vectorlength - 1];
  430|  43.3k|                const uint16_t b_max = B[i_b + vectorlength - 1];
  431|  43.3k|                if (a_max <= b_max) {
  ------------------
  |  Branch (431:21): [True: 19.3k, False: 23.9k]
  ------------------
  432|  19.3k|                    i_a += vectorlength;
  433|  19.3k|                    if (i_a == st_a) break;
  ------------------
  |  Branch (433:25): [True: 807, False: 18.5k]
  ------------------
  434|  18.5k|                    v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  435|  18.5k|                }
  436|  42.5k|                if (b_max <= a_max) {
  ------------------
  |  Branch (436:21): [True: 25.4k, False: 17.0k]
  ------------------
  437|  25.4k|                    i_b += vectorlength;
  438|  25.4k|                    if (i_b == st_b) break;
  ------------------
  |  Branch (438:25): [True: 579, False: 24.8k]
  ------------------
  439|  24.8k|                    v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  440|  24.8k|                }
  441|  42.5k|            }
  442|  1.54k|    }
  443|       |    // intersect the tail using scalar intersection
  444|  32.3k|    while (i_a < s_a && i_b < s_b) {
  ------------------
  |  Branch (444:12): [True: 30.8k, False: 1.45k]
  |  Branch (444:25): [True: 30.4k, False: 375]
  ------------------
  445|  30.4k|        uint16_t a = A[i_a];
  446|  30.4k|        uint16_t b = B[i_b];
  447|  30.4k|        if (a < b) {
  ------------------
  |  Branch (447:13): [True: 12.2k, False: 18.2k]
  ------------------
  448|  12.2k|            i_a++;
  449|  18.2k|        } else if (b < a) {
  ------------------
  |  Branch (449:20): [True: 12.5k, False: 5.76k]
  ------------------
  450|  12.5k|            i_b++;
  451|  12.5k|        } else {
  452|  5.76k|            C[count] = a;  //==b;
  453|  5.76k|            count++;
  454|  5.76k|            i_a++;
  455|  5.76k|            i_b++;
  456|  5.76k|        }
  457|  30.4k|    }
  458|  1.83k|    return (int32_t)count;
  459|  1.83k|}
array_container_to_uint32_array_vector16:
  464|  5.78k|                                             uint32_t base) {
  465|  5.78k|    int outpos = 0;
  466|  5.78k|    uint32_t *out = (uint32_t *)vout;
  467|  5.78k|    size_t i = 0;
  468|   193k|    for (; i + sizeof(__m128i) / sizeof(uint16_t) <= cardinality;
  ------------------
  |  Branch (468:12): [True: 187k, False: 5.78k]
  ------------------
  469|   187k|         i += sizeof(__m128i) / sizeof(uint16_t)) {
  470|   187k|        __m128i vinput = _mm_loadu_si128((const __m128i *)(array + i));
  471|   187k|        __m256i voutput = _mm256_add_epi32(_mm256_cvtepu16_epi32(vinput),
  472|   187k|                                           _mm256_set1_epi32(base));
  473|   187k|        _mm256_storeu_si256((__m256i *)(out + outpos), voutput);
  474|   187k|        outpos += sizeof(__m256i) / sizeof(uint32_t);
  475|   187k|    }
  476|  20.2k|    for (; i < cardinality; ++i) {
  ------------------
  |  Branch (476:12): [True: 14.4k, False: 5.78k]
  ------------------
  477|  14.4k|        const uint32_t val = base + array[i];
  478|  14.4k|        memcpy(out + outpos, &val,
  479|  14.4k|               sizeof(uint32_t));  // should be compiled as a MOV on x64
  480|  14.4k|        outpos++;
  481|  14.4k|    }
  482|  5.78k|    return outpos;
  483|  5.78k|}
intersect_vector16_inplace:
  486|  4.48k|                                   size_t s_b) {
  487|  4.48k|    size_t count = 0;
  488|  4.48k|    size_t i_a = 0, i_b = 0;
  489|  4.48k|    const int vectorlength = sizeof(__m128i) / sizeof(uint16_t);
  490|  4.48k|    const size_t st_a = (s_a / vectorlength) * vectorlength;
  491|  4.48k|    const size_t st_b = (s_b / vectorlength) * vectorlength;
  492|  4.48k|    __m128i v_a, v_b;
  493|  4.48k|    if ((i_a < st_a) && (i_b < st_b)) {
  ------------------
  |  Branch (493:9): [True: 2.32k, False: 2.15k]
  |  Branch (493:25): [True: 2.13k, False: 198]
  ------------------
  494|  2.13k|        v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  495|  2.13k|        v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  496|  2.13k|        __m128i tmp[2] = {_mm_setzero_si128()};
  497|  2.13k|        size_t tmp_count = 0;
  498|  4.21k|        while ((A[i_a] == 0) || (B[i_b] == 0)) {
  ------------------
  |  Branch (498:16): [True: 1.88k, False: 2.32k]
  |  Branch (498:33): [True: 296, False: 2.02k]
  ------------------
  499|  2.18k|            const __m128i res_v = _mm_cmpestrm(
  500|  2.18k|                v_b, vectorlength, v_a, vectorlength,
  501|  2.18k|                _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  502|  2.18k|            const int r = _mm_extract_epi32(res_v, 0);
  503|  2.18k|            __m128i sm16 = _mm_loadu_si128((const __m128i *)shuffle_mask16 + r);
  504|  2.18k|            __m128i p = _mm_shuffle_epi8(v_a, sm16);
  505|  2.18k|            _mm_storeu_si128((__m128i *)&((uint16_t *)tmp)[tmp_count], p);
  506|  2.18k|            tmp_count += _mm_popcnt_u32(r);
  507|  2.18k|            const uint16_t a_max = A[i_a + vectorlength - 1];
  508|  2.18k|            const uint16_t b_max = B[i_b + vectorlength - 1];
  509|  2.18k|            if (a_max <= b_max) {
  ------------------
  |  Branch (509:17): [True: 2.06k, False: 125]
  ------------------
  510|  2.06k|                _mm_storeu_si128((__m128i *)&A[count], tmp[0]);
  511|  2.06k|                _mm_storeu_si128(tmp, _mm_setzero_si128());
  512|  2.06k|                count += tmp_count;
  513|  2.06k|                tmp_count = 0;
  514|  2.06k|                i_a += vectorlength;
  515|  2.06k|                if (i_a == st_a) break;
  ------------------
  |  Branch (515:21): [True: 95, False: 1.96k]
  ------------------
  516|  1.96k|                v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  517|  1.96k|            }
  518|  2.09k|            if (b_max <= a_max) {
  ------------------
  |  Branch (518:17): [True: 305, False: 1.78k]
  ------------------
  519|    305|                i_b += vectorlength;
  520|    305|                if (i_b == st_b) break;
  ------------------
  |  Branch (520:21): [True: 8, False: 297]
  ------------------
  521|    297|                v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  522|    297|            }
  523|  2.09k|        }
  524|  2.13k|        if ((i_a < st_a) && (i_b < st_b)) {
  ------------------
  |  Branch (524:13): [True: 2.03k, False: 95]
  |  Branch (524:29): [True: 2.02k, False: 8]
  ------------------
  525|   248k|            while (true) {
  ------------------
  |  Branch (525:20): [True: 248k, Folded]
  ------------------
  526|   248k|                const __m128i res_v = _mm_cmpistrm(
  527|   248k|                    v_b, v_a,
  528|   248k|                    _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  529|   248k|                const int r = _mm_extract_epi32(res_v, 0);
  530|   248k|                __m128i sm16 =
  531|   248k|                    _mm_loadu_si128((const __m128i *)shuffle_mask16 + r);
  532|   248k|                __m128i p = _mm_shuffle_epi8(v_a, sm16);
  533|   248k|                _mm_storeu_si128((__m128i *)&((uint16_t *)tmp)[tmp_count], p);
  534|   248k|                tmp_count += _mm_popcnt_u32(r);
  535|   248k|                const uint16_t a_max = A[i_a + vectorlength - 1];
  536|   248k|                const uint16_t b_max = B[i_b + vectorlength - 1];
  537|   248k|                if (a_max <= b_max) {
  ------------------
  |  Branch (537:21): [True: 142k, False: 106k]
  ------------------
  538|   142k|                    _mm_storeu_si128((__m128i *)&A[count], tmp[0]);
  539|   142k|                    _mm_storeu_si128(tmp, _mm_setzero_si128());
  540|   142k|                    count += tmp_count;
  541|   142k|                    tmp_count = 0;
  542|   142k|                    i_a += vectorlength;
  543|   142k|                    if (i_a == st_a) break;
  ------------------
  |  Branch (543:25): [True: 1.10k, False: 141k]
  ------------------
  544|   141k|                    v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  545|   141k|                }
  546|   247k|                if (b_max <= a_max) {
  ------------------
  |  Branch (546:21): [True: 136k, False: 111k]
  ------------------
  547|   136k|                    i_b += vectorlength;
  548|   136k|                    if (i_b == st_b) break;
  ------------------
  |  Branch (548:25): [True: 925, False: 135k]
  ------------------
  549|   135k|                    v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  550|   135k|                }
  551|   247k|            }
  552|  2.02k|        }
  553|       |        // tmp_count <= 8, so this does not affect efficiency so much
  554|  4.76k|        for (size_t i = 0; i < tmp_count; i++) {
  ------------------
  |  Branch (554:28): [True: 2.62k, False: 2.13k]
  ------------------
  555|  2.62k|            A[count] = ((uint16_t *)tmp)[i];
  556|  2.62k|            count++;
  557|  2.62k|        }
  558|  2.13k|        i_a += tmp_count;  // We can at least jump pass $tmp_count elements in A
  559|  2.13k|    }
  560|       |    // intersect the tail using scalar intersection
  561|  34.0k|    while (i_a < s_a && i_b < s_b) {
  ------------------
  |  Branch (561:12): [True: 30.0k, False: 4.06k]
  |  Branch (561:25): [True: 29.5k, False: 425]
  ------------------
  562|  29.5k|        uint16_t a = A[i_a];
  563|  29.5k|        uint16_t b = B[i_b];
  564|  29.5k|        if (a < b) {
  ------------------
  |  Branch (564:13): [True: 10.5k, False: 19.0k]
  ------------------
  565|  10.5k|            i_a++;
  566|  19.0k|        } else if (b < a) {
  ------------------
  |  Branch (566:20): [True: 7.24k, False: 11.8k]
  ------------------
  567|  7.24k|            i_b++;
  568|  11.8k|        } else {
  569|  11.8k|            A[count] = a;  //==b;
  570|  11.8k|            count++;
  571|  11.8k|            i_a++;
  572|  11.8k|            i_b++;
  573|  11.8k|        }
  574|  29.5k|    }
  575|  4.48k|    return (int32_t)count;
  576|  4.48k|}
intersect_vector16_cardinality:
  581|  7.32k|                                       const uint16_t *B, size_t s_b) {
  582|  7.32k|    size_t count = 0;
  583|  7.32k|    size_t i_a = 0, i_b = 0;
  584|  7.32k|    const int vectorlength = sizeof(__m128i) / sizeof(uint16_t);
  585|  7.32k|    const size_t st_a = (s_a / vectorlength) * vectorlength;
  586|  7.32k|    const size_t st_b = (s_b / vectorlength) * vectorlength;
  587|  7.32k|    __m128i v_a, v_b;
  588|  7.32k|    if ((i_a < st_a) && (i_b < st_b)) {
  ------------------
  |  Branch (588:9): [True: 6.82k, False: 504]
  |  Branch (588:25): [True: 6.16k, False: 656]
  ------------------
  589|  6.16k|        v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  590|  6.16k|        v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  591|  17.0k|        while ((A[i_a] == 0) || (B[i_b] == 0)) {
  ------------------
  |  Branch (591:16): [True: 10.7k, False: 6.27k]
  |  Branch (591:33): [True: 728, False: 5.54k]
  ------------------
  592|  11.4k|            const __m128i res_v = _mm_cmpestrm(
  593|  11.4k|                v_b, vectorlength, v_a, vectorlength,
  594|  11.4k|                _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  595|  11.4k|            const int r = _mm_extract_epi32(res_v, 0);
  596|  11.4k|            count += _mm_popcnt_u32(r);
  597|  11.4k|            const uint16_t a_max = A[i_a + vectorlength - 1];
  598|  11.4k|            const uint16_t b_max = B[i_b + vectorlength - 1];
  599|  11.4k|            if (a_max <= b_max) {
  ------------------
  |  Branch (599:17): [True: 6.25k, False: 5.20k]
  ------------------
  600|  6.25k|                i_a += vectorlength;
  601|  6.25k|                if (i_a == st_a) break;
  ------------------
  |  Branch (601:21): [True: 496, False: 5.75k]
  ------------------
  602|  5.75k|                v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  603|  5.75k|            }
  604|  10.9k|            if (b_max <= a_max) {
  ------------------
  |  Branch (604:17): [True: 5.59k, False: 5.36k]
  ------------------
  605|  5.59k|                i_b += vectorlength;
  606|  5.59k|                if (i_b == st_b) break;
  ------------------
  |  Branch (606:21): [True: 128, False: 5.46k]
  ------------------
  607|  5.46k|                v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  608|  5.46k|            }
  609|  10.9k|        }
  610|  6.16k|        if ((i_a < st_a) && (i_b < st_b))
  ------------------
  |  Branch (610:13): [True: 5.67k, False: 496]
  |  Branch (610:29): [True: 5.54k, False: 128]
  ------------------
  611|   173k|            while (true) {
  ------------------
  |  Branch (611:20): [True: 173k, Folded]
  ------------------
  612|   173k|                const __m128i res_v = _mm_cmpistrm(
  613|   173k|                    v_b, v_a,
  614|   173k|                    _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  615|   173k|                const int r = _mm_extract_epi32(res_v, 0);
  616|   173k|                count += _mm_popcnt_u32(r);
  617|   173k|                const uint16_t a_max = A[i_a + vectorlength - 1];
  618|   173k|                const uint16_t b_max = B[i_b + vectorlength - 1];
  619|   173k|                if (a_max <= b_max) {
  ------------------
  |  Branch (619:21): [True: 77.4k, False: 95.8k]
  ------------------
  620|  77.4k|                    i_a += vectorlength;
  621|  77.4k|                    if (i_a == st_a) break;
  ------------------
  |  Branch (621:25): [True: 3.22k, False: 74.1k]
  ------------------
  622|  74.1k|                    v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  623|  74.1k|                }
  624|   170k|                if (b_max <= a_max) {
  ------------------
  |  Branch (624:21): [True: 101k, False: 68.2k]
  ------------------
  625|   101k|                    i_b += vectorlength;
  626|   101k|                    if (i_b == st_b) break;
  ------------------
  |  Branch (626:25): [True: 2.31k, False: 99.5k]
  ------------------
  627|  99.5k|                    v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  628|  99.5k|                }
  629|   170k|            }
  630|  6.16k|    }
  631|       |    // intersect the tail using scalar intersection
  632|   129k|    while (i_a < s_a && i_b < s_b) {
  ------------------
  |  Branch (632:12): [True: 123k, False: 5.82k]
  |  Branch (632:25): [True: 121k, False: 1.50k]
  ------------------
  633|   121k|        uint16_t a = A[i_a];
  634|   121k|        uint16_t b = B[i_b];
  635|   121k|        if (a < b) {
  ------------------
  |  Branch (635:13): [True: 48.8k, False: 73.0k]
  ------------------
  636|  48.8k|            i_a++;
  637|  73.0k|        } else if (b < a) {
  ------------------
  |  Branch (637:20): [True: 50.0k, False: 23.0k]
  ------------------
  638|  50.0k|            i_b++;
  639|  50.0k|        } else {
  640|  23.0k|            count++;
  641|  23.0k|            i_a++;
  642|  23.0k|            i_b++;
  643|  23.0k|        }
  644|   121k|    }
  645|  7.32k|    return (int32_t)count;
  646|  7.32k|}
difference_vector16:
  655|  2.39k|                            size_t s_b, uint16_t *C) {
  656|       |    // we handle the degenerate case
  657|  2.39k|    if (s_a == 0) return 0;
  ------------------
  |  Branch (657:9): [True: 0, False: 2.39k]
  ------------------
  658|  2.39k|    if (s_b == 0) {
  ------------------
  |  Branch (658:9): [True: 0, False: 2.39k]
  ------------------
  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.39k|    int32_t count = 0;
  665|  2.39k|    if ((A[0] == 0) || (B[0] == 0)) {
  ------------------
  |  Branch (665:9): [True: 2.18k, False: 207]
  |  Branch (665:24): [True: 8, False: 199]
  ------------------
  666|  2.19k|        if ((A[0] == 0) && (B[0] == 0)) {
  ------------------
  |  Branch (666:13): [True: 2.18k, False: 8]
  |  Branch (666:28): [True: 275, False: 1.91k]
  ------------------
  667|    275|            A++;
  668|    275|            s_a--;
  669|    275|            B++;
  670|    275|            s_b--;
  671|  1.91k|        } else if (A[0] == 0) {
  ------------------
  |  Branch (671:20): [True: 1.91k, False: 8]
  ------------------
  672|  1.91k|            C[count++] = 0;
  673|  1.91k|            A++;
  674|  1.91k|            s_a--;
  675|  1.91k|        } else {
  676|      8|            B++;
  677|      8|            s_b--;
  678|      8|        }
  679|  2.19k|    }
  680|       |    // at this point, we have two non-empty arrays, made of non-zero
  681|       |    // increasing values.
  682|  2.39k|    size_t i_a = 0, i_b = 0;
  683|  2.39k|    const size_t vectorlength = sizeof(__m128i) / sizeof(uint16_t);
  684|  2.39k|    const size_t st_a = (s_a / vectorlength) * vectorlength;
  685|  2.39k|    const size_t st_b = (s_b / vectorlength) * vectorlength;
  686|  2.39k|    if ((i_a < st_a) && (i_b < st_b)) {  // this is the vectorized code path
  ------------------
  |  Branch (686:9): [True: 1.98k, False: 409]
  |  Branch (686:25): [True: 1.66k, False: 320]
  ------------------
  687|  1.66k|        __m128i v_a, v_b;                //, v_bmax;
  688|       |        // we load a vector from A and a vector from B
  689|  1.66k|        v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  690|  1.66k|        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.66k|        __m128i runningmask_a_found_in_b = _mm_setzero_si128();
  694|       |        /****
  695|       |         * start of the main vectorized loop
  696|       |         *****/
  697|  47.4k|        while (true) {
  ------------------
  |  Branch (697:16): [True: 47.4k, Folded]
  ------------------
  698|       |            // afoundinb will contain a mask indicate for each entry in A
  699|       |            // whether it is seen
  700|       |            // in B
  701|  47.4k|            const __m128i a_found_in_b = _mm_cmpistrm(
  702|  47.4k|                v_b, v_a,
  703|  47.4k|                _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  704|  47.4k|            runningmask_a_found_in_b =
  705|  47.4k|                _mm_or_si128(runningmask_a_found_in_b, a_found_in_b);
  706|       |            // we always compare the last values of A and B
  707|  47.4k|            const uint16_t a_max = A[i_a + vectorlength - 1];
  708|  47.4k|            const uint16_t b_max = B[i_b + vectorlength - 1];
  709|  47.4k|            if (a_max <= b_max) {
  ------------------
  |  Branch (709:17): [True: 21.3k, False: 26.1k]
  ------------------
  710|       |                // Ok. In this code path, we are ready to write our v_a
  711|       |                // because there is no need to read more from B, they will
  712|       |                // all be large values.
  713|  21.3k|                const int bitmask_belongs_to_difference =
  714|  21.3k|                    _mm_extract_epi32(runningmask_a_found_in_b, 0) ^ 0xFF;
  715|       |                /*** next few lines are probably expensive *****/
  716|  21.3k|                __m128i sm16 = _mm_loadu_si128((const __m128i *)shuffle_mask16 +
  717|  21.3k|                                               bitmask_belongs_to_difference);
  718|  21.3k|                __m128i p = _mm_shuffle_epi8(v_a, sm16);
  719|  21.3k|                _mm_storeu_si128((__m128i *)&C[count], p);  // can overflow
  720|  21.3k|                count += _mm_popcnt_u32(bitmask_belongs_to_difference);
  721|       |                // we advance a
  722|  21.3k|                i_a += vectorlength;
  723|  21.3k|                if (i_a == st_a)  // no more
  ------------------
  |  Branch (723:21): [True: 1.18k, False: 20.1k]
  ------------------
  724|  1.18k|                    break;
  725|  20.1k|                runningmask_a_found_in_b = _mm_setzero_si128();
  726|  20.1k|                v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  727|  20.1k|            }
  728|  46.2k|            if (b_max <= a_max) {
  ------------------
  |  Branch (728:17): [True: 29.3k, False: 16.9k]
  ------------------
  729|       |                // in this code path, the current v_b has become useless
  730|  29.3k|                i_b += vectorlength;
  731|  29.3k|                if (i_b == st_b) break;
  ------------------
  |  Branch (731:21): [True: 474, False: 28.8k]
  ------------------
  732|  28.8k|                v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  733|  28.8k|            }
  734|  46.2k|        }
  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.66k|        if (i_a < st_a) {        // we have unfinished business...
  ------------------
  |  Branch (739:13): [True: 474, False: 1.18k]
  ------------------
  740|    474|            uint16_t buffer[8];  // buffer to do a masked load
  741|    474|            memset(buffer, 0, 8 * sizeof(uint16_t));
  742|    474|            memcpy(buffer, B + i_b, (s_b - i_b) * sizeof(uint16_t));
  743|    474|            v_b = _mm_lddqu_si128((__m128i *)buffer);
  744|    474|            const __m128i a_found_in_b = _mm_cmpistrm(
  745|    474|                v_b, v_a,
  746|    474|                _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  747|    474|            runningmask_a_found_in_b =
  748|    474|                _mm_or_si128(runningmask_a_found_in_b, a_found_in_b);
  749|    474|            const int bitmask_belongs_to_difference =
  750|    474|                _mm_extract_epi32(runningmask_a_found_in_b, 0) ^ 0xFF;
  751|    474|            __m128i sm16 = _mm_loadu_si128((const __m128i *)shuffle_mask16 +
  752|    474|                                           bitmask_belongs_to_difference);
  753|    474|            __m128i p = _mm_shuffle_epi8(v_a, sm16);
  754|    474|            _mm_storeu_si128((__m128i *)&C[count], p);  // can overflow
  755|    474|            count += _mm_popcnt_u32(bitmask_belongs_to_difference);
  756|    474|            i_a += vectorlength;
  757|    474|        }
  758|       |        // at this point we should have i_a == st_a and i_b == st_b
  759|  1.66k|    }
  760|       |    // do the tail using scalar code
  761|   112k|    while (i_a < s_a && i_b < s_b) {
  ------------------
  |  Branch (761:12): [True: 110k, False: 1.85k]
  |  Branch (761:25): [True: 109k, False: 536]
  ------------------
  762|   109k|        uint16_t a = A[i_a];
  763|   109k|        uint16_t b = B[i_b];
  764|   109k|        if (b < a) {
  ------------------
  |  Branch (764:13): [True: 75.7k, False: 34.0k]
  ------------------
  765|  75.7k|            i_b++;
  766|  75.7k|        } else if (a < b) {
  ------------------
  |  Branch (766:20): [True: 28.3k, False: 5.66k]
  ------------------
  767|  28.3k|            C[count] = a;
  768|  28.3k|            count++;
  769|  28.3k|            i_a++;
  770|  28.3k|        } else {  //==
  771|  5.66k|            i_a++;
  772|  5.66k|            i_b++;
  773|  5.66k|        }
  774|   109k|    }
  775|  2.39k|    if (i_a < s_a) {
  ------------------
  |  Branch (775:9): [True: 536, False: 1.85k]
  ------------------
  776|    536|        if (C == A) {
  ------------------
  |  Branch (776:13): [True: 0, False: 536]
  ------------------
  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|    536|        } else {
  782|  25.6k|            for (size_t i = 0; i < (s_a - i_a); i++) {
  ------------------
  |  Branch (782:32): [True: 25.0k, False: 536]
  ------------------
  783|  25.0k|                C[count + i] = A[i + i_a];
  784|  25.0k|            }
  785|    536|        }
  786|    536|        count += (int32_t)(s_a - i_a);
  787|    536|    }
  788|  2.39k|    return count;
  789|  2.39k|}
intersect_skewed_uint16:
  855|    780|                                uint16_t *buffer) {
  856|    780|    size_t pos = 0, idx_l = 0, idx_s = 0;
  857|       |
  858|    780|    if (0 == size_s) {
  ------------------
  |  Branch (858:9): [True: 0, False: 780]
  ------------------
  859|      0|        return 0;
  860|      0|    }
  861|    780|    int32_t index1 = 0, index2 = 0, index3 = 0, index4 = 0;
  862|  2.06k|    while ((idx_s + 4 <= size_s) && (idx_l < size_l)) {
  ------------------
  |  Branch (862:12): [True: 1.28k, False: 780]
  |  Branch (862:37): [True: 1.28k, False: 0]
  ------------------
  863|  1.28k|        uint16_t target1 = small[idx_s];
  864|  1.28k|        uint16_t target2 = small[idx_s + 1];
  865|  1.28k|        uint16_t target3 = small[idx_s + 2];
  866|  1.28k|        uint16_t target4 = small[idx_s + 3];
  867|  1.28k|        binarySearch4(large + idx_l, (int32_t)(size_l - idx_l), target1,
  868|  1.28k|                      target2, target3, target4, &index1, &index2, &index3,
  869|  1.28k|                      &index4);
  870|  1.28k|        if ((index1 + idx_l < size_l) && (large[idx_l + index1] == target1)) {
  ------------------
  |  Branch (870:13): [True: 1.28k, False: 1]
  |  Branch (870:42): [True: 648, False: 635]
  ------------------
  871|    648|            buffer[pos++] = target1;
  872|    648|        }
  873|  1.28k|        if ((index2 + idx_l < size_l) && (large[idx_l + index2] == target2)) {
  ------------------
  |  Branch (873:13): [True: 1.28k, False: 3]
  |  Branch (873:42): [True: 783, False: 498]
  ------------------
  874|    783|            buffer[pos++] = target2;
  875|    783|        }
  876|  1.28k|        if ((index3 + idx_l < size_l) && (large[idx_l + index3] == target3)) {
  ------------------
  |  Branch (876:13): [True: 1.28k, False: 4]
  |  Branch (876:42): [True: 757, False: 523]
  ------------------
  877|    757|            buffer[pos++] = target3;
  878|    757|        }
  879|  1.28k|        if ((index4 + idx_l < size_l) && (large[idx_l + index4] == target4)) {
  ------------------
  |  Branch (879:13): [True: 1.27k, False: 7]
  |  Branch (879:42): [True: 716, False: 561]
  ------------------
  880|    716|            buffer[pos++] = target4;
  881|    716|        }
  882|  1.28k|        idx_s += 4;
  883|  1.28k|        idx_l += index4;
  884|  1.28k|    }
  885|    780|    if ((idx_s + 2 <= size_s) && (idx_l < size_l)) {
  ------------------
  |  Branch (885:9): [True: 414, False: 366]
  |  Branch (885:34): [True: 413, False: 1]
  ------------------
  886|    413|        uint16_t target1 = small[idx_s];
  887|    413|        uint16_t target2 = small[idx_s + 1];
  888|    413|        binarySearch2(large + idx_l, (int32_t)(size_l - idx_l), target1,
  889|    413|                      target2, &index1, &index2);
  890|    413|        if ((index1 + idx_l < size_l) && (large[idx_l + index1] == target1)) {
  ------------------
  |  Branch (890:13): [True: 407, False: 6]
  |  Branch (890:42): [True: 265, False: 142]
  ------------------
  891|    265|            buffer[pos++] = target1;
  892|    265|        }
  893|    413|        if ((index2 + idx_l < size_l) && (large[idx_l + index2] == target2)) {
  ------------------
  |  Branch (893:13): [True: 393, False: 20]
  |  Branch (893:42): [True: 270, False: 123]
  ------------------
  894|    270|            buffer[pos++] = target2;
  895|    270|        }
  896|    413|        idx_s += 2;
  897|    413|        idx_l += index2;
  898|    413|    }
  899|    780|    if ((idx_s < size_s) && (idx_l < size_l)) {
  ------------------
  |  Branch (899:9): [True: 375, False: 405]
  |  Branch (899:29): [True: 370, False: 5]
  ------------------
  900|    370|        uint16_t val_s = small[idx_s];
  901|    370|        int32_t index =
  902|    370|            binarySearch(large + idx_l, (int32_t)(size_l - idx_l), val_s);
  903|    370|        if (index >= 0) buffer[pos++] = val_s;
  ------------------
  |  Branch (903:13): [True: 266, False: 104]
  ------------------
  904|    370|    }
  905|    780|    return (int32_t)pos;
  906|    780|}
intersect_skewed_uint16_cardinality:
  912|  2.24k|                                            size_t size_l) {
  913|  2.24k|    size_t pos = 0, idx_l = 0, idx_s = 0;
  914|       |
  915|  2.24k|    if (0 == size_s) {
  ------------------
  |  Branch (915:9): [True: 0, False: 2.24k]
  ------------------
  916|      0|        return 0;
  917|      0|    }
  918|       |
  919|  2.24k|    uint16_t val_l = large[idx_l], val_s = small[idx_s];
  920|       |
  921|  29.5k|    while (true) {
  ------------------
  |  Branch (921:12): [True: 29.5k, Folded]
  ------------------
  922|  29.5k|        if (val_l < val_s) {
  ------------------
  |  Branch (922:13): [True: 6.17k, False: 23.3k]
  ------------------
  923|  6.17k|            idx_l = advanceUntil(large, (int32_t)idx_l, (int32_t)size_l, val_s);
  924|  6.17k|            if (idx_l == size_l) break;
  ------------------
  |  Branch (924:17): [True: 136, False: 6.03k]
  ------------------
  925|  6.03k|            val_l = large[idx_l];
  926|  23.3k|        } else if (val_s < val_l) {
  ------------------
  |  Branch (926:20): [True: 10.2k, False: 13.1k]
  ------------------
  927|  10.2k|            idx_s++;
  928|  10.2k|            if (idx_s == size_s) break;
  ------------------
  |  Branch (928:17): [True: 876, False: 9.35k]
  ------------------
  929|  9.35k|            val_s = small[idx_s];
  930|  13.1k|        } else {
  931|  13.1k|            pos++;
  932|  13.1k|            idx_s++;
  933|  13.1k|            if (idx_s == size_s) break;
  ------------------
  |  Branch (933:17): [True: 1.14k, False: 12.0k]
  ------------------
  934|  12.0k|            val_s = small[idx_s];
  935|  12.0k|            idx_l = advanceUntil(large, (int32_t)idx_l, (int32_t)size_l, val_s);
  936|  12.0k|            if (idx_l == size_l) break;
  ------------------
  |  Branch (936:17): [True: 84, False: 11.9k]
  ------------------
  937|  11.9k|            val_l = large[idx_l];
  938|  11.9k|        }
  939|  29.5k|    }
  940|       |
  941|  2.24k|    return (int32_t)pos;
  942|  2.24k|}
intersect_skewed_uint16_nonempty:
  945|    560|                                      const uint16_t *large, size_t size_l) {
  946|    560|    size_t idx_l = 0, idx_s = 0;
  947|       |
  948|    560|    if (0 == size_s) {
  ------------------
  |  Branch (948:9): [True: 0, False: 560]
  ------------------
  949|      0|        return false;
  950|      0|    }
  951|       |
  952|    560|    uint16_t val_l = large[idx_l], val_s = small[idx_s];
  953|       |
  954|  2.19k|    while (true) {
  ------------------
  |  Branch (954:12): [True: 2.19k, Folded]
  ------------------
  955|  2.19k|        if (val_l < val_s) {
  ------------------
  |  Branch (955:13): [True: 820, False: 1.37k]
  ------------------
  956|    820|            idx_l = advanceUntil(large, (int32_t)idx_l, (int32_t)size_l, val_s);
  957|    820|            if (idx_l == size_l) break;
  ------------------
  |  Branch (957:17): [True: 33, False: 787]
  ------------------
  958|    787|            val_l = large[idx_l];
  959|  1.37k|        } else if (val_s < val_l) {
  ------------------
  |  Branch (959:20): [True: 928, False: 449]
  ------------------
  960|    928|            idx_s++;
  961|    928|            if (idx_s == size_s) break;
  ------------------
  |  Branch (961:17): [True: 78, False: 850]
  ------------------
  962|    850|            val_s = small[idx_s];
  963|    850|        } else {
  964|    449|            return true;
  965|    449|        }
  966|  2.19k|    }
  967|       |
  968|    111|    return false;
  969|    560|}
intersect_uint16_nonempty:
 1025|  1.83k|                               const uint16_t *B, const size_t lenB) {
 1026|  1.83k|    if (lenA == 0 || lenB == 0) return 0;
  ------------------
  |  Branch (1026:9): [True: 0, False: 1.83k]
  |  Branch (1026:22): [True: 0, False: 1.83k]
  ------------------
 1027|  1.83k|    const uint16_t *endA = A + lenA;
 1028|  1.83k|    const uint16_t *endB = B + lenB;
 1029|       |
 1030|  1.83k|    while (1) {
  ------------------
  |  Branch (1030:12): [True: 1.83k, Folded]
  ------------------
 1031|  10.7k|        while (*A < *B) {
  ------------------
  |  Branch (1031:16): [True: 8.37k, False: 2.36k]
  ------------------
 1032|  8.95k|        SKIP_FIRST_COMPARE:
 1033|  8.95k|            if (++A == endA) return false;
  ------------------
  |  Branch (1033:17): [True: 50, False: 8.90k]
  ------------------
 1034|  8.95k|        }
 1035|  5.86k|        while (*A > *B) {
  ------------------
  |  Branch (1035:16): [True: 3.51k, False: 2.35k]
  ------------------
 1036|  3.51k|            if (++B == endB) return false;
  ------------------
  |  Branch (1036:17): [True: 11, False: 3.50k]
  ------------------
 1037|  3.51k|        }
 1038|  2.35k|        if (*A == *B) {
  ------------------
  |  Branch (1038:13): [True: 1.77k, False: 580]
  ------------------
 1039|  1.77k|            return true;
 1040|  1.77k|        } else {
 1041|    580|            goto SKIP_FIRST_COMPARE;
 1042|    580|        }
 1043|  2.35k|    }
 1044|      0|    return false;  // NOTREACHED
 1045|  1.83k|}
union_uint16:
 1105|  4.76k|                    size_t size_2, uint16_t *buffer) {
 1106|  4.76k|    size_t pos = 0, idx_1 = 0, idx_2 = 0;
 1107|       |
 1108|  4.76k|    if (0 == size_2) {
  ------------------
  |  Branch (1108:9): [True: 59, False: 4.70k]
  ------------------
 1109|     59|        memmove(buffer, set_1, size_1 * sizeof(uint16_t));
 1110|     59|        return size_1;
 1111|     59|    }
 1112|  4.70k|    if (0 == size_1) {
  ------------------
  |  Branch (1112:9): [True: 0, False: 4.70k]
  ------------------
 1113|      0|        memmove(buffer, set_2, size_2 * sizeof(uint16_t));
 1114|      0|        return size_2;
 1115|      0|    }
 1116|       |
 1117|  4.70k|    uint16_t val_1 = set_1[idx_1], val_2 = set_2[idx_2];
 1118|       |
 1119|   219k|    while (true) {
  ------------------
  |  Branch (1119:12): [True: 219k, Folded]
  ------------------
 1120|   219k|        if (val_1 < val_2) {
  ------------------
  |  Branch (1120:13): [True: 8.44k, False: 210k]
  ------------------
 1121|  8.44k|            buffer[pos++] = val_1;
 1122|  8.44k|            ++idx_1;
 1123|  8.44k|            if (idx_1 >= size_1) break;
  ------------------
  |  Branch (1123:17): [True: 423, False: 8.02k]
  ------------------
 1124|  8.02k|            val_1 = set_1[idx_1];
 1125|   210k|        } else if (val_2 < val_1) {
  ------------------
  |  Branch (1125:20): [True: 178k, False: 32.6k]
  ------------------
 1126|   178k|            buffer[pos++] = val_2;
 1127|   178k|            ++idx_2;
 1128|   178k|            if (idx_2 >= size_2) break;
  ------------------
  |  Branch (1128:17): [True: 199, False: 177k]
  ------------------
 1129|   177k|            val_2 = set_2[idx_2];
 1130|   177k|        } else {
 1131|  32.6k|            buffer[pos++] = val_1;
 1132|  32.6k|            ++idx_1;
 1133|  32.6k|            ++idx_2;
 1134|  32.6k|            if (idx_1 >= size_1 || idx_2 >= size_2) break;
  ------------------
  |  Branch (1134:17): [True: 3.93k, False: 28.6k]
  |  Branch (1134:36): [True: 144, False: 28.5k]
  ------------------
 1135|  28.5k|            val_1 = set_1[idx_1];
 1136|  28.5k|            val_2 = set_2[idx_2];
 1137|  28.5k|        }
 1138|   219k|    }
 1139|       |
 1140|  4.70k|    if (idx_1 < size_1) {
  ------------------
  |  Branch (1140:9): [True: 343, False: 4.35k]
  ------------------
 1141|    343|        const size_t n_elems = size_1 - idx_1;
 1142|    343|        memmove(buffer + pos, set_1 + idx_1, n_elems * sizeof(uint16_t));
 1143|    343|        pos += n_elems;
 1144|  4.35k|    } else if (idx_2 < size_2) {
  ------------------
  |  Branch (1144:16): [True: 1.87k, False: 2.48k]
  ------------------
 1145|  1.87k|        const size_t n_elems = size_2 - idx_2;
 1146|  1.87k|        memmove(buffer + pos, set_2 + idx_2, n_elems * sizeof(uint16_t));
 1147|  1.87k|        pos += n_elems;
 1148|  1.87k|    }
 1149|       |
 1150|  4.70k|    return pos;
 1151|  4.70k|}
difference_uint16:
 1154|  3.51k|                      int length2, uint16_t *a_out) {
 1155|  3.51k|    int out_card = 0;
 1156|  3.51k|    int k1 = 0, k2 = 0;
 1157|  3.51k|    if (length1 == 0) return 0;
  ------------------
  |  Branch (1157:9): [True: 0, False: 3.51k]
  ------------------
 1158|  3.51k|    if (length2 == 0) {
  ------------------
  |  Branch (1158:9): [True: 0, False: 3.51k]
  ------------------
 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.51k|    uint16_t s1 = a1[k1];
 1163|  3.51k|    uint16_t s2 = a2[k2];
 1164|   446k|    while (true) {
  ------------------
  |  Branch (1164:12): [True: 446k, Folded]
  ------------------
 1165|   446k|        if (s1 < s2) {
  ------------------
  |  Branch (1165:13): [True: 222k, False: 224k]
  ------------------
 1166|   222k|            a_out[out_card++] = s1;
 1167|   222k|            ++k1;
 1168|   222k|            if (k1 >= length1) {
  ------------------
  |  Branch (1168:17): [True: 0, False: 222k]
  ------------------
 1169|      0|                break;
 1170|      0|            }
 1171|   222k|            s1 = a1[k1];
 1172|   224k|        } else if (s1 == s2) {
  ------------------
  |  Branch (1172:20): [True: 224k, False: 0]
  ------------------
 1173|   224k|            ++k1;
 1174|   224k|            ++k2;
 1175|   224k|            if (k1 >= length1) {
  ------------------
  |  Branch (1175:17): [True: 2.26k, False: 221k]
  ------------------
 1176|  2.26k|                break;
 1177|  2.26k|            }
 1178|   221k|            if (k2 >= length2) {
  ------------------
  |  Branch (1178:17): [True: 1.25k, False: 220k]
  ------------------
 1179|  1.25k|                memmove(a_out + out_card, a1 + k1,
 1180|  1.25k|                        sizeof(uint16_t) * (length1 - k1));
 1181|  1.25k|                return out_card + length1 - k1;
 1182|  1.25k|            }
 1183|   220k|            s1 = a1[k1];
 1184|   220k|            s2 = a2[k2];
 1185|   220k|        } 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|   446k|    }
 1195|  2.26k|    return out_card;
 1196|  3.51k|}
xor_uint16:
 1199|  7.82k|                   const uint16_t *array_2, int32_t card_2, uint16_t *out) {
 1200|  7.82k|    int32_t pos1 = 0, pos2 = 0, pos_out = 0;
 1201|   224k|    while (pos1 < card_1 && pos2 < card_2) {
  ------------------
  |  Branch (1201:12): [True: 217k, False: 7.17k]
  |  Branch (1201:29): [True: 216k, False: 652]
  ------------------
 1202|   216k|        const uint16_t v1 = array_1[pos1];
 1203|   216k|        const uint16_t v2 = array_2[pos2];
 1204|   216k|        if (v1 == v2) {
  ------------------
  |  Branch (1204:13): [True: 39.0k, False: 177k]
  ------------------
 1205|  39.0k|            ++pos1;
 1206|  39.0k|            ++pos2;
 1207|  39.0k|            continue;
 1208|  39.0k|        }
 1209|   177k|        if (v1 < v2) {
  ------------------
  |  Branch (1209:13): [True: 32.2k, False: 145k]
  ------------------
 1210|  32.2k|            out[pos_out++] = v1;
 1211|  32.2k|            ++pos1;
 1212|   145k|        } else {
 1213|   145k|            out[pos_out++] = v2;
 1214|   145k|            ++pos2;
 1215|   145k|        }
 1216|   177k|    }
 1217|  7.82k|    if (pos1 < card_1) {
  ------------------
  |  Branch (1217:9): [True: 652, False: 7.17k]
  ------------------
 1218|    652|        const size_t n_elems = card_1 - pos1;
 1219|    652|        memcpy(out + pos_out, array_1 + pos1, n_elems * sizeof(uint16_t));
 1220|    652|        pos_out += (int32_t)n_elems;
 1221|  7.17k|    } else if (pos2 < card_2) {
  ------------------
  |  Branch (1221:16): [True: 2.24k, False: 4.92k]
  ------------------
 1222|  2.24k|        const size_t n_elems = card_2 - pos2;
 1223|  2.24k|        memcpy(out + pos_out, array_2 + pos2, n_elems * sizeof(uint16_t));
 1224|  2.24k|        pos_out += (int32_t)n_elems;
 1225|  2.24k|    }
 1226|  7.82k|    return pos_out;
 1227|  7.82k|}
union_vector16:
 1664|  4.76k|                        uint16_t *output) {
 1665|  4.76k|    if ((length1 < 8) || (length2 < 8)) {
  ------------------
  |  Branch (1665:9): [True: 1.04k, False: 3.71k]
  |  Branch (1665:26): [True: 0, False: 3.71k]
  ------------------
 1666|  1.04k|        return (uint32_t)union_uint16(array1, length1, array2, length2, output);
 1667|  1.04k|    }
 1668|  3.71k|    __m128i vA, vB, V, vecMin, vecMax;
 1669|  3.71k|    __m128i laststore;
 1670|  3.71k|    uint16_t *initoutput = output;
 1671|  3.71k|    uint32_t len1 = length1 / 8;
 1672|  3.71k|    uint32_t len2 = length2 / 8;
 1673|  3.71k|    uint32_t pos1 = 0;
 1674|  3.71k|    uint32_t pos2 = 0;
 1675|       |    // we start the machine
 1676|  3.71k|    vA = _mm_lddqu_si128((const __m128i *)array1 + pos1);
 1677|  3.71k|    pos1++;
 1678|  3.71k|    vB = _mm_lddqu_si128((const __m128i *)array2 + pos2);
 1679|  3.71k|    pos2++;
 1680|  3.71k|    sse_merge(&vA, &vB, &vecMin, &vecMax);
 1681|  3.71k|    laststore = _mm_set1_epi16(-1);
 1682|  3.71k|    output += store_unique(laststore, vecMin, output);
 1683|  3.71k|    laststore = vecMin;
 1684|  3.71k|    if ((pos1 < len1) && (pos2 < len2)) {
  ------------------
  |  Branch (1684:9): [True: 3.15k, False: 562]
  |  Branch (1684:26): [True: 3.15k, False: 0]
  ------------------
 1685|  3.15k|        uint16_t curA, curB;
 1686|  3.15k|        curA = array1[8 * pos1];
 1687|  3.15k|        curB = array2[8 * pos2];
 1688|   105k|        while (true) {
  ------------------
  |  Branch (1688:16): [True: 105k, Folded]
  ------------------
 1689|   105k|            if (curA <= curB) {
  ------------------
  |  Branch (1689:17): [True: 44.4k, False: 61.4k]
  ------------------
 1690|  44.4k|                V = _mm_lddqu_si128((const __m128i *)array1 + pos1);
 1691|  44.4k|                pos1++;
 1692|  44.4k|                if (pos1 < len1) {
  ------------------
  |  Branch (1692:21): [True: 42.0k, False: 2.39k]
  ------------------
 1693|  42.0k|                    curA = array1[8 * pos1];
 1694|  42.0k|                } else {
 1695|  2.39k|                    break;
 1696|  2.39k|                }
 1697|  61.4k|            } else {
 1698|  61.4k|                V = _mm_lddqu_si128((const __m128i *)array2 + pos2);
 1699|  61.4k|                pos2++;
 1700|  61.4k|                if (pos2 < len2) {
  ------------------
  |  Branch (1700:21): [True: 60.6k, False: 760]
  ------------------
 1701|  60.6k|                    curB = array2[8 * pos2];
 1702|  60.6k|                } else {
 1703|    760|                    break;
 1704|    760|                }
 1705|  61.4k|            }
 1706|   102k|            sse_merge(&V, &vecMax, &vecMin, &vecMax);
 1707|   102k|            output += store_unique(laststore, vecMin, output);
 1708|   102k|            laststore = vecMin;
 1709|   102k|        }
 1710|  3.15k|        sse_merge(&V, &vecMax, &vecMin, &vecMax);
 1711|  3.15k|        output += store_unique(laststore, vecMin, output);
 1712|  3.15k|        laststore = vecMin;
 1713|  3.15k|    }
 1714|       |    // we finish the rest off using a scalar algorithm
 1715|       |    // could be improved?
 1716|       |    //
 1717|       |    // copy the small end on a tmp buffer
 1718|  3.71k|    uint32_t len = (uint32_t)(output - initoutput);
 1719|  3.71k|    uint16_t buffer[16];
 1720|  3.71k|    uint32_t leftoversize = store_unique(laststore, vecMax, buffer);
 1721|  3.71k|    if (pos1 == len1) {
  ------------------
  |  Branch (1721:9): [True: 2.95k, False: 760]
  ------------------
 1722|  2.95k|        memcpy(buffer + leftoversize, array1 + 8 * pos1,
 1723|  2.95k|               (length1 - 8 * len1) * sizeof(uint16_t));
 1724|  2.95k|        leftoversize += length1 - 8 * len1;
 1725|  2.95k|        sort_uint16_short(buffer, leftoversize);
 1726|       |
 1727|  2.95k|        leftoversize = unique(buffer, leftoversize);
 1728|  2.95k|        len += (uint32_t)union_uint16(buffer, leftoversize, array2 + 8 * pos2,
 1729|  2.95k|                                      length2 - 8 * pos2, output);
 1730|  2.95k|    } else {
 1731|    760|        memcpy(buffer + leftoversize, array2 + 8 * pos2,
 1732|    760|               (length2 - 8 * len2) * sizeof(uint16_t));
 1733|    760|        leftoversize += length2 - 8 * len2;
 1734|    760|        sort_uint16_short(buffer, leftoversize);
 1735|    760|        leftoversize = unique(buffer, leftoversize);
 1736|    760|        len += (uint32_t)union_uint16(buffer, leftoversize, array1 + 8 * pos1,
 1737|    760|                                      length1 - 8 * pos1, output);
 1738|    760|    }
 1739|  3.71k|    return len;
 1740|  4.76k|}
xor_vector16:
 1975|  7.84k|                      uint16_t *output) {
 1976|  7.84k|    if ((length1 < 8) || (length2 < 8)) {
  ------------------
  |  Branch (1976:9): [True: 3.07k, False: 4.76k]
  |  Branch (1976:26): [True: 377, False: 4.38k]
  ------------------
 1977|  3.45k|        return xor_uint16(array1, length1, array2, length2, output);
 1978|  3.45k|    }
 1979|  4.38k|    __m128i vA, vB, V, vecMin, vecMax;
 1980|  4.38k|    __m128i laststore;
 1981|  4.38k|    uint16_t *initoutput = output;
 1982|  4.38k|    uint32_t len1 = length1 / 8;
 1983|  4.38k|    uint32_t len2 = length2 / 8;
 1984|  4.38k|    uint32_t pos1 = 0;
 1985|  4.38k|    uint32_t pos2 = 0;
 1986|       |    // we start the machine
 1987|  4.38k|    vA = _mm_lddqu_si128((const __m128i *)array1 + pos1);
 1988|  4.38k|    pos1++;
 1989|  4.38k|    vB = _mm_lddqu_si128((const __m128i *)array2 + pos2);
 1990|  4.38k|    pos2++;
 1991|  4.38k|    sse_merge(&vA, &vB, &vecMin, &vecMax);
 1992|  4.38k|    laststore = _mm_set1_epi16(-1);
 1993|  4.38k|    uint16_t buffer[17];
 1994|  4.38k|    output += store_unique_xor(laststore, vecMin, output);
 1995|       |
 1996|  4.38k|    laststore = vecMin;
 1997|  4.38k|    if ((pos1 < len1) && (pos2 < len2)) {
  ------------------
  |  Branch (1997:9): [True: 4.03k, False: 351]
  |  Branch (1997:26): [True: 3.90k, False: 133]
  ------------------
 1998|  3.90k|        uint16_t curA, curB;
 1999|  3.90k|        curA = array1[8 * pos1];
 2000|  3.90k|        curB = array2[8 * pos2];
 2001|   186k|        while (true) {
  ------------------
  |  Branch (2001:16): [True: 186k, Folded]
  ------------------
 2002|   186k|            if (curA <= curB) {
  ------------------
  |  Branch (2002:17): [True: 88.6k, False: 98.2k]
  ------------------
 2003|  88.6k|                V = _mm_lddqu_si128((const __m128i *)array1 + pos1);
 2004|  88.6k|                pos1++;
 2005|  88.6k|                if (pos1 < len1) {
  ------------------
  |  Branch (2005:21): [True: 86.1k, False: 2.58k]
  ------------------
 2006|  86.1k|                    curA = array1[8 * pos1];
 2007|  86.1k|                } else {
 2008|  2.58k|                    break;
 2009|  2.58k|                }
 2010|  98.2k|            } else {
 2011|  98.2k|                V = _mm_lddqu_si128((const __m128i *)array2 + pos2);
 2012|  98.2k|                pos2++;
 2013|  98.2k|                if (pos2 < len2) {
  ------------------
  |  Branch (2013:21): [True: 96.9k, False: 1.31k]
  ------------------
 2014|  96.9k|                    curB = array2[8 * pos2];
 2015|  96.9k|                } else {
 2016|  1.31k|                    break;
 2017|  1.31k|                }
 2018|  98.2k|            }
 2019|   183k|            sse_merge(&V, &vecMax, &vecMin, &vecMax);
 2020|       |            // conditionally stores the last value of laststore as well as all
 2021|       |            // but the
 2022|       |            // last value of vecMin
 2023|   183k|            output += store_unique_xor(laststore, vecMin, output);
 2024|   183k|            laststore = vecMin;
 2025|   183k|        }
 2026|  3.90k|        sse_merge(&V, &vecMax, &vecMin, &vecMax);
 2027|       |        // conditionally stores the last value of laststore as well as all but
 2028|       |        // the
 2029|       |        // last value of vecMin
 2030|  3.90k|        output += store_unique_xor(laststore, vecMin, output);
 2031|  3.90k|        laststore = vecMin;
 2032|  3.90k|    }
 2033|  4.38k|    uint32_t len = (uint32_t)(output - initoutput);
 2034|       |
 2035|       |    // we finish the rest off using a scalar algorithm
 2036|       |    // could be improved?
 2037|       |    // conditionally stores the last value of laststore as well as all but the
 2038|       |    // last value of vecMax,
 2039|       |    // we store to "buffer"
 2040|  4.38k|    int leftoversize = store_unique_xor(laststore, vecMax, buffer);
 2041|  4.38k|    uint16_t vec7 = (uint16_t)_mm_extract_epi16(vecMax, 7);
 2042|  4.38k|    uint16_t vec6 = (uint16_t)_mm_extract_epi16(vecMax, 6);
 2043|  4.38k|    if (vec7 != vec6) buffer[leftoversize++] = vec7;
  ------------------
  |  Branch (2043:9): [True: 4.32k, False: 56]
  ------------------
 2044|  4.38k|    if (pos1 == len1) {
  ------------------
  |  Branch (2044:9): [True: 2.93k, False: 1.45k]
  ------------------
 2045|  2.93k|        memcpy(buffer + leftoversize, array1 + 8 * pos1,
 2046|  2.93k|               (length1 - 8 * len1) * sizeof(uint16_t));
 2047|  2.93k|        leftoversize += length1 - 8 * len1;
 2048|  2.93k|        if (leftoversize == 0) {  // trivial case
  ------------------
  |  Branch (2048:13): [True: 7, False: 2.92k]
  ------------------
 2049|      7|            memcpy(output, array2 + 8 * pos2,
 2050|      7|                   (length2 - 8 * pos2) * sizeof(uint16_t));
 2051|      7|            len += (length2 - 8 * pos2);
 2052|  2.92k|        } else {
 2053|  2.92k|            sort_uint16_short(buffer, leftoversize);
 2054|  2.92k|            leftoversize = unique_xor(buffer, leftoversize);
 2055|  2.92k|            len += xor_uint16(buffer, leftoversize, array2 + 8 * pos2,
 2056|  2.92k|                              length2 - 8 * pos2, output);
 2057|  2.92k|        }
 2058|  2.93k|    } else {
 2059|  1.45k|        memcpy(buffer + leftoversize, array2 + 8 * pos2,
 2060|  1.45k|               (length2 - 8 * len2) * sizeof(uint16_t));
 2061|  1.45k|        leftoversize += length2 - 8 * len2;
 2062|  1.45k|        if (leftoversize == 0) {  // trivial case
  ------------------
  |  Branch (2062:13): [True: 5, False: 1.44k]
  ------------------
 2063|      5|            memcpy(output, array1 + 8 * pos1,
 2064|      5|                   (length1 - 8 * pos1) * sizeof(uint16_t));
 2065|      5|            len += (length1 - 8 * pos1);
 2066|  1.44k|        } else {
 2067|  1.44k|            sort_uint16_short(buffer, leftoversize);
 2068|  1.44k|            leftoversize = unique_xor(buffer, leftoversize);
 2069|  1.44k|            len += xor_uint16(buffer, leftoversize, array1 + 8 * pos1,
 2070|  1.44k|                              length1 - 8 * pos1, output);
 2071|  1.44k|        }
 2072|  1.45k|    }
 2073|  4.38k|    return len;
 2074|  7.84k|}
fast_union_uint16:
 2177|  4.76k|                         uint16_t *buffer) {
 2178|  4.76k|#if CROARING_IS_X64
 2179|  4.76k|    const unsigned support = (unsigned)croaring_hardware_support();
 2180|  4.76k|#if CROARING_COMPILER_SUPPORTS_AVX512
 2181|  4.76k|    if (support & ROARING_SUPPORTS_AVX512) {
  ------------------
  |  Branch (2181:9): [True: 0, False: 4.76k]
  ------------------
 2182|       |        // compute union with smallest array first
 2183|      0|        if (size_1 < size_2) {
  ------------------
  |  Branch (2183:13): [True: 0, False: 0]
  ------------------
 2184|      0|            return avx512_union_uint16(set_1, (uint32_t)size_1, set_2,
 2185|      0|                                       (uint32_t)size_2, buffer);
 2186|      0|        } else {
 2187|      0|            return avx512_union_uint16(set_2, (uint32_t)size_2, set_1,
 2188|      0|                                       (uint32_t)size_1, buffer);
 2189|      0|        }
 2190|      0|    }
 2191|  4.76k|#endif  // CROARING_COMPILER_SUPPORTS_AVX512
 2192|  4.76k|    if (support & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (2192:9): [True: 4.76k, False: 0]
  ------------------
 2193|       |        // compute union with smallest array first
 2194|  4.76k|        if (size_1 < size_2) {
  ------------------
  |  Branch (2194:13): [True: 2.39k, False: 2.36k]
  ------------------
 2195|  2.39k|            return union_vector16(set_1, (uint32_t)size_1, set_2,
 2196|  2.39k|                                  (uint32_t)size_2, buffer);
 2197|  2.39k|        } else {
 2198|  2.36k|            return union_vector16(set_2, (uint32_t)size_2, set_1,
 2199|  2.36k|                                  (uint32_t)size_1, buffer);
 2200|  2.36k|        }
 2201|  4.76k|    } else {
 2202|       |        // compute union with smallest array first
 2203|      0|        if (size_1 < size_2) {
  ------------------
  |  Branch (2203:13): [True: 0, False: 0]
  ------------------
 2204|      0|            return union_uint16(set_1, size_1, set_2, size_2, buffer);
 2205|      0|        } else {
 2206|      0|            return union_uint16(set_2, size_2, set_1, size_1, buffer);
 2207|      0|        }
 2208|      0|    }
 2209|       |#else
 2210|       |    // compute union with smallest array first
 2211|       |    if (size_1 < size_2) {
 2212|       |        return union_uint16(set_1, size_1, set_2, size_2, buffer);
 2213|       |    } else {
 2214|       |        return union_uint16(set_2, size_2, set_1, size_1, buffer);
 2215|       |    }
 2216|       |#endif
 2217|  4.76k|}
memequals:
 2321|  7.15k|bool memequals(const void *s1, const void *s2, size_t n) {
 2322|  7.15k|    if (n == 0) {
  ------------------
  |  Branch (2322:9): [True: 0, False: 7.15k]
  ------------------
 2323|      0|        return true;
 2324|      0|    }
 2325|  7.15k|#if CROARING_IS_X64
 2326|  7.15k|    int support = croaring_hardware_support();
 2327|  7.15k|#if CROARING_COMPILER_SUPPORTS_AVX512
 2328|  7.15k|    if (support & ROARING_SUPPORTS_AVX512) {
  ------------------
  |  Branch (2328:9): [True: 0, False: 7.15k]
  ------------------
 2329|      0|        return _avx512_memequals(s1, s2, n);
 2330|      0|    } else
 2331|  7.15k|#endif  // CROARING_COMPILER_SUPPORTS_AVX512
 2332|  7.15k|        if (support & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (2332:13): [True: 7.15k, False: 0]
  ------------------
 2333|  7.15k|            return _avx2_memequals(s1, s2, n);
 2334|  7.15k|        } else {
 2335|      0|            return memcmp(s1, s2, n) == 0;
 2336|      0|        }
 2337|       |#else
 2338|       |    return memcmp(s1, s2, n) == 0;
 2339|       |#endif
 2340|  7.15k|}
array_util.c:binarySearch4:
  804|  1.28k|                          int32_t *index4) {
  805|  1.28k|    const uint16_t *base1 = array;
  806|  1.28k|    const uint16_t *base2 = array;
  807|  1.28k|    const uint16_t *base3 = array;
  808|  1.28k|    const uint16_t *base4 = array;
  809|  1.28k|    if (n == 0) return;
  ------------------
  |  Branch (809:9): [True: 0, False: 1.28k]
  ------------------
  810|  16.0k|    while (n > 1) {
  ------------------
  |  Branch (810:12): [True: 14.7k, False: 1.28k]
  ------------------
  811|  14.7k|        int32_t half = n >> 1;
  812|  14.7k|        base1 = (base1[half] < target1) ? &base1[half] : base1;
  ------------------
  |  Branch (812:17): [True: 1.24k, False: 13.5k]
  ------------------
  813|  14.7k|        base2 = (base2[half] < target2) ? &base2[half] : base2;
  ------------------
  |  Branch (813:17): [True: 2.22k, False: 12.5k]
  ------------------
  814|  14.7k|        base3 = (base3[half] < target3) ? &base3[half] : base3;
  ------------------
  |  Branch (814:17): [True: 2.83k, False: 11.9k]
  ------------------
  815|  14.7k|        base4 = (base4[half] < target4) ? &base4[half] : base4;
  ------------------
  |  Branch (815:17): [True: 3.28k, False: 11.4k]
  ------------------
  816|  14.7k|        n -= half;
  817|  14.7k|    }
  818|  1.28k|    *index1 = (int32_t)((*base1 < target1) + base1 - array);
  819|  1.28k|    *index2 = (int32_t)((*base2 < target2) + base2 - array);
  820|  1.28k|    *index3 = (int32_t)((*base3 < target3) + base3 - array);
  821|  1.28k|    *index4 = (int32_t)((*base4 < target4) + base4 - array);
  822|  1.28k|}
array_util.c:binarySearch2:
  833|    413|                          uint16_t target2, int32_t *index1, int32_t *index2) {
  834|    413|    const uint16_t *base1 = array;
  835|    413|    const uint16_t *base2 = array;
  836|    413|    if (n == 0) return;
  ------------------
  |  Branch (836:9): [True: 0, False: 413]
  ------------------
  837|  3.88k|    while (n > 1) {
  ------------------
  |  Branch (837:12): [True: 3.47k, False: 413]
  ------------------
  838|  3.47k|        int32_t half = n >> 1;
  839|  3.47k|        base1 = (base1[half] < target1) ? &base1[half] : base1;
  ------------------
  |  Branch (839:17): [True: 875, False: 2.59k]
  ------------------
  840|  3.47k|        base2 = (base2[half] < target2) ? &base2[half] : base2;
  ------------------
  |  Branch (840:17): [True: 1.47k, False: 1.99k]
  ------------------
  841|  3.47k|        n -= half;
  842|  3.47k|    }
  843|    413|    *index1 = (int32_t)((*base1 < target1) + base1 - array);
  844|    413|    *index2 = (int32_t)((*base2 < target2) + base2 - array);
  845|    413|}
array_util.c:sse_merge:
 1244|   300k|                             __m128i *vecMin, __m128i *vecMax) {  // output
 1245|   300k|    __m128i vecTmp;
 1246|   300k|    vecTmp = _mm_min_epu16(*vInput1, *vInput2);
 1247|   300k|    *vecMax = _mm_max_epu16(*vInput1, *vInput2);
 1248|   300k|    vecTmp = _mm_alignr_epi8(vecTmp, vecTmp, 2);
 1249|   300k|    *vecMin = _mm_min_epu16(vecTmp, *vecMax);
 1250|   300k|    *vecMax = _mm_max_epu16(vecTmp, *vecMax);
 1251|   300k|    vecTmp = _mm_alignr_epi8(*vecMin, *vecMin, 2);
 1252|   300k|    *vecMin = _mm_min_epu16(vecTmp, *vecMax);
 1253|   300k|    *vecMax = _mm_max_epu16(vecTmp, *vecMax);
 1254|   300k|    vecTmp = _mm_alignr_epi8(*vecMin, *vecMin, 2);
 1255|   300k|    *vecMin = _mm_min_epu16(vecTmp, *vecMax);
 1256|   300k|    *vecMax = _mm_max_epu16(vecTmp, *vecMax);
 1257|   300k|    vecTmp = _mm_alignr_epi8(*vecMin, *vecMin, 2);
 1258|   300k|    *vecMin = _mm_min_epu16(vecTmp, *vecMax);
 1259|   300k|    *vecMax = _mm_max_epu16(vecTmp, *vecMax);
 1260|   300k|    vecTmp = _mm_alignr_epi8(*vecMin, *vecMin, 2);
 1261|   300k|    *vecMin = _mm_min_epu16(vecTmp, *vecMax);
 1262|   300k|    *vecMax = _mm_max_epu16(vecTmp, *vecMax);
 1263|   300k|    vecTmp = _mm_alignr_epi8(*vecMin, *vecMin, 2);
 1264|   300k|    *vecMin = _mm_min_epu16(vecTmp, *vecMax);
 1265|   300k|    *vecMax = _mm_max_epu16(vecTmp, *vecMax);
 1266|   300k|    vecTmp = _mm_alignr_epi8(*vecMin, *vecMin, 2);
 1267|   300k|    *vecMin = _mm_min_epu16(vecTmp, *vecMax);
 1268|   300k|    *vecMax = _mm_max_epu16(vecTmp, *vecMax);
 1269|       |    *vecMin = _mm_alignr_epi8(*vecMin, *vecMin, 2);
 1270|   300k|}
array_util.c:store_unique:
 1619|   113k|static inline int store_unique(__m128i old, __m128i newval, uint16_t *output) {
 1620|   113k|    __m128i vecTmp = _mm_alignr_epi8(newval, old, 16 - 2);
 1621|       |    // lots of high latency instructions follow (optimize?)
 1622|   113k|    int M = _mm_movemask_epi8(
 1623|   113k|        _mm_packs_epi16(_mm_cmpeq_epi16(vecTmp, newval), _mm_setzero_si128()));
 1624|   113k|    int numberofnewvalues = 8 - _mm_popcnt_u32(M);
 1625|   113k|    __m128i key = _mm_lddqu_si128((const __m128i *)uniqshuf + M);
 1626|   113k|    __m128i val = _mm_shuffle_epi8(newval, key);
 1627|   113k|    _mm_storeu_si128((__m128i *)output, val);
 1628|   113k|    return numberofnewvalues;
 1629|   113k|}
array_util.c:sort_uint16_short:
 1647|  8.09k|static inline void sort_uint16_short(uint16_t *z, uint32_t n) {
 1648|  81.9k|    for (uint32_t i = 1; i < n; i++) {
  ------------------
  |  Branch (1648:26): [True: 73.8k, False: 8.09k]
  ------------------
 1649|  73.8k|        uint16_t v = z[i];
 1650|  73.8k|        uint32_t j = i;
 1651|  77.7k|        while (j > 0 && z[j - 1] > v) {
  ------------------
  |  Branch (1651:16): [True: 77.7k, False: 25]
  |  Branch (1651:25): [True: 3.95k, False: 73.7k]
  ------------------
 1652|  3.95k|            z[j] = z[j - 1];
 1653|  3.95k|            j--;
 1654|  3.95k|        }
 1655|  73.8k|        z[j] = v;
 1656|  73.8k|    }
 1657|  8.09k|}
array_util.c:unique:
 1634|  3.71k|static inline uint32_t unique(uint16_t *out, uint32_t len) {
 1635|  3.71k|    uint32_t pos = 1;
 1636|  38.1k|    for (uint32_t i = 1; i < len; ++i) {
  ------------------
  |  Branch (1636:26): [True: 34.4k, False: 3.71k]
  ------------------
 1637|  34.4k|        if (out[i] != out[i - 1]) {
  ------------------
  |  Branch (1637:13): [True: 34.3k, False: 155]
  ------------------
 1638|  34.3k|            out[pos++] = out[i];
 1639|  34.3k|        }
 1640|  34.4k|    }
 1641|  3.71k|    return pos;
 1642|  3.71k|}
array_util.c:store_unique_xor:
 1943|   195k|                                   uint16_t *output) {
 1944|   195k|    __m128i vecTmp1 = _mm_alignr_epi8(newval, old, 16 - 4);
 1945|       |    __m128i vecTmp2 = _mm_alignr_epi8(newval, old, 16 - 2);
 1946|   195k|    __m128i equalleft = _mm_cmpeq_epi16(vecTmp2, vecTmp1);
 1947|   195k|    __m128i equalright = _mm_cmpeq_epi16(vecTmp2, newval);
 1948|   195k|    __m128i equalleftoright = _mm_or_si128(equalleft, equalright);
 1949|   195k|    int M = _mm_movemask_epi8(
 1950|   195k|        _mm_packs_epi16(equalleftoright, _mm_setzero_si128()));
 1951|   195k|    int numberofnewvalues = 8 - _mm_popcnt_u32(M);
 1952|   195k|    __m128i key = _mm_lddqu_si128((const __m128i *)uniqshuf + M);
 1953|   195k|    __m128i val = _mm_shuffle_epi8(vecTmp2, key);
 1954|   195k|    _mm_storeu_si128((__m128i *)output, val);
 1955|   195k|    return numberofnewvalues;
 1956|   195k|}
array_util.c:unique_xor:
 1961|  4.37k|static inline uint32_t unique_xor(uint16_t *out, uint32_t len) {
 1962|  4.37k|    uint32_t pos = 1;
 1963|  43.7k|    for (uint32_t i = 1; i < len; ++i) {
  ------------------
  |  Branch (1963:26): [True: 39.3k, False: 4.37k]
  ------------------
 1964|  39.3k|        if (out[i] != out[i - 1]) {
  ------------------
  |  Branch (1964:13): [True: 39.0k, False: 301]
  ------------------
 1965|  39.0k|            out[pos++] = out[i];
 1966|  39.0k|        } else
 1967|    301|            pos--;  // if it is identical to previous, delete it
 1968|  39.3k|    }
 1969|  4.37k|    return pos;
 1970|  4.37k|}
array_util.c:_avx2_memequals:
 2279|  7.15k|static inline bool _avx2_memequals(const void *s1, const void *s2, size_t n) {
 2280|  7.15k|    const uint8_t *ptr1 = (const uint8_t *)s1;
 2281|  7.15k|    const uint8_t *ptr2 = (const uint8_t *)s2;
 2282|  7.15k|    const uint8_t *end1 = ptr1 + n;
 2283|  7.15k|    const uint8_t *end8 = ptr1 + n / 8 * 8;
 2284|  7.15k|    const uint8_t *end32 = ptr1 + n / 32 * 32;
 2285|       |
 2286|   136k|    while (ptr1 < end32) {
  ------------------
  |  Branch (2286:12): [True: 129k, False: 7.09k]
  ------------------
 2287|   129k|        __m256i r1 = _mm256_loadu_si256((const __m256i *)ptr1);
 2288|   129k|        __m256i r2 = _mm256_loadu_si256((const __m256i *)ptr2);
 2289|   129k|        int mask = _mm256_movemask_epi8(_mm256_cmpeq_epi8(r1, r2));
 2290|   129k|        if ((uint32_t)mask != UINT32_MAX) {
  ------------------
  |  Branch (2290:13): [True: 55, False: 129k]
  ------------------
 2291|     55|            return false;
 2292|     55|        }
 2293|   129k|        ptr1 += 32;
 2294|   129k|        ptr2 += 32;
 2295|   129k|    }
 2296|       |
 2297|  12.9k|    while (ptr1 < end8) {
  ------------------
  |  Branch (2297:12): [True: 5.98k, False: 7.00k]
  ------------------
 2298|  5.98k|        uint64_t v1, v2;
 2299|  5.98k|        memcpy(&v1, ptr1, sizeof(uint64_t));
 2300|  5.98k|        memcpy(&v2, ptr2, sizeof(uint64_t));
 2301|  5.98k|        if (v1 != v2) {
  ------------------
  |  Branch (2301:13): [True: 90, False: 5.89k]
  ------------------
 2302|     90|            return false;
 2303|     90|        }
 2304|  5.89k|        ptr1 += 8;
 2305|  5.89k|        ptr2 += 8;
 2306|  5.89k|    }
 2307|       |
 2308|  25.2k|    while (ptr1 < end1) {
  ------------------
  |  Branch (2308:12): [True: 18.2k, False: 6.97k]
  ------------------
 2309|  18.2k|        if (*ptr1 != *ptr2) {
  ------------------
  |  Branch (2309:13): [True: 32, False: 18.2k]
  ------------------
 2310|     32|            return false;
 2311|     32|        }
 2312|  18.2k|        ptr1++;
 2313|  18.2k|        ptr2++;
 2314|  18.2k|    }
 2315|       |
 2316|  6.97k|    return true;
 2317|  7.00k|}

bitset_extract_setbits_avx2:
  722|    987|                                   uint32_t base) {
  723|    987|    if (outcapacity == 0) return 0;
  ------------------
  |  Branch (723:9): [True: 0, False: 987]
  ------------------
  724|    987|    uint32_t *initout = out;
  725|    987|    __m256i baseVec = _mm256_set1_epi32(base - 1);
  726|    987|    __m256i incVec = _mm256_set1_epi32(64);
  727|    987|    __m256i add8 = _mm256_set1_epi32(8);
  728|    987|    uint32_t *safeout = out + outcapacity;
  729|    987|    size_t i = 0;
  730|   839k|    for (; (i < length) && (out + 64 <= safeout); ++i) {
  ------------------
  |  Branch (730:12): [True: 839k, False: 247]
  |  Branch (730:28): [True: 838k, False: 740]
  ------------------
  731|   838k|        uint64_t w = words[i];
  732|   838k|        if (w == 0) {
  ------------------
  |  Branch (732:13): [True: 118k, False: 720k]
  ------------------
  733|   118k|            baseVec = _mm256_add_epi32(baseVec, incVec);
  734|   720k|        } else {
  735|  3.60M|            for (int k = 0; k < 4; ++k) {
  ------------------
  |  Branch (735:29): [True: 2.88M, False: 720k]
  ------------------
  736|  2.88M|                uint8_t byteA = (uint8_t)w;
  737|  2.88M|                uint8_t byteB = (uint8_t)(w >> 8);
  738|  2.88M|                w >>= 16;
  739|  2.88M|                __m256i vecA =
  740|  2.88M|                    _mm256_loadu_si256((const __m256i *)vecDecodeTable[byteA]);
  741|  2.88M|                __m256i vecB =
  742|  2.88M|                    _mm256_loadu_si256((const __m256i *)vecDecodeTable[byteB]);
  743|  2.88M|                uint8_t advanceA = lengthTable[byteA];
  744|  2.88M|                uint8_t advanceB = lengthTable[byteB];
  745|  2.88M|                vecA = _mm256_add_epi32(baseVec, vecA);
  746|  2.88M|                baseVec = _mm256_add_epi32(baseVec, add8);
  747|  2.88M|                vecB = _mm256_add_epi32(baseVec, vecB);
  748|  2.88M|                baseVec = _mm256_add_epi32(baseVec, add8);
  749|  2.88M|                _mm256_storeu_si256((__m256i *)out, vecA);
  750|  2.88M|                out += advanceA;
  751|  2.88M|                _mm256_storeu_si256((__m256i *)out, vecB);
  752|  2.88M|                out += advanceB;
  753|  2.88M|            }
  754|   720k|        }
  755|   838k|    }
  756|    987|    base += i * 64;
  757|  13.2k|    for (; (i < length) && (out < safeout); ++i) {
  ------------------
  |  Branch (757:12): [True: 12.8k, False: 355]
  |  Branch (757:28): [True: 12.2k, False: 632]
  ------------------
  758|  12.2k|        uint64_t w = words[i];
  759|  32.2k|        while ((w != 0) && (out < safeout)) {
  ------------------
  |  Branch (759:16): [True: 20.0k, False: 12.2k]
  |  Branch (759:28): [True: 20.0k, False: 0]
  ------------------
  760|  20.0k|            int r =
  761|  20.0k|                roaring_trailing_zeroes(w);  // on x64, should compile to TZCNT
  762|  20.0k|            uint32_t val = r + base;
  763|  20.0k|            memcpy(out, &val,
  764|  20.0k|                   sizeof(uint32_t));  // should be compiled as a MOV on x64
  765|  20.0k|            out++;
  766|  20.0k|            w &= (w - 1);
  767|  20.0k|        }
  768|  12.2k|        base += 64;
  769|  12.2k|    }
  770|    987|    return out - initout;
  771|    987|}
bitset_extract_setbits:
  776|    432|                              uint32_t *out, uint32_t base) {
  777|    432|    int outpos = 0;
  778|   442k|    for (size_t i = 0; i < length; ++i) {
  ------------------
  |  Branch (778:24): [True: 442k, False: 432]
  ------------------
  779|   442k|        uint64_t w = words[i];
  780|  2.50M|        while (w != 0) {
  ------------------
  |  Branch (780:16): [True: 2.06M, False: 442k]
  ------------------
  781|  2.06M|            int r =
  782|  2.06M|                roaring_trailing_zeroes(w);  // on x64, should compile to TZCNT
  783|  2.06M|            uint32_t val = r + base;
  784|  2.06M|            memcpy(out + outpos, &val,
  785|  2.06M|                   sizeof(uint32_t));  // should be compiled as a MOV on x64
  786|  2.06M|            outpos++;
  787|  2.06M|            w &= (w - 1);
  788|  2.06M|        }
  789|   442k|        base += 64;
  790|   442k|    }
  791|    432|    return outpos;
  792|    432|}
bitset_extract_setbits_uint16:
  887|  2.84k|                                     uint16_t *out, uint16_t base) {
  888|  2.84k|    int outpos = 0;
  889|  2.91M|    for (size_t i = 0; i < length; ++i) {
  ------------------
  |  Branch (889:24): [True: 2.91M, False: 2.84k]
  ------------------
  890|  2.91M|        uint64_t w = words[i];
  891|  5.70M|        while (w != 0) {
  ------------------
  |  Branch (891:16): [True: 2.79M, False: 2.91M]
  ------------------
  892|  2.79M|            int r = roaring_trailing_zeroes(w);
  893|  2.79M|            out[outpos++] = (uint16_t)(r + base);
  894|  2.79M|            w &= (w - 1);
  895|  2.79M|        }
  896|  2.91M|        base += 64;
  897|  2.91M|    }
  898|  2.84k|    return outpos;
  899|  2.84k|}
bitset_clear_list:
 1067|  1.60k|                           uint64_t length) {
 1068|  1.60k|    if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (1068:9): [True: 1.60k, False: 0]
  ------------------
 1069|  1.60k|        return _asm_bitset_clear_list(words, card, list, length);
 1070|  1.60k|    } else {
 1071|      0|        return _scalar_bitset_clear_list(words, card, list, length);
 1072|      0|    }
 1073|  1.60k|}
bitset_set_list_withcard:
 1076|  1.28k|                                  const uint16_t *list, uint64_t length) {
 1077|  1.28k|    if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (1077:9): [True: 1.28k, False: 0]
  ------------------
 1078|  1.28k|        return _asm_bitset_set_list_withcard(words, card, list, length);
 1079|  1.28k|    } else {
 1080|      0|        return _scalar_bitset_set_list_withcard(words, card, list, length);
 1081|      0|    }
 1082|  1.28k|}
bitset_set_list:
 1084|    202|void bitset_set_list(uint64_t *words, const uint16_t *list, uint64_t length) {
 1085|    202|    if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (1085:9): [True: 202, False: 0]
  ------------------
 1086|    202|        _asm_bitset_set_list(words, list, length);
 1087|    202|    } else {
 1088|      0|        _scalar_bitset_set_list(words, list, length);
 1089|      0|    }
 1090|    202|}
bitset_flip_list_withcard:
 1146|  1.42k|                                   const uint16_t *list, uint64_t length) {
 1147|  1.42k|    uint64_t offset, load, newload, pos, index;
 1148|  1.42k|    const uint16_t *end = list + length;
 1149|  2.65M|    while (list != end) {
  ------------------
  |  Branch (1149:12): [True: 2.65M, False: 1.42k]
  ------------------
 1150|  2.65M|        pos = *list;
 1151|  2.65M|        offset = pos >> 6;
 1152|  2.65M|        index = pos % 64;
 1153|  2.65M|        load = words[offset];
 1154|  2.65M|        newload = load ^ (UINT64_C(1) << index);
 1155|       |        // todo: is a branch here all that bad?
 1156|  2.65M|        card +=
 1157|       |            (1 - 2 * (((UINT64_C(1) << index) & load) >> index));  // +1 or -1
 1158|  2.65M|        words[offset] = newload;
 1159|  2.65M|        list++;
 1160|  2.65M|    }
 1161|  1.42k|    return card;
 1162|  1.42k|}
bitset_util.c:_asm_bitset_clear_list:
  988|  1.60k|                                              uint64_t length) {
  989|  1.60k|    uint64_t offset, load, pos;
  990|  1.60k|    uint64_t shift = 6;
  991|  1.60k|    const uint16_t *end = list + length;
  992|  1.60k|    if (!length) return card;
  ------------------
  |  Branch (992:9): [True: 0, False: 1.60k]
  ------------------
  993|       |    // btr is not available as an intrinsic in GCC
  994|  1.60k|    __asm volatile(
  995|  1.60k|        "1:\n"
  996|  1.60k|        "movzwq (%[list]), %[pos]\n"
  997|  1.60k|        "shrx %[shift], %[pos], %[offset]\n"
  998|  1.60k|        "mov (%[words],%[offset],8), %[load]\n"
  999|  1.60k|        "btr %[pos], %[load]\n"
 1000|  1.60k|        "mov %[load], (%[words],%[offset],8)\n"
 1001|  1.60k|        "sbb $0, %[card]\n"
 1002|  1.60k|        "add $2, %[list]\n"
 1003|  1.60k|        "cmp %[list], %[end]\n"
 1004|  1.60k|        "jnz 1b"
 1005|  1.60k|        : [card] "+&r"(card), [list] "+&r"(list), [load] "=&r"(load),
 1006|  1.60k|          [pos] "=&r"(pos), [offset] "=&r"(offset)
 1007|  1.60k|        : [end] "r"(end), [words] "r"(words), [shift] "r"(shift)
 1008|  1.60k|        :
 1009|  1.60k|        /* clobbers */ "memory");
 1010|  1.60k|    return card;
 1011|  1.60k|}
bitset_util.c:_asm_bitset_set_list_withcard:
  906|  1.28k|                                                     uint64_t length) {
  907|  1.28k|    uint64_t offset, load, pos;
  908|  1.28k|    uint64_t shift = 6;
  909|  1.28k|    const uint16_t *end = list + length;
  910|  1.28k|    if (!length) return card;
  ------------------
  |  Branch (910:9): [True: 0, False: 1.28k]
  ------------------
  911|       |    // TODO: could unroll for performance, see bitset_set_list
  912|       |    // bts is not available as an intrinsic in GCC
  913|  1.28k|    __asm volatile(
  914|  1.28k|        "1:\n"
  915|  1.28k|        "movzwq (%[list]), %[pos]\n"
  916|  1.28k|        "shrx %[shift], %[pos], %[offset]\n"
  917|  1.28k|        "mov (%[words],%[offset],8), %[load]\n"
  918|  1.28k|        "bts %[pos], %[load]\n"
  919|  1.28k|        "mov %[load], (%[words],%[offset],8)\n"
  920|  1.28k|        "sbb $-1, %[card]\n"
  921|  1.28k|        "add $2, %[list]\n"
  922|  1.28k|        "cmp %[list], %[end]\n"
  923|  1.28k|        "jnz 1b"
  924|  1.28k|        : [card] "+&r"(card), [list] "+&r"(list), [load] "=&r"(load),
  925|  1.28k|          [pos] "=&r"(pos), [offset] "=&r"(offset)
  926|  1.28k|        : [end] "r"(end), [words] "r"(words), [shift] "r"(shift));
  927|  1.28k|    return card;
  928|  1.28k|}
bitset_util.c:_asm_bitset_set_list:
  931|    202|                                        uint64_t length) {
  932|    202|    uint64_t pos;
  933|    202|    const uint16_t *end = list + length;
  934|       |
  935|    202|    uint64_t shift = 6;
  936|    202|    uint64_t offset;
  937|    202|    uint64_t load;
  938|  6.00k|    for (; list + 3 < end; list += 4) {
  ------------------
  |  Branch (938:12): [True: 5.79k, False: 202]
  ------------------
  939|  5.79k|        pos = list[0];
  940|  5.79k|        __asm volatile(
  941|  5.79k|            "shrx %[shift], %[pos], %[offset]\n"
  942|  5.79k|            "mov (%[words],%[offset],8), %[load]\n"
  943|  5.79k|            "bts %[pos], %[load]\n"
  944|  5.79k|            "mov %[load], (%[words],%[offset],8)"
  945|  5.79k|            : [load] "=&r"(load), [offset] "=&r"(offset)
  946|  5.79k|            : [words] "r"(words), [shift] "r"(shift), [pos] "r"(pos));
  947|  5.79k|        pos = list[1];
  948|  5.79k|        __asm volatile(
  949|  5.79k|            "shrx %[shift], %[pos], %[offset]\n"
  950|  5.79k|            "mov (%[words],%[offset],8), %[load]\n"
  951|  5.79k|            "bts %[pos], %[load]\n"
  952|  5.79k|            "mov %[load], (%[words],%[offset],8)"
  953|  5.79k|            : [load] "=&r"(load), [offset] "=&r"(offset)
  954|  5.79k|            : [words] "r"(words), [shift] "r"(shift), [pos] "r"(pos));
  955|  5.79k|        pos = list[2];
  956|  5.79k|        __asm volatile(
  957|  5.79k|            "shrx %[shift], %[pos], %[offset]\n"
  958|  5.79k|            "mov (%[words],%[offset],8), %[load]\n"
  959|  5.79k|            "bts %[pos], %[load]\n"
  960|  5.79k|            "mov %[load], (%[words],%[offset],8)"
  961|  5.79k|            : [load] "=&r"(load), [offset] "=&r"(offset)
  962|  5.79k|            : [words] "r"(words), [shift] "r"(shift), [pos] "r"(pos));
  963|  5.79k|        pos = list[3];
  964|  5.79k|        __asm volatile(
  965|  5.79k|            "shrx %[shift], %[pos], %[offset]\n"
  966|  5.79k|            "mov (%[words],%[offset],8), %[load]\n"
  967|  5.79k|            "bts %[pos], %[load]\n"
  968|  5.79k|            "mov %[load], (%[words],%[offset],8)"
  969|  5.79k|            : [load] "=&r"(load), [offset] "=&r"(offset)
  970|  5.79k|            : [words] "r"(words), [shift] "r"(shift), [pos] "r"(pos));
  971|  5.79k|    }
  972|       |
  973|    511|    while (list != end) {
  ------------------
  |  Branch (973:12): [True: 309, False: 202]
  ------------------
  974|    309|        pos = list[0];
  975|    309|        __asm volatile(
  976|    309|            "shrx %[shift], %[pos], %[offset]\n"
  977|    309|            "mov (%[words],%[offset],8), %[load]\n"
  978|    309|            "bts %[pos], %[load]\n"
  979|    309|            "mov %[load], (%[words],%[offset],8)"
  980|    309|            : [load] "=&r"(load), [offset] "=&r"(offset)
  981|    309|            : [words] "r"(words), [shift] "r"(shift), [pos] "r"(pos));
  982|    309|        list++;
  983|    309|    }
  984|    202|}

array_container_create_given_capacity:
   49|   142k|array_container_t *array_container_create_given_capacity(int32_t size) {
   50|   142k|    array_container_t *container;
   51|       |
   52|   142k|    if ((container = (array_container_t *)roaring_malloc(
  ------------------
  |  Branch (52:9): [True: 0, False: 142k]
  ------------------
   53|   142k|             sizeof(array_container_t))) == NULL) {
   54|      0|        return NULL;
   55|      0|    }
   56|       |
   57|   142k|    if (size <= 0) {  // we don't want to rely on malloc(0)
  ------------------
  |  Branch (57:9): [True: 87.4k, False: 55.2k]
  ------------------
   58|  87.4k|        container->array = NULL;
   59|  87.4k|    } else if ((container->array = (uint16_t *)roaring_malloc(sizeof(uint16_t) *
  ------------------
  |  Branch (59:16): [True: 0, False: 55.2k]
  ------------------
   60|  55.2k|                                                              size)) == NULL) {
   61|      0|        roaring_free(container);
   62|      0|        return NULL;
   63|      0|    }
   64|       |
   65|   142k|    container->capacity = size;
   66|   142k|    container->cardinality = 0;
   67|       |
   68|   142k|    return container;
   69|   142k|}
array_container_create:
   72|  25.6k|array_container_t *array_container_create(void) {
   73|  25.6k|    return array_container_create_given_capacity(ARRAY_DEFAULT_INIT_SIZE);
   74|  25.6k|}
array_container_create_range:
   77|    133|array_container_t *array_container_create_range(uint32_t min, uint32_t max) {
   78|    133|    array_container_t *answer =
   79|    133|        array_container_create_given_capacity(max - min + 1);
   80|    133|    if (answer == NULL) return answer;
  ------------------
  |  Branch (80:9): [True: 0, False: 133]
  ------------------
   81|    133|    answer->cardinality = 0;
   82|    266|    for (uint32_t k = min; k < max; k++) {
  ------------------
  |  Branch (82:28): [True: 133, False: 133]
  ------------------
   83|    133|        answer->array[answer->cardinality++] = k;
   84|    133|    }
   85|    133|    return answer;
   86|    133|}
array_container_clone:
   90|  22.1k|array_container_t *array_container_clone(const array_container_t *src) {
   91|  22.1k|    array_container_t *newcontainer =
   92|  22.1k|        array_container_create_given_capacity(src->capacity);
   93|  22.1k|    if (newcontainer == NULL) return NULL;
  ------------------
  |  Branch (93:9): [True: 0, False: 22.1k]
  ------------------
   94|       |
   95|  22.1k|    newcontainer->cardinality = src->cardinality;
   96|       |
   97|  22.1k|    memcpy(newcontainer->array, src->array,
   98|  22.1k|           src->cardinality * sizeof(uint16_t));
   99|       |
  100|  22.1k|    return newcontainer;
  101|  22.1k|}
array_container_shrink_to_fit:
  131|  3.75k|int array_container_shrink_to_fit(array_container_t *src) {
  132|  3.75k|    if (src->cardinality == src->capacity) return 0;  // nothing to do
  ------------------
  |  Branch (132:9): [True: 475, False: 3.28k]
  ------------------
  133|  3.28k|    int savings = src->capacity - src->cardinality;
  134|  3.28k|    src->capacity = src->cardinality;
  135|  3.28k|    if (src->capacity ==
  ------------------
  |  Branch (135:9): [True: 0, False: 3.28k]
  ------------------
  136|  3.28k|        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.28k|    } else {
  140|  3.28k|        uint16_t *oldarray = src->array;
  141|  3.28k|        src->array = (uint16_t *)roaring_realloc(
  142|  3.28k|            oldarray, src->capacity * sizeof(uint16_t));
  143|  3.28k|        if (src->array == NULL) roaring_free(oldarray);  // should never happen?
  ------------------
  |  Branch (143:13): [True: 0, False: 3.28k]
  ------------------
  144|  3.28k|    }
  145|  3.28k|    return savings;
  146|  3.75k|}
array_container_free:
  149|   142k|void array_container_free(array_container_t *arr) {
  150|   142k|    if (arr == NULL) return;
  ------------------
  |  Branch (150:9): [True: 0, False: 142k]
  ------------------
  151|   142k|    roaring_free(arr->array);
  152|   142k|    roaring_free(arr);
  153|   142k|}
array_container_grow:
  167|   118k|                          bool preserve) {
  168|   118k|    int32_t max = (min <= DEFAULT_MAX_SIZE ? DEFAULT_MAX_SIZE : 65536);
  ------------------
  |  Branch (168:20): [True: 118k, False: 0]
  ------------------
  169|   118k|    int32_t new_capacity = clamp(grow_capacity(container->capacity), min, max);
  170|       |
  171|   118k|    container->capacity = new_capacity;
  172|   118k|    uint16_t *array = container->array;
  173|       |
  174|   118k|    if (preserve) {
  ------------------
  |  Branch (174:9): [True: 108k, False: 9.84k]
  ------------------
  175|   108k|        container->array =
  176|   108k|            (uint16_t *)roaring_realloc(array, new_capacity * sizeof(uint16_t));
  177|   108k|        if (container->array == NULL) roaring_free(array);
  ------------------
  |  Branch (177:13): [True: 0, False: 108k]
  ------------------
  178|   108k|    } else {
  179|  9.84k|        roaring_free(array);
  180|  9.84k|        container->array =
  181|  9.84k|            (uint16_t *)roaring_malloc(new_capacity * sizeof(uint16_t));
  182|  9.84k|    }
  183|       |
  184|       |    // if realloc fails, we have container->array == NULL.
  185|   118k|}
array_container_copy:
  189|     22|                          array_container_t *dst) {
  190|     22|    const int32_t cardinality = src->cardinality;
  191|     22|    if (cardinality > dst->capacity) {
  ------------------
  |  Branch (191:9): [True: 22, False: 0]
  ------------------
  192|     22|        array_container_grow(dst, cardinality, false);
  193|     22|    }
  194|       |
  195|     22|    dst->cardinality = cardinality;
  196|     22|    memcpy(dst->array, src->array, cardinality * sizeof(uint16_t));
  197|     22|}
array_container_union:
  211|  4.76k|                           array_container_t *out) {
  212|  4.76k|    const int32_t card_1 = array_1->cardinality, card_2 = array_2->cardinality;
  213|  4.76k|    const int32_t max_cardinality = card_1 + card_2;
  214|       |
  215|  4.76k|    if (out->capacity < max_cardinality) {
  ------------------
  |  Branch (215:9): [True: 0, False: 4.76k]
  ------------------
  216|       |        array_container_grow(out, max_cardinality, false);
  217|      0|    }
  218|  4.76k|    out->cardinality = (int32_t)fast_union_uint16(
  219|  4.76k|        array_1->array, card_1, array_2->array, card_2, out->array);
  220|  4.76k|}
array_container_andnot:
  228|  5.90k|                            array_container_t *out) {
  229|  5.90k|    if (out->capacity < array_1->cardinality)
  ------------------
  |  Branch (229:9): [True: 2.39k, False: 3.51k]
  ------------------
  230|  2.39k|        array_container_grow(out, array_1->cardinality, false);
  231|  5.90k|#if CROARING_IS_X64
  232|  5.90k|    if ((croaring_hardware_support() & ROARING_SUPPORTS_AVX2) &&
  ------------------
  |  Branch (232:9): [True: 5.90k, False: 0]
  ------------------
  233|  5.90k|        (out != array_1) && (out != array_2)) {
  ------------------
  |  Branch (233:9): [True: 2.39k, False: 3.51k]
  |  Branch (233:29): [True: 2.39k, False: 0]
  ------------------
  234|  2.39k|        out->cardinality = difference_vector16(
  235|  2.39k|            array_1->array, array_1->cardinality, array_2->array,
  236|  2.39k|            array_2->cardinality, out->array);
  237|  3.51k|    } else {
  238|  3.51k|        out->cardinality =
  239|  3.51k|            difference_uint16(array_1->array, array_1->cardinality,
  240|  3.51k|                              array_2->array, array_2->cardinality, out->array);
  241|  3.51k|    }
  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.90k|}
array_container_xor:
  256|  7.84k|                         array_container_t *out) {
  257|  7.84k|    const int32_t card_1 = array_1->cardinality, card_2 = array_2->cardinality;
  258|  7.84k|    const int32_t max_cardinality = card_1 + card_2;
  259|  7.84k|    if (out->capacity < max_cardinality) {
  ------------------
  |  Branch (259:9): [True: 0, False: 7.84k]
  ------------------
  260|      0|        array_container_grow(out, max_cardinality, false);
  261|      0|    }
  262|       |
  263|  7.84k|#if CROARING_IS_X64
  264|  7.84k|    if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (264:9): [True: 7.84k, False: 0]
  ------------------
  265|  7.84k|        out->cardinality =
  266|  7.84k|            xor_vector16(array_1->array, array_1->cardinality, array_2->array,
  267|  7.84k|                         array_2->cardinality, out->array);
  268|  7.84k|    } 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|  7.84k|}
array_container_intersection:
  290|  2.39k|                                  array_container_t *out) {
  291|  2.39k|    int32_t card_1 = array1->cardinality, card_2 = array2->cardinality,
  292|  2.39k|            min_card = minimum_int32(card_1, card_2);
  293|  2.39k|    const int threshold = 64;  // subject to tuning
  294|  2.39k|#if CROARING_IS_X64
  295|  2.39k|    if (out->capacity < min_card) {
  ------------------
  |  Branch (295:9): [True: 2.39k, False: 0]
  ------------------
  296|  2.39k|        array_container_grow(out, min_card + sizeof(__m128i) / sizeof(uint16_t),
  297|  2.39k|                             false);
  298|  2.39k|    }
  299|       |#else
  300|       |    if (out->capacity < min_card) {
  301|       |        array_container_grow(out, min_card, false);
  302|       |    }
  303|       |#endif
  304|       |
  305|  2.39k|    if (card_1 * threshold < card_2) {
  ------------------
  |  Branch (305:9): [True: 347, False: 2.04k]
  ------------------
  306|    347|        out->cardinality = intersect_skewed_uint16(
  307|    347|            array1->array, card_1, array2->array, card_2, out->array);
  308|  2.04k|    } else if (card_2 * threshold < card_1) {
  ------------------
  |  Branch (308:16): [True: 213, False: 1.83k]
  ------------------
  309|    213|        out->cardinality = intersect_skewed_uint16(
  310|    213|            array2->array, card_2, array1->array, card_1, out->array);
  311|  1.83k|    } else {
  312|  1.83k|#if CROARING_IS_X64
  313|  1.83k|        if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (313:13): [True: 1.83k, False: 0]
  ------------------
  314|  1.83k|            out->cardinality = intersect_vector16(
  315|  1.83k|                array1->array, card_1, array2->array, card_2, out->array);
  316|  1.83k|        } 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.83k|    }
  325|  2.39k|}
array_container_intersection_cardinality:
  330|  9.56k|                                             const array_container_t *array2) {
  331|  9.56k|    int32_t card_1 = array1->cardinality, card_2 = array2->cardinality;
  332|  9.56k|    const int threshold = 64;  // subject to tuning
  333|  9.56k|    if (card_1 * threshold < card_2) {
  ------------------
  |  Branch (333:9): [True: 1.38k, False: 8.18k]
  ------------------
  334|  1.38k|        return intersect_skewed_uint16_cardinality(array1->array, card_1,
  335|  1.38k|                                                   array2->array, card_2);
  336|  8.18k|    } else if (card_2 * threshold < card_1) {
  ------------------
  |  Branch (336:16): [True: 852, False: 7.32k]
  ------------------
  337|    852|        return intersect_skewed_uint16_cardinality(array2->array, card_2,
  338|    852|                                                   array1->array, card_1);
  339|  7.32k|    } else {
  340|  7.32k|#if CROARING_IS_X64
  341|  7.32k|        if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (341:13): [True: 7.32k, False: 0]
  ------------------
  342|  7.32k|            return intersect_vector16_cardinality(array1->array, card_1,
  343|  7.32k|                                                  array2->array, card_2);
  344|  7.32k|        } else {
  345|      0|            return intersect_uint16_cardinality(array1->array, card_1,
  346|      0|                                                array2->array, card_2);
  347|      0|        }
  348|       |#else
  349|       |        return intersect_uint16_cardinality(array1->array, card_1,
  350|       |                                            array2->array, card_2);
  351|       |#endif
  352|  7.32k|    }
  353|  9.56k|}
array_container_intersect:
  356|  2.39k|                               const array_container_t *array2) {
  357|  2.39k|    int32_t card_1 = array1->cardinality, card_2 = array2->cardinality;
  358|  2.39k|    const int threshold = 64;  // subject to tuning
  359|  2.39k|    if (card_1 * threshold < card_2) {
  ------------------
  |  Branch (359:9): [True: 347, False: 2.04k]
  ------------------
  360|    347|        return intersect_skewed_uint16_nonempty(array1->array, card_1,
  361|    347|                                                array2->array, card_2);
  362|  2.04k|    } else if (card_2 * threshold < card_1) {
  ------------------
  |  Branch (362:16): [True: 213, False: 1.83k]
  ------------------
  363|    213|        return intersect_skewed_uint16_nonempty(array2->array, card_2,
  364|    213|                                                array1->array, card_1);
  365|  1.83k|    } else {
  366|       |        // we do not bother vectorizing
  367|  1.83k|        return intersect_uint16_nonempty(array1->array, card_1, array2->array,
  368|  1.83k|                                         card_2);
  369|  1.83k|    }
  370|  2.39k|}
array_container_intersection_inplace:
  376|  4.70k|                                          const array_container_t *src_2) {
  377|  4.70k|    int32_t card_1 = src_1->cardinality, card_2 = src_2->cardinality;
  378|  4.70k|    const int threshold = 64;  // subject to tuning
  379|  4.70k|    if (card_1 * threshold < card_2) {
  ------------------
  |  Branch (379:9): [True: 0, False: 4.70k]
  ------------------
  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.70k|    } else if (card_2 * threshold < card_1) {
  ------------------
  |  Branch (382:16): [True: 220, False: 4.48k]
  ------------------
  383|    220|        src_1->cardinality = intersect_skewed_uint16(
  384|    220|            src_2->array, card_2, src_1->array, card_1, src_1->array);
  385|  4.48k|    } else {
  386|  4.48k|#if CROARING_IS_X64
  387|  4.48k|        if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (387:13): [True: 4.48k, False: 0]
  ------------------
  388|  4.48k|            src_1->cardinality = intersect_vector16_inplace(
  389|  4.48k|                src_1->array, card_1, src_2->array, card_2);
  390|  4.48k|        } 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.48k|    }
  399|  4.70k|}
array_container_to_uint32_array:
  403|  5.78k|                                    uint32_t base) {
  404|  5.78k|#if CROARING_IS_X64
  405|  5.78k|    int support = croaring_hardware_support();
  406|  5.78k|#if CROARING_COMPILER_SUPPORTS_AVX512
  407|  5.78k|    if (support & ROARING_SUPPORTS_AVX512) {
  ------------------
  |  Branch (407:9): [True: 0, False: 5.78k]
  ------------------
  408|      0|        return avx512_array_container_to_uint32_array(vout, cont->array,
  409|      0|                                                      cont->cardinality, base);
  410|      0|    }
  411|  5.78k|#endif
  412|  5.78k|    if (support & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (412:9): [True: 5.78k, False: 0]
  ------------------
  413|  5.78k|        return array_container_to_uint32_array_vector16(
  414|  5.78k|            vout, cont->array, cont->cardinality, base);
  415|  5.78k|    }
  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.78k|}
array_container_number_of_runs:
  495|  12.6k|int32_t array_container_number_of_runs(const array_container_t *ac) {
  496|       |    // Can SIMD work here?
  497|  12.6k|    int32_t nr_runs = 0;
  498|  12.6k|    int32_t prev = -2;
  499|  1.62M|    for (const uint16_t *p = ac->array; p != ac->array + ac->cardinality; ++p) {
  ------------------
  |  Branch (499:41): [True: 1.61M, False: 12.6k]
  ------------------
  500|  1.61M|        if (*p != prev + 1) nr_runs++;
  ------------------
  |  Branch (500:13): [True: 870k, False: 740k]
  ------------------
  501|  1.61M|        prev = *p;
  502|  1.61M|    }
  503|  12.6k|    return nr_runs;
  504|  12.6k|}
array_container_write:
  512|  6.97k|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|  6.97k|    memcpy(buf, container->array, container->cardinality * sizeof(uint16_t));
  520|  6.97k|#endif
  521|  6.97k|    return array_container_size_in_bytes(container);
  522|  6.97k|}
array_container_is_subset:
  525|  5.75k|                               const array_container_t *container2) {
  526|  5.75k|    if (container1->cardinality > container2->cardinality) {
  ------------------
  |  Branch (526:9): [True: 636, False: 5.11k]
  ------------------
  527|    636|        return false;
  528|    636|    }
  529|  5.11k|    int i1 = 0, i2 = 0;
  530|  47.0k|    while (i1 < container1->cardinality && i2 < container2->cardinality) {
  ------------------
  |  Branch (530:12): [True: 47.0k, False: 0]
  |  Branch (530:44): [True: 47.0k, False: 22]
  ------------------
  531|  47.0k|        if (container1->array[i1] == container2->array[i2]) {
  ------------------
  |  Branch (531:13): [True: 0, False: 47.0k]
  ------------------
  532|      0|            i1++;
  533|      0|            i2++;
  534|  47.0k|        } else if (container1->array[i1] > container2->array[i2]) {
  ------------------
  |  Branch (534:20): [True: 41.9k, False: 5.09k]
  ------------------
  535|  41.9k|            i2++;
  536|  41.9k|        } else {  // container1->array[i1] < container2->array[i2]
  537|  5.09k|            return false;
  538|  5.09k|        }
  539|  47.0k|    }
  540|     22|    if (i1 == container1->cardinality) {
  ------------------
  |  Branch (540:9): [True: 0, False: 22]
  ------------------
  541|      0|        return true;
  542|     22|    } else {
  543|       |        return false;
  544|     22|    }
  545|     22|}
array_container_read:
  548|  7.02k|                             const char *buf) {
  549|  7.02k|    if (container->capacity < cardinality) {
  ------------------
  |  Branch (549:9): [True: 0, False: 7.02k]
  ------------------
  550|      0|        array_container_grow(container, cardinality, false);
  551|      0|    }
  552|  7.02k|    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.02k|    memcpy(container->array, buf, container->cardinality * sizeof(uint16_t));
  561|  7.02k|#endif
  562|       |
  563|  7.02k|    return array_container_size_in_bytes(container);
  564|  7.02k|}
array_container_iterate:
  567|  6.33k|                             roaring_iterator iterator, void *ptr) {
  568|  2.08M|    for (int i = 0; i < cont->cardinality; i++)
  ------------------
  |  Branch (568:21): [True: 2.07M, False: 6.33k]
  ------------------
  569|  2.07M|        if (!iterator(cont->array[i] + base, ptr)) return false;
  ------------------
  |  Branch (569:13): [True: 0, False: 2.07M]
  ------------------
  570|  6.33k|    return true;
  571|  6.33k|}
array.c:clamp:
  162|   118k|static inline int32_t clamp(int32_t val, int32_t min, int32_t max) {
  163|   118k|    return ((val < min) ? min : (val > max) ? max : val);
  ------------------
  |  Branch (163:13): [True: 26.1k, False: 92.0k]
  |  Branch (163:33): [True: 261, False: 91.7k]
  ------------------
  164|   118k|}
array.c:grow_capacity:
  155|   118k|static inline int32_t grow_capacity(int32_t capacity) {
  156|   118k|    return (capacity <= 0)   ? ARRAY_DEFAULT_INIT_SIZE
  ------------------
  |  Branch (156:12): [True: 25.5k, False: 92.6k]
  ------------------
  157|   118k|           : capacity < 64   ? capacity * 2
  ------------------
  |  Branch (157:14): [True: 67.2k, False: 25.4k]
  ------------------
  158|  92.6k|           : capacity < 1024 ? capacity * 3 / 2
  ------------------
  |  Branch (158:14): [True: 25.0k, False: 316]
  ------------------
  159|  25.4k|                             : capacity * 5 / 4;
  160|   118k|}
array.c:minimum_int32:
  280|  2.39k|static inline int32_t minimum_int32(int32_t a, int32_t b) {
  281|  2.39k|    return (a < b) ? a : b;
  ------------------
  |  Branch (281:12): [True: 985, False: 1.40k]
  ------------------
  282|  2.39k|}

bitset_container_clear:
   51|  72.4k|void bitset_container_clear(bitset_container_t *bitset) {
   52|  72.4k|    memset(bitset->words, 0, sizeof(uint64_t) * BITSET_CONTAINER_SIZE_IN_WORDS);
   53|  72.4k|    bitset->cardinality = 0;
   54|  72.4k|}
bitset_container_set_all:
   56|    153|void bitset_container_set_all(bitset_container_t *bitset) {
   57|       |    memset(bitset->words, INT64_C(-1),
   58|    153|           sizeof(uint64_t) * BITSET_CONTAINER_SIZE_IN_WORDS);
   59|    153|    bitset->cardinality = (1 << 16);
   60|    153|}
bitset_container_create:
   91|  72.4k|bitset_container_t *bitset_container_create(void) {
   92|  72.4k|    bitset_container_t *bitset = bitset_container_allocate();
   93|  72.4k|    if (bitset) {
  ------------------
  |  Branch (93:9): [True: 72.4k, False: 0]
  ------------------
   94|  72.4k|        bitset_container_clear(bitset);
   95|  72.4k|    }
   96|  72.4k|    return bitset;
   97|  72.4k|}
bitset_container_create_uninitialized:
   99|  67.1k|bitset_container_t *bitset_container_create_uninitialized(void) {
  100|  67.1k|    bitset_container_t *bitset = bitset_container_allocate();
  101|  67.1k|    if (bitset) {
  ------------------
  |  Branch (101:9): [True: 67.1k, False: 0]
  ------------------
  102|  67.1k|        bitset->cardinality = 0;
  103|  67.1k|    }
  104|  67.1k|    return bitset;
  105|  67.1k|}
bitset_container_copy:
  109|  3.75k|                           bitset_container_t *dest) {
  110|  3.75k|    dest->cardinality = source->cardinality;
  111|  3.75k|    memcpy(dest->words, source->words,
  112|  3.75k|           sizeof(uint64_t) * BITSET_CONTAINER_SIZE_IN_WORDS);
  113|  3.75k|}
bitset_container_free:
  144|   274k|void bitset_container_free(bitset_container_t *bitset) {
  145|   274k|    if (bitset == NULL) return;
  ------------------
  |  Branch (145:9): [True: 0, False: 274k]
  ------------------
  146|   274k|    roaring_aligned_free(bitset->words);
  147|   274k|    roaring_free(bitset);
  148|   274k|}
bitset_container_clone:
  152|   135k|bitset_container_t *bitset_container_clone(const bitset_container_t *src) {
  153|   135k|    bitset_container_t *bitset =
  154|   135k|        (bitset_container_t *)roaring_malloc(sizeof(bitset_container_t));
  155|       |
  156|   135k|    if (!bitset) {
  ------------------
  |  Branch (156:9): [True: 0, False: 135k]
  ------------------
  157|      0|        return NULL;
  158|      0|    }
  159|       |
  160|   135k|    size_t align_size = 32;
  161|   135k|#if CROARING_IS_X64
  162|   135k|    if (croaring_hardware_support() & ROARING_SUPPORTS_AVX512) {
  ------------------
  |  Branch (162:9): [True: 0, False: 135k]
  ------------------
  163|       |        // sizeof(__m512i) == 64
  164|      0|        align_size = 64;
  165|   135k|    } else {
  166|       |        // sizeof(__m256i) == 32
  167|   135k|        align_size = 32;
  168|   135k|    }
  169|   135k|#endif
  170|   135k|    bitset->words = (uint64_t *)roaring_aligned_malloc(
  171|   135k|        align_size, sizeof(uint64_t) * BITSET_CONTAINER_SIZE_IN_WORDS);
  172|   135k|    if (!bitset->words) {
  ------------------
  |  Branch (172:9): [True: 0, False: 135k]
  ------------------
  173|      0|        roaring_free(bitset);
  174|      0|        return NULL;
  175|      0|    }
  176|   135k|    bitset->cardinality = src->cardinality;
  177|   135k|    memcpy(bitset->words, src->words,
  178|   135k|           sizeof(uint64_t) * BITSET_CONTAINER_SIZE_IN_WORDS);
  179|   135k|    return bitset;
  180|   135k|}
bitset_container_compute_cardinality:
  284|  3.40k|int bitset_container_compute_cardinality(const bitset_container_t *bitset) {
  285|  3.40k|    int support = croaring_hardware_support();
  286|  3.40k|#if CROARING_COMPILER_SUPPORTS_AVX512
  287|  3.40k|    if (support & ROARING_SUPPORTS_AVX512) {
  ------------------
  |  Branch (287:9): [True: 0, False: 3.40k]
  ------------------
  288|      0|        return (int)avx512_vpopcount(
  289|      0|            (const __m512i *)bitset->words,
  290|      0|            BITSET_CONTAINER_SIZE_IN_WORDS / (WORDS_IN_AVX512_REG));
  ------------------
  |  |  268|      0|#define WORDS_IN_AVX512_REG sizeof(__m512i) / sizeof(uint64_t)
  ------------------
  291|      0|    } else
  292|  3.40k|#endif  // CROARING_COMPILER_SUPPORTS_AVX512
  293|  3.40k|        if (support & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (293:13): [True: 3.40k, False: 0]
  ------------------
  294|  3.40k|            return (int)avx2_harley_seal_popcount256(
  295|  3.40k|                (const __m256i *)bitset->words,
  296|  3.40k|                BITSET_CONTAINER_SIZE_IN_WORDS / (CROARING_WORDS_IN_AVX2_REG));
  ------------------
  |  |  265|  3.40k|#define CROARING_WORDS_IN_AVX2_REG sizeof(__m256i) / sizeof(uint64_t)
  ------------------
  297|  3.40k|        } else {
  298|      0|            return _scalar_bitset_container_compute_cardinality(bitset);
  299|      0|        }
  300|  3.40k|}
bitset_container_and_nocard:
  739|  1.41k|                                         bitset_container_t *dst) {            \
  740|  1.41k|    int support = croaring_hardware_support();                                 \
  741|  1.41k|    if ( support & ROARING_SUPPORTS_AVX512 ) {                                 \
  ------------------
  |  Branch (741:10): [True: 0, False: 1.41k]
  ------------------
  742|      0|      return _avx512_bitset_container_##opname##_nocard(src_1, src_2, dst);    \
  743|      0|    }                                                                          \
  744|  1.41k|    else if ( support & ROARING_SUPPORTS_AVX2 ) {                              \
  ------------------
  |  Branch (744:15): [True: 1.41k, False: 0]
  ------------------
  745|  1.41k|      return _avx2_bitset_container_##opname##_nocard(src_1, src_2, dst);      \
  746|  1.41k|    } else {                                                                   \
  747|      0|      return _scalar_bitset_container_##opname##_nocard(src_1, src_2, dst);    \
  748|      0|    }                                                                          \
  749|  1.41k|  }                                                                            \
bitset_container_and_justcard:
  751|  1.41k|                                           const bitset_container_t *src_2) {  \
  752|  1.41k|     int support = croaring_hardware_support();                                \
  753|  1.41k|    if ( support & ROARING_SUPPORTS_AVX512 ) {                                 \
  ------------------
  |  Branch (753:10): [True: 0, False: 1.41k]
  ------------------
  754|      0|      return _avx512_bitset_container_##opname##_justcard(src_1, src_2);       \
  755|      0|    }                                                                          \
  756|  1.41k|    else if ( support & ROARING_SUPPORTS_AVX2 ) {                              \
  ------------------
  |  Branch (756:15): [True: 1.41k, False: 0]
  ------------------
  757|  1.41k|      return _avx2_bitset_container_##opname##_justcard(src_1, src_2);         \
  758|  1.41k|    } else {                                                                   \
  759|      0|      return _scalar_bitset_container_##opname##_justcard(src_1, src_2);       \
  760|      0|    }                                                                          \
  761|  1.41k|  }
bitset_container_xor:
  726|  1.45k|                                bitset_container_t *dst) {                     \
  727|  1.45k|    int support = croaring_hardware_support();                                 \
  728|  1.45k|    if ( support & ROARING_SUPPORTS_AVX512 ) {                                 \
  ------------------
  |  Branch (728:10): [True: 0, False: 1.45k]
  ------------------
  729|      0|      return _avx512_bitset_container_##opname(src_1, src_2, dst);             \
  730|      0|    }                                                                          \
  731|  1.45k|    else if ( support & ROARING_SUPPORTS_AVX2 ) {                              \
  ------------------
  |  Branch (731:15): [True: 1.45k, False: 0]
  ------------------
  732|  1.45k|      return _avx2_bitset_container_##opname(src_1, src_2, dst);               \
  733|  1.45k|    } else {                                                                   \
  734|      0|      return _scalar_bitset_container_##opname(src_1, src_2, dst);             \
  735|      0|    }                                                                          \
  736|  1.45k|  }                                                                            \
bitset_container_to_uint32_array:
  951|  1.41k|){
  952|  1.41k|#if CROARING_IS_X64
  953|  1.41k|   int support = croaring_hardware_support();
  954|  1.41k|#if CROARING_COMPILER_SUPPORTS_AVX512
  955|       |   // Unlike the AVX2 kernel, the AVX-512 one needs no cardinality heuristic:
  956|       |   // it skips empty words and only stores the blocks that carry a value, so it
  957|       |   // beat the scalar loop at every cardinality measured from 16 to 65536 (on
  958|       |   // an Emerald Rapids Xeon, 1.3x at 512 values, 6x at 4096, 7.5x at 8192).
  959|  1.41k|   if( support & ROARING_SUPPORTS_AVX512 )
  ------------------
  |  Branch (959:8): [True: 0, False: 1.41k]
  ------------------
  960|      0|		return (int) bitset_extract_setbits_avx512(bc->words,
  961|      0|                BITSET_CONTAINER_SIZE_IN_WORDS, out, bc->cardinality, base);
  962|  1.41k|   else
  963|  1.41k|#endif
  964|  1.41k|   if(( support & ROARING_SUPPORTS_AVX2 ) &&  (bc->cardinality >= 8192))  // heuristic
  ------------------
  |  Branch (964:7): [True: 1.41k, False: 0]
  |  Branch (964:47): [True: 987, False: 432]
  ------------------
  965|    987|		return (int) bitset_extract_setbits_avx2(bc->words,
  966|    987|                BITSET_CONTAINER_SIZE_IN_WORDS, out, bc->cardinality, base);
  967|    432|	else
  968|    432|		return (int) bitset_extract_setbits(bc->words,
  969|    432|                BITSET_CONTAINER_SIZE_IN_WORDS, out, base);
  970|       |#else
  971|       |	return (int) bitset_extract_setbits(bc->words,
  972|       |                BITSET_CONTAINER_SIZE_IN_WORDS, out, base);
  973|       |#endif
  974|  1.41k|}
bitset_container_write:
 1069|  67.1k|                                  char *buf) {
 1070|       |#if CROARING_IS_BIG_ENDIAN
 1071|       |	for (int32_t i = 0; i < BITSET_CONTAINER_SIZE_IN_WORDS; ++i) {
 1072|       |		uint64_t w_le = croaring_htole64(container->words[i]);
 1073|       |		memcpy(buf + i * sizeof(uint64_t), &w_le, sizeof(uint64_t));
 1074|       |	}
 1075|       |#else
 1076|  67.1k|	memcpy(buf, container->words, BITSET_CONTAINER_SIZE_IN_WORDS * sizeof(uint64_t));
 1077|  67.1k|#endif
 1078|  67.1k|	return bitset_container_size_in_bytes(container);
 1079|  67.1k|}
bitset_container_read:
 1083|  67.1k|		const char *buf)  {
 1084|  67.1k|	container->cardinality = cardinality;
 1085|       |#if CROARING_IS_BIG_ENDIAN
 1086|       |	for (int32_t i = 0; i < BITSET_CONTAINER_SIZE_IN_WORDS; ++i) {
 1087|       |		uint64_t w_le;
 1088|       |		memcpy(&w_le, buf + i * sizeof(uint64_t), sizeof(uint64_t));
 1089|       |		container->words[i] = croaring_letoh64(w_le);
 1090|       |	}
 1091|       |#else
 1092|  67.1k|	memcpy(container->words, buf, BITSET_CONTAINER_SIZE_IN_WORDS * sizeof(uint64_t));
 1093|  67.1k|#endif
 1094|  67.1k|	return bitset_container_size_in_bytes(container);
 1095|  67.1k|}
bitset_container_iterate:
 1097|  1.56k|bool bitset_container_iterate(const bitset_container_t *cont, uint32_t base, roaring_iterator iterator, void *ptr) {
 1098|  1.60M|  for (int32_t i = 0; i < BITSET_CONTAINER_SIZE_IN_WORDS; ++i ) {
  ------------------
  |  Branch (1098:23): [True: 1.60M, False: 1.56k]
  ------------------
 1099|  1.60M|    uint64_t w = cont->words[i];
 1100|  61.4M|    while (w != 0) {
  ------------------
  |  Branch (1100:12): [True: 59.8M, False: 1.60M]
  ------------------
 1101|  59.8M|      uint64_t t = w & (~w + 1);
 1102|  59.8M|      int r = roaring_trailing_zeroes(w);
 1103|  59.8M|      if(!iterator(r + base, ptr)) return false;
  ------------------
  |  Branch (1103:10): [True: 0, False: 59.8M]
  ------------------
 1104|  59.8M|      w ^= t;
 1105|  59.8M|    }
 1106|  1.60M|    base += 64;
 1107|  1.60M|  }
 1108|  1.56k|  return true;
 1109|  1.56k|}
bitset_container_equals:
 1163|  67.1k|bool bitset_container_equals(const bitset_container_t *container1, const bitset_container_t *container2) {
 1164|  67.1k|  if((container1->cardinality != BITSET_UNKNOWN_CARDINALITY) && (container2->cardinality != BITSET_UNKNOWN_CARDINALITY)) {
  ------------------
  |  Branch (1164:6): [True: 67.1k, False: 0]
  |  Branch (1164:65): [True: 67.1k, False: 0]
  ------------------
 1165|  67.1k|    if(container1->cardinality != container2->cardinality) {
  ------------------
  |  Branch (1165:8): [True: 0, False: 67.1k]
  ------------------
 1166|      0|      return false;
 1167|      0|    }
 1168|  67.1k|    if (container1->cardinality == INT32_C(0x10000)) {
  ------------------
  |  Branch (1168:9): [True: 63.3k, False: 3.81k]
  ------------------
 1169|  63.3k|      return true;
 1170|  63.3k|    }
 1171|  67.1k|  }
 1172|  3.81k|#if CROARING_IS_X64
 1173|  3.81k|  int support = croaring_hardware_support();
 1174|  3.81k|#if CROARING_COMPILER_SUPPORTS_AVX512
 1175|  3.81k|  if( support & ROARING_SUPPORTS_AVX512 ) {
  ------------------
  |  Branch (1175:7): [True: 0, False: 3.81k]
  ------------------
 1176|      0|    return _avx512_bitset_container_equals(container1, container2);
 1177|      0|  }
 1178|  3.81k|  else
 1179|  3.81k|#endif
 1180|  3.81k|  if( support & ROARING_SUPPORTS_AVX2 ) {
  ------------------
  |  Branch (1180:7): [True: 3.81k, False: 0]
  ------------------
 1181|  3.81k|    return _avx2_bitset_container_equals(container1, container2);
 1182|  3.81k|  }
 1183|      0|#endif
 1184|      0|  return memcmp(container1->words,
 1185|      0|                container2->words,
 1186|      0|                BITSET_CONTAINER_SIZE_IN_WORDS*sizeof(uint64_t)) == 0;
 1187|  3.81k|}
bitset_container_minimum:
 1237|  1.18k|uint16_t bitset_container_minimum(const bitset_container_t *container) {
 1238|  13.3k|  for (int32_t i = 0; i < BITSET_CONTAINER_SIZE_IN_WORDS; ++i ) {
  ------------------
  |  Branch (1238:23): [True: 13.3k, False: 0]
  ------------------
 1239|  13.3k|    uint64_t w = container->words[i];
 1240|  13.3k|    if (w != 0) {
  ------------------
  |  Branch (1240:9): [True: 1.18k, False: 12.2k]
  ------------------
 1241|  1.18k|      int r = roaring_trailing_zeroes(w);
 1242|  1.18k|      return r + i * 64;
 1243|  1.18k|    }
 1244|  13.3k|  }
 1245|      0|  return UINT16_MAX;
 1246|  1.18k|}
bitset_container_maximum:
 1249|  4.22k|uint16_t bitset_container_maximum(const bitset_container_t *container) {
 1250|   975k|  for (int32_t i = BITSET_CONTAINER_SIZE_IN_WORDS - 1; i > 0; --i ) {
  ------------------
  |  Branch (1250:56): [True: 975k, False: 0]
  ------------------
 1251|   975k|    uint64_t w = container->words[i];
 1252|   975k|    if (w != 0) {
  ------------------
  |  Branch (1252:9): [True: 4.22k, False: 971k]
  ------------------
 1253|  4.22k|      int r = roaring_leading_zeroes(w);
 1254|  4.22k|      return i * 64 + 63  - r;
 1255|  4.22k|    }
 1256|   975k|  }
 1257|      0|  return 0;
 1258|  4.22k|}
bitset_container_index_equalorlarger:
 1318|  1.78k|int bitset_container_index_equalorlarger(const bitset_container_t *container, uint16_t x) {
 1319|  1.78k|  uint32_t x32 = x;
 1320|  1.78k|  uint32_t k = x32 / 64;
 1321|  1.78k|  uint64_t word = container->words[k];
 1322|  1.78k|  const int diff = x32 - k * 64; // in [0,64)
 1323|  1.78k|  word = (word >> diff) << diff; // a mask is faster, but we don't care
 1324|  3.96k|  while(word == 0) {
  ------------------
  |  Branch (1324:9): [True: 2.17k, False: 1.78k]
  ------------------
 1325|  2.17k|    k++;
 1326|  2.17k|    if(k == BITSET_CONTAINER_SIZE_IN_WORDS) return -1;
  ------------------
  |  Branch (1326:8): [True: 0, False: 2.17k]
  ------------------
 1327|  2.17k|    word = container->words[k];
 1328|  2.17k|  }
 1329|  1.78k|  return k * 64 + roaring_trailing_zeroes(word);
 1330|  1.78k|}
bitset.c:bitset_container_allocate:
   62|   139k|static bitset_container_t *bitset_container_allocate(void) {
   63|   139k|    bitset_container_t *bitset =
   64|   139k|        (bitset_container_t *)roaring_malloc(sizeof(bitset_container_t));
   65|       |
   66|   139k|    if (!bitset) {
  ------------------
  |  Branch (66:9): [True: 0, False: 139k]
  ------------------
   67|      0|        return NULL;
   68|      0|    }
   69|       |
   70|   139k|    size_t align_size = 32;
   71|   139k|#if CROARING_IS_X64
   72|   139k|    int support = croaring_hardware_support();
   73|   139k|    if (support & ROARING_SUPPORTS_AVX512) {
  ------------------
  |  Branch (73:9): [True: 0, False: 139k]
  ------------------
   74|       |        // sizeof(__m512i) == 64
   75|      0|        align_size = 64;
   76|   139k|    } else {
   77|       |        // sizeof(__m256i) == 32
   78|   139k|        align_size = 32;
   79|   139k|    }
   80|   139k|#endif
   81|   139k|    bitset->words = (uint64_t *)roaring_aligned_malloc(
   82|   139k|        align_size, sizeof(uint64_t) * BITSET_CONTAINER_SIZE_IN_WORDS);
   83|   139k|    if (!bitset->words) {
  ------------------
  |  Branch (83:9): [True: 0, False: 139k]
  ------------------
   84|      0|        roaring_free(bitset);
   85|      0|        return NULL;
   86|      0|    }
   87|   139k|    return bitset;
   88|   139k|}
bitset.c:_avx2_bitset_container_and_nocard:
  518|  1.41k|      bitset_container_t *dst) {                                               \
  519|  1.41k|    const uint8_t *__restrict__ words_1 = (const uint8_t *)src_1->words;       \
  520|  1.41k|    const uint8_t *__restrict__ words_2 = (const uint8_t *)src_2->words;       \
  521|  1.41k|    /* not using the blocking optimization for some reason*/                   \
  522|  1.41k|    uint8_t *out = (uint8_t *)dst->words;                                      \
  523|  1.41k|    const int innerloop = 8;                                                   \
  524|  1.41k|    for (size_t i = 0;                                                         \
  525|  46.8k|         i < BITSET_CONTAINER_SIZE_IN_WORDS / (CROARING_WORDS_IN_AVX2_REG);             \
  ------------------
  |  |  265|  46.8k|#define CROARING_WORDS_IN_AVX2_REG sizeof(__m256i) / sizeof(uint64_t)
  ------------------
  |  Branch (525:10): [True: 45.4k, False: 1.41k]
  ------------------
  526|  45.4k|         i += innerloop) {                                                     \
  527|  45.4k|      __m256i A1, A2, AO;                                                      \
  528|  45.4k|      A1 = _mm256_loadu_si256((const __m256i *)(words_1));                     \
  529|  45.4k|      A2 = _mm256_loadu_si256((const __m256i *)(words_2));                     \
  530|  45.4k|      AO = avx_intrinsic(A2, A1);                                              \
  531|  45.4k|      _mm256_storeu_si256((__m256i *)out, AO);                                 \
  532|  45.4k|      A1 = _mm256_loadu_si256((const __m256i *)(words_1 + 32));                \
  533|  45.4k|      A2 = _mm256_loadu_si256((const __m256i *)(words_2 + 32));                \
  534|  45.4k|      AO = avx_intrinsic(A2, A1);                                              \
  535|  45.4k|      _mm256_storeu_si256((__m256i *)(out + 32), AO);                          \
  536|  45.4k|      A1 = _mm256_loadu_si256((const __m256i *)(words_1 + 64));                \
  537|  45.4k|      A2 = _mm256_loadu_si256((const __m256i *)(words_2 + 64));                \
  538|  45.4k|      AO = avx_intrinsic(A2, A1);                                              \
  539|  45.4k|      _mm256_storeu_si256((__m256i *)(out + 64), AO);                          \
  540|  45.4k|      A1 = _mm256_loadu_si256((const __m256i *)(words_1 + 96));                \
  541|  45.4k|      A2 = _mm256_loadu_si256((const __m256i *)(words_2 + 96));                \
  542|  45.4k|      AO = avx_intrinsic(A2, A1);                                              \
  543|  45.4k|      _mm256_storeu_si256((__m256i *)(out + 96), AO);                          \
  544|  45.4k|      A1 = _mm256_loadu_si256((const __m256i *)(words_1 + 128));               \
  545|  45.4k|      A2 = _mm256_loadu_si256((const __m256i *)(words_2 + 128));               \
  546|  45.4k|      AO = avx_intrinsic(A2, A1);                                              \
  547|  45.4k|      _mm256_storeu_si256((__m256i *)(out + 128), AO);                         \
  548|  45.4k|      A1 = _mm256_loadu_si256((const __m256i *)(words_1 + 160));               \
  549|  45.4k|      A2 = _mm256_loadu_si256((const __m256i *)(words_2 + 160));               \
  550|  45.4k|      AO = avx_intrinsic(A2, A1);                                              \
  551|  45.4k|      _mm256_storeu_si256((__m256i *)(out + 160), AO);                         \
  552|  45.4k|      A1 = _mm256_loadu_si256((const __m256i *)(words_1 + 192));               \
  553|  45.4k|      A2 = _mm256_loadu_si256((const __m256i *)(words_2 + 192));               \
  554|  45.4k|      AO = avx_intrinsic(A2, A1);                                              \
  555|  45.4k|      _mm256_storeu_si256((__m256i *)(out + 192), AO);                         \
  556|  45.4k|      A1 = _mm256_loadu_si256((const __m256i *)(words_1 + 224));               \
  557|  45.4k|      A2 = _mm256_loadu_si256((const __m256i *)(words_2 + 224));               \
  558|  45.4k|      AO = avx_intrinsic(A2, A1);                                              \
  559|  45.4k|      _mm256_storeu_si256((__m256i *)(out + 224), AO);                         \
  560|  45.4k|      out += 256;                                                              \
  561|  45.4k|      words_1 += 256;                                                          \
  562|  45.4k|      words_2 += 256;                                                          \
  563|  45.4k|    }                                                                          \
  564|  1.41k|    dst->cardinality = BITSET_UNKNOWN_CARDINALITY;                             \
  565|  1.41k|    return dst->cardinality;                                                   \
  566|  1.41k|  }
bitset.c:_avx2_bitset_container_and_justcard:
  587|  1.41k|      const bitset_container_t *src_1, const bitset_container_t *src_2) {      \
  588|  1.41k|    const __m256i *__restrict__ data1 = (const __m256i *)src_1->words;         \
  589|  1.41k|    const __m256i *__restrict__ data2 = (const __m256i *)src_2->words;         \
  590|  1.41k|    return (int)avx2_harley_seal_popcount256_##opname(                         \
  591|  1.41k|        data2, data1, BITSET_CONTAINER_SIZE_IN_WORDS / (CROARING_WORDS_IN_AVX2_REG));   \
  ------------------
  |  |  265|  1.41k|#define CROARING_WORDS_IN_AVX2_REG sizeof(__m256i) / sizeof(uint64_t)
  ------------------
  592|  1.41k|  }
bitset.c:_avx2_bitset_container_xor:
  573|  1.45k|                                      bitset_container_t *dst) {               \
  574|  1.45k|    const __m256i *__restrict__ words_1 = (const __m256i *)src_1->words;       \
  575|  1.45k|    const __m256i *__restrict__ words_2 = (const __m256i *)src_2->words;       \
  576|  1.45k|    __m256i *out = (__m256i *)dst->words;                                      \
  577|  1.45k|    dst->cardinality = (int32_t)avx2_harley_seal_popcount256andstore_##opname( \
  578|  1.45k|        words_2, words_1, out,                                                 \
  579|  1.45k|        BITSET_CONTAINER_SIZE_IN_WORDS / (CROARING_WORDS_IN_AVX2_REG));                 \
  ------------------
  |  |  265|  1.45k|#define CROARING_WORDS_IN_AVX2_REG sizeof(__m256i) / sizeof(uint64_t)
  ------------------
  580|  1.45k|    return dst->cardinality;                                                   \
  581|  1.45k|  }                                                                            \
bitset.c:_avx2_bitset_container_equals:
 1146|  3.81k|static inline bool _avx2_bitset_container_equals(const bitset_container_t *container1, const bitset_container_t *container2) {
 1147|  3.81k|    const __m256i *ptr1 = (const __m256i*)container1->words;
 1148|  3.81k|    const __m256i *ptr2 = (const __m256i*)container2->words;
 1149|   980k|    for (size_t i = 0; i < BITSET_CONTAINER_SIZE_IN_WORDS*sizeof(uint64_t)/32; i++) {
  ------------------
  |  Branch (1149:24): [True: 976k, False: 3.81k]
  ------------------
 1150|   976k|      __m256i r1 = _mm256_loadu_si256(ptr1+i);
 1151|   976k|      __m256i r2 = _mm256_loadu_si256(ptr2+i);
 1152|   976k|      int mask = _mm256_movemask_epi8(_mm256_cmpeq_epi8(r1, r2));
 1153|   976k|      if ((uint32_t)mask != UINT32_MAX) {
  ------------------
  |  Branch (1153:11): [True: 0, False: 976k]
  ------------------
 1154|      0|          return false;
 1155|      0|      }
 1156|   976k|  }
 1157|  3.81k|	return true;
 1158|  3.81k|}

container_free:
   58|   586k|void container_free(container_t *c, uint8_t type) {
   59|   586k|    switch (type) {
   60|   272k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|   272k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (60:9): [True: 272k, False: 314k]
  ------------------
   61|   272k|            bitset_container_free(CAST_bitset(c));
  ------------------
  |  |   52|   272k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|   272k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
   62|   272k|            break;
   63|   128k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|   128k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (63:9): [True: 128k, False: 457k]
  ------------------
   64|   128k|            array_container_free(CAST_array(c));
  ------------------
  |  |   54|   128k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|   128k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
   65|   128k|            break;
   66|   185k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|   185k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (66:9): [True: 185k, False: 400k]
  ------------------
   67|   185k|            run_container_free(CAST_run(c));
  ------------------
  |  |   77|   185k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|   185k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
   68|   185k|            break;
   69|      0|        case SHARED_CONTAINER_TYPE:
  ------------------
  |  |   51|      0|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (69:9): [True: 0, False: 586k]
  ------------------
   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: 586k]
  ------------------
   73|      0|            assert(false);
   74|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
   75|   586k|    }
   76|   586k|}
get_copy_of_container:
  181|    268|                                   bool copy_on_write) {
  182|    268|    if (copy_on_write) {
  ------------------
  |  Branch (182:9): [True: 0, False: 268]
  ------------------
  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|    268|    const container_t *actual_container = container_unwrap_shared(c, typecode);
  209|       |    assert(*typecode != SHARED_CONTAINER_TYPE);
  210|    268|    return container_clone(actual_container, *typecode);
  211|    268|}
container_clone:
  217|   323k|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|   323k|    switch (typecode) {
  221|   135k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|   135k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (221:9): [True: 135k, False: 188k]
  ------------------
  222|   135k|            return bitset_container_clone(const_CAST_bitset(c));
  ------------------
  |  |   53|   135k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|   135k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  223|  22.1k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  22.1k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (223:9): [True: 22.1k, False: 301k]
  ------------------
  224|  22.1k|            return array_container_clone(const_CAST_array(c));
  ------------------
  |  |   55|  22.1k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  22.1k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  225|   166k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|   166k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (225:9): [True: 166k, False: 157k]
  ------------------
  226|   166k|            return run_container_clone(const_CAST_run(c));
  ------------------
  |  |   78|   166k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|   166k|#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: 323k]
  ------------------
  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: 323k]
  ------------------
  232|      0|            assert(false);
  233|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  234|      0|            return NULL;
  235|   323k|    }
  236|   323k|}
container_init_iterator:
  306|  18.6k|                                                     uint16_t *value) {
  307|  18.6k|    switch (typecode) {
  308|  3.63k|        case BITSET_CONTAINER_TYPE: {
  ------------------
  |  |   48|  3.63k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (308:9): [True: 3.63k, False: 15.0k]
  ------------------
  309|  3.63k|            const bitset_container_t *bc = const_CAST_bitset(c);
  ------------------
  |  |   53|  3.63k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.63k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  310|  3.63k|            uint32_t wordindex = 0;
  311|  3.63k|            uint64_t word;
  312|  31.2k|            while ((word = bc->words[wordindex]) == 0) {
  ------------------
  |  Branch (312:20): [True: 27.6k, False: 3.63k]
  ------------------
  313|  27.6k|                wordindex++;
  314|  27.6k|            }
  315|       |            // word is non-zero
  316|  3.63k|            int32_t index = wordindex * 64 + roaring_trailing_zeroes(word);
  317|  3.63k|            *value = index;
  318|  3.63k|            return ROARING_INIT_ROARING_CONTAINER_ITERATOR_T{
  ------------------
  |  |   13|  3.63k|#define ROARING_INIT_ROARING_CONTAINER_ITERATOR_T (roaring_container_iterator_t)
  ------------------
  319|  3.63k|                .index = index,
  320|  3.63k|            };
  321|      0|        }
  322|  14.5k|        case ARRAY_CONTAINER_TYPE: {
  ------------------
  |  |   49|  14.5k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (322:9): [True: 14.5k, False: 4.13k]
  ------------------
  323|  14.5k|            const array_container_t *ac = const_CAST_array(c);
  ------------------
  |  |   55|  14.5k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  14.5k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  324|  14.5k|            *value = ac->array[0];
  325|  14.5k|            return ROARING_INIT_ROARING_CONTAINER_ITERATOR_T{
  ------------------
  |  |   13|  14.5k|#define ROARING_INIT_ROARING_CONTAINER_ITERATOR_T (roaring_container_iterator_t)
  ------------------
  326|  14.5k|                .index = 0,
  327|  14.5k|            };
  328|      0|        }
  329|    497|        case RUN_CONTAINER_TYPE: {
  ------------------
  |  |   50|    497|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (329:9): [True: 497, False: 18.1k]
  ------------------
  330|    497|            const run_container_t *rc = const_CAST_run(c);
  ------------------
  |  |   78|    497|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    497|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  331|    497|            *value = rc->runs[0].value;
  332|    497|            return ROARING_INIT_ROARING_CONTAINER_ITERATOR_T{
  ------------------
  |  |   13|    497|#define ROARING_INIT_ROARING_CONTAINER_ITERATOR_T (roaring_container_iterator_t)
  ------------------
  333|    497|                .index = 0,
  334|    497|            };
  335|      0|        }
  336|      0|        default:
  ------------------
  |  Branch (336:9): [True: 0, False: 18.6k]
  ------------------
  337|      0|            assert(false);
  338|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  339|      0|            return ROARING_INIT_ROARING_CONTAINER_ITERATOR_T{0};
  ------------------
  |  |   13|      0|#define ROARING_INIT_ROARING_CONTAINER_ITERATOR_T (roaring_container_iterator_t)
  ------------------
  340|  18.6k|    }
  341|  18.6k|}
container_iterator_lower_bound:
  389|  6.21k|                                    uint16_t *value_out, uint16_t val) {
  390|  6.21k|    if (val > container_maximum(c, typecode)) {
  ------------------
  |  Branch (390:9): [True: 0, False: 6.21k]
  ------------------
  391|      0|        return false;
  392|      0|    }
  393|  6.21k|    switch (typecode) {
  394|  1.78k|        case BITSET_CONTAINER_TYPE: {
  ------------------
  |  |   48|  1.78k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (394:9): [True: 1.78k, False: 4.42k]
  ------------------
  395|  1.78k|            const bitset_container_t *bc = const_CAST_bitset(c);
  ------------------
  |  |   53|  1.78k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.78k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  396|  1.78k|            it->index = bitset_container_index_equalorlarger(bc, val);
  397|  1.78k|            *value_out = it->index;
  398|  1.78k|            return true;
  399|      0|        }
  400|  4.42k|        case ARRAY_CONTAINER_TYPE: {
  ------------------
  |  |   49|  4.42k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (400:9): [True: 4.42k, False: 1.78k]
  ------------------
  401|  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)
  |  |  ------------------
  ------------------
  402|  4.42k|            it->index = array_container_index_equalorlarger(ac, val);
  403|  4.42k|            *value_out = ac->array[it->index];
  404|  4.42k|            return true;
  405|      0|        }
  406|      0|        case RUN_CONTAINER_TYPE: {
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (406:9): [True: 0, False: 6.21k]
  ------------------
  407|      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)
  |  |  ------------------
  ------------------
  408|      0|            it->index = run_container_index_equalorlarger(rc, val);
  409|      0|            if (rc->runs[it->index].value <= val) {
  ------------------
  |  Branch (409:17): [True: 0, False: 0]
  ------------------
  410|      0|                *value_out = val;
  411|      0|            } else {
  412|      0|                *value_out = rc->runs[it->index].value;
  413|      0|            }
  414|      0|            return true;
  415|      0|        }
  416|      0|        default:
  ------------------
  |  Branch (416:9): [True: 0, False: 6.21k]
  ------------------
  417|      0|            assert(false);
  418|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  419|      0|            return false;
  420|  6.21k|    }
  421|  6.21k|}

bitset_container_from_array:
   22|  2.23k|bitset_container_t *bitset_container_from_array(const array_container_t *ac) {
   23|  2.23k|    bitset_container_t *ans = bitset_container_create();
   24|  2.23k|    int limit = array_container_cardinality(ac);
   25|  2.38M|    for (int i = 0; i < limit; ++i) bitset_container_set(ans, ac->array[i]);
  ------------------
  |  Branch (25:21): [True: 2.38M, False: 2.23k]
  ------------------
   26|  2.23k|    return ans;
   27|  2.23k|}
bitset_container_from_run:
   29|    568|bitset_container_t *bitset_container_from_run(const run_container_t *arr) {
   30|    568|    int card = run_container_cardinality(arr);
   31|    568|    bitset_container_t *answer = bitset_container_create();
   32|  21.9k|    for (int rlepos = 0; rlepos < arr->n_runs; ++rlepos) {
  ------------------
  |  Branch (32:26): [True: 21.3k, False: 568]
  ------------------
   33|  21.3k|        rle16_t vl = arr->runs[rlepos];
   34|  21.3k|        bitset_set_lenrange(answer->words, vl.value, vl.length);
   35|  21.3k|    }
   36|    568|    answer->cardinality = card;
   37|    568|    return answer;
   38|    568|}
array_container_from_run:
   40|  1.14k|array_container_t *array_container_from_run(const run_container_t *arr) {
   41|  1.14k|    array_container_t *answer =
   42|  1.14k|        array_container_create_given_capacity(run_container_cardinality(arr));
   43|  1.14k|    answer->cardinality = 0;
   44|  86.4k|    for (int rlepos = 0; rlepos < arr->n_runs; ++rlepos) {
  ------------------
  |  Branch (44:26): [True: 85.3k, False: 1.14k]
  ------------------
   45|  85.3k|        int run_start = arr->runs[rlepos].value;
   46|  85.3k|        int run_end = run_start + arr->runs[rlepos].length;
   47|       |
   48|   449k|        for (int run_value = run_start; run_value <= run_end; ++run_value) {
  ------------------
  |  Branch (48:41): [True: 364k, False: 85.3k]
  ------------------
   49|   364k|            answer->array[answer->cardinality++] = (uint16_t)run_value;
   50|   364k|        }
   51|  85.3k|    }
   52|  1.14k|    return answer;
   53|  1.14k|}
array_container_from_bitset:
   55|  2.76k|array_container_t *array_container_from_bitset(const bitset_container_t *bits) {
   56|  2.76k|    array_container_t *result =
   57|  2.76k|        array_container_create_given_capacity(bits->cardinality);
   58|  2.76k|    result->cardinality = bits->cardinality;
   59|  2.76k|#if CROARING_IS_X64
   60|  2.76k|#if CROARING_COMPILER_SUPPORTS_AVX512
   61|       |    // Every caller first checks that the cardinality fits an array container
   62|       |    // (<= DEFAULT_MAX_SIZE), so the input here is sparse: under 6.25% density,
   63|       |    // a couple of set bits per word.
   64|       |    // Below ~1024 values the vector decoder does not make back its per-word
   65|       |    // cost and the scalar loop is as fast or faster; from 1024 up it wins
   66|       |    // (1.2x at 1024, 1.4x at 4096, measured on an Emerald Rapids Xeon).
   67|  2.76k|    if ((bits->cardinality >= 1024) &&
  ------------------
  |  Branch (67:9): [True: 603, False: 2.16k]
  ------------------
   68|    603|        (croaring_hardware_support() & ROARING_SUPPORTS_AVX512)) {
  ------------------
  |  Branch (68:9): [True: 0, False: 603]
  ------------------
   69|      0|        bitset_extract_setbits_avx512_uint16(
   70|      0|            bits->words, BITSET_CONTAINER_SIZE_IN_WORDS, result->array,
   71|      0|            bits->cardinality, 0);
   72|      0|    } else
   73|  2.76k|#endif
   74|  2.76k|    {
   75|       |        //  sse version ends up being slower here
   76|       |        // (bitset_extract_setbits_sse_uint16)
   77|       |        // because of the sparsity of the data
   78|  2.76k|        bitset_extract_setbits_uint16(
   79|  2.76k|            bits->words, BITSET_CONTAINER_SIZE_IN_WORDS, result->array, 0);
   80|  2.76k|    }
   81|       |#else
   82|       |    // If the system is not x64, then we have no accelerated function.
   83|       |    bitset_extract_setbits_uint16(bits->words, BITSET_CONTAINER_SIZE_IN_WORDS,
   84|       |                                  result->array, 0);
   85|       |#endif
   86|       |
   87|  2.76k|    return result;
   88|  2.76k|}
convert_to_bitset_or_array_container:
  127|  66.7k|                                                  uint8_t *resulttype) {
  128|  66.7k|    if (card <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (128:9): [True: 1.17k, False: 65.5k]
  ------------------
  129|  1.17k|        array_container_t *answer = array_container_create_given_capacity(card);
  130|  1.17k|        answer->cardinality = 0;
  131|  61.6k|        for (int rlepos = 0; rlepos < rc->n_runs; ++rlepos) {
  ------------------
  |  Branch (131:30): [True: 60.4k, False: 1.17k]
  ------------------
  132|  60.4k|            uint16_t run_start = rc->runs[rlepos].value;
  133|  60.4k|            uint16_t run_end = run_start + rc->runs[rlepos].length;
  134|   606k|            for (uint16_t run_value = run_start; run_value < run_end;
  ------------------
  |  Branch (134:50): [True: 546k, False: 60.4k]
  ------------------
  135|   546k|                 ++run_value) {
  136|   546k|                answer->array[answer->cardinality++] = run_value;
  137|   546k|            }
  138|  60.4k|            answer->array[answer->cardinality++] = run_end;
  139|  60.4k|        }
  140|  1.17k|        assert(card == answer->cardinality);
  141|  1.17k|        *resulttype = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  1.17k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  142|       |        // run_container_free(r);
  143|  1.17k|        return answer;
  144|  1.17k|    }
  145|  65.5k|    bitset_container_t *answer = bitset_container_create();
  146|   150k|    for (int rlepos = 0; rlepos < rc->n_runs; ++rlepos) {
  ------------------
  |  Branch (146:26): [True: 85.2k, False: 65.5k]
  ------------------
  147|  85.2k|        uint16_t run_start = rc->runs[rlepos].value;
  148|  85.2k|        bitset_set_lenrange(answer->words, run_start, rc->runs[rlepos].length);
  149|  85.2k|    }
  150|  65.5k|    answer->cardinality = card;
  151|  65.5k|    *resulttype = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|  65.5k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  152|       |    // run_container_free(r);
  153|  65.5k|    return answer;
  154|  66.7k|}
convert_run_to_efficient_container:
  162|   130k|                                                uint8_t *typecode_after) {
  163|   130k|    int32_t size_as_run_container =
  164|   130k|        run_container_serialized_size_in_bytes(c->n_runs);
  165|       |
  166|   130k|    int32_t size_as_bitset_container =
  167|   130k|        bitset_container_serialized_size_in_bytes();
  168|   130k|    int32_t card = run_container_cardinality(c);
  169|   130k|    int32_t size_as_array_container =
  170|   130k|        array_container_serialized_size_in_bytes(card);
  171|       |
  172|   130k|    int32_t min_size_non_run =
  173|   130k|        size_as_bitset_container < size_as_array_container
  ------------------
  |  Branch (173:9): [True: 58.3k, False: 72.2k]
  ------------------
  174|   130k|            ? size_as_bitset_container
  175|   130k|            : size_as_array_container;
  176|   130k|    if (size_as_run_container <= min_size_non_run) {  // no conversion
  ------------------
  |  Branch (176:9): [True: 66.5k, False: 64.0k]
  ------------------
  177|  66.5k|        *typecode_after = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|  66.5k|#define RUN_CONTAINER_TYPE 3
  ------------------
  178|  66.5k|        return c;
  179|  66.5k|    }
  180|  64.0k|    if (card <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (180:9): [True: 64.0k, False: 0]
  ------------------
  181|       |        // to array
  182|  64.0k|        array_container_t *answer = array_container_create_given_capacity(card);
  183|  64.0k|        answer->cardinality = 0;
  184|   199k|        for (int rlepos = 0; rlepos < c->n_runs; ++rlepos) {
  ------------------
  |  Branch (184:30): [True: 135k, False: 64.0k]
  ------------------
  185|   135k|            int run_start = c->runs[rlepos].value;
  186|   135k|            int run_end = run_start + c->runs[rlepos].length;
  187|       |
  188|   363k|            for (int run_value = run_start; run_value <= run_end; ++run_value) {
  ------------------
  |  Branch (188:45): [True: 228k, False: 135k]
  ------------------
  189|   228k|                answer->array[answer->cardinality++] = (uint16_t)run_value;
  190|   228k|            }
  191|   135k|        }
  192|  64.0k|        *typecode_after = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  64.0k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  193|  64.0k|        return answer;
  194|  64.0k|    }
  195|       |
  196|       |    // else to bitset
  197|      0|    bitset_container_t *answer = bitset_container_create();
  198|       |
  199|      0|    for (int rlepos = 0; rlepos < c->n_runs; ++rlepos) {
  ------------------
  |  Branch (199:26): [True: 0, False: 0]
  ------------------
  200|      0|        int start = c->runs[rlepos].value;
  201|      0|        int end = start + c->runs[rlepos].length;
  202|      0|        bitset_set_range(answer->words, start, end + 1);
  203|      0|    }
  204|      0|    answer->cardinality = card;
  205|      0|    *typecode_after = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  206|      0|    return answer;
  207|  64.0k|}
convert_run_to_efficient_container_and_free:
  211|   118k|    run_container_t *c, uint8_t *typecode_after) {
  212|   118k|    container_t *answer = convert_run_to_efficient_container(c, typecode_after);
  213|   118k|    if (answer != c) run_container_free(c);
  ------------------
  |  Branch (213:9): [True: 57.2k, False: 61.3k]
  ------------------
  214|   118k|    return answer;
  215|   118k|}
convert_run_optimize:
  225|  12.6k|                                  uint8_t *typecode_after) {
  226|  12.6k|    if (typecode_original == RUN_CONTAINER_TYPE) {
  ------------------
  |  |   50|  12.6k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (226:9): [True: 0, False: 12.6k]
  ------------------
  227|      0|        container_t *newc =
  228|      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)
  |  |  ------------------
  ------------------
  229|      0|        if (newc != c) {
  ------------------
  |  Branch (229:13): [True: 0, False: 0]
  ------------------
  230|      0|            container_free(c, typecode_original);
  231|      0|        }
  232|      0|        return newc;
  233|  12.6k|    } else if (typecode_original == ARRAY_CONTAINER_TYPE) {
  ------------------
  |  |   49|  12.6k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (233:16): [True: 12.6k, False: 0]
  ------------------
  234|       |        // it might need to be converted to a run container.
  235|  12.6k|        array_container_t *c_qua_array = CAST_array(c);
  ------------------
  |  |   54|  12.6k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  12.6k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  236|  12.6k|        int32_t n_runs = array_container_number_of_runs(c_qua_array);
  237|  12.6k|        int32_t size_as_run_container =
  238|  12.6k|            run_container_serialized_size_in_bytes(n_runs);
  239|  12.6k|        int32_t card = array_container_cardinality(c_qua_array);
  240|  12.6k|        int32_t size_as_array_container =
  241|  12.6k|            array_container_serialized_size_in_bytes(card);
  242|       |
  243|  12.6k|        if (size_as_run_container >= size_as_array_container) {
  ------------------
  |  Branch (243:13): [True: 8.65k, False: 3.97k]
  ------------------
  244|  8.65k|            *typecode_after = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  8.65k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  245|  8.65k|            return c;
  246|  8.65k|        }
  247|       |        // else convert array to run container
  248|  3.97k|        run_container_t *answer = run_container_create_given_capacity(n_runs);
  249|  3.97k|        int prev = -2;
  250|  3.97k|        int run_start = -1;
  251|       |
  252|  3.97k|        assert(card > 0);
  253|   659k|        for (int i = 0; i < card; ++i) {
  ------------------
  |  Branch (253:25): [True: 655k, False: 3.97k]
  ------------------
  254|   655k|            uint16_t cur_val = c_qua_array->array[i];
  255|   655k|            if (cur_val != prev + 1) {
  ------------------
  |  Branch (255:17): [True: 264k, False: 390k]
  ------------------
  256|       |                // new run starts; flush old one, if any
  257|   264k|                if (run_start != -1) add_run(answer, run_start, prev);
  ------------------
  |  Branch (257:21): [True: 260k, False: 3.97k]
  ------------------
  258|   264k|                run_start = cur_val;
  259|   264k|            }
  260|   655k|            prev = c_qua_array->array[i];
  261|   655k|        }
  262|  3.97k|        assert(run_start >= 0);
  263|       |        // now prev is the last seen value
  264|  3.97k|        add_run(answer, run_start, prev);
  265|  3.97k|        *typecode_after = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|  3.97k|#define RUN_CONTAINER_TYPE 3
  ------------------
  266|  3.97k|        array_container_free(c_qua_array);
  267|  3.97k|        return answer;
  268|  12.6k|    } else if (typecode_original ==
  ------------------
  |  Branch (268:16): [True: 0, False: 0]
  ------------------
  269|      0|               BITSET_CONTAINER_TYPE) {  // run conversions on bitset
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  270|       |        // does bitset need conversion to run?
  271|      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)
  |  |  ------------------
  ------------------
  272|      0|        int32_t n_runs = bitset_container_number_of_runs(c_qua_bitset);
  273|      0|        int32_t size_as_run_container =
  274|      0|            run_container_serialized_size_in_bytes(n_runs);
  275|      0|        int32_t size_as_bitset_container =
  276|      0|            bitset_container_serialized_size_in_bytes();
  277|       |
  278|      0|        if (size_as_bitset_container <= size_as_run_container) {
  ------------------
  |  Branch (278:13): [True: 0, False: 0]
  ------------------
  279|       |            // no conversion needed.
  280|      0|            *typecode_after = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  281|      0|            return c;
  282|      0|        }
  283|       |        // bitset to runcontainer (ported from Java  RunContainer(
  284|       |        // BitmapContainer bc, int nbrRuns))
  285|      0|        assert(n_runs > 0);  // no empty bitmaps
  286|      0|        run_container_t *answer = run_container_create_given_capacity(n_runs);
  287|       |
  288|      0|        int long_ctr = 0;
  289|      0|        uint64_t cur_word = c_qua_bitset->words[0];
  290|      0|        while (true) {
  ------------------
  |  Branch (290:16): [True: 0, Folded]
  ------------------
  291|      0|            while (cur_word == UINT64_C(0) &&
  ------------------
  |  Branch (291:20): [True: 0, False: 0]
  ------------------
  292|      0|                   long_ctr < BITSET_CONTAINER_SIZE_IN_WORDS - 1)
  ------------------
  |  Branch (292:20): [True: 0, False: 0]
  ------------------
  293|      0|                cur_word = c_qua_bitset->words[++long_ctr];
  294|       |
  295|      0|            if (cur_word == UINT64_C(0)) {
  ------------------
  |  Branch (295:17): [True: 0, False: 0]
  ------------------
  296|      0|                bitset_container_free(c_qua_bitset);
  297|      0|                *typecode_after = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
  298|      0|                return answer;
  299|      0|            }
  300|       |
  301|      0|            int local_run_start = roaring_trailing_zeroes(cur_word);
  302|      0|            int run_start = local_run_start + 64 * long_ctr;
  303|      0|            uint64_t cur_word_with_1s = cur_word | (cur_word - 1);
  304|       |
  305|      0|            int run_end = 0;
  306|      0|            while (cur_word_with_1s == UINT64_C(0xFFFFFFFFFFFFFFFF) &&
  ------------------
  |  Branch (306:20): [True: 0, False: 0]
  ------------------
  307|      0|                   long_ctr < BITSET_CONTAINER_SIZE_IN_WORDS - 1)
  ------------------
  |  Branch (307:20): [True: 0, False: 0]
  ------------------
  308|      0|                cur_word_with_1s = c_qua_bitset->words[++long_ctr];
  309|       |
  310|      0|            if (cur_word_with_1s == UINT64_C(0xFFFFFFFFFFFFFFFF)) {
  ------------------
  |  Branch (310:17): [True: 0, False: 0]
  ------------------
  311|      0|                run_end = 64 + long_ctr * 64;  // exclusive, I guess
  312|      0|                add_run(answer, run_start, run_end - 1);
  313|      0|                bitset_container_free(c_qua_bitset);
  314|      0|                *typecode_after = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
  315|      0|                return answer;
  316|      0|            }
  317|      0|            int local_run_end = roaring_trailing_zeroes(~cur_word_with_1s);
  318|      0|            run_end = local_run_end + long_ctr * 64;
  319|      0|            add_run(answer, run_start, run_end - 1);
  320|      0|            cur_word = cur_word_with_1s & (cur_word_with_1s + 1);
  321|      0|        }
  322|      0|        return answer;
  323|      0|    } else {
  324|      0|        assert(false);
  325|      0|        roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  326|      0|        return NULL;
  327|      0|    }
  328|  12.6k|}
convert.c:add_run:
   91|   264k|static void add_run(run_container_t *rc, int s, int e) {
   92|   264k|    rc->runs[rc->n_runs].value = s;
   93|   264k|    rc->runs[rc->n_runs].length = e - s;
   94|   264k|    rc->n_runs++;
   95|   264k|}

array_bitset_container_andnot:
   26|    519|                                   array_container_t *dst) {
   27|       |    // follows Java implementation as of June 2016
   28|    519|    if (dst->capacity < src_1->cardinality) {
  ------------------
  |  Branch (28:9): [True: 519, False: 0]
  ------------------
   29|    519|        array_container_grow(dst, src_1->cardinality, false);
   30|    519|    }
   31|    519|    int32_t newcard = 0;
   32|    519|    const int32_t origcard = src_1->cardinality;
   33|  90.0k|    for (int i = 0; i < origcard; ++i) {
  ------------------
  |  Branch (33:21): [True: 89.5k, False: 519]
  ------------------
   34|  89.5k|        uint16_t key = src_1->array[i];
   35|  89.5k|        dst->array[newcard] = key;
   36|  89.5k|        newcard += 1 - bitset_container_contains(src_2, key);
   37|  89.5k|    }
   38|    519|    dst->cardinality = newcard;
   39|    519|}
bitset_array_container_iandnot:
   83|  1.45k|                                    container_t **dst) {
   84|  1.45k|    *dst = src_1;
   85|  1.45k|    src_1->cardinality =
   86|  1.45k|        (int32_t)bitset_clear_list(src_1->words, (uint64_t)src_1->cardinality,
   87|  1.45k|                                   src_2->array, (uint64_t)src_2->cardinality);
   88|       |
   89|  1.45k|    if (src_1->cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (89:9): [True: 210, False: 1.24k]
  ------------------
   90|    210|        *dst = array_container_from_bitset(src_1);
   91|    210|        bitset_container_free(src_1);
   92|    210|        return false;  // not bitset
   93|    210|    } else
   94|  1.24k|        return true;
   95|  1.45k|}
run_bitset_container_andnot:
  106|    654|                                 container_t **dst) {
  107|       |    // follows the Java implementation as of June 2016
  108|    654|    int card = run_container_cardinality(src_1);
  109|    654|    if (card <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (109:9): [True: 654, False: 0]
  ------------------
  110|       |        // must be an array
  111|    654|        array_container_t *answer = array_container_create_given_capacity(card);
  112|    654|        answer->cardinality = 0;
  113|  51.8k|        for (int32_t rlepos = 0; rlepos < src_1->n_runs; ++rlepos) {
  ------------------
  |  Branch (113:34): [True: 51.1k, False: 654]
  ------------------
  114|  51.1k|            rle16_t rle = src_1->runs[rlepos];
  115|   189k|            for (int run_value = rle.value; run_value <= rle.value + rle.length;
  ------------------
  |  Branch (115:45): [True: 138k, False: 51.1k]
  ------------------
  116|   138k|                 ++run_value) {
  117|   138k|                if (!bitset_container_get(src_2, (uint16_t)run_value)) {
  ------------------
  |  Branch (117:21): [True: 38.9k, False: 99.7k]
  ------------------
  118|  38.9k|                    answer->array[answer->cardinality++] = (uint16_t)run_value;
  119|  38.9k|                }
  120|   138k|            }
  121|  51.1k|        }
  122|    654|        *dst = answer;
  123|    654|        return false;
  124|    654|    } 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|    654|}
run_array_container_andnot:
  279|  1.97k|                               container_t **dst) {
  280|       |    // follows the Java impl as of June 2016
  281|       |
  282|  1.97k|    int card = run_container_cardinality(src_1);
  283|  1.97k|    const int arbitrary_threshold = 32;
  284|       |
  285|  1.97k|    if (card <= arbitrary_threshold) {
  ------------------
  |  Branch (285:9): [True: 362, False: 1.60k]
  ------------------
  286|    362|        if (src_2->cardinality == 0) {
  ------------------
  |  Branch (286:13): [True: 0, False: 362]
  ------------------
  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|    362|        run_container_t *answer = run_container_create_given_capacity(
  292|    362|            card + array_container_cardinality(src_2));
  293|       |
  294|    362|        int rlepos = 0;
  295|    362|        int xrlepos = 0;  // "x" is src_2
  296|    362|        rle16_t rle = src_1->runs[rlepos];
  297|    362|        int32_t start = rle.value;
  298|    362|        int32_t end = start + rle.length + 1;
  299|    362|        int32_t xstart = src_2->array[xrlepos];
  300|       |
  301|  13.0k|        while ((rlepos < src_1->n_runs) && (xrlepos < src_2->cardinality)) {
  ------------------
  |  Branch (301:16): [True: 12.7k, False: 295]
  |  Branch (301:44): [True: 12.6k, False: 67]
  ------------------
  302|  12.6k|            if (end <= xstart) {
  ------------------
  |  Branch (302:17): [True: 634, False: 12.0k]
  ------------------
  303|       |                // output the first run
  304|    634|                answer->runs[answer->n_runs++] =
  305|    634|                    CROARING_MAKE_RLE16(start, end - start - 1);
  ------------------
  |  |   60|    634|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  306|    634|                rlepos++;
  307|    634|                if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (307:21): [True: 588, False: 46]
  ------------------
  308|    588|                    start = src_1->runs[rlepos].value;
  309|    588|                    end = start + src_1->runs[rlepos].length + 1;
  310|    588|                }
  311|  12.0k|            } else if (xstart + 1 <= start) {
  ------------------
  |  Branch (311:24): [True: 8.11k, False: 3.88k]
  ------------------
  312|       |                // exit the second run
  313|  8.11k|                xrlepos++;
  314|  8.11k|                if (xrlepos < src_2->cardinality) {
  ------------------
  |  Branch (314:21): [True: 8.05k, False: 67]
  ------------------
  315|  8.05k|                    xstart = src_2->array[xrlepos];
  316|  8.05k|                }
  317|  8.11k|            } else {
  318|  3.88k|                if (start < xstart) {
  ------------------
  |  Branch (318:21): [True: 327, False: 3.56k]
  ------------------
  319|    327|                    answer->runs[answer->n_runs++] =
  320|    327|                        CROARING_MAKE_RLE16(start, xstart - start - 1);
  ------------------
  |  |   60|    327|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  321|    327|                }
  322|  3.88k|                if (xstart + 1 < end) {
  ------------------
  |  Branch (322:21): [True: 2.35k, False: 1.53k]
  ------------------
  323|  2.35k|                    start = xstart + 1;
  324|  2.35k|                } else {
  325|  1.53k|                    rlepos++;
  326|  1.53k|                    if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (326:25): [True: 1.28k, False: 249]
  ------------------
  327|  1.28k|                        start = src_1->runs[rlepos].value;
  328|  1.28k|                        end = start + src_1->runs[rlepos].length + 1;
  329|  1.28k|                    }
  330|  1.53k|                }
  331|  3.88k|            }
  332|  12.6k|        }
  333|    362|        if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (333:13): [True: 67, False: 295]
  ------------------
  334|     67|            answer->runs[answer->n_runs++] =
  335|     67|                CROARING_MAKE_RLE16(start, end - start - 1);
  ------------------
  |  |   60|     67|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  336|     67|            rlepos++;
  337|     67|            if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (337:17): [True: 19, False: 48]
  ------------------
  338|     19|                memcpy(answer->runs + answer->n_runs, src_1->runs + rlepos,
  339|     19|                       (src_1->n_runs - rlepos) * sizeof(rle16_t));
  340|     19|                answer->n_runs += (src_1->n_runs - rlepos);
  341|     19|            }
  342|     67|        }
  343|    362|        uint8_t return_type;
  344|    362|        *dst = convert_run_to_efficient_container(answer, &return_type);
  345|    362|        if (answer != *dst) run_container_free(answer);
  ------------------
  |  Branch (345:13): [True: 236, False: 126]
  ------------------
  346|    362|        return return_type;
  347|    362|    }
  348|       |    // else it's a bitmap or array
  349|       |
  350|  1.60k|    if (card <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (350:9): [True: 1.29k, False: 313]
  ------------------
  351|  1.29k|        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.29k|        ac->cardinality = run_array_array_subtract(src_1, src_2, ac);
  355|  1.29k|        *dst = ac;
  356|  1.29k|        return ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  1.29k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  357|  1.29k|    }
  358|    313|    bitset_container_t *ans = bitset_container_from_run(src_1);
  359|    313|    bool result_is_bitset = bitset_array_container_iandnot(ans, src_2, dst);
  360|    313|    return (result_is_bitset ? BITSET_CONTAINER_TYPE : ARRAY_CONTAINER_TYPE);
  ------------------
  |  |   48|    287|#define BITSET_CONTAINER_TYPE 1
  ------------------
                  return (result_is_bitset ? BITSET_CONTAINER_TYPE : ARRAY_CONTAINER_TYPE);
  ------------------
  |  |   49|     26|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (360:13): [True: 287, False: 26]
  ------------------
  361|  1.60k|}
run_array_container_iandnot:
  372|    753|                                container_t **dst) {
  373|       |    // dummy implementation same as June 2016 Java
  374|    753|    int ans = run_array_container_andnot(src_1, src_2, dst);
  375|    753|    run_container_free(src_1);
  376|    753|    return ans;
  377|    753|}
array_run_container_andnot:
  383|    766|                                array_container_t *dst) {
  384|       |    // basically following Java impl as of June 2016
  385|    766|    if (src_1->cardinality > dst->capacity) {
  ------------------
  |  Branch (385:9): [True: 725, False: 41]
  ------------------
  386|    725|        array_container_grow(dst, src_1->cardinality, false);
  387|    725|    }
  388|       |
  389|    766|    if (src_2->n_runs == 0) {
  ------------------
  |  Branch (389:9): [True: 0, False: 766]
  ------------------
  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|    766|    int32_t run_start = src_2->runs[0].value;
  396|    766|    int32_t run_end = run_start + src_2->runs[0].length;
  397|    766|    int which_run = 0;
  398|       |
  399|    766|    uint16_t val = 0;
  400|    766|    int dest_card = 0;
  401|   170k|    for (int i = 0; i < src_1->cardinality; ++i) {
  ------------------
  |  Branch (401:21): [True: 169k, False: 766]
  ------------------
  402|   169k|        val = src_1->array[i];
  403|   169k|        if (val < run_start)
  ------------------
  |  Branch (403:13): [True: 41.4k, False: 128k]
  ------------------
  404|  41.4k|            dst->array[dest_card++] = val;
  405|   128k|        else if (val <= run_end) {
  ------------------
  |  Branch (405:18): [True: 93.1k, False: 35.3k]
  ------------------
  406|  93.1k|            ;  // omitted item
  407|  93.1k|        } else {
  408|  48.9k|            do {
  409|  48.9k|                if (which_run + 1 < src_2->n_runs) {
  ------------------
  |  Branch (409:21): [True: 48.8k, False: 160]
  ------------------
  410|  48.8k|                    ++which_run;
  411|  48.8k|                    run_start = src_2->runs[which_run].value;
  412|  48.8k|                    run_end = run_start + src_2->runs[which_run].length;
  413|       |
  414|  48.8k|                } else
  415|    160|                    run_start = run_end = (1 << 16) + 1;
  416|  48.9k|            } while (val > run_end);
  ------------------
  |  Branch (416:22): [True: 13.6k, False: 35.3k]
  ------------------
  417|  35.3k|            --i;
  418|  35.3k|        }
  419|   169k|    }
  420|    766|    dst->cardinality = dest_card;
  421|    766|}
array_run_container_iandnot:
  428|     41|                                 const run_container_t *src_2) {
  429|     41|    array_run_container_andnot(src_1, src_2, src_1);
  430|     41|}
run_run_container_andnot:
  437|  1.05k|                             const run_container_t *src_2, container_t **dst) {
  438|  1.05k|    run_container_t *ans = run_container_create();
  439|  1.05k|    run_container_andnot(src_1, src_2, ans);
  440|  1.05k|    uint8_t typecode_after;
  441|  1.05k|    *dst = convert_run_to_efficient_container_and_free(ans, &typecode_after);
  442|  1.05k|    return typecode_after;
  443|  1.05k|}
run_run_container_iandnot:
  453|    412|                              const run_container_t *src_2, container_t **dst) {
  454|       |    // following Java impl as of June 2016 (dummy)
  455|    412|    int ans = run_run_container_andnot(src_1, src_2, dst);
  456|    412|    run_container_free(src_1);
  457|    412|    return ans;
  458|    412|}
array_array_container_andnot:
  466|  2.39k|                                  array_container_t *dst) {
  467|  2.39k|    array_container_andnot(src_1, src_2, dst);
  468|  2.39k|}
array_array_container_iandnot:
  473|  3.51k|                                   const array_container_t *src_2) {
  474|  3.51k|    array_container_andnot(src_1, src_2, src_1);
  475|  3.51k|}
mixed_andnot.c:run_array_array_subtract:
  235|  1.29k|                                    array_container_t *a_out) {
  236|  1.29k|    int out_card = 0;
  237|  1.29k|    int32_t in_array_pos =
  238|  1.29k|        -1;  // since advanceUntil always assumes we start the search AFTER this
  239|       |
  240|  97.5k|    for (int rlepos = 0; rlepos < rc->n_runs; rlepos++) {
  ------------------
  |  Branch (240:26): [True: 96.3k, False: 1.29k]
  ------------------
  241|  96.3k|        int32_t start = rc->runs[rlepos].value;
  242|  96.3k|        int32_t end = start + rc->runs[rlepos].length + 1;
  243|       |
  244|  96.3k|        in_array_pos = advanceUntil(a_in->array, in_array_pos,
  245|  96.3k|                                    a_in->cardinality, (uint16_t)start);
  246|       |
  247|  96.3k|        if (in_array_pos >= a_in->cardinality) {  // run has no items subtracted
  ------------------
  |  Branch (247:13): [True: 5.04k, False: 91.2k]
  ------------------
  248|   108k|            for (int32_t i = start; i < end; ++i)
  ------------------
  |  Branch (248:37): [True: 103k, False: 5.04k]
  ------------------
  249|   103k|                a_out->array[out_card++] = (uint16_t)i;
  250|  91.2k|        } else {
  251|  91.2k|            uint16_t next_nonincluded = a_in->array[in_array_pos];
  252|  91.2k|            if (next_nonincluded >= end) {
  ------------------
  |  Branch (252:17): [True: 31.5k, False: 59.7k]
  ------------------
  253|       |                // another case when run goes unaltered
  254|  85.6k|                for (int32_t i = start; i < end; ++i)
  ------------------
  |  Branch (254:41): [True: 54.1k, False: 31.5k]
  ------------------
  255|  54.1k|                    a_out->array[out_card++] = (uint16_t)i;
  256|  31.5k|                in_array_pos--;  // ensure we see this item again if necessary
  257|  59.7k|            } else {
  258|   279k|                for (int32_t i = start; i < end; ++i)
  ------------------
  |  Branch (258:41): [True: 220k, False: 59.7k]
  ------------------
  259|   220k|                    if (i != next_nonincluded)
  ------------------
  |  Branch (259:25): [True: 86.2k, False: 133k]
  ------------------
  260|  86.2k|                        a_out->array[out_card++] = (uint16_t)i;
  261|   133k|                    else  // 0 should ensure  we don't match
  262|   133k|                        next_nonincluded =
  263|   133k|                            (in_array_pos + 1 >= a_in->cardinality)
  ------------------
  |  Branch (263:29): [True: 1.02k, False: 132k]
  ------------------
  264|   133k|                                ? 0
  265|   133k|                                : a_in->array[++in_array_pos];
  266|  59.7k|                in_array_pos--;  // see again
  267|  59.7k|            }
  268|  91.2k|        }
  269|  96.3k|    }
  270|  1.29k|    return out_card;
  271|  1.29k|}

array_container_equal_bitset:
   10|    476|                                  const bitset_container_t* container2) {
   11|    476|    if (container2->cardinality != BITSET_UNKNOWN_CARDINALITY) {
  ------------------
  |  Branch (11:9): [True: 476, False: 0]
  ------------------
   12|    476|        if (container2->cardinality != container1->cardinality) {
  ------------------
  |  Branch (12:13): [True: 476, False: 0]
  ------------------
   13|    476|            return false;
   14|    476|        }
   15|    476|    }
   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|    846|                                const array_container_t* container2) {
   37|    846|    if (run_container_cardinality(container1) != container2->cardinality)
  ------------------
  |  Branch (37:9): [True: 799, False: 47]
  ------------------
   38|    799|        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|    568|                                         array_container_t *dst) {
   22|    568|    if (dst->capacity < src_1->cardinality) {
  ------------------
  |  Branch (22:9): [True: 568, False: 0]
  ------------------
   23|    568|        array_container_grow(dst, src_1->cardinality, false);
   24|    568|    }
   25|    568|    int32_t newcard = 0;  // dst could be src_1
   26|    568|    const int32_t origcard = src_1->cardinality;
   27|   290k|    for (int i = 0; i < origcard; ++i) {
  ------------------
  |  Branch (27:21): [True: 289k, False: 568]
  ------------------
   28|   289k|        uint16_t key = src_1->array[i];
   29|       |        // this branchless approach is much faster...
   30|   289k|        dst->array[newcard] = key;
   31|   289k|        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|   289k|    }
   45|    568|    dst->cardinality = newcard;
   46|    568|}
array_bitset_container_intersection_cardinality:
   50|  2.07k|    const array_container_t *src_1, const bitset_container_t *src_2) {
   51|  2.07k|    int32_t newcard = 0;
   52|  2.07k|    const int32_t origcard = src_1->cardinality;
   53|   360k|    for (int i = 0; i < origcard; ++i) {
  ------------------
  |  Branch (53:21): [True: 358k, False: 2.07k]
  ------------------
   54|   358k|        uint16_t key = src_1->array[i];
   55|   358k|        newcard += bitset_container_contains(src_2, key);
   56|   358k|    }
   57|  2.07k|    return newcard;
   58|  2.07k|}
array_bitset_container_intersect:
   61|    519|                                      const bitset_container_t *src_2) {
   62|    519|    const int32_t origcard = src_1->cardinality;
   63|  4.63k|    for (int i = 0; i < origcard; ++i) {
  ------------------
  |  Branch (63:21): [True: 4.61k, False: 17]
  ------------------
   64|  4.61k|        uint16_t key = src_1->array[i];
   65|  4.61k|        if (bitset_container_contains(src_2, key)) return true;
  ------------------
  |  Branch (65:13): [True: 502, False: 4.11k]
  ------------------
   66|  4.61k|    }
   67|     17|    return false;
   68|    519|}
array_run_container_intersection:
   75|  3.16k|                                      array_container_t *dst) {
   76|  3.16k|    if (run_container_is_full(src_2)) {
  ------------------
  |  Branch (76:9): [True: 22, False: 3.14k]
  ------------------
   77|     22|        if (dst != src_1) array_container_copy(src_1, dst);
  ------------------
  |  Branch (77:13): [True: 22, False: 0]
  ------------------
   78|     22|        return;
   79|     22|    }
   80|  3.14k|    if (dst->capacity < src_1->cardinality) {
  ------------------
  |  Branch (80:9): [True: 3.14k, False: 0]
  ------------------
   81|  3.14k|        array_container_grow(dst, src_1->cardinality, false);
   82|  3.14k|    }
   83|  3.14k|    if (src_2->n_runs == 0) {
  ------------------
  |  Branch (83:9): [True: 0, False: 3.14k]
  ------------------
   84|      0|        return;
   85|      0|    }
   86|  3.14k|    int32_t rlepos = 0;
   87|  3.14k|    int32_t arraypos = 0;
   88|  3.14k|    rle16_t rle = src_2->runs[rlepos];
   89|  3.14k|    int32_t newcard = 0;
   90|   427k|    while (arraypos < src_1->cardinality) {
  ------------------
  |  Branch (90:12): [True: 425k, False: 2.62k]
  ------------------
   91|   425k|        const uint16_t arrayval = src_1->array[arraypos];
   92|   578k|        while (rle.value + rle.length <
  ------------------
  |  Branch (92:16): [True: 153k, False: 424k]
  ------------------
   93|   578k|               arrayval) {  // this will frequently be false
   94|   153k|            ++rlepos;
   95|   153k|            if (rlepos == src_2->n_runs) {
  ------------------
  |  Branch (95:17): [True: 518, False: 152k]
  ------------------
   96|    518|                dst->cardinality = newcard;
   97|    518|                return;  // we are done
   98|    518|            }
   99|   152k|            rle = src_2->runs[rlepos];
  100|   152k|        }
  101|   424k|        if (rle.value > arrayval) {
  ------------------
  |  Branch (101:13): [True: 30.4k, False: 394k]
  ------------------
  102|  30.4k|            arraypos = advanceUntil(src_1->array, arraypos, src_1->cardinality,
  103|  30.4k|                                    rle.value);
  104|   394k|        } else {
  105|   394k|            dst->array[newcard] = arrayval;
  106|   394k|            newcard++;
  107|   394k|            arraypos++;
  108|   394k|        }
  109|   424k|    }
  110|  2.62k|    dst->cardinality = newcard;
  111|  2.62k|}
run_bitset_container_intersection:
  119|    654|                                       container_t **dst) {
  120|    654|    if (run_container_is_full(src_1)) {
  ------------------
  |  Branch (120:9): [True: 0, False: 654]
  ------------------
  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|    654|    int32_t card = run_container_cardinality(src_1);
  125|    654|    if (card <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (125:9): [True: 654, False: 0]
  ------------------
  126|       |        // result can only be an array (assuming that we never make a
  127|       |        // RunContainer)
  128|    654|        if (card > src_2->cardinality) {
  ------------------
  |  Branch (128:13): [True: 0, False: 654]
  ------------------
  129|      0|            card = src_2->cardinality;
  130|      0|        }
  131|    654|        array_container_t *answer = array_container_create_given_capacity(card);
  132|    654|        *dst = answer;
  133|    654|        if (*dst == NULL) {
  ------------------
  |  Branch (133:13): [True: 0, False: 654]
  ------------------
  134|      0|            return false;
  135|      0|        }
  136|  51.8k|        for (int32_t rlepos = 0; rlepos < src_1->n_runs; ++rlepos) {
  ------------------
  |  Branch (136:34): [True: 51.1k, False: 654]
  ------------------
  137|  51.1k|            rle16_t rle = src_1->runs[rlepos];
  138|  51.1k|            uint32_t endofrun = (uint32_t)rle.value + rle.length;
  139|   189k|            for (uint32_t runValue = rle.value; runValue <= endofrun;
  ------------------
  |  Branch (139:49): [True: 138k, False: 51.1k]
  ------------------
  140|   138k|                 ++runValue) {
  141|   138k|                answer->array[answer->cardinality] = (uint16_t)runValue;
  142|   138k|                answer->cardinality +=
  143|   138k|                    bitset_container_contains(src_2, runValue);
  144|   138k|            }
  145|  51.1k|        }
  146|    654|        return false;
  147|    654|    }
  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|  7.86k|                                                 const run_container_t *src_2) {
  207|  7.86k|    if (run_container_is_full(src_2)) {
  ------------------
  |  Branch (207:9): [True: 88, False: 7.77k]
  ------------------
  208|     88|        return src_1->cardinality;
  209|     88|    }
  210|  7.77k|    if (src_2->n_runs == 0) {
  ------------------
  |  Branch (210:9): [True: 0, False: 7.77k]
  ------------------
  211|      0|        return 0;
  212|      0|    }
  213|  7.77k|    int32_t rlepos = 0;
  214|  7.77k|    int32_t arraypos = 0;
  215|  7.77k|    rle16_t rle = src_2->runs[rlepos];
  216|  7.77k|    int32_t newcard = 0;
  217|   804k|    while (arraypos < src_1->cardinality) {
  ------------------
  |  Branch (217:12): [True: 798k, False: 6.05k]
  ------------------
  218|   798k|        const uint16_t arrayval = src_1->array[arraypos];
  219|  1.18M|        while (rle.value + rle.length <
  ------------------
  |  Branch (219:16): [True: 391k, False: 796k]
  ------------------
  220|  1.18M|               arrayval) {  // this will frequently be false
  221|   391k|            ++rlepos;
  222|   391k|            if (rlepos == src_2->n_runs) {
  ------------------
  |  Branch (222:17): [True: 1.71k, False: 390k]
  ------------------
  223|  1.71k|                return newcard;  // we are done
  224|  1.71k|            }
  225|   390k|            rle = src_2->runs[rlepos];
  226|   390k|        }
  227|   796k|        if (rle.value > arrayval) {
  ------------------
  |  Branch (227:13): [True: 108k, False: 688k]
  ------------------
  228|   108k|            arraypos = advanceUntil(src_1->array, arraypos, src_1->cardinality,
  229|   108k|                                    rle.value);
  230|   688k|        } else {
  231|   688k|            newcard++;
  232|   688k|            arraypos++;
  233|   688k|        }
  234|   796k|    }
  235|  6.05k|    return newcard;
  236|  7.77k|}
run_bitset_container_intersection_cardinality:
  241|  2.61k|    const run_container_t *src_1, const bitset_container_t *src_2) {
  242|  2.61k|    if (run_container_is_full(src_1)) {
  ------------------
  |  Branch (242:9): [True: 0, False: 2.61k]
  ------------------
  243|      0|        return bitset_container_cardinality(src_2);
  244|      0|    }
  245|  2.61k|    int answer = 0;
  246|   207k|    for (int32_t rlepos = 0; rlepos < src_1->n_runs; ++rlepos) {
  ------------------
  |  Branch (246:30): [True: 204k, False: 2.61k]
  ------------------
  247|   204k|        rle16_t rle = src_1->runs[rlepos];
  248|   204k|        answer +=
  249|   204k|            bitset_lenrange_cardinality(src_2->words, rle.value, rle.length);
  250|   204k|    }
  251|  2.61k|    return answer;
  252|  2.61k|}
array_run_container_intersect:
  255|  1.96k|                                   const run_container_t *src_2) {
  256|  1.96k|    if (run_container_is_full(src_2)) {
  ------------------
  |  Branch (256:9): [True: 22, False: 1.94k]
  ------------------
  257|     22|        return !array_container_empty(src_1);
  258|     22|    }
  259|  1.94k|    if (src_2->n_runs == 0) {
  ------------------
  |  Branch (259:9): [True: 0, False: 1.94k]
  ------------------
  260|      0|        return false;
  261|      0|    }
  262|  1.94k|    int32_t rlepos = 0;
  263|  1.94k|    int32_t arraypos = 0;
  264|  1.94k|    rle16_t rle = src_2->runs[rlepos];
  265|  3.36k|    while (arraypos < src_1->cardinality) {
  ------------------
  |  Branch (265:12): [True: 3.31k, False: 49]
  ------------------
  266|  3.31k|        const uint16_t arrayval = src_1->array[arraypos];
  267|  8.43k|        while (rle.value + rle.length <
  ------------------
  |  Branch (267:16): [True: 5.16k, False: 3.26k]
  ------------------
  268|  8.43k|               arrayval) {  // this will frequently be false
  269|  5.16k|            ++rlepos;
  270|  5.16k|            if (rlepos == src_2->n_runs) {
  ------------------
  |  Branch (270:17): [True: 47, False: 5.11k]
  ------------------
  271|     47|                return false;  // we are done
  272|     47|            }
  273|  5.11k|            rle = src_2->runs[rlepos];
  274|  5.11k|        }
  275|  3.26k|        if (rle.value > arrayval) {
  ------------------
  |  Branch (275:13): [True: 1.42k, False: 1.84k]
  ------------------
  276|  1.42k|            arraypos = advanceUntil(src_1->array, arraypos, src_1->cardinality,
  277|  1.42k|                                    rle.value);
  278|  1.84k|        } else {
  279|  1.84k|            return true;
  280|  1.84k|        }
  281|  3.26k|    }
  282|     49|    return false;
  283|  1.94k|}
run_bitset_container_intersect:
  288|    654|                                    const bitset_container_t *src_2) {
  289|    654|    if (run_container_is_full(src_1)) {
  ------------------
  |  Branch (289:9): [True: 0, False: 654]
  ------------------
  290|      0|        return !bitset_container_empty(src_2);
  291|      0|    }
  292|  4.36k|    for (int32_t rlepos = 0; rlepos < src_1->n_runs; ++rlepos) {
  ------------------
  |  Branch (292:30): [True: 4.34k, False: 16]
  ------------------
  293|  4.34k|        rle16_t rle = src_1->runs[rlepos];
  294|  4.34k|        if (!bitset_lenrange_empty(src_2->words, rle.value, rle.length))
  ------------------
  |  Branch (294:13): [True: 638, False: 3.70k]
  ------------------
  295|    638|            return true;
  296|  4.34k|    }
  297|     16|    return false;
  298|    654|}
bitset_bitset_container_intersection_inplace:
  329|  1.41k|    container_t **dst) {
  330|  1.41k|    const int newCardinality = bitset_container_and_justcard(src_1, src_2);
  331|  1.41k|    if (newCardinality > DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (331:9): [True: 1.41k, False: 0]
  ------------------
  332|  1.41k|        *dst = src_1;
  333|  1.41k|        bitset_container_and_nocard(src_1, src_2, src_1);
  334|  1.41k|        CAST_bitset(*dst)->cardinality = newCardinality;
  ------------------
  |  |   52|  1.41k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.41k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  335|  1.41k|        return true;  // it is a bitset
  336|  1.41k|    }
  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.41k|}

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

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

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

array_bitset_container_xor:
   25|    622|                                container_t **dst) {
   26|    622|    bitset_container_t *result = bitset_container_create();
   27|    622|    bitset_container_copy(src_2, result);
   28|    622|    result->cardinality = (int32_t)bitset_flip_list_withcard(
   29|    622|        result->words, result->cardinality, src_1->array, src_1->cardinality);
   30|       |
   31|       |    // do required type conversions.
   32|    622|    if (result->cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (32:9): [True: 146, False: 476]
  ------------------
   33|    146|        *dst = array_container_from_bitset(result);
   34|    146|        bitset_container_free(result);
   35|    146|        return false;  // not bitset
   36|    146|    }
   37|    476|    *dst = result;
   38|       |    return true;  // bitset
   39|    622|}
run_bitset_container_xor:
   63|    740|                              container_t **dst) {
   64|    740|    bitset_container_t *result = bitset_container_create();
   65|       |
   66|    740|    bitset_container_copy(src_2, result);
   67|  56.4k|    for (int32_t rlepos = 0; rlepos < src_1->n_runs; ++rlepos) {
  ------------------
  |  Branch (67:30): [True: 55.7k, False: 740]
  ------------------
   68|  55.7k|        rle16_t rle = src_1->runs[rlepos];
   69|  55.7k|        bitset_flip_range(result->words, rle.value,
   70|  55.7k|                          rle.value + rle.length + UINT32_C(1));
   71|  55.7k|    }
   72|    740|    result->cardinality = bitset_container_compute_cardinality(result);
   73|       |
   74|    740|    if (result->cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (74:9): [True: 145, False: 595]
  ------------------
   75|    145|        *dst = array_container_from_bitset(result);
   76|    145|        bitset_container_free(result);
   77|    145|        return false;  // not bitset
   78|    145|    }
   79|    595|    *dst = result;
   80|       |    return true;  // bitset
   81|    740|}
array_run_container_xor:
  105|  2.31k|                            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.31k|    const int arbitrary_threshold = 32;
  113|  2.31k|    if (src_1->cardinality < arbitrary_threshold) {
  ------------------
  |  Branch (113:9): [True: 920, False: 1.39k]
  ------------------
  114|    920|        run_container_t *ans = run_container_create();
  115|    920|        array_run_container_lazy_xor(src_1, src_2, ans);  // keeps runs.
  116|    920|        uint8_t typecode_after;
  117|    920|        *dst =
  118|    920|            convert_run_to_efficient_container_and_free(ans, &typecode_after);
  119|    920|        return typecode_after;
  120|    920|    }
  121|       |
  122|  1.39k|    int card = run_container_cardinality(src_2);
  123|  1.39k|    if (card <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (123:9): [True: 1.14k, False: 255]
  ------------------
  124|       |        // Java implementation works with the array, xoring the run elements via
  125|       |        // iterator
  126|  1.14k|        array_container_t *temp = array_container_from_run(src_2);
  127|  1.14k|        bool ret_is_bitset = array_array_container_xor(temp, src_1, dst);
  128|  1.14k|        array_container_free(temp);
  129|  1.14k|        return ret_is_bitset ? BITSET_CONTAINER_TYPE : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   48|      3|#define BITSET_CONTAINER_TYPE 1
  ------------------
                      return ret_is_bitset ? BITSET_CONTAINER_TYPE : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  1.13k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (129:16): [True: 3, False: 1.13k]
  ------------------
  130|       |
  131|  1.14k|    } 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.39k|}
array_run_container_lazy_xor:
  147|    920|                                  run_container_t *dst) {
  148|    920|    run_container_grow(dst, src_1->cardinality + src_2->n_runs, false);
  149|    920|    int32_t rlepos = 0;
  150|    920|    int32_t arraypos = 0;
  151|    920|    dst->n_runs = 0;
  152|       |
  153|  29.8k|    while ((rlepos < src_2->n_runs) && (arraypos < src_1->cardinality)) {
  ------------------
  |  Branch (153:12): [True: 29.3k, False: 550]
  |  Branch (153:40): [True: 28.9k, False: 370]
  ------------------
  154|  28.9k|        if (src_2->runs[rlepos].value <= src_1->array[arraypos]) {
  ------------------
  |  Branch (154:13): [True: 18.1k, False: 10.8k]
  ------------------
  155|  18.1k|            run_container_smart_append_exclusive(dst, src_2->runs[rlepos].value,
  156|  18.1k|                                                 src_2->runs[rlepos].length);
  157|  18.1k|            rlepos++;
  158|  18.1k|        } 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|  28.9k|    }
  164|  3.24k|    while (arraypos < src_1->cardinality) {
  ------------------
  |  Branch (164:12): [True: 2.32k, False: 920]
  ------------------
  165|  2.32k|        run_container_smart_append_exclusive(dst, src_1->array[arraypos], 0);
  166|  2.32k|        arraypos++;
  167|  2.32k|    }
  168|  9.09k|    while (rlepos < src_2->n_runs) {
  ------------------
  |  Branch (168:12): [True: 8.17k, False: 920]
  ------------------
  169|  8.17k|        run_container_smart_append_exclusive(dst, src_2->runs[rlepos].value,
  170|  8.17k|                                             src_2->runs[rlepos].length);
  171|  8.17k|        rlepos++;
  172|  8.17k|    }
  173|    920|}
run_run_container_xor:
  180|  56.2k|                          const run_container_t *src_2, container_t **dst) {
  181|  56.2k|    run_container_t *ans = run_container_create();
  182|  56.2k|    run_container_xor(src_1, src_2, ans);
  183|  56.2k|    uint8_t typecode_after;
  184|  56.2k|    *dst = convert_run_to_efficient_container_and_free(ans, &typecode_after);
  185|  56.2k|    return typecode_after;
  186|  56.2k|}
array_array_container_xor:
  198|  8.38k|                               container_t **dst) {
  199|  8.38k|    int totalCardinality =
  200|  8.38k|        src_1->cardinality + src_2->cardinality;  // upper bound
  201|  8.38k|    if (totalCardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (201:9): [True: 7.84k, False: 546]
  ------------------
  202|  7.84k|        *dst = array_container_create_given_capacity(totalCardinality);
  203|  7.84k|        array_container_xor(src_1, src_2, CAST_array(*dst));
  ------------------
  |  |   54|  7.84k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  7.84k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  204|  7.84k|        return false;  // not a bitset
  205|  7.84k|    }
  206|    546|    *dst = bitset_container_from_array(src_1);
  207|    546|    bool returnval = true;  // expect a bitset
  208|    546|    bitset_container_t *ourbitset = CAST_bitset(*dst);
  ------------------
  |  |   52|    546|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    546|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  209|    546|    ourbitset->cardinality = (uint32_t)bitset_flip_list_withcard(
  210|    546|        ourbitset->words, src_1->cardinality, src_2->array, src_2->cardinality);
  211|    546|    if (ourbitset->cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (211:9): [True: 530, False: 16]
  ------------------
  212|       |        // need to convert!
  213|    530|        *dst = array_container_from_bitset(ourbitset);
  214|    530|        bitset_container_free(ourbitset);
  215|    530|        returnval = false;  // not going to be a bitset
  216|    530|    }
  217|       |
  218|    546|    return returnval;
  219|  8.38k|}
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.45k|                                  container_t **dst) {
  305|  1.45k|    int card = bitset_container_xor(src_1, src_2, src_1);
  306|  1.45k|    if (card <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (306:9): [True: 1.45k, False: 0]
  ------------------
  307|  1.45k|        *dst = array_container_from_bitset(src_1);
  308|  1.45k|        bitset_container_free(src_1);
  309|  1.45k|        return false;  // not bitset
  310|  1.45k|    } else {
  311|      0|        *dst = src_1;
  312|       |        return true;
  313|      0|    }
  314|  1.45k|}
array_bitset_container_ixor:
  318|    103|                                 container_t **dst) {
  319|       |    bool ans = array_bitset_container_xor(src_1, src_2, dst);
  320|    103|    array_container_free(src_1);
  321|    103|    return ans;
  322|    103|}
run_bitset_container_ixor:
  333|     15|                               container_t **dst) {
  334|       |    bool ans = run_bitset_container_xor(src_1, src_2, dst);
  335|     15|    run_container_free(src_1);
  336|     15|    return ans;
  337|     15|}
bitset_run_container_ixor:
  341|     71|                               container_t **dst) {
  342|       |    bool ans = run_bitset_container_xor(src_2, src_1, dst);
  343|     71|    bitset_container_free(src_1);
  344|     71|    return ans;
  345|     71|}
array_run_container_ixor:
  352|    290|                             const run_container_t *src_2, container_t **dst) {
  353|    290|    int ans = array_run_container_xor(src_1, src_2, dst);
  354|    290|    array_container_free(src_1);
  355|    290|    return ans;
  356|    290|}
run_array_container_ixor:
  360|     61|                             container_t **dst) {
  361|     61|    int ans = array_run_container_xor(src_2, src_1, dst);
  362|     61|    run_container_free(src_1);
  363|     61|    return ans;
  364|     61|}
array_array_container_ixor:
  368|  4.85k|                                container_t **dst) {
  369|       |    bool ans = array_array_container_xor(src_1, src_2, dst);
  370|  4.85k|    array_container_free(src_1);
  371|  4.85k|    return ans;
  372|  4.85k|}
run_run_container_ixor:
  375|  55.5k|                           container_t **dst) {
  376|  55.5k|    int ans = run_run_container_xor(src_1, src_2, dst);
  377|  55.5k|    run_container_free(src_1);
  378|  55.5k|    return ans;
  379|  55.5k|}

run_container_add:
   39|   401k|bool run_container_add(run_container_t *run, uint16_t pos) {
   40|   401k|    int32_t index = interleavedBinarySearch(run->runs, run->n_runs, pos);
   41|   401k|    if (index >= 0) return false;  // already there
  ------------------
  |  Branch (41:9): [True: 174k, False: 226k]
  ------------------
   42|   226k|    index = -index - 2;            // points to preceding value, possibly -1
   43|   226k|    if (index >= 0) {              // possible match
  ------------------
  |  Branch (43:9): [True: 226k, False: 469]
  ------------------
   44|   226k|        int32_t offset = pos - run->runs[index].value;
   45|   226k|        int32_t le = run->runs[index].length;
   46|   226k|        if (offset <= le) return false;  // already there
  ------------------
  |  Branch (46:13): [True: 136k, False: 89.5k]
  ------------------
   47|  89.5k|        if (offset == le + 1) {
  ------------------
  |  Branch (47:13): [True: 14.8k, False: 74.7k]
  ------------------
   48|       |            // we may need to fuse
   49|  14.8k|            if (index + 1 < run->n_runs) {
  ------------------
  |  Branch (49:17): [True: 14.4k, False: 321]
  ------------------
   50|  14.4k|                if (run->runs[index + 1].value == pos + 1) {
  ------------------
  |  Branch (50:21): [True: 6.86k, False: 7.62k]
  ------------------
   51|       |                    // indeed fusion is needed
   52|  6.86k|                    run->runs[index].length = run->runs[index + 1].value +
   53|  6.86k|                                              run->runs[index + 1].length -
   54|  6.86k|                                              run->runs[index].value;
   55|  6.86k|                    recoverRoomAtIndex(run, (uint16_t)(index + 1));
   56|  6.86k|                    return true;
   57|  6.86k|                }
   58|  14.4k|            }
   59|  7.94k|            run->runs[index].length++;
   60|  7.94k|            return true;
   61|  14.8k|        }
   62|  74.7k|        if (index + 1 < run->n_runs) {
  ------------------
  |  Branch (62:13): [True: 73.0k, False: 1.68k]
  ------------------
   63|       |            // we may need to fuse
   64|  73.0k|            if (run->runs[index + 1].value == pos + 1) {
  ------------------
  |  Branch (64:17): [True: 31.9k, False: 41.1k]
  ------------------
   65|       |                // indeed fusion is needed
   66|  31.9k|                run->runs[index + 1].value = pos;
   67|  31.9k|                run->runs[index + 1].length = run->runs[index + 1].length + 1;
   68|  31.9k|                return true;
   69|  31.9k|            }
   70|  73.0k|        }
   71|  74.7k|    }
   72|  43.2k|    if (index == -1) {
  ------------------
  |  Branch (72:9): [True: 469, False: 42.7k]
  ------------------
   73|       |        // we may need to extend the first run
   74|    469|        if (0 < run->n_runs) {
  ------------------
  |  Branch (74:13): [True: 469, False: 0]
  ------------------
   75|    469|            if (run->runs[0].value == pos + 1) {
  ------------------
  |  Branch (75:17): [True: 273, False: 196]
  ------------------
   76|    273|                run->runs[0].length++;
   77|    273|                run->runs[0].value--;
   78|    273|                return true;
   79|    273|            }
   80|    469|        }
   81|    469|    }
   82|  42.9k|    makeRoomAtIndex(run, (uint16_t)(index + 1));
   83|  42.9k|    run->runs[index + 1].value = pos;
   84|  42.9k|    run->runs[index + 1].length = 0;
   85|       |    return true;
   86|  43.2k|}
run_container_create_given_capacity:
   89|   373k|run_container_t *run_container_create_given_capacity(int32_t size) {
   90|   373k|    run_container_t *run;
   91|       |    /* Allocate the run container itself. */
   92|   373k|    if ((run = (run_container_t *)roaring_malloc(sizeof(run_container_t))) ==
  ------------------
  |  Branch (92:9): [True: 0, False: 373k]
  ------------------
   93|   373k|        NULL) {
   94|      0|        return NULL;
   95|      0|    }
   96|   373k|    if (size <= 0) {  // we don't want to rely on malloc(0)
  ------------------
  |  Branch (96:9): [True: 118k, False: 254k]
  ------------------
   97|   118k|        run->runs = NULL;
   98|   254k|    } else if ((run->runs = (rle16_t *)roaring_malloc(sizeof(rle16_t) *
  ------------------
  |  Branch (98:16): [True: 0, False: 254k]
  ------------------
   99|   254k|                                                      size)) == NULL) {
  100|      0|        roaring_free(run);
  101|      0|        return NULL;
  102|      0|    }
  103|   373k|    run->capacity = size;
  104|   373k|    run->n_runs = 0;
  105|   373k|    return run;
  106|   373k|}
run_container_shrink_to_fit:
  108|  2.55k|int run_container_shrink_to_fit(run_container_t *src) {
  109|  2.55k|    if (src->n_runs == src->capacity) return 0;  // nothing to do
  ------------------
  |  Branch (109:9): [True: 2.55k, 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.55k|}
run_container_create:
  119|   118k|run_container_t *run_container_create(void) {
  120|   118k|    return run_container_create_given_capacity(RUN_DEFAULT_INIT_SIZE);
  121|   118k|}
run_container_clone:
  124|   166k|run_container_t *run_container_clone(const run_container_t *src) {
  125|   166k|    run_container_t *run = run_container_create_given_capacity(src->capacity);
  126|   166k|    if (run == NULL) return NULL;
  ------------------
  |  Branch (126:9): [True: 0, False: 166k]
  ------------------
  127|   166k|    run->capacity = src->capacity;
  128|   166k|    run->n_runs = src->n_runs;
  129|   166k|    memcpy(run->runs, src->runs, src->n_runs * sizeof(rle16_t));
  130|   166k|    return run;
  131|   166k|}
run_container_free:
  193|   373k|void run_container_free(run_container_t *run) {
  194|   373k|    if (run == NULL) return;
  ------------------
  |  Branch (194:9): [True: 0, False: 373k]
  ------------------
  195|   373k|    roaring_free(run->runs);
  196|   373k|    roaring_free(run);
  197|   373k|}
run_container_grow:
  199|   123k|void run_container_grow(run_container_t *run, int32_t min, bool copy) {
  200|   123k|    int32_t newCapacity = (run->capacity == 0)   ? RUN_DEFAULT_INIT_SIZE
  ------------------
  |  Branch (200:27): [True: 118k, False: 5.01k]
  ------------------
  201|   123k|                          : run->capacity < 64   ? run->capacity * 2
  ------------------
  |  Branch (201:29): [True: 3.45k, False: 1.56k]
  ------------------
  202|  5.01k|                          : run->capacity < 1024 ? run->capacity * 3 / 2
  ------------------
  |  Branch (202:29): [True: 1.56k, False: 0]
  ------------------
  203|  1.56k|                                                 : run->capacity * 5 / 4;
  204|   123k|    if (newCapacity < min) newCapacity = min;
  ------------------
  |  Branch (204:9): [True: 120k, False: 3.15k]
  ------------------
  205|   123k|    run->capacity = newCapacity;
  206|   123k|    assert(run->capacity >= min);
  207|   123k|    if (copy) {
  ------------------
  |  Branch (207:9): [True: 5.01k, False: 118k]
  ------------------
  208|  5.01k|        rle16_t *oldruns = run->runs;
  209|  5.01k|        run->runs = (rle16_t *)roaring_realloc(oldruns,
  210|  5.01k|                                               run->capacity * sizeof(rle16_t));
  211|  5.01k|        if (run->runs == NULL) roaring_free(oldruns);
  ------------------
  |  Branch (211:13): [True: 0, False: 5.01k]
  ------------------
  212|   118k|    } else {
  213|   118k|        roaring_free(run->runs);
  214|   118k|        run->runs = (rle16_t *)roaring_malloc(run->capacity * sizeof(rle16_t));
  215|   118k|    }
  216|       |    // We may have run->runs == NULL.
  217|   123k|}
run_container_copy:
  220|  53.8k|void run_container_copy(const run_container_t *src, run_container_t *dst) {
  221|  53.8k|    const int32_t n_runs = src->n_runs;
  222|  53.8k|    if (src->n_runs > dst->capacity) {
  ------------------
  |  Branch (222:9): [True: 53.8k, False: 40]
  ------------------
  223|       |        run_container_grow(dst, n_runs, false);
  224|  53.8k|    }
  225|  53.8k|    dst->n_runs = n_runs;
  226|  53.8k|    memcpy(dst->runs, src->runs, sizeof(rle16_t) * n_runs);
  227|  53.8k|}
run_container_union:
  232|    655|                         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|    655|    const bool if1 = run_container_is_full(src_1);
  237|    655|    const bool if2 = run_container_is_full(src_2);
  238|    655|    if (if1 || if2) {
  ------------------
  |  Branch (238:9): [True: 0, False: 655]
  |  Branch (238:16): [True: 8, False: 647]
  ------------------
  239|      8|        if (if1) {
  ------------------
  |  Branch (239:13): [True: 0, False: 8]
  ------------------
  240|      0|            run_container_copy(src_1, dst);
  241|      0|            return;
  242|      0|        }
  243|      8|        if (if2) {
  ------------------
  |  Branch (243:13): [True: 8, False: 0]
  ------------------
  244|      8|            run_container_copy(src_2, dst);
  245|      8|            return;
  246|      8|        }
  247|      8|    }
  248|    647|    const int32_t neededcapacity = src_1->n_runs + src_2->n_runs;
  249|    647|    if (dst->capacity < neededcapacity)
  ------------------
  |  Branch (249:9): [True: 647, False: 0]
  ------------------
  250|    647|        run_container_grow(dst, neededcapacity, false);
  251|    647|    dst->n_runs = 0;
  252|    647|    int32_t rlepos = 0;
  253|    647|    int32_t xrlepos = 0;
  254|       |
  255|    647|    rle16_t previousrle;
  256|    647|    if (src_1->runs[rlepos].value <= src_2->runs[xrlepos].value) {
  ------------------
  |  Branch (256:9): [True: 599, False: 48]
  ------------------
  257|    599|        previousrle = run_container_append_first(dst, src_1->runs[rlepos]);
  258|    599|        rlepos++;
  259|    599|    } else {
  260|     48|        previousrle = run_container_append_first(dst, src_2->runs[xrlepos]);
  261|     48|        xrlepos++;
  262|     48|    }
  263|       |
  264|  77.9k|    while ((xrlepos < src_2->n_runs) && (rlepos < src_1->n_runs)) {
  ------------------
  |  Branch (264:12): [True: 77.7k, False: 291]
  |  Branch (264:41): [True: 77.3k, False: 356]
  ------------------
  265|  77.3k|        rle16_t newrl;
  266|  77.3k|        if (src_1->runs[rlepos].value <= src_2->runs[xrlepos].value) {
  ------------------
  |  Branch (266:13): [True: 42.6k, False: 34.6k]
  ------------------
  267|  42.6k|            newrl = src_1->runs[rlepos];
  268|  42.6k|            rlepos++;
  269|  42.6k|        } else {
  270|  34.6k|            newrl = src_2->runs[xrlepos];
  271|  34.6k|            xrlepos++;
  272|  34.6k|        }
  273|  77.3k|        run_container_append(dst, newrl, &previousrle);
  274|  77.3k|    }
  275|  1.65k|    while (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (275:12): [True: 1.01k, False: 647]
  ------------------
  276|  1.01k|        run_container_append(dst, src_2->runs[xrlepos], &previousrle);
  277|  1.01k|        xrlepos++;
  278|  1.01k|    }
  279|  14.1k|    while (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (279:12): [True: 13.5k, False: 647]
  ------------------
  280|  13.5k|        run_container_append(dst, src_1->runs[rlepos], &previousrle);
  281|  13.5k|        rlepos++;
  282|  13.5k|    }
  283|    647|}
run_container_union_inplace:
  288|  1.67k|                                 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.67k|    const bool if1 = run_container_is_full(src_1);
  293|  1.67k|    const bool if2 = run_container_is_full(src_2);
  294|  1.67k|    if (if1 || if2) {
  ------------------
  |  Branch (294:9): [True: 0, False: 1.67k]
  |  Branch (294:16): [True: 40, False: 1.63k]
  ------------------
  295|     40|        if (if1) {
  ------------------
  |  Branch (295:13): [True: 0, False: 40]
  ------------------
  296|      0|            return;
  297|      0|        }
  298|     40|        if (if2) {
  ------------------
  |  Branch (298:13): [True: 40, False: 0]
  ------------------
  299|     40|            run_container_copy(src_2, src_1);
  300|     40|            return;
  301|     40|        }
  302|     40|    }
  303|       |    // we move the data to the end of the current array
  304|  1.63k|    const int32_t maxoutput = src_1->n_runs + src_2->n_runs;
  305|  1.63k|    const int32_t neededcapacity = maxoutput + src_1->n_runs;
  306|  1.63k|    if (src_1->capacity < neededcapacity)
  ------------------
  |  Branch (306:9): [True: 1.63k, False: 0]
  ------------------
  307|  1.63k|        run_container_grow(src_1, neededcapacity, true);
  308|  1.63k|    memmove(src_1->runs + maxoutput, src_1->runs,
  309|  1.63k|            src_1->n_runs * sizeof(rle16_t));
  310|  1.63k|    rle16_t *inputsrc1 = src_1->runs + maxoutput;
  311|  1.63k|    const int32_t input1nruns = src_1->n_runs;
  312|  1.63k|    src_1->n_runs = 0;
  313|  1.63k|    int32_t rlepos = 0;
  314|  1.63k|    int32_t xrlepos = 0;
  315|       |
  316|  1.63k|    rle16_t previousrle;
  317|  1.63k|    if (inputsrc1[rlepos].value <= src_2->runs[xrlepos].value) {
  ------------------
  |  Branch (317:9): [True: 1.56k, False: 75]
  ------------------
  318|  1.56k|        previousrle = run_container_append_first(src_1, inputsrc1[rlepos]);
  319|  1.56k|        rlepos++;
  320|  1.56k|    } else {
  321|     75|        previousrle = run_container_append_first(src_1, src_2->runs[xrlepos]);
  322|     75|        xrlepos++;
  323|     75|    }
  324|   189k|    while ((xrlepos < src_2->n_runs) && (rlepos < input1nruns)) {
  ------------------
  |  Branch (324:12): [True: 189k, False: 140]
  |  Branch (324:41): [True: 188k, False: 1.49k]
  ------------------
  325|   188k|        rle16_t newrl;
  326|   188k|        if (inputsrc1[rlepos].value <= src_2->runs[xrlepos].value) {
  ------------------
  |  Branch (326:13): [True: 90.4k, False: 97.8k]
  ------------------
  327|  90.4k|            newrl = inputsrc1[rlepos];
  328|  90.4k|            rlepos++;
  329|  97.8k|        } else {
  330|  97.8k|            newrl = src_2->runs[xrlepos];
  331|  97.8k|            xrlepos++;
  332|  97.8k|        }
  333|   188k|        run_container_append(src_1, newrl, &previousrle);
  334|   188k|    }
  335|  4.38k|    while (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (335:12): [True: 2.75k, False: 1.63k]
  ------------------
  336|  2.75k|        run_container_append(src_1, src_2->runs[xrlepos], &previousrle);
  337|  2.75k|        xrlepos++;
  338|  2.75k|    }
  339|  9.69k|    while (rlepos < input1nruns) {
  ------------------
  |  Branch (339:12): [True: 8.05k, False: 1.63k]
  ------------------
  340|  8.05k|        run_container_append(src_1, inputsrc1[rlepos], &previousrle);
  341|  8.05k|        rlepos++;
  342|  8.05k|    }
  343|  1.63k|}
run_container_xor:
  349|  56.2k|                       const run_container_t *src_2, run_container_t *dst) {
  350|       |    // don't bother to convert xor with full range into negation
  351|       |    // since negation is implemented similarly
  352|       |
  353|  56.2k|    const int32_t neededcapacity = src_1->n_runs + src_2->n_runs;
  354|  56.2k|    if (dst->capacity < neededcapacity)
  ------------------
  |  Branch (354:9): [True: 56.2k, False: 0]
  ------------------
  355|  56.2k|        run_container_grow(dst, neededcapacity, false);
  356|       |
  357|  56.2k|    int32_t pos1 = 0;
  358|  56.2k|    int32_t pos2 = 0;
  359|  56.2k|    dst->n_runs = 0;
  360|       |
  361|   225k|    while ((pos1 < src_1->n_runs) && (pos2 < src_2->n_runs)) {
  ------------------
  |  Branch (361:12): [True: 170k, False: 55.9k]
  |  Branch (361:38): [True: 169k, False: 303]
  ------------------
  362|   169k|        if (src_1->runs[pos1].value <= src_2->runs[pos2].value) {
  ------------------
  |  Branch (362:13): [True: 115k, False: 54.7k]
  ------------------
  363|   115k|            run_container_smart_append_exclusive(dst, src_1->runs[pos1].value,
  364|   115k|                                                 src_1->runs[pos1].length);
  365|   115k|            pos1++;
  366|   115k|        } else {
  367|  54.7k|            run_container_smart_append_exclusive(dst, src_2->runs[pos2].value,
  368|  54.7k|                                                 src_2->runs[pos2].length);
  369|  54.7k|            pos2++;
  370|  54.7k|        }
  371|   169k|    }
  372|  70.6k|    while (pos1 < src_1->n_runs) {
  ------------------
  |  Branch (372:12): [True: 14.4k, False: 56.2k]
  ------------------
  373|  14.4k|        run_container_smart_append_exclusive(dst, src_1->runs[pos1].value,
  374|  14.4k|                                             src_1->runs[pos1].length);
  375|  14.4k|        pos1++;
  376|  14.4k|    }
  377|       |
  378|   113k|    while (pos2 < src_2->n_runs) {
  ------------------
  |  Branch (378:12): [True: 57.7k, False: 56.2k]
  ------------------
  379|  57.7k|        run_container_smart_append_exclusive(dst, src_2->runs[pos2].value,
  380|  57.7k|                                             src_2->runs[pos2].length);
  381|  57.7k|        pos2++;
  382|  57.7k|    }
  383|  56.2k|}
run_container_intersection:
  389|  57.1k|                                run_container_t *dst) {
  390|  57.1k|    const bool if1 = run_container_is_full(src_1);
  391|  57.1k|    const bool if2 = run_container_is_full(src_2);
  392|  57.1k|    if (if1 || if2) {
  ------------------
  |  Branch (392:9): [True: 53.7k, False: 3.47k]
  |  Branch (392:16): [True: 8, False: 3.46k]
  ------------------
  393|  53.7k|        if (if1) {
  ------------------
  |  Branch (393:13): [True: 53.7k, False: 8]
  ------------------
  394|  53.7k|            run_container_copy(src_2, dst);
  395|  53.7k|            return;
  396|  53.7k|        }
  397|      8|        if (if2) {
  ------------------
  |  Branch (397:13): [True: 8, False: 0]
  ------------------
  398|      8|            run_container_copy(src_1, dst);
  399|      8|            return;
  400|      8|        }
  401|      8|    }
  402|       |    // TODO: this could be a lot more efficient, could use SIMD optimizations
  403|  3.46k|    const int32_t neededcapacity = src_1->n_runs + src_2->n_runs;
  404|  3.46k|    if (dst->capacity < neededcapacity)
  ------------------
  |  Branch (404:9): [True: 3.46k, False: 0]
  ------------------
  405|  3.46k|        run_container_grow(dst, neededcapacity, false);
  406|  3.46k|    dst->n_runs = 0;
  407|  3.46k|    int32_t rlepos = 0;
  408|  3.46k|    int32_t xrlepos = 0;
  409|  3.46k|    int32_t start = src_1->runs[rlepos].value;
  410|  3.46k|    int32_t end = start + src_1->runs[rlepos].length + 1;
  411|  3.46k|    int32_t xstart = src_2->runs[xrlepos].value;
  412|  3.46k|    int32_t xend = xstart + src_2->runs[xrlepos].length + 1;
  413|   178k|    while ((rlepos < src_1->n_runs) && (xrlepos < src_2->n_runs)) {
  ------------------
  |  Branch (413:12): [True: 175k, False: 3.01k]
  |  Branch (413:40): [True: 175k, False: 452]
  ------------------
  414|   175k|        if (end <= xstart) {
  ------------------
  |  Branch (414:13): [True: 46.0k, False: 129k]
  ------------------
  415|  46.0k|            ++rlepos;
  416|  46.0k|            if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (416:17): [True: 45.9k, False: 81]
  ------------------
  417|  45.9k|                start = src_1->runs[rlepos].value;
  418|  45.9k|                end = start + src_1->runs[rlepos].length + 1;
  419|  45.9k|            }
  420|   129k|        } else if (xend <= start) {
  ------------------
  |  Branch (420:20): [True: 11.4k, False: 117k]
  ------------------
  421|  11.4k|            ++xrlepos;
  422|  11.4k|            if (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (422:17): [True: 11.3k, False: 44]
  ------------------
  423|  11.3k|                xstart = src_2->runs[xrlepos].value;
  424|  11.3k|                xend = xstart + src_2->runs[xrlepos].length + 1;
  425|  11.3k|            }
  426|   117k|        } else {  // they overlap
  427|   117k|            const int32_t lateststart = start > xstart ? start : xstart;
  ------------------
  |  Branch (427:41): [True: 16.8k, False: 101k]
  ------------------
  428|   117k|            int32_t earliestend;
  429|   117k|            if (end == xend) {  // improbable
  ------------------
  |  Branch (429:17): [True: 87.1k, False: 30.8k]
  ------------------
  430|  87.1k|                earliestend = end;
  431|  87.1k|                rlepos++;
  432|  87.1k|                xrlepos++;
  433|  87.1k|                if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (433:21): [True: 84.3k, False: 2.78k]
  ------------------
  434|  84.3k|                    start = src_1->runs[rlepos].value;
  435|  84.3k|                    end = start + src_1->runs[rlepos].length + 1;
  436|  84.3k|                }
  437|  87.1k|                if (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (437:21): [True: 84.1k, False: 2.98k]
  ------------------
  438|  84.1k|                    xstart = src_2->runs[xrlepos].value;
  439|  84.1k|                    xend = xstart + src_2->runs[xrlepos].length + 1;
  440|  84.1k|                }
  441|  87.1k|            } else if (end < xend) {
  ------------------
  |  Branch (441:24): [True: 17.1k, False: 13.6k]
  ------------------
  442|  17.1k|                earliestend = end;
  443|  17.1k|                rlepos++;
  444|  17.1k|                if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (444:21): [True: 16.9k, False: 143]
  ------------------
  445|  16.9k|                    start = src_1->runs[rlepos].value;
  446|  16.9k|                    end = start + src_1->runs[rlepos].length + 1;
  447|  16.9k|                }
  448|       |
  449|  17.1k|            } else {  // end > xend
  450|  13.6k|                earliestend = xend;
  451|  13.6k|                xrlepos++;
  452|  13.6k|                if (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (452:21): [True: 13.5k, False: 124]
  ------------------
  453|  13.5k|                    xstart = src_2->runs[xrlepos].value;
  454|  13.5k|                    xend = xstart + src_2->runs[xrlepos].length + 1;
  455|  13.5k|                }
  456|  13.6k|            }
  457|   117k|            dst->runs[dst->n_runs].value = (uint16_t)lateststart;
  458|   117k|            dst->runs[dst->n_runs].length =
  459|   117k|                (uint16_t)(earliestend - lateststart - 1);
  460|   117k|            dst->n_runs++;
  461|   117k|        }
  462|   175k|    }
  463|  3.46k|}
run_container_intersection_cardinality:
  467|  2.62k|                                           const run_container_t *src_2) {
  468|  2.62k|    const bool if1 = run_container_is_full(src_1);
  469|  2.62k|    const bool if2 = run_container_is_full(src_2);
  470|  2.62k|    if (if1 || if2) {
  ------------------
  |  Branch (470:9): [True: 0, False: 2.62k]
  |  Branch (470:16): [True: 32, False: 2.58k]
  ------------------
  471|     32|        if (if1) {
  ------------------
  |  Branch (471:13): [True: 0, False: 32]
  ------------------
  472|      0|            return run_container_cardinality(src_2);
  473|      0|        }
  474|     32|        if (if2) {
  ------------------
  |  Branch (474:13): [True: 32, False: 0]
  ------------------
  475|     32|            return run_container_cardinality(src_1);
  476|     32|        }
  477|     32|    }
  478|  2.58k|    int answer = 0;
  479|  2.58k|    int32_t rlepos = 0;
  480|  2.58k|    int32_t xrlepos = 0;
  481|  2.58k|    int32_t start = src_1->runs[rlepos].value;
  482|  2.58k|    int32_t end = start + src_1->runs[rlepos].length + 1;
  483|  2.58k|    int32_t xstart = src_2->runs[xrlepos].value;
  484|  2.58k|    int32_t xend = xstart + src_2->runs[xrlepos].length + 1;
  485|   277k|    while ((rlepos < src_1->n_runs) && (xrlepos < src_2->n_runs)) {
  ------------------
  |  Branch (485:12): [True: 276k, False: 1.78k]
  |  Branch (485:40): [True: 275k, False: 804]
  ------------------
  486|   275k|        if (end <= xstart) {
  ------------------
  |  Branch (486:13): [True: 67.0k, False: 208k]
  ------------------
  487|  67.0k|            ++rlepos;
  488|  67.0k|            if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (488:17): [True: 66.7k, False: 324]
  ------------------
  489|  66.7k|                start = src_1->runs[rlepos].value;
  490|  66.7k|                end = start + src_1->runs[rlepos].length + 1;
  491|  66.7k|            }
  492|   208k|        } else if (xend <= start) {
  ------------------
  |  Branch (492:20): [True: 45.6k, False: 162k]
  ------------------
  493|  45.6k|            ++xrlepos;
  494|  45.6k|            if (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (494:17): [True: 45.4k, False: 176]
  ------------------
  495|  45.4k|                xstart = src_2->runs[xrlepos].value;
  496|  45.4k|                xend = xstart + src_2->runs[xrlepos].length + 1;
  497|  45.4k|            }
  498|   162k|        } else {  // they overlap
  499|   162k|            const int32_t lateststart = start > xstart ? start : xstart;
  ------------------
  |  Branch (499:41): [True: 67.3k, False: 95.2k]
  ------------------
  500|   162k|            int32_t earliestend;
  501|   162k|            if (end == xend) {  // improbable
  ------------------
  |  Branch (501:17): [True: 76.4k, False: 86.1k]
  ------------------
  502|  76.4k|                earliestend = end;
  503|  76.4k|                rlepos++;
  504|  76.4k|                xrlepos++;
  505|  76.4k|                if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (505:21): [True: 75.5k, False: 888]
  ------------------
  506|  75.5k|                    start = src_1->runs[rlepos].value;
  507|  75.5k|                    end = start + src_1->runs[rlepos].length + 1;
  508|  75.5k|                }
  509|  76.4k|                if (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (509:21): [True: 75.4k, False: 984]
  ------------------
  510|  75.4k|                    xstart = src_2->runs[xrlepos].value;
  511|  75.4k|                    xend = xstart + src_2->runs[xrlepos].length + 1;
  512|  75.4k|                }
  513|  86.1k|            } else if (end < xend) {
  ------------------
  |  Branch (513:24): [True: 68.5k, False: 17.6k]
  ------------------
  514|  68.5k|                earliestend = end;
  515|  68.5k|                rlepos++;
  516|  68.5k|                if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (516:21): [True: 67.9k, False: 572]
  ------------------
  517|  67.9k|                    start = src_1->runs[rlepos].value;
  518|  67.9k|                    end = start + src_1->runs[rlepos].length + 1;
  519|  67.9k|                }
  520|       |
  521|  68.5k|            } else {  // end > xend
  522|  17.6k|                earliestend = xend;
  523|  17.6k|                xrlepos++;
  524|  17.6k|                if (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (524:21): [True: 17.4k, False: 196]
  ------------------
  525|  17.4k|                    xstart = src_2->runs[xrlepos].value;
  526|  17.4k|                    xend = xstart + src_2->runs[xrlepos].length + 1;
  527|  17.4k|                }
  528|  17.6k|            }
  529|   162k|            answer += earliestend - lateststart;
  530|   162k|        }
  531|   275k|    }
  532|  2.58k|    return answer;
  533|  2.62k|}
run_container_intersect:
  536|    655|                             const run_container_t *src_2) {
  537|    655|    const bool if1 = run_container_is_full(src_1);
  538|    655|    const bool if2 = run_container_is_full(src_2);
  539|    655|    if (if1 || if2) {
  ------------------
  |  Branch (539:9): [True: 0, False: 655]
  |  Branch (539:16): [True: 8, False: 647]
  ------------------
  540|      8|        if (if1) {
  ------------------
  |  Branch (540:13): [True: 0, False: 8]
  ------------------
  541|      0|            return !run_container_empty(src_2);
  542|      0|        }
  543|      8|        if (if2) {
  ------------------
  |  Branch (543:13): [True: 8, False: 0]
  ------------------
  544|      8|            return !run_container_empty(src_1);
  545|      8|        }
  546|      8|    }
  547|    647|    int32_t rlepos = 0;
  548|    647|    int32_t xrlepos = 0;
  549|    647|    int32_t start = src_1->runs[rlepos].value;
  550|    647|    int32_t end = start + src_1->runs[rlepos].length + 1;
  551|    647|    int32_t xstart = src_2->runs[xrlepos].value;
  552|    647|    int32_t xend = xstart + src_2->runs[xrlepos].length + 1;
  553|  3.92k|    while ((rlepos < src_1->n_runs) && (xrlepos < src_2->n_runs)) {
  ------------------
  |  Branch (553:12): [True: 3.90k, False: 21]
  |  Branch (553:40): [True: 3.89k, False: 2]
  ------------------
  554|  3.89k|        if (end <= xstart) {
  ------------------
  |  Branch (554:13): [True: 2.87k, False: 1.02k]
  ------------------
  555|  2.87k|            ++rlepos;
  556|  2.87k|            if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (556:17): [True: 2.85k, False: 21]
  ------------------
  557|  2.85k|                start = src_1->runs[rlepos].value;
  558|  2.85k|                end = start + src_1->runs[rlepos].length + 1;
  559|  2.85k|            }
  560|  2.87k|        } else if (xend <= start) {
  ------------------
  |  Branch (560:20): [True: 400, False: 624]
  ------------------
  561|    400|            ++xrlepos;
  562|    400|            if (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (562:17): [True: 398, False: 2]
  ------------------
  563|    398|                xstart = src_2->runs[xrlepos].value;
  564|    398|                xend = xstart + src_2->runs[xrlepos].length + 1;
  565|    398|            }
  566|    624|        } else {  // they overlap
  567|    624|            return true;
  568|    624|        }
  569|  3.89k|    }
  570|     23|    return false;
  571|    647|}
run_container_andnot:
  576|  1.05k|                          const run_container_t *src_2, run_container_t *dst) {
  577|       |    // following Java implementation as of June 2016
  578|       |
  579|  1.05k|    if (dst->capacity < src_1->n_runs + src_2->n_runs)
  ------------------
  |  Branch (579:9): [True: 1.05k, False: 0]
  ------------------
  580|  1.05k|        run_container_grow(dst, src_1->n_runs + src_2->n_runs, false);
  581|       |
  582|  1.05k|    dst->n_runs = 0;
  583|       |
  584|  1.05k|    int rlepos1 = 0;
  585|  1.05k|    int rlepos2 = 0;
  586|  1.05k|    int32_t start = src_1->runs[rlepos1].value;
  587|  1.05k|    int32_t end = start + src_1->runs[rlepos1].length + 1;
  588|  1.05k|    int32_t start2 = src_2->runs[rlepos2].value;
  589|  1.05k|    int32_t end2 = start2 + src_2->runs[rlepos2].length + 1;
  590|       |
  591|   149k|    while ((rlepos1 < src_1->n_runs) && (rlepos2 < src_2->n_runs)) {
  ------------------
  |  Branch (591:12): [True: 148k, False: 641]
  |  Branch (591:41): [True: 147k, False: 418]
  ------------------
  592|   147k|        if (end <= start2) {
  ------------------
  |  Branch (592:13): [True: 21.9k, False: 126k]
  ------------------
  593|       |            // output the first run
  594|  21.9k|            dst->runs[dst->n_runs++] =
  595|  21.9k|                CROARING_MAKE_RLE16(start, end - start - 1);
  ------------------
  |  |   60|  21.9k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  596|  21.9k|            rlepos1++;
  597|  21.9k|            if (rlepos1 < src_1->n_runs) {
  ------------------
  |  Branch (597:17): [True: 21.8k, False: 81]
  ------------------
  598|  21.8k|                start = src_1->runs[rlepos1].value;
  599|  21.8k|                end = start + src_1->runs[rlepos1].length + 1;
  600|  21.8k|            }
  601|   126k|        } else if (end2 <= start) {
  ------------------
  |  Branch (601:20): [True: 59.9k, False: 66.1k]
  ------------------
  602|       |            // exit the second run
  603|  59.9k|            rlepos2++;
  604|  59.9k|            if (rlepos2 < src_2->n_runs) {
  ------------------
  |  Branch (604:17): [True: 59.5k, False: 418]
  ------------------
  605|  59.5k|                start2 = src_2->runs[rlepos2].value;
  606|  59.5k|                end2 = start2 + src_2->runs[rlepos2].length + 1;
  607|  59.5k|            }
  608|  66.1k|        } else {
  609|  66.1k|            if (start < start2) {
  ------------------
  |  Branch (609:17): [True: 18.4k, False: 47.6k]
  ------------------
  610|  18.4k|                dst->runs[dst->n_runs++] =
  611|  18.4k|                    CROARING_MAKE_RLE16(start, start2 - start - 1);
  ------------------
  |  |   60|  18.4k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  612|  18.4k|            }
  613|  66.1k|            if (end2 < end) {
  ------------------
  |  Branch (613:17): [True: 18.1k, False: 47.9k]
  ------------------
  614|  18.1k|                start = end2;
  615|  47.9k|            } else {
  616|  47.9k|                rlepos1++;
  617|  47.9k|                if (rlepos1 < src_1->n_runs) {
  ------------------
  |  Branch (617:21): [True: 47.3k, False: 560]
  ------------------
  618|  47.3k|                    start = src_1->runs[rlepos1].value;
  619|  47.3k|                    end = start + src_1->runs[rlepos1].length + 1;
  620|  47.3k|                }
  621|  47.9k|            }
  622|  66.1k|        }
  623|   147k|    }
  624|  1.05k|    if (rlepos1 < src_1->n_runs) {
  ------------------
  |  Branch (624:9): [True: 418, False: 641]
  ------------------
  625|    418|        dst->runs[dst->n_runs++] = CROARING_MAKE_RLE16(start, end - start - 1);
  ------------------
  |  |   60|    418|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  626|    418|        rlepos1++;
  627|    418|        if (rlepos1 < src_1->n_runs) {
  ------------------
  |  Branch (627:13): [True: 192, False: 226]
  ------------------
  628|    192|            memcpy(dst->runs + dst->n_runs, src_1->runs + rlepos1,
  629|    192|                   sizeof(rle16_t) * (src_1->n_runs - rlepos1));
  630|    192|            dst->n_runs += src_1->n_runs - rlepos1;
  631|    192|        }
  632|    418|    }
  633|  1.05k|}
run_container_read:
  739|     49|                           const char *buf) {
  740|     49|    (void)cardinality;
  741|     49|    uint16_t cast_16;
  742|     49|    memcpy(&cast_16, buf, sizeof(uint16_t));
  743|     49|    container->n_runs = croaring_letoh16(cast_16);
  ------------------
  |  |  524|     49|#define croaring_letoh16(x) croaring_htole16(x)
  |  |  ------------------
  |  |  |  |  518|     49|#define croaring_htole16(x) (x)
  |  |  ------------------
  ------------------
  744|     49|    if (container->n_runs > container->capacity)
  ------------------
  |  Branch (744:9): [True: 7, False: 42]
  ------------------
  745|      7|        run_container_grow(container, container->n_runs, false);
  746|     49|    if (container->n_runs > 0) {
  ------------------
  |  Branch (746:9): [True: 7, False: 42]
  ------------------
  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|     49|    return run_container_size_in_bytes(container);
  763|     49|}
run_container_iterate:
  766|  56.1k|                           roaring_iterator iterator, void *ptr) {
  767|   158k|    for (int i = 0; i < cont->n_runs; ++i) {
  ------------------
  |  Branch (767:21): [True: 102k, False: 56.1k]
  ------------------
  768|   102k|        uint32_t run_start = base + cont->runs[i].value;
  769|   102k|        uint16_t le = cont->runs[i].length;
  770|       |
  771|  3.59G|        for (int j = 0; j <= le; ++j)
  ------------------
  |  Branch (771:25): [True: 3.59G, False: 102k]
  ------------------
  772|  3.59G|            if (!iterator(run_start + j, ptr)) return false;
  ------------------
  |  Branch (772:17): [True: 0, False: 3.59G]
  ------------------
  773|   102k|    }
  774|  56.1k|    return true;
  775|  56.1k|}
run_container_is_subset:
  792|    255|                             const run_container_t *container2) {
  793|    255|    int i1 = 0, i2 = 0;
  794|    744|    while (i1 < container1->n_runs && i2 < container2->n_runs) {
  ------------------
  |  Branch (794:12): [True: 744, False: 0]
  |  Branch (794:39): [True: 728, False: 16]
  ------------------
  795|    728|        int start1 = container1->runs[i1].value;
  796|    728|        int stop1 = start1 + container1->runs[i1].length;
  797|    728|        int start2 = container2->runs[i2].value;
  798|    728|        int stop2 = start2 + container2->runs[i2].length;
  799|    728|        if (start1 < start2) {
  ------------------
  |  Branch (799:13): [True: 239, False: 489]
  ------------------
  800|    239|            return false;
  801|    489|        } else {  // start1 >= start2
  802|    489|            if (stop1 < stop2) {
  ------------------
  |  Branch (802:17): [True: 0, False: 489]
  ------------------
  803|      0|                i1++;
  804|    489|            } else if (stop1 == stop2) {
  ------------------
  |  Branch (804:24): [True: 0, False: 489]
  ------------------
  805|      0|                i1++;
  806|      0|                i2++;
  807|    489|            } else {  // stop1 > stop2
  808|    489|                i2++;
  809|    489|            }
  810|    489|        }
  811|    728|    }
  812|     16|    if (i1 == container1->n_runs) {
  ------------------
  |  Branch (812:9): [True: 0, False: 16]
  ------------------
  813|      0|        return true;
  814|     16|    } else {
  815|       |        return false;
  816|     16|    }
  817|     16|}
run_container_smart_append_exclusive:
  826|   380k|                                          const uint16_t length) {
  827|   380k|    int old_end;
  828|   380k|    rle16_t *last_run = src->n_runs ? src->runs + (src->n_runs - 1) : NULL;
  ------------------
  |  Branch (828:25): [True: 310k, False: 70.0k]
  ------------------
  829|   380k|    rle16_t *appended_last_run = src->runs + src->n_runs;
  830|       |
  831|   380k|    if (!src->n_runs ||
  ------------------
  |  Branch (831:9): [True: 70.0k, False: 310k]
  ------------------
  832|   310k|        (start > (old_end = last_run->value + last_run->length + 1))) {
  ------------------
  |  Branch (832:9): [True: 171k, False: 139k]
  ------------------
  833|   241k|        *appended_last_run = CROARING_MAKE_RLE16(start, length);
  ------------------
  |  |   60|   241k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  834|   241k|        src->n_runs++;
  835|   241k|        return;
  836|   241k|    }
  837|   139k|    if (old_end == start) {
  ------------------
  |  Branch (837:9): [True: 3.59k, False: 135k]
  ------------------
  838|       |        // we merge
  839|  3.59k|        last_run->length += (length + 1);
  840|  3.59k|        return;
  841|  3.59k|    }
  842|   135k|    int new_end = start + length + 1;
  843|       |
  844|   135k|    if (start == last_run->value) {
  ------------------
  |  Branch (844:9): [True: 106k, False: 29.3k]
  ------------------
  845|       |        // wipe out previous
  846|   106k|        if (new_end < old_end) {
  ------------------
  |  Branch (846:13): [True: 6.71k, False: 99.8k]
  ------------------
  847|  6.71k|            *last_run = CROARING_MAKE_RLE16(new_end, old_end - new_end - 1);
  ------------------
  |  |   60|  6.71k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  848|  6.71k|            return;
  849|  99.8k|        } else if (new_end > old_end) {
  ------------------
  |  Branch (849:20): [True: 2.28k, False: 97.5k]
  ------------------
  850|  2.28k|            *last_run = CROARING_MAKE_RLE16(old_end, new_end - old_end - 1);
  ------------------
  |  |   60|  2.28k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  851|  2.28k|            return;
  852|  97.5k|        } else {
  853|  97.5k|            src->n_runs--;
  854|  97.5k|            return;
  855|  97.5k|        }
  856|   106k|    }
  857|  29.3k|    last_run->length = start - last_run->value - 1;
  858|  29.3k|    if (new_end < old_end) {
  ------------------
  |  Branch (858:9): [True: 23.7k, False: 5.57k]
  ------------------
  859|  23.7k|        *appended_last_run =
  860|  23.7k|            CROARING_MAKE_RLE16(new_end, old_end - new_end - 1);
  ------------------
  |  |   60|  23.7k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  861|  23.7k|        src->n_runs++;
  862|  23.7k|    } else if (new_end > old_end) {
  ------------------
  |  Branch (862:16): [True: 1.17k, False: 4.40k]
  ------------------
  863|  1.17k|        *appended_last_run =
  864|  1.17k|            CROARING_MAKE_RLE16(old_end, new_end - old_end - 1);
  ------------------
  |  |   60|  1.17k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  865|  1.17k|        src->n_runs++;
  866|  1.17k|    }
  867|  29.3k|}
run_container_select:
  871|  2.55k|                          uint32_t *element) {
  872|  13.1k|    for (int i = 0; i < container->n_runs; i++) {
  ------------------
  |  Branch (872:21): [True: 13.0k, False: 87]
  ------------------
  873|  13.0k|        uint16_t length = container->runs[i].length;
  874|  13.0k|        if (rank <= *start_rank + length) {
  ------------------
  |  Branch (874:13): [True: 2.47k, False: 10.5k]
  ------------------
  875|  2.47k|            uint16_t value = container->runs[i].value;
  876|  2.47k|            *element = value + rank - (*start_rank);
  877|  2.47k|            return true;
  878|  2.47k|        } else
  879|  10.5k|            *start_rank += length + 1;
  880|  13.0k|    }
  881|     87|    return false;
  882|  2.55k|}
run_container_rank:
  884|  2.55k|int run_container_rank(const run_container_t *container, uint16_t x) {
  885|  2.55k|    int sum = 0;
  886|  2.55k|    uint32_t x32 = x;
  887|  11.1k|    for (int i = 0; i < container->n_runs; i++) {
  ------------------
  |  Branch (887:21): [True: 11.0k, False: 61]
  ------------------
  888|  11.0k|        uint32_t startpoint = container->runs[i].value;
  889|  11.0k|        uint32_t length = container->runs[i].length;
  890|  11.0k|        uint32_t endpoint = length + startpoint;
  891|  11.0k|        if (x <= endpoint) {
  ------------------
  |  Branch (891:13): [True: 2.49k, False: 8.54k]
  ------------------
  892|  2.49k|            if (x < startpoint) break;
  ------------------
  |  Branch (892:17): [True: 255, False: 2.24k]
  ------------------
  893|  2.24k|            return sum + (x32 - startpoint) + 1;
  894|  8.54k|        } else {
  895|  8.54k|            sum += length + 1;
  896|  8.54k|        }
  897|  11.0k|    }
  898|    316|    return sum;
  899|  2.55k|}
_avx2_run_container_to_uint32_array:
 1021|  56.7k|                                        uint32_t base) {
 1022|  56.7k|    int outpos = 0;
 1023|  56.7k|    uint32_t *out = (uint32_t *)vout;
 1024|       |
 1025|   196k|    for (int i = 0; i < cont->n_runs; ++i) {
  ------------------
  |  Branch (1025:21): [True: 139k, False: 56.7k]
  ------------------
 1026|   139k|        uint32_t run_start = base + cont->runs[i].value;
 1027|   139k|        uint16_t le = cont->runs[i].length;
 1028|   139k|        if (le < 8) {
  ------------------
  |  Branch (1028:13): [True: 79.1k, False: 60.2k]
  ------------------
 1029|   205k|            for (int j = 0; j <= le; ++j) {
  ------------------
  |  Branch (1029:29): [True: 126k, False: 79.1k]
  ------------------
 1030|   126k|                uint32_t val = run_start + j;
 1031|   126k|                memcpy(out + outpos, &val,
 1032|   126k|                       sizeof(uint32_t));  // should be compiled as a MOV on x64
 1033|   126k|                outpos++;
 1034|   126k|            }
 1035|  79.1k|        } else {
 1036|  60.2k|            int j = 0;
 1037|  60.2k|            __m256i run_start_v = _mm256_set1_epi32(run_start);
 1038|       |            // [8,8,8,8....]
 1039|  60.2k|            __m256i inc = _mm256_set1_epi32(8);
 1040|       |            // used for generate sequence:
 1041|       |            // [0, 1, 2, 3...], [8, 9, 10,...]
 1042|  60.2k|            __m256i delta = _mm256_setr_epi32(0, 1, 2, 3, 4, 5, 6, 7);
 1043|   450M|            for (j = 0; j + 8 <= le; j += 8) {
  ------------------
  |  Branch (1043:25): [True: 450M, False: 60.2k]
  ------------------
 1044|   450M|                __m256i val_v = _mm256_add_epi32(run_start_v, delta);
 1045|   450M|                _mm256_storeu_si256((__m256i *)(out + outpos), val_v);
 1046|   450M|                delta = _mm256_add_epi32(inc, delta);
 1047|   450M|                outpos += 8;
 1048|   450M|            }
 1049|   518k|            for (; j <= le; ++j) {
  ------------------
  |  Branch (1049:20): [True: 458k, False: 60.2k]
  ------------------
 1050|   458k|                uint32_t val = run_start + j;
 1051|   458k|                memcpy(out + outpos, &val,
 1052|   458k|                       sizeof(uint32_t));  // should be compiled as a MOV on x64
 1053|   458k|                outpos++;
 1054|   458k|            }
 1055|  60.2k|        }
 1056|   139k|    }
 1057|  56.7k|    return outpos;
 1058|  56.7k|}
run_container_cardinality:
 1077|   506k|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|   506k|        if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (1085:13): [True: 506k, False: 0]
  ------------------
 1086|   506k|        return _avx2_run_container_cardinality(run);
 1087|   506k|    } else {
 1088|      0|        return _scalar_run_container_cardinality(run);
 1089|      0|    }
 1090|   506k|}
run_container_to_uint32_array:
 1111|  56.7k|                                  uint32_t base) {
 1112|  56.7k|    if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (1112:9): [True: 56.7k, False: 0]
  ------------------
 1113|  56.7k|        return _avx2_run_container_to_uint32_array(vout, cont, base);
 1114|  56.7k|    } else {
 1115|      0|        return _scalar_run_container_to_uint32_array(vout, cont, base);
 1116|      0|    }
 1117|  56.7k|}
run.c:_avx2_run_container_cardinality:
  991|   506k|static inline int _avx2_run_container_cardinality(const run_container_t *run) {
  992|   506k|    const int32_t n_runs = run->n_runs;
  993|   506k|    const rle16_t *runs = run->runs;
  994|       |
  995|       |    /* by initializing with n_runs, we omit counting the +1 for each pair. */
  996|   506k|    int sum = n_runs;
  997|   506k|    int32_t k = 0;
  998|   506k|    const int32_t step = sizeof(__m256i) / sizeof(rle16_t);
  999|   506k|    if (n_runs > step) {
  ------------------
  |  Branch (999:9): [True: 32.7k, False: 473k]
  ------------------
 1000|  32.7k|        __m256i total = _mm256_setzero_si256();
 1001|   369k|        for (; k + step <= n_runs; k += step) {
  ------------------
  |  Branch (1001:16): [True: 336k, False: 32.7k]
  ------------------
 1002|   336k|            __m256i ymm1 = _mm256_loadu_si256((const __m256i *)(runs + k));
 1003|   336k|            __m256i justlengths = _mm256_srli_epi32(ymm1, 16);
 1004|   336k|            total = _mm256_add_epi32(total, justlengths);
 1005|   336k|        }
 1006|       |        // a store might be faster than extract?
 1007|  32.7k|        uint32_t buffer[sizeof(__m256i) / sizeof(rle16_t)];
 1008|  32.7k|        _mm256_storeu_si256((__m256i *)buffer, total);
 1009|  32.7k|        sum += (buffer[0] + buffer[1]) + (buffer[2] + buffer[3]) +
 1010|  32.7k|               (buffer[4] + buffer[5]) + (buffer[6] + buffer[7]);
 1011|  32.7k|    }
 1012|  1.05M|    for (; k < n_runs; ++k) {
  ------------------
  |  Branch (1012:12): [True: 551k, False: 506k]
  ------------------
 1013|   551k|        sum += runs[k].length;
 1014|   551k|    }
 1015|       |
 1016|   506k|    return sum;
 1017|   506k|}

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

roaring_malloc:
   48|  1.33M|void* roaring_malloc(size_t n) { return global_memory_hook.malloc(n); }
roaring_realloc:
   50|   116k|void* roaring_realloc(void* p, size_t new_sz) {
   51|   116k|    return global_memory_hook.realloc(p, new_sz);
   52|   116k|}
roaring_free:
   58|  1.57M|void roaring_free(void* p) { global_memory_hook.free(p); }
roaring_aligned_malloc:
   60|   274k|void* roaring_aligned_malloc(size_t alignment, size_t size) {
   61|   274k|    return global_memory_hook.aligned_malloc(alignment, size);
   62|   274k|}
roaring_aligned_free:
   64|   274k|void roaring_aligned_free(void* p) { global_memory_hook.aligned_free(p); }
memory.c:roaring_bitmap_aligned_malloc:
   11|   274k|static void* roaring_bitmap_aligned_malloc(size_t alignment, size_t size) {
   12|   274k|    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|   274k|    if (posix_memalign(&p, alignment, size) != 0) return NULL;
  ------------------
  |  Branch (20:9): [True: 0, False: 274k]
  ------------------
   21|   274k|#endif
   22|   274k|    return p;
   23|   274k|}
memory.c:roaring_bitmap_aligned_free:
   25|   274k|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|   274k|    free(memblock);
   32|   274k|#endif
   33|   274k|}

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

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

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

