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

binarySearch:
   52|  7.14M|                            uint16_t ikey) {
   53|  7.14M|    const int32_t gap = 16;
   54|  7.14M|    if (lenarray < gap) {
  ------------------
  |  Branch (54:9): [True: 2.75M, False: 4.38M]
  ------------------
   55|  4.24M|        for (int32_t j = 0; j < lenarray; j++) {
  ------------------
  |  Branch (55:29): [True: 4.24M, False: 7.03k]
  ------------------
   56|  4.24M|            if (array[j] >= ikey) {
  ------------------
  |  Branch (56:17): [True: 2.75M, False: 1.49M]
  ------------------
   57|  2.75M|                return (array[j] == ikey) ? j : -(j + 1);
  ------------------
  |  Branch (57:24): [True: 2.60M, False: 147k]
  ------------------
   58|  2.75M|            }
   59|  4.24M|        }
   60|  7.03k|        return -(lenarray + 1);
   61|  2.75M|    }
   62|  4.38M|    const int32_t num_blocks = lenarray / gap;
   63|  4.38M|    int32_t base = 0;
   64|  4.38M|    int32_t n = num_blocks;
   65|  8.85M|    while (n > 3) {
  ------------------
  |  Branch (65:12): [True: 4.46M, False: 4.38M]
  ------------------
   66|  4.46M|        int32_t quarter = n >> 2;
   67|       |
   68|  4.46M|        int32_t k1 = array[(base + quarter + 1) * gap - 1];
   69|  4.46M|        int32_t k2 = array[(base + 2 * quarter + 1) * gap - 1];
   70|  4.46M|        int32_t k3 = array[(base + 3 * quarter + 1) * gap - 1];
   71|       |
   72|  4.46M|        int32_t c1 = (k1 < ikey);
   73|  4.46M|        int32_t c2 = (k2 < ikey);
   74|  4.46M|        int32_t c3 = (k3 < ikey);
   75|       |
   76|  4.46M|        base += (c1 + c2 + c3) * quarter;
   77|  4.46M|        n -= 3 * quarter;
   78|  4.46M|    }
   79|  8.12M|    while (n > 1) {
  ------------------
  |  Branch (79:12): [True: 3.74M, False: 4.38M]
  ------------------
   80|  3.74M|        int32_t half = n >> 1;
   81|  3.74M|        base = (array[(base + half + 1) * gap - 1] < ikey) ? base + half : base;
  ------------------
  |  Branch (81:16): [True: 529k, False: 3.21M]
  ------------------
   82|  3.74M|        n -= half;
   83|  3.74M|    }
   84|  4.38M|    int32_t lo = (array[(base + 1) * gap - 1] < ikey) ? base + 1 : base;
  ------------------
  |  Branch (84:18): [True: 2.07M, False: 2.30M]
  ------------------
   85|       |
   86|  4.38M|    if (lo < num_blocks) {
  ------------------
  |  Branch (86:9): [True: 4.06M, False: 317k]
  ------------------
   87|  4.06M|        const int32_t start = lo * gap;
   88|  4.06M|#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.06M|        __m128i needle = _mm_set1_epi16((short)ikey);
   95|  4.06M|        __m128i zero = _mm_setzero_si128();
   96|  4.06M|        __m128i v0 = _mm_loadu_si128((const __m128i *)(array + start));
   97|  4.06M|        __m128i ge0 = _mm_cmpeq_epi16(_mm_subs_epu16(needle, v0), zero);
   98|  4.06M|        unsigned m0 = (unsigned)_mm_movemask_epi8(ge0);
   99|  4.06M|        if (m0 != 0) {
  ------------------
  |  Branch (99:13): [True: 2.88M, False: 1.18M]
  ------------------
  100|  2.88M|            int32_t j = start + (int32_t)(roaring_trailing_zeroes(m0) >> 1);
  101|  2.88M|            return (array[j] == ikey) ? j : -(j + 1);
  ------------------
  |  Branch (101:20): [True: 2.12M, False: 758k]
  ------------------
  102|  2.88M|        }
  103|  1.18M|        __m128i v1 = _mm_loadu_si128((const __m128i *)(array + start + 8));
  104|  1.18M|        __m128i ge1 = _mm_cmpeq_epi16(_mm_subs_epu16(needle, v1), zero);
  105|  1.18M|        unsigned m1 = (unsigned)_mm_movemask_epi8(ge1);
  106|  1.18M|        int32_t j = start + 8 + (int32_t)(roaring_trailing_zeroes(m1) >> 1);
  107|  1.18M|        return (array[j] == ikey) ? j : -(j + 1);
  ------------------
  |  Branch (107:16): [True: 506k, False: 673k]
  ------------------
  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.06M|    }
  120|       |
  121|  1.82M|    for (int32_t j = num_blocks * gap; j < lenarray; j++) {
  ------------------
  |  Branch (121:40): [True: 1.81M, False: 10.4k]
  ------------------
  122|  1.81M|        if (array[j] >= ikey) {
  ------------------
  |  Branch (122:13): [True: 306k, False: 1.51M]
  ------------------
  123|   306k|            return (array[j] == ikey) ? j : -(j + 1);
  ------------------
  |  Branch (123:20): [True: 171k, False: 134k]
  ------------------
  124|   306k|        }
  125|  1.81M|    }
  126|  10.4k|    return -(lenarray + 1);
  127|   317k|}
roaring.c:advanceUntil:
  137|    469|                                   int32_t length, uint16_t min) {
  138|    469|    int32_t lower = pos + 1;
  139|       |
  140|    469|    if ((lower >= length) || (array[lower] >= min)) {
  ------------------
  |  Branch (140:9): [True: 469, False: 0]
  |  Branch (140:30): [True: 0, False: 0]
  ------------------
  141|    469|        return lower;
  142|    469|    }
  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|  8.91k|                                    uint16_t ikey) {
  198|  8.91k|    if (lenarray == 0) return 0;
  ------------------
  |  Branch (198:9): [True: 0, False: 8.91k]
  ------------------
  199|  8.91k|    int32_t pos = binarySearch(array, lenarray, ikey);
  200|  8.91k|    if (pos >= 0) {
  ------------------
  |  Branch (200:9): [True: 1.93k, False: 6.97k]
  ------------------
  201|  1.93k|        return lenarray - (pos + 1);
  202|  6.97k|    } else {
  203|  6.97k|        return lenarray - (-pos - 1);
  204|  6.97k|    }
  205|  8.91k|}
roaring.c:count_less:
  186|  15.2k|                                 uint16_t ikey) {
  187|  15.2k|    if (lenarray == 0) return 0;
  ------------------
  |  Branch (187:9): [True: 3.00k, False: 12.2k]
  ------------------
  188|  12.2k|    int32_t pos = binarySearch(array, lenarray, ikey);
  189|  12.2k|    return pos >= 0 ? pos : -(pos + 1);
  ------------------
  |  Branch (189:12): [True: 9.40k, False: 2.87k]
  ------------------
  190|  15.2k|}
array_util.c:advanceUntil:
  137|  19.7k|                                   int32_t length, uint16_t min) {
  138|  19.7k|    int32_t lower = pos + 1;
  139|       |
  140|  19.7k|    if ((lower >= length) || (array[lower] >= min)) {
  ------------------
  |  Branch (140:9): [True: 13, False: 19.7k]
  |  Branch (140:30): [True: 7.05k, False: 12.6k]
  ------------------
  141|  7.06k|        return lower;
  142|  7.06k|    }
  143|       |
  144|  12.6k|    int32_t spansize = 1;
  145|       |
  146|  54.2k|    while ((lower + spansize < length) && (array[lower + spansize] < min)) {
  ------------------
  |  Branch (146:12): [True: 52.8k, False: 1.34k]
  |  Branch (146:43): [True: 41.5k, False: 11.3k]
  ------------------
  147|  41.5k|        spansize <<= 1;
  148|  41.5k|    }
  149|  12.6k|    int32_t upper = (lower + spansize < length) ? lower + spansize : length - 1;
  ------------------
  |  Branch (149:21): [True: 11.3k, False: 1.34k]
  ------------------
  150|       |
  151|  12.6k|    if (array[upper] == min) {
  ------------------
  |  Branch (151:9): [True: 3.28k, False: 9.37k]
  ------------------
  152|  3.28k|        return upper;
  153|  3.28k|    }
  154|  9.37k|    if (array[upper] < min) {
  ------------------
  |  Branch (154:9): [True: 233, False: 9.13k]
  ------------------
  155|       |        // means
  156|       |        // array
  157|       |        // has no
  158|       |        // item
  159|       |        // >= min
  160|       |        // pos = array.length;
  161|    233|        return length;
  162|    233|    }
  163|       |
  164|       |    // we know that the next-smallest span was too small
  165|  9.13k|    lower += (spansize >> 1);
  166|       |
  167|  9.13k|    int32_t mid = 0;
  168|  28.7k|    while (lower + 1 != upper) {
  ------------------
  |  Branch (168:12): [True: 24.5k, False: 4.22k]
  ------------------
  169|  24.5k|        mid = (lower + upper) >> 1;
  170|  24.5k|        if (array[mid] == min) {
  ------------------
  |  Branch (170:13): [True: 4.91k, False: 19.5k]
  ------------------
  171|  4.91k|            return mid;
  172|  19.5k|        } else if (array[mid] < min) {
  ------------------
  |  Branch (172:20): [True: 9.62k, False: 9.96k]
  ------------------
  173|  9.62k|            lower = mid;
  174|  9.96k|        } else {
  175|  9.96k|            upper = mid;
  176|  9.96k|        }
  177|  24.5k|    }
  178|  4.22k|    return upper;
  179|  9.13k|}
mixed_intersection.c:advanceUntil:
  137|   137k|                                   int32_t length, uint16_t min) {
  138|   137k|    int32_t lower = pos + 1;
  139|       |
  140|   137k|    if ((lower >= length) || (array[lower] >= min)) {
  ------------------
  |  Branch (140:9): [True: 536, False: 137k]
  |  Branch (140:30): [True: 77.4k, False: 59.9k]
  ------------------
  141|  78.0k|        return lower;
  142|  78.0k|    }
  143|       |
  144|  59.9k|    int32_t spansize = 1;
  145|       |
  146|   146k|    while ((lower + spansize < length) && (array[lower + spansize] < min)) {
  ------------------
  |  Branch (146:12): [True: 145k, False: 1.32k]
  |  Branch (146:43): [True: 86.8k, False: 58.6k]
  ------------------
  147|  86.8k|        spansize <<= 1;
  148|  86.8k|    }
  149|  59.9k|    int32_t upper = (lower + spansize < length) ? lower + spansize : length - 1;
  ------------------
  |  Branch (149:21): [True: 58.6k, False: 1.32k]
  ------------------
  150|       |
  151|  59.9k|    if (array[upper] == min) {
  ------------------
  |  Branch (151:9): [True: 29.0k, False: 30.9k]
  ------------------
  152|  29.0k|        return upper;
  153|  29.0k|    }
  154|  30.9k|    if (array[upper] < min) {
  ------------------
  |  Branch (154:9): [True: 635, False: 30.3k]
  ------------------
  155|       |        // means
  156|       |        // array
  157|       |        // has no
  158|       |        // item
  159|       |        // >= min
  160|       |        // pos = array.length;
  161|    635|        return length;
  162|    635|    }
  163|       |
  164|       |    // we know that the next-smallest span was too small
  165|  30.3k|    lower += (spansize >> 1);
  166|       |
  167|  30.3k|    int32_t mid = 0;
  168|  54.6k|    while (lower + 1 != upper) {
  ------------------
  |  Branch (168:12): [True: 38.6k, False: 15.9k]
  ------------------
  169|  38.6k|        mid = (lower + upper) >> 1;
  170|  38.6k|        if (array[mid] == min) {
  ------------------
  |  Branch (170:13): [True: 14.3k, False: 24.2k]
  ------------------
  171|  14.3k|            return mid;
  172|  24.2k|        } else if (array[mid] < min) {
  ------------------
  |  Branch (172:20): [True: 8.99k, False: 15.2k]
  ------------------
  173|  8.99k|            lower = mid;
  174|  15.2k|        } else {
  175|  15.2k|            upper = mid;
  176|  15.2k|        }
  177|  38.6k|    }
  178|  15.9k|    return upper;
  179|  30.3k|}
mixed_subset.c:advanceUntil:
  137|    436|                                   int32_t length, uint16_t min) {
  138|    436|    int32_t lower = pos + 1;
  139|       |
  140|    436|    if ((lower >= length) || (array[lower] >= min)) {
  ------------------
  |  Branch (140:9): [True: 0, False: 436]
  |  Branch (140:30): [True: 218, False: 218]
  ------------------
  141|    218|        return lower;
  142|    218|    }
  143|       |
  144|    218|    int32_t spansize = 1;
  145|       |
  146|  1.03k|    while ((lower + spansize < length) && (array[lower + spansize] < min)) {
  ------------------
  |  Branch (146:12): [True: 954, False: 82]
  |  Branch (146:43): [True: 818, False: 136]
  ------------------
  147|    818|        spansize <<= 1;
  148|    818|    }
  149|    218|    int32_t upper = (lower + spansize < length) ? lower + spansize : length - 1;
  ------------------
  |  Branch (149:21): [True: 136, False: 82]
  ------------------
  150|       |
  151|    218|    if (array[upper] == min) {
  ------------------
  |  Branch (151:9): [True: 0, False: 218]
  ------------------
  152|      0|        return upper;
  153|      0|    }
  154|    218|    if (array[upper] < min) {
  ------------------
  |  Branch (154:9): [True: 10, False: 208]
  ------------------
  155|       |        // means
  156|       |        // array
  157|       |        // has no
  158|       |        // item
  159|       |        // >= min
  160|       |        // pos = array.length;
  161|     10|        return length;
  162|     10|    }
  163|       |
  164|       |    // we know that the next-smallest span was too small
  165|    208|    lower += (spansize >> 1);
  166|       |
  167|    208|    int32_t mid = 0;
  168|    746|    while (lower + 1 != upper) {
  ------------------
  |  Branch (168:12): [True: 538, False: 208]
  ------------------
  169|    538|        mid = (lower + upper) >> 1;
  170|    538|        if (array[mid] == min) {
  ------------------
  |  Branch (170:13): [True: 0, False: 538]
  ------------------
  171|      0|            return mid;
  172|    538|        } else if (array[mid] < min) {
  ------------------
  |  Branch (172:20): [True: 264, False: 274]
  ------------------
  173|    264|            lower = mid;
  174|    274|        } else {
  175|    274|            upper = mid;
  176|    274|        }
  177|    538|    }
  178|    208|    return upper;
  179|    208|}
mixed_andnot.c:advanceUntil:
  137|  94.2k|                                   int32_t length, uint16_t min) {
  138|  94.2k|    int32_t lower = pos + 1;
  139|       |
  140|  94.2k|    if ((lower >= length) || (array[lower] >= min)) {
  ------------------
  |  Branch (140:9): [True: 4.79k, False: 89.4k]
  |  Branch (140:30): [True: 76.2k, False: 13.1k]
  ------------------
  141|  81.0k|        return lower;
  142|  81.0k|    }
  143|       |
  144|  13.1k|    int32_t spansize = 1;
  145|       |
  146|  27.0k|    while ((lower + spansize < length) && (array[lower + spansize] < min)) {
  ------------------
  |  Branch (146:12): [True: 26.5k, False: 468]
  |  Branch (146:43): [True: 13.8k, False: 12.6k]
  ------------------
  147|  13.8k|        spansize <<= 1;
  148|  13.8k|    }
  149|  13.1k|    int32_t upper = (lower + spansize < length) ? lower + spansize : length - 1;
  ------------------
  |  Branch (149:21): [True: 12.6k, False: 468]
  ------------------
  150|       |
  151|  13.1k|    if (array[upper] == min) {
  ------------------
  |  Branch (151:9): [True: 6.62k, False: 6.54k]
  ------------------
  152|  6.62k|        return upper;
  153|  6.62k|    }
  154|  6.54k|    if (array[upper] < min) {
  ------------------
  |  Branch (154:9): [True: 432, False: 6.11k]
  ------------------
  155|       |        // means
  156|       |        // array
  157|       |        // has no
  158|       |        // item
  159|       |        // >= min
  160|       |        // pos = array.length;
  161|    432|        return length;
  162|    432|    }
  163|       |
  164|       |    // we know that the next-smallest span was too small
  165|  6.11k|    lower += (spansize >> 1);
  166|       |
  167|  6.11k|    int32_t mid = 0;
  168|  9.49k|    while (lower + 1 != upper) {
  ------------------
  |  Branch (168:12): [True: 5.73k, False: 3.75k]
  ------------------
  169|  5.73k|        mid = (lower + upper) >> 1;
  170|  5.73k|        if (array[mid] == min) {
  ------------------
  |  Branch (170:13): [True: 2.35k, False: 3.37k]
  ------------------
  171|  2.35k|            return mid;
  172|  3.37k|        } else if (array[mid] < min) {
  ------------------
  |  Branch (172:20): [True: 1.15k, False: 2.21k]
  ------------------
  173|  1.15k|            lower = mid;
  174|  2.21k|        } else {
  175|  2.21k|            upper = mid;
  176|  2.21k|        }
  177|  5.73k|    }
  178|  3.75k|    return upper;
  179|  6.11k|}

roaring.c:bitset_lenrange_cardinality:
   63|  1.16k|                                              uint32_t lenminusone) {
   64|  1.16k|    uint32_t firstword = start / 64;
   65|  1.16k|    uint32_t endword = (start + lenminusone) / 64;
   66|  1.16k|    if (firstword == endword) {
  ------------------
  |  Branch (66:9): [True: 856, False: 309]
  ------------------
   67|    856|        return roaring_hamming(words[firstword] &
   68|    856|                               ((~UINT64_C(0)) >> ((63 - lenminusone) % 64))
   69|    856|                                   << (start % 64));
   70|    856|    }
   71|    309|    int answer =
   72|    309|        roaring_hamming(words[firstword] & ((~UINT64_C(0)) << (start % 64)));
   73|   151k|    for (uint32_t i = firstword + 1; i < endword; i++) {
  ------------------
  |  Branch (73:38): [True: 151k, False: 309]
  ------------------
   74|   151k|        answer += roaring_hamming(words[i]);
   75|   151k|    }
   76|    309|    answer += roaring_hamming(words[endword] &
   77|       |                              (~UINT64_C(0)) >>
   78|    309|                                  (((~start + 1) - lenminusone - 1) % 64));
   79|    309|    return answer;
   80|  1.16k|}
roaring.c:bitset_reset_range:
  147|  1.13k|                                      uint32_t end) {
  148|  1.13k|    if (start == end) return;
  ------------------
  |  Branch (148:9): [True: 0, False: 1.13k]
  ------------------
  149|  1.13k|    uint32_t firstword = start / 64;
  150|  1.13k|    uint32_t endword = (end - 1) / 64;
  151|  1.13k|    if (firstword == endword) {
  ------------------
  |  Branch (151:9): [True: 856, False: 278]
  ------------------
  152|    856|        words[firstword] &= ~(((~UINT64_C(0)) << (start % 64)) &
  153|    856|                              ((~UINT64_C(0)) >> ((~end + 1) % 64)));
  154|    856|        return;
  155|    856|    }
  156|    278|    words[firstword] &= ~((~UINT64_C(0)) << (start % 64));
  157|   124k|    for (uint32_t i = firstword + 1; i < endword; i++) {
  ------------------
  |  Branch (157:38): [True: 123k, False: 278]
  ------------------
  158|   123k|        words[i] = UINT64_C(0);
  159|   123k|    }
  160|       |    words[endword] &= ~((~UINT64_C(0)) >> ((~end + 1) % 64));
  161|    278|}
roaring.c:bitset_set_lenrange:
  112|  1.44k|                                       uint32_t lenminusone) {
  113|  1.44k|    uint32_t firstword = start / 64;
  114|  1.44k|    uint32_t endword = (start + lenminusone) / 64;
  115|  1.44k|    if (firstword == endword) {
  ------------------
  |  Branch (115:9): [True: 0, False: 1.44k]
  ------------------
  116|      0|        words[firstword] |= ((~UINT64_C(0)) >> ((63 - lenminusone) % 64))
  117|      0|                            << (start % 64);
  118|      0|        return;
  119|      0|    }
  120|  1.44k|    uint64_t temp = words[endword];
  121|  1.44k|    words[firstword] |= (~UINT64_C(0)) << (start % 64);
  122|   427k|    for (uint32_t i = firstword + 1; i < endword; i += 2)
  ------------------
  |  Branch (122:38): [True: 426k, False: 1.44k]
  ------------------
  123|   426k|        words[i] = words[i + 1] = ~UINT64_C(0);
  124|  1.44k|    words[endword] =
  125|       |        temp | (~UINT64_C(0)) >> (((~start + 1) - lenminusone - 1) % 64);
  126|  1.44k|}
bitset.c:avx2_harley_seal_popcount256:
  355|  3.22k|                                                    const uint64_t size) {
  356|  3.22k|    __m256i total = _mm256_setzero_si256();
  357|  3.22k|    __m256i ones = _mm256_setzero_si256();
  358|  3.22k|    __m256i twos = _mm256_setzero_si256();
  359|  3.22k|    __m256i fours = _mm256_setzero_si256();
  360|  3.22k|    __m256i eights = _mm256_setzero_si256();
  361|  3.22k|    __m256i sixteens = _mm256_setzero_si256();
  362|  3.22k|    __m256i twosA, twosB, foursA, foursB, eightsA, eightsB;
  363|       |
  364|  3.22k|    const uint64_t limit = size - size % 16;
  365|  3.22k|    uint64_t i = 0;
  366|       |
  367|  54.7k|    for (; i < limit; i += 16) {
  ------------------
  |  Branch (367:12): [True: 51.5k, False: 3.22k]
  ------------------
  368|  51.5k|        CSA(&twosA, &ones, ones, _mm256_lddqu_si256(data + i),
  369|  51.5k|            _mm256_lddqu_si256(data + i + 1));
  370|  51.5k|        CSA(&twosB, &ones, ones, _mm256_lddqu_si256(data + i + 2),
  371|  51.5k|            _mm256_lddqu_si256(data + i + 3));
  372|  51.5k|        CSA(&foursA, &twos, twos, twosA, twosB);
  373|  51.5k|        CSA(&twosA, &ones, ones, _mm256_lddqu_si256(data + i + 4),
  374|  51.5k|            _mm256_lddqu_si256(data + i + 5));
  375|  51.5k|        CSA(&twosB, &ones, ones, _mm256_lddqu_si256(data + i + 6),
  376|  51.5k|            _mm256_lddqu_si256(data + i + 7));
  377|  51.5k|        CSA(&foursB, &twos, twos, twosA, twosB);
  378|  51.5k|        CSA(&eightsA, &fours, fours, foursA, foursB);
  379|  51.5k|        CSA(&twosA, &ones, ones, _mm256_lddqu_si256(data + i + 8),
  380|  51.5k|            _mm256_lddqu_si256(data + i + 9));
  381|  51.5k|        CSA(&twosB, &ones, ones, _mm256_lddqu_si256(data + i + 10),
  382|  51.5k|            _mm256_lddqu_si256(data + i + 11));
  383|  51.5k|        CSA(&foursA, &twos, twos, twosA, twosB);
  384|  51.5k|        CSA(&twosA, &ones, ones, _mm256_lddqu_si256(data + i + 12),
  385|  51.5k|            _mm256_lddqu_si256(data + i + 13));
  386|  51.5k|        CSA(&twosB, &ones, ones, _mm256_lddqu_si256(data + i + 14),
  387|  51.5k|            _mm256_lddqu_si256(data + i + 15));
  388|  51.5k|        CSA(&foursB, &twos, twos, twosA, twosB);
  389|  51.5k|        CSA(&eightsB, &fours, fours, foursA, foursB);
  390|  51.5k|        CSA(&sixteens, &eights, eights, eightsA, eightsB);
  391|       |
  392|  51.5k|        total = _mm256_add_epi64(total, popcount256(sixteens));
  393|  51.5k|    }
  394|       |
  395|  3.22k|    total = _mm256_slli_epi64(total, 4);  // * 16
  396|  3.22k|    total = _mm256_add_epi64(
  397|  3.22k|        total, _mm256_slli_epi64(popcount256(eights), 3));  // += 8 * ...
  398|  3.22k|    total = _mm256_add_epi64(
  399|  3.22k|        total, _mm256_slli_epi64(popcount256(fours), 2));  // += 4 * ...
  400|  3.22k|    total = _mm256_add_epi64(
  401|  3.22k|        total, _mm256_slli_epi64(popcount256(twos), 1));  // += 2 * ...
  402|  3.22k|    total = _mm256_add_epi64(total, popcount256(ones));
  403|  3.22k|    for (; i < size; i++)
  ------------------
  |  Branch (403:12): [True: 0, False: 3.22k]
  ------------------
  404|      0|        total =
  405|      0|            _mm256_add_epi64(total, popcount256(_mm256_lddqu_si256(data + i)));
  406|       |
  407|  3.22k|    return (uint64_t)(_mm256_extract_epi64(total, 0)) +
  408|  3.22k|           (uint64_t)(_mm256_extract_epi64(total, 1)) +
  409|  3.22k|           (uint64_t)(_mm256_extract_epi64(total, 2)) +
  410|       |           (uint64_t)(_mm256_extract_epi64(total, 3));
  411|  3.22k|}
bitset.c:CSA:
  343|  1.46M|                       __m256i c) {
  344|  1.46M|    const __m256i u = _mm256_xor_si256(a, b);
  345|  1.46M|    *h = _mm256_or_si256(_mm256_and_si256(a, b), _mm256_and_si256(u, c));
  346|  1.46M|    *l = _mm256_xor_si256(u, c);
  347|  1.46M|}
bitset.c:popcount256:
  307|   121k|static inline __m256i popcount256(__m256i v) {
  308|   121k|    const __m256i lookuppos = _mm256_setr_epi8(
  309|   121k|        /* 0 */ 4 + 0, /* 1 */ 4 + 1, /* 2 */ 4 + 1, /* 3 */ 4 + 2,
  310|   121k|        /* 4 */ 4 + 1, /* 5 */ 4 + 2, /* 6 */ 4 + 2, /* 7 */ 4 + 3,
  311|   121k|        /* 8 */ 4 + 1, /* 9 */ 4 + 2, /* a */ 4 + 2, /* b */ 4 + 3,
  312|   121k|        /* 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|   121k|        /* 4 */ 4 + 1, /* 5 */ 4 + 2, /* 6 */ 4 + 2, /* 7 */ 4 + 3,
  316|   121k|        /* 8 */ 4 + 1, /* 9 */ 4 + 2, /* a */ 4 + 2, /* b */ 4 + 3,
  317|   121k|        /* c */ 4 + 2, /* d */ 4 + 3, /* e */ 4 + 3, /* f */ 4 + 4);
  318|   121k|    const __m256i lookupneg = _mm256_setr_epi8(
  319|   121k|        /* 0 */ 4 - 0, /* 1 */ 4 - 1, /* 2 */ 4 - 1, /* 3 */ 4 - 2,
  320|   121k|        /* 4 */ 4 - 1, /* 5 */ 4 - 2, /* 6 */ 4 - 2, /* 7 */ 4 - 3,
  321|   121k|        /* 8 */ 4 - 1, /* 9 */ 4 - 2, /* a */ 4 - 2, /* b */ 4 - 3,
  322|   121k|        /* 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|   121k|        /* 4 */ 4 - 1, /* 5 */ 4 - 2, /* 6 */ 4 - 2, /* 7 */ 4 - 3,
  326|   121k|        /* 8 */ 4 - 1, /* 9 */ 4 - 2, /* a */ 4 - 2, /* b */ 4 - 3,
  327|   121k|        /* c */ 4 - 2, /* d */ 4 - 3, /* e */ 4 - 3, /* f */ 4 - 4);
  328|   121k|    const __m256i low_mask = _mm256_set1_epi8(0x0f);
  329|       |
  330|   121k|    const __m256i lo = _mm256_and_si256(v, low_mask);
  331|   121k|    const __m256i hi = _mm256_and_si256(_mm256_srli_epi16(v, 4), low_mask);
  332|   121k|    const __m256i popcnt1 = _mm256_shuffle_epi8(lookuppos, lo);
  333|   121k|    const __m256i popcnt2 = _mm256_shuffle_epi8(lookupneg, hi);
  334|   121k|    return _mm256_sad_epu8(popcnt1, popcnt2);
  335|   121k|}
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: 39.3k, False: 67.6k]
  ------------------
  116|  39.3k|        words[firstword] |= ((~UINT64_C(0)) >> ((63 - lenminusone) % 64))
  117|  39.3k|                            << (start % 64);
  118|  39.3k|        return;
  119|  39.3k|    }
  120|  67.6k|    uint64_t temp = words[endword];
  121|  67.6k|    words[firstword] |= (~UINT64_C(0)) << (start % 64);
  122|  33.3M|    for (uint32_t i = firstword + 1; i < endword; i += 2)
  ------------------
  |  Branch (122:38): [True: 33.2M, False: 67.6k]
  ------------------
  123|  33.2M|        words[i] = words[i + 1] = ~UINT64_C(0);
  124|  67.6k|    words[endword] =
  125|       |        temp | (~UINT64_C(0)) >> (((~start + 1) - lenminusone - 1) % 64);
  126|  67.6k|}
mixed_intersection.c:bitset_lenrange_cardinality:
   63|   201k|                                              uint32_t lenminusone) {
   64|   201k|    uint32_t firstword = start / 64;
   65|   201k|    uint32_t endword = (start + lenminusone) / 64;
   66|   201k|    if (firstword == endword) {
  ------------------
  |  Branch (66:9): [True: 195k, False: 5.87k]
  ------------------
   67|   195k|        return roaring_hamming(words[firstword] &
   68|   195k|                               ((~UINT64_C(0)) >> ((63 - lenminusone) % 64))
   69|   195k|                                   << (start % 64));
   70|   195k|    }
   71|  5.87k|    int answer =
   72|  5.87k|        roaring_hamming(words[firstword] & ((~UINT64_C(0)) << (start % 64)));
   73|  6.15k|    for (uint32_t i = firstword + 1; i < endword; i++) {
  ------------------
  |  Branch (73:38): [True: 280, False: 5.87k]
  ------------------
   74|    280|        answer += roaring_hamming(words[i]);
   75|    280|    }
   76|  5.87k|    answer += roaring_hamming(words[endword] &
   77|       |                              (~UINT64_C(0)) >>
   78|  5.87k|                                  (((~start + 1) - lenminusone - 1) % 64));
   79|  5.87k|    return answer;
   80|   201k|}
mixed_intersection.c:bitset_lenrange_empty:
   86|  3.74k|                                         uint32_t lenminusone) {
   87|  3.74k|    uint32_t firstword = start / 64;
   88|  3.74k|    uint32_t endword = (start + lenminusone) / 64;
   89|  3.74k|    if (firstword == endword) {
  ------------------
  |  Branch (89:9): [True: 3.46k, False: 279]
  ------------------
   90|  3.46k|        return (words[firstword] & ((~UINT64_C(0)) >> ((63 - lenminusone) % 64))
   91|  3.46k|                                       << (start % 64)) == 0;
   92|  3.46k|    }
   93|    279|    if (((words[firstword] & ((~UINT64_C(0)) << (start % 64)))) != 0) {
  ------------------
  |  Branch (93:9): [True: 82, False: 197]
  ------------------
   94|     82|        return false;
   95|     82|    }
   96|    209|    for (uint32_t i = firstword + 1; i < endword; i++) {
  ------------------
  |  Branch (96:38): [True: 14, False: 195]
  ------------------
   97|     14|        if (words[i] != 0) {
  ------------------
  |  Branch (97:13): [True: 2, False: 12]
  ------------------
   98|      2|            return false;
   99|      2|        }
  100|     14|    }
  101|    195|    if ((words[endword] &
  ------------------
  |  Branch (101:9): [True: 103, False: 92]
  ------------------
  102|    195|         (~UINT64_C(0)) >> (((~start + 1) - lenminusone - 1) % 64)) != 0) {
  103|    103|        return false;
  104|    103|    }
  105|     92|    return true;
  106|    195|}
mixed_union.c:bitset_set_lenrange:
  112|   100k|                                       uint32_t lenminusone) {
  113|   100k|    uint32_t firstword = start / 64;
  114|   100k|    uint32_t endword = (start + lenminusone) / 64;
  115|   100k|    if (firstword == endword) {
  ------------------
  |  Branch (115:9): [True: 97.8k, False: 2.93k]
  ------------------
  116|  97.8k|        words[firstword] |= ((~UINT64_C(0)) >> ((63 - lenminusone) % 64))
  117|  97.8k|                            << (start % 64);
  118|  97.8k|        return;
  119|  97.8k|    }
  120|  2.93k|    uint64_t temp = words[endword];
  121|  2.93k|    words[firstword] |= (~UINT64_C(0)) << (start % 64);
  122|  3.04k|    for (uint32_t i = firstword + 1; i < endword; i += 2)
  ------------------
  |  Branch (122:38): [True: 108, False: 2.93k]
  ------------------
  123|    108|        words[i] = words[i + 1] = ~UINT64_C(0);
  124|  2.93k|    words[endword] =
  125|       |        temp | (~UINT64_C(0)) >> (((~start + 1) - lenminusone - 1) % 64);
  126|  2.93k|}
mixed_negation.c:bitset_flip_range:
  132|  1.42k|                                     uint32_t end) {
  133|  1.42k|    if (start == end) return;
  ------------------
  |  Branch (133:9): [True: 0, False: 1.42k]
  ------------------
  134|  1.42k|    uint32_t firstword = start / 64;
  135|  1.42k|    uint32_t endword = (end - 1) / 64;
  136|  1.42k|    words[firstword] ^= ~((~UINT64_C(0)) << (start % 64));
  137|   184k|    for (uint32_t i = firstword; i < endword; i++) {
  ------------------
  |  Branch (137:34): [True: 182k, False: 1.42k]
  ------------------
  138|   182k|        words[i] = ~words[i];
  139|   182k|    }
  140|       |    words[endword] ^= ((~UINT64_C(0)) >> ((~end + 1) % 64));
  141|  1.42k|}
mixed_xor.c:bitset_flip_range:
  132|  53.8k|                                     uint32_t end) {
  133|  53.8k|    if (start == end) return;
  ------------------
  |  Branch (133:9): [True: 0, False: 53.8k]
  ------------------
  134|  53.8k|    uint32_t firstword = start / 64;
  135|  53.8k|    uint32_t endword = (end - 1) / 64;
  136|  53.8k|    words[firstword] ^= ~((~UINT64_C(0)) << (start % 64));
  137|   120k|    for (uint32_t i = firstword; i < endword; i++) {
  ------------------
  |  Branch (137:34): [True: 66.7k, False: 53.8k]
  ------------------
  138|  66.7k|        words[i] = ~words[i];
  139|  66.7k|    }
  140|       |    words[endword] ^= ((~UINT64_C(0)) >> ((~end + 1) % 64));
  141|  53.8k|}

array_container_contains:
  343|  3.25k|                                     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.25k|    const int32_t gap = 16;
  351|  3.25k|    const uint16_t *carr = arr->array;
  352|  3.25k|    int32_t cardinality = arr->cardinality;
  353|  3.25k|    if (cardinality < gap) {
  ------------------
  |  Branch (353:9): [True: 949, False: 2.31k]
  ------------------
  354|  1.06k|        for (int32_t j = 0; j < cardinality; j++) {
  ------------------
  |  Branch (354:29): [True: 1.04k, False: 20]
  ------------------
  355|  1.04k|            if (carr[j] >= pos) return carr[j] == pos;
  ------------------
  |  Branch (355:17): [True: 929, False: 114]
  ------------------
  356|  1.04k|        }
  357|     20|        return false;
  358|    949|    }
  359|  2.31k|    int32_t num_blocks = cardinality / gap;
  360|  2.31k|    int32_t base = 0;
  361|  2.31k|    int32_t n = num_blocks;
  362|  5.24k|    while (n > 3) {
  ------------------
  |  Branch (362:12): [True: 2.93k, False: 2.31k]
  ------------------
  363|  2.93k|        int32_t quarter = n >> 2;
  364|       |
  365|  2.93k|        int32_t k1 = carr[(base + quarter + 1) * gap - 1];
  366|  2.93k|        int32_t k2 = carr[(base + 2 * quarter + 1) * gap - 1];
  367|  2.93k|        int32_t k3 = carr[(base + 3 * quarter + 1) * gap - 1];
  368|       |
  369|  2.93k|        int32_t c1 = (k1 < pos);
  370|  2.93k|        int32_t c2 = (k2 < pos);
  371|  2.93k|        int32_t c3 = (k3 < pos);
  372|       |
  373|  2.93k|        base += (c1 + c2 + c3) * quarter;
  374|  2.93k|        n -= 3 * quarter;
  375|  2.93k|    }
  376|  4.11k|    while (n > 1) {
  ------------------
  |  Branch (376:12): [True: 1.80k, False: 2.31k]
  ------------------
  377|  1.80k|        int32_t half = n >> 1;
  378|  1.80k|        base = (carr[(base + half + 1) * gap - 1] < pos) ? base + half : base;
  ------------------
  |  Branch (378:16): [True: 83, False: 1.71k]
  ------------------
  379|  1.80k|        n -= half;
  380|  1.80k|    }
  381|  2.31k|    int32_t lo = (carr[(base + 1) * gap - 1] < pos) ? base + 1 : base;
  ------------------
  |  Branch (381:18): [True: 104, False: 2.20k]
  ------------------
  382|       |
  383|  2.31k|    if (lo < num_blocks) {
  ------------------
  |  Branch (383:9): [True: 2.23k, False: 77]
  ------------------
  384|  2.23k|        const uint16_t *blk = carr + lo * gap;
  385|       |#ifdef CROARING_USENEON
  386|       |        uint16x8_t needle = vdupq_n_u16(pos);
  387|       |        uint16x8_t v0 = vld1q_u16(blk);
  388|       |        uint16x8_t v1 = vld1q_u16(blk + 8);
  389|       |        uint16x8_t hit =
  390|       |            vorrq_u16(vceqq_u16(v0, needle), vceqq_u16(v1, needle));
  391|       |        return vmaxvq_u16(hit) != 0;
  392|       |#elif defined(CROARING_IS_X64)
  393|       |        __m128i needle = _mm_set1_epi16((short)pos);
  394|  2.23k|        __m128i v0 = _mm_loadu_si128((const __m128i *)blk);
  395|  2.23k|        __m128i v1 = _mm_loadu_si128((const __m128i *)(blk + 8));
  396|  2.23k|        __m128i hit = _mm_or_si128(_mm_cmpeq_epi16(v0, needle),
  397|  2.23k|                                   _mm_cmpeq_epi16(v1, needle));
  398|  2.23k|        return _mm_movemask_epi8(hit) != 0;
  399|       |#else
  400|       |        for (int32_t j = 0; j < gap; j++) {
  401|       |            if (blk[j] >= pos) return blk[j] == pos;
  402|       |        }
  403|       |        return false;
  404|       |#endif
  405|  2.23k|    }
  406|       |
  407|    495|    for (int32_t j = num_blocks * gap; j < cardinality; j++) {
  ------------------
  |  Branch (407:40): [True: 443, False: 52]
  ------------------
  408|    443|        uint16_t v = carr[j];
  409|    443|        if (v >= pos) return (v == pos);
  ------------------
  |  Branch (409:13): [True: 25, False: 418]
  ------------------
  410|    443|    }
  411|     52|    return false;
  412|     77|}
array_container_minimum:
  445|  3.54k|inline uint16_t array_container_minimum(const array_container_t *arr) {
  446|  3.54k|    if (arr->cardinality == 0) return 0;
  ------------------
  |  Branch (446:9): [True: 0, False: 3.54k]
  ------------------
  447|  3.54k|    return arr->array[0];
  448|  3.54k|}
array_container_maximum:
  451|  12.9k|inline uint16_t array_container_maximum(const array_container_t *arr) {
  452|  12.9k|    if (arr->cardinality == 0) return 0;
  ------------------
  |  Branch (452:9): [True: 0, False: 12.9k]
  ------------------
  453|  12.9k|    return arr->array[arr->cardinality - 1];
  454|  12.9k|}
array_container_rank:
  457|  3.70k|inline int array_container_rank(const array_container_t *arr, uint16_t x) {
  458|  3.70k|    const int32_t idx = binarySearch(arr->array, arr->cardinality, x);
  459|  3.70k|    const bool is_present = idx >= 0;
  460|  3.70k|    if (is_present) {
  ------------------
  |  Branch (460:9): [True: 3.13k, False: 563]
  ------------------
  461|  3.13k|        return idx + 1;
  462|  3.13k|    } else {
  463|    563|        return -idx - 1;
  464|    563|    }
  465|  3.70k|}
array_container_index_equalorlarger:
  507|  4.37k|                                               uint16_t x) {
  508|  4.37k|    const int32_t idx = binarySearch(arr->array, arr->cardinality, x);
  509|  4.37k|    const bool is_present = idx >= 0;
  510|  4.37k|    if (is_present) {
  ------------------
  |  Branch (510:9): [True: 4.02k, False: 348]
  ------------------
  511|  4.02k|        return idx;
  512|  4.02k|    } else {
  513|    348|        int32_t candidate = -idx - 1;
  514|    348|        if (candidate < arr->cardinality) return candidate;
  ------------------
  |  Branch (514:13): [True: 348, False: 0]
  ------------------
  515|      0|        return -1;
  516|    348|    }
  517|  4.37k|}
roaring.c:array_container_add_range_nvals:
  527|    582|                                                   int32_t nvals_greater) {
  528|    582|    int32_t union_cardinality = nvals_less + (max - min + 1) + nvals_greater;
  529|    582|    if (union_cardinality > array->capacity) {
  ------------------
  |  Branch (529:9): [True: 541, False: 41]
  ------------------
  530|    541|        array_container_grow(array, union_cardinality, true);
  531|    541|    }
  532|    582|    memmove(&(array->array[union_cardinality - nvals_greater]),
  533|    582|            &(array->array[array->cardinality - nvals_greater]),
  534|    582|            nvals_greater * sizeof(uint16_t));
  535|  1.40M|    for (uint32_t i = 0; i <= max - min; i++) {
  ------------------
  |  Branch (535:26): [True: 1.40M, False: 582]
  ------------------
  536|  1.40M|        array->array[nvals_less + i] = (uint16_t)(min + i);
  537|  1.40M|    }
  538|    582|    array->cardinality = union_cardinality;
  539|    582|}
roaring.c:array_container_remove_range:
  557|  3.14k|                                                uint32_t pos, uint32_t count) {
  558|  3.14k|    if (count != 0) {
  ------------------
  |  Branch (558:9): [True: 283, False: 2.86k]
  ------------------
  559|    283|        memmove(&(array->array[pos]), &(array->array[pos + count]),
  560|    283|                (array->cardinality - pos - count) * sizeof(uint16_t));
  561|    283|        array->cardinality -= count;
  562|    283|    }
  563|  3.14k|}
roaring.c:array_container_cardinality:
   82|  69.4k|static inline int array_container_cardinality(const array_container_t *array) {
   83|  69.4k|    return array->cardinality;
   84|  69.4k|}
roaring.c:array_container_try_add:
  293|  7.12M|                                          int32_t max_cardinality) {
  294|  7.12M|    const int32_t cardinality = arr->cardinality;
  295|       |
  296|       |    // best case, we can append.
  297|  7.12M|    if ((array_container_empty(arr) || arr->array[cardinality - 1] < value) &&
  ------------------
  |  Branch (297:10): [True: 15.6k, False: 7.10M]
  |  Branch (297:40): [True: 50.3k, False: 7.05M]
  ------------------
  298|  65.9k|        cardinality < max_cardinality) {
  ------------------
  |  Branch (298:9): [True: 65.9k, False: 0]
  ------------------
  299|  65.9k|        array_container_append(arr, value);
  300|  65.9k|        return 1;
  301|  65.9k|    }
  302|       |
  303|  7.05M|    const int32_t loc = binarySearch(arr->array, cardinality, value);
  304|       |
  305|  7.05M|    if (loc >= 0) {
  ------------------
  |  Branch (305:9): [True: 5.36M, False: 1.69M]
  ------------------
  306|  5.36M|        return 0;
  307|  5.36M|    } else if (cardinality < max_cardinality) {
  ------------------
  |  Branch (307:16): [True: 1.69M, False: 120]
  ------------------
  308|  1.69M|        if (array_container_full(arr)) {
  ------------------
  |  Branch (308:13): [True: 75.1k, False: 1.61M]
  ------------------
  309|  75.1k|            array_container_grow(arr, arr->capacity + 1, true);
  310|  75.1k|        }
  311|  1.69M|        const int32_t insert_idx = -loc - 1;
  312|  1.69M|        memmove(arr->array + insert_idx + 1, arr->array + insert_idx,
  313|  1.69M|                (cardinality - insert_idx) * sizeof(uint16_t));
  314|  1.69M|        arr->array[insert_idx] = value;
  315|  1.69M|        arr->cardinality++;
  316|  1.69M|        return 1;
  317|  1.69M|    } else {
  318|    120|        return -1;
  319|    120|    }
  320|  7.05M|}
roaring.c:array_container_empty:
  100|  7.12M|static inline bool array_container_empty(const array_container_t *array) {
  101|  7.12M|    return array->cardinality == 0;
  102|  7.12M|}
roaring.c:array_container_append:
  274|  65.9k|                                          uint16_t pos) {
  275|  65.9k|    const int32_t capacity = arr->capacity;
  276|       |
  277|  65.9k|    if (array_container_full(arr)) {
  ------------------
  |  Branch (277:9): [True: 31.5k, False: 34.4k]
  ------------------
  278|  31.5k|        array_container_grow(arr, capacity + 1, true);
  279|  31.5k|    }
  280|       |
  281|  65.9k|    arr->array[arr->cardinality++] = pos;
  282|  65.9k|}
roaring.c:array_container_full:
  106|  1.75M|static inline bool array_container_full(const array_container_t *array) {
  107|  1.75M|    return array->cardinality == array->capacity;
  108|  1.75M|}
roaring.c:array_container_remove:
  329|  6.04k|                                          uint16_t pos) {
  330|  6.04k|    const int32_t idx = binarySearch(arr->array, arr->cardinality, pos);
  331|  6.04k|    const bool is_present = idx >= 0;
  332|  6.04k|    if (is_present) {
  ------------------
  |  Branch (332:9): [True: 3.03k, False: 3.01k]
  ------------------
  333|  3.03k|        memmove(arr->array + idx, arr->array + idx + 1,
  334|  3.03k|                (arr->cardinality - idx - 1) * sizeof(uint16_t));
  335|  3.03k|        arr->cardinality--;
  336|  3.03k|    }
  337|       |
  338|  6.04k|    return is_present;
  339|  6.04k|}
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.23k|                                          const array_container_t *container2) {
  231|  9.23k|    if (container1->cardinality != container2->cardinality) {
  ------------------
  |  Branch (231:9): [True: 2.27k, False: 6.96k]
  ------------------
  232|  2.27k|        return false;
  233|  2.27k|    }
  234|  6.96k|    return memequals(container1->array, container2->array,
  235|  6.96k|                     container1->cardinality * 2);
  236|  9.23k|}
roaring.c:array_container_select:
  252|  3.70k|                                          uint32_t *element) {
  253|  3.70k|    int card = array_container_cardinality(container);
  254|  3.70k|    if (*start_rank + card <= rank) {
  ------------------
  |  Branch (254:9): [True: 349, False: 3.35k]
  ------------------
  255|    349|        *start_rank += card;
  256|    349|        return false;
  257|  3.35k|    } else {
  258|  3.35k|        *element = container->array[rank - *start_rank];
  259|       |        return true;
  260|  3.35k|    }
  261|  3.70k|}
roaring.c:array_container_contains_range:
  421|     83|                                                  uint32_t range_end) {
  422|     83|    const int32_t range_count = range_end - range_start;
  423|     83|    const uint16_t rs_included = (uint16_t)range_start;
  424|     83|    const uint16_t re_included = (uint16_t)(range_end - 1);
  425|       |
  426|       |    // Empty range is always included
  427|     83|    if (range_count <= 0) {
  ------------------
  |  Branch (427:9): [True: 0, False: 83]
  ------------------
  428|      0|        return true;
  429|      0|    }
  430|     83|    if (range_count > arr->cardinality) {
  ------------------
  |  Branch (430:9): [True: 34, False: 49]
  ------------------
  431|     34|        return false;
  432|     34|    }
  433|       |
  434|     49|    const int32_t start =
  435|     49|        binarySearch(arr->array, arr->cardinality, rs_included);
  436|       |    // If this sorted array contains all items in the range:
  437|       |    // * the start item must be found
  438|       |    // * the last item in range range_count must exist, and be the expected end
  439|       |    // value
  440|     49|    return (start >= 0) && (arr->cardinality >= start + range_count) &&
  ------------------
  |  Branch (440:12): [True: 39, False: 10]
  |  Branch (440:28): [True: 35, False: 4]
  ------------------
  441|     35|           (arr->array[start + range_count - 1] == re_included);
  ------------------
  |  Branch (441:12): [True: 10, False: 25]
  ------------------
  442|     83|}
roaring_array.c:array_container_size_in_bytes:
  221|  17.3k|    const array_container_t *container) {
  222|  17.3k|    return container->cardinality * sizeof(uint16_t);
  223|  17.3k|}
roaring_array.c:array_container_cardinality:
   82|  6.82k|static inline int array_container_cardinality(const array_container_t *array) {
   83|  6.82k|    return array->cardinality;
   84|  6.82k|}
array.c:array_container_size_in_bytes:
  221|  13.6k|    const array_container_t *container) {
  222|  13.6k|    return container->cardinality * sizeof(uint16_t);
  223|  13.6k|}
convert.c:array_container_cardinality:
   82|  14.7k|static inline int array_container_cardinality(const array_container_t *array) {
   83|  14.7k|    return array->cardinality;
   84|  14.7k|}
convert.c:array_container_serialized_size_in_bytes:
  173|   142k|static inline int32_t array_container_serialized_size_in_bytes(int32_t card) {
  174|   142k|    return card * sizeof(uint16_t);
  175|   142k|}
mixed_intersection.c:array_container_empty:
  100|     24|static inline bool array_container_empty(const array_container_t *array) {
  101|     24|    return array->cardinality == 0;
  102|     24|}
mixed_andnot.c:array_container_cardinality:
   82|    368|static inline int array_container_cardinality(const array_container_t *array) {
   83|    368|    return array->cardinality;
   84|    368|}

bitset_container_get:
  197|  1.04M|                                 uint16_t pos) {
  198|  1.04M|    const uint64_t word = bitset->words[pos >> 6];
  199|  1.04M|    return (word >> (pos & 63)) & 1;
  200|  1.04M|}
bitset_container_contains:
  236|   905k|                                      uint16_t pos) {
  237|   905k|    return bitset_container_get(bitset, pos);
  238|   905k|}
roaring.c:bitset_container_cardinality:
  252|  10.4k|    const bitset_container_t *bitset) {
  253|  10.4k|    return bitset->cardinality;
  254|  10.4k|}
roaring.c:bitset_container_set:
  151|   303k|                                        uint16_t pos) {
  152|   303k|    const uint64_t old_word = bitset->words[pos >> 6];
  153|   303k|    const int index = pos & 63;
  154|       |    const uint64_t new_word = old_word | (UINT64_C(1) << index);
  155|   303k|    bitset->cardinality += (uint32_t)((old_word ^ new_word) >> index);
  156|   303k|    bitset->words[pos >> 6] = new_word;
  157|   303k|}
roaring.c:bitset_container_add:
  172|    120|                                        uint16_t pos) {
  173|    120|    const uint64_t old_word = bitset->words[pos >> 6];
  174|    120|    const int index = pos & 63;
  175|       |    const uint64_t new_word = old_word | (UINT64_C(1) << index);
  176|    120|    const uint64_t increment = (old_word ^ new_word) >> index;
  177|    120|    bitset->cardinality += (uint32_t)increment;
  178|    120|    bitset->words[pos >> 6] = new_word;
  179|    120|    return increment > 0;
  180|    120|}
roaring.c:bitset_container_remove:
  185|  2.15k|                                           uint16_t pos) {
  186|  2.15k|    const uint64_t old_word = bitset->words[pos >> 6];
  187|  2.15k|    const int index = pos & 63;
  188|       |    const uint64_t new_word = old_word & (~(UINT64_C(1) << index));
  189|  2.15k|    const uint64_t increment = (old_word ^ new_word) >> index;
  190|  2.15k|    bitset->cardinality -= (uint32_t)increment;
  191|  2.15k|    bitset->words[pos >> 6] = new_word;
  192|  2.15k|    return increment > 0;
  193|  2.15k|}
roaring.c:bitset_container_const_nonzero_cardinality:
  285|  6.54k|    const bitset_container_t *bitset) {
  286|  6.54k|    return !bitset_container_empty(bitset);
  287|  6.54k|}
roaring.c:bitset_container_empty:
  272|  6.54k|static inline bool bitset_container_empty(const bitset_container_t *bitset) {
  273|  6.54k|    if (bitset->cardinality == BITSET_UNKNOWN_CARDINALITY) {
  ------------------
  |  Branch (273:9): [True: 0, False: 6.54k]
  ------------------
  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.54k|    return bitset->cardinality == 0;
  280|  6.54k|}
roaring.c:bitset_container_get_range:
  210|    219|                                              uint32_t pos_end) {
  211|    219|    const uint32_t start = pos_start >> 6;
  212|    219|    const uint32_t end = pos_end >> 6;
  213|       |
  214|    219|    const uint64_t first = ~((1ULL << (pos_start & 0x3F)) - 1);
  215|    219|    const uint64_t last = (1ULL << (pos_end & 0x3F)) - 1;
  216|       |
  217|    219|    if (start == end)
  ------------------
  |  Branch (217:9): [True: 5, False: 214]
  ------------------
  218|      5|        return ((bitset->words[end] & first & last) == (first & last));
  219|    214|    if ((bitset->words[start] & first) != first) return false;
  ------------------
  |  Branch (219:9): [True: 79, False: 135]
  ------------------
  220|       |
  221|    135|    if ((end < BITSET_CONTAINER_SIZE_IN_WORDS) &&
  ------------------
  |  Branch (221:9): [True: 117, False: 18]
  ------------------
  222|    117|        ((bitset->words[end] & last) != last)) {
  ------------------
  |  Branch (222:9): [True: 95, False: 22]
  ------------------
  223|     95|        return false;
  224|     95|    }
  225|       |
  226|     40|    for (uint32_t i = start + 1;
  227|  15.7k|         (i < BITSET_CONTAINER_SIZE_IN_WORDS) && (i < end); ++i) {
  ------------------
  |  Branch (227:10): [True: 15.7k, False: 15]
  |  Branch (227:50): [True: 15.7k, False: 20]
  ------------------
  228|  15.7k|        if (bitset->words[i] != UINT64_C(0xFFFFFFFFFFFFFFFF)) return false;
  ------------------
  |  Branch (228:13): [True: 5, False: 15.7k]
  ------------------
  229|  15.7k|    }
  230|       |
  231|     35|    return true;
  232|     40|}
roaring_array.c:bitset_container_size_in_bytes:
  472|   133k|    const bitset_container_t *container) {
  473|   133k|    (void)container;
  474|   133k|    return BITSET_CONTAINER_SIZE_IN_WORDS * sizeof(uint64_t);
  475|   133k|}
roaring_array.c:bitset_container_cardinality:
  252|  66.9k|    const bitset_container_t *bitset) {
  253|  66.9k|    return bitset->cardinality;
  254|  66.9k|}
bitset.c:bitset_container_size_in_bytes:
  472|   133k|    const bitset_container_t *container) {
  473|   133k|    (void)container;
  474|   133k|    return BITSET_CONTAINER_SIZE_IN_WORDS * sizeof(uint64_t);
  475|   133k|}
convert.c:bitset_container_set:
  151|  2.28M|                                        uint16_t pos) {
  152|  2.28M|    const uint64_t old_word = bitset->words[pos >> 6];
  153|  2.28M|    const int index = pos & 63;
  154|       |    const uint64_t new_word = old_word | (UINT64_C(1) << index);
  155|  2.28M|    bitset->cardinality += (uint32_t)((old_word ^ new_word) >> index);
  156|  2.28M|    bitset->words[pos >> 6] = new_word;
  157|  2.28M|}
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|   329k|                                    uint16_t *value) {
 2458|   329k|    switch (typecode) {
 2459|      0|        case BITSET_CONTAINER_TYPE: {
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2459:9): [True: 0, False: 329k]
  ------------------
 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|   283k|        case ARRAY_CONTAINER_TYPE: {
  ------------------
  |  |   49|   283k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2483:9): [True: 283k, False: 45.3k]
  ------------------
 2484|   283k|            const array_container_t *ac = const_CAST_array(c);
  ------------------
  |  |   55|   283k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|   283k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2485|   283k|            it->index++;
 2486|   283k|            if (it->index < ac->cardinality) {
  ------------------
  |  Branch (2486:17): [True: 278k, False: 5.55k]
  ------------------
 2487|   278k|                *value = ac->array[it->index];
 2488|   278k|                return true;
 2489|   278k|            }
 2490|  5.55k|            return false;
 2491|   283k|        }
 2492|  45.3k|        case RUN_CONTAINER_TYPE: {
  ------------------
  |  |   50|  45.3k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2492:9): [True: 45.3k, False: 283k]
  ------------------
 2493|  45.3k|            if (*value == UINT16_MAX) {  // Avoid overflow to zero
  ------------------
  |  Branch (2493:17): [True: 0, False: 45.3k]
  ------------------
 2494|      0|                return false;
 2495|      0|            }
 2496|       |
 2497|  45.3k|            const run_container_t *rc = const_CAST_run(c);
  ------------------
  |  |   78|  45.3k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  45.3k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2498|  45.3k|            uint32_t limit =
 2499|  45.3k|                rc->runs[it->index].value + rc->runs[it->index].length;
 2500|  45.3k|            if (*value < limit) {
  ------------------
  |  Branch (2500:17): [True: 28.4k, False: 16.9k]
  ------------------
 2501|  28.4k|                (*value)++;
 2502|  28.4k|                return true;
 2503|  28.4k|            }
 2504|       |
 2505|  16.9k|            it->index++;
 2506|  16.9k|            if (it->index < rc->n_runs) {
  ------------------
  |  Branch (2506:17): [True: 16.4k, False: 489]
  ------------------
 2507|  16.4k|                *value = rc->runs[it->index].value;
 2508|  16.4k|                return true;
 2509|  16.4k|            }
 2510|    489|            return false;
 2511|  16.9k|        }
 2512|      0|        default:
  ------------------
  |  Branch (2512:9): [True: 0, False: 329k]
  ------------------
 2513|      0|            assert(false);
 2514|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2515|      0|            return false;
 2516|   329k|    }
 2517|   329k|}
roaring.c:container_from_range:
  317|  68.2k|                                                uint32_t max, uint16_t step) {
  318|  68.2k|    if (step == 0) return NULL;  // being paranoid
  ------------------
  |  Branch (318:9): [True: 0, False: 68.2k]
  ------------------
  319|  68.2k|    if (step == 1) {
  ------------------
  |  Branch (319:9): [True: 68.2k, False: 0]
  ------------------
  320|  68.2k|        return container_range_of_ones(min, max, type);
  321|       |        // Note: the result is not always a run (need to check the cardinality)
  322|       |        //*type = RUN_CONTAINER_TYPE;
  323|       |        // return run_container_create_range(min, max);
  324|  68.2k|    }
  325|      0|    int size = (max - min + step - 1) / step;
  326|      0|    if (size <= DEFAULT_MAX_SIZE) {  // array container
  ------------------
  |  Branch (326:9): [True: 0, False: 0]
  ------------------
  327|      0|        *type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  328|      0|        array_container_t *array = array_container_create_given_capacity(size);
  329|      0|        array_container_add_from_range(array, min, max, step);
  330|      0|        assert(array->cardinality == size);
  331|      0|        return array;
  332|      0|    } else {  // bitset container
  333|      0|        *type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  334|      0|        bitset_container_t *bitset = bitset_container_create();
  335|      0|        bitset_container_add_from_range(bitset, min, max, step);
  336|       |        assert(bitset->cardinality == size);
  337|      0|        return bitset;
  338|      0|    }
  339|      0|}
roaring.c:container_range_of_ones:
  302|  85.1k|                                                   uint8_t *result_type) {
  303|  85.1k|    assert(range_end >= range_start);
  304|  85.1k|    uint64_t cardinality = range_end - range_start + 1;
  305|  85.1k|    if (cardinality <= 2) {
  ------------------
  |  Branch (305:9): [True: 126, False: 85.0k]
  ------------------
  306|    126|        *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    126|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  307|    126|        return array_container_create_range(range_start, range_end);
  308|  85.0k|    } else {
  309|  85.0k|        *result_type = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|  85.0k|#define RUN_CONTAINER_TYPE 3
  ------------------
  310|  85.0k|        return run_container_create_range(range_start, range_end);
  311|  85.0k|    }
  312|  85.1k|}
roaring.c:container_add_range:
 2282|  3.16k|                                               uint8_t *result_type) {
 2283|       |    // NB: when selecting new container type, we perform only inexpensive checks
 2284|  3.16k|    switch (type) {
 2285|      0|        case BITSET_CONTAINER_TYPE: {
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2285:9): [True: 0, False: 3.16k]
  ------------------
 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.68k|        case ARRAY_CONTAINER_TYPE: {
  ------------------
  |  |   49|  2.68k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2304:9): [True: 2.68k, False: 476]
  ------------------
 2305|  2.68k|            array_container_t *array = CAST_array(c);
  ------------------
  |  |   54|  2.68k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  2.68k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2306|       |
 2307|  2.68k|            int32_t nvals_greater =
 2308|  2.68k|                count_greater(array->array, array->cardinality, (uint16_t)max);
 2309|  2.68k|            int32_t nvals_less =
 2310|  2.68k|                count_less(array->array, array->cardinality - nvals_greater,
 2311|  2.68k|                           (uint16_t)min);
 2312|  2.68k|            int32_t union_cardinality =
 2313|  2.68k|                nvals_less + (max - min + 1) + nvals_greater;
 2314|       |
 2315|  2.68k|            if (union_cardinality == INT32_C(0x10000)) {
  ------------------
  |  Branch (2315:17): [True: 664, False: 2.02k]
  ------------------
 2316|    664|                *result_type = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|    664|#define RUN_CONTAINER_TYPE 3
  ------------------
 2317|    664|                return run_container_create_range(0, INT32_C(0x10000));
 2318|  2.02k|            } else if (union_cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (2318:24): [True: 582, False: 1.44k]
  ------------------
 2319|    582|                *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    582|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 2320|    582|                array_container_add_range_nvals(array, min, max, nvals_less,
 2321|    582|                                                nvals_greater);
 2322|    582|                return array;
 2323|  1.44k|            } else {
 2324|  1.44k|                *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|  1.44k|#define BITSET_CONTAINER_TYPE 1
  ------------------
 2325|  1.44k|                bitset_container_t *bitset = bitset_container_from_array(array);
 2326|  1.44k|                bitset_set_lenrange(bitset->words, min, max - min);
 2327|  1.44k|                bitset->cardinality = union_cardinality;
 2328|  1.44k|                return bitset;
 2329|  1.44k|            }
 2330|  2.68k|        }
 2331|    476|        case RUN_CONTAINER_TYPE: {
  ------------------
  |  |   50|    476|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2331:9): [True: 476, False: 2.68k]
  ------------------
 2332|    476|            run_container_t *run = CAST_run(c);
  ------------------
  |  |   77|    476|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    476|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2333|       |
 2334|    476|            int32_t nruns_greater =
 2335|    476|                rle16_count_greater(run->runs, run->n_runs, (uint16_t)max);
 2336|    476|            int32_t nruns_less = rle16_count_less(
 2337|    476|                run->runs, run->n_runs - nruns_greater, (uint16_t)min);
 2338|       |
 2339|    476|            int32_t run_size_bytes =
 2340|    476|                (nruns_less + 1 + nruns_greater) * sizeof(rle16_t);
 2341|    476|            int32_t bitset_size_bytes =
 2342|    476|                BITSET_CONTAINER_SIZE_IN_WORDS * sizeof(uint64_t);
 2343|       |
 2344|    476|            if (run_size_bytes <= bitset_size_bytes) {
  ------------------
  |  Branch (2344:17): [True: 476, False: 0]
  ------------------
 2345|    476|                run_container_add_range_nruns(run, min, max, nruns_less,
 2346|    476|                                              nruns_greater);
 2347|    476|                *result_type = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|    476|#define RUN_CONTAINER_TYPE 3
  ------------------
 2348|    476|                return run;
 2349|    476|            } else {
 2350|      0|                return container_from_run_range(run, min, max, result_type);
 2351|      0|            }
 2352|    476|        }
 2353|      0|        default:
  ------------------
  |  Branch (2353:9): [True: 0, False: 3.16k]
  ------------------
 2354|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2355|  3.16k|    }
 2356|  3.16k|}
roaring.c:container_remove_range:
 2371|  20.4k|                                                  uint8_t *result_type) {
 2372|  20.4k|    switch (type) {
 2373|  1.16k|        case BITSET_CONTAINER_TYPE: {
  ------------------
  |  |   48|  1.16k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2373:9): [True: 1.16k, False: 19.2k]
  ------------------
 2374|  1.16k|            bitset_container_t *bitset = CAST_bitset(c);
  ------------------
  |  |   52|  1.16k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.16k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2375|       |
 2376|  1.16k|            int32_t result_cardinality =
 2377|  1.16k|                bitset->cardinality -
 2378|  1.16k|                bitset_lenrange_cardinality(bitset->words, min, max - min);
 2379|       |
 2380|  1.16k|            if (result_cardinality == 0) {
  ------------------
  |  Branch (2380:17): [True: 31, False: 1.13k]
  ------------------
 2381|     31|                return NULL;
 2382|  1.13k|            } else if (result_cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (2382:24): [True: 109, False: 1.02k]
  ------------------
 2383|    109|                *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    109|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 2384|    109|                bitset_reset_range(bitset->words, min, max + 1);
 2385|    109|                bitset->cardinality = result_cardinality;
 2386|    109|                return array_container_from_bitset(bitset);
 2387|  1.02k|            } else {
 2388|  1.02k|                *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|  1.02k|#define BITSET_CONTAINER_TYPE 1
  ------------------
 2389|  1.02k|                bitset_reset_range(bitset->words, min, max + 1);
 2390|  1.02k|                bitset->cardinality = result_cardinality;
 2391|  1.02k|                return bitset;
 2392|  1.02k|            }
 2393|  1.16k|        }
 2394|  3.50k|        case ARRAY_CONTAINER_TYPE: {
  ------------------
  |  |   49|  3.50k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2394:9): [True: 3.50k, False: 16.9k]
  ------------------
 2395|  3.50k|            array_container_t *array = CAST_array(c);
  ------------------
  |  |   54|  3.50k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  3.50k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2396|       |
 2397|  3.50k|            int32_t nvals_greater =
 2398|  3.50k|                count_greater(array->array, array->cardinality, (uint16_t)max);
 2399|  3.50k|            int32_t nvals_less =
 2400|  3.50k|                count_less(array->array, array->cardinality - nvals_greater,
 2401|  3.50k|                           (uint16_t)min);
 2402|  3.50k|            int32_t result_cardinality = nvals_less + nvals_greater;
 2403|       |
 2404|  3.50k|            if (result_cardinality == 0) {
  ------------------
  |  Branch (2404:17): [True: 363, False: 3.14k]
  ------------------
 2405|    363|                return NULL;
 2406|  3.14k|            } else {
 2407|  3.14k|                *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  3.14k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 2408|  3.14k|                array_container_remove_range(
 2409|  3.14k|                    array, nvals_less, array->cardinality - result_cardinality);
 2410|  3.14k|                return array;
 2411|  3.14k|            }
 2412|  3.50k|        }
 2413|  15.7k|        case RUN_CONTAINER_TYPE: {
  ------------------
  |  |   50|  15.7k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2413:9): [True: 15.7k, False: 4.67k]
  ------------------
 2414|  15.7k|            run_container_t *run = CAST_run(c);
  ------------------
  |  |   77|  15.7k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  15.7k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2415|       |
 2416|  15.7k|            if (run->n_runs == 0) {
  ------------------
  |  Branch (2416:17): [True: 0, False: 15.7k]
  ------------------
 2417|      0|                return NULL;
 2418|      0|            }
 2419|  15.7k|            if (min <= run_container_minimum(run) &&
  ------------------
  |  Branch (2419:17): [True: 15.3k, False: 396]
  ------------------
 2420|  15.3k|                max >= run_container_maximum(run)) {
  ------------------
  |  Branch (2420:17): [True: 13.9k, False: 1.43k]
  ------------------
 2421|  13.9k|                return NULL;
 2422|  13.9k|            }
 2423|       |
 2424|  1.83k|            run_container_remove_range(run, min, max);
 2425|  1.83k|            return convert_run_to_efficient_container(run, result_type);
 2426|  15.7k|        }
 2427|      0|        default:
  ------------------
  |  Branch (2427:9): [True: 0, False: 20.4k]
  ------------------
 2428|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2429|  20.4k|    }
 2430|  20.4k|}
roaring.c:container_get_cardinality:
  244|   368k|                                            uint8_t typecode) {
  245|   368k|    c = container_unwrap_shared(c, &typecode);
  246|   368k|    switch (typecode) {
  ------------------
  |  Branch (246:13): [True: 368k, False: 0]
  ------------------
  247|  9.13k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  9.13k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (247:9): [True: 9.13k, False: 359k]
  ------------------
  248|  9.13k|            return bitset_container_cardinality(const_CAST_bitset(c));
  ------------------
  |  |   53|  9.13k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  9.13k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  249|  62.0k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  62.0k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (249:9): [True: 62.0k, False: 306k]
  ------------------
  250|  62.0k|            return array_container_cardinality(const_CAST_array(c));
  ------------------
  |  |   55|  62.0k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  62.0k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  251|   297k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|   297k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (251:9): [True: 297k, False: 71.1k]
  ------------------
  252|   297k|            return run_container_cardinality(const_CAST_run(c));
  ------------------
  |  |   78|   297k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|   297k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  253|   368k|    }
  254|   368k|    assert(false);
  255|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  256|      0|    return 0;  // unreached
  257|   368k|}
roaring.c:get_container_type:
  129|  73.8k|static inline uint8_t get_container_type(const container_t *c, uint8_t type) {
  130|  73.8k|    if (type == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|  73.8k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (130:9): [True: 0, False: 73.8k]
  ------------------
  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|  73.8k|    } else {
  133|  73.8k|        return type;
  134|  73.8k|    }
  135|  73.8k|}
roaring.c:get_writable_copy_if_shared:
  146|  8.06M|                                                       uint8_t *type) {
  147|  8.06M|    if (*type == SHARED_CONTAINER_TYPE) {  // shared, return enclosed container
  ------------------
  |  |   51|  8.06M|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (147:9): [True: 0, False: 8.06M]
  ------------------
  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.06M|    } else {
  150|  8.06M|        return c;  // not shared, so return as-is
  151|  8.06M|    }
  152|  8.06M|}
roaring.c:container_add:
  492|  7.83M|    uint8_t *new_typecode) {
  493|  7.83M|    c = get_writable_copy_if_shared(c, &typecode);
  494|  7.83M|    switch (typecode) {
  495|   303k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|   303k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (495:9): [True: 303k, False: 7.53M]
  ------------------
  496|   303k|            bitset_container_set(CAST_bitset(c), val);
  ------------------
  |  |   52|   303k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|   303k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  497|   303k|            *new_typecode = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|   303k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  498|   303k|            return c;
  499|  7.12M|        case ARRAY_CONTAINER_TYPE: {
  ------------------
  |  |   49|  7.12M|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (499:9): [True: 7.12M, False: 715k]
  ------------------
  500|  7.12M|            array_container_t *ac = CAST_array(c);
  ------------------
  |  |   54|  7.12M|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  7.12M|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  501|  7.12M|            if (array_container_try_add(ac, val, DEFAULT_MAX_SIZE) != -1) {
  ------------------
  |  Branch (501:17): [True: 7.12M, False: 120]
  ------------------
  502|  7.12M|                *new_typecode = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  7.12M|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  503|  7.12M|                return ac;
  504|  7.12M|            } else {
  505|    120|                bitset_container_t *bitset = bitset_container_from_array(ac);
  506|    120|                bitset_container_add(bitset, val);
  507|    120|                *new_typecode = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|    120|#define BITSET_CONTAINER_TYPE 1
  ------------------
  508|    120|                return bitset;
  509|    120|            }
  510|  7.12M|        } break;
  511|   412k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|   412k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (511:9): [True: 412k, False: 7.42M]
  ------------------
  512|       |            // per Java, no container type adjustments are done (revisit?)
  513|   412k|            run_container_add(CAST_run(c), val);
  ------------------
  |  |   77|   412k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|   412k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  514|   412k|            *new_typecode = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|   412k|#define RUN_CONTAINER_TYPE 3
  ------------------
  515|   412k|            return c;
  516|      0|        default:
  ------------------
  |  Branch (516:9): [True: 0, False: 7.83M]
  ------------------
  517|      0|            assert(false);
  518|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  519|      0|            return NULL;
  520|  7.83M|    }
  521|  7.83M|}
roaring.c:container_remove:
  533|  11.3k|    uint8_t *new_typecode) {
  534|  11.3k|    c = get_writable_copy_if_shared(c, &typecode);
  535|  11.3k|    switch (typecode) {
  536|  2.15k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  2.15k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (536:9): [True: 2.15k, False: 9.19k]
  ------------------
  537|  2.15k|            if (bitset_container_remove(CAST_bitset(c), val)) {
  ------------------
  |  |   52|  2.15k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  2.15k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (537:17): [True: 1.31k, False: 841]
  ------------------
  538|  1.31k|                int card = bitset_container_cardinality(CAST_bitset(c));
  ------------------
  |  |   52|  1.31k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.31k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  539|  1.31k|                if (card <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (539:21): [True: 18, False: 1.30k]
  ------------------
  540|     18|                    *new_typecode = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|     18|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  541|     18|                    return array_container_from_bitset(CAST_bitset(c));
  ------------------
  |  |   52|     18|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     18|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  542|     18|                }
  543|  1.31k|            }
  544|  2.14k|            *new_typecode = typecode;
  545|  2.14k|            return c;
  546|  6.04k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  6.04k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (546:9): [True: 6.04k, False: 5.30k]
  ------------------
  547|  6.04k|            *new_typecode = typecode;
  548|  6.04k|            array_container_remove(CAST_array(c), val);
  ------------------
  |  |   54|  6.04k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  6.04k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  549|  6.04k|            return c;
  550|  3.14k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  3.14k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (550:9): [True: 3.14k, False: 8.20k]
  ------------------
  551|       |            // per Java, no container type adjustments are done (revisit?)
  552|  3.14k|            run_container_remove(CAST_run(c), val);
  ------------------
  |  |   77|  3.14k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  3.14k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  553|  3.14k|            *new_typecode = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|  3.14k|#define RUN_CONTAINER_TYPE 3
  ------------------
  554|  3.14k|            return c;
  555|      0|        default:
  ------------------
  |  Branch (555:9): [True: 0, False: 11.3k]
  ------------------
  556|      0|            assert(false);
  557|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  558|      0|            return NULL;
  559|  11.3k|    }
  560|  11.3k|}
roaring.c:container_nonzero_cardinality:
  437|   168k|                                                 uint8_t typecode) {
  438|   168k|    c = container_unwrap_shared(c, &typecode);
  439|   168k|    switch (typecode) {
  ------------------
  |  Branch (439:13): [True: 168k, False: 0]
  ------------------
  440|  6.54k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  6.54k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (440:9): [True: 6.54k, False: 161k]
  ------------------
  441|  6.54k|            return bitset_container_const_nonzero_cardinality(
  442|  6.54k|                const_CAST_bitset(c));
  ------------------
  |  |   53|  6.54k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  6.54k|#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.1k]
  ------------------
  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.6k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  61.6k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (445:9): [True: 61.6k, False: 106k]
  ------------------
  446|  61.6k|            return run_container_nonzero_cardinality(const_CAST_run(c));
  ------------------
  |  |   78|  61.6k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  61.6k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  447|   168k|    }
  448|   168k|    assert(false);
  449|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  450|      0|    return 0;  // unreached
  451|   168k|}
roaring.c:container_and:
  728|  6.12k|                                         uint8_t *result_type) {
  729|  6.12k|    c1 = container_unwrap_shared(c1, &type1);
  730|  6.12k|    c2 = container_unwrap_shared(c2, &type2);
  731|  6.12k|    container_t *result = NULL;
  732|  6.12k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  6.12k|#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.12k]
  ------------------
  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.30k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  2.30k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.30k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.30k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (741:9): [True: 2.30k, False: 3.82k]
  ------------------
  742|  2.30k|            result = array_container_create();
  743|  2.30k|            array_container_intersection(
  744|  2.30k|                const_CAST_array(c1), const_CAST_array(c2), CAST_array(result));
  ------------------
  |  |   55|  2.30k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.30k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_array(c2), CAST_array(result));
  ------------------
  |  |   55|  2.30k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.30k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_array(c2), CAST_array(result));
  ------------------
  |  |   54|  2.30k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  2.30k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  745|  2.30k|            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
  ------------------
  |  |   49|  2.30k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  746|  2.30k|            return result;
  747|       |
  748|    690|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    690|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    690|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    690|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (748:9): [True: 690, False: 5.43k]
  ------------------
  749|    690|            result = run_container_create();
  750|    690|            run_container_intersection(const_CAST_run(c1), const_CAST_run(c2),
  ------------------
  |  |   78|    690|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    690|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          run_container_intersection(const_CAST_run(c1), const_CAST_run(c2),
  ------------------
  |  |   78|    690|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    690|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  751|    690|                                       CAST_run(result));
  ------------------
  |  |   77|    690|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    690|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  752|    690|            return convert_run_to_efficient_container_and_free(CAST_run(result),
  ------------------
  |  |   77|    690|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    690|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  753|    690|                                                               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.12k]
  ------------------
  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|    531|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|    531|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    531|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    531|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (763:9): [True: 531, False: 5.59k]
  ------------------
  764|    531|            result = array_container_create();
  765|    531|            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
  ------------------
  |  |   49|    531|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  766|    531|            array_bitset_container_intersection(const_CAST_array(c1),
  ------------------
  |  |   55|    531|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    531|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  767|    531|                                                const_CAST_bitset(c2),
  ------------------
  |  |   53|    531|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    531|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  768|    531|                                                CAST_array(result));
  ------------------
  |  |   54|    531|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    531|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  769|    531|            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.12k]
  ------------------
  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|    613|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|    613|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    613|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    613|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (779:9): [True: 613, False: 5.51k]
  ------------------
  780|    613|            *result_type =
  781|    613|                run_bitset_container_intersection(
  ------------------
  |  Branch (781:17): [True: 0, False: 613]
  ------------------
  782|    613|                    const_CAST_run(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   78|    613|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    613|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                  const_CAST_run(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|    613|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    613|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  783|    613|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  784|    613|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  1.22k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  785|    613|            return result;
  786|       |
  787|    783|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    783|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    783|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    783|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (787:9): [True: 783, False: 5.34k]
  ------------------
  788|    783|            result = array_container_create();
  789|    783|            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
  ------------------
  |  |   49|    783|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  790|    783|            array_run_container_intersection(
  791|    783|                const_CAST_array(c1), const_CAST_run(c2), CAST_array(result));
  ------------------
  |  |   55|    783|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    783|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_run(c2), CAST_array(result));
  ------------------
  |  |   78|    783|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    783|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_run(c2), CAST_array(result));
  ------------------
  |  |   54|    783|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    783|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  792|    783|            return result;
  793|       |
  794|  1.20k|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|  1.20k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  1.20k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  1.20k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (794:9): [True: 1.20k, False: 4.92k]
  ------------------
  795|  1.20k|            result = array_container_create();
  796|  1.20k|            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
  ------------------
  |  |   49|  1.20k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  797|  1.20k|            array_run_container_intersection(
  798|  1.20k|                const_CAST_array(c2), const_CAST_run(c1), CAST_array(result));
  ------------------
  |  |   55|  1.20k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.20k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c2), const_CAST_run(c1), CAST_array(result));
  ------------------
  |  |   78|  1.20k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.20k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c2), const_CAST_run(c1), CAST_array(result));
  ------------------
  |  |   54|  1.20k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.20k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  799|  1.20k|            return result;
  800|       |
  801|      0|        default:
  ------------------
  |  Branch (801:9): [True: 0, False: 6.12k]
  ------------------
  802|      0|            assert(false);
  803|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  804|      0|            return NULL;
  805|  6.12k|    }
  806|  6.12k|}
roaring.c:container_iand:
  923|  63.2k|                                          uint8_t *result_type) {
  924|  63.2k|    c1 = get_writable_copy_if_shared(c1, &type1);
  925|  63.2k|    c2 = container_unwrap_shared(c2, &type2);
  926|  63.2k|    container_t *result = NULL;
  927|  63.2k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  63.2k|#define PAIR_CONTAINER_TYPES(type1, type2) (4 * (type1) + (type2))
  ------------------
  928|  1.40k|        case CONTAINER_PAIR(BITSET, BITSET):
  ------------------
  |  |   65|  1.40k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  1.40k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  1.40k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (928:9): [True: 1.40k, False: 61.8k]
  ------------------
  929|  1.40k|            *result_type = bitset_bitset_container_intersection_inplace(
  ------------------
  |  Branch (929:28): [True: 1.40k, False: 0]
  ------------------
  930|  1.40k|                               CAST_bitset(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   52|  1.40k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.40k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_bitset(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|  1.40k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.40k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  931|  1.40k|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|  1.40k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  932|  1.40k|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  1.40k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  933|  1.40k|            return result;
  934|       |
  935|  4.57k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  4.57k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  4.57k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  4.57k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (935:9): [True: 4.57k, False: 58.7k]
  ------------------
  936|  4.57k|            array_container_intersection_inplace(CAST_array(c1),
  ------------------
  |  |   54|  4.57k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  4.57k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  937|  4.57k|                                                 const_CAST_array(c2));
  ------------------
  |  |   55|  4.57k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  4.57k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  938|  4.57k|            *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  4.57k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  939|  4.57k|            return c1;
  940|       |
  941|  56.0k|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|  56.0k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  56.0k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  56.0k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (941:9): [True: 56.0k, False: 7.22k]
  ------------------
  942|  56.0k|            result = run_container_create();
  943|  56.0k|            run_container_intersection(const_CAST_run(c1), const_CAST_run(c2),
  ------------------
  |  |   78|  56.0k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  56.0k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          run_container_intersection(const_CAST_run(c1), const_CAST_run(c2),
  ------------------
  |  |   78|  56.0k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  56.0k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  944|  56.0k|                                       CAST_run(result));
  ------------------
  |  |   77|  56.0k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  56.0k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  945|       |            // as of January 2016, Java code used non-in-place intersection for
  946|       |            // two runcontainers
  947|  56.0k|            return convert_run_to_efficient_container_and_free(CAST_run(result),
  ------------------
  |  |   77|  56.0k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  56.0k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  948|  56.0k|                                                               result_type);
  949|       |
  950|     54|        case CONTAINER_PAIR(BITSET, ARRAY):
  ------------------
  |  |   65|     54|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|     54|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|     54|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (950:9): [True: 54, False: 63.2k]
  ------------------
  951|       |            // c1 is a bitmap so no inplace possible
  952|     54|            result = array_container_create();
  953|     54|            array_bitset_container_intersection(const_CAST_array(c2),
  ------------------
  |  |   55|     54|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|     54|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  954|     54|                                                const_CAST_bitset(c1),
  ------------------
  |  |   53|     54|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|     54|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  955|     54|                                                CAST_array(result));
  ------------------
  |  |   54|     54|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     54|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  956|     54|            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
  ------------------
  |  |   49|     54|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  957|     54|            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.2k]
  ------------------
  960|      0|            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  961|      0|            array_bitset_container_intersection(
  962|      0|                const_CAST_array(c1), const_CAST_bitset(c2),
  ------------------
  |  |   55|      0|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_bitset(c2),
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  963|      0|                CAST_array(c1));  // result is allowed to be same as c1
  ------------------
  |  |   54|      0|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  964|      0|            return c1;
  965|       |
  966|      0|        case CONTAINER_PAIR(BITSET, RUN):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (966:9): [True: 0, False: 63.2k]
  ------------------
  967|       |            // will attempt in-place computation
  968|      0|            *result_type = run_bitset_container_intersection(
  ------------------
  |  Branch (968:28): [True: 0, False: 0]
  ------------------
  969|      0|                               const_CAST_run(c2), const_CAST_bitset(c1), &c1)
  ------------------
  |  |   78|      0|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             const_CAST_run(c2), const_CAST_bitset(c1), &c1)
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  970|      0|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  971|      0|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  972|      0|            return c1;
  973|       |
  974|      0|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (974:9): [True: 0, False: 63.2k]
  ------------------
  975|      0|            *result_type =
  976|      0|                run_bitset_container_intersection(
  ------------------
  |  Branch (976:17): [True: 0, False: 0]
  ------------------
  977|      0|                    const_CAST_run(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   78|      0|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                  const_CAST_run(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|      0|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  978|      0|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  979|      0|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  980|      0|            return result;
  981|       |
  982|    198|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    198|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    198|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    198|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (982:9): [True: 198, False: 63.0k]
  ------------------
  983|    198|            result = array_container_create();
  984|    198|            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
  ------------------
  |  |   49|    198|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  985|    198|            array_run_container_intersection(
  986|    198|                const_CAST_array(c1), const_CAST_run(c2), CAST_array(result));
  ------------------
  |  |   55|    198|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    198|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_run(c2), CAST_array(result));
  ------------------
  |  |   78|    198|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    198|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_run(c2), CAST_array(result));
  ------------------
  |  |   54|    198|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    198|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  987|    198|            return result;
  988|       |
  989|    999|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|    999|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    999|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    999|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (989:9): [True: 999, False: 62.2k]
  ------------------
  990|    999|            result = array_container_create();
  991|    999|            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
  ------------------
  |  |   49|    999|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  992|    999|            array_run_container_intersection(
  993|    999|                const_CAST_array(c2), const_CAST_run(c1), CAST_array(result));
  ------------------
  |  |   55|    999|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    999|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c2), const_CAST_run(c1), CAST_array(result));
  ------------------
  |  |   78|    999|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    999|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c2), const_CAST_run(c1), CAST_array(result));
  ------------------
  |  |   54|    999|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    999|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  994|    999|            return result;
  995|       |
  996|      0|        default:
  ------------------
  |  Branch (996:9): [True: 0, False: 63.2k]
  ------------------
  997|      0|            assert(false);
  998|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  999|      0|            return NULL;
 1000|  63.2k|    }
 1001|  63.2k|}
roaring.c:container_or:
 1010|  6.12k|                                        uint8_t *result_type) {
 1011|  6.12k|    c1 = container_unwrap_shared(c1, &type1);
 1012|  6.12k|    c2 = container_unwrap_shared(c2, &type2);
 1013|  6.12k|    container_t *result = NULL;
 1014|  6.12k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  6.12k|#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.12k]
  ------------------
 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.30k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  2.30k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.30k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.30k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1022:9): [True: 2.30k, False: 3.82k]
  ------------------
 1023|  2.30k|            *result_type =
 1024|  2.30k|                array_array_container_union(const_CAST_array(c1),
  ------------------
  |  |   55|  2.30k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.30k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1024:17): [True: 54, False: 2.25k]
  ------------------
 1025|  2.30k|                                            const_CAST_array(c2), &result)
  ------------------
  |  |   55|  2.30k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.30k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1026|  2.30k|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|     54|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1027|  2.30k|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  4.55k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1028|  2.30k|            return result;
 1029|       |
 1030|    690|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    690|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    690|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    690|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1030:9): [True: 690, False: 5.43k]
  ------------------
 1031|    690|            result = run_container_create();
 1032|    690|            run_container_union(const_CAST_run(c1), const_CAST_run(c2),
  ------------------
  |  |   78|    690|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    690|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          run_container_union(const_CAST_run(c1), const_CAST_run(c2),
  ------------------
  |  |   78|    690|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    690|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1033|    690|                                CAST_run(result));
  ------------------
  |  |   77|    690|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    690|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1034|    690|            *result_type = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|    690|#define RUN_CONTAINER_TYPE 3
  ------------------
 1035|       |            // todo: could be optimized since will never convert to array
 1036|    690|            result = convert_run_to_efficient_container_and_free(
 1037|    690|                CAST_run(result), result_type);
  ------------------
  |  |   77|    690|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    690|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1038|    690|            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.12k]
  ------------------
 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|    531|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|    531|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    531|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    531|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1048:9): [True: 531, False: 5.59k]
  ------------------
 1049|    531|            result = bitset_container_create();
 1050|    531|            array_bitset_container_union(const_CAST_array(c1),
  ------------------
  |  |   55|    531|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    531|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1051|    531|                                         const_CAST_bitset(c2),
  ------------------
  |  |   53|    531|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    531|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1052|    531|                                         CAST_bitset(result));
  ------------------
  |  |   52|    531|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    531|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1053|    531|            *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|    531|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1054|    531|            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.12k]
  ------------------
 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|    613|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|    613|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    613|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    613|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1069:9): [True: 613, False: 5.51k]
  ------------------
 1070|    613|            if (run_container_is_full(const_CAST_run(c1))) {
  ------------------
  |  |   78|    613|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    613|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1070:17): [True: 0, False: 613]
  ------------------
 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|    613|            result = bitset_container_create();
 1077|    613|            run_bitset_container_union(
 1078|    613|                const_CAST_run(c1), const_CAST_bitset(c2), CAST_bitset(result));
  ------------------
  |  |   78|    613|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    613|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c1), const_CAST_bitset(c2), CAST_bitset(result));
  ------------------
  |  |   53|    613|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    613|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c1), const_CAST_bitset(c2), CAST_bitset(result));
  ------------------
  |  |   52|    613|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    613|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1079|    613|            *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|    613|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1080|    613|            return result;
 1081|       |
 1082|    783|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    783|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    783|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    783|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1082:9): [True: 783, False: 5.34k]
  ------------------
 1083|    783|            result = run_container_create();
 1084|    783|            array_run_container_union(const_CAST_array(c1), const_CAST_run(c2),
  ------------------
  |  |   55|    783|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    783|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          array_run_container_union(const_CAST_array(c1), const_CAST_run(c2),
  ------------------
  |  |   78|    783|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    783|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1085|    783|                                      CAST_run(result));
  ------------------
  |  |   77|    783|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    783|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1086|    783|            result = convert_run_to_efficient_container_and_free(
 1087|    783|                CAST_run(result), result_type);
  ------------------
  |  |   77|    783|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    783|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1088|    783|            return result;
 1089|       |
 1090|  1.20k|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|  1.20k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  1.20k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  1.20k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1090:9): [True: 1.20k, False: 4.92k]
  ------------------
 1091|  1.20k|            result = run_container_create();
 1092|  1.20k|            array_run_container_union(const_CAST_array(c2), const_CAST_run(c1),
  ------------------
  |  |   55|  1.20k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.20k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          array_run_container_union(const_CAST_array(c2), const_CAST_run(c1),
  ------------------
  |  |   78|  1.20k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.20k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1093|  1.20k|                                      CAST_run(result));
  ------------------
  |  |   77|  1.20k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.20k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1094|  1.20k|            result = convert_run_to_efficient_container_and_free(
 1095|  1.20k|                CAST_run(result), result_type);
  ------------------
  |  |   77|  1.20k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.20k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1096|  1.20k|            return result;
 1097|       |
 1098|      0|        default:
  ------------------
  |  Branch (1098:9): [True: 0, False: 6.12k]
  ------------------
 1099|      0|            assert(false);
 1100|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1101|      0|            return NULL;  // unreached
 1102|  6.12k|    }
 1103|  6.12k|}
roaring.c:container_is_full:
  262|  7.00k|static inline bool container_is_full(const container_t *c, uint8_t typecode) {
  263|  7.00k|    c = container_unwrap_shared(c, &typecode);
  264|  7.00k|    switch (typecode) {
  ------------------
  |  Branch (264:13): [True: 7.00k, False: 0]
  ------------------
  265|      0|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (265:9): [True: 0, False: 7.00k]
  ------------------
  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.70k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  3.70k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (268:9): [True: 3.70k, False: 3.30k]
  ------------------
  269|  3.70k|            return array_container_cardinality(const_CAST_array(c)) ==
  ------------------
  |  |   55|  3.70k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.70k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  270|  3.70k|                   (1 << 16);
  271|  3.30k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  3.30k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (271:9): [True: 3.30k, False: 3.70k]
  ------------------
  272|  3.30k|            return run_container_is_full(const_CAST_run(c));
  ------------------
  |  |   78|  3.30k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.30k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  273|  7.00k|    }
  274|  7.00k|    assert(false);
  275|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  276|      0|    return 0;  // unreached
  277|  7.00k|}
roaring.c:container_ior:
 1228|  6.24k|                                         uint8_t *result_type) {
 1229|  6.24k|    c1 = get_writable_copy_if_shared(c1, &type1);
 1230|  6.24k|    c2 = container_unwrap_shared(c2, &type2);
 1231|  6.24k|    container_t *result = NULL;
 1232|  6.24k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  6.24k|#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.24k]
  ------------------
 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.47k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  2.47k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.47k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.47k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1246:9): [True: 2.47k, False: 3.76k]
  ------------------
 1247|  2.47k|            *result_type = array_array_container_inplace_union(
  ------------------
  |  Branch (1247:28): [True: 0, False: 2.47k]
  ------------------
 1248|  2.47k|                               CAST_array(c1), const_CAST_array(c2), &result)
  ------------------
  |  |   54|  2.47k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  2.47k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_array(c1), const_CAST_array(c2), &result)
  ------------------
  |  |   55|  2.47k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.47k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1249|  2.47k|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1250|  2.47k|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  4.95k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1251|  2.47k|            if ((result == NULL) && (*result_type == ARRAY_CONTAINER_TYPE)) {
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (1251:17): [True: 0, False: 2.47k]
  |  Branch (1251:37): [True: 0, False: 0]
  ------------------
 1252|      0|                return c1;  // the computation was done in-place!
 1253|      0|            }
 1254|  2.47k|            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.57k]
  ------------------
 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.24k]
  ------------------
 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|    585|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|    585|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    585|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    585|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1267:9): [True: 585, False: 5.66k]
  ------------------
 1268|       |            // c1 is an array, so no in-place possible
 1269|    585|            result = bitset_container_create();
 1270|    585|            *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|    585|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1271|    585|            array_bitset_container_union(const_CAST_array(c1),
  ------------------
  |  |   55|    585|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    585|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1272|    585|                                         const_CAST_bitset(c2),
  ------------------
  |  |   53|    585|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    585|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1273|    585|                                         CAST_bitset(result));
  ------------------
  |  |   52|    585|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    585|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1274|    585|            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.24k]
  ------------------
 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|    613|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|    613|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    613|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    613|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1289:9): [True: 613, False: 5.63k]
  ------------------
 1290|    613|            if (run_container_is_full(const_CAST_run(c1))) {
  ------------------
  |  |   78|    613|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    613|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1290:17): [True: 0, False: 613]
  ------------------
 1291|      0|                *result_type = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
 1292|      0|                return c1;
 1293|      0|            }
 1294|    613|            result = bitset_container_create();
 1295|    613|            run_bitset_container_union(
 1296|    613|                const_CAST_run(c1), const_CAST_bitset(c2), CAST_bitset(result));
  ------------------
  |  |   78|    613|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    613|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c1), const_CAST_bitset(c2), CAST_bitset(result));
  ------------------
  |  |   53|    613|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    613|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c1), const_CAST_bitset(c2), CAST_bitset(result));
  ------------------
  |  |   52|    613|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    613|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1297|    613|            *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|    613|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1298|    613|            return result;
 1299|       |
 1300|    636|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    636|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    636|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    636|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1300:9): [True: 636, False: 5.61k]
  ------------------
 1301|    636|            result = run_container_create();
 1302|    636|            array_run_container_union(const_CAST_array(c1), const_CAST_run(c2),
  ------------------
  |  |   55|    636|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    636|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          array_run_container_union(const_CAST_array(c1), const_CAST_run(c2),
  ------------------
  |  |   78|    636|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    636|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1303|    636|                                      CAST_run(result));
  ------------------
  |  |   77|    636|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    636|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1304|    636|            result = convert_run_to_efficient_container_and_free(
 1305|    636|                CAST_run(result), result_type);
  ------------------
  |  |   77|    636|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    636|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1306|    636|            return result;
 1307|       |
 1308|    259|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|    259|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    259|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    259|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1308:9): [True: 259, False: 5.98k]
  ------------------
 1309|    259|            array_run_container_inplace_union(const_CAST_array(c2),
  ------------------
  |  |   55|    259|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    259|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1310|    259|                                              CAST_run(c1));
  ------------------
  |  |   77|    259|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    259|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1311|    259|            c1 = convert_run_to_efficient_container(CAST_run(c1), result_type);
  ------------------
  |  |   77|    259|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    259|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1312|    259|            return c1;
 1313|       |
 1314|      0|        default:
  ------------------
  |  Branch (1314:9): [True: 0, False: 6.24k]
  ------------------
 1315|      0|            assert(false);
 1316|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1317|      0|            return NULL;
 1318|  6.24k|    }
 1319|  6.24k|}
roaring.c:container_xor:
 1451|  6.12k|                                         uint8_t *result_type) {
 1452|  6.12k|    c1 = container_unwrap_shared(c1, &type1);
 1453|  6.12k|    c2 = container_unwrap_shared(c2, &type2);
 1454|  6.12k|    container_t *result = NULL;
 1455|  6.12k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  6.12k|#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.12k]
  ------------------
 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.30k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  2.30k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.30k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.30k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1464:9): [True: 2.30k, False: 3.82k]
  ------------------
 1465|  2.30k|            *result_type =
 1466|  2.30k|                array_array_container_xor(const_CAST_array(c1),
  ------------------
  |  |   55|  2.30k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.30k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1466:17): [True: 12, False: 2.29k]
  ------------------
 1467|  2.30k|                                          const_CAST_array(c2), &result)
  ------------------
  |  |   55|  2.30k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.30k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1468|  2.30k|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|     12|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1469|  2.30k|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  4.59k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1470|  2.30k|            return result;
 1471|       |
 1472|    690|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    690|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    690|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    690|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1472:9): [True: 690, False: 5.43k]
  ------------------
 1473|    690|            *result_type = (uint8_t)run_run_container_xor(
 1474|    690|                const_CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|    690|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    690|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|    690|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    690|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1475|    690|            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.12k]
  ------------------
 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|    531|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|    531|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    531|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    531|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1485:9): [True: 531, False: 5.59k]
  ------------------
 1486|    531|            *result_type =
 1487|    531|                array_bitset_container_xor(const_CAST_array(c1),
  ------------------
  |  |   55|    531|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    531|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1487:17): [True: 483, False: 48]
  ------------------
 1488|    531|                                           const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|    531|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    531|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1489|    531|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|    483|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1490|    531|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    579|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1491|    531|            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.12k]
  ------------------
 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|    613|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|    613|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    613|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    613|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1501:9): [True: 613, False: 5.51k]
  ------------------
 1502|    613|            *result_type =
 1503|    613|                run_bitset_container_xor(const_CAST_run(c1),
  ------------------
  |  |   78|    613|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    613|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1503:17): [True: 564, False: 49]
  ------------------
 1504|    613|                                         const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|    613|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    613|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1505|    613|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|    564|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1506|    613|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    662|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1507|    613|            return result;
 1508|       |
 1509|    783|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    783|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    783|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    783|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1509:9): [True: 783, False: 5.34k]
  ------------------
 1510|    783|            *result_type = (uint8_t)array_run_container_xor(
 1511|    783|                const_CAST_array(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   55|    783|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    783|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|    783|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    783|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1512|    783|            return result;
 1513|       |
 1514|  1.20k|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|  1.20k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  1.20k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  1.20k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1514:9): [True: 1.20k, False: 4.92k]
  ------------------
 1515|  1.20k|            *result_type = (uint8_t)array_run_container_xor(
 1516|  1.20k|                const_CAST_array(c2), const_CAST_run(c1), &result);
  ------------------
  |  |   55|  1.20k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.20k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c2), const_CAST_run(c1), &result);
  ------------------
  |  |   78|  1.20k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.20k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1517|  1.20k|            return result;
 1518|       |
 1519|      0|        default:
  ------------------
  |  Branch (1519:9): [True: 0, False: 6.12k]
  ------------------
 1520|      0|            assert(false);
 1521|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1522|      0|            return NULL;  // unreached
 1523|  6.12k|    }
 1524|  6.12k|}
roaring.c:container_ixor:
 1667|  61.7k|                                          uint8_t *result_type) {
 1668|  61.7k|    c1 = get_writable_copy_if_shared(c1, &type1);
 1669|  61.7k|    c2 = container_unwrap_shared(c2, &type2);
 1670|  61.7k|    container_t *result = NULL;
 1671|  61.7k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  61.7k|#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.3k]
  ------------------
 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.91k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1677|  1.45k|            return result;
 1678|       |
 1679|  4.78k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  4.78k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  4.78k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  4.78k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1679:9): [True: 4.78k, False: 57.0k]
  ------------------
 1680|  4.78k|            *result_type = array_array_container_ixor(
  ------------------
  |  Branch (1680:28): [True: 0, False: 4.78k]
  ------------------
 1681|  4.78k|                               CAST_array(c1), const_CAST_array(c2), &result)
  ------------------
  |  |   54|  4.78k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  4.78k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_array(c1), const_CAST_array(c2), &result)
  ------------------
  |  |   55|  4.78k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  4.78k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1682|  4.78k|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1683|  4.78k|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  9.56k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1684|  4.78k|            return result;
 1685|       |
 1686|  55.0k|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|  55.0k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  55.0k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  55.0k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1686:9): [True: 55.0k, False: 6.73k]
  ------------------
 1687|  55.0k|            *result_type = (uint8_t)run_run_container_ixor(
 1688|  55.0k|                CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   77|  55.0k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  55.0k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|  55.0k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  55.0k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1689|  55.0k|            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: 61.7k]
  ------------------
 1692|      0|            *result_type = bitset_array_container_ixor(
  ------------------
  |  Branch (1692:28): [True: 0, False: 0]
  ------------------
 1693|      0|                               CAST_bitset(c1), const_CAST_array(c2), &result)
  ------------------
  |  |   52|      0|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_bitset(c1), const_CAST_array(c2), &result)
  ------------------
  |  |   55|      0|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1694|      0|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1695|      0|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1696|      0|            return result;
 1697|       |
 1698|     88|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|     88|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|     88|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|     88|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1698:9): [True: 88, False: 61.7k]
  ------------------
 1699|     88|            *result_type = array_bitset_container_ixor(
  ------------------
  |  Branch (1699:28): [True: 0, False: 88]
  ------------------
 1700|     88|                               CAST_array(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   54|     88|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     88|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_array(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|     88|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|     88|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1701|     88|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1702|     88|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    176|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1703|     88|            return result;
 1704|       |
 1705|     63|        case CONTAINER_PAIR(BITSET, RUN):
  ------------------
  |  |   65|     63|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|     63|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|     63|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1705:9): [True: 63, False: 61.7k]
  ------------------
 1706|     63|            *result_type = bitset_run_container_ixor(
  ------------------
  |  Branch (1706:28): [True: 0, False: 63]
  ------------------
 1707|     63|                               CAST_bitset(c1), const_CAST_run(c2), &result)
  ------------------
  |  |   52|     63|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     63|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_bitset(c1), const_CAST_run(c2), &result)
  ------------------
  |  |   78|     63|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|     63|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1708|     63|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1709|     63|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    126|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1710|       |
 1711|     63|            return result;
 1712|       |
 1713|     22|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|     22|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|     22|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|     22|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1713:9): [True: 22, False: 61.7k]
  ------------------
 1714|     22|            *result_type = run_bitset_container_ixor(
  ------------------
  |  Branch (1714:28): [True: 0, False: 22]
  ------------------
 1715|     22|                               CAST_run(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   77|     22|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     22|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_run(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|     22|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|     22|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1716|     22|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1717|     22|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|     44|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1718|     22|            return result;
 1719|       |
 1720|    262|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    262|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    262|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    262|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1720:9): [True: 262, False: 61.5k]
  ------------------
 1721|    262|            *result_type = (uint8_t)array_run_container_ixor(
 1722|    262|                CAST_array(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   54|    262|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    262|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              CAST_array(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|    262|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    262|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1723|    262|            return result;
 1724|       |
 1725|     58|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|     58|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|     58|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|     58|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1725:9): [True: 58, False: 61.7k]
  ------------------
 1726|     58|            *result_type = (uint8_t)run_array_container_ixor(
 1727|     58|                CAST_run(c1), const_CAST_array(c2), &result);
  ------------------
  |  |   77|     58|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     58|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              CAST_run(c1), const_CAST_array(c2), &result);
  ------------------
  |  |   55|     58|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|     58|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1728|     58|            return result;
 1729|       |
 1730|      0|        default:
  ------------------
  |  Branch (1730:9): [True: 0, False: 61.7k]
  ------------------
 1731|      0|            assert(false);
 1732|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1733|      0|            return NULL;
 1734|  61.7k|    }
 1735|  61.7k|}
roaring.c:container_andnot:
 1787|  6.12k|                                            uint8_t *result_type) {
 1788|  6.12k|    c1 = container_unwrap_shared(c1, &type1);
 1789|  6.12k|    c2 = container_unwrap_shared(c2, &type2);
 1790|  6.12k|    container_t *result = NULL;
 1791|  6.12k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  6.12k|#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.12k]
  ------------------
 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.30k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  2.30k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.30k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.30k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1800:9): [True: 2.30k, False: 3.82k]
  ------------------
 1801|  2.30k|            result = array_container_create();
 1802|  2.30k|            array_array_container_andnot(
 1803|  2.30k|                const_CAST_array(c1), const_CAST_array(c2), CAST_array(result));
  ------------------
  |  |   55|  2.30k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.30k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_array(c2), CAST_array(result));
  ------------------
  |  |   55|  2.30k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.30k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_array(c2), CAST_array(result));
  ------------------
  |  |   54|  2.30k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  2.30k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1804|  2.30k|            *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  2.30k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1805|  2.30k|            return result;
 1806|       |
 1807|    690|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    690|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    690|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    690|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1807:9): [True: 690, False: 5.43k]
  ------------------
 1808|    690|            if (run_container_is_full(const_CAST_run(c2))) {
  ------------------
  |  |   78|    690|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    690|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1808:17): [True: 14, False: 676]
  ------------------
 1809|     14|                result = array_container_create();
 1810|     14|                *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|     14|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1811|     14|                return result;
 1812|     14|            }
 1813|    676|            *result_type = (uint8_t)run_run_container_andnot(
 1814|    676|                const_CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|    676|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    676|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|    676|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    676|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1815|    676|            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.12k]
  ------------------
 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|    531|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|    531|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    531|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    531|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1825:9): [True: 531, False: 5.59k]
  ------------------
 1826|    531|            result = array_container_create();
 1827|    531|            array_bitset_container_andnot(const_CAST_array(c1),
  ------------------
  |  |   55|    531|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    531|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1828|    531|                                          const_CAST_bitset(c2),
  ------------------
  |  |   53|    531|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    531|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1829|    531|                                          CAST_array(result));
  ------------------
  |  |   54|    531|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    531|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1830|    531|            *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    531|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1831|    531|            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.12k]
  ------------------
 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|    613|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|    613|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    613|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    613|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1846:9): [True: 613, False: 5.51k]
  ------------------
 1847|    613|            *result_type =
 1848|    613|                run_bitset_container_andnot(const_CAST_run(c1),
  ------------------
  |  |   78|    613|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    613|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1848:17): [True: 0, False: 613]
  ------------------
 1849|    613|                                            const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|    613|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    613|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1850|    613|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1851|    613|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  1.22k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1852|    613|            return result;
 1853|       |
 1854|    783|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    783|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    783|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    783|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1854:9): [True: 783, False: 5.34k]
  ------------------
 1855|    783|            if (run_container_is_full(const_CAST_run(c2))) {
  ------------------
  |  |   78|    783|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    783|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1855:17): [True: 24, False: 759]
  ------------------
 1856|     24|                result = array_container_create();
 1857|     24|                *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|     24|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1858|     24|                return result;
 1859|     24|            }
 1860|    759|            result = array_container_create();
 1861|    759|            array_run_container_andnot(const_CAST_array(c1), const_CAST_run(c2),
  ------------------
  |  |   55|    759|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    759|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          array_run_container_andnot(const_CAST_array(c1), const_CAST_run(c2),
  ------------------
  |  |   78|    759|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    759|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1862|    759|                                       CAST_array(result));
  ------------------
  |  |   54|    759|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    759|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1863|    759|            *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    759|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1864|    759|            return result;
 1865|       |
 1866|  1.20k|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|  1.20k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  1.20k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  1.20k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1866:9): [True: 1.20k, False: 4.92k]
  ------------------
 1867|  1.20k|            *result_type = (uint8_t)run_array_container_andnot(
 1868|  1.20k|                const_CAST_run(c1), const_CAST_array(c2), &result);
  ------------------
  |  |   78|  1.20k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.20k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c1), const_CAST_array(c2), &result);
  ------------------
  |  |   55|  1.20k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.20k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1869|  1.20k|            return result;
 1870|       |
 1871|      0|        default:
  ------------------
  |  Branch (1871:9): [True: 0, False: 6.12k]
  ------------------
 1872|      0|            assert(false);
 1873|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1874|      0|            return NULL;  // unreached
 1875|  6.12k|    }
 1876|  6.12k|}
roaring.c:container_iandnot:
 1891|  5.81k|                                             uint8_t *result_type) {
 1892|  5.81k|    c1 = get_writable_copy_if_shared(c1, &type1);
 1893|  5.81k|    c2 = container_unwrap_shared(c2, &type2);
 1894|  5.81k|    container_t *result = NULL;
 1895|  5.81k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  5.81k|#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.81k]
  ------------------
 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.44k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  3.44k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  3.44k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  3.44k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1903:9): [True: 3.44k, False: 2.36k]
  ------------------
 1904|  3.44k|            array_array_container_iandnot(CAST_array(c1), const_CAST_array(c2));
  ------------------
  |  |   54|  3.44k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  3.44k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          array_array_container_iandnot(CAST_array(c1), const_CAST_array(c2));
  ------------------
  |  |   55|  3.44k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.44k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1905|  3.44k|            *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  3.44k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1906|  3.44k|            return c1;
 1907|       |
 1908|    463|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    463|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    463|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    463|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1908:9): [True: 463, False: 5.34k]
  ------------------
 1909|    463|            *result_type = (uint8_t)run_run_container_iandnot(
 1910|    463|                CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   77|    463|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    463|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|    463|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    463|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1911|    463|            return result;
 1912|       |
 1913|  1.11k|        case CONTAINER_PAIR(BITSET, ARRAY):
  ------------------
  |  |   65|  1.11k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  1.11k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  1.11k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1913:9): [True: 1.11k, False: 4.69k]
  ------------------
 1914|  1.11k|            *result_type = bitset_array_container_iandnot(
  ------------------
  |  Branch (1914:28): [True: 947, False: 167]
  ------------------
 1915|  1.11k|                               CAST_bitset(c1), const_CAST_array(c2), &result)
  ------------------
  |  |   52|  1.11k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.11k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_bitset(c1), const_CAST_array(c2), &result)
  ------------------
  |  |   55|  1.11k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.11k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1916|  1.11k|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|    947|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1917|  1.11k|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  1.28k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1918|  1.11k|            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.81k]
  ------------------
 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.81k]
  ------------------
 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.81k]
  ------------------
 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|     50|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|     50|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|     50|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|     50|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1940:9): [True: 50, False: 5.76k]
  ------------------
 1941|     50|            *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|     50|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1942|     50|            array_run_container_iandnot(CAST_array(c1), const_CAST_run(c2));
  ------------------
  |  |   54|     50|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     50|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          array_run_container_iandnot(CAST_array(c1), const_CAST_run(c2));
  ------------------
  |  |   78|     50|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|     50|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1943|     50|            return c1;
 1944|       |
 1945|    742|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|    742|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    742|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    742|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1945:9): [True: 742, False: 5.07k]
  ------------------
 1946|    742|            *result_type = (uint8_t)run_array_container_iandnot(
 1947|    742|                CAST_run(c1), const_CAST_array(c2), &result);
  ------------------
  |  |   77|    742|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    742|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              CAST_run(c1), const_CAST_array(c2), &result);
  ------------------
  |  |   55|    742|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    742|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1948|    742|            return result;
 1949|       |
 1950|      0|        default:
  ------------------
  |  Branch (1950:9): [True: 0, False: 5.81k]
  ------------------
 1951|      0|            assert(false);
 1952|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1953|      0|            return NULL;
 1954|  5.81k|    }
 1955|  5.81k|}
roaring.c:container_rank:
 2209|  6.24k|                                 uint16_t x) {
 2210|  6.24k|    c = container_unwrap_shared(c, &type);
 2211|  6.24k|    switch (type) {
 2212|      0|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2212:9): [True: 0, False: 6.24k]
  ------------------
 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.70k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  3.70k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2214:9): [True: 3.70k, False: 2.54k]
  ------------------
 2215|  3.70k|            return array_container_rank(const_CAST_array(c), x);
  ------------------
  |  |   55|  3.70k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.70k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2216|  2.54k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  2.54k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2216:9): [True: 2.54k, False: 3.70k]
  ------------------
 2217|  2.54k|            return run_container_rank(const_CAST_run(c), x);
  ------------------
  |  |   78|  2.54k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.54k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2218|      0|        default:
  ------------------
  |  Branch (2218:9): [True: 0, False: 6.24k]
  ------------------
 2219|      0|            assert(false);
 2220|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2221|  6.24k|    }
 2222|  6.24k|    assert(false);
 2223|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2224|      0|    return false;
 2225|  6.24k|}
roaring.c:container_shrink_to_fit:
  279|  6.24k|static inline int container_shrink_to_fit(container_t *c, uint8_t type) {
  280|  6.24k|    c = container_mutable_unwrap_shared(c, &type);
  281|  6.24k|    switch (type) {
  ------------------
  |  Branch (281:13): [True: 6.24k, False: 0]
  ------------------
  282|      0|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (282:9): [True: 0, False: 6.24k]
  ------------------
  283|      0|            return 0;  // no shrinking possible
  284|  3.70k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  3.70k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (284:9): [True: 3.70k, False: 2.54k]
  ------------------
  285|  3.70k|            return array_container_shrink_to_fit(CAST_array(c));
  ------------------
  |  |   54|  3.70k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  3.70k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  286|  2.54k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  2.54k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (286:9): [True: 2.54k, False: 3.70k]
  ------------------
  287|  2.54k|            return run_container_shrink_to_fit(CAST_run(c));
  ------------------
  |  |   77|  2.54k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  2.54k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  288|  6.24k|    }
  289|  6.24k|    assert(false);
  290|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  291|      0|    return 0;  // unreached
  292|  6.24k|}
roaring.c:container_iterate:
 1964|  63.3k|                                     void *ptr) {
 1965|  63.3k|    c = container_unwrap_shared(c, &type);
 1966|  63.3k|    switch (type) {
 1967|  1.56k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  1.56k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (1967:9): [True: 1.56k, False: 61.8k]
  ------------------
 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.22k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  6.22k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (1970:9): [True: 6.22k, False: 57.1k]
  ------------------
 1971|  6.22k|            return array_container_iterate(const_CAST_array(c), base, iterator,
  ------------------
  |  |   55|  6.22k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  6.22k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1972|  6.22k|                                           ptr);
 1973|  55.6k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  55.6k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (1973:9): [True: 55.6k, False: 7.79k]
  ------------------
 1974|  55.6k|            return run_container_iterate(const_CAST_run(c), base, iterator,
  ------------------
  |  |   78|  55.6k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  55.6k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1975|  55.6k|                                         ptr);
 1976|      0|        default:
  ------------------
  |  Branch (1976:9): [True: 0, False: 63.3k]
  ------------------
 1977|      0|            assert(false);
 1978|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1979|  63.3k|    }
 1980|  63.3k|    assert(false);
 1981|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1982|      0|    return false;
 1983|  63.3k|}
roaring.c:container_maximum:
 2171|  12.3k|static inline uint16_t container_maximum(const container_t *c, uint8_t type) {
 2172|  12.3k|    c = container_unwrap_shared(c, &type);
 2173|  12.3k|    switch (type) {
 2174|  2.43k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  2.43k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2174:9): [True: 2.43k, False: 9.94k]
  ------------------
 2175|  2.43k|            return bitset_container_maximum(const_CAST_bitset(c));
  ------------------
  |  |   53|  2.43k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.43k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2176|  8.59k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  8.59k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2176:9): [True: 8.59k, False: 3.79k]
  ------------------
 2177|  8.59k|            return array_container_maximum(const_CAST_array(c));
  ------------------
  |  |   55|  8.59k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  8.59k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2178|  1.35k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  1.35k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2178:9): [True: 1.35k, False: 11.0k]
  ------------------
 2179|  1.35k|            return run_container_maximum(const_CAST_run(c));
  ------------------
  |  |   78|  1.35k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.35k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2180|      0|        default:
  ------------------
  |  Branch (2180:9): [True: 0, False: 12.3k]
  ------------------
 2181|      0|            assert(false);
 2182|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2183|  12.3k|    }
 2184|  12.3k|    assert(false);
 2185|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2186|      0|    return false;
 2187|  12.3k|}
roaring.c:container_equals:
  620|  77.7k|                                    const container_t *c2, uint8_t type2) {
  621|  77.7k|    c1 = container_unwrap_shared(c1, &type1);
  622|  77.7k|    c2 = container_unwrap_shared(c2, &type2);
  623|  77.7k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  77.7k|#define PAIR_CONTAINER_TYPES(type1, type2) (4 * (type1) + (type2))
  ------------------
  624|  66.9k|        case CONTAINER_PAIR(BITSET, BITSET):
  ------------------
  |  |   65|  66.9k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  66.9k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  66.9k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (624:9): [True: 66.9k, False: 10.7k]
  ------------------
  625|  66.9k|            return bitset_container_equals(const_CAST_bitset(c1),
  ------------------
  |  |   53|  66.9k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  66.9k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  626|  66.9k|                                           const_CAST_bitset(c2));
  ------------------
  |  |   53|  66.9k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  66.9k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  627|       |
  628|      0|        case CONTAINER_PAIR(BITSET, RUN):
  ------------------
  |  |   65|      0|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (628:9): [True: 0, False: 77.7k]
  ------------------
  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: 77.7k]
  ------------------
  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: 77.7k]
  ------------------
  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|    457|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|    457|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    457|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    457|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (641:9): [True: 457, False: 77.2k]
  ------------------
  642|       |            // java would always return false?
  643|    457|            return array_container_equal_bitset(const_CAST_array(c1),
  ------------------
  |  |   55|    457|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    457|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  644|    457|                                                const_CAST_bitset(c2));
  ------------------
  |  |   53|    457|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    457|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  645|       |
  646|    641|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    641|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    641|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    641|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (646:9): [True: 641, False: 77.0k]
  ------------------
  647|    641|            return run_container_equals_array(const_CAST_run(c2),
  ------------------
  |  |   78|    641|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    641|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  648|    641|                                              const_CAST_array(c1));
  ------------------
  |  |   55|    641|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    641|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  649|       |
  650|    256|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|    256|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    256|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    256|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (650:9): [True: 256, False: 77.4k]
  ------------------
  651|    256|            return run_container_equals_array(const_CAST_run(c1),
  ------------------
  |  |   78|    256|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    256|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  652|    256|                                              const_CAST_array(c2));
  ------------------
  |  |   55|    256|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    256|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  653|       |
  654|  9.23k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  9.23k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  9.23k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  9.23k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (654:9): [True: 9.23k, False: 68.4k]
  ------------------
  655|  9.23k|            return array_container_equals(const_CAST_array(c1),
  ------------------
  |  |   55|  9.23k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  9.23k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  656|  9.23k|                                          const_CAST_array(c2));
  ------------------
  |  |   55|  9.23k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  9.23k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  657|       |
  658|    133|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    133|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    133|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    133|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (658:9): [True: 133, False: 77.5k]
  ------------------
  659|    133|            return run_container_equals(const_CAST_run(c1), const_CAST_run(c2));
  ------------------
  |  |   78|    133|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    133|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          return run_container_equals(const_CAST_run(c1), const_CAST_run(c2));
  ------------------
  |  |   78|    133|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    133|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  660|       |
  661|      0|        default:
  ------------------
  |  Branch (661:9): [True: 0, False: 77.7k]
  ------------------
  662|      0|            assert(false);
  663|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  664|      0|            return false;
  665|  77.7k|    }
  666|  77.7k|}
roaring.c:container_is_subset:
  673|  10.7k|                                       const container_t *c2, uint8_t type2) {
  674|  10.7k|    c1 = container_unwrap_shared(c1, &type1);
  675|  10.7k|    c2 = container_unwrap_shared(c2, &type2);
  676|  10.7k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  10.7k|#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.7k]
  ------------------
  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.7k]
  ------------------
  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.7k]
  ------------------
  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.7k]
  ------------------
  690|      0|            return false;  // by construction, size(c1) > size(c2)
  691|       |
  692|  2.20k|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|  2.20k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.20k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  2.20k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (692:9): [True: 2.20k, False: 8.52k]
  ------------------
  693|  2.20k|            return array_container_is_subset_bitset(const_CAST_array(c1),
  ------------------
  |  |   55|  2.20k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.20k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  694|  2.20k|                                                    const_CAST_bitset(c2));
  ------------------
  |  |   53|  2.20k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.20k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  695|       |
  696|  2.27k|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|  2.27k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.27k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  2.27k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (696:9): [True: 2.27k, False: 8.44k]
  ------------------
  697|  2.27k|            return array_container_is_subset_run(const_CAST_array(c1),
  ------------------
  |  |   55|  2.27k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.27k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  698|  2.27k|                                                 const_CAST_run(c2));
  ------------------
  |  |   78|  2.27k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.27k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  699|       |
  700|    391|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|    391|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    391|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    391|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (700:9): [True: 391, False: 10.3k]
  ------------------
  701|    391|            return run_container_is_subset_array(const_CAST_run(c1),
  ------------------
  |  |   78|    391|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    391|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  702|    391|                                                 const_CAST_array(c2));
  ------------------
  |  |   55|    391|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    391|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  703|       |
  704|  5.59k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  5.59k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  5.59k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  5.59k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (704:9): [True: 5.59k, False: 5.12k]
  ------------------
  705|  5.59k|            return array_container_is_subset(const_CAST_array(c1),
  ------------------
  |  |   55|  5.59k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  5.59k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  706|  5.59k|                                             const_CAST_array(c2));
  ------------------
  |  |   55|  5.59k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  5.59k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  707|       |
  708|    256|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    256|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    256|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    256|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (708:9): [True: 256, False: 10.4k]
  ------------------
  709|    256|            return run_container_is_subset(const_CAST_run(c1),
  ------------------
  |  |   78|    256|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    256|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  710|    256|                                           const_CAST_run(c2));
  ------------------
  |  |   78|    256|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    256|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  711|       |
  712|      0|        default:
  ------------------
  |  Branch (712:9): [True: 0, False: 10.7k]
  ------------------
  713|      0|            assert(false);
  714|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  715|      0|            return false;
  716|  10.7k|    }
  717|  10.7k|}
roaring.c:container_inot_range:
 2110|  6.45k|                                                uint8_t *result_type) {
 2111|  6.45k|    c = get_writable_copy_if_shared(c, &type);
 2112|  6.45k|    container_t *result = NULL;
 2113|  6.45k|    switch (type) {
 2114|  1.23k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  1.23k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2114:9): [True: 1.23k, False: 5.21k]
  ------------------
 2115|  1.23k|            *result_type = bitset_container_negation_range_inplace(
  ------------------
  |  Branch (2115:28): [True: 1.20k, False: 33]
  ------------------
 2116|  1.23k|                               CAST_bitset(c), range_start, range_end, &result)
  ------------------
  |  |   52|  1.23k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.23k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2117|  1.23k|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|  1.20k|#define BITSET_CONTAINER_TYPE 1
  ------------------
 2118|  1.23k|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  1.27k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 2119|  1.23k|            return result;
 2120|  3.49k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  3.49k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2120:9): [True: 3.49k, False: 2.95k]
  ------------------
 2121|  3.49k|            *result_type = array_container_negation_range_inplace(
  ------------------
  |  Branch (2121:28): [True: 130, False: 3.36k]
  ------------------
 2122|  3.49k|                               CAST_array(c), range_start, range_end, &result)
  ------------------
  |  |   54|  3.49k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  3.49k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2123|  3.49k|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|    130|#define BITSET_CONTAINER_TYPE 1
  ------------------
 2124|  3.49k|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  6.86k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 2125|  3.49k|            return result;
 2126|  1.71k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  1.71k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2126:9): [True: 1.71k, False: 4.73k]
  ------------------
 2127|  1.71k|            *result_type = (uint8_t)run_container_negation_range_inplace(
 2128|  1.71k|                CAST_run(c), range_start, range_end, &result);
  ------------------
  |  |   77|  1.71k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.71k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2129|  1.71k|            return result;
 2130|       |
 2131|      0|        default:
  ------------------
  |  Branch (2131:9): [True: 0, False: 6.45k]
  ------------------
 2132|      0|            assert(false);
 2133|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2134|  6.45k|    }
 2135|  6.45k|    assert(false);
 2136|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2137|      0|    return NULL;
 2138|  6.45k|}
roaring.c:container_inot:
 2076|  6.84k|                                          uint8_t *result_type) {
 2077|  6.84k|    c = get_writable_copy_if_shared(c, &type);
 2078|  6.84k|    container_t *result = NULL;
 2079|  6.84k|    switch (type) {
 2080|     61|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|     61|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2080:9): [True: 61, False: 6.78k]
  ------------------
 2081|     61|            *result_type =
 2082|     61|                bitset_container_negation_inplace(CAST_bitset(c), &result)
  ------------------
  |  |   52|     61|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     61|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (2082:17): [True: 23, False: 38]
  ------------------
 2083|     61|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|     23|#define BITSET_CONTAINER_TYPE 1
  ------------------
 2084|     61|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|     99|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 2085|     61|            return result;
 2086|    155|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|    155|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2086:9): [True: 155, False: 6.69k]
  ------------------
 2087|       |            // will never be inplace
 2088|    155|            result = bitset_container_create();
 2089|    155|            *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|    155|#define BITSET_CONTAINER_TYPE 1
  ------------------
 2090|    155|            array_container_negation(CAST_array(c), CAST_bitset(result));
  ------------------
  |  |   54|    155|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    155|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          array_container_negation(CAST_array(c), CAST_bitset(result));
  ------------------
  |  |   52|    155|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    155|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2091|    155|            array_container_free(CAST_array(c));
  ------------------
  |  |   54|    155|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    155|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2092|    155|            return result;
 2093|  6.63k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  6.63k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2093:9): [True: 6.63k, False: 216]
  ------------------
 2094|  6.63k|            *result_type =
 2095|  6.63k|                (uint8_t)run_container_negation_inplace(CAST_run(c), &result);
  ------------------
  |  |   77|  6.63k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  6.63k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2096|  6.63k|            return result;
 2097|       |
 2098|      0|        default:
  ------------------
  |  Branch (2098:9): [True: 0, False: 6.84k]
  ------------------
 2099|      0|            assert(false);
 2100|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2101|  6.84k|    }
 2102|  6.84k|    assert(false);
 2103|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2104|      0|    return NULL;
 2105|  6.84k|}
roaring.c:container_unwrap_shared:
  106|  1.08M|    const container_t *candidate_shared_container, uint8_t *type) {
  107|  1.08M|    if (*type == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|  1.08M|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (107:9): [True: 0, False: 1.08M]
  ------------------
  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.08M|    } else {
  112|  1.08M|        return candidate_shared_container;
  113|  1.08M|    }
  114|  1.08M|}
roaring.c:container_mutable_unwrap_shared:
  118|  6.24k|                                                           uint8_t *type) {
  119|  6.24k|    if (*type == SHARED_CONTAINER_TYPE) {  // the passed in container is shared
  ------------------
  |  |   51|  6.24k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (119:9): [True: 0, False: 6.24k]
  ------------------
  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.24k|    } else {
  124|  6.24k|        return c;  // wasn't shared, so return as-is
  125|  6.24k|    }
  126|  6.24k|}
roaring.c:container_minimum:
 2189|  6.19k|static inline uint16_t container_minimum(const container_t *c, uint8_t type) {
 2190|  6.19k|    c = container_unwrap_shared(c, &type);
 2191|  6.19k|    switch (type) {
 2192|  1.15k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  1.15k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2192:9): [True: 1.15k, False: 5.04k]
  ------------------
 2193|  1.15k|            return bitset_container_minimum(const_CAST_bitset(c));
  ------------------
  |  |   53|  1.15k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.15k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2194|  3.54k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  3.54k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2194:9): [True: 3.54k, False: 2.64k]
  ------------------
 2195|  3.54k|            return array_container_minimum(const_CAST_array(c));
  ------------------
  |  |   55|  3.54k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.54k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2196|  1.49k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  1.49k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2196:9): [True: 1.49k, False: 4.69k]
  ------------------
 2197|  1.49k|            return run_container_minimum(const_CAST_run(c));
  ------------------
  |  |   78|  1.49k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.49k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2198|      0|        default:
  ------------------
  |  Branch (2198:9): [True: 0, False: 6.19k]
  ------------------
 2199|      0|            assert(false);
 2200|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2201|  6.19k|    }
 2202|  6.19k|    assert(false);
 2203|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2204|      0|    return false;
 2205|  6.19k|}
roaring.c:container_select:
 2150|  6.24k|                                    uint32_t *element) {
 2151|  6.24k|    c = container_unwrap_shared(c, &type);
 2152|  6.24k|    switch (type) {
 2153|      0|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2153:9): [True: 0, False: 6.24k]
  ------------------
 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.70k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  3.70k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2156:9): [True: 3.70k, False: 2.54k]
  ------------------
 2157|  3.70k|            return array_container_select(const_CAST_array(c), start_rank, rank,
  ------------------
  |  |   55|  3.70k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.70k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2158|  3.70k|                                          element);
 2159|  2.54k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  2.54k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2159:9): [True: 2.54k, False: 3.70k]
  ------------------
 2160|  2.54k|            return run_container_select(const_CAST_run(c), start_rank, rank,
  ------------------
  |  |   78|  2.54k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.54k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2161|  2.54k|                                        element);
 2162|      0|        default:
  ------------------
  |  Branch (2162:9): [True: 0, False: 6.24k]
  ------------------
 2163|      0|            assert(false);
 2164|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2165|  6.24k|    }
 2166|  6.24k|    assert(false);
 2167|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2168|      0|    return false;
 2169|  6.24k|}
roaring.c:container_intersect:
  865|  6.12k|                                       const container_t *c2, uint8_t type2) {
  866|  6.12k|    c1 = container_unwrap_shared(c1, &type1);
  867|  6.12k|    c2 = container_unwrap_shared(c2, &type2);
  868|  6.12k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  6.12k|#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.12k]
  ------------------
  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.30k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  2.30k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.30k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.30k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (873:9): [True: 2.30k, False: 3.82k]
  ------------------
  874|  2.30k|            return array_container_intersect(const_CAST_array(c1),
  ------------------
  |  |   55|  2.30k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.30k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  875|  2.30k|                                             const_CAST_array(c2));
  ------------------
  |  |   55|  2.30k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.30k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  876|       |
  877|    690|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    690|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    690|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    690|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (877:9): [True: 690, False: 5.43k]
  ------------------
  878|    690|            return run_container_intersect(const_CAST_run(c1),
  ------------------
  |  |   78|    690|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    690|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  879|    690|                                           const_CAST_run(c2));
  ------------------
  |  |   78|    690|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    690|#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.12k]
  ------------------
  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|    531|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|    531|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    531|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    531|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (885:9): [True: 531, False: 5.59k]
  ------------------
  886|    531|            return array_bitset_container_intersect(const_CAST_array(c1),
  ------------------
  |  |   55|    531|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    531|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  887|    531|                                                    const_CAST_bitset(c2));
  ------------------
  |  |   53|    531|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    531|#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.12k]
  ------------------
  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|    613|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|    613|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    613|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    613|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (893:9): [True: 613, False: 5.51k]
  ------------------
  894|    613|            return run_bitset_container_intersect(const_CAST_run(c1),
  ------------------
  |  |   78|    613|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    613|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  895|    613|                                                  const_CAST_bitset(c2));
  ------------------
  |  |   53|    613|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    613|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  896|       |
  897|    783|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    783|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    783|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    783|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (897:9): [True: 783, False: 5.34k]
  ------------------
  898|    783|            return array_run_container_intersect(const_CAST_array(c1),
  ------------------
  |  |   55|    783|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    783|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  899|    783|                                                 const_CAST_run(c2));
  ------------------
  |  |   78|    783|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    783|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  900|       |
  901|  1.20k|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|  1.20k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  1.20k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  1.20k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (901:9): [True: 1.20k, False: 4.92k]
  ------------------
  902|  1.20k|            return array_run_container_intersect(const_CAST_array(c2),
  ------------------
  |  |   55|  1.20k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.20k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  903|  1.20k|                                                 const_CAST_run(c1));
  ------------------
  |  |   78|  1.20k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.20k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  904|       |
  905|      0|        default:
  ------------------
  |  Branch (905:9): [True: 0, False: 6.12k]
  ------------------
  906|      0|            assert(false);
  907|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  908|      0|            return 0;
  909|  6.12k|    }
  910|  6.12k|}
roaring.c:container_and_cardinality:
  814|  24.5k|                                            uint8_t type2) {
  815|  24.5k|    c1 = container_unwrap_shared(c1, &type1);
  816|  24.5k|    c2 = container_unwrap_shared(c2, &type2);
  817|  24.5k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  24.5k|#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.5k]
  ------------------
  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.21k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  9.21k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  9.21k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  9.21k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (822:9): [True: 9.21k, False: 15.2k]
  ------------------
  823|  9.21k|            return array_container_intersection_cardinality(
  824|  9.21k|                const_CAST_array(c1), const_CAST_array(c2));
  ------------------
  |  |   55|  9.21k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  9.21k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_array(c2));
  ------------------
  |  |   55|  9.21k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  9.21k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  825|       |
  826|  2.76k|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|  2.76k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  2.76k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  2.76k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (826:9): [True: 2.76k, False: 21.7k]
  ------------------
  827|  2.76k|            return run_container_intersection_cardinality(const_CAST_run(c1),
  ------------------
  |  |   78|  2.76k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.76k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  828|  2.76k|                                                          const_CAST_run(c2));
  ------------------
  |  |   78|  2.76k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.76k|#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.5k]
  ------------------
  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.12k|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   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))
  |  |  ------------------
  |  |  |  |   48|  2.12k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (834:9): [True: 2.12k, False: 22.3k]
  ------------------
  835|  2.12k|            return array_bitset_container_intersection_cardinality(
  836|  2.12k|                const_CAST_array(c1), const_CAST_bitset(c2));
  ------------------
  |  |   55|  2.12k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.12k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_bitset(c2));
  ------------------
  |  |   53|  2.12k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.12k|#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.5k]
  ------------------
  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.45k|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|  2.45k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  2.45k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  2.45k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (842:9): [True: 2.45k, False: 22.0k]
  ------------------
  843|  2.45k|            return run_bitset_container_intersection_cardinality(
  844|  2.45k|                const_CAST_run(c1), const_CAST_bitset(c2));
  ------------------
  |  |   78|  2.45k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.45k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c1), const_CAST_bitset(c2));
  ------------------
  |  |   53|  2.45k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.45k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  845|       |
  846|  3.13k|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|  3.13k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  3.13k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  3.13k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (846:9): [True: 3.13k, False: 21.3k]
  ------------------
  847|  3.13k|            return array_run_container_intersection_cardinality(
  848|  3.13k|                const_CAST_array(c1), const_CAST_run(c2));
  ------------------
  |  |   55|  3.13k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.13k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_run(c2));
  ------------------
  |  |   78|  3.13k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.13k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  849|       |
  850|  4.82k|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|  4.82k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  4.82k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  4.82k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (850:9): [True: 4.82k, False: 19.6k]
  ------------------
  851|  4.82k|            return array_run_container_intersection_cardinality(
  852|  4.82k|                const_CAST_array(c2), const_CAST_run(c1));
  ------------------
  |  |   55|  4.82k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  4.82k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c2), const_CAST_run(c1));
  ------------------
  |  |   78|  4.82k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  4.82k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  853|       |
  854|      0|        default:
  ------------------
  |  Branch (854:9): [True: 0, False: 24.5k]
  ------------------
  855|      0|            assert(false);
  856|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  857|      0|            return 0;
  858|  24.5k|    }
  859|  24.5k|}
roaring.c:container_contains_range:
  596|    493|) {
  597|    493|    c = container_unwrap_shared(c, &typecode);
  598|    493|    switch (typecode) {
  599|    219|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|    219|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (599:9): [True: 219, False: 274]
  ------------------
  600|    219|            return bitset_container_get_range(const_CAST_bitset(c), range_start,
  ------------------
  |  |   53|    219|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    219|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  601|    219|                                              range_end);
  602|     83|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|     83|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (602:9): [True: 83, False: 410]
  ------------------
  603|     83|            return array_container_contains_range(const_CAST_array(c),
  ------------------
  |  |   55|     83|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|     83|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  604|     83|                                                  range_start, range_end);
  605|    191|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|    191|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (605:9): [True: 191, False: 302]
  ------------------
  606|    191|            return run_container_contains_range(const_CAST_run(c), range_start,
  ------------------
  |  |   78|    191|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    191|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  607|    191|                                                range_end);
  608|      0|        default:
  ------------------
  |  Branch (608:9): [True: 0, False: 493]
  ------------------
  609|      0|            assert(false);
  610|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  611|      0|            return false;
  612|    493|    }
  613|    493|}
roaring_array.c:container_to_uint32_array:
  465|  63.2k|                                            uint8_t typecode, uint32_t base) {
  466|  63.2k|    c = container_unwrap_shared(c, &typecode);
  467|  63.2k|    switch (typecode) {
  ------------------
  |  Branch (467:13): [True: 63.2k, False: 0]
  ------------------
  468|  1.40k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  1.40k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (468:9): [True: 1.40k, False: 61.8k]
  ------------------
  469|  1.40k|            return bitset_container_to_uint32_array(output,
  470|  1.40k|                                                    const_CAST_bitset(c), base);
  ------------------
  |  |   53|  1.40k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.40k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  471|  5.62k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  5.62k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (471:9): [True: 5.62k, False: 57.6k]
  ------------------
  472|  5.62k|            return array_container_to_uint32_array(output, const_CAST_array(c),
  ------------------
  |  |   55|  5.62k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  5.62k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  473|  5.62k|                                                   base);
  474|  56.2k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  56.2k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (474:9): [True: 56.2k, False: 7.03k]
  ------------------
  475|  56.2k|            return run_container_to_uint32_array(output, const_CAST_run(c),
  ------------------
  |  |   78|  56.2k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  56.2k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  476|  56.2k|                                                 base);
  477|  63.2k|    }
  478|  63.2k|    assert(false);
  479|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  480|      0|    return 0;  // unreached
  481|  63.2k|}
roaring_array.c:container_unwrap_shared:
  106|   364k|    const container_t *candidate_shared_container, uint8_t *type) {
  107|   364k|    if (*type == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|   364k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (107:9): [True: 0, False: 364k]
  ------------------
  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|   364k|    } else {
  112|   364k|        return candidate_shared_container;
  113|   364k|    }
  114|   364k|}
roaring_array.c:get_container_type:
  129|   153k|static inline uint8_t get_container_type(const container_t *c, uint8_t type) {
  130|   153k|    if (type == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|   153k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (130:9): [True: 0, False: 153k]
  ------------------
  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|   153k|    } else {
  133|   153k|        return type;
  134|   153k|    }
  135|   153k|}
roaring_array.c:container_size_in_bytes:
  403|   153k|                                              uint8_t typecode) {
  404|   153k|    c = container_unwrap_shared(c, &typecode);
  405|   153k|    switch (typecode) {
  ------------------
  |  Branch (405:13): [True: 153k, False: 0]
  ------------------
  406|   133k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|   133k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (406:9): [True: 133k, False: 19.8k]
  ------------------
  407|   133k|            return bitset_container_size_in_bytes(const_CAST_bitset(c));
  ------------------
  |  |   53|   133k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|   133k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  408|  17.3k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  17.3k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (408:9): [True: 17.3k, False: 136k]
  ------------------
  409|  17.3k|            return array_container_size_in_bytes(const_CAST_array(c));
  ------------------
  |  |   55|  17.3k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  17.3k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  410|  2.54k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  2.54k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (410:9): [True: 2.54k, False: 151k]
  ------------------
  411|  2.54k|            return run_container_size_in_bytes(const_CAST_run(c));
  ------------------
  |  |   78|  2.54k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.54k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  412|   153k|    }
  413|   153k|    assert(false);
  414|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  415|      0|    return 0;  // unreached
  416|   153k|}
roaring_array.c:container_get_cardinality:
  244|  73.8k|                                            uint8_t typecode) {
  245|  73.8k|    c = container_unwrap_shared(c, &typecode);
  246|  73.8k|    switch (typecode) {
  ------------------
  |  Branch (246:13): [True: 73.8k, False: 0]
  ------------------
  247|  66.9k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  66.9k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (247:9): [True: 66.9k, False: 6.82k]
  ------------------
  248|  66.9k|            return bitset_container_cardinality(const_CAST_bitset(c));
  ------------------
  |  |   53|  66.9k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  66.9k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  249|  6.82k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  6.82k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (249:9): [True: 6.82k, False: 66.9k]
  ------------------
  250|  6.82k|            return array_container_cardinality(const_CAST_array(c));
  ------------------
  |  |   55|  6.82k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  6.82k|#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: 73.8k]
  ------------------
  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|  73.8k|    }
  254|  73.8k|    assert(false);
  255|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  256|      0|    return 0;  // unreached
  257|  73.8k|}
roaring_array.c:container_write:
  382|  73.8k|                                      char *buf) {
  383|  73.8k|    c = container_unwrap_shared(c, &typecode);
  384|  73.8k|    switch (typecode) {
  ------------------
  |  Branch (384:13): [True: 73.8k, False: 0]
  ------------------
  385|  66.9k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  66.9k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (385:9): [True: 66.9k, False: 6.82k]
  ------------------
  386|  66.9k|            return bitset_container_write(const_CAST_bitset(c), buf);
  ------------------
  |  |   53|  66.9k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  66.9k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  387|  6.82k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  6.82k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (387:9): [True: 6.82k, False: 66.9k]
  ------------------
  388|  6.82k|            return array_container_write(const_CAST_array(c), buf);
  ------------------
  |  |   55|  6.82k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  6.82k|#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: 73.8k]
  ------------------
  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|  73.8k|    }
  392|  73.8k|    assert(false);
  393|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  394|      0|    return 0;  // unreached
  395|  73.8k|}
containers.c:container_unwrap_shared:
  106|  6.40k|    const container_t *candidate_shared_container, uint8_t *type) {
  107|  6.40k|    if (*type == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|  6.40k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (107:9): [True: 0, False: 6.40k]
  ------------------
  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.40k|    } else {
  112|  6.40k|        return candidate_shared_container;
  113|  6.40k|    }
  114|  6.40k|}
containers.c:container_maximum:
 2171|  6.17k|static inline uint16_t container_maximum(const container_t *c, uint8_t type) {
 2172|  6.17k|    c = container_unwrap_shared(c, &type);
 2173|  6.17k|    switch (type) {
 2174|  1.79k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  1.79k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2174:9): [True: 1.79k, False: 4.37k]
  ------------------
 2175|  1.79k|            return bitset_container_maximum(const_CAST_bitset(c));
  ------------------
  |  |   53|  1.79k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.79k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2176|  4.37k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  4.37k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2176:9): [True: 4.37k, False: 1.79k]
  ------------------
 2177|  4.37k|            return array_container_maximum(const_CAST_array(c));
  ------------------
  |  |   55|  4.37k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  4.37k|#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.17k]
  ------------------
 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.17k]
  ------------------
 2181|      0|            assert(false);
 2182|      0|            roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2183|  6.17k|    }
 2184|  6.17k|    assert(false);
 2185|      0|    roaring_unreachable;
  ------------------
  |  |  240|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2186|      0|    return false;
 2187|  6.17k|}

run_container_contains:
  260|  9.61k|inline bool run_container_contains(const run_container_t *run, uint16_t pos) {
  261|  9.61k|    int32_t index = interleavedBinarySearch(run->runs, run->n_runs, pos);
  262|  9.61k|    if (index >= 0) return true;
  ------------------
  |  Branch (262:9): [True: 6.96k, False: 2.64k]
  ------------------
  263|  2.64k|    index = -index - 2;  // points to preceding value, possibly -1
  264|  2.64k|    if (index != -1) {   // possible match
  ------------------
  |  Branch (264:9): [True: 908, False: 1.74k]
  ------------------
  265|    908|        int32_t offset = pos - run->runs[index].value;
  266|    908|        int32_t le = run->runs[index].length;
  267|    908|        if (offset <= le) return true;
  ------------------
  |  Branch (267:13): [True: 597, False: 311]
  ------------------
  268|    908|    }
  269|  2.05k|    return false;
  270|  2.64k|}
interleavedBinarySearch:
  112|   425k|                                       uint16_t ikey) {
  113|   425k|    int32_t low = 0;
  114|   425k|    int32_t high = lenarray - 1;
  115|  1.97M|    while (low <= high) {
  ------------------
  |  Branch (115:12): [True: 1.73M, False: 237k]
  ------------------
  116|  1.73M|        int32_t middleIndex = (low + high) >> 1;
  117|  1.73M|        uint16_t middleValue = array[middleIndex].value;
  118|  1.73M|        if (middleValue < ikey) {
  ------------------
  |  Branch (118:13): [True: 683k, False: 1.05M]
  ------------------
  119|   683k|            low = middleIndex + 1;
  120|  1.05M|        } else if (middleValue > ikey) {
  ------------------
  |  Branch (120:20): [True: 863k, False: 187k]
  ------------------
  121|   863k|            high = middleIndex - 1;
  122|   863k|        } else {
  123|   187k|            return middleIndex;
  124|   187k|        }
  125|  1.73M|    }
  126|   237k|    return -(low + 1);
  127|   425k|}
run_container_minimum:
  563|  17.2k|inline uint16_t run_container_minimum(const run_container_t *run) {
  564|  17.2k|    if (run->n_runs == 0) return 0;
  ------------------
  |  Branch (564:9): [True: 0, False: 17.2k]
  ------------------
  565|  17.2k|    return run->runs[0].value;
  566|  17.2k|}
run_container_maximum:
  569|  16.7k|inline uint16_t run_container_maximum(const run_container_t *run) {
  570|  16.7k|    if (run->n_runs == 0) return 0;
  ------------------
  |  Branch (570:9): [True: 0, False: 16.7k]
  ------------------
  571|  16.7k|    return run->runs[run->n_runs - 1].value + run->runs[run->n_runs - 1].length;
  572|  16.7k|}
roaring.c:run_container_create_range:
  532|  85.6k|                                                          uint32_t stop) {
  533|  85.6k|    run_container_t *rc = run_container_create_given_capacity(1);
  534|  85.6k|    if (rc) {
  ------------------
  |  Branch (534:9): [True: 85.6k, False: 0]
  ------------------
  535|  85.6k|        rle16_t r;
  536|  85.6k|        r.value = (uint16_t)start;
  537|  85.6k|        r.length = (uint16_t)(stop - start - 1);
  538|  85.6k|        run_container_append_first(rc, r);
  539|  85.6k|    }
  540|  85.6k|    return rc;
  541|  85.6k|}
roaring.c:run_container_append_first:
  351|  85.6k|                                                 rle16_t vl) {
  352|  85.6k|    run->runs[run->n_runs] = vl;
  353|  85.6k|    run->n_runs++;
  354|  85.6k|    return vl;
  355|  85.6k|}
roaring.c:rle16_count_greater:
  178|    476|                                          int32_t lenarray, uint16_t key) {
  179|    476|    if (lenarray == 0) return 0;
  ------------------
  |  Branch (179:9): [True: 0, False: 476]
  ------------------
  180|    476|    int32_t low = 0;
  181|    476|    int32_t high = lenarray - 1;
  182|  3.61k|    while (low <= high) {
  ------------------
  |  Branch (182:12): [True: 3.17k, False: 435]
  ------------------
  183|  3.17k|        int32_t middleIndex = (low + high) >> 1;
  184|  3.17k|        uint16_t min_value = array[middleIndex].value;
  185|  3.17k|        uint16_t max_value =
  186|  3.17k|            array[middleIndex].value + array[middleIndex].length;
  187|  3.17k|        if (max_value < key) {
  ------------------
  |  Branch (187:13): [True: 2.90k, False: 276]
  ------------------
  188|  2.90k|            low = middleIndex + 1;
  189|  2.90k|        } else if (key + UINT32_C(1) < min_value) {  // uint32 arithmetic
  ------------------
  |  Branch (189:20): [True: 235, False: 41]
  ------------------
  190|    235|            high = middleIndex - 1;
  191|    235|        } else {
  192|     41|            return lenarray - (middleIndex + 1);
  193|     41|        }
  194|  3.17k|    }
  195|    435|    return lenarray - low;
  196|    476|}
roaring.c:rle16_count_less:
  157|    476|                                       uint16_t key) {
  158|    476|    if (lenarray == 0) return 0;
  ------------------
  |  Branch (158:9): [True: 1, False: 475]
  ------------------
  159|    475|    int32_t low = 0;
  160|    475|    int32_t high = lenarray - 1;
  161|  3.01k|    while (low <= high) {
  ------------------
  |  Branch (161:12): [True: 2.80k, False: 209]
  ------------------
  162|  2.80k|        int32_t middleIndex = (low + high) >> 1;
  163|  2.80k|        uint16_t min_value = array[middleIndex].value;
  164|  2.80k|        uint16_t max_value =
  165|  2.80k|            array[middleIndex].value + array[middleIndex].length;
  166|  2.80k|        if (max_value + UINT32_C(1) < key) {  // uint32 arithmetic
  ------------------
  |  Branch (166:13): [True: 1.30k, False: 1.49k]
  ------------------
  167|  1.30k|            low = middleIndex + 1;
  168|  1.49k|        } else if (key < min_value) {
  ------------------
  |  Branch (168:20): [True: 1.23k, False: 266]
  ------------------
  169|  1.23k|            high = middleIndex - 1;
  170|  1.23k|        } else {
  171|    266|            return middleIndex;
  172|    266|        }
  173|  2.80k|    }
  174|    209|    return low;
  175|    475|}
roaring.c:run_container_add_range_nruns:
  610|    476|                                                 int32_t nruns_greater) {
  611|    476|    int32_t nruns_common = run->n_runs - nruns_less - nruns_greater;
  612|    476|    if (nruns_common == 0) {
  ------------------
  |  Branch (612:9): [True: 139, False: 337]
  ------------------
  613|    139|        makeRoomAtIndex(run, (uint16_t)nruns_less);
  614|    139|        run->runs[nruns_less].value = (uint16_t)min;
  615|    139|        run->runs[nruns_less].length = (uint16_t)(max - min);
  616|    337|    } else {
  617|    337|        uint32_t common_min = run->runs[nruns_less].value;
  618|    337|        uint32_t common_max = run->runs[nruns_less + nruns_common - 1].value +
  619|    337|                              run->runs[nruns_less + nruns_common - 1].length;
  620|    337|        uint32_t result_min = (common_min < min) ? common_min : min;
  ------------------
  |  Branch (620:31): [True: 84, False: 253]
  ------------------
  621|    337|        uint32_t result_max = (common_max > max) ? common_max : max;
  ------------------
  |  Branch (621:31): [True: 35, False: 302]
  ------------------
  622|       |
  623|    337|        run->runs[nruns_less].value = (uint16_t)result_min;
  624|    337|        run->runs[nruns_less].length = (uint16_t)(result_max - result_min);
  625|       |
  626|    337|        memmove(&(run->runs[nruns_less + 1]),
  627|    337|                &(run->runs[run->n_runs - nruns_greater]),
  628|    337|                nruns_greater * sizeof(rle16_t));
  629|    337|        run->n_runs = nruns_less + 1 + nruns_greater;
  630|    337|    }
  631|    476|}
roaring.c:makeRoomAtIndex:
  208|    821|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|    821|    if (run->n_runs + 1 > run->capacity)
  ------------------
  |  Branch (212:9): [True: 646, False: 175]
  ------------------
  213|    646|        run_container_grow(run, run->n_runs + 1, true);
  214|    821|    memmove(run->runs + 1 + index, run->runs + index,
  215|    821|            (run->n_runs - index) * sizeof(rle16_t));
  216|    821|    run->n_runs++;
  217|    821|}
roaring.c:run_container_remove_range:
  667|  1.83k|                                              uint32_t min, uint32_t max) {
  668|  1.83k|    int32_t first = rle16_find_run(run->runs, run->n_runs, (uint16_t)min);
  669|  1.83k|    int32_t last = rle16_find_run(run->runs, run->n_runs, (uint16_t)max);
  670|       |
  671|  1.83k|    if (first >= 0 && min > run->runs[first].value &&
  ------------------
  |  Branch (671:9): [True: 653, False: 1.18k]
  |  Branch (671:23): [True: 309, False: 344]
  ------------------
  672|    309|        max < ((uint32_t)run->runs[first].value +
  ------------------
  |  Branch (672:9): [True: 49, False: 260]
  ------------------
  673|    309|               (uint32_t)run->runs[first].length)) {
  674|       |        // split this run into two adjacent runs
  675|       |
  676|       |        // right subinterval
  677|     49|        makeRoomAtIndex(run, (uint16_t)(first + 1));
  678|     49|        run->runs[first + 1].value = (uint16_t)(max + 1);
  679|     49|        run->runs[first + 1].length =
  680|     49|            (uint16_t)((run->runs[first].value + run->runs[first].length) -
  681|     49|                       (max + 1));
  682|       |
  683|       |        // left subinterval
  684|     49|        run->runs[first].length =
  685|     49|            (uint16_t)((min - 1) - run->runs[first].value);
  686|       |
  687|     49|        return;
  688|     49|    }
  689|       |
  690|       |    // update left-most partial run
  691|  1.78k|    if (first >= 0) {
  ------------------
  |  Branch (691:9): [True: 604, False: 1.18k]
  ------------------
  692|    604|        if (min > run->runs[first].value) {
  ------------------
  |  Branch (692:13): [True: 260, False: 344]
  ------------------
  693|    260|            run->runs[first].length =
  694|    260|                (uint16_t)((min - 1) - run->runs[first].value);
  695|    260|            first++;
  696|    260|        }
  697|  1.18k|    } else {
  698|  1.18k|        first = -first - 1;
  699|  1.18k|    }
  700|       |
  701|       |    // update right-most run
  702|  1.78k|    if (last >= 0) {
  ------------------
  |  Branch (702:9): [True: 577, False: 1.20k]
  ------------------
  703|    577|        uint16_t run_max = run->runs[last].value + run->runs[last].length;
  704|    577|        if (run_max > max) {
  ------------------
  |  Branch (704:13): [True: 335, False: 242]
  ------------------
  705|    335|            run->runs[last].value = (uint16_t)(max + 1);
  706|    335|            run->runs[last].length = (uint16_t)(run_max - (max + 1));
  707|    335|            last--;
  708|    335|        }
  709|  1.20k|    } else {
  710|  1.20k|        last = (-last - 1) - 1;
  711|  1.20k|    }
  712|       |
  713|       |    // remove intermediate runs
  714|  1.78k|    if (first <= last) {
  ------------------
  |  Branch (714:9): [True: 164, False: 1.62k]
  ------------------
  715|    164|        run_container_shift_tail(run, run->n_runs - (last + 1),
  716|    164|                                 -(last - first + 1));
  717|    164|    }
  718|  1.78k|}
roaring.c:rle16_find_run:
  133|  3.66k|                                     uint16_t ikey) {
  134|  3.66k|    int32_t low = 0;
  135|  3.66k|    int32_t high = lenarray - 1;
  136|  15.7k|    while (low <= high) {
  ------------------
  |  Branch (136:12): [True: 13.3k, False: 2.38k]
  ------------------
  137|  13.3k|        int32_t middleIndex = (low + high) >> 1;
  138|  13.3k|        uint16_t min = array[middleIndex].value;
  139|  13.3k|        uint16_t max = array[middleIndex].value + array[middleIndex].length;
  140|  13.3k|        if (ikey > max) {
  ------------------
  |  Branch (140:13): [True: 1.50k, False: 11.8k]
  ------------------
  141|  1.50k|            low = middleIndex + 1;
  142|  11.8k|        } else if (ikey < min) {
  ------------------
  |  Branch (142:20): [True: 10.5k, False: 1.27k]
  ------------------
  143|  10.5k|            high = middleIndex - 1;
  144|  10.5k|        } else {
  145|  1.27k|            return middleIndex;
  146|  1.27k|        }
  147|  13.3k|    }
  148|  2.38k|    return -(low + 1);
  149|  3.66k|}
roaring.c:run_container_shift_tail:
  650|    164|                                            int32_t distance) {
  651|    164|    if (distance > 0) {
  ------------------
  |  Branch (651:9): [True: 0, False: 164]
  ------------------
  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|    164|    int32_t srcpos = run->n_runs - count;
  657|    164|    int32_t dstpos = srcpos + distance;
  658|    164|    memmove(&(run->runs[dstpos]), &(run->runs[srcpos]),
  659|    164|            sizeof(rle16_t) * count);
  660|    164|    run->n_runs += distance;
  661|    164|}
roaring.c:run_container_remove:
  223|  3.14k|static inline bool run_container_remove(run_container_t *run, uint16_t pos) {
  224|  3.14k|    int32_t index = interleavedBinarySearch(run->runs, run->n_runs, pos);
  225|  3.14k|    if (index >= 0) {
  ------------------
  |  Branch (225:9): [True: 1.24k, False: 1.90k]
  ------------------
  226|  1.24k|        int32_t le = run->runs[index].length;
  227|  1.24k|        if (le == 0) {
  ------------------
  |  Branch (227:13): [True: 239, False: 1.00k]
  ------------------
  228|    239|            recoverRoomAtIndex(run, (uint16_t)index);
  229|  1.00k|        } else {
  230|  1.00k|            run->runs[index].value++;
  231|  1.00k|            run->runs[index].length--;
  232|  1.00k|        }
  233|  1.24k|        return true;
  234|  1.24k|    }
  235|  1.90k|    index = -index - 2;  // points to preceding value, possibly -1
  236|  1.90k|    if (index >= 0) {    // possible match
  ------------------
  |  Branch (236:9): [True: 850, False: 1.05k]
  ------------------
  237|    850|        int32_t offset = pos - run->runs[index].value;
  238|    850|        int32_t le = run->runs[index].length;
  239|    850|        if (offset < le) {
  ------------------
  |  Branch (239:13): [True: 633, False: 217]
  ------------------
  240|       |            // need to break in two
  241|    633|            run->runs[index].length = (uint16_t)(offset - 1);
  242|       |            // need to insert
  243|    633|            uint16_t newvalue = pos + 1;
  244|    633|            int32_t newlength = le - offset - 1;
  245|    633|            makeRoomAtIndex(run, (uint16_t)(index + 1));
  246|    633|            run->runs[index + 1].value = newvalue;
  247|    633|            run->runs[index + 1].length = (uint16_t)newlength;
  248|    633|            return true;
  249|       |
  250|    633|        } else if (offset == le) {
  ------------------
  |  Branch (250:20): [True: 28, False: 189]
  ------------------
  251|     28|            run->runs[index].length--;
  252|     28|            return true;
  253|     28|        }
  254|    850|    }
  255|       |    // no match
  256|  1.24k|    return false;
  257|  1.90k|}
roaring.c:recoverRoomAtIndex:
  102|    239|static inline void recoverRoomAtIndex(run_container_t *run, uint16_t index) {
  103|    239|    memmove(run->runs + index, run->runs + (1 + index),
  104|    239|            (run->n_runs - index - 1) * sizeof(rle16_t));
  105|    239|    run->n_runs--;
  106|    239|}
roaring.c:run_container_nonzero_cardinality:
  309|  61.6k|    const run_container_t *run) {
  310|  61.6k|    return run->n_runs > 0;  // runs never empty
  311|  61.6k|}
roaring.c:run_container_is_full:
  394|  6.00k|static inline bool run_container_is_full(const run_container_t *run) {
  395|  6.00k|    rle16_t vl = run->runs[0];
  396|  6.00k|    return (run->n_runs == 1) && (vl.value == 0) && (vl.length == 0xFFFF);
  ------------------
  |  Branch (396:12): [True: 1.15k, False: 4.84k]
  |  Branch (396:34): [True: 894, False: 260]
  |  Branch (396:53): [True: 772, False: 122]
  ------------------
  397|  6.00k|}
roaring.c:run_container_equals:
  502|    133|                                        const run_container_t *container2) {
  503|    133|    if (container1->n_runs != container2->n_runs) {
  ------------------
  |  Branch (503:9): [True: 105, False: 28]
  ------------------
  504|    105|        return false;
  505|    105|    }
  506|     28|    return memequals(container1->runs, container2->runs,
  507|     28|                     container1->n_runs * sizeof(rle16_t));
  508|    133|}
roaring.c:run_container_contains_range:
  278|    191|                                                uint32_t pos_end) {
  279|    191|    uint32_t count = 0;
  280|    191|    int32_t index =
  281|    191|        interleavedBinarySearch(run->runs, run->n_runs, (uint16_t)pos_start);
  282|    191|    if (index < 0) {
  ------------------
  |  Branch (282:9): [True: 124, False: 67]
  ------------------
  283|    124|        index = -index - 2;
  284|    124|        if ((index == -1) ||
  ------------------
  |  Branch (284:13): [True: 17, False: 107]
  ------------------
  285|    107|            ((pos_start - run->runs[index].value) > run->runs[index].length)) {
  ------------------
  |  Branch (285:13): [True: 24, False: 83]
  ------------------
  286|     41|            return false;
  287|     41|        }
  288|    124|    }
  289|  1.81k|    for (int32_t i = index; i < run->n_runs; ++i) {
  ------------------
  |  Branch (289:29): [True: 1.75k, False: 58]
  ------------------
  290|  1.75k|        const uint32_t stop = run->runs[i].value + run->runs[i].length;
  291|  1.75k|        if (run->runs[i].value >= pos_end) break;
  ------------------
  |  Branch (291:13): [True: 10, False: 1.74k]
  ------------------
  292|  1.74k|        if (stop >= pos_end) {
  ------------------
  |  Branch (292:13): [True: 82, False: 1.66k]
  ------------------
  293|     82|            count += (((pos_end - run->runs[i].value) > 0)
  ------------------
  |  Branch (293:23): [True: 82, False: 0]
  ------------------
  294|     82|                          ? (pos_end - run->runs[i].value)
  295|     82|                          : 0);
  296|     82|            break;
  297|     82|        }
  298|  1.66k|        const uint32_t min = (stop - pos_start) > 0 ? (stop - pos_start) : 0;
  ------------------
  |  Branch (298:30): [True: 1.65k, False: 9]
  ------------------
  299|  1.66k|        count += (min < run->runs[i].length) ? min : run->runs[i].length;
  ------------------
  |  Branch (299:18): [True: 52, False: 1.61k]
  ------------------
  300|  1.66k|    }
  301|    150|    return count >= (pos_end - pos_start - 1);
  302|    191|}
roaring_array.c:run_container_size_in_bytes:
  493|  2.54k|    const run_container_t *container) {
  494|  2.54k|    return run_container_serialized_size_in_bytes(container->n_runs);
  495|  2.54k|}
roaring_array.c:run_container_serialized_size_in_bytes:
  456|  2.54k|static inline int32_t run_container_serialized_size_in_bytes(int32_t num_runs) {
  457|  2.54k|    return sizeof(uint16_t) +
  458|  2.54k|           sizeof(rle16_t) * num_runs;  // each run requires 2 2-byte entries.
  459|  2.54k|}
convert.c:run_container_serialized_size_in_bytes:
  456|   142k|static inline int32_t run_container_serialized_size_in_bytes(int32_t num_runs) {
  457|   142k|    return sizeof(uint16_t) +
  458|   142k|           sizeof(rle16_t) * num_runs;  // each run requires 2 2-byte entries.
  459|   142k|}
mixed_intersection.c:run_container_is_full:
  394|  16.8k|static inline bool run_container_is_full(const run_container_t *run) {
  395|  16.8k|    rle16_t vl = run->runs[0];
  396|  16.8k|    return (run->n_runs == 1) && (vl.value == 0) && (vl.length == 0xFFFF);
  ------------------
  |  Branch (396:12): [True: 1.47k, False: 15.3k]
  |  Branch (396:34): [True: 481, False: 997]
  |  Branch (396:53): [True: 144, False: 337]
  ------------------
  397|  16.8k|}
mixed_union.c:run_container_is_full:
  394|  2.88k|static inline bool run_container_is_full(const run_container_t *run) {
  395|  2.88k|    rle16_t vl = run->runs[0];
  396|  2.88k|    return (run->n_runs == 1) && (vl.value == 0) && (vl.length == 0xFFFF);
  ------------------
  |  Branch (396:12): [True: 355, False: 2.53k]
  |  Branch (396:34): [True: 193, False: 162]
  |  Branch (396:53): [True: 93, False: 100]
  ------------------
  397|  2.88k|}
mixed_union.c:run_container_append_first:
  351|  2.08k|                                                 rle16_t vl) {
  352|  2.08k|    run->runs[run->n_runs] = vl;
  353|  2.08k|    run->n_runs++;
  354|  2.08k|    return vl;
  355|  2.08k|}
mixed_union.c:run_container_append_value_first:
  385|    705|                                                       uint16_t val) {
  386|    705|    rle16_t newrle = CROARING_MAKE_RLE16(val, 0);
  ------------------
  |  |   60|    705|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  387|    705|    run->runs[run->n_runs] = newrle;
  388|    705|    run->n_runs++;
  389|    705|    return newrle;
  390|    705|}
mixed_union.c:run_container_append:
  332|   170k|                                        rle16_t *previousrl) {
  333|   170k|    const uint32_t previousend = previousrl->value + previousrl->length;
  334|   170k|    if (vl.value > previousend + 1) {  // we add a new one
  ------------------
  |  Branch (334:9): [True: 157k, False: 13.0k]
  ------------------
  335|   157k|        run->runs[run->n_runs] = vl;
  336|   157k|        run->n_runs++;
  337|   157k|        *previousrl = vl;
  338|   157k|    } else {
  339|  13.0k|        uint32_t newend = vl.value + vl.length + UINT32_C(1);
  340|  13.0k|        if (newend > previousend) {  // we merge
  ------------------
  |  Branch (340:13): [True: 13.0k, False: 0]
  ------------------
  341|  13.0k|            previousrl->length = (uint16_t)(newend - 1 - previousrl->value);
  342|  13.0k|            run->runs[run->n_runs - 1] = *previousrl;
  343|  13.0k|        }
  344|  13.0k|    }
  345|   170k|}
mixed_union.c:run_container_append_value:
  368|   502k|                                              rle16_t *previousrl) {
  369|   502k|    const uint32_t previousend = previousrl->value + previousrl->length;
  370|   502k|    if (val > previousend + 1) {  // we add a new one
  ------------------
  |  Branch (370:9): [True: 55.3k, False: 447k]
  ------------------
  371|  55.3k|        *previousrl = CROARING_MAKE_RLE16(val, 0);
  ------------------
  |  |   60|  55.3k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  372|  55.3k|        run->runs[run->n_runs] = *previousrl;
  373|  55.3k|        run->n_runs++;
  374|   447k|    } else if (val == previousend + 1) {  // we merge
  ------------------
  |  Branch (374:16): [True: 144k, False: 302k]
  ------------------
  375|   144k|        previousrl->length++;
  376|   144k|        run->runs[run->n_runs - 1] = *previousrl;
  377|   144k|    }
  378|   502k|}
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: 110k, False: 14.5k]
  |  Branch (396:34): [True: 108k, False: 1.63k]
  |  Branch (396:53): [True: 106k, False: 2.13k]
  ------------------
  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.59k|static inline void recoverRoomAtIndex(run_container_t *run, uint16_t index) {
  103|  6.59k|    memmove(run->runs + index, run->runs + (1 + index),
  104|  6.59k|            (run->n_runs - index - 1) * sizeof(rle16_t));
  105|  6.59k|    run->n_runs--;
  106|  6.59k|}
run.c:makeRoomAtIndex:
  208|  45.7k|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|  45.7k|    if (run->n_runs + 1 > run->capacity)
  ------------------
  |  Branch (212:9): [True: 2.59k, False: 43.1k]
  ------------------
  213|  2.59k|        run_container_grow(run, run->n_runs + 1, true);
  214|  45.7k|    memmove(run->runs + 1 + index, run->runs + index,
  215|  45.7k|            (run->n_runs - index) * sizeof(rle16_t));
  216|  45.7k|    run->n_runs++;
  217|  45.7k|}
run.c:run_container_append_first:
  351|  2.31k|                                                 rle16_t vl) {
  352|  2.31k|    run->runs[run->n_runs] = vl;
  353|  2.31k|    run->n_runs++;
  354|  2.31k|    return vl;
  355|  2.31k|}
run.c:run_container_append:
  332|   303k|                                        rle16_t *previousrl) {
  333|   303k|    const uint32_t previousend = previousrl->value + previousrl->length;
  334|   303k|    if (vl.value > previousend + 1) {  // we add a new one
  ------------------
  |  Branch (334:9): [True: 153k, False: 149k]
  ------------------
  335|   153k|        run->runs[run->n_runs] = vl;
  336|   153k|        run->n_runs++;
  337|   153k|        *previousrl = vl;
  338|   153k|    } else {
  339|   149k|        uint32_t newend = vl.value + vl.length + UINT32_C(1);
  340|   149k|        if (newend > previousend) {  // we merge
  ------------------
  |  Branch (340:13): [True: 112k, False: 37.6k]
  ------------------
  341|   112k|            previousrl->length = (uint16_t)(newend - 1 - previousrl->value);
  342|   112k|            run->runs[run->n_runs - 1] = *previousrl;
  343|   112k|        }
  344|   149k|    }
  345|   303k|}
run.c:run_container_empty:
  314|     14|static inline bool run_container_empty(const run_container_t *run) {
  315|     14|    return run->n_runs == 0;  // runs never empty
  316|     14|}
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.5M|inline int roaring_trailing_zeroes(unsigned long long input_num) {
  243|  68.5M|    return __builtin_ctzll(input_num);
  244|  68.5M|}
roaring_leading_zeroes:
  246|  4.23k|inline int roaring_leading_zeroes(unsigned long long input_num) {
  247|  4.23k|    return __builtin_clzll(input_num);
  248|  4.23k|}
roaring.c:roaring_hamming:
  287|   153k|static inline int roaring_hamming(uint64_t x) {
  288|       |#if defined(_WIN64) && defined(CROARING_REGULAR_VISUAL_STUDIO) && \
  289|       |    CROARING_REGULAR_VISUAL_STUDIO
  290|       |#ifdef CROARING_USENEON
  291|       |    return vaddv_u8(vcnt_u8(vcreate_u8(input_num)));
  292|       |#elif defined(_M_ARM64)
  293|       |    return roaring_hamming_backup(x);
  294|       |    // (int) _CountOneBits64(x); is unavailable
  295|       |#else   // _M_ARM64
  296|       |    return (int)__popcnt64(x);
  297|       |#endif  // _M_ARM64
  298|       |#elif defined(_WIN32) && defined(CROARING_REGULAR_VISUAL_STUDIO) && \
  299|       |    CROARING_REGULAR_VISUAL_STUDIO
  300|       |#ifdef _M_ARM
  301|       |    return roaring_hamming_backup(x);
  302|       |    // _CountOneBits is unavailable
  303|       |#else   // _M_ARM
  304|       |    return (int)__popcnt((unsigned int)x) +
  305|       |           (int)__popcnt((unsigned int)(x >> 32));
  306|       |#endif  // _M_ARM
  307|       |#else
  308|   153k|    return __builtin_popcountll(x);
  309|   153k|#endif
  310|   153k|}
mixed_intersection.c:roaring_hamming:
  287|   207k|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|   207k|    return __builtin_popcountll(x);
  309|   207k|#endif
  310|   207k|}

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

ra_get_index:
   93|  87.4k|inline int32_t ra_get_index(const roaring_array_t *ra, uint16_t x) {
   94|  87.4k|    if ((ra->size == 0) || ra->keys[ra->size - 1] == x) return ra->size - 1;
  ------------------
  |  Branch (94:9): [True: 12.6k, False: 74.7k]
  |  Branch (94:28): [True: 32.6k, False: 42.1k]
  ------------------
   95|  42.1k|    return binarySearch(ra->keys, (int32_t)ra->size, x);
   96|  87.4k|}
ra_get_container_at_index:
  102|   435k|                                              uint16_t i, uint8_t *typecode) {
  103|   435k|    *typecode = ra->typecodes[i];
  104|   435k|    return ra->containers[i];
  105|   435k|}
ra_get_key_at_index:
  110|   297k|inline uint16_t ra_get_key_at_index(const roaring_array_t *ra, uint16_t i) {
  111|   297k|    return ra->keys[i];
  112|   297k|}
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.1k|inline int32_t ra_get_size(const roaring_array_t *ra) { return ra->size; }
ra_replace_key_and_container_at_index:
  205|   145k|                                                  uint8_t typecode) {
  206|   145k|    assert(i < ra->size);
  207|       |
  208|   145k|    ra->keys[i] = key;
  209|   145k|    ra->containers[i] = c;
  210|   145k|    ra->typecodes[i] = typecode;
  211|   145k|}
roaring.c:ra_advance_until:
  194|    469|                                       int32_t pos) {
  195|    469|    return advanceUntil(ra->keys, pos, ra->size, x);
  196|    469|}
roaring.c:ra_unshare_container_at_index:
  268|  63.0k|                                                 uint16_t i) {
  269|       |    assert(i < ra->size);
  270|  63.0k|    ra->containers[i] =
  271|  63.0k|        get_writable_copy_if_shared(ra->containers[i], &ra->typecodes[i]);
  272|  63.0k|}

intersect_vector16:
  386|  1.76k|                           size_t s_b, uint16_t *C) {
  387|  1.76k|    size_t count = 0;
  388|  1.76k|    size_t i_a = 0, i_b = 0;
  389|  1.76k|    const int vectorlength = sizeof(__m128i) / sizeof(uint16_t);
  390|  1.76k|    const size_t st_a = (s_a / vectorlength) * vectorlength;
  391|  1.76k|    const size_t st_b = (s_b / vectorlength) * vectorlength;
  392|  1.76k|    __m128i v_a, v_b;
  393|  1.76k|    if ((i_a < st_a) && (i_b < st_b)) {
  ------------------
  |  Branch (393:9): [True: 1.63k, False: 135]
  |  Branch (393:25): [True: 1.48k, False: 149]
  ------------------
  394|  1.48k|        v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  395|  1.48k|        v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  396|  4.01k|        while ((A[i_a] == 0) || (B[i_b] == 0)) {
  ------------------
  |  Branch (396:16): [True: 2.52k, False: 1.49k]
  |  Branch (396:33): [True: 182, False: 1.31k]
  ------------------
  397|  2.70k|            const __m128i res_v = _mm_cmpestrm(
  398|  2.70k|                v_b, vectorlength, v_a, vectorlength,
  399|  2.70k|                _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  400|  2.70k|            const int r = _mm_extract_epi32(res_v, 0);
  401|  2.70k|            __m128i sm16 = _mm_loadu_si128((const __m128i *)shuffle_mask16 + r);
  402|  2.70k|            __m128i p = _mm_shuffle_epi8(v_a, sm16);
  403|  2.70k|            _mm_storeu_si128((__m128i *)&C[count], p);  // can overflow
  404|  2.70k|            count += _mm_popcnt_u32(r);
  405|  2.70k|            const uint16_t a_max = A[i_a + vectorlength - 1];
  406|  2.70k|            const uint16_t b_max = B[i_b + vectorlength - 1];
  407|  2.70k|            if (a_max <= b_max) {
  ------------------
  |  Branch (407:17): [True: 1.51k, False: 1.19k]
  ------------------
  408|  1.51k|                i_a += vectorlength;
  409|  1.51k|                if (i_a == st_a) break;
  ------------------
  |  Branch (409:21): [True: 130, False: 1.38k]
  ------------------
  410|  1.38k|                v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  411|  1.38k|            }
  412|  2.57k|            if (b_max <= a_max) {
  ------------------
  |  Branch (412:17): [True: 1.25k, False: 1.31k]
  ------------------
  413|  1.25k|                i_b += vectorlength;
  414|  1.25k|                if (i_b == st_b) break;
  ------------------
  |  Branch (414:21): [True: 35, False: 1.22k]
  ------------------
  415|  1.22k|                v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  416|  1.22k|            }
  417|  2.57k|        }
  418|  1.48k|        if ((i_a < st_a) && (i_b < st_b))
  ------------------
  |  Branch (418:13): [True: 1.35k, False: 130]
  |  Branch (418:29): [True: 1.31k, False: 35]
  ------------------
  419|  41.2k|            while (true) {
  ------------------
  |  Branch (419:20): [True: 41.2k, Folded]
  ------------------
  420|  41.2k|                const __m128i res_v = _mm_cmpistrm(
  421|  41.2k|                    v_b, v_a,
  422|  41.2k|                    _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  423|  41.2k|                const int r = _mm_extract_epi32(res_v, 0);
  424|  41.2k|                __m128i sm16 =
  425|  41.2k|                    _mm_loadu_si128((const __m128i *)shuffle_mask16 + r);
  426|  41.2k|                __m128i p = _mm_shuffle_epi8(v_a, sm16);
  427|  41.2k|                _mm_storeu_si128((__m128i *)&C[count], p);  // can overflow
  428|  41.2k|                count += _mm_popcnt_u32(r);
  429|  41.2k|                const uint16_t a_max = A[i_a + vectorlength - 1];
  430|  41.2k|                const uint16_t b_max = B[i_b + vectorlength - 1];
  431|  41.2k|                if (a_max <= b_max) {
  ------------------
  |  Branch (431:21): [True: 18.5k, False: 22.7k]
  ------------------
  432|  18.5k|                    i_a += vectorlength;
  433|  18.5k|                    if (i_a == st_a) break;
  ------------------
  |  Branch (433:25): [True: 755, False: 17.7k]
  ------------------
  434|  17.7k|                    v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  435|  17.7k|                }
  436|  40.5k|                if (b_max <= a_max) {
  ------------------
  |  Branch (436:21): [True: 24.2k, False: 16.3k]
  ------------------
  437|  24.2k|                    i_b += vectorlength;
  438|  24.2k|                    if (i_b == st_b) break;
  ------------------
  |  Branch (438:25): [True: 562, False: 23.6k]
  ------------------
  439|  23.6k|                    v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  440|  23.6k|                }
  441|  40.5k|            }
  442|  1.48k|    }
  443|       |    // intersect the tail using scalar intersection
  444|  28.7k|    while (i_a < s_a && i_b < s_b) {
  ------------------
  |  Branch (444:12): [True: 27.3k, False: 1.38k]
  |  Branch (444:25): [True: 26.9k, False: 378]
  ------------------
  445|  26.9k|        uint16_t a = A[i_a];
  446|  26.9k|        uint16_t b = B[i_b];
  447|  26.9k|        if (a < b) {
  ------------------
  |  Branch (447:13): [True: 11.4k, False: 15.5k]
  ------------------
  448|  11.4k|            i_a++;
  449|  15.5k|        } else if (b < a) {
  ------------------
  |  Branch (449:20): [True: 9.95k, False: 5.57k]
  ------------------
  450|  9.95k|            i_b++;
  451|  9.95k|        } else {
  452|  5.57k|            C[count] = a;  //==b;
  453|  5.57k|            count++;
  454|  5.57k|            i_a++;
  455|  5.57k|            i_b++;
  456|  5.57k|        }
  457|  26.9k|    }
  458|  1.76k|    return (int32_t)count;
  459|  1.76k|}
array_container_to_uint32_array_vector16:
  464|  5.62k|                                             uint32_t base) {
  465|  5.62k|    int outpos = 0;
  466|  5.62k|    uint32_t *out = (uint32_t *)vout;
  467|  5.62k|    size_t i = 0;
  468|   183k|    for (; i + sizeof(__m128i) / sizeof(uint16_t) <= cardinality;
  ------------------
  |  Branch (468:12): [True: 177k, False: 5.62k]
  ------------------
  469|   177k|         i += sizeof(__m128i) / sizeof(uint16_t)) {
  470|   177k|        __m128i vinput = _mm_loadu_si128((const __m128i *)(array + i));
  471|   177k|        __m256i voutput = _mm256_add_epi32(_mm256_cvtepu16_epi32(vinput),
  472|   177k|                                           _mm256_set1_epi32(base));
  473|   177k|        _mm256_storeu_si256((__m256i *)(out + outpos), voutput);
  474|   177k|        outpos += sizeof(__m256i) / sizeof(uint32_t);
  475|   177k|    }
  476|  19.7k|    for (; i < cardinality; ++i) {
  ------------------
  |  Branch (476:12): [True: 14.1k, False: 5.62k]
  ------------------
  477|  14.1k|        const uint32_t val = base + array[i];
  478|  14.1k|        memcpy(out + outpos, &val,
  479|  14.1k|               sizeof(uint32_t));  // should be compiled as a MOV on x64
  480|  14.1k|        outpos++;
  481|  14.1k|    }
  482|  5.62k|    return outpos;
  483|  5.62k|}
intersect_vector16_inplace:
  486|  4.36k|                                   size_t s_b) {
  487|  4.36k|    size_t count = 0;
  488|  4.36k|    size_t i_a = 0, i_b = 0;
  489|  4.36k|    const int vectorlength = sizeof(__m128i) / sizeof(uint16_t);
  490|  4.36k|    const size_t st_a = (s_a / vectorlength) * vectorlength;
  491|  4.36k|    const size_t st_b = (s_b / vectorlength) * vectorlength;
  492|  4.36k|    __m128i v_a, v_b;
  493|  4.36k|    if ((i_a < st_a) && (i_b < st_b)) {
  ------------------
  |  Branch (493:9): [True: 2.26k, False: 2.10k]
  |  Branch (493:25): [True: 2.07k, False: 185]
  ------------------
  494|  2.07k|        v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  495|  2.07k|        v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  496|  2.07k|        __m128i tmp[2] = {_mm_setzero_si128()};
  497|  2.07k|        size_t tmp_count = 0;
  498|  4.08k|        while ((A[i_a] == 0) || (B[i_b] == 0)) {
  ------------------
  |  Branch (498:16): [True: 1.83k, False: 2.25k]
  |  Branch (498:33): [True: 286, False: 1.96k]
  ------------------
  499|  2.11k|            const __m128i res_v = _mm_cmpestrm(
  500|  2.11k|                v_b, vectorlength, v_a, vectorlength,
  501|  2.11k|                _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  502|  2.11k|            const int r = _mm_extract_epi32(res_v, 0);
  503|  2.11k|            __m128i sm16 = _mm_loadu_si128((const __m128i *)shuffle_mask16 + r);
  504|  2.11k|            __m128i p = _mm_shuffle_epi8(v_a, sm16);
  505|  2.11k|            _mm_storeu_si128((__m128i *)&((uint16_t *)tmp)[tmp_count], p);
  506|  2.11k|            tmp_count += _mm_popcnt_u32(r);
  507|  2.11k|            const uint16_t a_max = A[i_a + vectorlength - 1];
  508|  2.11k|            const uint16_t b_max = B[i_b + vectorlength - 1];
  509|  2.11k|            if (a_max <= b_max) {
  ------------------
  |  Branch (509:17): [True: 1.98k, False: 136]
  ------------------
  510|  1.98k|                _mm_storeu_si128((__m128i *)&A[count], tmp[0]);
  511|  1.98k|                _mm_storeu_si128(tmp, _mm_setzero_si128());
  512|  1.98k|                count += tmp_count;
  513|  1.98k|                tmp_count = 0;
  514|  1.98k|                i_a += vectorlength;
  515|  1.98k|                if (i_a == st_a) break;
  ------------------
  |  Branch (515:21): [True: 105, False: 1.87k]
  ------------------
  516|  1.87k|                v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  517|  1.87k|            }
  518|  2.01k|            if (b_max <= a_max) {
  ------------------
  |  Branch (518:17): [True: 327, False: 1.68k]
  ------------------
  519|    327|                i_b += vectorlength;
  520|    327|                if (i_b == st_b) break;
  ------------------
  |  Branch (520:21): [True: 9, False: 318]
  ------------------
  521|    318|                v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  522|    318|            }
  523|  2.01k|        }
  524|  2.07k|        if ((i_a < st_a) && (i_b < st_b)) {
  ------------------
  |  Branch (524:13): [True: 1.97k, False: 105]
  |  Branch (524:29): [True: 1.96k, False: 9]
  ------------------
  525|   220k|            while (true) {
  ------------------
  |  Branch (525:20): [True: 220k, Folded]
  ------------------
  526|   220k|                const __m128i res_v = _mm_cmpistrm(
  527|   220k|                    v_b, v_a,
  528|   220k|                    _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  529|   220k|                const int r = _mm_extract_epi32(res_v, 0);
  530|   220k|                __m128i sm16 =
  531|   220k|                    _mm_loadu_si128((const __m128i *)shuffle_mask16 + r);
  532|   220k|                __m128i p = _mm_shuffle_epi8(v_a, sm16);
  533|   220k|                _mm_storeu_si128((__m128i *)&((uint16_t *)tmp)[tmp_count], p);
  534|   220k|                tmp_count += _mm_popcnt_u32(r);
  535|   220k|                const uint16_t a_max = A[i_a + vectorlength - 1];
  536|   220k|                const uint16_t b_max = B[i_b + vectorlength - 1];
  537|   220k|                if (a_max <= b_max) {
  ------------------
  |  Branch (537:21): [True: 129k, False: 91.0k]
  ------------------
  538|   129k|                    _mm_storeu_si128((__m128i *)&A[count], tmp[0]);
  539|   129k|                    _mm_storeu_si128(tmp, _mm_setzero_si128());
  540|   129k|                    count += tmp_count;
  541|   129k|                    tmp_count = 0;
  542|   129k|                    i_a += vectorlength;
  543|   129k|                    if (i_a == st_a) break;
  ------------------
  |  Branch (543:25): [True: 1.05k, False: 128k]
  ------------------
  544|   128k|                    v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  545|   128k|                }
  546|   219k|                if (b_max <= a_max) {
  ------------------
  |  Branch (546:21): [True: 123k, False: 95.9k]
  ------------------
  547|   123k|                    i_b += vectorlength;
  548|   123k|                    if (i_b == st_b) break;
  ------------------
  |  Branch (548:25): [True: 912, False: 122k]
  ------------------
  549|   122k|                    v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  550|   122k|                }
  551|   219k|            }
  552|  1.96k|        }
  553|       |        // tmp_count <= 8, so this does not affect efficiency so much
  554|  4.57k|        for (size_t i = 0; i < tmp_count; i++) {
  ------------------
  |  Branch (554:28): [True: 2.49k, False: 2.07k]
  ------------------
  555|  2.49k|            A[count] = ((uint16_t *)tmp)[i];
  556|  2.49k|            count++;
  557|  2.49k|        }
  558|  2.07k|        i_a += tmp_count;  // We can at least jump pass $tmp_count elements in A
  559|  2.07k|    }
  560|       |    // intersect the tail using scalar intersection
  561|  33.2k|    while (i_a < s_a && i_b < s_b) {
  ------------------
  |  Branch (561:12): [True: 29.3k, False: 3.93k]
  |  Branch (561:25): [True: 28.8k, False: 433]
  ------------------
  562|  28.8k|        uint16_t a = A[i_a];
  563|  28.8k|        uint16_t b = B[i_b];
  564|  28.8k|        if (a < b) {
  ------------------
  |  Branch (564:13): [True: 10.2k, False: 18.6k]
  ------------------
  565|  10.2k|            i_a++;
  566|  18.6k|        } else if (b < a) {
  ------------------
  |  Branch (566:20): [True: 7.06k, False: 11.5k]
  ------------------
  567|  7.06k|            i_b++;
  568|  11.5k|        } else {
  569|  11.5k|            A[count] = a;  //==b;
  570|  11.5k|            count++;
  571|  11.5k|            i_a++;
  572|  11.5k|            i_b++;
  573|  11.5k|        }
  574|  28.8k|    }
  575|  4.36k|    return (int32_t)count;
  576|  4.36k|}
intersect_vector16_cardinality:
  581|  7.06k|                                       const uint16_t *B, size_t s_b) {
  582|  7.06k|    size_t count = 0;
  583|  7.06k|    size_t i_a = 0, i_b = 0;
  584|  7.06k|    const int vectorlength = sizeof(__m128i) / sizeof(uint16_t);
  585|  7.06k|    const size_t st_a = (s_a / vectorlength) * vectorlength;
  586|  7.06k|    const size_t st_b = (s_b / vectorlength) * vectorlength;
  587|  7.06k|    __m128i v_a, v_b;
  588|  7.06k|    if ((i_a < st_a) && (i_b < st_b)) {
  ------------------
  |  Branch (588:9): [True: 6.52k, False: 540]
  |  Branch (588:25): [True: 5.92k, False: 596]
  ------------------
  589|  5.92k|        v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  590|  5.92k|        v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  591|  16.0k|        while ((A[i_a] == 0) || (B[i_b] == 0)) {
  ------------------
  |  Branch (591:16): [True: 10.0k, False: 5.99k]
  |  Branch (591:33): [True: 728, False: 5.26k]
  ------------------
  592|  10.8k|            const __m128i res_v = _mm_cmpestrm(
  593|  10.8k|                v_b, vectorlength, v_a, vectorlength,
  594|  10.8k|                _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  595|  10.8k|            const int r = _mm_extract_epi32(res_v, 0);
  596|  10.8k|            count += _mm_popcnt_u32(r);
  597|  10.8k|            const uint16_t a_max = A[i_a + vectorlength - 1];
  598|  10.8k|            const uint16_t b_max = B[i_b + vectorlength - 1];
  599|  10.8k|            if (a_max <= b_max) {
  ------------------
  |  Branch (599:17): [True: 6.04k, False: 4.76k]
  ------------------
  600|  6.04k|                i_a += vectorlength;
  601|  6.04k|                if (i_a == st_a) break;
  ------------------
  |  Branch (601:21): [True: 520, False: 5.52k]
  ------------------
  602|  5.52k|                v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  603|  5.52k|            }
  604|  10.2k|            if (b_max <= a_max) {
  ------------------
  |  Branch (604:17): [True: 5.03k, False: 5.25k]
  ------------------
  605|  5.03k|                i_b += vectorlength;
  606|  5.03k|                if (i_b == st_b) break;
  ------------------
  |  Branch (606:21): [True: 140, False: 4.89k]
  ------------------
  607|  4.89k|                v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  608|  4.89k|            }
  609|  10.2k|        }
  610|  5.92k|        if ((i_a < st_a) && (i_b < st_b))
  ------------------
  |  Branch (610:13): [True: 5.40k, False: 520]
  |  Branch (610:29): [True: 5.26k, False: 140]
  ------------------
  611|   165k|            while (true) {
  ------------------
  |  Branch (611:20): [True: 165k, Folded]
  ------------------
  612|   165k|                const __m128i res_v = _mm_cmpistrm(
  613|   165k|                    v_b, v_a,
  614|   165k|                    _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  615|   165k|                const int r = _mm_extract_epi32(res_v, 0);
  616|   165k|                count += _mm_popcnt_u32(r);
  617|   165k|                const uint16_t a_max = A[i_a + vectorlength - 1];
  618|   165k|                const uint16_t b_max = B[i_b + vectorlength - 1];
  619|   165k|                if (a_max <= b_max) {
  ------------------
  |  Branch (619:21): [True: 74.0k, False: 91.1k]
  ------------------
  620|  74.0k|                    i_a += vectorlength;
  621|  74.0k|                    if (i_a == st_a) break;
  ------------------
  |  Branch (621:25): [True: 3.02k, False: 71.0k]
  ------------------
  622|  71.0k|                    v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  623|  71.0k|                }
  624|   162k|                if (b_max <= a_max) {
  ------------------
  |  Branch (624:21): [True: 96.8k, False: 65.2k]
  ------------------
  625|  96.8k|                    i_b += vectorlength;
  626|  96.8k|                    if (i_b == st_b) break;
  ------------------
  |  Branch (626:25): [True: 2.24k, False: 94.6k]
  ------------------
  627|  94.6k|                    v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  628|  94.6k|                }
  629|   162k|            }
  630|  5.92k|    }
  631|       |    // intersect the tail using scalar intersection
  632|   114k|    while (i_a < s_a && i_b < s_b) {
  ------------------
  |  Branch (632:12): [True: 109k, False: 5.55k]
  |  Branch (632:25): [True: 107k, False: 1.51k]
  ------------------
  633|   107k|        uint16_t a = A[i_a];
  634|   107k|        uint16_t b = B[i_b];
  635|   107k|        if (a < b) {
  ------------------
  |  Branch (635:13): [True: 45.6k, False: 62.1k]
  ------------------
  636|  45.6k|            i_a++;
  637|  62.1k|        } else if (b < a) {
  ------------------
  |  Branch (637:20): [True: 39.8k, False: 22.2k]
  ------------------
  638|  39.8k|            i_b++;
  639|  39.8k|        } else {
  640|  22.2k|            count++;
  641|  22.2k|            i_a++;
  642|  22.2k|            i_b++;
  643|  22.2k|        }
  644|   107k|    }
  645|  7.06k|    return (int32_t)count;
  646|  7.06k|}
difference_vector16:
  655|  2.30k|                            size_t s_b, uint16_t *C) {
  656|       |    // we handle the degenerate case
  657|  2.30k|    if (s_a == 0) return 0;
  ------------------
  |  Branch (657:9): [True: 0, False: 2.30k]
  ------------------
  658|  2.30k|    if (s_b == 0) {
  ------------------
  |  Branch (658:9): [True: 0, False: 2.30k]
  ------------------
  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.30k|    int32_t count = 0;
  665|  2.30k|    if ((A[0] == 0) || (B[0] == 0)) {
  ------------------
  |  Branch (665:9): [True: 2.11k, False: 186]
  |  Branch (665:24): [True: 4, False: 182]
  ------------------
  666|  2.12k|        if ((A[0] == 0) && (B[0] == 0)) {
  ------------------
  |  Branch (666:13): [True: 2.11k, False: 4]
  |  Branch (666:28): [True: 291, False: 1.82k]
  ------------------
  667|    291|            A++;
  668|    291|            s_a--;
  669|    291|            B++;
  670|    291|            s_b--;
  671|  1.83k|        } else if (A[0] == 0) {
  ------------------
  |  Branch (671:20): [True: 1.82k, False: 4]
  ------------------
  672|  1.82k|            C[count++] = 0;
  673|  1.82k|            A++;
  674|  1.82k|            s_a--;
  675|  1.82k|        } else {
  676|      4|            B++;
  677|      4|            s_b--;
  678|      4|        }
  679|  2.12k|    }
  680|       |    // at this point, we have two non-empty arrays, made of non-zero
  681|       |    // increasing values.
  682|  2.30k|    size_t i_a = 0, i_b = 0;
  683|  2.30k|    const size_t vectorlength = sizeof(__m128i) / sizeof(uint16_t);
  684|  2.30k|    const size_t st_a = (s_a / vectorlength) * vectorlength;
  685|  2.30k|    const size_t st_b = (s_b / vectorlength) * vectorlength;
  686|  2.30k|    if ((i_a < st_a) && (i_b < st_b)) {  // this is the vectorized code path
  ------------------
  |  Branch (686:9): [True: 1.89k, False: 411]
  |  Branch (686:25): [True: 1.60k, False: 293]
  ------------------
  687|  1.60k|        __m128i v_a, v_b;                //, v_bmax;
  688|       |        // we load a vector from A and a vector from B
  689|  1.60k|        v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  690|  1.60k|        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.60k|        __m128i runningmask_a_found_in_b = _mm_setzero_si128();
  694|       |        /****
  695|       |         * start of the main vectorized loop
  696|       |         *****/
  697|  45.1k|        while (true) {
  ------------------
  |  Branch (697:16): [True: 45.1k, Folded]
  ------------------
  698|       |            // afoundinb will contain a mask indicate for each entry in A
  699|       |            // whether it is seen
  700|       |            // in B
  701|  45.1k|            const __m128i a_found_in_b = _mm_cmpistrm(
  702|  45.1k|                v_b, v_a,
  703|  45.1k|                _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  704|  45.1k|            runningmask_a_found_in_b =
  705|  45.1k|                _mm_or_si128(runningmask_a_found_in_b, a_found_in_b);
  706|       |            // we always compare the last values of A and B
  707|  45.1k|            const uint16_t a_max = A[i_a + vectorlength - 1];
  708|  45.1k|            const uint16_t b_max = B[i_b + vectorlength - 1];
  709|  45.1k|            if (a_max <= b_max) {
  ------------------
  |  Branch (709:17): [True: 20.4k, False: 24.7k]
  ------------------
  710|       |                // Ok. In this code path, we are ready to write our v_a
  711|       |                // because there is no need to read more from B, they will
  712|       |                // all be large values.
  713|  20.4k|                const int bitmask_belongs_to_difference =
  714|  20.4k|                    _mm_extract_epi32(runningmask_a_found_in_b, 0) ^ 0xFF;
  715|       |                /*** next few lines are probably expensive *****/
  716|  20.4k|                __m128i sm16 = _mm_loadu_si128((const __m128i *)shuffle_mask16 +
  717|  20.4k|                                               bitmask_belongs_to_difference);
  718|  20.4k|                __m128i p = _mm_shuffle_epi8(v_a, sm16);
  719|  20.4k|                _mm_storeu_si128((__m128i *)&C[count], p);  // can overflow
  720|  20.4k|                count += _mm_popcnt_u32(bitmask_belongs_to_difference);
  721|       |                // we advance a
  722|  20.4k|                i_a += vectorlength;
  723|  20.4k|                if (i_a == st_a)  // no more
  ------------------
  |  Branch (723:21): [True: 1.12k, False: 19.2k]
  ------------------
  724|  1.12k|                    break;
  725|  19.2k|                runningmask_a_found_in_b = _mm_setzero_si128();
  726|  19.2k|                v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  727|  19.2k|            }
  728|  44.0k|            if (b_max <= a_max) {
  ------------------
  |  Branch (728:17): [True: 27.7k, False: 16.3k]
  ------------------
  729|       |                // in this code path, the current v_b has become useless
  730|  27.7k|                i_b += vectorlength;
  731|  27.7k|                if (i_b == st_b) break;
  ------------------
  |  Branch (731:21): [True: 474, False: 27.2k]
  ------------------
  732|  27.2k|                v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  733|  27.2k|            }
  734|  44.0k|        }
  735|       |        // at this point, either we have i_a == st_a, which is the end of the
  736|       |        // vectorized processing,
  737|       |        // or we have i_b == st_b,  and we are not done processing the vector...
  738|       |        // so we need to finish it off.
  739|  1.60k|        if (i_a < st_a) {        // we have unfinished business...
  ------------------
  |  Branch (739:13): [True: 474, False: 1.12k]
  ------------------
  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.60k|    }
  760|       |    // do the tail using scalar code
  761|   107k|    while (i_a < s_a && i_b < s_b) {
  ------------------
  |  Branch (761:12): [True: 105k, False: 1.78k]
  |  Branch (761:25): [True: 105k, False: 520]
  ------------------
  762|   105k|        uint16_t a = A[i_a];
  763|   105k|        uint16_t b = B[i_b];
  764|   105k|        if (b < a) {
  ------------------
  |  Branch (764:13): [True: 72.9k, False: 32.1k]
  ------------------
  765|  72.9k|            i_b++;
  766|  72.9k|        } else if (a < b) {
  ------------------
  |  Branch (766:20): [True: 26.6k, False: 5.51k]
  ------------------
  767|  26.6k|            C[count] = a;
  768|  26.6k|            count++;
  769|  26.6k|            i_a++;
  770|  26.6k|        } else {  //==
  771|  5.51k|            i_a++;
  772|  5.51k|            i_b++;
  773|  5.51k|        }
  774|   105k|    }
  775|  2.30k|    if (i_a < s_a) {
  ------------------
  |  Branch (775:9): [True: 520, False: 1.78k]
  ------------------
  776|    520|        if (C == A) {
  ------------------
  |  Branch (776:13): [True: 0, False: 520]
  ------------------
  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|    520|        } else {
  782|  26.8k|            for (size_t i = 0; i < (s_a - i_a); i++) {
  ------------------
  |  Branch (782:32): [True: 26.3k, False: 520]
  ------------------
  783|  26.3k|                C[count + i] = A[i + i_a];
  784|  26.3k|            }
  785|    520|        }
  786|    520|        count += (int32_t)(s_a - i_a);
  787|    520|    }
  788|  2.30k|    return count;
  789|  2.30k|}
intersect_skewed_uint16:
  855|    743|                                uint16_t *buffer) {
  856|    743|    size_t pos = 0, idx_l = 0, idx_s = 0;
  857|       |
  858|    743|    if (0 == size_s) {
  ------------------
  |  Branch (858:9): [True: 0, False: 743]
  ------------------
  859|      0|        return 0;
  860|      0|    }
  861|    743|    int32_t index1 = 0, index2 = 0, index3 = 0, index4 = 0;
  862|  2.10k|    while ((idx_s + 4 <= size_s) && (idx_l < size_l)) {
  ------------------
  |  Branch (862:12): [True: 1.36k, False: 742]
  |  Branch (862:37): [True: 1.36k, False: 1]
  ------------------
  863|  1.36k|        uint16_t target1 = small[idx_s];
  864|  1.36k|        uint16_t target2 = small[idx_s + 1];
  865|  1.36k|        uint16_t target3 = small[idx_s + 2];
  866|  1.36k|        uint16_t target4 = small[idx_s + 3];
  867|  1.36k|        binarySearch4(large + idx_l, (int32_t)(size_l - idx_l), target1,
  868|  1.36k|                      target2, target3, target4, &index1, &index2, &index3,
  869|  1.36k|                      &index4);
  870|  1.36k|        if ((index1 + idx_l < size_l) && (large[idx_l + index1] == target1)) {
  ------------------
  |  Branch (870:13): [True: 1.36k, False: 1]
  |  Branch (870:42): [True: 681, False: 680]
  ------------------
  871|    681|            buffer[pos++] = target1;
  872|    681|        }
  873|  1.36k|        if ((index2 + idx_l < size_l) && (large[idx_l + index2] == target2)) {
  ------------------
  |  Branch (873:13): [True: 1.36k, False: 2]
  |  Branch (873:42): [True: 841, False: 519]
  ------------------
  874|    841|            buffer[pos++] = target2;
  875|    841|        }
  876|  1.36k|        if ((index3 + idx_l < size_l) && (large[idx_l + index3] == target3)) {
  ------------------
  |  Branch (876:13): [True: 1.35k, False: 3]
  |  Branch (876:42): [True: 822, False: 537]
  ------------------
  877|    822|            buffer[pos++] = target3;
  878|    822|        }
  879|  1.36k|        if ((index4 + idx_l < size_l) && (large[idx_l + index4] == target4)) {
  ------------------
  |  Branch (879:13): [True: 1.35k, False: 6]
  |  Branch (879:42): [True: 804, False: 552]
  ------------------
  880|    804|            buffer[pos++] = target4;
  881|    804|        }
  882|  1.36k|        idx_s += 4;
  883|  1.36k|        idx_l += index4;
  884|  1.36k|    }
  885|    743|    if ((idx_s + 2 <= size_s) && (idx_l < size_l)) {
  ------------------
  |  Branch (885:9): [True: 383, False: 360]
  |  Branch (885:34): [True: 381, False: 2]
  ------------------
  886|    381|        uint16_t target1 = small[idx_s];
  887|    381|        uint16_t target2 = small[idx_s + 1];
  888|    381|        binarySearch2(large + idx_l, (int32_t)(size_l - idx_l), target1,
  889|    381|                      target2, &index1, &index2);
  890|    381|        if ((index1 + idx_l < size_l) && (large[idx_l + index1] == target1)) {
  ------------------
  |  Branch (890:13): [True: 375, False: 6]
  |  Branch (890:42): [True: 239, False: 136]
  ------------------
  891|    239|            buffer[pos++] = target1;
  892|    239|        }
  893|    381|        if ((index2 + idx_l < size_l) && (large[idx_l + index2] == target2)) {
  ------------------
  |  Branch (893:13): [True: 365, False: 16]
  |  Branch (893:42): [True: 241, False: 124]
  ------------------
  894|    241|            buffer[pos++] = target2;
  895|    241|        }
  896|    381|        idx_s += 2;
  897|    381|        idx_l += index2;
  898|    381|    }
  899|    743|    if ((idx_s < size_s) && (idx_l < size_l)) {
  ------------------
  |  Branch (899:9): [True: 356, False: 387]
  |  Branch (899:29): [True: 353, False: 3]
  ------------------
  900|    353|        uint16_t val_s = small[idx_s];
  901|    353|        int32_t index =
  902|    353|            binarySearch(large + idx_l, (int32_t)(size_l - idx_l), val_s);
  903|    353|        if (index >= 0) buffer[pos++] = val_s;
  ------------------
  |  Branch (903:13): [True: 247, False: 106]
  ------------------
  904|    353|    }
  905|    743|    return (int32_t)pos;
  906|    743|}
intersect_skewed_uint16_cardinality:
  912|  2.15k|                                            size_t size_l) {
  913|  2.15k|    size_t pos = 0, idx_l = 0, idx_s = 0;
  914|       |
  915|  2.15k|    if (0 == size_s) {
  ------------------
  |  Branch (915:9): [True: 0, False: 2.15k]
  ------------------
  916|      0|        return 0;
  917|      0|    }
  918|       |
  919|  2.15k|    uint16_t val_l = large[idx_l], val_s = small[idx_s];
  920|       |
  921|  30.5k|    while (true) {
  ------------------
  |  Branch (921:12): [True: 30.5k, Folded]
  ------------------
  922|  30.5k|        if (val_l < val_s) {
  ------------------
  |  Branch (922:13): [True: 6.08k, False: 24.4k]
  ------------------
  923|  6.08k|            idx_l = advanceUntil(large, (int32_t)idx_l, (int32_t)size_l, val_s);
  924|  6.08k|            if (idx_l == size_l) break;
  ------------------
  |  Branch (924:17): [True: 140, False: 5.94k]
  ------------------
  925|  5.94k|            val_l = large[idx_l];
  926|  24.4k|        } else if (val_s < val_l) {
  ------------------
  |  Branch (926:20): [True: 10.4k, False: 13.9k]
  ------------------
  927|  10.4k|            idx_s++;
  928|  10.4k|            if (idx_s == size_s) break;
  ------------------
  |  Branch (928:17): [True: 840, False: 9.65k]
  ------------------
  929|  9.65k|            val_s = small[idx_s];
  930|  13.9k|        } else {
  931|  13.9k|            pos++;
  932|  13.9k|            idx_s++;
  933|  13.9k|            if (idx_s == size_s) break;
  ------------------
  |  Branch (933:17): [True: 1.10k, False: 12.8k]
  ------------------
  934|  12.8k|            val_s = small[idx_s];
  935|  12.8k|            idx_l = advanceUntil(large, (int32_t)idx_l, (int32_t)size_l, val_s);
  936|  12.8k|            if (idx_l == size_l) break;
  ------------------
  |  Branch (936:17): [True: 72, False: 12.7k]
  ------------------
  937|  12.7k|            val_l = large[idx_l];
  938|  12.7k|        }
  939|  30.5k|    }
  940|       |
  941|  2.15k|    return (int32_t)pos;
  942|  2.15k|}
intersect_skewed_uint16_nonempty:
  945|    538|                                      const uint16_t *large, size_t size_l) {
  946|    538|    size_t idx_l = 0, idx_s = 0;
  947|       |
  948|    538|    if (0 == size_s) {
  ------------------
  |  Branch (948:9): [True: 0, False: 538]
  ------------------
  949|      0|        return false;
  950|      0|    }
  951|       |
  952|    538|    uint16_t val_l = large[idx_l], val_s = small[idx_s];
  953|       |
  954|  2.06k|    while (true) {
  ------------------
  |  Branch (954:12): [True: 2.06k, Folded]
  ------------------
  955|  2.06k|        if (val_l < val_s) {
  ------------------
  |  Branch (955:13): [True: 793, False: 1.26k]
  ------------------
  956|    793|            idx_l = advanceUntil(large, (int32_t)idx_l, (int32_t)size_l, val_s);
  957|    793|            if (idx_l == size_l) break;
  ------------------
  |  Branch (957:17): [True: 34, False: 759]
  ------------------
  958|    759|            val_l = large[idx_l];
  959|  1.26k|        } else if (val_s < val_l) {
  ------------------
  |  Branch (959:20): [True: 845, False: 423]
  ------------------
  960|    845|            idx_s++;
  961|    845|            if (idx_s == size_s) break;
  ------------------
  |  Branch (961:17): [True: 81, False: 764]
  ------------------
  962|    764|            val_s = small[idx_s];
  963|    764|        } else {
  964|    423|            return true;
  965|    423|        }
  966|  2.06k|    }
  967|       |
  968|    115|    return false;
  969|    538|}
intersect_uint16_nonempty:
 1025|  1.76k|                               const uint16_t *B, const size_t lenB) {
 1026|  1.76k|    if (lenA == 0 || lenB == 0) return 0;
  ------------------
  |  Branch (1026:9): [True: 0, False: 1.76k]
  |  Branch (1026:22): [True: 0, False: 1.76k]
  ------------------
 1027|  1.76k|    const uint16_t *endA = A + lenA;
 1028|  1.76k|    const uint16_t *endB = B + lenB;
 1029|       |
 1030|  1.76k|    while (1) {
  ------------------
  |  Branch (1030:12): [True: 1.76k, Folded]
  ------------------
 1031|  9.93k|        while (*A < *B) {
  ------------------
  |  Branch (1031:16): [True: 7.74k, False: 2.19k]
  ------------------
 1032|  8.21k|        SKIP_FIRST_COMPARE:
 1033|  8.21k|            if (++A == endA) return false;
  ------------------
  |  Branch (1033:17): [True: 44, False: 8.17k]
  ------------------
 1034|  8.21k|        }
 1035|  4.55k|        while (*A > *B) {
  ------------------
  |  Branch (1035:16): [True: 2.37k, False: 2.18k]
  ------------------
 1036|  2.37k|            if (++B == endB) return false;
  ------------------
  |  Branch (1036:17): [True: 8, False: 2.36k]
  ------------------
 1037|  2.37k|        }
 1038|  2.18k|        if (*A == *B) {
  ------------------
  |  Branch (1038:13): [True: 1.71k, False: 469]
  ------------------
 1039|  1.71k|            return true;
 1040|  1.71k|        } else {
 1041|    469|            goto SKIP_FIRST_COMPARE;
 1042|    469|        }
 1043|  2.18k|    }
 1044|      0|    return false;  // NOTREACHED
 1045|  1.76k|}
union_uint16:
 1105|  4.59k|                    size_t size_2, uint16_t *buffer) {
 1106|  4.59k|    size_t pos = 0, idx_1 = 0, idx_2 = 0;
 1107|       |
 1108|  4.59k|    if (0 == size_2) {
  ------------------
  |  Branch (1108:9): [True: 60, False: 4.53k]
  ------------------
 1109|     60|        memmove(buffer, set_1, size_1 * sizeof(uint16_t));
 1110|     60|        return size_1;
 1111|     60|    }
 1112|  4.53k|    if (0 == size_1) {
  ------------------
  |  Branch (1112:9): [True: 0, False: 4.53k]
  ------------------
 1113|      0|        memmove(buffer, set_2, size_2 * sizeof(uint16_t));
 1114|      0|        return size_2;
 1115|      0|    }
 1116|       |
 1117|  4.53k|    uint16_t val_1 = set_1[idx_1], val_2 = set_2[idx_2];
 1118|       |
 1119|   209k|    while (true) {
  ------------------
  |  Branch (1119:12): [True: 209k, Folded]
  ------------------
 1120|   209k|        if (val_1 < val_2) {
  ------------------
  |  Branch (1120:13): [True: 7.94k, False: 201k]
  ------------------
 1121|  7.94k|            buffer[pos++] = val_1;
 1122|  7.94k|            ++idx_1;
 1123|  7.94k|            if (idx_1 >= size_1) break;
  ------------------
  |  Branch (1123:17): [True: 391, False: 7.55k]
  ------------------
 1124|  7.55k|            val_1 = set_1[idx_1];
 1125|   201k|        } else if (val_2 < val_1) {
  ------------------
  |  Branch (1125:20): [True: 169k, False: 31.3k]
  ------------------
 1126|   169k|            buffer[pos++] = val_2;
 1127|   169k|            ++idx_2;
 1128|   169k|            if (idx_2 >= size_2) break;
  ------------------
  |  Branch (1128:17): [True: 201, False: 169k]
  ------------------
 1129|   169k|            val_2 = set_2[idx_2];
 1130|   169k|        } else {
 1131|  31.3k|            buffer[pos++] = val_1;
 1132|  31.3k|            ++idx_1;
 1133|  31.3k|            ++idx_2;
 1134|  31.3k|            if (idx_1 >= size_1 || idx_2 >= size_2) break;
  ------------------
  |  Branch (1134:17): [True: 3.81k, False: 27.5k]
  |  Branch (1134:36): [True: 121, False: 27.4k]
  ------------------
 1135|  27.4k|            val_1 = set_1[idx_1];
 1136|  27.4k|            val_2 = set_2[idx_2];
 1137|  27.4k|        }
 1138|   209k|    }
 1139|       |
 1140|  4.53k|    if (idx_1 < size_1) {
  ------------------
  |  Branch (1140:9): [True: 322, False: 4.20k]
  ------------------
 1141|    322|        const size_t n_elems = size_1 - idx_1;
 1142|    322|        memmove(buffer + pos, set_1 + idx_1, n_elems * sizeof(uint16_t));
 1143|    322|        pos += n_elems;
 1144|  4.20k|    } else if (idx_2 < size_2) {
  ------------------
  |  Branch (1144:16): [True: 1.76k, False: 2.44k]
  ------------------
 1145|  1.76k|        const size_t n_elems = size_2 - idx_2;
 1146|  1.76k|        memmove(buffer + pos, set_2 + idx_2, n_elems * sizeof(uint16_t));
 1147|  1.76k|        pos += n_elems;
 1148|  1.76k|    }
 1149|       |
 1150|  4.53k|    return pos;
 1151|  4.53k|}
difference_uint16:
 1154|  3.44k|                      int length2, uint16_t *a_out) {
 1155|  3.44k|    int out_card = 0;
 1156|  3.44k|    int k1 = 0, k2 = 0;
 1157|  3.44k|    if (length1 == 0) return 0;
  ------------------
  |  Branch (1157:9): [True: 0, False: 3.44k]
  ------------------
 1158|  3.44k|    if (length2 == 0) {
  ------------------
  |  Branch (1158:9): [True: 0, False: 3.44k]
  ------------------
 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.44k|    uint16_t s1 = a1[k1];
 1163|  3.44k|    uint16_t s2 = a2[k2];
 1164|   421k|    while (true) {
  ------------------
  |  Branch (1164:12): [True: 421k, Folded]
  ------------------
 1165|   421k|        if (s1 < s2) {
  ------------------
  |  Branch (1165:13): [True: 207k, False: 214k]
  ------------------
 1166|   207k|            a_out[out_card++] = s1;
 1167|   207k|            ++k1;
 1168|   207k|            if (k1 >= length1) {
  ------------------
  |  Branch (1168:17): [True: 0, False: 207k]
  ------------------
 1169|      0|                break;
 1170|      0|            }
 1171|   207k|            s1 = a1[k1];
 1172|   214k|        } else if (s1 == s2) {
  ------------------
  |  Branch (1172:20): [True: 214k, False: 0]
  ------------------
 1173|   214k|            ++k1;
 1174|   214k|            ++k2;
 1175|   214k|            if (k1 >= length1) {
  ------------------
  |  Branch (1175:17): [True: 2.23k, False: 212k]
  ------------------
 1176|  2.23k|                break;
 1177|  2.23k|            }
 1178|   212k|            if (k2 >= length2) {
  ------------------
  |  Branch (1178:17): [True: 1.20k, False: 210k]
  ------------------
 1179|  1.20k|                memmove(a_out + out_card, a1 + k1,
 1180|  1.20k|                        sizeof(uint16_t) * (length1 - k1));
 1181|  1.20k|                return out_card + length1 - k1;
 1182|  1.20k|            }
 1183|   210k|            s1 = a1[k1];
 1184|   210k|            s2 = a2[k2];
 1185|   210k|        } 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|   421k|    }
 1195|  2.23k|    return out_card;
 1196|  3.44k|}
xor_uint16:
 1199|  7.70k|                   const uint16_t *array_2, int32_t card_2, uint16_t *out) {
 1200|  7.70k|    int32_t pos1 = 0, pos2 = 0, pos_out = 0;
 1201|   219k|    while (pos1 < card_1 && pos2 < card_2) {
  ------------------
  |  Branch (1201:12): [True: 212k, False: 7.12k]
  |  Branch (1201:29): [True: 212k, False: 576]
  ------------------
 1202|   212k|        const uint16_t v1 = array_1[pos1];
 1203|   212k|        const uint16_t v2 = array_2[pos2];
 1204|   212k|        if (v1 == v2) {
  ------------------
  |  Branch (1204:13): [True: 38.4k, False: 173k]
  ------------------
 1205|  38.4k|            ++pos1;
 1206|  38.4k|            ++pos2;
 1207|  38.4k|            continue;
 1208|  38.4k|        }
 1209|   173k|        if (v1 < v2) {
  ------------------
  |  Branch (1209:13): [True: 30.3k, False: 143k]
  ------------------
 1210|  30.3k|            out[pos_out++] = v1;
 1211|  30.3k|            ++pos1;
 1212|   143k|        } else {
 1213|   143k|            out[pos_out++] = v2;
 1214|   143k|            ++pos2;
 1215|   143k|        }
 1216|   173k|    }
 1217|  7.70k|    if (pos1 < card_1) {
  ------------------
  |  Branch (1217:9): [True: 576, False: 7.12k]
  ------------------
 1218|    576|        const size_t n_elems = card_1 - pos1;
 1219|    576|        memcpy(out + pos_out, array_1 + pos1, n_elems * sizeof(uint16_t));
 1220|    576|        pos_out += (int32_t)n_elems;
 1221|  7.12k|    } else if (pos2 < card_2) {
  ------------------
  |  Branch (1221:16): [True: 2.27k, False: 4.85k]
  ------------------
 1222|  2.27k|        const size_t n_elems = card_2 - pos2;
 1223|  2.27k|        memcpy(out + pos_out, array_2 + pos2, n_elems * sizeof(uint16_t));
 1224|  2.27k|        pos_out += (int32_t)n_elems;
 1225|  2.27k|    }
 1226|  7.70k|    return pos_out;
 1227|  7.70k|}
union_vector16:
 1664|  4.59k|                        uint16_t *output) {
 1665|  4.59k|    if ((length1 < 8) || (length2 < 8)) {
  ------------------
  |  Branch (1665:9): [True: 1.01k, False: 3.57k]
  |  Branch (1665:26): [True: 0, False: 3.57k]
  ------------------
 1666|  1.01k|        return (uint32_t)union_uint16(array1, length1, array2, length2, output);
 1667|  1.01k|    }
 1668|  3.57k|    __m128i vA, vB, V, vecMin, vecMax;
 1669|  3.57k|    __m128i laststore;
 1670|  3.57k|    uint16_t *initoutput = output;
 1671|  3.57k|    uint32_t len1 = length1 / 8;
 1672|  3.57k|    uint32_t len2 = length2 / 8;
 1673|  3.57k|    uint32_t pos1 = 0;
 1674|  3.57k|    uint32_t pos2 = 0;
 1675|       |    // we start the machine
 1676|  3.57k|    vA = _mm_lddqu_si128((const __m128i *)array1 + pos1);
 1677|  3.57k|    pos1++;
 1678|  3.57k|    vB = _mm_lddqu_si128((const __m128i *)array2 + pos2);
 1679|  3.57k|    pos2++;
 1680|  3.57k|    sse_merge(&vA, &vB, &vecMin, &vecMax);
 1681|  3.57k|    laststore = _mm_set1_epi16(-1);
 1682|  3.57k|    output += store_unique(laststore, vecMin, output);
 1683|  3.57k|    laststore = vecMin;
 1684|  3.57k|    if ((pos1 < len1) && (pos2 < len2)) {
  ------------------
  |  Branch (1684:9): [True: 3.01k, False: 565]
  |  Branch (1684:26): [True: 3.01k, False: 0]
  ------------------
 1685|  3.01k|        uint16_t curA, curB;
 1686|  3.01k|        curA = array1[8 * pos1];
 1687|  3.01k|        curB = array2[8 * pos2];
 1688|   101k|        while (true) {
  ------------------
  |  Branch (1688:16): [True: 101k, Folded]
  ------------------
 1689|   101k|            if (curA <= curB) {
  ------------------
  |  Branch (1689:17): [True: 43.0k, False: 58.0k]
  ------------------
 1690|  43.0k|                V = _mm_lddqu_si128((const __m128i *)array1 + pos1);
 1691|  43.0k|                pos1++;
 1692|  43.0k|                if (pos1 < len1) {
  ------------------
  |  Branch (1692:21): [True: 40.7k, False: 2.30k]
  ------------------
 1693|  40.7k|                    curA = array1[8 * pos1];
 1694|  40.7k|                } else {
 1695|  2.30k|                    break;
 1696|  2.30k|                }
 1697|  58.0k|            } else {
 1698|  58.0k|                V = _mm_lddqu_si128((const __m128i *)array2 + pos2);
 1699|  58.0k|                pos2++;
 1700|  58.0k|                if (pos2 < len2) {
  ------------------
  |  Branch (1700:21): [True: 57.3k, False: 711]
  ------------------
 1701|  57.3k|                    curB = array2[8 * pos2];
 1702|  57.3k|                } else {
 1703|    711|                    break;
 1704|    711|                }
 1705|  58.0k|            }
 1706|  98.0k|            sse_merge(&V, &vecMax, &vecMin, &vecMax);
 1707|  98.0k|            output += store_unique(laststore, vecMin, output);
 1708|  98.0k|            laststore = vecMin;
 1709|  98.0k|        }
 1710|  3.01k|        sse_merge(&V, &vecMax, &vecMin, &vecMax);
 1711|  3.01k|        output += store_unique(laststore, vecMin, output);
 1712|  3.01k|        laststore = vecMin;
 1713|  3.01k|    }
 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.57k|    uint32_t len = (uint32_t)(output - initoutput);
 1719|  3.57k|    uint16_t buffer[16];
 1720|  3.57k|    uint32_t leftoversize = store_unique(laststore, vecMax, buffer);
 1721|  3.57k|    if (pos1 == len1) {
  ------------------
  |  Branch (1721:9): [True: 2.86k, False: 711]
  ------------------
 1722|  2.86k|        memcpy(buffer + leftoversize, array1 + 8 * pos1,
 1723|  2.86k|               (length1 - 8 * len1) * sizeof(uint16_t));
 1724|  2.86k|        leftoversize += length1 - 8 * len1;
 1725|  2.86k|        sort_uint16_short(buffer, leftoversize);
 1726|       |
 1727|  2.86k|        leftoversize = unique(buffer, leftoversize);
 1728|  2.86k|        len += (uint32_t)union_uint16(buffer, leftoversize, array2 + 8 * pos2,
 1729|  2.86k|                                      length2 - 8 * pos2, output);
 1730|  2.86k|    } else {
 1731|    711|        memcpy(buffer + leftoversize, array2 + 8 * pos2,
 1732|    711|               (length2 - 8 * len2) * sizeof(uint16_t));
 1733|    711|        leftoversize += length2 - 8 * len2;
 1734|    711|        sort_uint16_short(buffer, leftoversize);
 1735|    711|        leftoversize = unique(buffer, leftoversize);
 1736|    711|        len += (uint32_t)union_uint16(buffer, leftoversize, array1 + 8 * pos1,
 1737|    711|                                      length1 - 8 * pos1, output);
 1738|    711|    }
 1739|  3.57k|    return len;
 1740|  4.59k|}
xor_vector16:
 1975|  7.71k|                      uint16_t *output) {
 1976|  7.71k|    if ((length1 < 8) || (length2 < 8)) {
  ------------------
  |  Branch (1976:9): [True: 3.03k, False: 4.67k]
  |  Branch (1976:26): [True: 348, False: 4.33k]
  ------------------
 1977|  3.38k|        return xor_uint16(array1, length1, array2, length2, output);
 1978|  3.38k|    }
 1979|  4.33k|    __m128i vA, vB, V, vecMin, vecMax;
 1980|  4.33k|    __m128i laststore;
 1981|  4.33k|    uint16_t *initoutput = output;
 1982|  4.33k|    uint32_t len1 = length1 / 8;
 1983|  4.33k|    uint32_t len2 = length2 / 8;
 1984|  4.33k|    uint32_t pos1 = 0;
 1985|  4.33k|    uint32_t pos2 = 0;
 1986|       |    // we start the machine
 1987|  4.33k|    vA = _mm_lddqu_si128((const __m128i *)array1 + pos1);
 1988|  4.33k|    pos1++;
 1989|  4.33k|    vB = _mm_lddqu_si128((const __m128i *)array2 + pos2);
 1990|  4.33k|    pos2++;
 1991|  4.33k|    sse_merge(&vA, &vB, &vecMin, &vecMax);
 1992|  4.33k|    laststore = _mm_set1_epi16(-1);
 1993|  4.33k|    uint16_t buffer[17];
 1994|  4.33k|    output += store_unique_xor(laststore, vecMin, output);
 1995|       |
 1996|  4.33k|    laststore = vecMin;
 1997|  4.33k|    if ((pos1 < len1) && (pos2 < len2)) {
  ------------------
  |  Branch (1997:9): [True: 3.97k, False: 355]
  |  Branch (1997:26): [True: 3.85k, False: 120]
  ------------------
 1998|  3.85k|        uint16_t curA, curB;
 1999|  3.85k|        curA = array1[8 * pos1];
 2000|  3.85k|        curB = array2[8 * pos2];
 2001|   181k|        while (true) {
  ------------------
  |  Branch (2001:16): [True: 181k, Folded]
  ------------------
 2002|   181k|            if (curA <= curB) {
  ------------------
  |  Branch (2002:17): [True: 86.1k, False: 94.8k]
  ------------------
 2003|  86.1k|                V = _mm_lddqu_si128((const __m128i *)array1 + pos1);
 2004|  86.1k|                pos1++;
 2005|  86.1k|                if (pos1 < len1) {
  ------------------
  |  Branch (2005:21): [True: 83.6k, False: 2.53k]
  ------------------
 2006|  83.6k|                    curA = array1[8 * pos1];
 2007|  83.6k|                } else {
 2008|  2.53k|                    break;
 2009|  2.53k|                }
 2010|  94.8k|            } else {
 2011|  94.8k|                V = _mm_lddqu_si128((const __m128i *)array2 + pos2);
 2012|  94.8k|                pos2++;
 2013|  94.8k|                if (pos2 < len2) {
  ------------------
  |  Branch (2013:21): [True: 93.5k, False: 1.31k]
  ------------------
 2014|  93.5k|                    curB = array2[8 * pos2];
 2015|  93.5k|                } else {
 2016|  1.31k|                    break;
 2017|  1.31k|                }
 2018|  94.8k|            }
 2019|   177k|            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|   177k|            output += store_unique_xor(laststore, vecMin, output);
 2024|   177k|            laststore = vecMin;
 2025|   177k|        }
 2026|  3.85k|        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.85k|        output += store_unique_xor(laststore, vecMin, output);
 2031|  3.85k|        laststore = vecMin;
 2032|  3.85k|    }
 2033|  4.33k|    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.33k|    int leftoversize = store_unique_xor(laststore, vecMax, buffer);
 2041|  4.33k|    uint16_t vec7 = (uint16_t)_mm_extract_epi16(vecMax, 7);
 2042|  4.33k|    uint16_t vec6 = (uint16_t)_mm_extract_epi16(vecMax, 6);
 2043|  4.33k|    if (vec7 != vec6) buffer[leftoversize++] = vec7;
  ------------------
  |  Branch (2043:9): [True: 4.26k, False: 65]
  ------------------
 2044|  4.33k|    if (pos1 == len1) {
  ------------------
  |  Branch (2044:9): [True: 2.89k, False: 1.43k]
  ------------------
 2045|  2.89k|        memcpy(buffer + leftoversize, array1 + 8 * pos1,
 2046|  2.89k|               (length1 - 8 * len1) * sizeof(uint16_t));
 2047|  2.89k|        leftoversize += length1 - 8 * len1;
 2048|  2.89k|        if (leftoversize == 0) {  // trivial case
  ------------------
  |  Branch (2048:13): [True: 8, False: 2.88k]
  ------------------
 2049|      8|            memcpy(output, array2 + 8 * pos2,
 2050|      8|                   (length2 - 8 * pos2) * sizeof(uint16_t));
 2051|      8|            len += (length2 - 8 * pos2);
 2052|  2.88k|        } else {
 2053|  2.88k|            sort_uint16_short(buffer, leftoversize);
 2054|  2.88k|            leftoversize = unique_xor(buffer, leftoversize);
 2055|  2.88k|            len += xor_uint16(buffer, leftoversize, array2 + 8 * pos2,
 2056|  2.88k|                              length2 - 8 * pos2, output);
 2057|  2.88k|        }
 2058|  2.89k|    } else {
 2059|  1.43k|        memcpy(buffer + leftoversize, array2 + 8 * pos2,
 2060|  1.43k|               (length2 - 8 * len2) * sizeof(uint16_t));
 2061|  1.43k|        leftoversize += length2 - 8 * len2;
 2062|  1.43k|        if (leftoversize == 0) {  // trivial case
  ------------------
  |  Branch (2062:13): [True: 4, False: 1.43k]
  ------------------
 2063|      4|            memcpy(output, array1 + 8 * pos1,
 2064|      4|                   (length1 - 8 * pos1) * sizeof(uint16_t));
 2065|      4|            len += (length1 - 8 * pos1);
 2066|  1.43k|        } else {
 2067|  1.43k|            sort_uint16_short(buffer, leftoversize);
 2068|  1.43k|            leftoversize = unique_xor(buffer, leftoversize);
 2069|  1.43k|            len += xor_uint16(buffer, leftoversize, array1 + 8 * pos1,
 2070|  1.43k|                              length1 - 8 * pos1, output);
 2071|  1.43k|        }
 2072|  1.43k|    }
 2073|  4.33k|    return len;
 2074|  7.71k|}
fast_union_uint16:
 2177|  4.59k|                         uint16_t *buffer) {
 2178|  4.59k|#if CROARING_IS_X64
 2179|  4.59k|    const unsigned support = (unsigned)croaring_hardware_support();
 2180|  4.59k|#if CROARING_COMPILER_SUPPORTS_AVX512
 2181|  4.59k|    if (support & ROARING_SUPPORTS_AVX512) {
  ------------------
  |  Branch (2181:9): [True: 0, False: 4.59k]
  ------------------
 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.59k|#endif  // CROARING_COMPILER_SUPPORTS_AVX512
 2192|  4.59k|    if (support & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (2192:9): [True: 4.59k, False: 0]
  ------------------
 2193|       |        // compute union with smallest array first
 2194|  4.59k|        if (size_1 < size_2) {
  ------------------
  |  Branch (2194:13): [True: 2.30k, False: 2.28k]
  ------------------
 2195|  2.30k|            return union_vector16(set_1, (uint32_t)size_1, set_2,
 2196|  2.30k|                                  (uint32_t)size_2, buffer);
 2197|  2.30k|        } else {
 2198|  2.28k|            return union_vector16(set_2, (uint32_t)size_2, set_1,
 2199|  2.28k|                                  (uint32_t)size_1, buffer);
 2200|  2.28k|        }
 2201|  4.59k|    } 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.59k|}
memequals:
 2321|  6.99k|bool memequals(const void *s1, const void *s2, size_t n) {
 2322|  6.99k|    if (n == 0) {
  ------------------
  |  Branch (2322:9): [True: 0, False: 6.99k]
  ------------------
 2323|      0|        return true;
 2324|      0|    }
 2325|  6.99k|#if CROARING_IS_X64
 2326|  6.99k|    int support = croaring_hardware_support();
 2327|  6.99k|#if CROARING_COMPILER_SUPPORTS_AVX512
 2328|  6.99k|    if (support & ROARING_SUPPORTS_AVX512) {
  ------------------
  |  Branch (2328:9): [True: 0, False: 6.99k]
  ------------------
 2329|      0|        return _avx512_memequals(s1, s2, n);
 2330|      0|    } else
 2331|  6.99k|#endif  // CROARING_COMPILER_SUPPORTS_AVX512
 2332|  6.99k|        if (support & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (2332:13): [True: 6.99k, False: 0]
  ------------------
 2333|  6.99k|            return _avx2_memequals(s1, s2, n);
 2334|  6.99k|        } else {
 2335|      0|            return memcmp(s1, s2, n) == 0;
 2336|      0|        }
 2337|       |#else
 2338|       |    return memcmp(s1, s2, n) == 0;
 2339|       |#endif
 2340|  6.99k|}
array_util.c:binarySearch4:
  804|  1.36k|                          int32_t *index4) {
  805|  1.36k|    const uint16_t *base1 = array;
  806|  1.36k|    const uint16_t *base2 = array;
  807|  1.36k|    const uint16_t *base3 = array;
  808|  1.36k|    const uint16_t *base4 = array;
  809|  1.36k|    if (n == 0) return;
  ------------------
  |  Branch (809:9): [True: 0, False: 1.36k]
  ------------------
  810|  17.0k|    while (n > 1) {
  ------------------
  |  Branch (810:12): [True: 15.7k, False: 1.36k]
  ------------------
  811|  15.7k|        int32_t half = n >> 1;
  812|  15.7k|        base1 = (base1[half] < target1) ? &base1[half] : base1;
  ------------------
  |  Branch (812:17): [True: 1.15k, False: 14.5k]
  ------------------
  813|  15.7k|        base2 = (base2[half] < target2) ? &base2[half] : base2;
  ------------------
  |  Branch (813:17): [True: 2.21k, False: 13.5k]
  ------------------
  814|  15.7k|        base3 = (base3[half] < target3) ? &base3[half] : base3;
  ------------------
  |  Branch (814:17): [True: 2.76k, False: 12.9k]
  ------------------
  815|  15.7k|        base4 = (base4[half] < target4) ? &base4[half] : base4;
  ------------------
  |  Branch (815:17): [True: 3.34k, False: 12.3k]
  ------------------
  816|  15.7k|        n -= half;
  817|  15.7k|    }
  818|  1.36k|    *index1 = (int32_t)((*base1 < target1) + base1 - array);
  819|  1.36k|    *index2 = (int32_t)((*base2 < target2) + base2 - array);
  820|  1.36k|    *index3 = (int32_t)((*base3 < target3) + base3 - array);
  821|  1.36k|    *index4 = (int32_t)((*base4 < target4) + base4 - array);
  822|  1.36k|}
array_util.c:binarySearch2:
  833|    381|                          uint16_t target2, int32_t *index1, int32_t *index2) {
  834|    381|    const uint16_t *base1 = array;
  835|    381|    const uint16_t *base2 = array;
  836|    381|    if (n == 0) return;
  ------------------
  |  Branch (836:9): [True: 0, False: 381]
  ------------------
  837|  3.57k|    while (n > 1) {
  ------------------
  |  Branch (837:12): [True: 3.19k, False: 381]
  ------------------
  838|  3.19k|        int32_t half = n >> 1;
  839|  3.19k|        base1 = (base1[half] < target1) ? &base1[half] : base1;
  ------------------
  |  Branch (839:17): [True: 792, False: 2.40k]
  ------------------
  840|  3.19k|        base2 = (base2[half] < target2) ? &base2[half] : base2;
  ------------------
  |  Branch (840:17): [True: 1.32k, False: 1.87k]
  ------------------
  841|  3.19k|        n -= half;
  842|  3.19k|    }
  843|    381|    *index1 = (int32_t)((*base1 < target1) + base1 - array);
  844|    381|    *index2 = (int32_t)((*base2 < target2) + base2 - array);
  845|    381|}
array_util.c:sse_merge:
 1244|   289k|                             __m128i *vecMin, __m128i *vecMax) {  // output
 1245|   289k|    __m128i vecTmp;
 1246|   289k|    vecTmp = _mm_min_epu16(*vInput1, *vInput2);
 1247|   289k|    *vecMax = _mm_max_epu16(*vInput1, *vInput2);
 1248|   289k|    vecTmp = _mm_alignr_epi8(vecTmp, vecTmp, 2);
 1249|   289k|    *vecMin = _mm_min_epu16(vecTmp, *vecMax);
 1250|   289k|    *vecMax = _mm_max_epu16(vecTmp, *vecMax);
 1251|   289k|    vecTmp = _mm_alignr_epi8(*vecMin, *vecMin, 2);
 1252|   289k|    *vecMin = _mm_min_epu16(vecTmp, *vecMax);
 1253|   289k|    *vecMax = _mm_max_epu16(vecTmp, *vecMax);
 1254|   289k|    vecTmp = _mm_alignr_epi8(*vecMin, *vecMin, 2);
 1255|   289k|    *vecMin = _mm_min_epu16(vecTmp, *vecMax);
 1256|   289k|    *vecMax = _mm_max_epu16(vecTmp, *vecMax);
 1257|   289k|    vecTmp = _mm_alignr_epi8(*vecMin, *vecMin, 2);
 1258|   289k|    *vecMin = _mm_min_epu16(vecTmp, *vecMax);
 1259|   289k|    *vecMax = _mm_max_epu16(vecTmp, *vecMax);
 1260|   289k|    vecTmp = _mm_alignr_epi8(*vecMin, *vecMin, 2);
 1261|   289k|    *vecMin = _mm_min_epu16(vecTmp, *vecMax);
 1262|   289k|    *vecMax = _mm_max_epu16(vecTmp, *vecMax);
 1263|   289k|    vecTmp = _mm_alignr_epi8(*vecMin, *vecMin, 2);
 1264|   289k|    *vecMin = _mm_min_epu16(vecTmp, *vecMax);
 1265|   289k|    *vecMax = _mm_max_epu16(vecTmp, *vecMax);
 1266|   289k|    vecTmp = _mm_alignr_epi8(*vecMin, *vecMin, 2);
 1267|   289k|    *vecMin = _mm_min_epu16(vecTmp, *vecMax);
 1268|   289k|    *vecMax = _mm_max_epu16(vecTmp, *vecMax);
 1269|       |    *vecMin = _mm_alignr_epi8(*vecMin, *vecMin, 2);
 1270|   289k|}
array_util.c:store_unique:
 1619|   108k|static inline int store_unique(__m128i old, __m128i newval, uint16_t *output) {
 1620|   108k|    __m128i vecTmp = _mm_alignr_epi8(newval, old, 16 - 2);
 1621|       |    // lots of high latency instructions follow (optimize?)
 1622|   108k|    int M = _mm_movemask_epi8(
 1623|   108k|        _mm_packs_epi16(_mm_cmpeq_epi16(vecTmp, newval), _mm_setzero_si128()));
 1624|   108k|    int numberofnewvalues = 8 - _mm_popcnt_u32(M);
 1625|   108k|    __m128i key = _mm_lddqu_si128((const __m128i *)uniqshuf + M);
 1626|   108k|    __m128i val = _mm_shuffle_epi8(newval, key);
 1627|   108k|    _mm_storeu_si128((__m128i *)output, val);
 1628|   108k|    return numberofnewvalues;
 1629|   108k|}
array_util.c:sort_uint16_short:
 1647|  7.89k|static inline void sort_uint16_short(uint16_t *z, uint32_t n) {
 1648|  79.1k|    for (uint32_t i = 1; i < n; i++) {
  ------------------
  |  Branch (1648:26): [True: 71.2k, False: 7.89k]
  ------------------
 1649|  71.2k|        uint16_t v = z[i];
 1650|  71.2k|        uint32_t j = i;
 1651|  74.4k|        while (j > 0 && z[j - 1] > v) {
  ------------------
  |  Branch (1651:16): [True: 74.3k, False: 28]
  |  Branch (1651:25): [True: 3.20k, False: 71.1k]
  ------------------
 1652|  3.20k|            z[j] = z[j - 1];
 1653|  3.20k|            j--;
 1654|  3.20k|        }
 1655|  71.2k|        z[j] = v;
 1656|  71.2k|    }
 1657|  7.89k|}
array_util.c:unique:
 1634|  3.57k|static inline uint32_t unique(uint16_t *out, uint32_t len) {
 1635|  3.57k|    uint32_t pos = 1;
 1636|  36.5k|    for (uint32_t i = 1; i < len; ++i) {
  ------------------
  |  Branch (1636:26): [True: 32.9k, False: 3.57k]
  ------------------
 1637|  32.9k|        if (out[i] != out[i - 1]) {
  ------------------
  |  Branch (1637:13): [True: 32.8k, False: 133]
  ------------------
 1638|  32.8k|            out[pos++] = out[i];
 1639|  32.8k|        }
 1640|  32.9k|    }
 1641|  3.57k|    return pos;
 1642|  3.57k|}
array_util.c:store_unique_xor:
 1943|   189k|                                   uint16_t *output) {
 1944|   189k|    __m128i vecTmp1 = _mm_alignr_epi8(newval, old, 16 - 4);
 1945|       |    __m128i vecTmp2 = _mm_alignr_epi8(newval, old, 16 - 2);
 1946|   189k|    __m128i equalleft = _mm_cmpeq_epi16(vecTmp2, vecTmp1);
 1947|   189k|    __m128i equalright = _mm_cmpeq_epi16(vecTmp2, newval);
 1948|   189k|    __m128i equalleftoright = _mm_or_si128(equalleft, equalright);
 1949|   189k|    int M = _mm_movemask_epi8(
 1950|   189k|        _mm_packs_epi16(equalleftoright, _mm_setzero_si128()));
 1951|   189k|    int numberofnewvalues = 8 - _mm_popcnt_u32(M);
 1952|   189k|    __m128i key = _mm_lddqu_si128((const __m128i *)uniqshuf + M);
 1953|   189k|    __m128i val = _mm_shuffle_epi8(vecTmp2, key);
 1954|   189k|    _mm_storeu_si128((__m128i *)output, val);
 1955|   189k|    return numberofnewvalues;
 1956|   189k|}
array_util.c:unique_xor:
 1961|  4.31k|static inline uint32_t unique_xor(uint16_t *out, uint32_t len) {
 1962|  4.31k|    uint32_t pos = 1;
 1963|  42.5k|    for (uint32_t i = 1; i < len; ++i) {
  ------------------
  |  Branch (1963:26): [True: 38.2k, False: 4.31k]
  ------------------
 1964|  38.2k|        if (out[i] != out[i - 1]) {
  ------------------
  |  Branch (1964:13): [True: 37.9k, False: 294]
  ------------------
 1965|  37.9k|            out[pos++] = out[i];
 1966|  37.9k|        } else
 1967|    294|            pos--;  // if it is identical to previous, delete it
 1968|  38.2k|    }
 1969|  4.31k|    return pos;
 1970|  4.31k|}
array_util.c:_avx2_memequals:
 2279|  6.99k|static inline bool _avx2_memequals(const void *s1, const void *s2, size_t n) {
 2280|  6.99k|    const uint8_t *ptr1 = (const uint8_t *)s1;
 2281|  6.99k|    const uint8_t *ptr2 = (const uint8_t *)s2;
 2282|  6.99k|    const uint8_t *end1 = ptr1 + n;
 2283|  6.99k|    const uint8_t *end8 = ptr1 + n / 8 * 8;
 2284|  6.99k|    const uint8_t *end32 = ptr1 + n / 32 * 32;
 2285|       |
 2286|   134k|    while (ptr1 < end32) {
  ------------------
  |  Branch (2286:12): [True: 127k, False: 6.93k]
  ------------------
 2287|   127k|        __m256i r1 = _mm256_loadu_si256((const __m256i *)ptr1);
 2288|   127k|        __m256i r2 = _mm256_loadu_si256((const __m256i *)ptr2);
 2289|   127k|        int mask = _mm256_movemask_epi8(_mm256_cmpeq_epi8(r1, r2));
 2290|   127k|        if ((uint32_t)mask != UINT32_MAX) {
  ------------------
  |  Branch (2290:13): [True: 63, False: 127k]
  ------------------
 2291|     63|            return false;
 2292|     63|        }
 2293|   127k|        ptr1 += 32;
 2294|   127k|        ptr2 += 32;
 2295|   127k|    }
 2296|       |
 2297|  12.7k|    while (ptr1 < end8) {
  ------------------
  |  Branch (2297:12): [True: 5.92k, False: 6.85k]
  ------------------
 2298|  5.92k|        uint64_t v1, v2;
 2299|  5.92k|        memcpy(&v1, ptr1, sizeof(uint64_t));
 2300|  5.92k|        memcpy(&v2, ptr2, sizeof(uint64_t));
 2301|  5.92k|        if (v1 != v2) {
  ------------------
  |  Branch (2301:13): [True: 77, False: 5.84k]
  ------------------
 2302|     77|            return false;
 2303|     77|        }
 2304|  5.84k|        ptr1 += 8;
 2305|  5.84k|        ptr2 += 8;
 2306|  5.84k|    }
 2307|       |
 2308|  24.6k|    while (ptr1 < end1) {
  ------------------
  |  Branch (2308:12): [True: 17.8k, False: 6.82k]
  ------------------
 2309|  17.8k|        if (*ptr1 != *ptr2) {
  ------------------
  |  Branch (2309:13): [True: 32, False: 17.7k]
  ------------------
 2310|     32|            return false;
 2311|     32|        }
 2312|  17.7k|        ptr1++;
 2313|  17.7k|        ptr2++;
 2314|  17.7k|    }
 2315|       |
 2316|  6.82k|    return true;
 2317|  6.85k|}

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

array_container_create_given_capacity:
   49|   141k|array_container_t *array_container_create_given_capacity(int32_t size) {
   50|   141k|    array_container_t *container;
   51|       |
   52|   141k|    if ((container = (array_container_t *)roaring_malloc(
  ------------------
  |  Branch (52:9): [True: 0, False: 141k]
  ------------------
   53|   141k|             sizeof(array_container_t))) == NULL) {
   54|      0|        return NULL;
   55|      0|    }
   56|       |
   57|   141k|    if (size <= 0) {  // we don't want to rely on malloc(0)
  ------------------
  |  Branch (57:9): [True: 87.0k, False: 54.1k]
  ------------------
   58|  87.0k|        container->array = NULL;
   59|  87.0k|    } else if ((container->array = (uint16_t *)roaring_malloc(sizeof(uint16_t) *
  ------------------
  |  Branch (59:16): [True: 0, False: 54.1k]
  ------------------
   60|  54.1k|                                                              size)) == NULL) {
   61|      0|        roaring_free(container);
   62|      0|        return NULL;
   63|      0|    }
   64|       |
   65|   141k|    container->capacity = size;
   66|   141k|    container->cardinality = 0;
   67|       |
   68|   141k|    return container;
   69|   141k|}
array_container_create:
   72|  25.3k|array_container_t *array_container_create(void) {
   73|  25.3k|    return array_container_create_given_capacity(ARRAY_DEFAULT_INIT_SIZE);
   74|  25.3k|}
array_container_create_range:
   77|    126|array_container_t *array_container_create_range(uint32_t min, uint32_t max) {
   78|    126|    array_container_t *answer =
   79|    126|        array_container_create_given_capacity(max - min + 1);
   80|    126|    if (answer == NULL) return answer;
  ------------------
  |  Branch (80:9): [True: 0, False: 126]
  ------------------
   81|    126|    answer->cardinality = 0;
   82|    252|    for (uint32_t k = min; k < max; k++) {
  ------------------
  |  Branch (82:28): [True: 126, False: 126]
  ------------------
   83|    126|        answer->array[answer->cardinality++] = k;
   84|    126|    }
   85|    126|    return answer;
   86|    126|}
array_container_clone:
   90|  21.6k|array_container_t *array_container_clone(const array_container_t *src) {
   91|  21.6k|    array_container_t *newcontainer =
   92|  21.6k|        array_container_create_given_capacity(src->capacity);
   93|  21.6k|    if (newcontainer == NULL) return NULL;
  ------------------
  |  Branch (93:9): [True: 0, False: 21.6k]
  ------------------
   94|       |
   95|  21.6k|    newcontainer->cardinality = src->cardinality;
   96|       |
   97|  21.6k|    memcpy(newcontainer->array, src->array,
   98|  21.6k|           src->cardinality * sizeof(uint16_t));
   99|       |
  100|  21.6k|    return newcontainer;
  101|  21.6k|}
array_container_shrink_to_fit:
  131|  3.70k|int array_container_shrink_to_fit(array_container_t *src) {
  132|  3.70k|    if (src->cardinality == src->capacity) return 0;  // nothing to do
  ------------------
  |  Branch (132:9): [True: 466, False: 3.23k]
  ------------------
  133|  3.23k|    int savings = src->capacity - src->cardinality;
  134|  3.23k|    src->capacity = src->cardinality;
  135|  3.23k|    if (src->capacity ==
  ------------------
  |  Branch (135:9): [True: 0, False: 3.23k]
  ------------------
  136|  3.23k|        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.23k|    } else {
  140|  3.23k|        uint16_t *oldarray = src->array;
  141|  3.23k|        src->array = (uint16_t *)roaring_realloc(
  142|  3.23k|            oldarray, src->capacity * sizeof(uint16_t));
  143|  3.23k|        if (src->array == NULL) roaring_free(oldarray);  // should never happen?
  ------------------
  |  Branch (143:13): [True: 0, False: 3.23k]
  ------------------
  144|  3.23k|    }
  145|  3.23k|    return savings;
  146|  3.70k|}
array_container_free:
  149|   141k|void array_container_free(array_container_t *arr) {
  150|   141k|    if (arr == NULL) return;
  ------------------
  |  Branch (150:9): [True: 0, False: 141k]
  ------------------
  151|   141k|    roaring_free(arr->array);
  152|   141k|    roaring_free(arr);
  153|   141k|}
array_container_grow:
  167|   116k|                          bool preserve) {
  168|   116k|    int32_t max = (min <= DEFAULT_MAX_SIZE ? DEFAULT_MAX_SIZE : 65536);
  ------------------
  |  Branch (168:20): [True: 116k, False: 0]
  ------------------
  169|   116k|    int32_t new_capacity = clamp(grow_capacity(container->capacity), min, max);
  170|       |
  171|   116k|    container->capacity = new_capacity;
  172|   116k|    uint16_t *array = container->array;
  173|       |
  174|   116k|    if (preserve) {
  ------------------
  |  Branch (174:9): [True: 107k, False: 9.74k]
  ------------------
  175|   107k|        container->array =
  176|   107k|            (uint16_t *)roaring_realloc(array, new_capacity * sizeof(uint16_t));
  177|   107k|        if (container->array == NULL) roaring_free(array);
  ------------------
  |  Branch (177:13): [True: 0, False: 107k]
  ------------------
  178|   107k|    } else {
  179|  9.74k|        roaring_free(array);
  180|  9.74k|        container->array =
  181|  9.74k|            (uint16_t *)roaring_malloc(new_capacity * sizeof(uint16_t));
  182|  9.74k|    }
  183|       |
  184|       |    // if realloc fails, we have container->array == NULL.
  185|   116k|}
array_container_copy:
  189|     24|                          array_container_t *dst) {
  190|     24|    const int32_t cardinality = src->cardinality;
  191|     24|    if (cardinality > dst->capacity) {
  ------------------
  |  Branch (191:9): [True: 24, False: 0]
  ------------------
  192|     24|        array_container_grow(dst, cardinality, false);
  193|     24|    }
  194|       |
  195|     24|    dst->cardinality = cardinality;
  196|     24|    memcpy(dst->array, src->array, cardinality * sizeof(uint16_t));
  197|     24|}
array_container_union:
  211|  4.59k|                           array_container_t *out) {
  212|  4.59k|    const int32_t card_1 = array_1->cardinality, card_2 = array_2->cardinality;
  213|  4.59k|    const int32_t max_cardinality = card_1 + card_2;
  214|       |
  215|  4.59k|    if (out->capacity < max_cardinality) {
  ------------------
  |  Branch (215:9): [True: 0, False: 4.59k]
  ------------------
  216|       |        array_container_grow(out, max_cardinality, false);
  217|      0|    }
  218|  4.59k|    out->cardinality = (int32_t)fast_union_uint16(
  219|  4.59k|        array_1->array, card_1, array_2->array, card_2, out->array);
  220|  4.59k|}
array_container_andnot:
  228|  5.74k|                            array_container_t *out) {
  229|  5.74k|    if (out->capacity < array_1->cardinality)
  ------------------
  |  Branch (229:9): [True: 2.30k, False: 3.44k]
  ------------------
  230|  2.30k|        array_container_grow(out, array_1->cardinality, false);
  231|  5.74k|#if CROARING_IS_X64
  232|  5.74k|    if ((croaring_hardware_support() & ROARING_SUPPORTS_AVX2) &&
  ------------------
  |  Branch (232:9): [True: 5.74k, False: 0]
  ------------------
  233|  5.74k|        (out != array_1) && (out != array_2)) {
  ------------------
  |  Branch (233:9): [True: 2.30k, False: 3.44k]
  |  Branch (233:29): [True: 2.30k, False: 0]
  ------------------
  234|  2.30k|        out->cardinality = difference_vector16(
  235|  2.30k|            array_1->array, array_1->cardinality, array_2->array,
  236|  2.30k|            array_2->cardinality, out->array);
  237|  3.44k|    } else {
  238|  3.44k|        out->cardinality =
  239|  3.44k|            difference_uint16(array_1->array, array_1->cardinality,
  240|  3.44k|                              array_2->array, array_2->cardinality, out->array);
  241|  3.44k|    }
  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.74k|}
array_container_xor:
  256|  7.71k|                         array_container_t *out) {
  257|  7.71k|    const int32_t card_1 = array_1->cardinality, card_2 = array_2->cardinality;
  258|  7.71k|    const int32_t max_cardinality = card_1 + card_2;
  259|  7.71k|    if (out->capacity < max_cardinality) {
  ------------------
  |  Branch (259:9): [True: 0, False: 7.71k]
  ------------------
  260|      0|        array_container_grow(out, max_cardinality, false);
  261|      0|    }
  262|       |
  263|  7.71k|#if CROARING_IS_X64
  264|  7.71k|    if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (264:9): [True: 7.71k, False: 0]
  ------------------
  265|  7.71k|        out->cardinality =
  266|  7.71k|            xor_vector16(array_1->array, array_1->cardinality, array_2->array,
  267|  7.71k|                         array_2->cardinality, out->array);
  268|  7.71k|    } 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.71k|}
array_container_intersection:
  290|  2.30k|                                  array_container_t *out) {
  291|  2.30k|    int32_t card_1 = array1->cardinality, card_2 = array2->cardinality,
  292|  2.30k|            min_card = minimum_int32(card_1, card_2);
  293|  2.30k|    const int threshold = 64;  // subject to tuning
  294|  2.30k|#if CROARING_IS_X64
  295|  2.30k|    if (out->capacity < min_card) {
  ------------------
  |  Branch (295:9): [True: 2.30k, False: 0]
  ------------------
  296|  2.30k|        array_container_grow(out, min_card + sizeof(__m128i) / sizeof(uint16_t),
  297|  2.30k|                             false);
  298|  2.30k|    }
  299|       |#else
  300|       |    if (out->capacity < min_card) {
  301|       |        array_container_grow(out, min_card, false);
  302|       |    }
  303|       |#endif
  304|       |
  305|  2.30k|    if (card_1 * threshold < card_2) {
  ------------------
  |  Branch (305:9): [True: 339, False: 1.96k]
  ------------------
  306|    339|        out->cardinality = intersect_skewed_uint16(
  307|    339|            array1->array, card_1, array2->array, card_2, out->array);
  308|  1.96k|    } else if (card_2 * threshold < card_1) {
  ------------------
  |  Branch (308:16): [True: 199, False: 1.76k]
  ------------------
  309|    199|        out->cardinality = intersect_skewed_uint16(
  310|    199|            array2->array, card_2, array1->array, card_1, out->array);
  311|  1.76k|    } else {
  312|  1.76k|#if CROARING_IS_X64
  313|  1.76k|        if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (313:13): [True: 1.76k, False: 0]
  ------------------
  314|  1.76k|            out->cardinality = intersect_vector16(
  315|  1.76k|                array1->array, card_1, array2->array, card_2, out->array);
  316|  1.76k|        } 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.76k|    }
  325|  2.30k|}
array_container_intersection_cardinality:
  330|  9.21k|                                             const array_container_t *array2) {
  331|  9.21k|    int32_t card_1 = array1->cardinality, card_2 = array2->cardinality;
  332|  9.21k|    const int threshold = 64;  // subject to tuning
  333|  9.21k|    if (card_1 * threshold < card_2) {
  ------------------
  |  Branch (333:9): [True: 1.35k, False: 7.86k]
  ------------------
  334|  1.35k|        return intersect_skewed_uint16_cardinality(array1->array, card_1,
  335|  1.35k|                                                   array2->array, card_2);
  336|  7.86k|    } else if (card_2 * threshold < card_1) {
  ------------------
  |  Branch (336:16): [True: 796, False: 7.06k]
  ------------------
  337|    796|        return intersect_skewed_uint16_cardinality(array2->array, card_2,
  338|    796|                                                   array1->array, card_1);
  339|  7.06k|    } else {
  340|  7.06k|#if CROARING_IS_X64
  341|  7.06k|        if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (341:13): [True: 7.06k, False: 0]
  ------------------
  342|  7.06k|            return intersect_vector16_cardinality(array1->array, card_1,
  343|  7.06k|                                                  array2->array, card_2);
  344|  7.06k|        } 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.06k|    }
  353|  9.21k|}
array_container_intersect:
  356|  2.30k|                               const array_container_t *array2) {
  357|  2.30k|    int32_t card_1 = array1->cardinality, card_2 = array2->cardinality;
  358|  2.30k|    const int threshold = 64;  // subject to tuning
  359|  2.30k|    if (card_1 * threshold < card_2) {
  ------------------
  |  Branch (359:9): [True: 339, False: 1.96k]
  ------------------
  360|    339|        return intersect_skewed_uint16_nonempty(array1->array, card_1,
  361|    339|                                                array2->array, card_2);
  362|  1.96k|    } else if (card_2 * threshold < card_1) {
  ------------------
  |  Branch (362:16): [True: 199, False: 1.76k]
  ------------------
  363|    199|        return intersect_skewed_uint16_nonempty(array2->array, card_2,
  364|    199|                                                array1->array, card_1);
  365|  1.76k|    } else {
  366|       |        // we do not bother vectorizing
  367|  1.76k|        return intersect_uint16_nonempty(array1->array, card_1, array2->array,
  368|  1.76k|                                         card_2);
  369|  1.76k|    }
  370|  2.30k|}
array_container_intersection_inplace:
  376|  4.57k|                                          const array_container_t *src_2) {
  377|  4.57k|    int32_t card_1 = src_1->cardinality, card_2 = src_2->cardinality;
  378|  4.57k|    const int threshold = 64;  // subject to tuning
  379|  4.57k|    if (card_1 * threshold < card_2) {
  ------------------
  |  Branch (379:9): [True: 0, False: 4.57k]
  ------------------
  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.57k|    } else if (card_2 * threshold < card_1) {
  ------------------
  |  Branch (382:16): [True: 205, False: 4.36k]
  ------------------
  383|    205|        src_1->cardinality = intersect_skewed_uint16(
  384|    205|            src_2->array, card_2, src_1->array, card_1, src_1->array);
  385|  4.36k|    } else {
  386|  4.36k|#if CROARING_IS_X64
  387|  4.36k|        if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (387:13): [True: 4.36k, False: 0]
  ------------------
  388|  4.36k|            src_1->cardinality = intersect_vector16_inplace(
  389|  4.36k|                src_1->array, card_1, src_2->array, card_2);
  390|  4.36k|        } 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.36k|    }
  399|  4.57k|}
array_container_to_uint32_array:
  403|  5.62k|                                    uint32_t base) {
  404|  5.62k|#if CROARING_IS_X64
  405|  5.62k|    int support = croaring_hardware_support();
  406|  5.62k|#if CROARING_COMPILER_SUPPORTS_AVX512
  407|  5.62k|    if (support & ROARING_SUPPORTS_AVX512) {
  ------------------
  |  Branch (407:9): [True: 0, False: 5.62k]
  ------------------
  408|      0|        return avx512_array_container_to_uint32_array(vout, cont->array,
  409|      0|                                                      cont->cardinality, base);
  410|      0|    }
  411|  5.62k|#endif
  412|  5.62k|    if (support & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (412:9): [True: 5.62k, False: 0]
  ------------------
  413|  5.62k|        return array_container_to_uint32_array_vector16(
  414|  5.62k|            vout, cont->array, cont->cardinality, base);
  415|  5.62k|    }
  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.62k|}
array_container_number_of_runs:
  495|  12.4k|int32_t array_container_number_of_runs(const array_container_t *ac) {
  496|       |    // Can SIMD work here?
  497|  12.4k|    int32_t nr_runs = 0;
  498|  12.4k|    int32_t prev = -2;
  499|  1.61M|    for (const uint16_t *p = ac->array; p != ac->array + ac->cardinality; ++p) {
  ------------------
  |  Branch (499:41): [True: 1.60M, False: 12.4k]
  ------------------
  500|  1.60M|        if (*p != prev + 1) nr_runs++;
  ------------------
  |  Branch (500:13): [True: 867k, False: 733k]
  ------------------
  501|  1.60M|        prev = *p;
  502|  1.60M|    }
  503|  12.4k|    return nr_runs;
  504|  12.4k|}
array_container_write:
  512|  6.82k|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.82k|    memcpy(buf, container->array, container->cardinality * sizeof(uint16_t));
  520|  6.82k|#endif
  521|  6.82k|    return array_container_size_in_bytes(container);
  522|  6.82k|}
array_container_is_subset:
  525|  5.59k|                               const array_container_t *container2) {
  526|  5.59k|    if (container1->cardinality > container2->cardinality) {
  ------------------
  |  Branch (526:9): [True: 638, False: 4.96k]
  ------------------
  527|    638|        return false;
  528|    638|    }
  529|  4.96k|    int i1 = 0, i2 = 0;
  530|  49.3k|    while (i1 < container1->cardinality && i2 < container2->cardinality) {
  ------------------
  |  Branch (530:12): [True: 49.3k, False: 0]
  |  Branch (530:44): [True: 49.2k, False: 24]
  ------------------
  531|  49.2k|        if (container1->array[i1] == container2->array[i2]) {
  ------------------
  |  Branch (531:13): [True: 0, False: 49.2k]
  ------------------
  532|      0|            i1++;
  533|      0|            i2++;
  534|  49.2k|        } else if (container1->array[i1] > container2->array[i2]) {
  ------------------
  |  Branch (534:20): [True: 44.3k, False: 4.93k]
  ------------------
  535|  44.3k|            i2++;
  536|  44.3k|        } else {  // container1->array[i1] < container2->array[i2]
  537|  4.93k|            return false;
  538|  4.93k|        }
  539|  49.2k|    }
  540|     24|    if (i1 == container1->cardinality) {
  ------------------
  |  Branch (540:9): [True: 0, False: 24]
  ------------------
  541|      0|        return true;
  542|     24|    } else {
  543|       |        return false;
  544|     24|    }
  545|     24|}
array_container_read:
  548|  6.86k|                             const char *buf) {
  549|  6.86k|    if (container->capacity < cardinality) {
  ------------------
  |  Branch (549:9): [True: 0, False: 6.86k]
  ------------------
  550|      0|        array_container_grow(container, cardinality, false);
  551|      0|    }
  552|  6.86k|    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|  6.86k|    memcpy(container->array, buf, container->cardinality * sizeof(uint16_t));
  561|  6.86k|#endif
  562|       |
  563|  6.86k|    return array_container_size_in_bytes(container);
  564|  6.86k|}
array_container_iterate:
  567|  6.22k|                             roaring_iterator iterator, void *ptr) {
  568|  2.00M|    for (int i = 0; i < cont->cardinality; i++)
  ------------------
  |  Branch (568:21): [True: 2.00M, False: 6.22k]
  ------------------
  569|  2.00M|        if (!iterator(cont->array[i] + base, ptr)) return false;
  ------------------
  |  Branch (569:13): [True: 0, False: 2.00M]
  ------------------
  570|  6.22k|    return true;
  571|  6.22k|}
array.c:clamp:
  162|   116k|static inline int32_t clamp(int32_t val, int32_t min, int32_t max) {
  163|   116k|    return ((val < min) ? min : (val > max) ? max : val);
  ------------------
  |  Branch (163:13): [True: 25.9k, False: 91.0k]
  |  Branch (163:33): [True: 241, False: 90.8k]
  ------------------
  164|   116k|}
array.c:grow_capacity:
  155|   116k|static inline int32_t grow_capacity(int32_t capacity) {
  156|   116k|    return (capacity <= 0)   ? ARRAY_DEFAULT_INIT_SIZE
  ------------------
  |  Branch (156:12): [True: 25.3k, False: 91.6k]
  ------------------
  157|   116k|           : capacity < 64   ? capacity * 2
  ------------------
  |  Branch (157:14): [True: 66.5k, False: 25.0k]
  ------------------
  158|  91.6k|           : capacity < 1024 ? capacity * 3 / 2
  ------------------
  |  Branch (158:14): [True: 24.7k, False: 278]
  ------------------
  159|  25.0k|                             : capacity * 5 / 4;
  160|   116k|}
array.c:minimum_int32:
  280|  2.30k|static inline int32_t minimum_int32(int32_t a, int32_t b) {
  281|  2.30k|    return (a < b) ? a : b;
  ------------------
  |  Branch (281:12): [True: 958, False: 1.34k]
  ------------------
  282|  2.30k|}

bitset_container_clear:
   51|  72.1k|void bitset_container_clear(bitset_container_t *bitset) {
   52|  72.1k|    memset(bitset->words, 0, sizeof(uint64_t) * BITSET_CONTAINER_SIZE_IN_WORDS);
   53|  72.1k|    bitset->cardinality = 0;
   54|  72.1k|}
bitset_container_set_all:
   56|    155|void bitset_container_set_all(bitset_container_t *bitset) {
   57|       |    memset(bitset->words, INT64_C(-1),
   58|    155|           sizeof(uint64_t) * BITSET_CONTAINER_SIZE_IN_WORDS);
   59|    155|    bitset->cardinality = (1 << 16);
   60|    155|}
bitset_container_create:
   91|  72.1k|bitset_container_t *bitset_container_create(void) {
   92|  72.1k|    bitset_container_t *bitset = bitset_container_allocate();
   93|  72.1k|    if (bitset) {
  ------------------
  |  Branch (93:9): [True: 72.1k, False: 0]
  ------------------
   94|  72.1k|        bitset_container_clear(bitset);
   95|  72.1k|    }
   96|  72.1k|    return bitset;
   97|  72.1k|}
bitset_container_create_uninitialized:
   99|  66.9k|bitset_container_t *bitset_container_create_uninitialized(void) {
  100|  66.9k|    bitset_container_t *bitset = bitset_container_allocate();
  101|  66.9k|    if (bitset) {
  ------------------
  |  Branch (101:9): [True: 66.9k, False: 0]
  ------------------
  102|  66.9k|        bitset->cardinality = 0;
  103|  66.9k|    }
  104|  66.9k|    return bitset;
  105|  66.9k|}
bitset_container_copy:
  109|  3.65k|                           bitset_container_t *dest) {
  110|  3.65k|    dest->cardinality = source->cardinality;
  111|  3.65k|    memcpy(dest->words, source->words,
  112|  3.65k|           sizeof(uint64_t) * BITSET_CONTAINER_SIZE_IN_WORDS);
  113|  3.65k|}
bitset_container_free:
  144|   273k|void bitset_container_free(bitset_container_t *bitset) {
  145|   273k|    if (bitset == NULL) return;
  ------------------
  |  Branch (145:9): [True: 0, False: 273k]
  ------------------
  146|   273k|    roaring_aligned_free(bitset->words);
  147|   273k|    roaring_free(bitset);
  148|   273k|}
bitset_container_clone:
  152|   134k|bitset_container_t *bitset_container_clone(const bitset_container_t *src) {
  153|   134k|    bitset_container_t *bitset =
  154|   134k|        (bitset_container_t *)roaring_malloc(sizeof(bitset_container_t));
  155|       |
  156|   134k|    if (!bitset) {
  ------------------
  |  Branch (156:9): [True: 0, False: 134k]
  ------------------
  157|      0|        return NULL;
  158|      0|    }
  159|       |
  160|   134k|    size_t align_size = 32;
  161|   134k|#if CROARING_IS_X64
  162|   134k|    if (croaring_hardware_support() & ROARING_SUPPORTS_AVX512) {
  ------------------
  |  Branch (162:9): [True: 0, False: 134k]
  ------------------
  163|       |        // sizeof(__m512i) == 64
  164|      0|        align_size = 64;
  165|   134k|    } else {
  166|       |        // sizeof(__m256i) == 32
  167|   134k|        align_size = 32;
  168|   134k|    }
  169|   134k|#endif
  170|   134k|    bitset->words = (uint64_t *)roaring_aligned_malloc(
  171|   134k|        align_size, sizeof(uint64_t) * BITSET_CONTAINER_SIZE_IN_WORDS);
  172|   134k|    if (!bitset->words) {
  ------------------
  |  Branch (172:9): [True: 0, False: 134k]
  ------------------
  173|      0|        roaring_free(bitset);
  174|      0|        return NULL;
  175|      0|    }
  176|   134k|    bitset->cardinality = src->cardinality;
  177|   134k|    memcpy(bitset->words, src->words,
  178|   134k|           sizeof(uint64_t) * BITSET_CONTAINER_SIZE_IN_WORDS);
  179|   134k|    return bitset;
  180|   134k|}
bitset_container_compute_cardinality:
  284|  3.22k|int bitset_container_compute_cardinality(const bitset_container_t *bitset) {
  285|  3.22k|    int support = croaring_hardware_support();
  286|  3.22k|#if CROARING_COMPILER_SUPPORTS_AVX512
  287|  3.22k|    if (support & ROARING_SUPPORTS_AVX512) {
  ------------------
  |  Branch (287:9): [True: 0, False: 3.22k]
  ------------------
  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.22k|#endif  // CROARING_COMPILER_SUPPORTS_AVX512
  293|  3.22k|        if (support & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (293:13): [True: 3.22k, False: 0]
  ------------------
  294|  3.22k|            return (int)avx2_harley_seal_popcount256(
  295|  3.22k|                (const __m256i *)bitset->words,
  296|  3.22k|                BITSET_CONTAINER_SIZE_IN_WORDS / (CROARING_WORDS_IN_AVX2_REG));
  ------------------
  |  |  265|  3.22k|#define CROARING_WORDS_IN_AVX2_REG sizeof(__m256i) / sizeof(uint64_t)
  ------------------
  297|  3.22k|        } else {
  298|      0|            return _scalar_bitset_container_compute_cardinality(bitset);
  299|      0|        }
  300|  3.22k|}
bitset_container_and_nocard:
  739|  1.40k|                                         bitset_container_t *dst) {            \
  740|  1.40k|    int support = croaring_hardware_support();                                 \
  741|  1.40k|    if ( support & ROARING_SUPPORTS_AVX512 ) {                                 \
  ------------------
  |  Branch (741:10): [True: 0, False: 1.40k]
  ------------------
  742|      0|      return _avx512_bitset_container_##opname##_nocard(src_1, src_2, dst);    \
  743|      0|    }                                                                          \
  744|  1.40k|    else if ( support & ROARING_SUPPORTS_AVX2 ) {                              \
  ------------------
  |  Branch (744:15): [True: 1.40k, False: 0]
  ------------------
  745|  1.40k|      return _avx2_bitset_container_##opname##_nocard(src_1, src_2, dst);      \
  746|  1.40k|    } else {                                                                   \
  747|      0|      return _scalar_bitset_container_##opname##_nocard(src_1, src_2, dst);    \
  748|      0|    }                                                                          \
  749|  1.40k|  }                                                                            \
bitset_container_and_justcard:
  751|  1.40k|                                           const bitset_container_t *src_2) {  \
  752|  1.40k|     int support = croaring_hardware_support();                                \
  753|  1.40k|    if ( support & ROARING_SUPPORTS_AVX512 ) {                                 \
  ------------------
  |  Branch (753:10): [True: 0, False: 1.40k]
  ------------------
  754|      0|      return _avx512_bitset_container_##opname##_justcard(src_1, src_2);       \
  755|      0|    }                                                                          \
  756|  1.40k|    else if ( support & ROARING_SUPPORTS_AVX2 ) {                              \
  ------------------
  |  Branch (756:15): [True: 1.40k, False: 0]
  ------------------
  757|  1.40k|      return _avx2_bitset_container_##opname##_justcard(src_1, src_2);         \
  758|  1.40k|    } else {                                                                   \
  759|      0|      return _scalar_bitset_container_##opname##_justcard(src_1, src_2);       \
  760|      0|    }                                                                          \
  761|  1.40k|  }
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.40k|){
  952|  1.40k|#if CROARING_IS_X64
  953|  1.40k|   int support = croaring_hardware_support();
  954|  1.40k|#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.40k|   if( support & ROARING_SUPPORTS_AVX512 )
  ------------------
  |  Branch (959:8): [True: 0, False: 1.40k]
  ------------------
  960|      0|		return (int) bitset_extract_setbits_avx512(bc->words,
  961|      0|                BITSET_CONTAINER_SIZE_IN_WORDS, out, bc->cardinality, base);
  962|  1.40k|   else
  963|  1.40k|#endif
  964|  1.40k|   if(( support & ROARING_SUPPORTS_AVX2 ) &&  (bc->cardinality >= 8192))  // heuristic
  ------------------
  |  Branch (964:7): [True: 1.40k, False: 0]
  |  Branch (964:47): [True: 992, False: 412]
  ------------------
  965|    992|		return (int) bitset_extract_setbits_avx2(bc->words,
  966|    992|                BITSET_CONTAINER_SIZE_IN_WORDS, out, bc->cardinality, base);
  967|    412|	else
  968|    412|		return (int) bitset_extract_setbits(bc->words,
  969|    412|                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.40k|}
bitset_container_write:
 1069|  66.9k|                                  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|  66.9k|	memcpy(buf, container->words, BITSET_CONTAINER_SIZE_IN_WORDS * sizeof(uint64_t));
 1077|  66.9k|#endif
 1078|  66.9k|	return bitset_container_size_in_bytes(container);
 1079|  66.9k|}
bitset_container_read:
 1083|  66.9k|		const char *buf)  {
 1084|  66.9k|	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|  66.9k|	memcpy(container->words, buf, BITSET_CONTAINER_SIZE_IN_WORDS * sizeof(uint64_t));
 1093|  66.9k|#endif
 1094|  66.9k|	return bitset_container_size_in_bytes(container);
 1095|  66.9k|}
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|  66.9k|bool bitset_container_equals(const bitset_container_t *container1, const bitset_container_t *container2) {
 1164|  66.9k|  if((container1->cardinality != BITSET_UNKNOWN_CARDINALITY) && (container2->cardinality != BITSET_UNKNOWN_CARDINALITY)) {
  ------------------
  |  Branch (1164:6): [True: 66.9k, False: 0]
  |  Branch (1164:65): [True: 66.9k, False: 0]
  ------------------
 1165|  66.9k|    if(container1->cardinality != container2->cardinality) {
  ------------------
  |  Branch (1165:8): [True: 0, False: 66.9k]
  ------------------
 1166|      0|      return false;
 1167|      0|    }
 1168|  66.9k|    if (container1->cardinality == INT32_C(0x10000)) {
  ------------------
  |  Branch (1168:9): [True: 63.2k, False: 3.76k]
  ------------------
 1169|  63.2k|      return true;
 1170|  63.2k|    }
 1171|  66.9k|  }
 1172|  3.76k|#if CROARING_IS_X64
 1173|  3.76k|  int support = croaring_hardware_support();
 1174|  3.76k|#if CROARING_COMPILER_SUPPORTS_AVX512
 1175|  3.76k|  if( support & ROARING_SUPPORTS_AVX512 ) {
  ------------------
  |  Branch (1175:7): [True: 0, False: 3.76k]
  ------------------
 1176|      0|    return _avx512_bitset_container_equals(container1, container2);
 1177|      0|  }
 1178|  3.76k|  else
 1179|  3.76k|#endif
 1180|  3.76k|  if( support & ROARING_SUPPORTS_AVX2 ) {
  ------------------
  |  Branch (1180:7): [True: 3.76k, False: 0]
  ------------------
 1181|  3.76k|    return _avx2_bitset_container_equals(container1, container2);
 1182|  3.76k|  }
 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.76k|}
bitset_container_minimum:
 1237|  1.15k|uint16_t bitset_container_minimum(const bitset_container_t *container) {
 1238|  10.1k|  for (int32_t i = 0; i < BITSET_CONTAINER_SIZE_IN_WORDS; ++i ) {
  ------------------
  |  Branch (1238:23): [True: 10.1k, False: 0]
  ------------------
 1239|  10.1k|    uint64_t w = container->words[i];
 1240|  10.1k|    if (w != 0) {
  ------------------
  |  Branch (1240:9): [True: 1.15k, False: 9.01k]
  ------------------
 1241|  1.15k|      int r = roaring_trailing_zeroes(w);
 1242|  1.15k|      return r + i * 64;
 1243|  1.15k|    }
 1244|  10.1k|  }
 1245|      0|  return UINT16_MAX;
 1246|  1.15k|}
bitset_container_maximum:
 1249|  4.23k|uint16_t bitset_container_maximum(const bitset_container_t *container) {
 1250|   990k|  for (int32_t i = BITSET_CONTAINER_SIZE_IN_WORDS - 1; i > 0; --i ) {
  ------------------
  |  Branch (1250:56): [True: 990k, False: 0]
  ------------------
 1251|   990k|    uint64_t w = container->words[i];
 1252|   990k|    if (w != 0) {
  ------------------
  |  Branch (1252:9): [True: 4.23k, False: 986k]
  ------------------
 1253|  4.23k|      int r = roaring_leading_zeroes(w);
 1254|  4.23k|      return i * 64 + 63  - r;
 1255|  4.23k|    }
 1256|   990k|  }
 1257|      0|  return 0;
 1258|  4.23k|}
bitset_container_index_equalorlarger:
 1318|  1.79k|int bitset_container_index_equalorlarger(const bitset_container_t *container, uint16_t x) {
 1319|  1.79k|  uint32_t x32 = x;
 1320|  1.79k|  uint32_t k = x32 / 64;
 1321|  1.79k|  uint64_t word = container->words[k];
 1322|  1.79k|  const int diff = x32 - k * 64; // in [0,64)
 1323|  1.79k|  word = (word >> diff) << diff; // a mask is faster, but we don't care
 1324|  4.82k|  while(word == 0) {
  ------------------
  |  Branch (1324:9): [True: 3.03k, False: 1.79k]
  ------------------
 1325|  3.03k|    k++;
 1326|  3.03k|    if(k == BITSET_CONTAINER_SIZE_IN_WORDS) return -1;
  ------------------
  |  Branch (1326:8): [True: 0, False: 3.03k]
  ------------------
 1327|  3.03k|    word = container->words[k];
 1328|  3.03k|  }
 1329|  1.79k|  return k * 64 + roaring_trailing_zeroes(word);
 1330|  1.79k|}
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.40k|      bitset_container_t *dst) {                                               \
  519|  1.40k|    const uint8_t *__restrict__ words_1 = (const uint8_t *)src_1->words;       \
  520|  1.40k|    const uint8_t *__restrict__ words_2 = (const uint8_t *)src_2->words;       \
  521|  1.40k|    /* not using the blocking optimization for some reason*/                   \
  522|  1.40k|    uint8_t *out = (uint8_t *)dst->words;                                      \
  523|  1.40k|    const int innerloop = 8;                                                   \
  524|  1.40k|    for (size_t i = 0;                                                         \
  525|  46.3k|         i < BITSET_CONTAINER_SIZE_IN_WORDS / (CROARING_WORDS_IN_AVX2_REG);             \
  ------------------
  |  |  265|  46.3k|#define CROARING_WORDS_IN_AVX2_REG sizeof(__m256i) / sizeof(uint64_t)
  ------------------
  |  Branch (525:10): [True: 44.9k, False: 1.40k]
  ------------------
  526|  44.9k|         i += innerloop) {                                                     \
  527|  44.9k|      __m256i A1, A2, AO;                                                      \
  528|  44.9k|      A1 = _mm256_lddqu_si256((const __m256i *)(words_1));                     \
  529|  44.9k|      A2 = _mm256_lddqu_si256((const __m256i *)(words_2));                     \
  530|  44.9k|      AO = avx_intrinsic(A2, A1);                                              \
  531|  44.9k|      _mm256_storeu_si256((__m256i *)out, AO);                                 \
  532|  44.9k|      A1 = _mm256_lddqu_si256((const __m256i *)(words_1 + 32));                \
  533|  44.9k|      A2 = _mm256_lddqu_si256((const __m256i *)(words_2 + 32));                \
  534|  44.9k|      AO = avx_intrinsic(A2, A1);                                              \
  535|  44.9k|      _mm256_storeu_si256((__m256i *)(out + 32), AO);                          \
  536|  44.9k|      A1 = _mm256_lddqu_si256((const __m256i *)(words_1 + 64));                \
  537|  44.9k|      A2 = _mm256_lddqu_si256((const __m256i *)(words_2 + 64));                \
  538|  44.9k|      AO = avx_intrinsic(A2, A1);                                              \
  539|  44.9k|      _mm256_storeu_si256((__m256i *)(out + 64), AO);                          \
  540|  44.9k|      A1 = _mm256_lddqu_si256((const __m256i *)(words_1 + 96));                \
  541|  44.9k|      A2 = _mm256_lddqu_si256((const __m256i *)(words_2 + 96));                \
  542|  44.9k|      AO = avx_intrinsic(A2, A1);                                              \
  543|  44.9k|      _mm256_storeu_si256((__m256i *)(out + 96), AO);                          \
  544|  44.9k|      A1 = _mm256_lddqu_si256((const __m256i *)(words_1 + 128));               \
  545|  44.9k|      A2 = _mm256_lddqu_si256((const __m256i *)(words_2 + 128));               \
  546|  44.9k|      AO = avx_intrinsic(A2, A1);                                              \
  547|  44.9k|      _mm256_storeu_si256((__m256i *)(out + 128), AO);                         \
  548|  44.9k|      A1 = _mm256_lddqu_si256((const __m256i *)(words_1 + 160));               \
  549|  44.9k|      A2 = _mm256_lddqu_si256((const __m256i *)(words_2 + 160));               \
  550|  44.9k|      AO = avx_intrinsic(A2, A1);                                              \
  551|  44.9k|      _mm256_storeu_si256((__m256i *)(out + 160), AO);                         \
  552|  44.9k|      A1 = _mm256_lddqu_si256((const __m256i *)(words_1 + 192));               \
  553|  44.9k|      A2 = _mm256_lddqu_si256((const __m256i *)(words_2 + 192));               \
  554|  44.9k|      AO = avx_intrinsic(A2, A1);                                              \
  555|  44.9k|      _mm256_storeu_si256((__m256i *)(out + 192), AO);                         \
  556|  44.9k|      A1 = _mm256_lddqu_si256((const __m256i *)(words_1 + 224));               \
  557|  44.9k|      A2 = _mm256_lddqu_si256((const __m256i *)(words_2 + 224));               \
  558|  44.9k|      AO = avx_intrinsic(A2, A1);                                              \
  559|  44.9k|      _mm256_storeu_si256((__m256i *)(out + 224), AO);                         \
  560|  44.9k|      out += 256;                                                              \
  561|  44.9k|      words_1 += 256;                                                          \
  562|  44.9k|      words_2 += 256;                                                          \
  563|  44.9k|    }                                                                          \
  564|  1.40k|    dst->cardinality = BITSET_UNKNOWN_CARDINALITY;                             \
  565|  1.40k|    return dst->cardinality;                                                   \
  566|  1.40k|  }
bitset.c:_avx2_bitset_container_and_justcard:
  587|  1.40k|      const bitset_container_t *src_1, const bitset_container_t *src_2) {      \
  588|  1.40k|    const __m256i *__restrict__ data1 = (const __m256i *)src_1->words;         \
  589|  1.40k|    const __m256i *__restrict__ data2 = (const __m256i *)src_2->words;         \
  590|  1.40k|    return (int)avx2_harley_seal_popcount256_##opname(                         \
  591|  1.40k|        data2, data1, BITSET_CONTAINER_SIZE_IN_WORDS / (CROARING_WORDS_IN_AVX2_REG));   \
  ------------------
  |  |  265|  1.40k|#define CROARING_WORDS_IN_AVX2_REG sizeof(__m256i) / sizeof(uint64_t)
  ------------------
  592|  1.40k|  }
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.76k|static inline bool _avx2_bitset_container_equals(const bitset_container_t *container1, const bitset_container_t *container2) {
 1147|  3.76k|    const __m256i *ptr1 = (const __m256i*)container1->words;
 1148|  3.76k|    const __m256i *ptr2 = (const __m256i*)container2->words;
 1149|   967k|    for (size_t i = 0; i < BITSET_CONTAINER_SIZE_IN_WORDS*sizeof(uint64_t)/32; i++) {
  ------------------
  |  Branch (1149:24): [True: 963k, False: 3.76k]
  ------------------
 1150|   963k|      __m256i r1 = _mm256_loadu_si256(ptr1+i);
 1151|   963k|      __m256i r2 = _mm256_loadu_si256(ptr2+i);
 1152|   963k|      int mask = _mm256_movemask_epi8(_mm256_cmpeq_epi8(r1, r2));
 1153|   963k|      if ((uint32_t)mask != UINT32_MAX) {
  ------------------
  |  Branch (1153:11): [True: 0, False: 963k]
  ------------------
 1154|      0|          return false;
 1155|      0|      }
 1156|   963k|  }
 1157|  3.76k|	return true;
 1158|  3.76k|}

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

bitset_container_from_array:
   22|  2.21k|bitset_container_t *bitset_container_from_array(const array_container_t *ac) {
   23|  2.21k|    bitset_container_t *ans = bitset_container_create();
   24|  2.21k|    int limit = array_container_cardinality(ac);
   25|  2.28M|    for (int i = 0; i < limit; ++i) bitset_container_set(ans, ac->array[i]);
  ------------------
  |  Branch (25:21): [True: 2.28M, False: 2.21k]
  ------------------
   26|  2.21k|    return ans;
   27|  2.21k|}
bitset_container_from_run:
   29|    574|bitset_container_t *bitset_container_from_run(const run_container_t *arr) {
   30|    574|    int card = run_container_cardinality(arr);
   31|    574|    bitset_container_t *answer = bitset_container_create();
   32|  22.1k|    for (int rlepos = 0; rlepos < arr->n_runs; ++rlepos) {
  ------------------
  |  Branch (32:26): [True: 21.5k, False: 574]
  ------------------
   33|  21.5k|        rle16_t vl = arr->runs[rlepos];
   34|  21.5k|        bitset_set_lenrange(answer->words, vl.value, vl.length);
   35|  21.5k|    }
   36|    574|    answer->cardinality = card;
   37|    574|    return answer;
   38|    574|}
array_container_from_run:
   40|  1.15k|array_container_t *array_container_from_run(const run_container_t *arr) {
   41|  1.15k|    array_container_t *answer =
   42|  1.15k|        array_container_create_given_capacity(run_container_cardinality(arr));
   43|  1.15k|    answer->cardinality = 0;
   44|  83.8k|    for (int rlepos = 0; rlepos < arr->n_runs; ++rlepos) {
  ------------------
  |  Branch (44:26): [True: 82.6k, False: 1.15k]
  ------------------
   45|  82.6k|        int run_start = arr->runs[rlepos].value;
   46|  82.6k|        int run_end = run_start + arr->runs[rlepos].length;
   47|       |
   48|   441k|        for (int run_value = run_start; run_value <= run_end; ++run_value) {
  ------------------
  |  Branch (48:41): [True: 358k, False: 82.6k]
  ------------------
   49|   358k|            answer->array[answer->cardinality++] = (uint16_t)run_value;
   50|   358k|        }
   51|  82.6k|    }
   52|  1.15k|    return answer;
   53|  1.15k|}
array_container_from_bitset:
   55|  2.70k|array_container_t *array_container_from_bitset(const bitset_container_t *bits) {
   56|  2.70k|    array_container_t *result =
   57|  2.70k|        array_container_create_given_capacity(bits->cardinality);
   58|  2.70k|    result->cardinality = bits->cardinality;
   59|  2.70k|#if CROARING_IS_X64
   60|  2.70k|#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.70k|    if ((bits->cardinality >= 1024) &&
  ------------------
  |  Branch (67:9): [True: 571, False: 2.13k]
  ------------------
   68|    571|        (croaring_hardware_support() & ROARING_SUPPORTS_AVX512)) {
  ------------------
  |  Branch (68:9): [True: 0, False: 571]
  ------------------
   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.70k|#endif
   74|  2.70k|    {
   75|       |        //  sse version ends up being slower here
   76|       |        // (bitset_extract_setbits_sse_uint16)
   77|       |        // because of the sparsity of the data
   78|  2.70k|        bitset_extract_setbits_uint16(
   79|  2.70k|            bits->words, BITSET_CONTAINER_SIZE_IN_WORDS, result->array, 0);
   80|  2.70k|    }
   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.70k|    return result;
   88|  2.70k|}
convert_to_bitset_or_array_container:
  127|  66.5k|                                                  uint8_t *resulttype) {
  128|  66.5k|    if (card <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (128:9): [True: 1.19k, False: 65.3k]
  ------------------
  129|  1.19k|        array_container_t *answer = array_container_create_given_capacity(card);
  130|  1.19k|        answer->cardinality = 0;
  131|  63.5k|        for (int rlepos = 0; rlepos < rc->n_runs; ++rlepos) {
  ------------------
  |  Branch (131:30): [True: 62.3k, False: 1.19k]
  ------------------
  132|  62.3k|            uint16_t run_start = rc->runs[rlepos].value;
  133|  62.3k|            uint16_t run_end = run_start + rc->runs[rlepos].length;
  134|   620k|            for (uint16_t run_value = run_start; run_value < run_end;
  ------------------
  |  Branch (134:50): [True: 557k, False: 62.3k]
  ------------------
  135|   557k|                 ++run_value) {
  136|   557k|                answer->array[answer->cardinality++] = run_value;
  137|   557k|            }
  138|  62.3k|            answer->array[answer->cardinality++] = run_end;
  139|  62.3k|        }
  140|  1.19k|        assert(card == answer->cardinality);
  141|  1.19k|        *resulttype = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  1.19k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  142|       |        // run_container_free(r);
  143|  1.19k|        return answer;
  144|  1.19k|    }
  145|  65.3k|    bitset_container_t *answer = bitset_container_create();
  146|   150k|    for (int rlepos = 0; rlepos < rc->n_runs; ++rlepos) {
  ------------------
  |  Branch (146:26): [True: 85.4k, False: 65.3k]
  ------------------
  147|  85.4k|        uint16_t run_start = rc->runs[rlepos].value;
  148|  85.4k|        bitset_set_lenrange(answer->words, run_start, rc->runs[rlepos].length);
  149|  85.4k|    }
  150|  65.3k|    answer->cardinality = card;
  151|  65.3k|    *resulttype = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|  65.3k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  152|       |    // run_container_free(r);
  153|  65.3k|    return answer;
  154|  66.5k|}
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.0k, False: 72.3k]
  ------------------
  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.3k, False: 64.0k]
  ------------------
  177|  66.3k|        *typecode_after = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|  66.3k|#define RUN_CONTAINER_TYPE 3
  ------------------
  178|  66.3k|        return c;
  179|  66.3k|    }
  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|   209k|        for (int rlepos = 0; rlepos < c->n_runs; ++rlepos) {
  ------------------
  |  Branch (184:30): [True: 145k, False: 64.0k]
  ------------------
  185|   145k|            int run_start = c->runs[rlepos].value;
  186|   145k|            int run_end = run_start + c->runs[rlepos].length;
  187|       |
  188|   389k|            for (int run_value = run_start; run_value <= run_end; ++run_value) {
  ------------------
  |  Branch (188:45): [True: 243k, False: 145k]
  ------------------
  189|   243k|                answer->array[answer->cardinality++] = (uint16_t)run_value;
  190|   243k|            }
  191|   145k|        }
  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|   117k|    run_container_t *c, uint8_t *typecode_after) {
  212|   117k|    container_t *answer = convert_run_to_efficient_container(c, typecode_after);
  213|   117k|    if (answer != c) run_container_free(c);
  ------------------
  |  Branch (213:9): [True: 56.8k, False: 60.9k]
  ------------------
  214|   117k|    return answer;
  215|   117k|}
convert_run_optimize:
  225|  12.4k|                                  uint8_t *typecode_after) {
  226|  12.4k|    if (typecode_original == RUN_CONTAINER_TYPE) {
  ------------------
  |  |   50|  12.4k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (226:9): [True: 0, False: 12.4k]
  ------------------
  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.4k|    } else if (typecode_original == ARRAY_CONTAINER_TYPE) {
  ------------------
  |  |   49|  12.4k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (233:16): [True: 12.4k, False: 0]
  ------------------
  234|       |        // it might need to be converted to a run container.
  235|  12.4k|        array_container_t *c_qua_array = CAST_array(c);
  ------------------
  |  |   54|  12.4k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  12.4k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  236|  12.4k|        int32_t n_runs = array_container_number_of_runs(c_qua_array);
  237|  12.4k|        int32_t size_as_run_container =
  238|  12.4k|            run_container_serialized_size_in_bytes(n_runs);
  239|  12.4k|        int32_t card = array_container_cardinality(c_qua_array);
  240|  12.4k|        int32_t size_as_array_container =
  241|  12.4k|            array_container_serialized_size_in_bytes(card);
  242|       |
  243|  12.4k|        if (size_as_run_container >= size_as_array_container) {
  ------------------
  |  Branch (243:13): [True: 8.51k, False: 3.97k]
  ------------------
  244|  8.51k|            *typecode_after = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  8.51k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  245|  8.51k|            return c;
  246|  8.51k|        }
  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|   657k|        for (int i = 0; i < card; ++i) {
  ------------------
  |  Branch (253:25): [True: 653k, False: 3.97k]
  ------------------
  254|   653k|            uint16_t cur_val = c_qua_array->array[i];
  255|   653k|            if (cur_val != prev + 1) {
  ------------------
  |  Branch (255:17): [True: 265k, False: 388k]
  ------------------
  256|       |                // new run starts; flush old one, if any
  257|   265k|                if (run_start != -1) add_run(answer, run_start, prev);
  ------------------
  |  Branch (257:21): [True: 261k, False: 3.97k]
  ------------------
  258|   265k|                run_start = cur_val;
  259|   265k|            }
  260|   653k|            prev = c_qua_array->array[i];
  261|   653k|        }
  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.4k|    } 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.4k|}
convert.c:add_run:
   91|   265k|static void add_run(run_container_t *rc, int s, int e) {
   92|   265k|    rc->runs[rc->n_runs].value = s;
   93|   265k|    rc->runs[rc->n_runs].length = e - s;
   94|   265k|    rc->n_runs++;
   95|   265k|}

array_bitset_container_andnot:
   26|    531|                                   array_container_t *dst) {
   27|       |    // follows Java implementation as of June 2016
   28|    531|    if (dst->capacity < src_1->cardinality) {
  ------------------
  |  Branch (28:9): [True: 531, False: 0]
  ------------------
   29|    531|        array_container_grow(dst, src_1->cardinality, false);
   30|    531|    }
   31|    531|    int32_t newcard = 0;
   32|    531|    const int32_t origcard = src_1->cardinality;
   33|  91.2k|    for (int i = 0; i < origcard; ++i) {
  ------------------
  |  Branch (33:21): [True: 90.7k, False: 531]
  ------------------
   34|  90.7k|        uint16_t key = src_1->array[i];
   35|  90.7k|        dst->array[newcard] = key;
   36|  90.7k|        newcard += 1 - bitset_container_contains(src_2, key);
   37|  90.7k|    }
   38|    531|    dst->cardinality = newcard;
   39|    531|}
bitset_array_container_iandnot:
   83|  1.42k|                                    container_t **dst) {
   84|  1.42k|    *dst = src_1;
   85|  1.42k|    src_1->cardinality =
   86|  1.42k|        (int32_t)bitset_clear_list(src_1->words, (uint64_t)src_1->cardinality,
   87|  1.42k|                                   src_2->array, (uint64_t)src_2->cardinality);
   88|       |
   89|  1.42k|    if (src_1->cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (89:9): [True: 190, False: 1.23k]
  ------------------
   90|    190|        *dst = array_container_from_bitset(src_1);
   91|    190|        bitset_container_free(src_1);
   92|    190|        return false;  // not bitset
   93|    190|    } else
   94|  1.23k|        return true;
   95|  1.42k|}
run_bitset_container_andnot:
  106|    613|                                 container_t **dst) {
  107|       |    // follows the Java implementation as of June 2016
  108|    613|    int card = run_container_cardinality(src_1);
  109|    613|    if (card <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (109:9): [True: 613, False: 0]
  ------------------
  110|       |        // must be an array
  111|    613|        array_container_t *answer = array_container_create_given_capacity(card);
  112|    613|        answer->cardinality = 0;
  113|  51.0k|        for (int32_t rlepos = 0; rlepos < src_1->n_runs; ++rlepos) {
  ------------------
  |  Branch (113:34): [True: 50.4k, False: 613]
  ------------------
  114|  50.4k|            rle16_t rle = src_1->runs[rlepos];
  115|   184k|            for (int run_value = rle.value; run_value <= rle.value + rle.length;
  ------------------
  |  Branch (115:45): [True: 134k, False: 50.4k]
  ------------------
  116|   134k|                 ++run_value) {
  117|   134k|                if (!bitset_container_get(src_2, (uint16_t)run_value)) {
  ------------------
  |  Branch (117:21): [True: 36.4k, False: 97.9k]
  ------------------
  118|  36.4k|                    answer->array[answer->cardinality++] = (uint16_t)run_value;
  119|  36.4k|                }
  120|   134k|            }
  121|  50.4k|        }
  122|    613|        *dst = answer;
  123|    613|        return false;
  124|    613|    } 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|    613|}
run_array_container_andnot:
  279|  1.94k|                               container_t **dst) {
  280|       |    // follows the Java impl as of June 2016
  281|       |
  282|  1.94k|    int card = run_container_cardinality(src_1);
  283|  1.94k|    const int arbitrary_threshold = 32;
  284|       |
  285|  1.94k|    if (card <= arbitrary_threshold) {
  ------------------
  |  Branch (285:9): [True: 368, False: 1.58k]
  ------------------
  286|    368|        if (src_2->cardinality == 0) {
  ------------------
  |  Branch (286:13): [True: 0, False: 368]
  ------------------
  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|    368|        run_container_t *answer = run_container_create_given_capacity(
  292|    368|            card + array_container_cardinality(src_2));
  293|       |
  294|    368|        int rlepos = 0;
  295|    368|        int xrlepos = 0;  // "x" is src_2
  296|    368|        rle16_t rle = src_1->runs[rlepos];
  297|    368|        int32_t start = rle.value;
  298|    368|        int32_t end = start + rle.length + 1;
  299|    368|        int32_t xstart = src_2->array[xrlepos];
  300|       |
  301|  13.2k|        while ((rlepos < src_1->n_runs) && (xrlepos < src_2->cardinality)) {
  ------------------
  |  Branch (301:16): [True: 12.9k, False: 307]
  |  Branch (301:44): [True: 12.9k, False: 61]
  ------------------
  302|  12.9k|            if (end <= xstart) {
  ------------------
  |  Branch (302:17): [True: 641, False: 12.2k]
  ------------------
  303|       |                // output the first run
  304|    641|                answer->runs[answer->n_runs++] =
  305|    641|                    CROARING_MAKE_RLE16(start, end - start - 1);
  ------------------
  |  |   60|    641|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  306|    641|                rlepos++;
  307|    641|                if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (307:21): [True: 586, False: 55]
  ------------------
  308|    586|                    start = src_1->runs[rlepos].value;
  309|    586|                    end = start + src_1->runs[rlepos].length + 1;
  310|    586|                }
  311|  12.2k|            } else if (xstart + 1 <= start) {
  ------------------
  |  Branch (311:24): [True: 8.29k, False: 3.97k]
  ------------------
  312|       |                // exit the second run
  313|  8.29k|                xrlepos++;
  314|  8.29k|                if (xrlepos < src_2->cardinality) {
  ------------------
  |  Branch (314:21): [True: 8.23k, False: 61]
  ------------------
  315|  8.23k|                    xstart = src_2->array[xrlepos];
  316|  8.23k|                }
  317|  8.29k|            } else {
  318|  3.97k|                if (start < xstart) {
  ------------------
  |  Branch (318:21): [True: 331, False: 3.64k]
  ------------------
  319|    331|                    answer->runs[answer->n_runs++] =
  320|    331|                        CROARING_MAKE_RLE16(start, xstart - start - 1);
  ------------------
  |  |   60|    331|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  321|    331|                }
  322|  3.97k|                if (xstart + 1 < end) {
  ------------------
  |  Branch (322:21): [True: 2.39k, False: 1.57k]
  ------------------
  323|  2.39k|                    start = xstart + 1;
  324|  2.39k|                } else {
  325|  1.57k|                    rlepos++;
  326|  1.57k|                    if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (326:25): [True: 1.32k, False: 252]
  ------------------
  327|  1.32k|                        start = src_1->runs[rlepos].value;
  328|  1.32k|                        end = start + src_1->runs[rlepos].length + 1;
  329|  1.32k|                    }
  330|  1.57k|                }
  331|  3.97k|            }
  332|  12.9k|        }
  333|    368|        if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (333:13): [True: 61, False: 307]
  ------------------
  334|     61|            answer->runs[answer->n_runs++] =
  335|     61|                CROARING_MAKE_RLE16(start, end - start - 1);
  ------------------
  |  |   60|     61|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  336|     61|            rlepos++;
  337|     61|            if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (337:17): [True: 19, False: 42]
  ------------------
  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|     61|        }
  343|    368|        uint8_t return_type;
  344|    368|        *dst = convert_run_to_efficient_container(answer, &return_type);
  345|    368|        if (answer != *dst) run_container_free(answer);
  ------------------
  |  Branch (345:13): [True: 230, False: 138]
  ------------------
  346|    368|        return return_type;
  347|    368|    }
  348|       |    // else it's a bitmap or array
  349|       |
  350|  1.58k|    if (card <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (350:9): [True: 1.27k, False: 308]
  ------------------
  351|  1.27k|        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.27k|        ac->cardinality = run_array_array_subtract(src_1, src_2, ac);
  355|  1.27k|        *dst = ac;
  356|  1.27k|        return ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  1.27k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  357|  1.27k|    }
  358|    308|    bitset_container_t *ans = bitset_container_from_run(src_1);
  359|    308|    bool result_is_bitset = bitset_array_container_iandnot(ans, src_2, dst);
  360|    308|    return (result_is_bitset ? BITSET_CONTAINER_TYPE : ARRAY_CONTAINER_TYPE);
  ------------------
  |  |   48|    285|#define BITSET_CONTAINER_TYPE 1
  ------------------
                  return (result_is_bitset ? BITSET_CONTAINER_TYPE : ARRAY_CONTAINER_TYPE);
  ------------------
  |  |   49|     23|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (360:13): [True: 285, False: 23]
  ------------------
  361|  1.58k|}
run_array_container_iandnot:
  372|    742|                                container_t **dst) {
  373|       |    // dummy implementation same as June 2016 Java
  374|    742|    int ans = run_array_container_andnot(src_1, src_2, dst);
  375|    742|    run_container_free(src_1);
  376|    742|    return ans;
  377|    742|}
array_run_container_andnot:
  383|    809|                                array_container_t *dst) {
  384|       |    // basically following Java impl as of June 2016
  385|    809|    if (src_1->cardinality > dst->capacity) {
  ------------------
  |  Branch (385:9): [True: 759, False: 50]
  ------------------
  386|    759|        array_container_grow(dst, src_1->cardinality, false);
  387|    759|    }
  388|       |
  389|    809|    if (src_2->n_runs == 0) {
  ------------------
  |  Branch (389:9): [True: 0, False: 809]
  ------------------
  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|    809|    int32_t run_start = src_2->runs[0].value;
  396|    809|    int32_t run_end = run_start + src_2->runs[0].length;
  397|    809|    int which_run = 0;
  398|       |
  399|    809|    uint16_t val = 0;
  400|    809|    int dest_card = 0;
  401|   176k|    for (int i = 0; i < src_1->cardinality; ++i) {
  ------------------
  |  Branch (401:21): [True: 176k, False: 809]
  ------------------
  402|   176k|        val = src_1->array[i];
  403|   176k|        if (val < run_start)
  ------------------
  |  Branch (403:13): [True: 47.3k, False: 128k]
  ------------------
  404|  47.3k|            dst->array[dest_card++] = val;
  405|   128k|        else if (val <= run_end) {
  ------------------
  |  Branch (405:18): [True: 93.2k, False: 35.5k]
  ------------------
  406|  93.2k|            ;  // omitted item
  407|  93.2k|        } else {
  408|  48.0k|            do {
  409|  48.0k|                if (which_run + 1 < src_2->n_runs) {
  ------------------
  |  Branch (409:21): [True: 47.8k, False: 188]
  ------------------
  410|  47.8k|                    ++which_run;
  411|  47.8k|                    run_start = src_2->runs[which_run].value;
  412|  47.8k|                    run_end = run_start + src_2->runs[which_run].length;
  413|       |
  414|  47.8k|                } else
  415|    188|                    run_start = run_end = (1 << 16) + 1;
  416|  48.0k|            } while (val > run_end);
  ------------------
  |  Branch (416:22): [True: 12.5k, False: 35.5k]
  ------------------
  417|  35.5k|            --i;
  418|  35.5k|        }
  419|   176k|    }
  420|    809|    dst->cardinality = dest_card;
  421|    809|}
array_run_container_iandnot:
  428|     50|                                 const run_container_t *src_2) {
  429|     50|    array_run_container_andnot(src_1, src_2, src_1);
  430|     50|}
run_run_container_andnot:
  437|  1.13k|                             const run_container_t *src_2, container_t **dst) {
  438|  1.13k|    run_container_t *ans = run_container_create();
  439|  1.13k|    run_container_andnot(src_1, src_2, ans);
  440|  1.13k|    uint8_t typecode_after;
  441|  1.13k|    *dst = convert_run_to_efficient_container_and_free(ans, &typecode_after);
  442|  1.13k|    return typecode_after;
  443|  1.13k|}
run_run_container_iandnot:
  453|    463|                              const run_container_t *src_2, container_t **dst) {
  454|       |    // following Java impl as of June 2016 (dummy)
  455|    463|    int ans = run_run_container_andnot(src_1, src_2, dst);
  456|    463|    run_container_free(src_1);
  457|    463|    return ans;
  458|    463|}
array_array_container_andnot:
  466|  2.30k|                                  array_container_t *dst) {
  467|  2.30k|    array_container_andnot(src_1, src_2, dst);
  468|  2.30k|}
array_array_container_iandnot:
  473|  3.44k|                                   const array_container_t *src_2) {
  474|  3.44k|    array_container_andnot(src_1, src_2, src_1);
  475|  3.44k|}
mixed_andnot.c:run_array_array_subtract:
  235|  1.27k|                                    array_container_t *a_out) {
  236|  1.27k|    int out_card = 0;
  237|  1.27k|    int32_t in_array_pos =
  238|  1.27k|        -1;  // since advanceUntil always assumes we start the search AFTER this
  239|       |
  240|  95.4k|    for (int rlepos = 0; rlepos < rc->n_runs; rlepos++) {
  ------------------
  |  Branch (240:26): [True: 94.2k, False: 1.27k]
  ------------------
  241|  94.2k|        int32_t start = rc->runs[rlepos].value;
  242|  94.2k|        int32_t end = start + rc->runs[rlepos].length + 1;
  243|       |
  244|  94.2k|        in_array_pos = advanceUntil(a_in->array, in_array_pos,
  245|  94.2k|                                    a_in->cardinality, (uint16_t)start);
  246|       |
  247|  94.2k|        if (in_array_pos >= a_in->cardinality) {  // run has no items subtracted
  ------------------
  |  Branch (247:13): [True: 5.22k, False: 88.9k]
  ------------------
  248|  90.2k|            for (int32_t i = start; i < end; ++i)
  ------------------
  |  Branch (248:37): [True: 85.0k, False: 5.22k]
  ------------------
  249|  85.0k|                a_out->array[out_card++] = (uint16_t)i;
  250|  88.9k|        } else {
  251|  88.9k|            uint16_t next_nonincluded = a_in->array[in_array_pos];
  252|  88.9k|            if (next_nonincluded >= end) {
  ------------------
  |  Branch (252:17): [True: 29.6k, False: 59.3k]
  ------------------
  253|       |                // another case when run goes unaltered
  254|  79.2k|                for (int32_t i = start; i < end; ++i)
  ------------------
  |  Branch (254:41): [True: 49.6k, False: 29.6k]
  ------------------
  255|  49.6k|                    a_out->array[out_card++] = (uint16_t)i;
  256|  29.6k|                in_array_pos--;  // ensure we see this item again if necessary
  257|  59.3k|            } else {
  258|   283k|                for (int32_t i = start; i < end; ++i)
  ------------------
  |  Branch (258:41): [True: 223k, False: 59.3k]
  ------------------
  259|   223k|                    if (i != next_nonincluded)
  ------------------
  |  Branch (259:25): [True: 93.3k, False: 130k]
  ------------------
  260|  93.3k|                        a_out->array[out_card++] = (uint16_t)i;
  261|   130k|                    else  // 0 should ensure  we don't match
  262|   130k|                        next_nonincluded =
  263|   130k|                            (in_array_pos + 1 >= a_in->cardinality)
  ------------------
  |  Branch (263:29): [True: 1.01k, False: 129k]
  ------------------
  264|   130k|                                ? 0
  265|   130k|                                : a_in->array[++in_array_pos];
  266|  59.3k|                in_array_pos--;  // see again
  267|  59.3k|            }
  268|  88.9k|        }
  269|  94.2k|    }
  270|  1.27k|    return out_card;
  271|  1.27k|}

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

array_bitset_container_intersection:
   21|    585|                                         array_container_t *dst) {
   22|    585|    if (dst->capacity < src_1->cardinality) {
  ------------------
  |  Branch (22:9): [True: 585, False: 0]
  ------------------
   23|    585|        array_container_grow(dst, src_1->cardinality, false);
   24|    585|    }
   25|    585|    int32_t newcard = 0;  // dst could be src_1
   26|    585|    const int32_t origcard = src_1->cardinality;
   27|   311k|    for (int i = 0; i < origcard; ++i) {
  ------------------
  |  Branch (27:21): [True: 311k, False: 585]
  ------------------
   28|   311k|        uint16_t key = src_1->array[i];
   29|       |        // this branchless approach is much faster...
   30|   311k|        dst->array[newcard] = key;
   31|   311k|        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|   311k|    }
   45|    585|    dst->cardinality = newcard;
   46|    585|}
array_bitset_container_intersection_cardinality:
   50|  2.12k|    const array_container_t *src_1, const bitset_container_t *src_2) {
   51|  2.12k|    int32_t newcard = 0;
   52|  2.12k|    const int32_t origcard = src_1->cardinality;
   53|   365k|    for (int i = 0; i < origcard; ++i) {
  ------------------
  |  Branch (53:21): [True: 363k, False: 2.12k]
  ------------------
   54|   363k|        uint16_t key = src_1->array[i];
   55|   363k|        newcard += bitset_container_contains(src_2, key);
   56|   363k|    }
   57|  2.12k|    return newcard;
   58|  2.12k|}
array_bitset_container_intersect:
   61|    531|                                      const bitset_container_t *src_2) {
   62|    531|    const int32_t origcard = src_1->cardinality;
   63|  3.71k|    for (int i = 0; i < origcard; ++i) {
  ------------------
  |  Branch (63:21): [True: 3.69k, False: 19]
  ------------------
   64|  3.69k|        uint16_t key = src_1->array[i];
   65|  3.69k|        if (bitset_container_contains(src_2, key)) return true;
  ------------------
  |  Branch (65:13): [True: 512, False: 3.18k]
  ------------------
   66|  3.69k|    }
   67|     19|    return false;
   68|    531|}
array_run_container_intersection:
   75|  3.18k|                                      array_container_t *dst) {
   76|  3.18k|    if (run_container_is_full(src_2)) {
  ------------------
  |  Branch (76:9): [True: 24, False: 3.16k]
  ------------------
   77|     24|        if (dst != src_1) array_container_copy(src_1, dst);
  ------------------
  |  Branch (77:13): [True: 24, False: 0]
  ------------------
   78|     24|        return;
   79|     24|    }
   80|  3.16k|    if (dst->capacity < src_1->cardinality) {
  ------------------
  |  Branch (80:9): [True: 3.16k, False: 0]
  ------------------
   81|  3.16k|        array_container_grow(dst, src_1->cardinality, false);
   82|  3.16k|    }
   83|  3.16k|    if (src_2->n_runs == 0) {
  ------------------
  |  Branch (83:9): [True: 0, False: 3.16k]
  ------------------
   84|      0|        return;
   85|      0|    }
   86|  3.16k|    int32_t rlepos = 0;
   87|  3.16k|    int32_t arraypos = 0;
   88|  3.16k|    rle16_t rle = src_2->runs[rlepos];
   89|  3.16k|    int32_t newcard = 0;
   90|   419k|    while (arraypos < src_1->cardinality) {
  ------------------
  |  Branch (90:12): [True: 417k, False: 2.60k]
  ------------------
   91|   417k|        const uint16_t arrayval = src_1->array[arraypos];
   92|   564k|        while (rle.value + rle.length <
  ------------------
  |  Branch (92:16): [True: 147k, False: 416k]
  ------------------
   93|   564k|               arrayval) {  // this will frequently be false
   94|   147k|            ++rlepos;
   95|   147k|            if (rlepos == src_2->n_runs) {
  ------------------
  |  Branch (95:17): [True: 556, False: 146k]
  ------------------
   96|    556|                dst->cardinality = newcard;
   97|    556|                return;  // we are done
   98|    556|            }
   99|   146k|            rle = src_2->runs[rlepos];
  100|   146k|        }
  101|   416k|        if (rle.value > arrayval) {
  ------------------
  |  Branch (101:13): [True: 30.0k, False: 386k]
  ------------------
  102|  30.0k|            arraypos = advanceUntil(src_1->array, arraypos, src_1->cardinality,
  103|  30.0k|                                    rle.value);
  104|   386k|        } else {
  105|   386k|            dst->array[newcard] = arrayval;
  106|   386k|            newcard++;
  107|   386k|            arraypos++;
  108|   386k|        }
  109|   416k|    }
  110|  2.60k|    dst->cardinality = newcard;
  111|  2.60k|}
run_bitset_container_intersection:
  119|    613|                                       container_t **dst) {
  120|    613|    if (run_container_is_full(src_1)) {
  ------------------
  |  Branch (120:9): [True: 0, False: 613]
  ------------------
  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|    613|    int32_t card = run_container_cardinality(src_1);
  125|    613|    if (card <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (125:9): [True: 613, False: 0]
  ------------------
  126|       |        // result can only be an array (assuming that we never make a
  127|       |        // RunContainer)
  128|    613|        if (card > src_2->cardinality) {
  ------------------
  |  Branch (128:13): [True: 0, False: 613]
  ------------------
  129|      0|            card = src_2->cardinality;
  130|      0|        }
  131|    613|        array_container_t *answer = array_container_create_given_capacity(card);
  132|    613|        *dst = answer;
  133|    613|        if (*dst == NULL) {
  ------------------
  |  Branch (133:13): [True: 0, False: 613]
  ------------------
  134|      0|            return false;
  135|      0|        }
  136|  51.0k|        for (int32_t rlepos = 0; rlepos < src_1->n_runs; ++rlepos) {
  ------------------
  |  Branch (136:34): [True: 50.4k, False: 613]
  ------------------
  137|  50.4k|            rle16_t rle = src_1->runs[rlepos];
  138|  50.4k|            uint32_t endofrun = (uint32_t)rle.value + rle.length;
  139|   184k|            for (uint32_t runValue = rle.value; runValue <= endofrun;
  ------------------
  |  Branch (139:49): [True: 134k, False: 50.4k]
  ------------------
  140|   134k|                 ++runValue) {
  141|   134k|                answer->array[answer->cardinality] = (uint16_t)runValue;
  142|   134k|                answer->cardinality +=
  143|   134k|                    bitset_container_contains(src_2, runValue);
  144|   134k|            }
  145|  50.4k|        }
  146|    613|        return false;
  147|    613|    }
  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.96k|                                                 const run_container_t *src_2) {
  207|  7.96k|    if (run_container_is_full(src_2)) {
  ------------------
  |  Branch (207:9): [True: 96, False: 7.86k]
  ------------------
  208|     96|        return src_1->cardinality;
  209|     96|    }
  210|  7.86k|    if (src_2->n_runs == 0) {
  ------------------
  |  Branch (210:9): [True: 0, False: 7.86k]
  ------------------
  211|      0|        return 0;
  212|      0|    }
  213|  7.86k|    int32_t rlepos = 0;
  214|  7.86k|    int32_t arraypos = 0;
  215|  7.86k|    rle16_t rle = src_2->runs[rlepos];
  216|  7.86k|    int32_t newcard = 0;
  217|   786k|    while (arraypos < src_1->cardinality) {
  ------------------
  |  Branch (217:12): [True: 780k, False: 6.08k]
  ------------------
  218|   780k|        const uint16_t arrayval = src_1->array[arraypos];
  219|  1.16M|        while (rle.value + rle.length <
  ------------------
  |  Branch (219:16): [True: 383k, False: 778k]
  ------------------
  220|  1.16M|               arrayval) {  // this will frequently be false
  221|   383k|            ++rlepos;
  222|   383k|            if (rlepos == src_2->n_runs) {
  ------------------
  |  Branch (222:17): [True: 1.78k, False: 382k]
  ------------------
  223|  1.78k|                return newcard;  // we are done
  224|  1.78k|            }
  225|   382k|            rle = src_2->runs[rlepos];
  226|   382k|        }
  227|   778k|        if (rle.value > arrayval) {
  ------------------
  |  Branch (227:13): [True: 106k, False: 671k]
  ------------------
  228|   106k|            arraypos = advanceUntil(src_1->array, arraypos, src_1->cardinality,
  229|   106k|                                    rle.value);
  230|   671k|        } else {
  231|   671k|            newcard++;
  232|   671k|            arraypos++;
  233|   671k|        }
  234|   778k|    }
  235|  6.08k|    return newcard;
  236|  7.86k|}
run_bitset_container_intersection_cardinality:
  241|  2.45k|    const run_container_t *src_1, const bitset_container_t *src_2) {
  242|  2.45k|    if (run_container_is_full(src_1)) {
  ------------------
  |  Branch (242:9): [True: 0, False: 2.45k]
  ------------------
  243|      0|        return bitset_container_cardinality(src_2);
  244|      0|    }
  245|  2.45k|    int answer = 0;
  246|   204k|    for (int32_t rlepos = 0; rlepos < src_1->n_runs; ++rlepos) {
  ------------------
  |  Branch (246:30): [True: 201k, False: 2.45k]
  ------------------
  247|   201k|        rle16_t rle = src_1->runs[rlepos];
  248|   201k|        answer +=
  249|   201k|            bitset_lenrange_cardinality(src_2->words, rle.value, rle.length);
  250|   201k|    }
  251|  2.45k|    return answer;
  252|  2.45k|}
array_run_container_intersect:
  255|  1.99k|                                   const run_container_t *src_2) {
  256|  1.99k|    if (run_container_is_full(src_2)) {
  ------------------
  |  Branch (256:9): [True: 24, False: 1.96k]
  ------------------
  257|     24|        return !array_container_empty(src_1);
  258|     24|    }
  259|  1.96k|    if (src_2->n_runs == 0) {
  ------------------
  |  Branch (259:9): [True: 0, False: 1.96k]
  ------------------
  260|      0|        return false;
  261|      0|    }
  262|  1.96k|    int32_t rlepos = 0;
  263|  1.96k|    int32_t arraypos = 0;
  264|  1.96k|    rle16_t rle = src_2->runs[rlepos];
  265|  3.51k|    while (arraypos < src_1->cardinality) {
  ------------------
  |  Branch (265:12): [True: 3.45k, False: 61]
  ------------------
  266|  3.45k|        const uint16_t arrayval = src_1->array[arraypos];
  267|  8.15k|        while (rle.value + rle.length <
  ------------------
  |  Branch (267:16): [True: 4.74k, False: 3.41k]
  ------------------
  268|  8.15k|               arrayval) {  // this will frequently be false
  269|  4.74k|            ++rlepos;
  270|  4.74k|            if (rlepos == src_2->n_runs) {
  ------------------
  |  Branch (270:17): [True: 43, False: 4.70k]
  ------------------
  271|     43|                return false;  // we are done
  272|     43|            }
  273|  4.70k|            rle = src_2->runs[rlepos];
  274|  4.70k|        }
  275|  3.41k|        if (rle.value > arrayval) {
  ------------------
  |  Branch (275:13): [True: 1.54k, False: 1.86k]
  ------------------
  276|  1.54k|            arraypos = advanceUntil(src_1->array, arraypos, src_1->cardinality,
  277|  1.54k|                                    rle.value);
  278|  1.86k|        } else {
  279|  1.86k|            return true;
  280|  1.86k|        }
  281|  3.41k|    }
  282|     61|    return false;
  283|  1.96k|}
run_bitset_container_intersect:
  288|    613|                                    const bitset_container_t *src_2) {
  289|    613|    if (run_container_is_full(src_1)) {
  ------------------
  |  Branch (289:9): [True: 0, False: 613]
  ------------------
  290|      0|        return !bitset_container_empty(src_2);
  291|      0|    }
  292|  3.75k|    for (int32_t rlepos = 0; rlepos < src_1->n_runs; ++rlepos) {
  ------------------
  |  Branch (292:30): [True: 3.74k, False: 11]
  ------------------
  293|  3.74k|        rle16_t rle = src_1->runs[rlepos];
  294|  3.74k|        if (!bitset_lenrange_empty(src_2->words, rle.value, rle.length))
  ------------------
  |  Branch (294:13): [True: 602, False: 3.13k]
  ------------------
  295|    602|            return true;
  296|  3.74k|    }
  297|     11|    return false;
  298|    613|}
bitset_bitset_container_intersection_inplace:
  329|  1.40k|    container_t **dst) {
  330|  1.40k|    const int newCardinality = bitset_container_and_justcard(src_1, src_2);
  331|  1.40k|    if (newCardinality > DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (331:9): [True: 1.40k, False: 0]
  ------------------
  332|  1.40k|        *dst = src_1;
  333|  1.40k|        bitset_container_and_nocard(src_1, src_2, src_1);
  334|  1.40k|        CAST_bitset(*dst)->cardinality = newCardinality;
  ------------------
  |  |   52|  1.40k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.40k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  335|  1.40k|        return true;  // it is a bitset
  336|  1.40k|    }
  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.40k|}

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

array_container_is_subset_bitset:
   11|  2.20k|                                      const bitset_container_t* container2) {
   12|  2.20k|    if (container2->cardinality != BITSET_UNKNOWN_CARDINALITY) {
  ------------------
  |  Branch (12:9): [True: 2.20k, False: 0]
  ------------------
   13|  2.20k|        if (container2->cardinality < container1->cardinality) {
  ------------------
  |  Branch (13:13): [True: 0, False: 2.20k]
  ------------------
   14|      0|            return false;
   15|      0|        }
   16|  2.20k|    }
   17|  2.20k|    for (int i = 0; i < container1->cardinality; ++i) {
  ------------------
  |  Branch (17:21): [True: 2.20k, False: 0]
  ------------------
   18|  2.20k|        if (!bitset_container_contains(container2, container1->array[i])) {
  ------------------
  |  Branch (18:13): [True: 2.20k, False: 0]
  ------------------
   19|  2.20k|            return false;
   20|  2.20k|        }
   21|  2.20k|    }
   22|      0|    return true;
   23|  2.20k|}
run_container_is_subset_array:
   26|    391|                                   const array_container_t* container2) {
   27|    391|    if (run_container_cardinality(container1) > container2->cardinality)
  ------------------
  |  Branch (27:9): [True: 173, False: 218]
  ------------------
   28|    173|        return false;
   29|    218|    int32_t start_pos = -1, stop_pos = -1;
   30|    218|    for (int i = 0; i < container1->n_runs; ++i) {
  ------------------
  |  Branch (30:21): [True: 218, False: 0]
  ------------------
   31|    218|        int32_t start = container1->runs[i].value;
   32|    218|        int32_t stop = start + container1->runs[i].length;
   33|    218|        start_pos = advanceUntil(container2->array, stop_pos,
   34|    218|                                 container2->cardinality, start);
   35|    218|        stop_pos = advanceUntil(container2->array, stop_pos,
   36|    218|                                container2->cardinality, stop);
   37|    218|        if (stop_pos == container2->cardinality) {
  ------------------
  |  Branch (37:13): [True: 5, False: 213]
  ------------------
   38|      5|            return false;
   39|    213|        } else if (stop_pos - start_pos != stop - start ||
  ------------------
  |  Branch (39:20): [True: 78, False: 135]
  ------------------
   40|    135|                   container2->array[start_pos] != start ||
  ------------------
  |  Branch (40:20): [True: 135, False: 0]
  ------------------
   41|    213|                   container2->array[stop_pos] != stop) {
  ------------------
  |  Branch (41:20): [True: 0, False: 0]
  ------------------
   42|    213|            return false;
   43|    213|        }
   44|    218|    }
   45|      0|    return true;
   46|    218|}
array_container_is_subset_run:
   49|  2.27k|                                   const run_container_t* container2) {
   50|  2.27k|    if (container1->cardinality > run_container_cardinality(container2))
  ------------------
  |  Branch (50:9): [True: 179, False: 2.09k]
  ------------------
   51|    179|        return false;
   52|  2.09k|    int i_array = 0, i_run = 0;
   53|  5.48k|    while (i_array < container1->cardinality && i_run < container2->n_runs) {
  ------------------
  |  Branch (53:12): [True: 5.48k, False: 0]
  |  Branch (53:49): [True: 5.47k, False: 13]
  ------------------
   54|  5.47k|        uint32_t start = container2->runs[i_run].value;
   55|  5.47k|        uint32_t stop = start + container2->runs[i_run].length;
   56|  5.47k|        if (container1->array[i_array] < start) {
  ------------------
  |  Branch (56:13): [True: 2.08k, False: 3.38k]
  ------------------
   57|  2.08k|            return false;
   58|  3.38k|        } else if (container1->array[i_array] > stop) {
  ------------------
  |  Branch (58:20): [True: 3.38k, False: 0]
  ------------------
   59|  3.38k|            i_run++;
   60|  3.38k|        } else {  // the value of the array is in the run
   61|      0|            i_array++;
   62|      0|        }
   63|  5.47k|    }
   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.11k|                                  bitset_container_t *dst) {
   25|  1.11k|    if (src_2 != dst) bitset_container_copy(src_2, dst);
  ------------------
  |  Branch (25:9): [True: 1.11k, False: 0]
  ------------------
   26|  1.11k|    dst->cardinality = (int32_t)bitset_set_list_withcard(
   27|  1.11k|        dst->words, dst->cardinality, src_1->array, src_1->cardinality);
   28|  1.11k|}
run_bitset_container_union:
   43|  1.22k|                                bitset_container_t *dst) {
   44|  1.22k|    assert(!run_container_is_full(src_1));  // catch this case upstream
   45|  1.22k|    if (src_2 != dst) bitset_container_copy(src_2, dst);
  ------------------
  |  Branch (45:9): [True: 1.22k, False: 0]
  ------------------
   46|   102k|    for (int32_t rlepos = 0; rlepos < src_1->n_runs; ++rlepos) {
  ------------------
  |  Branch (46:30): [True: 100k, False: 1.22k]
  ------------------
   47|   100k|        rle16_t rle = src_1->runs[rlepos];
   48|   100k|        bitset_set_lenrange(dst->words, rle.value, rle.length);
   49|   100k|    }
   50|  1.22k|    dst->cardinality = bitset_container_compute_cardinality(dst);
   51|  1.22k|}
array_run_container_union:
   68|  2.62k|                               run_container_t *dst) {
   69|  2.62k|    if (run_container_is_full(src_2)) {
  ------------------
  |  Branch (69:9): [True: 93, False: 2.53k]
  ------------------
   70|     93|        run_container_copy(src_2, dst);
   71|     93|        return;
   72|     93|    }
   73|       |    // TODO: see whether the "2*" is spurious
   74|  2.53k|    run_container_grow(dst, 2 * (src_1->cardinality + src_2->n_runs), false);
   75|  2.53k|    int32_t rlepos = 0;
   76|  2.53k|    int32_t arraypos = 0;
   77|  2.53k|    rle16_t previousrle;
   78|  2.53k|    if (src_2->runs[rlepos].value <= src_1->array[arraypos]) {
  ------------------
  |  Branch (78:9): [True: 1.86k, False: 670]
  ------------------
   79|  1.86k|        previousrle = run_container_append_first(dst, src_2->runs[rlepos]);
   80|  1.86k|        rlepos++;
   81|  1.86k|    } else {
   82|    670|        previousrle =
   83|    670|            run_container_append_value_first(dst, src_1->array[arraypos]);
   84|    670|        arraypos++;
   85|    670|    }
   86|   466k|    while ((rlepos < src_2->n_runs) && (arraypos < src_1->cardinality)) {
  ------------------
  |  Branch (86:12): [True: 464k, False: 1.61k]
  |  Branch (86:40): [True: 463k, False: 915]
  ------------------
   87|   463k|        if (src_2->runs[rlepos].value <= src_1->array[arraypos]) {
  ------------------
  |  Branch (87:13): [True: 150k, False: 313k]
  ------------------
   88|   150k|            run_container_append(dst, src_2->runs[rlepos], &previousrle);
   89|   150k|            rlepos++;
   90|   313k|        } else {
   91|   313k|            run_container_append_value(dst, src_1->array[arraypos],
   92|   313k|                                       &previousrle);
   93|   313k|            arraypos++;
   94|   313k|        }
   95|   463k|    }
   96|  2.53k|    if (arraypos < src_1->cardinality) {
  ------------------
  |  Branch (96:9): [True: 1.61k, False: 915]
  ------------------
   97|   147k|        while (arraypos < src_1->cardinality) {
  ------------------
  |  Branch (97:16): [True: 146k, False: 1.61k]
  ------------------
   98|   146k|            run_container_append_value(dst, src_1->array[arraypos],
   99|   146k|                                       &previousrle);
  100|   146k|            arraypos++;
  101|   146k|        }
  102|  1.61k|    } else {
  103|  6.81k|        while (rlepos < src_2->n_runs) {
  ------------------
  |  Branch (103:16): [True: 5.89k, False: 915]
  ------------------
  104|  5.89k|            run_container_append(dst, src_2->runs[rlepos], &previousrle);
  105|  5.89k|            rlepos++;
  106|  5.89k|        }
  107|    915|    }
  108|  2.53k|}
array_run_container_inplace_union:
  111|    259|                                       run_container_t *src_2) {
  112|    259|    if (run_container_is_full(src_2)) {
  ------------------
  |  Branch (112:9): [True: 0, False: 259]
  ------------------
  113|      0|        return;
  114|      0|    }
  115|    259|    const int32_t maxoutput = src_1->cardinality + src_2->n_runs;
  116|    259|    const int32_t neededcapacity = maxoutput + src_2->n_runs;
  117|    259|    if (src_2->capacity < neededcapacity)
  ------------------
  |  Branch (117:9): [True: 259, False: 0]
  ------------------
  118|    259|        run_container_grow(src_2, neededcapacity, true);
  119|    259|    memmove(src_2->runs + maxoutput, src_2->runs,
  120|    259|            src_2->n_runs * sizeof(rle16_t));
  121|    259|    rle16_t *inputsrc2 = src_2->runs + maxoutput;
  122|    259|    int32_t rlepos = 0;
  123|    259|    int32_t arraypos = 0;
  124|    259|    int src2nruns = src_2->n_runs;
  125|    259|    src_2->n_runs = 0;
  126|       |
  127|    259|    rle16_t previousrle;
  128|       |
  129|    259|    if (inputsrc2[rlepos].value <= src_1->array[arraypos]) {
  ------------------
  |  Branch (129:9): [True: 224, False: 35]
  ------------------
  130|    224|        previousrle = run_container_append_first(src_2, inputsrc2[rlepos]);
  131|    224|        rlepos++;
  132|    224|    } else {
  133|     35|        previousrle =
  134|     35|            run_container_append_value_first(src_2, src_1->array[arraypos]);
  135|     35|        arraypos++;
  136|     35|    }
  137|       |
  138|  54.3k|    while ((rlepos < src2nruns) && (arraypos < src_1->cardinality)) {
  ------------------
  |  Branch (138:12): [True: 54.1k, False: 259]
  |  Branch (138:36): [True: 54.1k, False: 0]
  ------------------
  139|  54.1k|        if (inputsrc2[rlepos].value <= src_1->array[arraypos]) {
  ------------------
  |  Branch (139:13): [True: 14.2k, False: 39.8k]
  ------------------
  140|  14.2k|            run_container_append(src_2, inputsrc2[rlepos], &previousrle);
  141|  14.2k|            rlepos++;
  142|  39.8k|        } else {
  143|  39.8k|            run_container_append_value(src_2, src_1->array[arraypos],
  144|  39.8k|                                       &previousrle);
  145|  39.8k|            arraypos++;
  146|  39.8k|        }
  147|  54.1k|    }
  148|    259|    if (arraypos < src_1->cardinality) {
  ------------------
  |  Branch (148:9): [True: 259, False: 0]
  ------------------
  149|  2.70k|        while (arraypos < src_1->cardinality) {
  ------------------
  |  Branch (149:16): [True: 2.44k, False: 259]
  ------------------
  150|  2.44k|            run_container_append_value(src_2, src_1->array[arraypos],
  151|  2.44k|                                       &previousrle);
  152|  2.44k|            arraypos++;
  153|  2.44k|        }
  154|    259|    } 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|    259|}
array_array_container_union:
  164|  2.30k|                                 container_t **dst) {
  165|  2.30k|    int totalCardinality = src_1->cardinality + src_2->cardinality;
  166|  2.30k|    if (totalCardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (166:9): [True: 2.18k, False: 116]
  ------------------
  167|  2.18k|        *dst = array_container_create_given_capacity(totalCardinality);
  168|  2.18k|        if (*dst != NULL) {
  ------------------
  |  Branch (168:13): [True: 2.18k, False: 0]
  ------------------
  169|  2.18k|            array_container_union(src_1, src_2, CAST_array(*dst));
  ------------------
  |  |   54|  2.18k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  2.18k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  170|  2.18k|        } else {
  171|      0|            return true;  // otherwise failure won't be caught
  172|      0|        }
  173|  2.18k|        return false;  // not a bitset
  174|  2.18k|    }
  175|    116|    *dst = bitset_container_create();
  176|    116|    bool returnval = true;  // expect a bitset
  177|    116|    if (*dst != NULL) {
  ------------------
  |  Branch (177:9): [True: 116, False: 0]
  ------------------
  178|    116|        bitset_container_t *ourbitset = CAST_bitset(*dst);
  ------------------
  |  |   52|    116|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    116|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  179|    116|        bitset_set_list(ourbitset->words, src_1->array, src_1->cardinality);
  180|    116|        ourbitset->cardinality = (int32_t)bitset_set_list_withcard(
  181|    116|            ourbitset->words, src_1->cardinality, src_2->array,
  182|    116|            src_2->cardinality);
  183|    116|        if (ourbitset->cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (183:13): [True: 62, False: 54]
  ------------------
  184|       |            // need to convert!
  185|     62|            *dst = array_container_from_bitset(ourbitset);
  186|     62|            bitset_container_free(ourbitset);
  187|       |            returnval = false;  // not going to be a bitset
  188|     62|        }
  189|    116|    }
  190|    116|    return returnval;
  191|  2.30k|}
array_array_container_inplace_union:
  195|  2.47k|                                         container_t **dst) {
  196|  2.47k|    int totalCardinality = src_1->cardinality + src_2->cardinality;
  197|  2.47k|    *dst = NULL;
  198|  2.47k|    if (totalCardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (198:9): [True: 2.40k, False: 77]
  ------------------
  199|  2.40k|        if (src_1->capacity < totalCardinality) {
  ------------------
  |  Branch (199:13): [True: 2.40k, False: 0]
  ------------------
  200|  2.40k|            *dst = array_container_create_given_capacity(
  201|  2.40k|                2 * totalCardinality);  // be purposefully generous
  202|  2.40k|            if (*dst != NULL) {
  ------------------
  |  Branch (202:17): [True: 2.40k, False: 0]
  ------------------
  203|  2.40k|                array_container_union(src_1, src_2, CAST_array(*dst));
  ------------------
  |  |   54|  2.40k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  2.40k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  204|  2.40k|            } else {
  205|      0|                return true;  // otherwise failure won't be caught
  206|      0|            }
  207|  2.40k|            return false;  // not a bitset
  208|  2.40k|        } 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.40k|    }
  221|     77|    *dst = bitset_container_create();
  222|     77|    bool returnval = true;  // expect a bitset
  223|     77|    if (*dst != NULL) {
  ------------------
  |  Branch (223:9): [True: 77, False: 0]
  ------------------
  224|     77|        bitset_container_t *ourbitset = CAST_bitset(*dst);
  ------------------
  |  |   52|     77|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     77|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  225|     77|        bitset_set_list(ourbitset->words, src_1->array, src_1->cardinality);
  226|     77|        ourbitset->cardinality = (int32_t)bitset_set_list_withcard(
  227|     77|            ourbitset->words, src_1->cardinality, src_2->array,
  228|     77|            src_2->cardinality);
  229|     77|        if (ourbitset->cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (229:13): [True: 77, False: 0]
  ------------------
  230|       |            // need to convert!
  231|     77|            if (src_1->capacity < ourbitset->cardinality) {
  ------------------
  |  Branch (231:17): [True: 77, False: 0]
  ------------------
  232|     77|                array_container_grow(src_1, ourbitset->cardinality, false);
  233|     77|            }
  234|       |
  235|     77|            bitset_extract_setbits_uint16(ourbitset->words,
  236|     77|                                          BITSET_CONTAINER_SIZE_IN_WORDS,
  237|     77|                                          src_1->array, 0);
  238|     77|            src_1->cardinality = ourbitset->cardinality;
  239|     77|            *dst = src_1;
  240|     77|            bitset_container_free(ourbitset);
  241|       |            returnval = false;  // not going to be a bitset
  242|     77|        }
  243|     77|    }
  244|     77|    return returnval;
  245|  2.47k|}

array_bitset_container_xor:
   25|    619|                                container_t **dst) {
   26|    619|    bitset_container_t *result = bitset_container_create();
   27|    619|    bitset_container_copy(src_2, result);
   28|    619|    result->cardinality = (int32_t)bitset_flip_list_withcard(
   29|    619|        result->words, result->cardinality, src_1->array, src_1->cardinality);
   30|       |
   31|       |    // do required type conversions.
   32|    619|    if (result->cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (32:9): [True: 136, False: 483]
  ------------------
   33|    136|        *dst = array_container_from_bitset(result);
   34|    136|        bitset_container_free(result);
   35|    136|        return false;  // not bitset
   36|    136|    }
   37|    483|    *dst = result;
   38|       |    return true;  // bitset
   39|    619|}
run_bitset_container_xor:
   63|    698|                              container_t **dst) {
   64|    698|    bitset_container_t *result = bitset_container_create();
   65|       |
   66|    698|    bitset_container_copy(src_2, result);
   67|  54.5k|    for (int32_t rlepos = 0; rlepos < src_1->n_runs; ++rlepos) {
  ------------------
  |  Branch (67:30): [True: 53.8k, False: 698]
  ------------------
   68|  53.8k|        rle16_t rle = src_1->runs[rlepos];
   69|  53.8k|        bitset_flip_range(result->words, rle.value,
   70|  53.8k|                          rle.value + rle.length + UINT32_C(1));
   71|  53.8k|    }
   72|    698|    result->cardinality = bitset_container_compute_cardinality(result);
   73|       |
   74|    698|    if (result->cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (74:9): [True: 134, False: 564]
  ------------------
   75|    134|        *dst = array_container_from_bitset(result);
   76|    134|        bitset_container_free(result);
   77|    134|        return false;  // not bitset
   78|    134|    }
   79|    564|    *dst = result;
   80|       |    return true;  // bitset
   81|    698|}
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: 893, False: 1.41k]
  ------------------
  114|    893|        run_container_t *ans = run_container_create();
  115|    893|        array_run_container_lazy_xor(src_1, src_2, ans);  // keeps runs.
  116|    893|        uint8_t typecode_after;
  117|    893|        *dst =
  118|    893|            convert_run_to_efficient_container_and_free(ans, &typecode_after);
  119|    893|        return typecode_after;
  120|    893|    }
  121|       |
  122|  1.41k|    int card = run_container_cardinality(src_2);
  123|  1.41k|    if (card <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (123:9): [True: 1.15k, False: 266]
  ------------------
  124|       |        // Java implementation works with the array, xoring the run elements via
  125|       |        // iterator
  126|  1.15k|        array_container_t *temp = array_container_from_run(src_2);
  127|  1.15k|        bool ret_is_bitset = array_array_container_xor(temp, src_1, dst);
  128|  1.15k|        array_container_free(temp);
  129|  1.15k|        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.14k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (129:16): [True: 3, False: 1.14k]
  ------------------
  130|       |
  131|  1.15k|    } else {  // guess that it will end up as a bitset
  132|    266|        bitset_container_t *result = bitset_container_from_run(src_2);
  133|    266|        bool is_bitset = bitset_array_container_ixor(result, src_1, dst);
  134|       |        // any necessary type conversion has been done by the ixor
  135|    266|        int retval = (is_bitset ? BITSET_CONTAINER_TYPE : ARRAY_CONTAINER_TYPE);
  ------------------
  |  |   48|    247|#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: 247, False: 19]
  ------------------
  136|    266|        return retval;
  137|    266|    }
  138|  1.41k|}
array_run_container_lazy_xor:
  147|    893|                                  run_container_t *dst) {
  148|    893|    run_container_grow(dst, src_1->cardinality + src_2->n_runs, false);
  149|    893|    int32_t rlepos = 0;
  150|    893|    int32_t arraypos = 0;
  151|    893|    dst->n_runs = 0;
  152|       |
  153|  27.8k|    while ((rlepos < src_2->n_runs) && (arraypos < src_1->cardinality)) {
  ------------------
  |  Branch (153:12): [True: 27.2k, False: 547]
  |  Branch (153:40): [True: 26.9k, False: 346]
  ------------------
  154|  26.9k|        if (src_2->runs[rlepos].value <= src_1->array[arraypos]) {
  ------------------
  |  Branch (154:13): [True: 16.3k, False: 10.6k]
  ------------------
  155|  16.3k|            run_container_smart_append_exclusive(dst, src_2->runs[rlepos].value,
  156|  16.3k|                                                 src_2->runs[rlepos].length);
  157|  16.3k|            rlepos++;
  158|  16.3k|        } else {
  159|  10.6k|            run_container_smart_append_exclusive(dst, src_1->array[arraypos],
  160|  10.6k|                                                 0);
  161|  10.6k|            arraypos++;
  162|  10.6k|        }
  163|  26.9k|    }
  164|  3.06k|    while (arraypos < src_1->cardinality) {
  ------------------
  |  Branch (164:12): [True: 2.17k, False: 893]
  ------------------
  165|  2.17k|        run_container_smart_append_exclusive(dst, src_1->array[arraypos], 0);
  166|  2.17k|        arraypos++;
  167|  2.17k|    }
  168|  9.05k|    while (rlepos < src_2->n_runs) {
  ------------------
  |  Branch (168:12): [True: 8.16k, False: 893]
  ------------------
  169|  8.16k|        run_container_smart_append_exclusive(dst, src_2->runs[rlepos].value,
  170|  8.16k|                                             src_2->runs[rlepos].length);
  171|  8.16k|        rlepos++;
  172|  8.16k|    }
  173|    893|}
run_run_container_xor:
  180|  55.7k|                          const run_container_t *src_2, container_t **dst) {
  181|  55.7k|    run_container_t *ans = run_container_create();
  182|  55.7k|    run_container_xor(src_1, src_2, ans);
  183|  55.7k|    uint8_t typecode_after;
  184|  55.7k|    *dst = convert_run_to_efficient_container_and_free(ans, &typecode_after);
  185|  55.7k|    return typecode_after;
  186|  55.7k|}
array_array_container_xor:
  198|  8.23k|                               container_t **dst) {
  199|  8.23k|    int totalCardinality =
  200|  8.23k|        src_1->cardinality + src_2->cardinality;  // upper bound
  201|  8.23k|    if (totalCardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (201:9): [True: 7.71k, False: 519]
  ------------------
  202|  7.71k|        *dst = array_container_create_given_capacity(totalCardinality);
  203|  7.71k|        array_container_xor(src_1, src_2, CAST_array(*dst));
  ------------------
  |  |   54|  7.71k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  7.71k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  204|  7.71k|        return false;  // not a bitset
  205|  7.71k|    }
  206|    519|    *dst = bitset_container_from_array(src_1);
  207|    519|    bool returnval = true;  // expect a bitset
  208|    519|    bitset_container_t *ourbitset = CAST_bitset(*dst);
  ------------------
  |  |   52|    519|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    519|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  209|    519|    ourbitset->cardinality = (uint32_t)bitset_flip_list_withcard(
  210|    519|        ourbitset->words, src_1->cardinality, src_2->array, src_2->cardinality);
  211|    519|    if (ourbitset->cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (211:9): [True: 504, False: 15]
  ------------------
  212|       |        // need to convert!
  213|    504|        *dst = array_container_from_bitset(ourbitset);
  214|    504|        bitset_container_free(ourbitset);
  215|    504|        returnval = false;  // not going to be a bitset
  216|    504|    }
  217|       |
  218|    519|    return returnval;
  219|  8.23k|}
bitset_array_container_ixor:
  284|    266|                                 container_t **dst) {
  285|    266|    *dst = src_1;
  286|    266|    src_1->cardinality = (uint32_t)bitset_flip_list_withcard(
  287|    266|        src_1->words, src_1->cardinality, src_2->array, src_2->cardinality);
  288|       |
  289|    266|    if (src_1->cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (289:9): [True: 19, False: 247]
  ------------------
  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|    247|        return true;
  295|    266|}
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|     88|                                 container_t **dst) {
  319|       |    bool ans = array_bitset_container_xor(src_1, src_2, dst);
  320|     88|    array_container_free(src_1);
  321|     88|    return ans;
  322|     88|}
run_bitset_container_ixor:
  333|     22|                               container_t **dst) {
  334|       |    bool ans = run_bitset_container_xor(src_1, src_2, dst);
  335|     22|    run_container_free(src_1);
  336|     22|    return ans;
  337|     22|}
bitset_run_container_ixor:
  341|     63|                               container_t **dst) {
  342|       |    bool ans = run_bitset_container_xor(src_2, src_1, dst);
  343|     63|    bitset_container_free(src_1);
  344|     63|    return ans;
  345|     63|}
array_run_container_ixor:
  352|    262|                             const run_container_t *src_2, container_t **dst) {
  353|    262|    int ans = array_run_container_xor(src_1, src_2, dst);
  354|    262|    array_container_free(src_1);
  355|    262|    return ans;
  356|    262|}
run_array_container_ixor:
  360|     58|                             container_t **dst) {
  361|     58|    int ans = array_run_container_xor(src_2, src_1, dst);
  362|     58|    run_container_free(src_1);
  363|     58|    return ans;
  364|     58|}
array_array_container_ixor:
  368|  4.78k|                                container_t **dst) {
  369|       |    bool ans = array_array_container_xor(src_1, src_2, dst);
  370|  4.78k|    array_container_free(src_1);
  371|  4.78k|    return ans;
  372|  4.78k|}
run_run_container_ixor:
  375|  55.0k|                           container_t **dst) {
  376|  55.0k|    int ans = run_run_container_xor(src_1, src_2, dst);
  377|  55.0k|    run_container_free(src_1);
  378|  55.0k|    return ans;
  379|  55.0k|}

run_container_add:
   39|   412k|bool run_container_add(run_container_t *run, uint16_t pos) {
   40|   412k|    int32_t index = interleavedBinarySearch(run->runs, run->n_runs, pos);
   41|   412k|    if (index >= 0) return false;  // already there
  ------------------
  |  Branch (41:9): [True: 179k, False: 232k]
  ------------------
   42|   232k|    index = -index - 2;            // points to preceding value, possibly -1
   43|   232k|    if (index >= 0) {              // possible match
  ------------------
  |  Branch (43:9): [True: 232k, False: 458]
  ------------------
   44|   232k|        int32_t offset = pos - run->runs[index].value;
   45|   232k|        int32_t le = run->runs[index].length;
   46|   232k|        if (offset <= le) return false;  // already there
  ------------------
  |  Branch (46:13): [True: 138k, False: 93.6k]
  ------------------
   47|  93.6k|        if (offset == le + 1) {
  ------------------
  |  Branch (47:13): [True: 14.4k, False: 79.2k]
  ------------------
   48|       |            // we may need to fuse
   49|  14.4k|            if (index + 1 < run->n_runs) {
  ------------------
  |  Branch (49:17): [True: 14.1k, False: 248]
  ------------------
   50|  14.1k|                if (run->runs[index + 1].value == pos + 1) {
  ------------------
  |  Branch (50:21): [True: 6.59k, False: 7.59k]
  ------------------
   51|       |                    // indeed fusion is needed
   52|  6.59k|                    run->runs[index].length = run->runs[index + 1].value +
   53|  6.59k|                                              run->runs[index + 1].length -
   54|  6.59k|                                              run->runs[index].value;
   55|  6.59k|                    recoverRoomAtIndex(run, (uint16_t)(index + 1));
   56|  6.59k|                    return true;
   57|  6.59k|                }
   58|  14.1k|            }
   59|  7.84k|            run->runs[index].length++;
   60|  7.84k|            return true;
   61|  14.4k|        }
   62|  79.2k|        if (index + 1 < run->n_runs) {
  ------------------
  |  Branch (62:13): [True: 77.3k, False: 1.86k]
  ------------------
   63|       |            // we may need to fuse
   64|  77.3k|            if (run->runs[index + 1].value == pos + 1) {
  ------------------
  |  Branch (64:17): [True: 33.6k, False: 43.7k]
  ------------------
   65|       |                // indeed fusion is needed
   66|  33.6k|                run->runs[index + 1].value = pos;
   67|  33.6k|                run->runs[index + 1].length = run->runs[index + 1].length + 1;
   68|  33.6k|                return true;
   69|  33.6k|            }
   70|  77.3k|        }
   71|  79.2k|    }
   72|  46.0k|    if (index == -1) {
  ------------------
  |  Branch (72:9): [True: 458, False: 45.5k]
  ------------------
   73|       |        // we may need to extend the first run
   74|    458|        if (0 < run->n_runs) {
  ------------------
  |  Branch (74:13): [True: 458, False: 0]
  ------------------
   75|    458|            if (run->runs[0].value == pos + 1) {
  ------------------
  |  Branch (75:17): [True: 284, False: 174]
  ------------------
   76|    284|                run->runs[0].length++;
   77|    284|                run->runs[0].value--;
   78|    284|                return true;
   79|    284|            }
   80|    458|        }
   81|    458|    }
   82|  45.7k|    makeRoomAtIndex(run, (uint16_t)(index + 1));
   83|  45.7k|    run->runs[index + 1].value = pos;
   84|  45.7k|    run->runs[index + 1].length = 0;
   85|       |    return true;
   86|  46.0k|}
run_container_create_given_capacity:
   89|   372k|run_container_t *run_container_create_given_capacity(int32_t size) {
   90|   372k|    run_container_t *run;
   91|       |    /* Allocate the run container itself. */
   92|   372k|    if ((run = (run_container_t *)roaring_malloc(sizeof(run_container_t))) ==
  ------------------
  |  Branch (92:9): [True: 0, False: 372k]
  ------------------
   93|   372k|        NULL) {
   94|      0|        return NULL;
   95|      0|    }
   96|   372k|    if (size <= 0) {  // we don't want to rely on malloc(0)
  ------------------
  |  Branch (96:9): [True: 117k, False: 254k]
  ------------------
   97|   117k|        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|   372k|    run->capacity = size;
  104|   372k|    run->n_runs = 0;
  105|   372k|    return run;
  106|   372k|}
run_container_shrink_to_fit:
  108|  2.54k|int run_container_shrink_to_fit(run_container_t *src) {
  109|  2.54k|    if (src->n_runs == src->capacity) return 0;  // nothing to do
  ------------------
  |  Branch (109:9): [True: 2.54k, 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.54k|}
run_container_create:
  119|   117k|run_container_t *run_container_create(void) {
  120|   117k|    return run_container_create_given_capacity(RUN_DEFAULT_INIT_SIZE);
  121|   117k|}
run_container_clone:
  124|   164k|run_container_t *run_container_clone(const run_container_t *src) {
  125|   164k|    run_container_t *run = run_container_create_given_capacity(src->capacity);
  126|   164k|    if (run == NULL) return NULL;
  ------------------
  |  Branch (126:9): [True: 0, False: 164k]
  ------------------
  127|   164k|    run->capacity = src->capacity;
  128|   164k|    run->n_runs = src->n_runs;
  129|   164k|    memcpy(run->runs, src->runs, src->n_runs * sizeof(rle16_t));
  130|   164k|    return run;
  131|   164k|}
run_container_free:
  193|   372k|void run_container_free(run_container_t *run) {
  194|   372k|    if (run == NULL) return;
  ------------------
  |  Branch (194:9): [True: 0, False: 372k]
  ------------------
  195|   372k|    roaring_free(run->runs);
  196|   372k|    roaring_free(run);
  197|   372k|}
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: 117k, False: 5.14k]
  ------------------
  201|   123k|                          : run->capacity < 64   ? run->capacity * 2
  ------------------
  |  Branch (201:29): [True: 3.54k, False: 1.60k]
  ------------------
  202|  5.14k|                          : run->capacity < 1024 ? run->capacity * 3 / 2
  ------------------
  |  Branch (202:29): [True: 1.60k, False: 0]
  ------------------
  203|  1.60k|                                                 : run->capacity * 5 / 4;
  204|   123k|    if (newCapacity < min) newCapacity = min;
  ------------------
  |  Branch (204:9): [True: 119k, False: 3.24k]
  ------------------
  205|   123k|    run->capacity = newCapacity;
  206|   123k|    assert(run->capacity >= min);
  207|   123k|    if (copy) {
  ------------------
  |  Branch (207:9): [True: 5.14k, False: 117k]
  ------------------
  208|  5.14k|        rle16_t *oldruns = run->runs;
  209|  5.14k|        run->runs = (rle16_t *)roaring_realloc(oldruns,
  210|  5.14k|                                               run->capacity * sizeof(rle16_t));
  211|  5.14k|        if (run->runs == NULL) roaring_free(oldruns);
  ------------------
  |  Branch (211:13): [True: 0, False: 5.14k]
  ------------------
  212|   117k|    } else {
  213|   117k|        roaring_free(run->runs);
  214|   117k|        run->runs = (rle16_t *)roaring_malloc(run->capacity * sizeof(rle16_t));
  215|   117k|    }
  216|       |    // We may have run->runs == NULL.
  217|   123k|}
run_container_copy:
  220|  53.5k|void run_container_copy(const run_container_t *src, run_container_t *dst) {
  221|  53.5k|    const int32_t n_runs = src->n_runs;
  222|  53.5k|    if (src->n_runs > dst->capacity) {
  ------------------
  |  Branch (222:9): [True: 53.4k, False: 34]
  ------------------
  223|       |        run_container_grow(dst, n_runs, false);
  224|  53.4k|    }
  225|  53.5k|    dst->n_runs = n_runs;
  226|  53.5k|    memcpy(dst->runs, src->runs, sizeof(rle16_t) * n_runs);
  227|  53.5k|}
run_container_union:
  232|    690|                         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|    690|    const bool if1 = run_container_is_full(src_1);
  237|    690|    const bool if2 = run_container_is_full(src_2);
  238|    690|    if (if1 || if2) {
  ------------------
  |  Branch (238:9): [True: 0, False: 690]
  |  Branch (238:16): [True: 14, False: 676]
  ------------------
  239|     14|        if (if1) {
  ------------------
  |  Branch (239:13): [True: 0, False: 14]
  ------------------
  240|      0|            run_container_copy(src_1, dst);
  241|      0|            return;
  242|      0|        }
  243|     14|        if (if2) {
  ------------------
  |  Branch (243:13): [True: 14, False: 0]
  ------------------
  244|     14|            run_container_copy(src_2, dst);
  245|     14|            return;
  246|     14|        }
  247|     14|    }
  248|    676|    const int32_t neededcapacity = src_1->n_runs + src_2->n_runs;
  249|    676|    if (dst->capacity < neededcapacity)
  ------------------
  |  Branch (249:9): [True: 676, False: 0]
  ------------------
  250|    676|        run_container_grow(dst, neededcapacity, false);
  251|    676|    dst->n_runs = 0;
  252|    676|    int32_t rlepos = 0;
  253|    676|    int32_t xrlepos = 0;
  254|       |
  255|    676|    rle16_t previousrle;
  256|    676|    if (src_1->runs[rlepos].value <= src_2->runs[xrlepos].value) {
  ------------------
  |  Branch (256:9): [True: 632, False: 44]
  ------------------
  257|    632|        previousrle = run_container_append_first(dst, src_1->runs[rlepos]);
  258|    632|        rlepos++;
  259|    632|    } else {
  260|     44|        previousrle = run_container_append_first(dst, src_2->runs[xrlepos]);
  261|     44|        xrlepos++;
  262|     44|    }
  263|       |
  264|  85.1k|    while ((xrlepos < src_2->n_runs) && (rlepos < src_1->n_runs)) {
  ------------------
  |  Branch (264:12): [True: 84.8k, False: 295]
  |  Branch (264:41): [True: 84.4k, False: 381]
  ------------------
  265|  84.4k|        rle16_t newrl;
  266|  84.4k|        if (src_1->runs[rlepos].value <= src_2->runs[xrlepos].value) {
  ------------------
  |  Branch (266:13): [True: 46.8k, False: 37.6k]
  ------------------
  267|  46.8k|            newrl = src_1->runs[rlepos];
  268|  46.8k|            rlepos++;
  269|  46.8k|        } else {
  270|  37.6k|            newrl = src_2->runs[xrlepos];
  271|  37.6k|            xrlepos++;
  272|  37.6k|        }
  273|  84.4k|        run_container_append(dst, newrl, &previousrle);
  274|  84.4k|    }
  275|  1.65k|    while (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (275:12): [True: 975, False: 676]
  ------------------
  276|    975|        run_container_append(dst, src_2->runs[xrlepos], &previousrle);
  277|    975|        xrlepos++;
  278|    975|    }
  279|  14.7k|    while (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (279:12): [True: 14.0k, False: 676]
  ------------------
  280|  14.0k|        run_container_append(dst, src_1->runs[rlepos], &previousrle);
  281|  14.0k|        rlepos++;
  282|  14.0k|    }
  283|    676|}
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: 34, False: 1.64k]
  ------------------
  295|     34|        if (if1) {
  ------------------
  |  Branch (295:13): [True: 0, False: 34]
  ------------------
  296|      0|            return;
  297|      0|        }
  298|     34|        if (if2) {
  ------------------
  |  Branch (298:13): [True: 34, False: 0]
  ------------------
  299|     34|            run_container_copy(src_2, src_1);
  300|     34|            return;
  301|     34|        }
  302|     34|    }
  303|       |    // we move the data to the end of the current array
  304|  1.64k|    const int32_t maxoutput = src_1->n_runs + src_2->n_runs;
  305|  1.64k|    const int32_t neededcapacity = maxoutput + src_1->n_runs;
  306|  1.64k|    if (src_1->capacity < neededcapacity)
  ------------------
  |  Branch (306:9): [True: 1.64k, False: 0]
  ------------------
  307|  1.64k|        run_container_grow(src_1, neededcapacity, true);
  308|  1.64k|    memmove(src_1->runs + maxoutput, src_1->runs,
  309|  1.64k|            src_1->n_runs * sizeof(rle16_t));
  310|  1.64k|    rle16_t *inputsrc1 = src_1->runs + maxoutput;
  311|  1.64k|    const int32_t input1nruns = src_1->n_runs;
  312|  1.64k|    src_1->n_runs = 0;
  313|  1.64k|    int32_t rlepos = 0;
  314|  1.64k|    int32_t xrlepos = 0;
  315|       |
  316|  1.64k|    rle16_t previousrle;
  317|  1.64k|    if (inputsrc1[rlepos].value <= src_2->runs[xrlepos].value) {
  ------------------
  |  Branch (317:9): [True: 1.56k, False: 73]
  ------------------
  318|  1.56k|        previousrle = run_container_append_first(src_1, inputsrc1[rlepos]);
  319|  1.56k|        rlepos++;
  320|  1.56k|    } else {
  321|     73|        previousrle = run_container_append_first(src_1, src_2->runs[xrlepos]);
  322|     73|        xrlepos++;
  323|     73|    }
  324|   194k|    while ((xrlepos < src_2->n_runs) && (rlepos < input1nruns)) {
  ------------------
  |  Branch (324:12): [True: 194k, False: 139]
  |  Branch (324:41): [True: 192k, False: 1.50k]
  ------------------
  325|   192k|        rle16_t newrl;
  326|   192k|        if (inputsrc1[rlepos].value <= src_2->runs[xrlepos].value) {
  ------------------
  |  Branch (326:13): [True: 93.6k, False: 99.0k]
  ------------------
  327|  93.6k|            newrl = inputsrc1[rlepos];
  328|  93.6k|            rlepos++;
  329|  99.0k|        } else {
  330|  99.0k|            newrl = src_2->runs[xrlepos];
  331|  99.0k|            xrlepos++;
  332|  99.0k|        }
  333|   192k|        run_container_append(src_1, newrl, &previousrle);
  334|   192k|    }
  335|  4.22k|    while (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (335:12): [True: 2.58k, False: 1.64k]
  ------------------
  336|  2.58k|        run_container_append(src_1, src_2->runs[xrlepos], &previousrle);
  337|  2.58k|        xrlepos++;
  338|  2.58k|    }
  339|  10.4k|    while (rlepos < input1nruns) {
  ------------------
  |  Branch (339:12): [True: 8.76k, False: 1.64k]
  ------------------
  340|  8.76k|        run_container_append(src_1, inputsrc1[rlepos], &previousrle);
  341|  8.76k|        rlepos++;
  342|  8.76k|    }
  343|  1.64k|}
run_container_xor:
  349|  55.7k|                       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|  55.7k|    const int32_t neededcapacity = src_1->n_runs + src_2->n_runs;
  354|  55.7k|    if (dst->capacity < neededcapacity)
  ------------------
  |  Branch (354:9): [True: 55.7k, False: 0]
  ------------------
  355|  55.7k|        run_container_grow(dst, neededcapacity, false);
  356|       |
  357|  55.7k|    int32_t pos1 = 0;
  358|  55.7k|    int32_t pos2 = 0;
  359|  55.7k|    dst->n_runs = 0;
  360|       |
  361|   235k|    while ((pos1 < src_1->n_runs) && (pos2 < src_2->n_runs)) {
  ------------------
  |  Branch (361:12): [True: 179k, False: 55.4k]
  |  Branch (361:38): [True: 179k, False: 315]
  ------------------
  362|   179k|        if (src_1->runs[pos1].value <= src_2->runs[pos2].value) {
  ------------------
  |  Branch (362:13): [True: 120k, False: 58.8k]
  ------------------
  363|   120k|            run_container_smart_append_exclusive(dst, src_1->runs[pos1].value,
  364|   120k|                                                 src_1->runs[pos1].length);
  365|   120k|            pos1++;
  366|   120k|        } else {
  367|  58.8k|            run_container_smart_append_exclusive(dst, src_2->runs[pos2].value,
  368|  58.8k|                                                 src_2->runs[pos2].length);
  369|  58.8k|            pos2++;
  370|  58.8k|        }
  371|   179k|    }
  372|  71.1k|    while (pos1 < src_1->n_runs) {
  ------------------
  |  Branch (372:12): [True: 15.4k, False: 55.7k]
  ------------------
  373|  15.4k|        run_container_smart_append_exclusive(dst, src_1->runs[pos1].value,
  374|  15.4k|                                             src_1->runs[pos1].length);
  375|  15.4k|        pos1++;
  376|  15.4k|    }
  377|       |
  378|   113k|    while (pos2 < src_2->n_runs) {
  ------------------
  |  Branch (378:12): [True: 57.8k, False: 55.7k]
  ------------------
  379|  57.8k|        run_container_smart_append_exclusive(dst, src_2->runs[pos2].value,
  380|  57.8k|                                             src_2->runs[pos2].length);
  381|  57.8k|        pos2++;
  382|  57.8k|    }
  383|  55.7k|}
run_container_intersection:
  389|  56.7k|                                run_container_t *dst) {
  390|  56.7k|    const bool if1 = run_container_is_full(src_1);
  391|  56.7k|    const bool if2 = run_container_is_full(src_2);
  392|  56.7k|    if (if1 || if2) {
  ------------------
  |  Branch (392:9): [True: 53.3k, False: 3.39k]
  |  Branch (392:16): [True: 14, False: 3.38k]
  ------------------
  393|  53.3k|        if (if1) {
  ------------------
  |  Branch (393:13): [True: 53.3k, False: 14]
  ------------------
  394|  53.3k|            run_container_copy(src_2, dst);
  395|  53.3k|            return;
  396|  53.3k|        }
  397|     14|        if (if2) {
  ------------------
  |  Branch (397:13): [True: 14, False: 0]
  ------------------
  398|     14|            run_container_copy(src_1, dst);
  399|     14|            return;
  400|     14|        }
  401|     14|    }
  402|       |    // TODO: this could be a lot more efficient, could use SIMD optimizations
  403|  3.38k|    const int32_t neededcapacity = src_1->n_runs + src_2->n_runs;
  404|  3.38k|    if (dst->capacity < neededcapacity)
  ------------------
  |  Branch (404:9): [True: 3.38k, False: 0]
  ------------------
  405|  3.38k|        run_container_grow(dst, neededcapacity, false);
  406|  3.38k|    dst->n_runs = 0;
  407|  3.38k|    int32_t rlepos = 0;
  408|  3.38k|    int32_t xrlepos = 0;
  409|  3.38k|    int32_t start = src_1->runs[rlepos].value;
  410|  3.38k|    int32_t end = start + src_1->runs[rlepos].length + 1;
  411|  3.38k|    int32_t xstart = src_2->runs[xrlepos].value;
  412|  3.38k|    int32_t xend = xstart + src_2->runs[xrlepos].length + 1;
  413|   187k|    while ((rlepos < src_1->n_runs) && (xrlepos < src_2->n_runs)) {
  ------------------
  |  Branch (413:12): [True: 184k, False: 2.92k]
  |  Branch (413:40): [True: 183k, False: 460]
  ------------------
  414|   183k|        if (end <= xstart) {
  ------------------
  |  Branch (414:13): [True: 48.0k, False: 135k]
  ------------------
  415|  48.0k|            ++rlepos;
  416|  48.0k|            if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (416:17): [True: 47.9k, False: 73]
  ------------------
  417|  47.9k|                start = src_1->runs[rlepos].value;
  418|  47.9k|                end = start + src_1->runs[rlepos].length + 1;
  419|  47.9k|            }
  420|   135k|        } else if (xend <= start) {
  ------------------
  |  Branch (420:20): [True: 12.0k, False: 123k]
  ------------------
  421|  12.0k|            ++xrlepos;
  422|  12.0k|            if (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (422:17): [True: 12.0k, False: 42]
  ------------------
  423|  12.0k|                xstart = src_2->runs[xrlepos].value;
  424|  12.0k|                xend = xstart + src_2->runs[xrlepos].length + 1;
  425|  12.0k|            }
  426|   123k|        } else {  // they overlap
  427|   123k|            const int32_t lateststart = start > xstart ? start : xstart;
  ------------------
  |  Branch (427:41): [True: 17.8k, False: 106k]
  ------------------
  428|   123k|            int32_t earliestend;
  429|   123k|            if (end == xend) {  // improbable
  ------------------
  |  Branch (429:17): [True: 91.3k, False: 32.4k]
  ------------------
  430|  91.3k|                earliestend = end;
  431|  91.3k|                rlepos++;
  432|  91.3k|                xrlepos++;
  433|  91.3k|                if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (433:21): [True: 88.7k, False: 2.69k]
  ------------------
  434|  88.7k|                    start = src_1->runs[rlepos].value;
  435|  88.7k|                    end = start + src_1->runs[rlepos].length + 1;
  436|  88.7k|                }
  437|  91.3k|                if (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (437:21): [True: 88.5k, False: 2.89k]
  ------------------
  438|  88.5k|                    xstart = src_2->runs[xrlepos].value;
  439|  88.5k|                    xend = xstart + src_2->runs[xrlepos].length + 1;
  440|  88.5k|                }
  441|  91.3k|            } else if (end < xend) {
  ------------------
  |  Branch (441:24): [True: 18.1k, False: 14.3k]
  ------------------
  442|  18.1k|                earliestend = end;
  443|  18.1k|                rlepos++;
  444|  18.1k|                if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (444:21): [True: 18.0k, False: 160]
  ------------------
  445|  18.0k|                    start = src_1->runs[rlepos].value;
  446|  18.0k|                    end = start + src_1->runs[rlepos].length + 1;
  447|  18.0k|                }
  448|       |
  449|  18.1k|            } else {  // end > xend
  450|  14.3k|                earliestend = xend;
  451|  14.3k|                xrlepos++;
  452|  14.3k|                if (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (452:21): [True: 14.1k, False: 134]
  ------------------
  453|  14.1k|                    xstart = src_2->runs[xrlepos].value;
  454|  14.1k|                    xend = xstart + src_2->runs[xrlepos].length + 1;
  455|  14.1k|                }
  456|  14.3k|            }
  457|   123k|            dst->runs[dst->n_runs].value = (uint16_t)lateststart;
  458|   123k|            dst->runs[dst->n_runs].length =
  459|   123k|                (uint16_t)(earliestend - lateststart - 1);
  460|   123k|            dst->n_runs++;
  461|   123k|        }
  462|   183k|    }
  463|  3.38k|}
run_container_intersection_cardinality:
  467|  2.76k|                                           const run_container_t *src_2) {
  468|  2.76k|    const bool if1 = run_container_is_full(src_1);
  469|  2.76k|    const bool if2 = run_container_is_full(src_2);
  470|  2.76k|    if (if1 || if2) {
  ------------------
  |  Branch (470:9): [True: 0, False: 2.76k]
  |  Branch (470:16): [True: 56, False: 2.70k]
  ------------------
  471|     56|        if (if1) {
  ------------------
  |  Branch (471:13): [True: 0, False: 56]
  ------------------
  472|      0|            return run_container_cardinality(src_2);
  473|      0|        }
  474|     56|        if (if2) {
  ------------------
  |  Branch (474:13): [True: 56, False: 0]
  ------------------
  475|     56|            return run_container_cardinality(src_1);
  476|     56|        }
  477|     56|    }
  478|  2.70k|    int answer = 0;
  479|  2.70k|    int32_t rlepos = 0;
  480|  2.70k|    int32_t xrlepos = 0;
  481|  2.70k|    int32_t start = src_1->runs[rlepos].value;
  482|  2.70k|    int32_t end = start + src_1->runs[rlepos].length + 1;
  483|  2.70k|    int32_t xstart = src_2->runs[xrlepos].value;
  484|  2.70k|    int32_t xend = xstart + src_2->runs[xrlepos].length + 1;
  485|   297k|    while ((rlepos < src_1->n_runs) && (xrlepos < src_2->n_runs)) {
  ------------------
  |  Branch (485:12): [True: 295k, False: 1.88k]
  |  Branch (485:40): [True: 294k, False: 820]
  ------------------
  486|   294k|        if (end <= xstart) {
  ------------------
  |  Branch (486:13): [True: 70.3k, False: 224k]
  ------------------
  487|  70.3k|            ++rlepos;
  488|  70.3k|            if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (488:17): [True: 70.0k, False: 292]
  ------------------
  489|  70.0k|                start = src_1->runs[rlepos].value;
  490|  70.0k|                end = start + src_1->runs[rlepos].length + 1;
  491|  70.0k|            }
  492|   224k|        } else if (xend <= start) {
  ------------------
  |  Branch (492:20): [True: 48.3k, False: 175k]
  ------------------
  493|  48.3k|            ++xrlepos;
  494|  48.3k|            if (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (494:17): [True: 48.1k, False: 168]
  ------------------
  495|  48.1k|                xstart = src_2->runs[xrlepos].value;
  496|  48.1k|                xend = xstart + src_2->runs[xrlepos].length + 1;
  497|  48.1k|            }
  498|   175k|        } else {  // they overlap
  499|   175k|            const int32_t lateststart = start > xstart ? start : xstart;
  ------------------
  |  Branch (499:41): [True: 71.2k, False: 104k]
  ------------------
  500|   175k|            int32_t earliestend;
  501|   175k|            if (end == xend) {  // improbable
  ------------------
  |  Branch (501:17): [True: 84.5k, False: 91.2k]
  ------------------
  502|  84.5k|                earliestend = end;
  503|  84.5k|                rlepos++;
  504|  84.5k|                xrlepos++;
  505|  84.5k|                if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (505:21): [True: 83.5k, False: 952]
  ------------------
  506|  83.5k|                    start = src_1->runs[rlepos].value;
  507|  83.5k|                    end = start + src_1->runs[rlepos].length + 1;
  508|  83.5k|                }
  509|  84.5k|                if (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (509:21): [True: 83.4k, False: 1.08k]
  ------------------
  510|  83.4k|                    xstart = src_2->runs[xrlepos].value;
  511|  83.4k|                    xend = xstart + src_2->runs[xrlepos].length + 1;
  512|  83.4k|                }
  513|  91.2k|            } else if (end < xend) {
  ------------------
  |  Branch (513:24): [True: 72.6k, False: 18.6k]
  ------------------
  514|  72.6k|                earliestend = end;
  515|  72.6k|                rlepos++;
  516|  72.6k|                if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (516:21): [True: 72.0k, False: 640]
  ------------------
  517|  72.0k|                    start = src_1->runs[rlepos].value;
  518|  72.0k|                    end = start + src_1->runs[rlepos].length + 1;
  519|  72.0k|                }
  520|       |
  521|  72.6k|            } else {  // end > xend
  522|  18.6k|                earliestend = xend;
  523|  18.6k|                xrlepos++;
  524|  18.6k|                if (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (524:21): [True: 18.4k, False: 200]
  ------------------
  525|  18.4k|                    xstart = src_2->runs[xrlepos].value;
  526|  18.4k|                    xend = xstart + src_2->runs[xrlepos].length + 1;
  527|  18.4k|                }
  528|  18.6k|            }
  529|   175k|            answer += earliestend - lateststart;
  530|   175k|        }
  531|   294k|    }
  532|  2.70k|    return answer;
  533|  2.76k|}
run_container_intersect:
  536|    690|                             const run_container_t *src_2) {
  537|    690|    const bool if1 = run_container_is_full(src_1);
  538|    690|    const bool if2 = run_container_is_full(src_2);
  539|    690|    if (if1 || if2) {
  ------------------
  |  Branch (539:9): [True: 0, False: 690]
  |  Branch (539:16): [True: 14, False: 676]
  ------------------
  540|     14|        if (if1) {
  ------------------
  |  Branch (540:13): [True: 0, False: 14]
  ------------------
  541|      0|            return !run_container_empty(src_2);
  542|      0|        }
  543|     14|        if (if2) {
  ------------------
  |  Branch (543:13): [True: 14, False: 0]
  ------------------
  544|     14|            return !run_container_empty(src_1);
  545|     14|        }
  546|     14|    }
  547|    676|    int32_t rlepos = 0;
  548|    676|    int32_t xrlepos = 0;
  549|    676|    int32_t start = src_1->runs[rlepos].value;
  550|    676|    int32_t end = start + src_1->runs[rlepos].length + 1;
  551|    676|    int32_t xstart = src_2->runs[xrlepos].value;
  552|    676|    int32_t xend = xstart + src_2->runs[xrlepos].length + 1;
  553|  3.04k|    while ((rlepos < src_1->n_runs) && (xrlepos < src_2->n_runs)) {
  ------------------
  |  Branch (553:12): [True: 3.02k, False: 13]
  |  Branch (553:40): [True: 3.02k, False: 2]
  ------------------
  554|  3.02k|        if (end <= xstart) {
  ------------------
  |  Branch (554:13): [True: 1.97k, False: 1.05k]
  ------------------
  555|  1.97k|            ++rlepos;
  556|  1.97k|            if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (556:17): [True: 1.96k, False: 13]
  ------------------
  557|  1.96k|                start = src_1->runs[rlepos].value;
  558|  1.96k|                end = start + src_1->runs[rlepos].length + 1;
  559|  1.96k|            }
  560|  1.97k|        } else if (xend <= start) {
  ------------------
  |  Branch (560:20): [True: 393, False: 661]
  ------------------
  561|    393|            ++xrlepos;
  562|    393|            if (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (562:17): [True: 391, False: 2]
  ------------------
  563|    391|                xstart = src_2->runs[xrlepos].value;
  564|    391|                xend = xstart + src_2->runs[xrlepos].length + 1;
  565|    391|            }
  566|    661|        } else {  // they overlap
  567|    661|            return true;
  568|    661|        }
  569|  3.02k|    }
  570|     15|    return false;
  571|    676|}
run_container_andnot:
  576|  1.13k|                          const run_container_t *src_2, run_container_t *dst) {
  577|       |    // following Java implementation as of June 2016
  578|       |
  579|  1.13k|    if (dst->capacity < src_1->n_runs + src_2->n_runs)
  ------------------
  |  Branch (579:9): [True: 1.13k, False: 0]
  ------------------
  580|  1.13k|        run_container_grow(dst, src_1->n_runs + src_2->n_runs, false);
  581|       |
  582|  1.13k|    dst->n_runs = 0;
  583|       |
  584|  1.13k|    int rlepos1 = 0;
  585|  1.13k|    int rlepos2 = 0;
  586|  1.13k|    int32_t start = src_1->runs[rlepos1].value;
  587|  1.13k|    int32_t end = start + src_1->runs[rlepos1].length + 1;
  588|  1.13k|    int32_t start2 = src_2->runs[rlepos2].value;
  589|  1.13k|    int32_t end2 = start2 + src_2->runs[rlepos2].length + 1;
  590|       |
  591|   168k|    while ((rlepos1 < src_1->n_runs) && (rlepos2 < src_2->n_runs)) {
  ------------------
  |  Branch (591:12): [True: 168k, False: 692]
  |  Branch (591:41): [True: 167k, False: 447]
  ------------------
  592|   167k|        if (end <= start2) {
  ------------------
  |  Branch (592:13): [True: 24.2k, False: 143k]
  ------------------
  593|       |            // output the first run
  594|  24.2k|            dst->runs[dst->n_runs++] =
  595|  24.2k|                CROARING_MAKE_RLE16(start, end - start - 1);
  ------------------
  |  |   60|  24.2k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  596|  24.2k|            rlepos1++;
  597|  24.2k|            if (rlepos1 < src_1->n_runs) {
  ------------------
  |  Branch (597:17): [True: 24.1k, False: 73]
  ------------------
  598|  24.1k|                start = src_1->runs[rlepos1].value;
  599|  24.1k|                end = start + src_1->runs[rlepos1].length + 1;
  600|  24.1k|            }
  601|   143k|        } else if (end2 <= start) {
  ------------------
  |  Branch (601:20): [True: 68.4k, False: 75.0k]
  ------------------
  602|       |            // exit the second run
  603|  68.4k|            rlepos2++;
  604|  68.4k|            if (rlepos2 < src_2->n_runs) {
  ------------------
  |  Branch (604:17): [True: 68.0k, False: 447]
  ------------------
  605|  68.0k|                start2 = src_2->runs[rlepos2].value;
  606|  68.0k|                end2 = start2 + src_2->runs[rlepos2].length + 1;
  607|  68.0k|            }
  608|  75.0k|        } else {
  609|  75.0k|            if (start < start2) {
  ------------------
  |  Branch (609:17): [True: 21.4k, False: 53.5k]
  ------------------
  610|  21.4k|                dst->runs[dst->n_runs++] =
  611|  21.4k|                    CROARING_MAKE_RLE16(start, start2 - start - 1);
  ------------------
  |  |   60|  21.4k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  612|  21.4k|            }
  613|  75.0k|            if (end2 < end) {
  ------------------
  |  Branch (613:17): [True: 21.0k, False: 53.9k]
  ------------------
  614|  21.0k|                start = end2;
  615|  53.9k|            } else {
  616|  53.9k|                rlepos1++;
  617|  53.9k|                if (rlepos1 < src_1->n_runs) {
  ------------------
  |  Branch (617:21): [True: 53.3k, False: 619]
  ------------------
  618|  53.3k|                    start = src_1->runs[rlepos1].value;
  619|  53.3k|                    end = start + src_1->runs[rlepos1].length + 1;
  620|  53.3k|                }
  621|  53.9k|            }
  622|  75.0k|        }
  623|   167k|    }
  624|  1.13k|    if (rlepos1 < src_1->n_runs) {
  ------------------
  |  Branch (624:9): [True: 447, False: 692]
  ------------------
  625|    447|        dst->runs[dst->n_runs++] = CROARING_MAKE_RLE16(start, end - start - 1);
  ------------------
  |  |   60|    447|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  626|    447|        rlepos1++;
  627|    447|        if (rlepos1 < src_1->n_runs) {
  ------------------
  |  Branch (627:13): [True: 210, False: 237]
  ------------------
  628|    210|            memcpy(dst->runs + dst->n_runs, src_1->runs + rlepos1,
  629|    210|                   sizeof(rle16_t) * (src_1->n_runs - rlepos1));
  630|    210|            dst->n_runs += src_1->n_runs - rlepos1;
  631|    210|        }
  632|    447|    }
  633|  1.13k|}
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);
  ------------------
  |  |  523|     49|#define croaring_letoh16(x) croaring_htole16(x)
  |  |  ------------------
  |  |  |  |  517|     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|  55.6k|                           roaring_iterator iterator, void *ptr) {
  767|   156k|    for (int i = 0; i < cont->n_runs; ++i) {
  ------------------
  |  Branch (767:21): [True: 100k, False: 55.6k]
  ------------------
  768|   100k|        uint32_t run_start = base + cont->runs[i].value;
  769|   100k|        uint16_t le = cont->runs[i].length;
  770|       |
  771|  3.56G|        for (int j = 0; j <= le; ++j)
  ------------------
  |  Branch (771:25): [True: 3.56G, False: 100k]
  ------------------
  772|  3.56G|            if (!iterator(run_start + j, ptr)) return false;
  ------------------
  |  Branch (772:17): [True: 0, False: 3.56G]
  ------------------
  773|   100k|    }
  774|  55.6k|    return true;
  775|  55.6k|}
run_container_is_subset:
  792|    256|                             const run_container_t *container2) {
  793|    256|    int i1 = 0, i2 = 0;
  794|    856|    while (i1 < container1->n_runs && i2 < container2->n_runs) {
  ------------------
  |  Branch (794:12): [True: 856, False: 0]
  |  Branch (794:39): [True: 834, False: 22]
  ------------------
  795|    834|        int start1 = container1->runs[i1].value;
  796|    834|        int stop1 = start1 + container1->runs[i1].length;
  797|    834|        int start2 = container2->runs[i2].value;
  798|    834|        int stop2 = start2 + container2->runs[i2].length;
  799|    834|        if (start1 < start2) {
  ------------------
  |  Branch (799:13): [True: 234, False: 600]
  ------------------
  800|    234|            return false;
  801|    600|        } else {  // start1 >= start2
  802|    600|            if (stop1 < stop2) {
  ------------------
  |  Branch (802:17): [True: 0, False: 600]
  ------------------
  803|      0|                i1++;
  804|    600|            } else if (stop1 == stop2) {
  ------------------
  |  Branch (804:24): [True: 0, False: 600]
  ------------------
  805|      0|                i1++;
  806|      0|                i2++;
  807|    600|            } else {  // stop1 > stop2
  808|    600|                i2++;
  809|    600|            }
  810|    600|        }
  811|    834|    }
  812|     22|    if (i1 == container1->n_runs) {
  ------------------
  |  Branch (812:9): [True: 0, False: 22]
  ------------------
  813|      0|        return true;
  814|     22|    } else {
  815|       |        return false;
  816|     22|    }
  817|     22|}
run_container_smart_append_exclusive:
  826|   390k|                                          const uint16_t length) {
  827|   390k|    int old_end;
  828|   390k|    rle16_t *last_run = src->n_runs ? src->runs + (src->n_runs - 1) : NULL;
  ------------------
  |  Branch (828:25): [True: 319k, False: 70.7k]
  ------------------
  829|   390k|    rle16_t *appended_last_run = src->runs + src->n_runs;
  830|       |
  831|   390k|    if (!src->n_runs ||
  ------------------
  |  Branch (831:9): [True: 70.7k, False: 319k]
  ------------------
  832|   319k|        (start > (old_end = last_run->value + last_run->length + 1))) {
  ------------------
  |  Branch (832:9): [True: 175k, False: 144k]
  ------------------
  833|   245k|        *appended_last_run = CROARING_MAKE_RLE16(start, length);
  ------------------
  |  |   60|   245k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  834|   245k|        src->n_runs++;
  835|   245k|        return;
  836|   245k|    }
  837|   144k|    if (old_end == start) {
  ------------------
  |  Branch (837:9): [True: 3.50k, False: 140k]
  ------------------
  838|       |        // we merge
  839|  3.50k|        last_run->length += (length + 1);
  840|  3.50k|        return;
  841|  3.50k|    }
  842|   140k|    int new_end = start + length + 1;
  843|       |
  844|   140k|    if (start == last_run->value) {
  ------------------
  |  Branch (844:9): [True: 109k, False: 31.0k]
  ------------------
  845|       |        // wipe out previous
  846|   109k|        if (new_end < old_end) {
  ------------------
  |  Branch (846:13): [True: 6.83k, False: 103k]
  ------------------
  847|  6.83k|            *last_run = CROARING_MAKE_RLE16(new_end, old_end - new_end - 1);
  ------------------
  |  |   60|  6.83k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  848|  6.83k|            return;
  849|   103k|        } else if (new_end > old_end) {
  ------------------
  |  Branch (849:20): [True: 2.32k, False: 100k]
  ------------------
  850|  2.32k|            *last_run = CROARING_MAKE_RLE16(old_end, new_end - old_end - 1);
  ------------------
  |  |   60|  2.32k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  851|  2.32k|            return;
  852|   100k|        } else {
  853|   100k|            src->n_runs--;
  854|   100k|            return;
  855|   100k|        }
  856|   109k|    }
  857|  31.0k|    last_run->length = start - last_run->value - 1;
  858|  31.0k|    if (new_end < old_end) {
  ------------------
  |  Branch (858:9): [True: 25.1k, False: 5.84k]
  ------------------
  859|  25.1k|        *appended_last_run =
  860|  25.1k|            CROARING_MAKE_RLE16(new_end, old_end - new_end - 1);
  ------------------
  |  |   60|  25.1k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  861|  25.1k|        src->n_runs++;
  862|  25.1k|    } else if (new_end > old_end) {
  ------------------
  |  Branch (862:16): [True: 1.05k, False: 4.79k]
  ------------------
  863|  1.05k|        *appended_last_run =
  864|  1.05k|            CROARING_MAKE_RLE16(old_end, new_end - old_end - 1);
  ------------------
  |  |   60|  1.05k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  865|  1.05k|        src->n_runs++;
  866|  1.05k|    }
  867|  31.0k|}
run_container_select:
  871|  2.54k|                          uint32_t *element) {
  872|  13.1k|    for (int i = 0; i < container->n_runs; i++) {
  ------------------
  |  Branch (872:21): [True: 13.1k, False: 89]
  ------------------
  873|  13.1k|        uint16_t length = container->runs[i].length;
  874|  13.1k|        if (rank <= *start_rank + length) {
  ------------------
  |  Branch (874:13): [True: 2.45k, False: 10.6k]
  ------------------
  875|  2.45k|            uint16_t value = container->runs[i].value;
  876|  2.45k|            *element = value + rank - (*start_rank);
  877|  2.45k|            return true;
  878|  2.45k|        } else
  879|  10.6k|            *start_rank += length + 1;
  880|  13.1k|    }
  881|     89|    return false;
  882|  2.54k|}
run_container_rank:
  884|  2.54k|int run_container_rank(const run_container_t *container, uint16_t x) {
  885|  2.54k|    int sum = 0;
  886|  2.54k|    uint32_t x32 = x;
  887|  10.3k|    for (int i = 0; i < container->n_runs; i++) {
  ------------------
  |  Branch (887:21): [True: 10.2k, False: 53]
  ------------------
  888|  10.2k|        uint32_t startpoint = container->runs[i].value;
  889|  10.2k|        uint32_t length = container->runs[i].length;
  890|  10.2k|        uint32_t endpoint = length + startpoint;
  891|  10.2k|        if (x <= endpoint) {
  ------------------
  |  Branch (891:13): [True: 2.49k, False: 7.75k]
  ------------------
  892|  2.49k|            if (x < startpoint) break;
  ------------------
  |  Branch (892:17): [True: 253, False: 2.24k]
  ------------------
  893|  2.24k|            return sum + (x32 - startpoint) + 1;
  894|  7.75k|        } else {
  895|  7.75k|            sum += length + 1;
  896|  7.75k|        }
  897|  10.2k|    }
  898|    306|    return sum;
  899|  2.54k|}
_avx2_run_container_to_uint32_array:
 1021|  56.2k|                                        uint32_t base) {
 1022|  56.2k|    int outpos = 0;
 1023|  56.2k|    uint32_t *out = (uint32_t *)vout;
 1024|       |
 1025|   197k|    for (int i = 0; i < cont->n_runs; ++i) {
  ------------------
  |  Branch (1025:21): [True: 140k, False: 56.2k]
  ------------------
 1026|   140k|        uint32_t run_start = base + cont->runs[i].value;
 1027|   140k|        uint16_t le = cont->runs[i].length;
 1028|   140k|        if (le < 8) {
  ------------------
  |  Branch (1028:13): [True: 80.8k, False: 59.9k]
  ------------------
 1029|   208k|            for (int j = 0; j <= le; ++j) {
  ------------------
  |  Branch (1029:29): [True: 127k, False: 80.8k]
  ------------------
 1030|   127k|                uint32_t val = run_start + j;
 1031|   127k|                memcpy(out + outpos, &val,
 1032|   127k|                       sizeof(uint32_t));  // should be compiled as a MOV on x64
 1033|   127k|                outpos++;
 1034|   127k|            }
 1035|  80.8k|        } else {
 1036|  59.9k|            int j = 0;
 1037|  59.9k|            __m256i run_start_v = _mm256_set1_epi32(run_start);
 1038|       |            // [8,8,8,8....]
 1039|  59.9k|            __m256i inc = _mm256_set1_epi32(8);
 1040|       |            // used for generate sequence:
 1041|       |            // [0, 1, 2, 3...], [8, 9, 10,...]
 1042|  59.9k|            __m256i delta = _mm256_setr_epi32(0, 1, 2, 3, 4, 5, 6, 7);
 1043|   446M|            for (j = 0; j + 8 <= le; j += 8) {
  ------------------
  |  Branch (1043:25): [True: 446M, False: 59.9k]
  ------------------
 1044|   446M|                __m256i val_v = _mm256_add_epi32(run_start_v, delta);
 1045|   446M|                _mm256_storeu_si256((__m256i *)(out + outpos), val_v);
 1046|   446M|                delta = _mm256_add_epi32(inc, delta);
 1047|   446M|                outpos += 8;
 1048|   446M|            }
 1049|   515k|            for (; j <= le; ++j) {
  ------------------
  |  Branch (1049:20): [True: 455k, False: 59.9k]
  ------------------
 1050|   455k|                uint32_t val = run_start + j;
 1051|   455k|                memcpy(out + outpos, &val,
 1052|   455k|                       sizeof(uint32_t));  // should be compiled as a MOV on x64
 1053|   455k|                outpos++;
 1054|   455k|            }
 1055|  59.9k|        }
 1056|   140k|    }
 1057|  56.2k|    return outpos;
 1058|  56.2k|}
run_container_cardinality:
 1077|   504k|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|   504k|        if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (1085:13): [True: 504k, False: 0]
  ------------------
 1086|   504k|        return _avx2_run_container_cardinality(run);
 1087|   504k|    } else {
 1088|      0|        return _scalar_run_container_cardinality(run);
 1089|      0|    }
 1090|   504k|}
run_container_to_uint32_array:
 1111|  56.2k|                                  uint32_t base) {
 1112|  56.2k|    if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (1112:9): [True: 56.2k, False: 0]
  ------------------
 1113|  56.2k|        return _avx2_run_container_to_uint32_array(vout, cont, base);
 1114|  56.2k|    } else {
 1115|      0|        return _scalar_run_container_to_uint32_array(vout, cont, base);
 1116|      0|    }
 1117|  56.2k|}
run.c:_avx2_run_container_cardinality:
  991|   504k|static inline int _avx2_run_container_cardinality(const run_container_t *run) {
  992|   504k|    const int32_t n_runs = run->n_runs;
  993|   504k|    const rle16_t *runs = run->runs;
  994|       |
  995|       |    /* by initializing with n_runs, we omit counting the +1 for each pair. */
  996|   504k|    int sum = n_runs;
  997|   504k|    int32_t k = 0;
  998|   504k|    const int32_t step = sizeof(__m256i) / sizeof(rle16_t);
  999|   504k|    if (n_runs > step) {
  ------------------
  |  Branch (999:9): [True: 33.4k, False: 470k]
  ------------------
 1000|  33.4k|        __m256i total = _mm256_setzero_si256();
 1001|   377k|        for (; k + step <= n_runs; k += step) {
  ------------------
  |  Branch (1001:16): [True: 343k, False: 33.4k]
  ------------------
 1002|   343k|            __m256i ymm1 = _mm256_lddqu_si256((const __m256i *)(runs + k));
 1003|   343k|            __m256i justlengths = _mm256_srli_epi32(ymm1, 16);
 1004|   343k|            total = _mm256_add_epi32(total, justlengths);
 1005|   343k|        }
 1006|       |        // a store might be faster than extract?
 1007|  33.4k|        uint32_t buffer[sizeof(__m256i) / sizeof(rle16_t)];
 1008|  33.4k|        _mm256_storeu_si256((__m256i *)buffer, total);
 1009|  33.4k|        sum += (buffer[0] + buffer[1]) + (buffer[2] + buffer[3]) +
 1010|  33.4k|               (buffer[4] + buffer[5]) + (buffer[6] + buffer[7]);
 1011|  33.4k|    }
 1012|  1.05M|    for (; k < n_runs; ++k) {
  ------------------
  |  Branch (1012:12): [True: 552k, False: 504k]
  ------------------
 1013|   552k|        sum += runs[k].length;
 1014|   552k|    }
 1015|       |
 1016|   504k|    return sum;
 1017|   504k|}

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

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

roaring_bitmap_create_with_capacity:
   86|  24.8k|roaring_bitmap_t *roaring_bitmap_create_with_capacity(uint32_t cap) {
   87|  24.8k|    roaring_bitmap_t *ans =
   88|  24.8k|        (roaring_bitmap_t *)roaring_malloc(sizeof(roaring_bitmap_t));
   89|  24.8k|    if (!ans) {
  ------------------
  |  Branch (89:9): [True: 0, False: 24.8k]
  ------------------
   90|      0|        return NULL;
   91|      0|    }
   92|  24.8k|    bool is_ok = ra_init_with_capacity(&ans->high_low_container, cap);
   93|  24.8k|    if (!is_ok) {
  ------------------
  |  Branch (93:9): [True: 0, False: 24.8k]
  ------------------
   94|      0|        roaring_free(ans);
   95|      0|        return NULL;
   96|      0|    }
   97|  24.8k|    return ans;
   98|  24.8k|}
roaring_bitmap_init_with_capacity:
  100|  31.2k|bool roaring_bitmap_init_with_capacity(roaring_bitmap_t *r, uint32_t cap) {
  101|  31.2k|    return ra_init_with_capacity(&r->high_low_container, cap);
  102|  31.2k|}
roaring_bitmap_add_many:
  135|  18.7k|                             const uint32_t *vals) {
  136|  18.7k|    uint32_t val;
  137|  18.7k|    const uint32_t *start = vals;
  138|  18.7k|    const uint32_t *end = vals + n_args;
  139|  18.7k|    const uint32_t *current_val = start;
  140|       |
  141|  18.7k|    if (n_args == 0) {
  ------------------
  |  Branch (141:9): [True: 0, False: 18.7k]
  ------------------
  142|      0|        return;
  143|      0|    }
  144|       |
  145|  18.7k|    uint8_t typecode;
  146|  18.7k|    int idx;
  147|  18.7k|    container_t *container;
  148|  18.7k|    val = *current_val;
  149|  18.7k|    container = containerptr_roaring_bitmap_add(r, val, &typecode, &idx);
  150|  18.7k|    roaring_bulk_context_t context = {container, idx, (uint16_t)(val >> 16),
  151|  18.7k|                                      typecode};
  152|       |
  153|  7.82M|    for (; current_val != end; current_val++) {
  ------------------
  |  Branch (153:12): [True: 7.80M, False: 18.7k]
  ------------------
  154|  7.80M|        memcpy(&val, current_val, sizeof(val));
  155|  7.80M|        add_bulk_impl(r, &context, val);
  156|  7.80M|    }
  157|  18.7k|}
roaring_bitmap_add_range_closed:
  252|  2.71k|                                     uint32_t max) {
  253|  2.71k|    if (min > max) {
  ------------------
  |  Branch (253:9): [True: 0, False: 2.71k]
  ------------------
  254|      0|        return;
  255|      0|    }
  256|       |
  257|  2.71k|    roaring_array_t *ra = &r->high_low_container;
  258|       |
  259|  2.71k|    uint32_t min_key = min >> 16;
  260|  2.71k|    uint32_t max_key = max >> 16;
  261|       |
  262|  2.71k|    int32_t num_required_containers = max_key - min_key + 1;
  263|  2.71k|    int32_t suffix_length =
  264|  2.71k|        count_greater(ra->keys, ra->size, (uint16_t)max_key);
  265|  2.71k|    int32_t prefix_length =
  266|  2.71k|        count_less(ra->keys, ra->size - suffix_length, (uint16_t)min_key);
  267|  2.71k|    int32_t common_length = ra->size - prefix_length - suffix_length;
  268|       |
  269|  2.71k|    if (num_required_containers > common_length) {
  ------------------
  |  Branch (269:9): [True: 1.24k, False: 1.46k]
  ------------------
  270|  1.24k|        ra_shift_tail(ra, suffix_length,
  271|  1.24k|                      num_required_containers - common_length);
  272|  1.24k|    }
  273|       |
  274|  2.71k|    int32_t src = prefix_length + common_length - 1;
  275|  2.71k|    int32_t dst = ra->size - suffix_length - 1;
  276|  74.1k|    for (uint32_t key = max_key; key != min_key - 1;
  ------------------
  |  Branch (276:34): [True: 71.4k, False: 2.71k]
  ------------------
  277|  71.4k|         key--) {  // beware of min_key==0
  278|  71.4k|        uint32_t container_min = (min_key == key) ? (min & 0xffff) : 0;
  ------------------
  |  Branch (278:34): [True: 2.71k, False: 68.7k]
  ------------------
  279|  71.4k|        uint32_t container_max = (max_key == key) ? (max & 0xffff) : 0xffff;
  ------------------
  |  Branch (279:34): [True: 2.71k, False: 68.7k]
  ------------------
  280|  71.4k|        container_t *new_container;
  281|  71.4k|        uint8_t new_type;
  282|       |
  283|  71.4k|        if (src >= 0 && ra->keys[src] == key) {
  ------------------
  |  Branch (283:13): [True: 71.4k, False: 0]
  |  Branch (283:25): [True: 3.16k, False: 68.2k]
  ------------------
  284|  3.16k|            ra_unshare_container_at_index(ra, (uint16_t)src);
  285|  3.16k|            new_container =
  286|  3.16k|                container_add_range(ra->containers[src], ra->typecodes[src],
  287|  3.16k|                                    container_min, container_max, &new_type);
  288|  3.16k|            if (new_container != ra->containers[src]) {
  ------------------
  |  Branch (288:17): [True: 2.10k, False: 1.05k]
  ------------------
  289|  2.10k|                container_free(ra->containers[src], ra->typecodes[src]);
  290|  2.10k|            }
  291|  3.16k|            src--;
  292|  68.2k|        } else {
  293|  68.2k|            new_container = container_from_range(&new_type, container_min,
  294|  68.2k|                                                 container_max + 1, 1);
  295|  68.2k|        }
  296|  71.4k|        ra_replace_key_and_container_at_index(ra, dst, (uint16_t)key,
  297|  71.4k|                                              new_container, new_type);
  298|  71.4k|        dst--;
  299|  71.4k|    }
  300|  2.71k|}
roaring_bitmap_remove_range_closed:
  303|  7.14k|                                        uint32_t max) {
  304|  7.14k|    if (min > max) {
  ------------------
  |  Branch (304:9): [True: 767, False: 6.37k]
  ------------------
  305|    767|        return;
  306|    767|    }
  307|       |
  308|  6.37k|    roaring_array_t *ra = &r->high_low_container;
  309|       |
  310|  6.37k|    uint32_t min_key = min >> 16;
  311|  6.37k|    uint32_t max_key = max >> 16;
  312|       |
  313|  6.37k|    int32_t src = count_less(ra->keys, ra->size, (uint16_t)min_key);
  314|  6.37k|    int32_t dst = src;
  315|  26.8k|    while (src < ra->size && ra->keys[src] <= max_key) {
  ------------------
  |  Branch (315:12): [True: 22.4k, False: 4.37k]
  |  Branch (315:30): [True: 20.4k, False: 2.00k]
  ------------------
  316|  20.4k|        uint32_t container_min =
  317|  20.4k|            (min_key == ra->keys[src]) ? (min & 0xffff) : 0;
  ------------------
  |  Branch (317:13): [True: 5.99k, False: 14.4k]
  ------------------
  318|  20.4k|        uint32_t container_max =
  319|  20.4k|            (max_key == ra->keys[src]) ? (max & 0xffff) : 0xffff;
  ------------------
  |  Branch (319:13): [True: 5.65k, False: 14.7k]
  ------------------
  320|  20.4k|        ra_unshare_container_at_index(ra, (uint16_t)src);
  321|  20.4k|        container_t *new_container;
  322|  20.4k|        uint8_t new_type;
  323|  20.4k|        new_container =
  324|  20.4k|            container_remove_range(ra->containers[src], ra->typecodes[src],
  325|  20.4k|                                   container_min, container_max, &new_type);
  326|  20.4k|        if (new_container != ra->containers[src]) {
  ------------------
  |  Branch (326:13): [True: 14.5k, False: 5.85k]
  ------------------
  327|  14.5k|            container_free(ra->containers[src], ra->typecodes[src]);
  328|  14.5k|        }
  329|  20.4k|        if (new_container) {
  ------------------
  |  Branch (329:13): [True: 6.11k, False: 14.3k]
  ------------------
  330|  6.11k|            ra_replace_key_and_container_at_index(ra, dst, ra->keys[src],
  331|  6.11k|                                                  new_container, new_type);
  332|  6.11k|            dst++;
  333|  6.11k|        }
  334|  20.4k|        src++;
  335|  20.4k|    }
  336|  6.37k|    if (src > dst) {
  ------------------
  |  Branch (336:9): [True: 615, False: 5.76k]
  ------------------
  337|    615|        ra_shift_tail(ra, ra->size - src, dst - src);
  338|    615|    }
  339|  6.37k|}
roaring_bitmap_copy:
  525|    153|roaring_bitmap_t *roaring_bitmap_copy(const roaring_bitmap_t *r) {
  526|    153|    roaring_bitmap_t *ans =
  527|    153|        (roaring_bitmap_t *)roaring_malloc(sizeof(roaring_bitmap_t));
  528|    153|    if (!ans) {
  ------------------
  |  Branch (528:9): [True: 0, False: 153]
  ------------------
  529|      0|        return NULL;
  530|      0|    }
  531|    153|    if (!ra_init_with_capacity(  // allocation of list of containers can fail
  ------------------
  |  Branch (531:9): [True: 0, False: 153]
  ------------------
  532|    153|            &ans->high_low_container, r->high_low_container.size)) {
  533|      0|        roaring_free(ans);
  534|      0|        return NULL;
  535|      0|    }
  536|    153|    if (!ra_overwrite(  // memory allocation of individual containers may fail
  ------------------
  |  Branch (536:9): [True: 0, False: 153]
  ------------------
  537|    153|            &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|    153|    roaring_bitmap_set_copy_on_write(ans, is_cow(r));
  542|    153|    return ans;
  543|    153|}
roaring_bitmap_overwrite:
  546|  13.9k|                              const roaring_bitmap_t *src) {
  547|  13.9k|    roaring_bitmap_set_copy_on_write(dest, is_cow(src));
  548|  13.9k|    return ra_overwrite(&src->high_low_container, &dest->high_low_container,
  549|  13.9k|                        is_cow(src));
  550|  13.9k|}
roaring_bitmap_clear:
  562|  62.4k|void roaring_bitmap_clear(roaring_bitmap_t *r) {
  563|  62.4k|    ra_reset(&r->high_low_container);
  564|  62.4k|}
roaring_bitmap_add:
  566|  6.24k|void roaring_bitmap_add(roaring_bitmap_t *r, uint32_t val) {
  567|  6.24k|    roaring_array_t *ra = &r->high_low_container;
  568|       |
  569|  6.24k|    const uint16_t hb = val >> 16;
  570|  6.24k|    const int i = ra_get_index(ra, hb);
  571|  6.24k|    uint8_t typecode;
  572|  6.24k|    if (i >= 0) {
  ------------------
  |  Branch (572:9): [True: 4.54k, False: 1.70k]
  ------------------
  573|  4.54k|        ra_unshare_container_at_index(ra, (uint16_t)i);
  574|  4.54k|        container_t *container =
  575|  4.54k|            ra_get_container_at_index(ra, (uint16_t)i, &typecode);
  576|  4.54k|        uint8_t newtypecode = typecode;
  577|  4.54k|        container_t *container2 =
  578|  4.54k|            container_add(container, val & 0xFFFF, typecode, &newtypecode);
  579|  4.54k|        if (container2 != container) {
  ------------------
  |  Branch (579:13): [True: 0, False: 4.54k]
  ------------------
  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.54k|    } else {
  585|  1.70k|        array_container_t *newac = array_container_create();
  586|  1.70k|        container_t *container =
  587|  1.70k|            container_add(newac, val & 0xFFFF, ARRAY_CONTAINER_TYPE, &typecode);
  ------------------
  |  |   49|  1.70k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  588|       |        // we could just assume that it stays an array container
  589|  1.70k|        ra_insert_new_key_value_at(&r->high_low_container, -i - 1, hb,
  590|  1.70k|                                   container, typecode);
  591|  1.70k|    }
  592|  6.24k|}
roaring_bitmap_add_checked:
  594|  6.24k|bool roaring_bitmap_add_checked(roaring_bitmap_t *r, uint32_t val) {
  595|  6.24k|    const uint16_t hb = val >> 16;
  596|  6.24k|    const int i = ra_get_index(&r->high_low_container, hb);
  597|  6.24k|    uint8_t typecode;
  598|  6.24k|    bool result = false;
  599|  6.24k|    if (i >= 0) {
  ------------------
  |  Branch (599:9): [True: 4.78k, False: 1.45k]
  ------------------
  600|  4.78k|        ra_unshare_container_at_index(&r->high_low_container, (uint16_t)i);
  601|  4.78k|        container_t *container = ra_get_container_at_index(
  602|  4.78k|            &r->high_low_container, (uint16_t)i, &typecode);
  603|       |
  604|  4.78k|        const int oldCardinality =
  605|  4.78k|            container_get_cardinality(container, typecode);
  606|       |
  607|  4.78k|        uint8_t newtypecode = typecode;
  608|  4.78k|        container_t *container2 =
  609|  4.78k|            container_add(container, val & 0xFFFF, typecode, &newtypecode);
  610|  4.78k|        if (container2 != container) {
  ------------------
  |  Branch (610:13): [True: 0, False: 4.78k]
  ------------------
  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.78k|        } else {
  616|  4.78k|            const int newCardinality =
  617|  4.78k|                container_get_cardinality(container, newtypecode);
  618|       |
  619|  4.78k|            result = oldCardinality != newCardinality;
  620|  4.78k|        }
  621|  4.78k|    } else {
  622|  1.45k|        array_container_t *newac = array_container_create();
  623|  1.45k|        container_t *container =
  624|  1.45k|            container_add(newac, val & 0xFFFF, ARRAY_CONTAINER_TYPE, &typecode);
  ------------------
  |  |   49|  1.45k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  625|       |        // we could just assume that it stays an array container
  626|  1.45k|        ra_insert_new_key_value_at(&r->high_low_container, -i - 1, hb,
  627|  1.45k|                                   container, typecode);
  628|  1.45k|        result = true;
  629|  1.45k|    }
  630|       |
  631|  6.24k|    return result;
  632|  6.24k|}
roaring_bitmap_remove:
  634|  6.24k|void roaring_bitmap_remove(roaring_bitmap_t *r, uint32_t val) {
  635|  6.24k|    const uint16_t hb = val >> 16;
  636|  6.24k|    const int i = ra_get_index(&r->high_low_container, hb);
  637|  6.24k|    uint8_t typecode;
  638|  6.24k|    if (i >= 0) {
  ------------------
  |  Branch (638:9): [True: 5.67k, False: 573]
  ------------------
  639|  5.67k|        ra_unshare_container_at_index(&r->high_low_container, (uint16_t)i);
  640|  5.67k|        container_t *container = ra_get_container_at_index(
  641|  5.67k|            &r->high_low_container, (uint16_t)i, &typecode);
  642|  5.67k|        uint8_t newtypecode = typecode;
  643|  5.67k|        container_t *container2 =
  644|  5.67k|            container_remove(container, val & 0xFFFF, typecode, &newtypecode);
  645|  5.67k|        if (container2 != container) {
  ------------------
  |  Branch (645:13): [True: 15, False: 5.65k]
  ------------------
  646|     15|            container_free(container, typecode);
  647|     15|            ra_set_container_at_index(&r->high_low_container, i, container2,
  648|     15|                                      newtypecode);
  649|     15|        }
  650|  5.67k|        if (container_nonzero_cardinality(container2, newtypecode)) {
  ------------------
  |  Branch (650:13): [True: 5.62k, False: 49]
  ------------------
  651|  5.62k|            ra_set_container_at_index(&r->high_low_container, i, container2,
  652|  5.62k|                                      newtypecode);
  653|  5.62k|        } else {
  654|     49|            ra_remove_at_index_and_free(&r->high_low_container, i);
  655|     49|        }
  656|  5.67k|    }
  657|  6.24k|}
roaring_bitmap_remove_checked:
  659|  6.24k|bool roaring_bitmap_remove_checked(roaring_bitmap_t *r, uint32_t val) {
  660|  6.24k|    const uint16_t hb = val >> 16;
  661|  6.24k|    const int i = ra_get_index(&r->high_low_container, hb);
  662|  6.24k|    uint8_t typecode;
  663|  6.24k|    bool result = false;
  664|  6.24k|    if (i >= 0) {
  ------------------
  |  Branch (664:9): [True: 5.67k, False: 568]
  ------------------
  665|  5.67k|        ra_unshare_container_at_index(&r->high_low_container, (uint16_t)i);
  666|  5.67k|        container_t *container = ra_get_container_at_index(
  667|  5.67k|            &r->high_low_container, (uint16_t)i, &typecode);
  668|       |
  669|  5.67k|        const int oldCardinality =
  670|  5.67k|            container_get_cardinality(container, typecode);
  671|       |
  672|  5.67k|        uint8_t newtypecode = typecode;
  673|  5.67k|        container_t *container2 =
  674|  5.67k|            container_remove(container, val & 0xFFFF, typecode, &newtypecode);
  675|  5.67k|        if (container2 != container) {
  ------------------
  |  Branch (675:13): [True: 3, False: 5.67k]
  ------------------
  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.67k|        const int newCardinality =
  682|  5.67k|            container_get_cardinality(container2, newtypecode);
  683|       |
  684|  5.67k|        if (newCardinality != 0) {
  ------------------
  |  Branch (684:13): [True: 5.66k, False: 10]
  ------------------
  685|  5.66k|            ra_set_container_at_index(&r->high_low_container, i, container2,
  686|  5.66k|                                      newtypecode);
  687|  5.66k|        } else {
  688|     10|            ra_remove_at_index_and_free(&r->high_low_container, i);
  689|     10|        }
  690|       |
  691|  5.67k|        result = oldCardinality != newCardinality;
  692|  5.67k|    }
  693|  6.24k|    return result;
  694|  6.24k|}
roaring_bitmap_and:
  732|  6.24k|                                     const roaring_bitmap_t *x2) {
  733|  6.24k|    uint8_t result_type = 0;
  734|  6.24k|    const int length1 = x1->high_low_container.size,
  735|  6.24k|              length2 = x2->high_low_container.size;
  736|  6.24k|    uint32_t neededcap = length1 > length2 ? length2 : length1;
  ------------------
  |  Branch (736:26): [True: 51, False: 6.19k]
  ------------------
  737|  6.24k|    roaring_bitmap_t *answer = roaring_bitmap_create_with_capacity(neededcap);
  738|  6.24k|    roaring_bitmap_set_copy_on_write(answer, is_cow(x1) || is_cow(x2));
  ------------------
  |  Branch (738:46): [True: 0, False: 6.24k]
  |  Branch (738:60): [True: 0, False: 6.24k]
  ------------------
  739|       |
  740|  6.24k|    int pos1 = 0, pos2 = 0;
  741|       |
  742|  12.4k|    while (pos1 < length1 && pos2 < length2) {
  ------------------
  |  Branch (742:12): [True: 6.24k, False: 6.19k]
  |  Branch (742:30): [True: 6.19k, False: 51]
  ------------------
  743|  6.19k|        const uint16_t s1 =
  744|  6.19k|            ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
  745|  6.19k|        const uint16_t s2 =
  746|  6.19k|            ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
  747|       |
  748|  6.19k|        if (s1 == s2) {
  ------------------
  |  Branch (748:13): [True: 6.12k, False: 67]
  ------------------
  749|  6.12k|            uint8_t type1, type2;
  750|  6.12k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
  751|  6.12k|                                                        (uint16_t)pos1, &type1);
  752|  6.12k|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
  753|  6.12k|                                                        (uint16_t)pos2, &type2);
  754|  6.12k|            container_t *c = container_and(c1, type1, c2, type2, &result_type);
  755|       |
  756|  6.12k|            if (container_nonzero_cardinality(c, result_type)) {
  ------------------
  |  Branch (756:17): [True: 5.81k, False: 316]
  ------------------
  757|  5.81k|                ra_append(&answer->high_low_container, s1, c, result_type);
  758|  5.81k|            } else {
  759|    316|                container_free(c, result_type);  // otherwise: memory leak!
  760|    316|            }
  761|  6.12k|            ++pos1;
  762|  6.12k|            ++pos2;
  763|  6.12k|        } else if (s1 < s2) {  // s1 < s2
  ------------------
  |  Branch (763:20): [True: 67, False: 0]
  ------------------
  764|     67|            pos1 = ra_advance_until(&x1->high_low_container, s2, pos1);
  765|     67|        } else {  // s1 > s2
  766|      0|            pos2 = ra_advance_until(&x2->high_low_container, s1, pos2);
  767|      0|        }
  768|  6.19k|    }
  769|  6.24k|    return answer;
  770|  6.24k|}
roaring_bitmap_and_inplace:
  813|  6.24k|                                const roaring_bitmap_t *x2) {
  814|  6.24k|    if (x1 == x2) return;
  ------------------
  |  Branch (814:9): [True: 0, False: 6.24k]
  ------------------
  815|  6.24k|    int pos1 = 0, pos2 = 0, intersection_size = 0;
  816|  6.24k|    const int length1 = ra_get_size(&x1->high_low_container);
  817|  6.24k|    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|  69.6k|    while (pos1 < length1 && pos2 < length2) {
  ------------------
  |  Branch (821:12): [True: 63.4k, False: 6.19k]
  |  Branch (821:30): [True: 63.3k, False: 51]
  ------------------
  822|  63.3k|        const uint16_t s1 =
  823|  63.3k|            ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
  824|  63.3k|        const uint16_t s2 =
  825|  63.3k|            ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
  826|       |
  827|  63.3k|        if (s1 == s2) {
  ------------------
  |  Branch (827:13): [True: 63.2k, False: 67]
  ------------------
  828|  63.2k|            uint8_t type1, type2, result_type;
  829|  63.2k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
  830|  63.2k|                                                        (uint16_t)pos1, &type1);
  831|  63.2k|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
  832|  63.2k|                                                        (uint16_t)pos2, &type2);
  833|       |
  834|       |            // We do the computation "in place" only when c1 is not a shared
  835|       |            // container. Rationale: using a shared container safely with in
  836|       |            // place computation would require making a copy and then doing the
  837|       |            // computation in place which is likely less efficient than avoiding
  838|       |            // in place entirely and always generating a new container.
  839|  63.2k|            container_t *c =
  840|  63.2k|                (type1 == SHARED_CONTAINER_TYPE)
  ------------------
  |  |   51|  63.2k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (840:17): [True: 0, False: 63.2k]
  ------------------
  841|  63.2k|                    ? container_and(c1, type1, c2, type2, &result_type)
  842|  63.2k|                    : container_iand(c1, type1, c2, type2, &result_type);
  843|       |
  844|  63.2k|            if (c != c1) {  // in this instance a new container was created, and
  ------------------
  |  Branch (844:17): [True: 57.3k, False: 5.97k]
  ------------------
  845|       |                            // we need to free the old one
  846|  57.3k|                container_free(c1, type1);
  847|  57.3k|            }
  848|  63.2k|            if (container_nonzero_cardinality(c, result_type)) {
  ------------------
  |  Branch (848:17): [True: 63.2k, False: 0]
  ------------------
  849|  63.2k|                ra_replace_key_and_container_at_index(&x1->high_low_container,
  850|  63.2k|                                                      intersection_size, s1, c,
  851|  63.2k|                                                      result_type);
  852|  63.2k|                intersection_size++;
  853|  63.2k|            } else {
  854|      0|                container_free(c, result_type);
  855|      0|            }
  856|  63.2k|            ++pos1;
  857|  63.2k|            ++pos2;
  858|  63.2k|        } else if (s1 < s2) {
  ------------------
  |  Branch (858:20): [True: 67, False: 0]
  ------------------
  859|     67|            pos1 = ra_advance_until_freeing(&x1->high_low_container, s2, pos1);
  860|     67|        } else {  // s1 > s2
  861|      0|            pos2 = ra_advance_until(&x2->high_low_container, s1, pos2);
  862|      0|        }
  863|  63.3k|    }
  864|       |
  865|       |    // if we ended early because x2 ran out, then all remaining in x1 should be
  866|       |    // freed
  867|  6.29k|    while (pos1 < length1) {
  ------------------
  |  Branch (867:12): [True: 51, False: 6.24k]
  ------------------
  868|     51|        container_free(x1->high_low_container.containers[pos1],
  869|     51|                       x1->high_low_container.typecodes[pos1]);
  870|     51|        ++pos1;
  871|     51|    }
  872|       |
  873|       |    // all containers after this have either been copied or freed
  874|  6.24k|    ra_downsize(&x1->high_low_container, intersection_size);
  875|  6.24k|}
roaring_bitmap_or:
  878|  6.24k|                                    const roaring_bitmap_t *x2) {
  879|  6.24k|    uint8_t result_type = 0;
  880|  6.24k|    const int length1 = x1->high_low_container.size,
  881|  6.24k|              length2 = x2->high_low_container.size;
  882|  6.24k|    if (0 == length1) {
  ------------------
  |  Branch (882:9): [True: 0, False: 6.24k]
  ------------------
  883|      0|        return roaring_bitmap_copy(x2);
  884|      0|    }
  885|  6.24k|    if (0 == length2) {
  ------------------
  |  Branch (885:9): [True: 51, False: 6.19k]
  ------------------
  886|     51|        return roaring_bitmap_copy(x1);
  887|     51|    }
  888|  6.19k|    roaring_bitmap_t *answer =
  889|  6.19k|        roaring_bitmap_create_with_capacity(length1 + length2);
  890|  6.19k|    roaring_bitmap_set_copy_on_write(answer, is_cow(x1) || is_cow(x2));
  ------------------
  |  Branch (890:46): [True: 0, False: 6.19k]
  |  Branch (890:60): [True: 0, False: 6.19k]
  ------------------
  891|  6.19k|    int pos1 = 0, pos2 = 0;
  892|  6.19k|    uint8_t type1, type2;
  893|  6.19k|    uint16_t s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
  894|  6.19k|    uint16_t s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
  895|  6.19k|    while (true) {
  ------------------
  |  Branch (895:12): [True: 6.19k, Folded]
  ------------------
  896|  6.19k|        if (s1 == s2) {
  ------------------
  |  Branch (896:13): [True: 6.12k, False: 67]
  ------------------
  897|  6.12k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
  898|  6.12k|                                                        (uint16_t)pos1, &type1);
  899|  6.12k|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
  900|  6.12k|                                                        (uint16_t)pos2, &type2);
  901|  6.12k|            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.12k|            ra_append(&answer->high_low_container, s1, c, result_type);
  907|  6.12k|            ++pos1;
  908|  6.12k|            ++pos2;
  909|  6.12k|            if (pos1 == length1) break;
  ------------------
  |  Branch (909:17): [True: 6.12k, 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|     67|        } else if (s1 < s2) {  // s1 < s2
  ------------------
  |  Branch (914:20): [True: 67, False: 0]
  ------------------
  915|     67|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
  916|     67|                                                        (uint16_t)pos1, &type1);
  917|       |            // c1 = container_clone(c1, type1);
  918|     67|            c1 = get_copy_of_container(c1, &type1, is_cow(x1));
  919|     67|            if (is_cow(x1)) {
  ------------------
  |  Branch (919:17): [True: 0, False: 67]
  ------------------
  920|      0|                ra_set_container_at_index(&x1->high_low_container, pos1, c1,
  921|      0|                                          type1);
  922|      0|            }
  923|     67|            ra_append(&answer->high_low_container, s1, c1, type1);
  924|     67|            pos1++;
  925|     67|            if (pos1 == length1) break;
  ------------------
  |  Branch (925:17): [True: 67, 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.19k|    }
  943|  6.19k|    if (pos1 == length1) {
  ------------------
  |  Branch (943:9): [True: 6.19k, False: 0]
  ------------------
  944|  6.19k|        ra_append_copy_range(&answer->high_low_container,
  945|  6.19k|                             &x2->high_low_container, pos2, length2,
  946|  6.19k|                             is_cow(x2));
  947|  6.19k|    } 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.19k|    return answer;
  953|  6.24k|}
roaring_bitmap_or_inplace:
 1064|  6.24k|                               const roaring_bitmap_t *x2) {
 1065|  6.24k|    uint8_t result_type = 0;
 1066|  6.24k|    int length1 = x1->high_low_container.size;
 1067|  6.24k|    const int length2 = x2->high_low_container.size;
 1068|       |
 1069|  6.24k|    if (0 == length2) return;
  ------------------
  |  Branch (1069:9): [True: 0, False: 6.24k]
  ------------------
 1070|       |
 1071|  6.24k|    if (0 == length1) {
  ------------------
  |  Branch (1071:9): [True: 0, False: 6.24k]
  ------------------
 1072|      0|        roaring_bitmap_overwrite(x1, x2);
 1073|      0|        return;
 1074|      0|    }
 1075|  6.24k|    int pos1 = 0, pos2 = 0;
 1076|  6.24k|    uint8_t type1, type2;
 1077|  6.24k|    uint16_t s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1078|  6.24k|    uint16_t s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 1079|  6.24k|    while (true) {
  ------------------
  |  Branch (1079:12): [True: 6.24k, Folded]
  ------------------
 1080|  6.24k|        if (s1 == s2) {
  ------------------
  |  Branch (1080:13): [True: 6.24k, False: 0]
  ------------------
 1081|  6.24k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
 1082|  6.24k|                                                        (uint16_t)pos1, &type1);
 1083|  6.24k|            if (!container_is_full(c1, type1)) {
  ------------------
  |  Branch (1083:17): [True: 6.24k, False: 0]
  ------------------
 1084|  6.24k|                container_t *c2 = ra_get_container_at_index(
 1085|  6.24k|                    &x2->high_low_container, (uint16_t)pos2, &type2);
 1086|  6.24k|                container_t *c =
 1087|  6.24k|                    (type1 == SHARED_CONTAINER_TYPE)
  ------------------
  |  |   51|  6.24k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (1087:21): [True: 0, False: 6.24k]
  ------------------
 1088|  6.24k|                        ? container_or(c1, type1, c2, type2, &result_type)
 1089|  6.24k|                        : container_ior(c1, type1, c2, type2, &result_type);
 1090|       |
 1091|  6.24k|                if (c != c1) {  // in this instance a new container was created,
  ------------------
  |  Branch (1091:21): [True: 4.49k, False: 1.75k]
  ------------------
 1092|       |                                // and we need to free the old one
 1093|  4.49k|                    container_free(c1, type1);
 1094|  4.49k|                }
 1095|  6.24k|                ra_set_container_at_index(&x1->high_low_container, pos1, c,
 1096|  6.24k|                                          result_type);
 1097|  6.24k|            }
 1098|  6.24k|            ++pos1;
 1099|  6.24k|            ++pos2;
 1100|  6.24k|            if (pos1 == length1) break;
  ------------------
  |  Branch (1100:17): [True: 6.24k, 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.24k|    }
 1115|  6.24k|    if (pos1 == length1) {
  ------------------
  |  Branch (1115:9): [True: 6.24k, False: 0]
  ------------------
 1116|  6.24k|        ra_append_copy_range(&x1->high_low_container, &x2->high_low_container,
 1117|  6.24k|                             pos2, length2, is_cow(x2));
 1118|  6.24k|    }
 1119|  6.24k|}
roaring_bitmap_xor:
 1122|  6.24k|                                     const roaring_bitmap_t *x2) {
 1123|  6.24k|    uint8_t result_type = 0;
 1124|  6.24k|    const int length1 = x1->high_low_container.size,
 1125|  6.24k|              length2 = x2->high_low_container.size;
 1126|  6.24k|    if (0 == length1) {
  ------------------
  |  Branch (1126:9): [True: 0, False: 6.24k]
  ------------------
 1127|      0|        return roaring_bitmap_copy(x2);
 1128|      0|    }
 1129|  6.24k|    if (0 == length2) {
  ------------------
  |  Branch (1129:9): [True: 51, False: 6.19k]
  ------------------
 1130|     51|        return roaring_bitmap_copy(x1);
 1131|     51|    }
 1132|  6.19k|    roaring_bitmap_t *answer =
 1133|  6.19k|        roaring_bitmap_create_with_capacity(length1 + length2);
 1134|  6.19k|    roaring_bitmap_set_copy_on_write(answer, is_cow(x1) || is_cow(x2));
  ------------------
  |  Branch (1134:46): [True: 0, False: 6.19k]
  |  Branch (1134:60): [True: 0, False: 6.19k]
  ------------------
 1135|  6.19k|    int pos1 = 0, pos2 = 0;
 1136|  6.19k|    uint8_t type1, type2;
 1137|  6.19k|    uint16_t s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1138|  6.19k|    uint16_t s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 1139|  6.19k|    while (true) {
  ------------------
  |  Branch (1139:12): [True: 6.19k, Folded]
  ------------------
 1140|  6.19k|        if (s1 == s2) {
  ------------------
  |  Branch (1140:13): [True: 6.12k, False: 67]
  ------------------
 1141|  6.12k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
 1142|  6.12k|                                                        (uint16_t)pos1, &type1);
 1143|  6.12k|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
 1144|  6.12k|                                                        (uint16_t)pos2, &type2);
 1145|  6.12k|            container_t *c = container_xor(c1, type1, c2, type2, &result_type);
 1146|       |
 1147|  6.12k|            if (container_nonzero_cardinality(c, result_type)) {
  ------------------
  |  Branch (1147:17): [True: 6.11k, False: 17]
  ------------------
 1148|  6.11k|                ra_append(&answer->high_low_container, s1, c, result_type);
 1149|  6.11k|            } else {
 1150|     17|                container_free(c, result_type);
 1151|     17|            }
 1152|  6.12k|            ++pos1;
 1153|  6.12k|            ++pos2;
 1154|  6.12k|            if (pos1 == length1) break;
  ------------------
  |  Branch (1154:17): [True: 6.12k, 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|     67|        } else if (s1 < s2) {  // s1 < s2
  ------------------
  |  Branch (1159:20): [True: 67, False: 0]
  ------------------
 1160|     67|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
 1161|     67|                                                        (uint16_t)pos1, &type1);
 1162|     67|            c1 = get_copy_of_container(c1, &type1, is_cow(x1));
 1163|     67|            if (is_cow(x1)) {
  ------------------
  |  Branch (1163:17): [True: 0, False: 67]
  ------------------
 1164|      0|                ra_set_container_at_index(&x1->high_low_container, pos1, c1,
 1165|      0|                                          type1);
 1166|      0|            }
 1167|     67|            ra_append(&answer->high_low_container, s1, c1, type1);
 1168|     67|            pos1++;
 1169|     67|            if (pos1 == length1) break;
  ------------------
  |  Branch (1169:17): [True: 67, 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.19k|    }
 1186|  6.19k|    if (pos1 == length1) {
  ------------------
  |  Branch (1186:9): [True: 6.19k, False: 0]
  ------------------
 1187|  6.19k|        ra_append_copy_range(&answer->high_low_container,
 1188|  6.19k|                             &x2->high_low_container, pos2, length2,
 1189|  6.19k|                             is_cow(x2));
 1190|  6.19k|    } 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.19k|    return answer;
 1196|  6.24k|}
roaring_bitmap_xor_inplace:
 1201|  6.24k|                                const roaring_bitmap_t *x2) {
 1202|  6.24k|    assert(x1 != x2);
 1203|  6.24k|    uint8_t result_type = 0;
 1204|  6.24k|    int length1 = x1->high_low_container.size;
 1205|  6.24k|    const int length2 = x2->high_low_container.size;
 1206|       |
 1207|  6.24k|    if (0 == length2) return;
  ------------------
  |  Branch (1207:9): [True: 14, False: 6.23k]
  ------------------
 1208|       |
 1209|  6.23k|    if (0 == length1) {
  ------------------
  |  Branch (1209:9): [True: 1.50k, False: 4.73k]
  ------------------
 1210|  1.50k|        roaring_bitmap_overwrite(x1, x2);
 1211|  1.50k|        return;
 1212|  1.50k|    }
 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.73k|    int pos1 = 0, pos2 = 0;
 1218|  4.73k|    uint8_t type1, type2;
 1219|  4.73k|    uint16_t s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1220|  4.73k|    uint16_t s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 1221|  6.71k|    while (true) {
  ------------------
  |  Branch (1221:12): [True: 6.71k, Folded]
  ------------------
 1222|  6.71k|        if (s1 == s2) {
  ------------------
  |  Branch (1222:13): [True: 6.61k, False: 102]
  ------------------
 1223|  6.61k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
 1224|  6.61k|                                                        (uint16_t)pos1, &type1);
 1225|  6.61k|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
 1226|  6.61k|                                                        (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.61k|            container_t *c;
 1235|  6.61k|            if (type1 == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|  6.61k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (1235:17): [True: 0, False: 6.61k]
  ------------------
 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.61k|            } else {
 1239|  6.61k|                c = container_ixor(c1, type1, c2, type2, &result_type);
 1240|  6.61k|            }
 1241|       |
 1242|  6.61k|            if (container_nonzero_cardinality(c, result_type)) {
  ------------------
  |  Branch (1242:17): [True: 4.43k, False: 2.17k]
  ------------------
 1243|  4.43k|                ra_set_container_at_index(&x1->high_low_container, pos1, c,
 1244|  4.43k|                                          result_type);
 1245|  4.43k|                ++pos1;
 1246|  4.43k|            } else {
 1247|  2.17k|                container_free(c, result_type);
 1248|  2.17k|                roaring_inplace_merge_bulk(x1, x2, pos1, pos1 + 1, pos2 + 1,
 1249|  2.17k|                                           true);
 1250|  2.17k|                return;
 1251|  2.17k|            }
 1252|       |
 1253|  4.43k|            ++pos2;
 1254|  4.43k|            if (pos1 == length1) break;
  ------------------
  |  Branch (1254:17): [True: 2.45k, False: 1.98k]
  ------------------
 1255|  1.98k|            if (pos2 == length2) break;
  ------------------
  |  Branch (1255:17): [True: 0, False: 1.98k]
  ------------------
 1256|  1.98k|            s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1257|  1.98k|            s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 1258|       |
 1259|  1.98k|        } else if (s1 < s2) {  // s1 < s2
  ------------------
  |  Branch (1259:20): [True: 0, False: 102]
  ------------------
 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|    102|        } else {  // s1 > s2
 1265|    102|            roaring_inplace_merge_bulk(x1, x2, pos1, pos1, pos2, true);
 1266|    102|            return;
 1267|    102|        }
 1268|  6.71k|    }
 1269|  2.45k|    if (pos1 == length1) {
  ------------------
  |  Branch (1269:9): [True: 2.45k, False: 0]
  ------------------
 1270|  2.45k|        ra_append_copy_range(&x1->high_low_container, &x2->high_low_container,
 1271|  2.45k|                             pos2, length2, is_cow(x2));
 1272|  2.45k|    }
 1273|  2.45k|}
roaring_bitmap_andnot:
 1276|  6.24k|                                        const roaring_bitmap_t *x2) {
 1277|  6.24k|    uint8_t result_type = 0;
 1278|  6.24k|    const int length1 = x1->high_low_container.size,
 1279|  6.24k|              length2 = x2->high_low_container.size;
 1280|  6.24k|    if (0 == length1) {
  ------------------
  |  Branch (1280:9): [True: 0, False: 6.24k]
  ------------------
 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.24k|    if (0 == length2) {
  ------------------
  |  Branch (1286:9): [True: 51, False: 6.19k]
  ------------------
 1287|     51|        return roaring_bitmap_copy(x1);
 1288|     51|    }
 1289|  6.19k|    roaring_bitmap_t *answer = roaring_bitmap_create_with_capacity(length1);
 1290|  6.19k|    roaring_bitmap_set_copy_on_write(answer, is_cow(x1) || is_cow(x2));
  ------------------
  |  Branch (1290:46): [True: 0, False: 6.19k]
  |  Branch (1290:60): [True: 0, False: 6.19k]
  ------------------
 1291|       |
 1292|  6.19k|    int pos1 = 0, pos2 = 0;
 1293|  6.19k|    uint8_t type1, type2;
 1294|  6.19k|    uint16_t s1 = 0;
 1295|  6.19k|    uint16_t s2 = 0;
 1296|  6.19k|    while (true) {
  ------------------
  |  Branch (1296:12): [True: 6.19k, Folded]
  ------------------
 1297|  6.19k|        s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1298|  6.19k|        s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 1299|       |
 1300|  6.19k|        if (s1 == s2) {
  ------------------
  |  Branch (1300:13): [True: 6.12k, False: 67]
  ------------------
 1301|  6.12k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
 1302|  6.12k|                                                        (uint16_t)pos1, &type1);
 1303|  6.12k|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
 1304|  6.12k|                                                        (uint16_t)pos2, &type2);
 1305|  6.12k|            container_t *c =
 1306|  6.12k|                container_andnot(c1, type1, c2, type2, &result_type);
 1307|       |
 1308|  6.12k|            if (container_nonzero_cardinality(c, result_type)) {
  ------------------
  |  Branch (1308:17): [True: 5.92k, False: 205]
  ------------------
 1309|  5.92k|                ra_append(&answer->high_low_container, s1, c, result_type);
 1310|  5.92k|            } else {
 1311|    205|                container_free(c, result_type);
 1312|    205|            }
 1313|  6.12k|            ++pos1;
 1314|  6.12k|            ++pos2;
 1315|  6.12k|            if (pos1 == length1) break;
  ------------------
  |  Branch (1315:17): [True: 6.12k, False: 0]
  ------------------
 1316|      0|            if (pos2 == length2) break;
  ------------------
  |  Branch (1316:17): [True: 0, False: 0]
  ------------------
 1317|     67|        } else if (s1 < s2) {  // s1 < s2
  ------------------
  |  Branch (1317:20): [True: 67, False: 0]
  ------------------
 1318|     67|            const int next_pos1 =
 1319|     67|                ra_advance_until(&x1->high_low_container, s2, pos1);
 1320|     67|            ra_append_copy_range(&answer->high_low_container,
 1321|     67|                                 &x1->high_low_container, pos1, next_pos1,
 1322|     67|                                 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|     67|            pos1 = next_pos1;
 1326|     67|            if (pos1 == length1) break;
  ------------------
  |  Branch (1326:17): [True: 67, False: 0]
  ------------------
 1327|     67|        } 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.19k|    }
 1332|  6.19k|    if (pos2 == length2) {
  ------------------
  |  Branch (1332:9): [True: 3.99k, False: 2.20k]
  ------------------
 1333|  3.99k|        ra_append_copy_range(&answer->high_low_container,
 1334|  3.99k|                             &x1->high_low_container, pos1, length1,
 1335|  3.99k|                             is_cow(x1));
 1336|  3.99k|    }
 1337|  6.19k|    return answer;
 1338|  6.24k|}
roaring_bitmap_andnot_inplace:
 1343|  6.24k|                                   const roaring_bitmap_t *x2) {
 1344|  6.24k|    assert(x1 != x2);
 1345|       |
 1346|  6.24k|    uint8_t result_type = 0;
 1347|  6.24k|    int length1 = x1->high_low_container.size;
 1348|  6.24k|    const int length2 = x2->high_low_container.size;
 1349|  6.24k|    int intersection_size = 0;
 1350|       |
 1351|  6.24k|    if (0 == length2) return;
  ------------------
  |  Branch (1351:9): [True: 434, False: 5.81k]
  ------------------
 1352|       |
 1353|  5.81k|    if (0 == length1) {
  ------------------
  |  Branch (1353:9): [True: 0, False: 5.81k]
  ------------------
 1354|      0|        roaring_bitmap_clear(x1);
 1355|      0|        return;
 1356|      0|    }
 1357|       |
 1358|  5.81k|    int pos1 = 0, pos2 = 0;
 1359|  5.81k|    uint8_t type1, type2;
 1360|  5.81k|    uint16_t s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1361|  5.81k|    uint16_t s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 1362|  5.81k|    while (true) {
  ------------------
  |  Branch (1362:12): [True: 5.81k, Folded]
  ------------------
 1363|  5.81k|        if (s1 == s2) {
  ------------------
  |  Branch (1363:13): [True: 5.81k, False: 0]
  ------------------
 1364|  5.81k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
 1365|  5.81k|                                                        (uint16_t)pos1, &type1);
 1366|  5.81k|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
 1367|  5.81k|                                                        (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.81k|            container_t *c;
 1376|  5.81k|            if (type1 == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|  5.81k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (1376:17): [True: 0, False: 5.81k]
  ------------------
 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.81k|            } else {
 1380|  5.81k|                c = container_iandnot(c1, type1, c2, type2, &result_type);
 1381|  5.81k|            }
 1382|       |
 1383|  5.81k|            if (container_nonzero_cardinality(c, result_type)) {
  ------------------
  |  Branch (1383:17): [True: 4.31k, False: 1.50k]
  ------------------
 1384|  4.31k|                ra_replace_key_and_container_at_index(&x1->high_low_container,
 1385|  4.31k|                                                      intersection_size++, s1,
 1386|  4.31k|                                                      c, result_type);
 1387|  4.31k|            } else {
 1388|  1.50k|                container_free(c, result_type);
 1389|  1.50k|            }
 1390|       |
 1391|  5.81k|            ++pos1;
 1392|  5.81k|            ++pos2;
 1393|  5.81k|            if (pos1 == length1) break;
  ------------------
  |  Branch (1393:17): [True: 3.77k, False: 2.03k]
  ------------------
 1394|  2.03k|            if (pos2 == length2) break;
  ------------------
  |  Branch (1394:17): [True: 2.03k, 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.81k|    }
 1417|       |
 1418|  5.81k|    if (pos1 < length1) {
  ------------------
  |  Branch (1418:9): [True: 2.03k, False: 3.77k]
  ------------------
 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.03k|        if (pos1 > intersection_size) {
  ------------------
  |  Branch (1425:13): [True: 38, False: 1.99k]
  ------------------
 1426|       |            // left slide of remaining items
 1427|     38|            ra_copy_range(&x1->high_low_container, pos1, length1,
 1428|     38|                          intersection_size);
 1429|     38|        }
 1430|       |        // else current placement is fine
 1431|  2.03k|        intersection_size += (length1 - pos1);
 1432|  2.03k|    }
 1433|  5.81k|    ra_downsize(&x1->high_low_container, intersection_size);
 1434|  5.81k|}
roaring_bitmap_get_cardinality:
 1436|  62.4k|uint64_t roaring_bitmap_get_cardinality(const roaring_bitmap_t *r) {
 1437|  62.4k|    const roaring_array_t *ra = &r->high_low_container;
 1438|       |
 1439|  62.4k|    uint64_t card = 0;
 1440|   409k|    for (int i = 0; i < ra->size; ++i)
  ------------------
  |  Branch (1440:21): [True: 347k, False: 62.4k]
  ------------------
 1441|   347k|        card += container_get_cardinality(ra->containers[i], ra->typecodes[i]);
 1442|  62.4k|    return card;
 1443|  62.4k|}
roaring_bitmap_is_empty:
 1506|  12.4k|bool roaring_bitmap_is_empty(const roaring_bitmap_t *r) {
 1507|  12.4k|    return r->high_low_container.size == 0;
 1508|  12.4k|}
roaring_bitmap_to_uint32_array:
 1510|  6.24k|void roaring_bitmap_to_uint32_array(const roaring_bitmap_t *r, uint32_t *ans) {
 1511|  6.24k|    ra_to_uint32_array(&r->high_low_container, ans);
 1512|  6.24k|}
roaring_bitmap_run_optimize:
 1530|  12.4k|bool roaring_bitmap_run_optimize(roaring_bitmap_t *r) {
 1531|  12.4k|    bool answer = false;
 1532|  24.9k|    for (int i = 0; i < r->high_low_container.size; i++) {
  ------------------
  |  Branch (1532:21): [True: 12.4k, False: 12.4k]
  ------------------
 1533|  12.4k|        uint8_t type_original, type_after;
 1534|  12.4k|        ra_unshare_container_at_index(
 1535|  12.4k|            &r->high_low_container,
 1536|  12.4k|            (uint16_t)i);  // TODO: this introduces extra cloning!
 1537|  12.4k|        container_t *c = ra_get_container_at_index(&r->high_low_container,
 1538|  12.4k|                                                   (uint16_t)i, &type_original);
 1539|  12.4k|        container_t *c1 = convert_run_optimize(c, type_original, &type_after);
 1540|  12.4k|        if (type_after == RUN_CONTAINER_TYPE) {
  ------------------
  |  |   50|  12.4k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (1540:13): [True: 3.97k, False: 8.51k]
  ------------------
 1541|       |            answer = true;
 1542|  3.97k|        }
 1543|  12.4k|        ra_set_container_at_index(&r->high_low_container, i, c1, type_after);
 1544|  12.4k|    }
 1545|  12.4k|    return answer;
 1546|  12.4k|}
roaring_bitmap_shrink_to_fit:
 1548|  6.24k|size_t roaring_bitmap_shrink_to_fit(roaring_bitmap_t *r) {
 1549|  6.24k|    size_t answer = 0;
 1550|  12.4k|    for (int i = 0; i < r->high_low_container.size; i++) {
  ------------------
  |  Branch (1550:21): [True: 6.24k, False: 6.24k]
  ------------------
 1551|  6.24k|        uint8_t type_original;
 1552|  6.24k|        container_t *c = ra_get_container_at_index(&r->high_low_container,
 1553|  6.24k|                                                   (uint16_t)i, &type_original);
 1554|  6.24k|        answer += container_shrink_to_fit(c, type_original);
 1555|  6.24k|    }
 1556|  6.24k|    answer += ra_shrink_to_fit(&r->high_low_container);
 1557|  6.24k|    return answer;
 1558|  6.24k|}
roaring_bitmap_remove_run_compression:
 1564|  6.24k|bool roaring_bitmap_remove_run_compression(roaring_bitmap_t *r) {
 1565|  6.24k|    bool answer = false;
 1566|  80.0k|    for (int i = 0; i < r->high_low_container.size; i++) {
  ------------------
  |  Branch (1566:21): [True: 73.8k, False: 6.24k]
  ------------------
 1567|  73.8k|        uint8_t type_original, type_after;
 1568|  73.8k|        container_t *c = ra_get_container_at_index(&r->high_low_container,
 1569|  73.8k|                                                   (uint16_t)i, &type_original);
 1570|  73.8k|        if (get_container_type(c, type_original) == RUN_CONTAINER_TYPE) {
  ------------------
  |  |   50|  73.8k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (1570:13): [True: 66.5k, False: 7.24k]
  ------------------
 1571|  66.5k|            answer = true;
 1572|  66.5k|            if (type_original == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|  66.5k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (1572:17): [True: 0, False: 66.5k]
  ------------------
 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.5k|            } else {
 1582|  66.5k|                int32_t card = run_container_cardinality(CAST_run(c));
  ------------------
  |  |   77|  66.5k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  66.5k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1583|  66.5k|                container_t *c1 = convert_to_bitset_or_array_container(
 1584|  66.5k|                    CAST_run(c), card, &type_after);
  ------------------
  |  |   77|  66.5k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  66.5k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1585|  66.5k|                run_container_free(CAST_run(c));
  ------------------
  |  |   77|  66.5k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  66.5k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1586|  66.5k|                ra_set_container_at_index(&r->high_low_container, i, c1,
 1587|  66.5k|                                          type_after);
 1588|  66.5k|            }
 1589|  66.5k|        }
 1590|  73.8k|    }
 1591|  6.24k|    return answer;
 1592|  6.24k|}
roaring_bitmap_portable_size_in_bytes:
 1627|  12.4k|size_t roaring_bitmap_portable_size_in_bytes(const roaring_bitmap_t *r) {
 1628|  12.4k|    return ra_portable_size_in_bytes(&r->high_low_container);
 1629|  12.4k|}
roaring_bitmap_portable_deserialize_safe:
 1632|  12.4k|                                                           size_t maxbytes) {
 1633|  12.4k|    roaring_bitmap_t *ans =
 1634|  12.4k|        (roaring_bitmap_t *)roaring_malloc(sizeof(roaring_bitmap_t));
 1635|  12.4k|    if (ans == NULL) {
  ------------------
  |  Branch (1635:9): [True: 0, False: 12.4k]
  ------------------
 1636|      0|        return NULL;
 1637|      0|    }
 1638|  12.4k|    size_t bytesread;
 1639|  12.4k|    bool is_ok = ra_portable_deserialize(&ans->high_low_container, buf,
 1640|  12.4k|                                         maxbytes, &bytesread);
 1641|  12.4k|    if (!is_ok) {
  ------------------
  |  Branch (1641:9): [True: 6.23k, False: 6.25k]
  ------------------
 1642|  6.23k|        roaring_free(ans);
 1643|  6.23k|        return NULL;
 1644|  6.23k|    }
 1645|  6.25k|    roaring_bitmap_set_copy_on_write(ans, false);
 1646|  6.25k|    if (!is_ok) {
  ------------------
  |  Branch (1646:9): [True: 0, False: 6.25k]
  ------------------
 1647|      0|        roaring_free(ans);
 1648|      0|        return NULL;
 1649|      0|    }
 1650|  6.25k|    return ans;
 1651|  6.25k|}
roaring_bitmap_portable_serialize:
 1662|  6.24k|size_t roaring_bitmap_portable_serialize(const roaring_bitmap_t *r, char *buf) {
 1663|  6.24k|    return ra_portable_serialize(&r->high_low_container, buf);
 1664|  6.24k|}
roaring_iterate:
 1745|  6.23k|                     void *ptr) {
 1746|  6.23k|    const roaring_array_t *ra = &r->high_low_container;
 1747|       |
 1748|  69.6k|    for (int i = 0; i < ra->size; ++i)
  ------------------
  |  Branch (1748:21): [True: 63.3k, False: 6.23k]
  ------------------
 1749|  63.3k|        if (!container_iterate(ra->containers[i], ra->typecodes[i],
  ------------------
  |  Branch (1749:13): [True: 0, False: 63.3k]
  ------------------
 1750|  63.3k|                               ((uint32_t)ra->keys[i]) << 16, iterator, ptr)) {
 1751|      0|            return false;
 1752|      0|        }
 1753|  6.23k|    return true;
 1754|  6.23k|}
roaring_iterator_init:
 1861|  12.4k|                           roaring_uint32_iterator_t *newit) {
 1862|  12.4k|    newit->parent = r;
 1863|  12.4k|    newit->container_index = 0;
 1864|  12.4k|    newit->has_value = loadfirstvalue(newit);
 1865|  12.4k|}
roaring_uint32_iterator_move_equalorlarger:
 1893|  6.24k|                                                uint32_t val) {
 1894|  6.24k|    uint16_t hb = val >> 16;
 1895|  6.24k|    const int i = ra_get_index(&it->parent->high_low_container, hb);
 1896|  6.24k|    if (i >= 0) {
  ------------------
  |  Branch (1896:9): [True: 6.18k, False: 57]
  ------------------
 1897|  6.18k|        uint32_t lowvalue =
 1898|  6.18k|            container_maximum(it->parent->high_low_container.containers[i],
 1899|  6.18k|                              it->parent->high_low_container.typecodes[i]);
 1900|  6.18k|        uint16_t lb = val & 0xFFFF;
 1901|  6.18k|        if (lowvalue < lb) {
  ------------------
  |  Branch (1901:13): [True: 19, False: 6.17k]
  ------------------
 1902|       |            // will have to load first value of next container
 1903|     19|            it->container_index = i + 1;
 1904|  6.17k|        } else {
 1905|       |            // the value is necessarily within the range of the container
 1906|  6.17k|            it->container_index = i;
 1907|  6.17k|            it->has_value = loadfirstvalue_largeorequal(it, val);
 1908|  6.17k|            return it->has_value;
 1909|  6.17k|        }
 1910|  6.18k|    } else {
 1911|       |        // there is no matching, so we are going for the next container
 1912|     57|        it->container_index = -i - 1;
 1913|     57|    }
 1914|     76|    it->has_value = loadfirstvalue(it);
 1915|     76|    return it->has_value;
 1916|  6.24k|}
roaring_uint32_iterator_advance:
 1918|   329k|bool roaring_uint32_iterator_advance(roaring_uint32_iterator_t *it) {
 1919|   329k|    if (it->container_index >= it->parent->high_low_container.size) {
  ------------------
  |  Branch (1919:9): [True: 0, False: 329k]
  ------------------
 1920|      0|        return (it->has_value = false);
 1921|      0|    }
 1922|   329k|    if (it->container_index < 0) {
  ------------------
  |  Branch (1922:9): [True: 0, False: 329k]
  ------------------
 1923|      0|        it->container_index = 0;
 1924|      0|        return (it->has_value = loadfirstvalue(it));
 1925|      0|    }
 1926|   329k|    uint16_t low16 = (uint16_t)it->current_value;
 1927|   329k|    if (container_iterator_next(it->container, it->typecode, &it->container_it,
  ------------------
  |  Branch (1927:9): [True: 323k, False: 6.04k]
  ------------------
 1928|   329k|                                &low16)) {
 1929|   323k|        it->current_value = it->highbits | low16;
 1930|   323k|        return (it->has_value = true);
 1931|   323k|    }
 1932|  6.04k|    it->container_index++;
 1933|  6.04k|    return (it->has_value = loadfirstvalue(it));
 1934|   329k|}
roaring_bitmap_equals:
 2129|  12.4k|                           const roaring_bitmap_t *r2) {
 2130|  12.4k|    const roaring_array_t *ra1 = &r1->high_low_container;
 2131|  12.4k|    const roaring_array_t *ra2 = &r2->high_low_container;
 2132|       |
 2133|  12.4k|    if (ra1->size != ra2->size) {
  ------------------
  |  Branch (2133:9): [True: 2.31k, False: 10.1k]
  ------------------
 2134|  2.31k|        return false;
 2135|  2.31k|    }
 2136|  87.8k|    for (int i = 0; i < ra1->size; ++i) {
  ------------------
  |  Branch (2136:21): [True: 77.7k, False: 10.1k]
  ------------------
 2137|  77.7k|        if (ra1->keys[i] != ra2->keys[i]) {
  ------------------
  |  Branch (2137:13): [True: 25, False: 77.7k]
  ------------------
 2138|     25|            return false;
 2139|     25|        }
 2140|  77.7k|    }
 2141|  83.9k|    for (int i = 0; i < ra1->size; ++i) {
  ------------------
  |  Branch (2141:21): [True: 77.7k, False: 6.24k]
  ------------------
 2142|  77.7k|        bool areequal = container_equals(ra1->containers[i], ra1->typecodes[i],
 2143|  77.7k|                                         ra2->containers[i], ra2->typecodes[i]);
 2144|  77.7k|        if (!areequal) {
  ------------------
  |  Branch (2144:13): [True: 3.90k, False: 73.8k]
  ------------------
 2145|  3.90k|            return false;
 2146|  3.90k|        }
 2147|  77.7k|    }
 2148|  6.24k|    return true;
 2149|  10.1k|}
roaring_bitmap_is_subset:
 2152|  11.2k|                              const roaring_bitmap_t *r2) {
 2153|  11.2k|    const roaring_array_t *ra1 = &r1->high_low_container;
 2154|  11.2k|    const roaring_array_t *ra2 = &r2->high_low_container;
 2155|       |
 2156|  11.2k|    const int length1 = ra1->size, length2 = ra2->size;
 2157|       |
 2158|  11.2k|    int pos1 = 0, pos2 = 0;
 2159|       |
 2160|  11.2k|    while (pos1 < length1 && pos2 < length2) {
  ------------------
  |  Branch (2160:12): [True: 10.8k, False: 410]
  |  Branch (2160:30): [True: 10.8k, False: 51]
  ------------------
 2161|  10.8k|        const uint16_t s1 = ra_get_key_at_index(ra1, (uint16_t)pos1);
 2162|  10.8k|        const uint16_t s2 = ra_get_key_at_index(ra2, (uint16_t)pos2);
 2163|       |
 2164|  10.8k|        if (s1 == s2) {
  ------------------
  |  Branch (2164:13): [True: 10.7k, False: 103]
  ------------------
 2165|  10.7k|            uint8_t type1, type2;
 2166|  10.7k|            container_t *c1 =
 2167|  10.7k|                ra_get_container_at_index(ra1, (uint16_t)pos1, &type1);
 2168|  10.7k|            container_t *c2 =
 2169|  10.7k|                ra_get_container_at_index(ra2, (uint16_t)pos2, &type2);
 2170|  10.7k|            if (!container_is_subset(c1, type1, c2, type2)) return false;
  ------------------
  |  Branch (2170:17): [True: 10.7k, False: 0]
  ------------------
 2171|      0|            ++pos1;
 2172|      0|            ++pos2;
 2173|    103|        } else if (s1 < s2) {  // s1 < s2
  ------------------
  |  Branch (2173:20): [True: 103, False: 0]
  ------------------
 2174|    103|            return false;
 2175|    103|        } else {  // s1 > s2
 2176|      0|            pos2 = ra_advance_until(ra2, s1, pos2);
 2177|      0|        }
 2178|  10.8k|    }
 2179|    461|    if (pos1 == length1)
  ------------------
  |  Branch (2179:9): [True: 410, False: 51]
  ------------------
 2180|    410|        return true;
 2181|     51|    else
 2182|     51|        return false;
 2183|    461|}
roaring_bitmap_flip_inplace:
 2352|  6.24k|                                 uint64_t range_end) {
 2353|  6.24k|    if (range_start >= range_end || range_start > (uint64_t)UINT32_MAX + 1) {
  ------------------
  |  Branch (2353:9): [True: 5.72k, False: 522]
  |  Branch (2353:37): [True: 0, False: 522]
  ------------------
 2354|  5.72k|        return;
 2355|  5.72k|    }
 2356|    522|    roaring_bitmap_flip_inplace_closed(x1, (uint32_t)range_start,
 2357|    522|                                       (uint32_t)(range_end - 1));
 2358|    522|}
roaring_bitmap_flip_inplace_closed:
 2362|  6.76k|                                        uint32_t range_end) {
 2363|  6.76k|    if (range_start > range_end) {
  ------------------
  |  Branch (2363:9): [True: 156, False: 6.61k]
  ------------------
 2364|    156|        return;  // empty range
 2365|    156|    }
 2366|       |
 2367|  6.61k|    uint16_t hb_start = (uint16_t)(range_start >> 16);
 2368|  6.61k|    const uint16_t lb_start = (uint16_t)range_start;
 2369|  6.61k|    uint16_t hb_end = (uint16_t)(range_end >> 16);
 2370|  6.61k|    const uint16_t lb_end = (uint16_t)range_end;
 2371|       |
 2372|  6.61k|    if (hb_start == hb_end) {
  ------------------
  |  Branch (2372:9): [True: 6.16k, False: 446]
  ------------------
 2373|  6.16k|        inplace_flip_container(&x1->high_low_container, hb_start, lb_start,
 2374|  6.16k|                               lb_end);
 2375|  6.16k|    } else {
 2376|       |        // start and end containers are distinct
 2377|    446|        if (lb_start > 0) {
  ------------------
  |  Branch (2377:13): [True: 359, False: 87]
  ------------------
 2378|       |            // handle first (partial) container
 2379|    359|            inplace_flip_container(&x1->high_low_container, hb_start, lb_start,
 2380|    359|                                   0xFFFF);
 2381|    359|            ++hb_start;  // for the full containers.  Can't wrap.
 2382|    359|        }
 2383|       |
 2384|    446|        if (lb_end != 0xFFFF) --hb_end;
  ------------------
  |  Branch (2384:13): [True: 429, False: 17]
  ------------------
 2385|       |
 2386|  23.6k|        for (uint32_t hb = hb_start; hb <= hb_end; ++hb) {
  ------------------
  |  Branch (2386:38): [True: 23.2k, False: 446]
  ------------------
 2387|  23.2k|            inplace_fully_flip_container(&x1->high_low_container, (uint16_t)hb);
 2388|  23.2k|        }
 2389|       |        // handle a partial final container
 2390|    446|        if (lb_end != 0xFFFF) {
  ------------------
  |  Branch (2390:13): [True: 429, False: 17]
  ------------------
 2391|    429|            inplace_flip_container(&x1->high_low_container, hb_end + 1, 0,
 2392|    429|                                   lb_end);
 2393|    429|            ++hb_end;
 2394|    429|        }
 2395|    446|    }
 2396|  6.61k|}
roaring_bitmap_rank:
 2862|  6.24k|uint64_t roaring_bitmap_rank(const roaring_bitmap_t *bm, uint32_t x) {
 2863|  6.24k|    uint64_t size = 0;
 2864|  6.24k|    uint32_t xhigh = x >> 16;
 2865|  6.24k|    for (int i = 0; i < bm->high_low_container.size; i++) {
  ------------------
  |  Branch (2865:21): [True: 6.24k, False: 0]
  ------------------
 2866|  6.24k|        uint32_t key = bm->high_low_container.keys[i];
 2867|  6.24k|        if (xhigh > key) {
  ------------------
  |  Branch (2867:13): [True: 0, False: 6.24k]
  ------------------
 2868|      0|            size +=
 2869|      0|                container_get_cardinality(bm->high_low_container.containers[i],
 2870|      0|                                          bm->high_low_container.typecodes[i]);
 2871|  6.24k|        } else if (xhigh == key) {
  ------------------
  |  Branch (2871:20): [True: 6.24k, False: 0]
  ------------------
 2872|  6.24k|            return size + container_rank(bm->high_low_container.containers[i],
 2873|  6.24k|                                         bm->high_low_container.typecodes[i],
 2874|  6.24k|                                         x & 0xFFFF);
 2875|  6.24k|        } else {
 2876|      0|            return size;
 2877|      0|        }
 2878|  6.24k|    }
 2879|      0|    return size;
 2880|  6.24k|}
roaring_bitmap_minimum:
 2945|  6.24k|uint32_t roaring_bitmap_minimum(const roaring_bitmap_t *bm) {
 2946|  6.24k|    if (bm->high_low_container.size > 0) {
  ------------------
  |  Branch (2946:9): [True: 6.19k, False: 51]
  ------------------
 2947|  6.19k|        container_t *c = bm->high_low_container.containers[0];
 2948|  6.19k|        uint8_t type = bm->high_low_container.typecodes[0];
 2949|  6.19k|        uint32_t key = bm->high_low_container.keys[0];
 2950|  6.19k|        uint32_t lowvalue = container_minimum(c, type);
 2951|  6.19k|        return lowvalue | (key << 16);
 2952|  6.19k|    }
 2953|     51|    return UINT32_MAX;
 2954|  6.24k|}
roaring_bitmap_maximum:
 2960|  6.24k|uint32_t roaring_bitmap_maximum(const roaring_bitmap_t *bm) {
 2961|  6.24k|    if (bm->high_low_container.size > 0) {
  ------------------
  |  Branch (2961:9): [True: 6.19k, False: 51]
  ------------------
 2962|  6.19k|        container_t *container =
 2963|  6.19k|            bm->high_low_container.containers[bm->high_low_container.size - 1];
 2964|  6.19k|        uint8_t typecode =
 2965|  6.19k|            bm->high_low_container.typecodes[bm->high_low_container.size - 1];
 2966|  6.19k|        uint32_t key =
 2967|  6.19k|            bm->high_low_container.keys[bm->high_low_container.size - 1];
 2968|  6.19k|        uint32_t lowvalue = container_maximum(container, typecode);
 2969|  6.19k|        return lowvalue | (key << 16);
 2970|  6.19k|    }
 2971|     51|    return 0;
 2972|  6.24k|}
roaring_bitmap_select:
 2975|  6.24k|                           uint32_t *element) {
 2976|  6.24k|    container_t *container;
 2977|  6.24k|    uint8_t typecode;
 2978|  6.24k|    uint16_t key;
 2979|  6.24k|    uint32_t start_rank = 0;
 2980|  6.24k|    int i = 0;
 2981|  6.24k|    bool valid = false;
 2982|  12.4k|    while (!valid && i < bm->high_low_container.size) {
  ------------------
  |  Branch (2982:12): [True: 6.68k, False: 5.80k]
  |  Branch (2982:22): [True: 6.24k, False: 438]
  ------------------
 2983|  6.24k|        container = bm->high_low_container.containers[i];
 2984|  6.24k|        typecode = bm->high_low_container.typecodes[i];
 2985|  6.24k|        valid =
 2986|  6.24k|            container_select(container, typecode, &start_rank, rank, element);
 2987|  6.24k|        i++;
 2988|  6.24k|    }
 2989|       |
 2990|  6.24k|    if (valid) {
  ------------------
  |  Branch (2990:9): [True: 5.80k, False: 438]
  ------------------
 2991|  5.80k|        key = bm->high_low_container.keys[i - 1];
 2992|  5.80k|        *element |= (((uint32_t)key) << 16);  // w/o cast, key promotes signed
 2993|  5.80k|        return true;
 2994|  5.80k|    } else
 2995|    438|        return false;
 2996|  6.24k|}
roaring_bitmap_intersect:
 2999|  6.24k|                              const roaring_bitmap_t *x2) {
 3000|  6.24k|    const int length1 = x1->high_low_container.size,
 3001|  6.24k|              length2 = x2->high_low_container.size;
 3002|  6.24k|    uint64_t answer = 0;
 3003|  6.24k|    int pos1 = 0, pos2 = 0;
 3004|       |
 3005|  6.62k|    while (pos1 < length1 && pos2 < length2) {
  ------------------
  |  Branch (3005:12): [True: 6.24k, False: 383]
  |  Branch (3005:30): [True: 6.19k, False: 51]
  ------------------
 3006|  6.19k|        const uint16_t s1 =
 3007|  6.19k|            ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 3008|  6.19k|        const uint16_t s2 =
 3009|  6.19k|            ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 3010|       |
 3011|  6.19k|        if (s1 == s2) {
  ------------------
  |  Branch (3011:13): [True: 6.12k, False: 67]
  ------------------
 3012|  6.12k|            uint8_t type1, type2;
 3013|  6.12k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
 3014|  6.12k|                                                        (uint16_t)pos1, &type1);
 3015|  6.12k|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
 3016|  6.12k|                                                        (uint16_t)pos2, &type2);
 3017|  6.12k|            if (container_intersect(c1, type1, c2, type2)) return true;
  ------------------
  |  Branch (3017:17): [True: 5.81k, False: 316]
  ------------------
 3018|    316|            ++pos1;
 3019|    316|            ++pos2;
 3020|    316|        } else if (s1 < s2) {  // s1 < s2
  ------------------
  |  Branch (3020:20): [True: 67, False: 0]
  ------------------
 3021|     67|            pos1 = ra_advance_until(&x1->high_low_container, s2, pos1);
 3022|     67|        } else {  // s1 > s2
 3023|      0|            pos2 = ra_advance_until(&x2->high_low_container, s1, pos2);
 3024|      0|        }
 3025|  6.19k|    }
 3026|    434|    return answer != 0;
 3027|  6.24k|}
roaring_bitmap_and_cardinality:
 3049|  24.9k|                                        const roaring_bitmap_t *x2) {
 3050|  24.9k|    const int length1 = x1->high_low_container.size,
 3051|  24.9k|              length2 = x2->high_low_container.size;
 3052|  24.9k|    uint64_t answer = 0;
 3053|  24.9k|    int pos1 = 0, pos2 = 0;
 3054|  49.7k|    while (pos1 < length1 && pos2 < length2) {
  ------------------
  |  Branch (3054:12): [True: 24.9k, False: 24.7k]
  |  Branch (3054:30): [True: 24.7k, False: 204]
  ------------------
 3055|  24.7k|        const uint16_t s1 =
 3056|  24.7k|            ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 3057|  24.7k|        const uint16_t s2 =
 3058|  24.7k|            ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 3059|       |
 3060|  24.7k|        if (s1 == s2) {
  ------------------
  |  Branch (3060:13): [True: 24.5k, False: 268]
  ------------------
 3061|  24.5k|            uint8_t type1, type2;
 3062|  24.5k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
 3063|  24.5k|                                                        (uint16_t)pos1, &type1);
 3064|  24.5k|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
 3065|  24.5k|                                                        (uint16_t)pos2, &type2);
 3066|  24.5k|            answer += container_and_cardinality(c1, type1, c2, type2);
 3067|  24.5k|            ++pos1;
 3068|  24.5k|            ++pos2;
 3069|  24.5k|        } else if (s1 < s2) {  // s1 < s2
  ------------------
  |  Branch (3069:20): [True: 268, False: 0]
  ------------------
 3070|    268|            pos1 = ra_advance_until(&x1->high_low_container, s2, pos1);
 3071|    268|        } else {  // s1 > s2
 3072|      0|            pos2 = ra_advance_until(&x2->high_low_container, s1, pos2);
 3073|      0|        }
 3074|  24.7k|    }
 3075|  24.9k|    return answer;
 3076|  24.9k|}
roaring_bitmap_jaccard_index:
 3079|  6.24k|                                    const roaring_bitmap_t *x2) {
 3080|  6.24k|    const uint64_t c1 = roaring_bitmap_get_cardinality(x1);
 3081|  6.24k|    const uint64_t c2 = roaring_bitmap_get_cardinality(x2);
 3082|  6.24k|    const uint64_t inter = roaring_bitmap_and_cardinality(x1, x2);
 3083|  6.24k|    return (double)inter / (double)(c1 + c2 - inter);
 3084|  6.24k|}
roaring_bitmap_or_cardinality:
 3087|  6.24k|                                       const roaring_bitmap_t *x2) {
 3088|  6.24k|    const uint64_t c1 = roaring_bitmap_get_cardinality(x1);
 3089|  6.24k|    const uint64_t c2 = roaring_bitmap_get_cardinality(x2);
 3090|  6.24k|    const uint64_t inter = roaring_bitmap_and_cardinality(x1, x2);
 3091|  6.24k|    return c1 + c2 - inter;
 3092|  6.24k|}
roaring_bitmap_andnot_cardinality:
 3095|  6.24k|                                           const roaring_bitmap_t *x2) {
 3096|  6.24k|    const uint64_t c1 = roaring_bitmap_get_cardinality(x1);
 3097|  6.24k|    const uint64_t inter = roaring_bitmap_and_cardinality(x1, x2);
 3098|  6.24k|    return c1 - inter;
 3099|  6.24k|}
roaring_bitmap_xor_cardinality:
 3102|  6.24k|                                        const roaring_bitmap_t *x2) {
 3103|  6.24k|    const uint64_t c1 = roaring_bitmap_get_cardinality(x1);
 3104|  6.24k|    const uint64_t c2 = roaring_bitmap_get_cardinality(x2);
 3105|  6.24k|    const uint64_t inter = roaring_bitmap_and_cardinality(x1, x2);
 3106|  6.24k|    return c1 + c2 - 2 * inter;
 3107|  6.24k|}
roaring_bitmap_contains_range:
 3114|  6.24k|                                   uint64_t range_start, uint64_t range_end) {
 3115|  6.24k|    if (range_start >= range_end || range_start > (uint64_t)UINT32_MAX + 1) {
  ------------------
  |  Branch (3115:9): [True: 5.49k, False: 752]
  |  Branch (3115:37): [True: 0, False: 752]
  ------------------
 3116|  5.49k|        return true;
 3117|  5.49k|    }
 3118|    752|    return roaring_bitmap_contains_range_closed(r, (uint32_t)range_start,
 3119|    752|                                                (uint32_t)(range_end - 1));
 3120|  6.24k|}
roaring_bitmap_contains_range_closed:
 3128|    752|                                          uint32_t range_end) {
 3129|    752|    if (range_start > range_end) {
  ------------------
  |  Branch (3129:9): [True: 0, False: 752]
  ------------------
 3130|      0|        return true;
 3131|      0|    }  // empty range are always contained!
 3132|    752|    if (range_end == range_start) {
  ------------------
  |  Branch (3132:9): [True: 46, False: 706]
  ------------------
 3133|     46|        return roaring_bitmap_contains(r, (uint32_t)range_start);
 3134|     46|    }
 3135|    706|    uint16_t hb_rs = (uint16_t)(range_start >> 16);
 3136|    706|    uint16_t hb_re = (uint16_t)(range_end >> 16);
 3137|    706|    const int32_t span = hb_re - hb_rs;
 3138|    706|    const int32_t hlc_sz = ra_get_size(&r->high_low_container);
 3139|    706|    if (hlc_sz < span + 1) {
  ------------------
  |  Branch (3139:9): [True: 224, False: 482]
  ------------------
 3140|    224|        return false;
 3141|    224|    }
 3142|    482|    int32_t is = ra_get_index(&r->high_low_container, hb_rs);
 3143|    482|    int32_t ie = ra_get_index(&r->high_low_container, hb_re);
 3144|    482|    if ((ie < 0) || (is < 0) || ((ie - is) != span) || ie >= hlc_sz) {
  ------------------
  |  Branch (3144:9): [True: 29, False: 453]
  |  Branch (3144:21): [True: 14, False: 439]
  |  Branch (3144:33): [True: 4, False: 435]
  |  Branch (3144:56): [True: 0, False: 435]
  ------------------
 3145|     47|        return false;
 3146|     47|    }
 3147|    435|    const uint32_t lb_rs = range_start & 0xFFFF;
 3148|    435|    const uint32_t lb_re = (range_end & 0xFFFF) + 1;
 3149|    435|    uint8_t type;
 3150|    435|    container_t *c =
 3151|    435|        ra_get_container_at_index(&r->high_low_container, (uint16_t)is, &type);
 3152|    435|    if (hb_rs == hb_re) {
  ------------------
  |  Branch (3152:9): [True: 362, False: 73]
  ------------------
 3153|    362|        return container_contains_range(c, lb_rs, lb_re, type);
 3154|    362|    }
 3155|     73|    if (!container_contains_range(c, lb_rs, 1 << 16, type)) {
  ------------------
  |  Branch (3155:9): [True: 15, False: 58]
  ------------------
 3156|     15|        return false;
 3157|     15|    }
 3158|     58|    c = ra_get_container_at_index(&r->high_low_container, (uint16_t)ie, &type);
 3159|     58|    if (!container_contains_range(c, 0, lb_re, type)) {
  ------------------
  |  Branch (3159:9): [True: 5, False: 53]
  ------------------
 3160|      5|        return false;
 3161|      5|    }
 3162|    787|    for (int32_t i = is + 1; i < ie; ++i) {
  ------------------
  |  Branch (3162:30): [True: 756, False: 31]
  ------------------
 3163|    756|        c = ra_get_container_at_index(&r->high_low_container, (uint16_t)i,
 3164|    756|                                      &type);
 3165|    756|        if (!container_is_full(c, type)) {
  ------------------
  |  Branch (3165:13): [True: 22, False: 734]
  ------------------
 3166|     22|            return false;
 3167|     22|        }
 3168|    756|    }
 3169|     31|    return true;
 3170|     53|}
roaring_bitmap_is_strict_subset:
 3173|  6.24k|                                     const roaring_bitmap_t *r2) {
 3174|  6.24k|    return (roaring_bitmap_get_cardinality(r2) >
  ------------------
  |  Branch (3174:13): [True: 5.04k, False: 1.20k]
  ------------------
 3175|  6.24k|                roaring_bitmap_get_cardinality(r1) &&
 3176|  5.04k|            roaring_bitmap_is_subset(r1, r2));
  ------------------
  |  Branch (3176:13): [True: 205, False: 4.83k]
  ------------------
 3177|  6.24k|}
roaring.c:containerptr_roaring_bitmap_add:
   56|  18.7k|                                                           int *index) {
   57|  18.7k|    roaring_array_t *ra = &r->high_low_container;
   58|       |
   59|  18.7k|    uint16_t hb = val >> 16;
   60|  18.7k|    const int i = ra_get_index(ra, hb);
   61|  18.7k|    if (i >= 0) {
  ------------------
  |  Branch (61:9): [True: 6.24k, False: 12.4k]
  ------------------
   62|  6.24k|        ra_unshare_container_at_index(ra, (uint16_t)i);
   63|  6.24k|        container_t *c = ra_get_container_at_index(ra, (uint16_t)i, type);
   64|  6.24k|        uint8_t new_type = *type;
   65|  6.24k|        container_t *c2 = container_add(c, val & 0xFFFF, *type, &new_type);
   66|  6.24k|        *index = i;
   67|  6.24k|        if (c2 != c) {
  ------------------
  |  Branch (67:13): [True: 3, False: 6.24k]
  ------------------
   68|      3|            container_free(c, *type);
   69|      3|            ra_set_container_at_index(ra, i, c2, new_type);
   70|      3|            *type = new_type;
   71|      3|            return c2;
   72|  6.24k|        } else {
   73|  6.24k|            return c;
   74|  6.24k|        }
   75|  12.4k|    } else {
   76|  12.4k|        array_container_t *new_ac = array_container_create();
   77|  12.4k|        container_t *c =
   78|  12.4k|            container_add(new_ac, val & 0xFFFF, ARRAY_CONTAINER_TYPE, type);
  ------------------
  |  |   49|  12.4k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
   79|       |        // we could just assume that it stays an array container
   80|  12.4k|        ra_insert_new_key_value_at(ra, -i - 1, hb, c, *type);
   81|  12.4k|        *index = -i - 1;
   82|  12.4k|        return c;
   83|  12.4k|    }
   84|  18.7k|}
roaring.c:add_bulk_impl:
  106|  7.80M|                                 uint32_t val) {
  107|  7.80M|    uint16_t key = val >> 16;
  108|  7.80M|    if (context->container == NULL || context->key != key) {
  ------------------
  |  Branch (108:9): [True: 0, False: 7.80M]
  |  Branch (108:39): [True: 0, False: 7.80M]
  ------------------
  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.80M|    } 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.80M|        uint8_t new_typecode;
  121|  7.80M|        container_t *container2 = container_add(
  122|  7.80M|            context->container, val & 0xFFFF, context->typecode, &new_typecode);
  123|  7.80M|        if (container2 != context->container) {
  ------------------
  |  Branch (123:13): [True: 117, False: 7.80M]
  ------------------
  124|       |            // rare instance when we need to change the container type
  125|    117|            container_free(context->container, context->typecode);
  126|    117|            ra_set_container_at_index(&r->high_low_container, context->idx,
  127|    117|                                      container2, new_typecode);
  128|    117|            context->typecode = new_typecode;
  129|    117|            context->container = container2;
  130|    117|        }
  131|  7.80M|    }
  132|  7.80M|}
roaring.c:is_cow:
   41|   105k|static inline bool is_cow(const roaring_bitmap_t *r) {
   42|       |    return r->high_low_container.flags & ROARING_FLAG_COW;
  ------------------
  |  |   46|   105k|#define ROARING_FLAG_COW UINT8_C(0x1)
  ------------------
   43|   105k|}
roaring.c:roaring_inplace_merge_bulk:
  957|  2.27k|                                       int left, int right, bool is_xor) {
  958|  2.27k|    roaring_array_t *ra1 = &x1->high_low_container;
  959|  2.27k|    const roaring_array_t *ra2 = &x2->high_low_container;
  960|  2.27k|    const bool cow2 = is_cow(x2);
  961|  2.27k|    const int length1 = ra1->size;
  962|  2.27k|    const int length2 = ra2->size;
  963|       |
  964|  2.27k|    int distinct = 0;
  965|  2.27k|    {
  966|  2.27k|        int l = left, r = right;
  967|  57.5k|        while (l < length1 && r < length2) {
  ------------------
  |  Branch (967:16): [True: 55.2k, False: 2.27k]
  |  Branch (967:31): [True: 55.2k, False: 0]
  ------------------
  968|  55.2k|            uint16_t k1 = ra1->keys[l];
  969|  55.2k|            uint16_t k2 = ra2->keys[r];
  970|  55.2k|            if (k1 < k2) {
  ------------------
  |  Branch (970:17): [True: 0, False: 55.2k]
  ------------------
  971|      0|                l++;
  972|  55.2k|            } else if (k1 > k2) {
  ------------------
  |  Branch (972:24): [True: 102, False: 55.1k]
  ------------------
  973|    102|                r++;
  974|  55.1k|            } else {
  975|  55.1k|                l++;
  976|  55.1k|                r++;
  977|  55.1k|            }
  978|  55.2k|            distinct++;
  979|  55.2k|        }
  980|  2.27k|        distinct += (length1 - l) + (length2 - r);
  981|  2.27k|    }
  982|  2.27k|    const int total = dst + distinct;
  983|       |
  984|  2.27k|    roaring_array_t merged;
  985|  2.27k|    ra_init_with_capacity(&merged, total > 0 ? (uint32_t)total : 1);
  ------------------
  |  Branch (985:36): [True: 2.20k, False: 78]
  ------------------
  986|       |
  987|  4.26k|    for (int i = 0; i < dst; i++) {
  ------------------
  |  Branch (987:21): [True: 1.98k, False: 2.27k]
  ------------------
  988|  1.98k|        ra_append(&merged, ra1->keys[i], ra1->containers[i], ra1->typecodes[i]);
  989|  1.98k|    }
  990|       |
  991|  2.27k|    uint8_t result_type = 0;
  992|  57.5k|    while (left < length1 && right < length2) {
  ------------------
  |  Branch (992:12): [True: 55.2k, False: 2.27k]
  |  Branch (992:30): [True: 55.2k, False: 0]
  ------------------
  993|  55.2k|        uint16_t k1 = ra1->keys[left];
  994|  55.2k|        uint16_t k2 = ra2->keys[right];
  995|  55.2k|        if (k1 < k2) {
  ------------------
  |  Branch (995:13): [True: 0, False: 55.2k]
  ------------------
  996|      0|            ra_append(&merged, k1, ra1->containers[left], ra1->typecodes[left]);
  997|      0|            left++;
  998|  55.2k|        } else if (k1 > k2) {
  ------------------
  |  Branch (998:20): [True: 102, False: 55.1k]
  ------------------
  999|    102|            uint8_t type2 = ra2->typecodes[right];
 1000|    102|            container_t *c2 =
 1001|    102|                get_copy_of_container(ra2->containers[right], &type2, cow2);
 1002|    102|            if (cow2) {
  ------------------
  |  Branch (1002:17): [True: 0, False: 102]
  ------------------
 1003|      0|                ra_set_container_at_index(ra2, right, c2, type2);
 1004|      0|            }
 1005|    102|            ra_append(&merged, k2, c2, type2);
 1006|    102|            right++;
 1007|  55.1k|        } else {
 1008|  55.1k|            uint8_t type1 = ra1->typecodes[left];
 1009|  55.1k|            container_t *c1 = ra1->containers[left];
 1010|  55.1k|            uint8_t type2 = ra2->typecodes[right];
 1011|  55.1k|            container_t *c2 = ra2->containers[right];
 1012|  55.1k|            if (is_xor) {
  ------------------
  |  Branch (1012:17): [True: 55.1k, False: 0]
  ------------------
 1013|  55.1k|                container_t *c;
 1014|  55.1k|                if (type1 == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|  55.1k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (1014:21): [True: 0, False: 55.1k]
  ------------------
 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.1k|                } else {
 1018|  55.1k|                    c = container_ixor(c1, type1, c2, type2, &result_type);
 1019|  55.1k|                }
 1020|  55.1k|                if (container_nonzero_cardinality(c, result_type)) {
  ------------------
  |  Branch (1020:21): [True: 0, False: 55.1k]
  ------------------
 1021|      0|                    ra_append(&merged, k1, c, result_type);
 1022|  55.1k|                } else {
 1023|  55.1k|                    container_free(c, result_type);
 1024|  55.1k|                }
 1025|  55.1k|            } 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.1k|            left++;
 1040|  55.1k|            right++;
 1041|  55.1k|        }
 1042|  55.2k|    }
 1043|  2.27k|    for (; left < length1; left++) {
  ------------------
  |  Branch (1043:12): [True: 0, False: 2.27k]
  ------------------
 1044|      0|        ra_append(&merged, ra1->keys[left], ra1->containers[left],
 1045|      0|                  ra1->typecodes[left]);
 1046|      0|    }
 1047|  2.27k|    for (; right < length2; right++) {
  ------------------
  |  Branch (1047:12): [True: 0, False: 2.27k]
  ------------------
 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.27k|    merged.flags = ra1->flags;
 1058|  2.27k|    ra_clear_without_containers(ra1);
 1059|  2.27k|    *ra1 = merged;
 1060|  2.27k|}
roaring.c:loadfirstvalue:
 1809|  18.6k|    roaring_uint32_iterator_t *newit) {
 1810|  18.6k|    if (iter_new_container_partial_init(newit)) {
  ------------------
  |  Branch (1810:9): [True: 12.3k, False: 6.27k]
  ------------------
 1811|  12.3k|        uint16_t value = 0;
 1812|  12.3k|        newit->container_it =
 1813|  12.3k|            container_init_iterator(newit->container, newit->typecode, &value);
 1814|  12.3k|        newit->current_value = newit->highbits | value;
 1815|  12.3k|    }
 1816|  18.6k|    return newit->has_value;
 1817|  18.6k|}
roaring.c:iter_new_container_partial_init:
 1779|  24.7k|    roaring_uint32_iterator_t *newit) {
 1780|  24.7k|    newit->current_value = 0;
 1781|  24.7k|    if (newit->container_index >= newit->parent->high_low_container.size ||
  ------------------
  |  Branch (1781:9): [True: 6.27k, False: 18.5k]
  ------------------
 1782|  18.5k|        newit->container_index < 0) {
  ------------------
  |  Branch (1782:9): [True: 0, False: 18.5k]
  ------------------
 1783|  6.27k|        newit->current_value = UINT32_MAX;
 1784|  6.27k|        return (newit->has_value = false);
 1785|  6.27k|    }
 1786|  18.5k|    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.5k|    newit->container =
 1792|  18.5k|        newit->parent->high_low_container.containers[newit->container_index];
 1793|  18.5k|    newit->typecode =
 1794|  18.5k|        newit->parent->high_low_container.typecodes[newit->container_index];
 1795|  18.5k|    newit->highbits =
 1796|  18.5k|        ((uint32_t)
 1797|  18.5k|             newit->parent->high_low_container.keys[newit->container_index])
 1798|  18.5k|        << 16;
 1799|  18.5k|    newit->container =
 1800|  18.5k|        container_unwrap_shared(newit->container, &(newit->typecode));
 1801|       |    return true;
 1802|  24.7k|}
roaring.c:loadfirstvalue_largeorequal:
 1840|  6.17k|    roaring_uint32_iterator_t *newit, uint32_t val) {
 1841|  6.17k|    bool partial_init = iter_new_container_partial_init(newit);
 1842|  6.17k|    assert(partial_init);
 1843|  6.17k|    if (!partial_init) {
  ------------------
  |  Branch (1843:9): [True: 0, False: 6.17k]
  ------------------
 1844|      0|        return false;
 1845|      0|    }
 1846|  6.17k|    uint16_t value = 0;
 1847|  6.17k|    newit->container_it =
 1848|  6.17k|        container_init_iterator(newit->container, newit->typecode, &value);
 1849|  6.17k|    bool found = container_iterator_lower_bound(
 1850|  6.17k|        newit->container, newit->typecode, &newit->container_it, &value,
 1851|  6.17k|        val & 0xFFFF);
 1852|  6.17k|    assert(found);
 1853|  6.17k|    if (!found) {
  ------------------
  |  Branch (1853:9): [True: 0, False: 6.17k]
  ------------------
 1854|      0|        return false;
 1855|      0|    }
 1856|  6.17k|    newit->current_value = newit->highbits | value;
 1857|       |    return true;
 1858|  6.17k|}
roaring.c:inplace_flip_container:
 2214|  6.95k|                                   uint16_t lb_start, uint16_t lb_end) {
 2215|  6.95k|    const int i = ra_get_index(x1_arr, hb);
 2216|  6.95k|    uint8_t ctype_in, ctype_out;
 2217|  6.95k|    container_t *flipped_container = NULL;
 2218|  6.95k|    if (i >= 0) {
  ------------------
  |  Branch (2218:9): [True: 6.45k, False: 504]
  ------------------
 2219|  6.45k|        container_t *container_to_flip =
 2220|  6.45k|            ra_get_container_at_index(x1_arr, (uint16_t)i, &ctype_in);
 2221|  6.45k|        flipped_container = container_inot_range(
 2222|  6.45k|            container_to_flip, ctype_in, (uint32_t)lb_start,
 2223|  6.45k|            (uint32_t)(lb_end + 1), &ctype_out);
 2224|       |        // if a new container was created, the old one was already freed
 2225|  6.45k|        if (container_nonzero_cardinality(flipped_container, ctype_out)) {
  ------------------
  |  Branch (2225:13): [True: 6.42k, False: 23]
  ------------------
 2226|  6.42k|            ra_set_container_at_index(x1_arr, i, flipped_container, ctype_out);
 2227|  6.42k|        } else {
 2228|     23|            container_free(flipped_container, ctype_out);
 2229|     23|            ra_remove_at_index(x1_arr, i);
 2230|     23|        }
 2231|       |
 2232|  6.45k|    } else {
 2233|    504|        flipped_container = container_range_of_ones(
 2234|    504|            (uint32_t)lb_start, (uint32_t)(lb_end + 1), &ctype_out);
 2235|    504|        ra_insert_new_key_value_at(x1_arr, -i - 1, hb, flipped_container,
 2236|    504|                                   ctype_out);
 2237|    504|    }
 2238|  6.95k|}
roaring.c:inplace_fully_flip_container:
 2265|  23.2k|static void inplace_fully_flip_container(roaring_array_t *x1_arr, uint16_t hb) {
 2266|  23.2k|    const int i = ra_get_index(x1_arr, hb);
 2267|  23.2k|    uint8_t ctype_in, ctype_out;
 2268|  23.2k|    container_t *flipped_container = NULL;
 2269|  23.2k|    if (i >= 0) {
  ------------------
  |  Branch (2269:9): [True: 6.84k, False: 16.3k]
  ------------------
 2270|  6.84k|        container_t *container_to_flip =
 2271|  6.84k|            ra_get_container_at_index(x1_arr, (uint16_t)i, &ctype_in);
 2272|  6.84k|        flipped_container =
 2273|  6.84k|            container_inot(container_to_flip, ctype_in, &ctype_out);
 2274|       |
 2275|  6.84k|        if (container_nonzero_cardinality(flipped_container, ctype_out)) {
  ------------------
  |  Branch (2275:13): [True: 495, False: 6.35k]
  ------------------
 2276|    495|            ra_set_container_at_index(x1_arr, i, flipped_container, ctype_out);
 2277|  6.35k|        } else {
 2278|  6.35k|            container_free(flipped_container, ctype_out);
 2279|  6.35k|            ra_remove_at_index(x1_arr, i);
 2280|  6.35k|        }
 2281|       |
 2282|  16.3k|    } else {
 2283|  16.3k|        flipped_container = container_range_of_ones(0U, 0x10000U, &ctype_out);
 2284|  16.3k|        ra_insert_new_key_value_at(x1_arr, -i - 1, hb, flipped_container,
 2285|  16.3k|                                   ctype_out);
 2286|  16.3k|    }
 2287|  23.2k|}

ra_init_with_capacity:
   80|  64.7k|bool ra_init_with_capacity(roaring_array_t *new_ra, uint32_t cap) {
   81|  64.7k|    if (!new_ra) return false;
  ------------------
  |  Branch (81:9): [True: 0, False: 64.7k]
  ------------------
   82|  64.7k|    ra_init(new_ra);
   83|       |
   84|       |    // Containers hold 64Ki elements, so 64Ki containers is enough to hold
   85|       |    // `0x10000 * 0x10000` (all 2^32) elements
   86|  64.7k|    if (cap > 0x10000) {
  ------------------
  |  Branch (86:9): [True: 0, False: 64.7k]
  ------------------
   87|      0|        cap = 0x10000;
   88|      0|    }
   89|       |
   90|  64.7k|    if (cap > 0) {
  ------------------
  |  Branch (90:9): [True: 33.4k, False: 31.2k]
  ------------------
   91|  33.4k|        void *bigalloc = roaring_malloc(
   92|  33.4k|            cap * (sizeof(uint16_t) + sizeof(container_t *) + sizeof(uint8_t)));
   93|  33.4k|        if (bigalloc == NULL) return false;
  ------------------
  |  Branch (93:13): [True: 0, False: 33.4k]
  ------------------
   94|  33.4k|        new_ra->containers = (container_t **)bigalloc;
   95|  33.4k|        new_ra->keys = (uint16_t *)(new_ra->containers + cap);
   96|  33.4k|        new_ra->typecodes = (uint8_t *)(new_ra->keys + cap);
   97|       |        // Narrowing is safe because of above check
   98|  33.4k|        new_ra->allocation_size = (int32_t)cap;
   99|  33.4k|    }
  100|  64.7k|    return true;
  101|  64.7k|}
ra_shrink_to_fit:
  103|  68.7k|int ra_shrink_to_fit(roaring_array_t *ra) {
  104|  68.7k|    int savings = (ra->allocation_size - ra->size) *
  105|  68.7k|                  (sizeof(uint16_t) + sizeof(container_t *) + sizeof(uint8_t));
  106|  68.7k|    if (!realloc_array(ra, ra->size)) {
  ------------------
  |  Branch (106:9): [True: 0, False: 68.7k]
  ------------------
  107|      0|        return 0;
  108|      0|    }
  109|  68.7k|    ra->allocation_size = ra->size;
  110|  68.7k|    return savings;
  111|  68.7k|}
ra_init:
  113|  64.7k|void ra_init(roaring_array_t *new_ra) {
  114|  64.7k|    if (!new_ra) {
  ------------------
  |  Branch (114:9): [True: 0, False: 64.7k]
  ------------------
  115|      0|        return;
  116|      0|    }
  117|  64.7k|    new_ra->keys = NULL;
  118|  64.7k|    new_ra->containers = NULL;
  119|  64.7k|    new_ra->typecodes = NULL;
  120|       |
  121|  64.7k|    new_ra->allocation_size = 0;
  122|  64.7k|    new_ra->size = 0;
  123|  64.7k|    new_ra->flags = 0;
  124|  64.7k|}
ra_overwrite:
  127|  14.1k|                  bool copy_on_write) {
  128|  14.1k|    ra_clear_containers(dest);  // we are going to overwrite them
  129|  14.1k|    if (source->size == 0) {    // Note: can't call memcpy(NULL), even w/size
  ------------------
  |  Branch (129:9): [True: 20, False: 14.1k]
  ------------------
  130|     20|        dest->size = 0;         // <--- This is important.
  131|     20|        return true;            // output was just cleared, so they match
  132|     20|    }
  133|  14.1k|    if (dest->allocation_size < source->size) {
  ------------------
  |  Branch (133:9): [True: 12.4k, False: 1.65k]
  ------------------
  134|  12.4k|        if (!realloc_array(dest, source->size)) {
  ------------------
  |  Branch (134:13): [True: 0, False: 12.4k]
  ------------------
  135|      0|            return false;
  136|      0|        }
  137|  12.4k|    }
  138|  14.1k|    dest->size = source->size;
  139|  14.1k|    memcpy(dest->keys, source->keys, dest->size * sizeof(uint16_t));
  140|       |    // we go through the containers, turning them into shared containers...
  141|  14.1k|    if (copy_on_write) {
  ------------------
  |  Branch (141:9): [True: 0, False: 14.1k]
  ------------------
  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.1k|    } else {
  152|  14.1k|        memcpy(dest->typecodes, source->typecodes,
  153|  14.1k|               dest->size * sizeof(uint8_t));
  154|   163k|        for (int32_t i = 0; i < dest->size; i++) {
  ------------------
  |  Branch (154:29): [True: 149k, False: 14.1k]
  ------------------
  155|   149k|            dest->containers[i] =
  156|   149k|                container_clone(source->containers[i], source->typecodes[i]);
  157|   149k|            if (dest->containers[i] == NULL) {
  ------------------
  |  Branch (157:17): [True: 0, False: 149k]
  ------------------
  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|   149k|        }
  165|  14.1k|    }
  166|  14.1k|    return true;
  167|  14.1k|}
ra_clear_containers:
  169|  76.6k|void ra_clear_containers(roaring_array_t *ra) {
  170|   516k|    for (int32_t i = 0; i < ra->size; ++i) {
  ------------------
  |  Branch (170:25): [True: 440k, False: 76.6k]
  ------------------
  171|   440k|        container_free(ra->containers[i], ra->typecodes[i]);
  172|   440k|    }
  173|  76.6k|}
ra_reset:
  175|  62.4k|void ra_reset(roaring_array_t *ra) {
  176|  62.4k|    ra_clear_containers(ra);
  177|  62.4k|    ra->size = 0;
  178|  62.4k|    ra_shrink_to_fit(ra);
  179|  62.4k|}
ra_clear_without_containers:
  181|  2.31k|void ra_clear_without_containers(roaring_array_t *ra) {
  182|  2.31k|    roaring_free(
  183|  2.31k|        ra->containers);  // keys and typecodes are allocated with containers
  184|  2.31k|    ra->size = 0;
  185|  2.31k|    ra->allocation_size = 0;
  186|  2.31k|    ra->containers = NULL;
  187|  2.31k|    ra->keys = NULL;
  188|       |    ra->typecodes = NULL;
  189|  2.31k|}
ra_clear:
  191|     38|void ra_clear(roaring_array_t *ra) {
  192|     38|    ra_clear_containers(ra);
  193|     38|    ra_clear_without_containers(ra);
  194|     38|}
extend_array:
  196|  85.1k|bool extend_array(roaring_array_t *ra, int32_t k) {
  197|  85.1k|    int32_t desired_size = ra->size + k;
  198|  85.1k|    const int32_t max_containers = 65536;
  199|  85.1k|    assert(desired_size <= max_containers);
  200|  85.1k|    if (desired_size > ra->allocation_size) {
  ------------------
  |  Branch (200:9): [True: 17.5k, False: 67.5k]
  ------------------
  201|  17.5k|        int32_t new_capacity =
  202|  17.5k|            (ra->size < 1024) ? 2 * desired_size : 5 * desired_size / 4;
  ------------------
  |  Branch (202:13): [True: 17.5k, False: 0]
  ------------------
  203|  17.5k|        if (new_capacity > max_containers) {
  ------------------
  |  Branch (203:13): [True: 0, False: 17.5k]
  ------------------
  204|      0|            new_capacity = max_containers;
  205|      0|        }
  206|       |
  207|  17.5k|        return realloc_array(ra, new_capacity);
  208|  17.5k|    }
  209|  67.5k|    return true;
  210|  85.1k|}
ra_append:
  213|  26.1k|               uint8_t typecode) {
  214|  26.1k|    extend_array(ra, 1);
  215|  26.1k|    const int32_t pos = ra->size;
  216|       |
  217|  26.1k|    ra->keys[pos] = key;
  218|  26.1k|    ra->containers[pos] = c;
  219|  26.1k|    ra->typecodes[pos] = typecode;
  220|  26.1k|    ra->size++;
  221|  26.1k|}
ra_append_copy_range:
  254|  25.1k|                          bool copy_on_write) {
  255|  25.1k|    extend_array(ra, end_index - start_index);
  256|   196k|    for (int32_t i = start_index; i < end_index; ++i) {
  ------------------
  |  Branch (256:35): [True: 171k, False: 25.1k]
  ------------------
  257|   171k|        const int32_t pos = ra->size;
  258|   171k|        ra->keys[pos] = sa->keys[i];
  259|   171k|        if (copy_on_write) {
  ------------------
  |  Branch (259:13): [True: 0, False: 171k]
  ------------------
  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|   171k|        } else {
  265|   171k|            ra->containers[pos] =
  266|   171k|                container_clone(sa->containers[i], sa->typecodes[i]);
  267|   171k|            ra->typecodes[pos] = sa->typecodes[i];
  268|   171k|        }
  269|   171k|        ra->size++;
  270|   171k|    }
  271|  25.1k|}
ra_advance_until_freeing:
  340|     67|int32_t ra_advance_until_freeing(roaring_array_t *ra, uint16_t x, int32_t pos) {
  341|    134|    while (pos < ra->size && ra->keys[pos] < x) {
  ------------------
  |  Branch (341:12): [True: 134, False: 0]
  |  Branch (341:30): [True: 67, False: 67]
  ------------------
  342|     67|        container_free(ra->containers[pos], ra->typecodes[pos]);
  343|     67|        ++pos;
  344|     67|    }
  345|     67|    return pos;
  346|     67|}
ra_insert_new_key_value_at:
  349|  32.5k|                                container_t *c, uint8_t typecode) {
  350|  32.5k|    extend_array(ra, 1);
  351|       |    // May be an optimization opportunity with DIY memmove
  352|  32.5k|    memmove(&(ra->keys[i + 1]), &(ra->keys[i]),
  353|  32.5k|            sizeof(uint16_t) * (ra->size - i));
  354|  32.5k|    memmove(&(ra->containers[i + 1]), &(ra->containers[i]),
  355|  32.5k|            sizeof(container_t *) * (ra->size - i));
  356|  32.5k|    memmove(&(ra->typecodes[i + 1]), &(ra->typecodes[i]),
  357|  32.5k|            sizeof(uint8_t) * (ra->size - i));
  358|  32.5k|    ra->keys[i] = key;
  359|  32.5k|    ra->containers[i] = c;
  360|  32.5k|    ra->typecodes[i] = typecode;
  361|  32.5k|    ra->size++;
  362|  32.5k|}
ra_downsize:
  369|  12.0k|void ra_downsize(roaring_array_t *ra, int32_t new_length) {
  370|       |    assert(new_length <= ra->size);
  371|  12.0k|    ra->size = new_length;
  372|  12.0k|}
ra_remove_at_index:
  374|  6.43k|void ra_remove_at_index(roaring_array_t *ra, int32_t i) {
  375|  6.43k|    memmove(&(ra->containers[i]), &(ra->containers[i + 1]),
  376|  6.43k|            sizeof(container_t *) * (ra->size - i - 1));
  377|  6.43k|    memmove(&(ra->keys[i]), &(ra->keys[i + 1]),
  378|  6.43k|            sizeof(uint16_t) * (ra->size - i - 1));
  379|  6.43k|    memmove(&(ra->typecodes[i]), &(ra->typecodes[i + 1]),
  380|  6.43k|            sizeof(uint8_t) * (ra->size - i - 1));
  381|  6.43k|    ra->size--;
  382|  6.43k|}
ra_remove_at_index_and_free:
  384|     59|void ra_remove_at_index_and_free(roaring_array_t *ra, int32_t i) {
  385|     59|    container_free(ra->containers[i], ra->typecodes[i]);
  386|     59|    ra_remove_at_index(ra, i);
  387|     59|}
ra_copy_range:
  395|     38|                   uint32_t new_begin) {
  396|     38|    assert(begin <= end);
  397|     38|    assert(new_begin < begin);
  398|       |
  399|     38|    const int range = end - begin;
  400|       |
  401|       |    // We ensure to previously have freed overwritten containers
  402|       |    // that are not copied elsewhere
  403|       |
  404|     38|    memmove(&(ra->containers[new_begin]), &(ra->containers[begin]),
  405|     38|            sizeof(container_t *) * range);
  406|     38|    memmove(&(ra->keys[new_begin]), &(ra->keys[begin]),
  407|     38|            sizeof(uint16_t) * range);
  408|     38|    memmove(&(ra->typecodes[new_begin]), &(ra->typecodes[begin]),
  409|     38|            sizeof(uint8_t) * range);
  410|     38|}
ra_shift_tail:
  412|  1.85k|void ra_shift_tail(roaring_array_t *ra, int32_t count, int32_t distance) {
  413|  1.85k|    if (distance > 0) {
  ------------------
  |  Branch (413:9): [True: 1.24k, False: 615]
  ------------------
  414|  1.24k|        extend_array(ra, distance);
  415|  1.24k|    }
  416|  1.85k|    int32_t srcpos = ra->size - count;
  417|  1.85k|    int32_t dstpos = srcpos + distance;
  418|  1.85k|    memmove(&(ra->keys[dstpos]), &(ra->keys[srcpos]), sizeof(uint16_t) * count);
  419|  1.85k|    memmove(&(ra->containers[dstpos]), &(ra->containers[srcpos]),
  420|  1.85k|            sizeof(container_t *) * count);
  421|  1.85k|    memmove(&(ra->typecodes[dstpos]), &(ra->typecodes[srcpos]),
  422|  1.85k|            sizeof(uint8_t) * count);
  423|  1.85k|    ra->size += distance;
  424|  1.85k|}
ra_to_uint32_array:
  426|  6.24k|void ra_to_uint32_array(const roaring_array_t *ra, uint32_t *ans) {
  427|  6.24k|    size_t ctr = 0;
  428|  69.5k|    for (int32_t i = 0; i < ra->size; ++i) {
  ------------------
  |  Branch (428:25): [True: 63.2k, False: 6.24k]
  ------------------
  429|  63.2k|        int num_added = container_to_uint32_array(
  430|  63.2k|            ans + ctr, ra->containers[i], ra->typecodes[i],
  431|  63.2k|            ((uint32_t)ra->keys[i]) << 16);
  432|  63.2k|        ctr += num_added;
  433|  63.2k|    }
  434|  6.24k|}
ra_has_run_container:
  436|  18.7k|bool ra_has_run_container(const roaring_array_t *ra) {
  437|   170k|    for (int32_t k = 0; k < ra->size; ++k) {
  ------------------
  |  Branch (437:25): [True: 153k, False: 16.1k]
  ------------------
  438|   153k|        if (get_container_type(ra->containers[k], ra->typecodes[k]) ==
  ------------------
  |  Branch (438:13): [True: 2.54k, False: 151k]
  ------------------
  439|   153k|            RUN_CONTAINER_TYPE)
  ------------------
  |  |   50|   153k|#define RUN_CONTAINER_TYPE 3
  ------------------
  440|  2.54k|            return true;
  441|   153k|    }
  442|  16.1k|    return false;
  443|  18.7k|}
ra_portable_header_size:
  445|  12.4k|uint32_t ra_portable_header_size(const roaring_array_t *ra) {
  446|  12.4k|    if (ra_has_run_container(ra)) {
  ------------------
  |  Branch (446:9): [True: 2.54k, False: 9.94k]
  ------------------
  447|  2.54k|        if (ra->size <
  ------------------
  |  Branch (447:13): [True: 2.54k, False: 0]
  ------------------
  448|  2.54k|            NO_OFFSET_THRESHOLD) {  // for small bitmaps, we omit the offsets
  449|  2.54k|            return 4 + (ra->size + 7) / 8 + 4 * ra->size;
  450|  2.54k|        }
  451|      0|        return 4 + (ra->size + 7) / 8 +
  452|      0|               8 * ra->size;  // - 4 because we pack the size with the cookie
  453|  9.94k|    } else {
  454|  9.94k|        return 4 + 4 + 8 * ra->size;
  455|  9.94k|    }
  456|  12.4k|}
ra_portable_size_in_bytes:
  458|  12.4k|size_t ra_portable_size_in_bytes(const roaring_array_t *ra) {
  459|  12.4k|    size_t count = ra_portable_header_size(ra);
  460|       |
  461|  92.5k|    for (int32_t k = 0; k < ra->size; ++k) {
  ------------------
  |  Branch (461:25): [True: 80.0k, False: 12.4k]
  ------------------
  462|  80.0k|        count += container_size_in_bytes(ra->containers[k], ra->typecodes[k]);
  463|  80.0k|    }
  464|  12.4k|    return count;
  465|  12.4k|}
ra_portable_serialize:
  469|  6.24k|size_t ra_portable_serialize(const roaring_array_t *ra, char *buf) {
  470|  6.24k|    char *initbuf = buf;
  471|  6.24k|    uint32_t startOffset = 0;
  472|  6.24k|    bool hasrun = ra_has_run_container(ra);
  473|  6.24k|    if (hasrun) {
  ------------------
  |  Branch (473:9): [True: 0, False: 6.24k]
  ------------------
  474|      0|        uint32_t cookie = SERIAL_COOKIE | ((uint32_t)(ra->size - 1) << 16);
  475|      0|        uint32_t cookie_le = croaring_htole32(cookie);
  ------------------
  |  |  518|      0|#define croaring_htole32(x) (x)
  ------------------
  476|      0|        memcpy(buf, &cookie_le, sizeof(cookie_le));
  477|      0|        buf += sizeof(cookie_le);
  478|      0|        uint32_t s = (ra->size + 7) / 8;
  479|      0|        memset(buf, 0, s);
  480|      0|        for (int32_t i = 0; i < ra->size; ++i) {
  ------------------
  |  Branch (480:29): [True: 0, False: 0]
  ------------------
  481|      0|            if (get_container_type(ra->containers[i], ra->typecodes[i]) ==
  ------------------
  |  Branch (481:17): [True: 0, False: 0]
  ------------------
  482|      0|                RUN_CONTAINER_TYPE) {
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
  483|      0|                buf[i / 8] |= 1 << (i % 8);
  484|      0|            }
  485|      0|        }
  486|      0|        buf += s;
  487|      0|        if (ra->size < NO_OFFSET_THRESHOLD) {
  ------------------
  |  Branch (487:13): [True: 0, False: 0]
  ------------------
  488|      0|            startOffset = 4 + 4 * ra->size + s;
  489|      0|        } else {
  490|      0|            startOffset = 4 + 8 * ra->size + s;
  491|      0|        }
  492|  6.24k|    } else {  // backwards compatibility
  493|  6.24k|        uint32_t cookie = SERIAL_COOKIE_NO_RUNCONTAINER;
  494|  6.24k|        uint32_t cookie_le = croaring_htole32(cookie);
  ------------------
  |  |  518|  6.24k|#define croaring_htole32(x) (x)
  ------------------
  495|  6.24k|        memcpy(buf, &cookie_le, sizeof(cookie_le));
  496|  6.24k|        buf += sizeof(cookie_le);
  497|  6.24k|        uint32_t size_le = croaring_htole32((uint32_t)ra->size);
  ------------------
  |  |  518|  6.24k|#define croaring_htole32(x) (x)
  ------------------
  498|  6.24k|        memcpy(buf, &size_le, sizeof(size_le));
  499|  6.24k|        buf += sizeof(size_le);
  500|       |
  501|  6.24k|        startOffset = 4 + 4 + 4 * ra->size + 4 * ra->size;
  502|  6.24k|    }
  503|  80.0k|    for (int32_t k = 0; k < ra->size; ++k) {
  ------------------
  |  Branch (503:25): [True: 73.8k, False: 6.24k]
  ------------------
  504|  73.8k|        uint16_t key_le = croaring_htole16(ra->keys[k]);
  ------------------
  |  |  517|  73.8k|#define croaring_htole16(x) (x)
  ------------------
  505|  73.8k|        memcpy(buf, &key_le, sizeof(key_le));
  506|  73.8k|        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|  73.8k|        uint16_t card = (uint16_t)(container_get_cardinality(ra->containers[k],
  510|  73.8k|                                                             ra->typecodes[k]) -
  511|  73.8k|                                   1);
  512|  73.8k|        uint16_t card_le = croaring_htole16(card);
  ------------------
  |  |  517|  73.8k|#define croaring_htole16(x) (x)
  ------------------
  513|  73.8k|        memcpy(buf, &card_le, sizeof(card_le));
  514|  73.8k|        buf += sizeof(card_le);
  515|  73.8k|    }
  516|  6.24k|    if ((!hasrun) || (ra->size >= NO_OFFSET_THRESHOLD)) {
  ------------------
  |  Branch (516:9): [True: 6.24k, False: 0]
  |  Branch (516:22): [True: 0, False: 0]
  ------------------
  517|       |        // writing the containers offsets
  518|  80.0k|        for (int32_t k = 0; k < ra->size; k++) {
  ------------------
  |  Branch (518:29): [True: 73.8k, False: 6.24k]
  ------------------
  519|  73.8k|            uint32_t off_le = croaring_htole32(startOffset);
  ------------------
  |  |  518|  73.8k|#define croaring_htole32(x) (x)
  ------------------
  520|  73.8k|            memcpy(buf, &off_le, sizeof(off_le));
  521|  73.8k|            buf += sizeof(off_le);
  522|  73.8k|            startOffset =
  523|  73.8k|                startOffset +
  524|  73.8k|                container_size_in_bytes(ra->containers[k], ra->typecodes[k]);
  525|  73.8k|        }
  526|  6.24k|    }
  527|  80.0k|    for (int32_t k = 0; k < ra->size; ++k) {
  ------------------
  |  Branch (527:25): [True: 73.8k, False: 6.24k]
  ------------------
  528|  73.8k|        buf += container_write(ra->containers[k], ra->typecodes[k], buf);
  529|  73.8k|    }
  530|  6.24k|    return buf - initbuf;
  531|  6.24k|}
ra_portable_deserialize:
  634|  12.4k|                             const size_t maxbytes, size_t *readbytes) {
  635|  12.4k|    *readbytes = sizeof(int32_t);  // for cookie
  636|  12.4k|    if (*readbytes > maxbytes) {
  ------------------
  |  Branch (636:9): [True: 5.86k, False: 6.62k]
  ------------------
  637|       |        // Ran out of bytes while reading first 4 bytes.
  638|  5.86k|        return false;
  639|  5.86k|    }
  640|  6.62k|    uint32_t cookie;
  641|  6.62k|    memcpy(&cookie, buf, sizeof(int32_t));
  642|  6.62k|    cookie = croaring_letoh32(cookie);
  ------------------
  |  |  524|  6.62k|#define croaring_letoh32(x) croaring_htole32(x)
  |  |  ------------------
  |  |  |  |  518|  6.62k|#define croaring_htole32(x) (x)
  |  |  ------------------
  ------------------
  643|  6.62k|    buf += sizeof(uint32_t);
  644|  6.62k|    if ((cookie & 0xFFFF) != SERIAL_COOKIE &&
  ------------------
  |  Branch (644:9): [True: 6.55k, False: 76]
  ------------------
  645|  6.55k|        cookie != SERIAL_COOKIE_NO_RUNCONTAINER) {
  ------------------
  |  Branch (645:9): [True: 241, False: 6.31k]
  ------------------
  646|       |        // "I failed to find one of the right cookies.
  647|    241|        return false;
  648|    241|    }
  649|  6.38k|    int32_t size;
  650|       |
  651|  6.38k|    if ((cookie & 0xFFFF) == SERIAL_COOKIE)
  ------------------
  |  Branch (651:9): [True: 76, False: 6.31k]
  ------------------
  652|     76|        size = (cookie >> 16) + 1;
  653|  6.31k|    else {
  654|  6.31k|        *readbytes += sizeof(int32_t);
  655|  6.31k|        if (*readbytes > maxbytes) {
  ------------------
  |  Branch (655:13): [True: 2, False: 6.30k]
  ------------------
  656|       |            // Ran out of bytes while reading second part of the cookie.
  657|      2|            return false;
  658|      2|        }
  659|  6.30k|        uint32_t size_le;
  660|  6.30k|        memcpy(&size_le, buf, sizeof(int32_t));
  661|  6.30k|        size = (int32_t)croaring_letoh32(size_le);
  ------------------
  |  |  524|  6.30k|#define croaring_letoh32(x) croaring_htole32(x)
  |  |  ------------------
  |  |  |  |  518|  6.30k|#define croaring_htole32(x) (x)
  |  |  ------------------
  ------------------
  662|  6.30k|        buf += sizeof(uint32_t);
  663|  6.30k|    }
  664|  6.38k|    if (size < 0) {
  ------------------
  |  Branch (664:9): [True: 18, False: 6.36k]
  ------------------
  665|       |        // You cannot have a negative number of containers, the data must be
  666|       |        // corrupted.
  667|     18|        return false;
  668|     18|    }
  669|  6.36k|    if (size > (1 << 16)) {
  ------------------
  |  Branch (669:9): [True: 16, False: 6.35k]
  ------------------
  670|       |        // You cannot have so many containers, the data must be corrupted.
  671|     16|        return false;
  672|     16|    }
  673|  6.35k|    const char *bitmapOfRunContainers = NULL;
  674|  6.35k|    bool hasrun = (cookie & 0xFFFF) == SERIAL_COOKIE;
  675|  6.35k|    if (hasrun) {
  ------------------
  |  Branch (675:9): [True: 76, False: 6.27k]
  ------------------
  676|     76|        int32_t s = (size + 7) / 8;
  677|     76|        *readbytes += s;
  678|     76|        if (*readbytes > maxbytes) {  // data is corrupted?
  ------------------
  |  Branch (678:13): [True: 22, False: 54]
  ------------------
  679|       |            // Ran out of bytes while reading run bitmap.
  680|     22|            return false;
  681|     22|        }
  682|     54|        bitmapOfRunContainers = buf;
  683|     54|        buf += s;
  684|     54|    }
  685|  6.32k|    const char *keyscards = buf;
  686|       |
  687|  6.32k|    *readbytes += size * 2 * sizeof(uint16_t);
  688|  6.32k|    if (*readbytes > maxbytes) {
  ------------------
  |  Branch (688:9): [True: 32, False: 6.29k]
  ------------------
  689|       |        // Ran out of bytes while reading key-cardinality array.
  690|     32|        return false;
  691|     32|    }
  692|  6.29k|    buf += size * 2 * sizeof(uint16_t);
  693|       |
  694|  6.29k|    bool is_ok = ra_init_with_capacity(answer, size);
  695|  6.29k|    if (!is_ok) {
  ------------------
  |  Branch (695:9): [True: 0, False: 6.29k]
  ------------------
  696|       |        // Failed to allocate memory for roaring array. Bailing out.
  697|      0|        return false;
  698|      0|    }
  699|       |
  700|  80.3k|    for (int32_t k = 0; k < size; ++k) {
  ------------------
  |  Branch (700:25): [True: 74.0k, False: 6.29k]
  ------------------
  701|  74.0k|        uint16_t tmp;
  702|  74.0k|        memcpy(&tmp, keyscards + 4 * k, sizeof(tmp));
  703|  74.0k|        answer->keys[k] = croaring_letoh16(tmp);
  ------------------
  |  |  523|  74.0k|#define croaring_letoh16(x) croaring_htole16(x)
  |  |  ------------------
  |  |  |  |  517|  74.0k|#define croaring_htole16(x) (x)
  |  |  ------------------
  ------------------
  704|  74.0k|    }
  705|  6.29k|    if ((!hasrun) || (size >= NO_OFFSET_THRESHOLD)) {
  ------------------
  |  Branch (705:9): [True: 6.25k, False: 45]
  |  Branch (705:22): [True: 21, False: 24]
  ------------------
  706|  6.27k|        *readbytes += size * 4;
  707|  6.27k|        if (*readbytes > maxbytes) {  // data is corrupted?
  ------------------
  |  Branch (707:13): [True: 9, False: 6.26k]
  ------------------
  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.26k|        buf += size * 4;
  716|  6.26k|    }
  717|       |    // Reading the containers
  718|  80.1k|    for (int32_t k = 0; k < size; ++k) {
  ------------------
  |  Branch (718:25): [True: 73.9k, False: 6.25k]
  ------------------
  719|  73.9k|        uint16_t tmp;
  720|  73.9k|        memcpy(&tmp, keyscards + 4 * k + 2, sizeof(tmp));
  721|  73.9k|        tmp = croaring_letoh16(tmp);
  ------------------
  |  |  523|  73.9k|#define croaring_letoh16(x) croaring_htole16(x)
  |  |  ------------------
  |  |  |  |  517|  73.9k|#define croaring_htole16(x) (x)
  |  |  ------------------
  ------------------
  722|  73.9k|        uint32_t thiscard = tmp + 1;
  723|  73.9k|        bool isbitmap = (thiscard > DEFAULT_MAX_SIZE);
  724|  73.9k|        bool isrun = false;
  725|  73.9k|        if (hasrun) {
  ------------------
  |  Branch (725:13): [True: 123, False: 73.8k]
  ------------------
  726|    123|            if ((bitmapOfRunContainers[k / 8] & (1 << (k % 8))) != 0) {
  ------------------
  |  Branch (726:17): [True: 64, False: 59]
  ------------------
  727|     64|                isbitmap = false;
  728|     64|                isrun = true;
  729|     64|            }
  730|    123|        }
  731|  73.9k|        if (isbitmap) {
  ------------------
  |  Branch (731:13): [True: 66.9k, False: 6.93k]
  ------------------
  732|       |            // we check that the read is allowed
  733|  66.9k|            size_t containersize =
  734|  66.9k|                BITSET_CONTAINER_SIZE_IN_WORDS * sizeof(uint64_t);
  735|  66.9k|            *readbytes += containersize;
  736|  66.9k|            if (*readbytes > maxbytes) {
  ------------------
  |  Branch (736:17): [True: 7, False: 66.9k]
  ------------------
  737|       |                // Running out of bytes while reading a bitset container.
  738|      7|                ra_clear(answer);  // we need to clear the containers already
  739|       |                                   // allocated, and the roaring array
  740|      7|                return false;
  741|      7|            }
  742|       |            // it is now safe to read
  743|  66.9k|            bitset_container_t *c = bitset_container_create_uninitialized();
  744|  66.9k|            if (c == NULL) {  // memory allocation failure
  ------------------
  |  Branch (744:17): [True: 0, False: 66.9k]
  ------------------
  745|       |                // Failed to allocate memory for a bitset container.
  746|      0|                ra_clear(answer);  // we need to clear the containers already
  747|       |                                   // allocated, and the roaring array
  748|      0|                return false;
  749|      0|            }
  750|  66.9k|            answer->size++;
  751|  66.9k|            buf += bitset_container_read(thiscard, c, buf);
  752|  66.9k|            answer->containers[k] = c;
  753|  66.9k|            answer->typecodes[k] = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|  66.9k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  754|  66.9k|        } else if (isrun) {
  ------------------
  |  Branch (754:20): [True: 64, False: 6.87k]
  ------------------
  755|       |            // we check that the read is allowed
  756|     64|            *readbytes += sizeof(uint16_t);
  757|     64|            if (*readbytes > maxbytes) {
  ------------------
  |  Branch (757:17): [True: 9, False: 55]
  ------------------
  758|       |                // Running out of bytes while reading a run container (header).
  759|      9|                ra_clear(answer);  // we need to clear the containers already
  760|       |                                   // allocated, and the roaring array
  761|      9|                return false;
  762|      9|            }
  763|     55|            uint16_t n_runs;
  764|     55|            memcpy(&n_runs, buf, sizeof(uint16_t));
  765|     55|            n_runs = croaring_letoh16(n_runs);
  ------------------
  |  |  523|     55|#define croaring_letoh16(x) croaring_htole16(x)
  |  |  ------------------
  |  |  |  |  517|     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|  6.87k|        } else {
  788|       |            // we check that the read is allowed
  789|  6.87k|            size_t containersize = thiscard * sizeof(uint16_t);
  790|  6.87k|            *readbytes += containersize;
  791|  6.87k|            if (*readbytes > maxbytes) {  // data is corrupted?
  ------------------
  |  Branch (791:17): [True: 7, False: 6.86k]
  ------------------
  792|       |                // Running out of bytes while reading an array container.
  793|      7|                ra_clear(answer);  // we need to clear the containers already
  794|       |                                   // allocated, and the roaring array
  795|      7|                return false;
  796|      7|            }
  797|       |            // it is now safe to read
  798|  6.86k|            array_container_t *c =
  799|  6.86k|                array_container_create_given_capacity(thiscard);
  800|  6.86k|            if (c == NULL) {  // memory allocation failure
  ------------------
  |  Branch (800:17): [True: 0, False: 6.86k]
  ------------------
  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|  6.86k|            answer->size++;
  807|  6.86k|            buf += array_container_read(thiscard, c, buf);
  808|  6.86k|            answer->containers[k] = c;
  809|  6.86k|            answer->typecodes[k] = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  6.86k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  810|  6.86k|        }
  811|  73.9k|    }
  812|  6.25k|    return true;
  813|  6.28k|}
roaring_array.c:realloc_array:
   42|  98.7k|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|  98.7k|    if (new_capacity == 0) {
  ------------------
  |  Branch (48:9): [True: 62.4k, False: 36.2k]
  ------------------
   49|  62.4k|        roaring_free(ra->containers);
   50|  62.4k|        ra->containers = NULL;
   51|  62.4k|        ra->keys = NULL;
   52|  62.4k|        ra->typecodes = NULL;
   53|  62.4k|        ra->allocation_size = 0;
   54|  62.4k|        return true;
   55|  62.4k|    }
   56|  36.2k|    const size_t memoryneeded =
   57|  36.2k|        new_capacity *
   58|  36.2k|        (sizeof(uint16_t) + sizeof(container_t *) + sizeof(uint8_t));
   59|  36.2k|    void *bigalloc = roaring_malloc(memoryneeded);
   60|  36.2k|    if (!bigalloc) return false;
  ------------------
  |  Branch (60:9): [True: 0, False: 36.2k]
  ------------------
   61|  36.2k|    void *oldbigalloc = ra->containers;
   62|  36.2k|    container_t **newcontainers = (container_t **)bigalloc;
   63|  36.2k|    uint16_t *newkeys = (uint16_t *)(newcontainers + new_capacity);
   64|  36.2k|    uint8_t *newtypecodes = (uint8_t *)(newkeys + new_capacity);
   65|  36.2k|    assert((char *)(newtypecodes + new_capacity) ==
   66|  36.2k|           (char *)bigalloc + memoryneeded);
   67|  36.2k|    if (ra->size > 0) {
  ------------------
  |  Branch (67:9): [True: 11.3k, False: 24.9k]
  ------------------
   68|  11.3k|        memcpy(newcontainers, ra->containers, sizeof(container_t *) * ra->size);
   69|  11.3k|        memcpy(newkeys, ra->keys, sizeof(uint16_t) * ra->size);
   70|  11.3k|        memcpy(newtypecodes, ra->typecodes, sizeof(uint8_t) * ra->size);
   71|  11.3k|    }
   72|  36.2k|    ra->containers = newcontainers;
   73|  36.2k|    ra->keys = newkeys;
   74|  36.2k|    ra->typecodes = newtypecodes;
   75|  36.2k|    ra->allocation_size = new_capacity;
   76|  36.2k|    roaring_free(oldbigalloc);
   77|       |    return true;
   78|  36.2k|}

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

